/* 网站监控报表 · 数据终端风格
   克制、高信息密度、单一数据主色，数字使用等宽字体保证纵向对齐。 */
:root {
  --bg: #0b0f14;
  --panel: #111721;
  --panel-2: #161f2b;
  --panel-3: #1b2532;
  --line: #202b38;
  --line-soft: #19222e;
  --text: #e7edf4;
  --text-2: #98a6b5;
  --text-3: #63717f;
  --accent: #46cfc0;
  --accent-soft: rgba(70, 207, 192, .12);
  --amber: #e0a458;
  --red: #e1606b;
  --blue: #6d8ff0;
  --violet: #a58ae0;
  --green: #4cc38a;
  --shadow: 0 8px 32px rgba(0, 0, 0, .24);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --r: 10px;
}
html[data-theme="light"] {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafb;
  --panel-3: #eef2f5;
  --line: #dde4ea;
  --line-soft: #e9eef2;
  --text: #17222e;
  --text-2: #5c6a78;
  --text-3: #8b98a5;
  --accent: #0d8c82;
  --accent-soft: rgba(13, 140, 130, .10);
  --amber: #b8792b;
  --red: #c8414d;
  --blue: #4166c4;
  --violet: #7a5cc0;
  --green: #23845b;
  --shadow: 0 10px 30px rgba(20, 40, 60, .10);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg:not(.sprite):not(.chart-svg):not(.spark) { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); }

.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

/* ---------- 侧栏 ---------- */
.sidebar { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 19px 18px 18px; border-bottom: 1px solid var(--line-soft); }
.brand-mark { width: 34px; height: 34px; border: 1px solid var(--accent); border-radius: 8px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 14px; font-weight: 650; letter-spacing: .01em; }
.brand-sub { font: 9px/1.6 var(--mono); letter-spacing: .18em; color: var(--text-3); margin-top: 1px; }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 10px; letter-spacing: .14em; color: var(--text-3); padding: 14px 10px 6px; text-transform: uppercase; }
.nav-group:first-child { padding-top: 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 7px; color: var(--text-2); cursor: pointer; margin-bottom: 2px; border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s; }
.nav-item svg { flex: none; opacity: .8; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(70, 207, 192, .18); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.side-foot { border-top: 1px solid var(--line-soft); padding: 12px 16px 14px; font-size: 11px; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.side-row.muted { color: var(--text-3); }
.side-row b { font-family: var(--mono); font-weight: 500; color: var(--text-2); }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; flex: none; box-shadow: 0 0 0 3px rgba(76, 195, 138, .14); animation: pulse 2.4s ease-in-out infinite; }
.dot-live.off { background: var(--text-3); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 14px 22px 13px; border-bottom: 1px solid var(--line); background: var(--panel); }
.crumb h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.crumb p { margin: 2px 0 0; font-size: 11px; color: var(--text-3); }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 0 9px; height: 32px; }
.field > span { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.field select, .field input { background: transparent; border: 0; outline: 0; height: 30px; font-size: 12px; min-width: 0; }
.field select { max-width: 165px; cursor: pointer; }
.field input[type="date"] { width: 116px; color-scheme: dark; font-family: var(--mono); font-size: 11px; }
html[data-theme="light"] .field input[type="date"] { color-scheme: light; }
.field:focus-within { border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--panel-2); height: 32px; }
.seg button { border: 0; background: transparent; padding: 0 10px; font-size: 11px; color: var(--text-2); border-right: 1px solid var(--line-soft); transition: .15s; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); background: var(--panel-3); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel-2); border-radius: 7px; color: var(--text-2); transition: .15s; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { margin: 14px 22px 0; padding: 9px 13px; border: 1px solid rgba(224, 164, 88, .3); background: rgba(224, 164, 88, .07); border-radius: 8px; font-size: 11.5px; color: var(--text-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner-tag { color: var(--amber); border: 1px solid rgba(224, 164, 88, .4); padding: 1px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; flex: none; }
.banner code { font-family: var(--mono); font-size: 10.5px; color: var(--text); }
.banner a { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ---------- 主区 ---------- */
.view { flex: 1; overflow-y: auto; padding: 18px 22px 34px; min-height: 0; }
.view::-webkit-scrollbar, .nav::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.view::-webkit-scrollbar-thumb, .nav::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 6px; border: 2px solid var(--bg); }
.statusbar { border-top: 1px solid var(--line); background: var(--panel); padding: 7px 22px; display: flex; justify-content: space-between; gap: 12px; font-size: 10.5px; color: var(--text-3); font-family: var(--mono); flex: none; }
.status-left { display: flex; align-items: center; gap: 7px; }
.status-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sep { opacity: .45; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 11px; }
.section-title h2 { margin: 0; font-size: 13px; font-weight: 650; }
.section-title span { font-size: 10.5px; color: var(--text-3); }
.section-title:first-child { margin-top: 2px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 12.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-head p { margin: 3px 0 0; font-size: 10.5px; color: var(--text-3); }
.card-head .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g-1-1-1 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 12px; position: relative; overflow: hidden; transition: border-color .18s, transform .18s; }
.kpi:hover { border-color: rgba(70, 207, 192, .35); transform: translateY(-1px); }
.kpi .lb { font-size: 10.5px; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; }
.kpi .hint { color: var(--text-3); font-size: 9.5px; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; cursor: help; }
.kpi .v { font: 600 27px/1.25 var(--mono); letter-spacing: -.045em; margin: 7px 0 3px; white-space: nowrap; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.kpi .sub { font-size: 10.5px; color: var(--text-3); display: flex; gap: 7px; align-items: center; }
.kpi .up { color: var(--red); font-family: var(--mono); }
.kpi .down { color: var(--green); font-family: var(--mono); }
.kpi .flat { color: var(--text-3); font-family: var(--mono); }
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 46%; height: 42px; opacity: .55; pointer-events: none; }

/* ---------- 图表 ---------- */
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-wrap { min-height: 180px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 10.5px; color: var(--text-2); margin-top: 10px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.ax { fill: var(--text-3); font: 10px var(--mono); }
.gridline { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; background: var(--panel-3); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font: 11px/1.6 var(--mono); color: var(--text); box-shadow: var(--shadow); white-space: nowrap; }
.chart-tip b { color: var(--accent); font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-wrap > svg { width: 168px; height: 168px; flex: none; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 140px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 11.5px; border-bottom: 1px solid var(--line-soft); }
.donut-legend li:last-child { border-bottom: 0; }
.donut-legend i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.donut-legend .nm { flex: 1; color: var(--text-2); }
.donut-legend .vl { font-family: var(--mono); font-weight: 600; }
.donut-legend .pc { font-family: var(--mono); color: var(--text-3); min-width: 46px; text-align: right; }
.segbar { height: 9px; border-radius: 5px; overflow: hidden; display: flex; background: var(--panel-3); }
.segbar > span { height: 100%; transition: width .3s; }
.segbar-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 10.5px; color: var(--text-2); }
.segbar-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 10.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); position: sticky; top: 0; z-index: 1; }
table.data td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data .num { font-family: var(--mono); text-align: right; }
table.data .mono { font-family: var(--mono); font-size: 11.5px; }
table.data .truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
table.data .site-cell { font-weight: 600; }
.rank { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--panel-3); color: var(--text-3); font: 10px var(--mono); }
.rank.top { background: var(--accent-soft); color: var(--accent); }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.bar-track { flex: 1; height: 4px; background: var(--panel-3); border-radius: 3px; overflow: hidden; min-width: 46px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-val { font: 10.5px var(--mono); color: var(--text-2); min-width: 42px; text-align: right; }

/* ---------- 控件 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); font-size: 11.5px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn svg { width: 13px; height: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06201e; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.1); color: #06201e; }
.btn.danger { color: var(--red); border-color: rgba(225, 96, 107, .35); }
.btn.danger:hover { background: rgba(225, 96, 107, .1); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 4px; font: 10px/1.7 var(--mono); border: 1px solid var(--line); color: var(--text-2); background: var(--panel-2); }
.chip.ok { color: var(--green); border-color: rgba(76, 195, 138, .3); background: rgba(76, 195, 138, .08); }
.chip.warn { color: var(--amber); border-color: rgba(224, 164, 88, .3); background: rgba(224, 164, 88, .08); }
.chip.err { color: var(--red); border-color: rgba(225, 96, 107, .3); background: rgba(225, 96, 107, .08); }
.chip.info { color: var(--blue); border-color: rgba(109, 143, 240, .3); background: rgba(109, 143, 240, .08); }
.chip.accent { color: var(--accent); border-color: rgba(70, 207, 192, .3); background: var(--accent-soft); }
.link { color: var(--accent); cursor: pointer; }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 9px; align-items: end; }
.filters .fi { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filters label { font-size: 10px; color: var(--text-3); }
.filters input, .filters select, .form input, .form select, .form textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; height: 31px;
  padding: 0 9px; outline: 0; font-size: 11.5px; width: 100%; min-width: 0;
}
.filters input:focus, .filters select:focus, .form input:focus, .form select:focus, .form textarea:focus { border-color: var(--accent); }
.filters .fi-actions { display: flex; gap: 6px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--text-2); flex-wrap: wrap; }
.pager .pg-btns { display: flex; gap: 5px; align-items: center; }
.pager .pg-btns button { min-width: 27px; height: 26px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 5px; color: var(--text-2); font: 11px var(--mono); }
.pager .pg-btns button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager .pg-btns button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pager .pg-btns button:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- 表单 / 配置 ---------- */
.form { display: grid; gap: 13px; }
.form-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.form-row:last-child { border-bottom: 0; }
.form-row .fl { font-size: 12px; font-weight: 600; }
.form-row .fd { font-size: 10.5px; color: var(--text-3); margin-top: 3px; line-height: 1.6; }
.form-row .fv { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.form-row input[type="number"] { max-width: 130px; }
.form textarea { height: auto; min-height: 68px; padding: 8px 9px; font-family: var(--mono); font-size: 11px; line-height: 1.6; resize: vertical; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch i { position: absolute; inset: 0; border-radius: 12px; background: var(--panel-3); border: 1px solid var(--line); transition: .18s; }
.switch i::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--text-3); top: 2px; left: 2px; transition: .18s; }
.switch input:checked + i { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + i::after { left: 18px; background: var(--accent); }
.switch-label { font-size: 11px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 7px 12px; font-size: 11.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.code-block { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font: 11px/1.7 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-all; max-height: 230px; overflow: auto; }

/* ---------- 抽屉 / 提示 / 空态 ---------- */
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer-mask { position: absolute; inset: 0; background: rgba(2, 6, 10, .55); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(620px, 94vw); background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slideIn .2s ease-out; }
@keyframes slideIn { from { transform: translateX(24px); opacity: .6; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.drawer-body { padding: 16px 18px 30px; overflow-y: auto; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; background: var(--panel-3); border: 1px solid var(--line); border-radius: 7px; padding: 10px 16px; font-size: 12px; box-shadow: var(--shadow); animation: fadeUp .2s ease-out; }
@keyframes fadeUp { from { transform: translate(-50%, 8px); opacity: 0; } }
.empty { padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 12px; }
.empty b { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 5px; height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading { display: grid; gap: 12px; }
.loading > div { height: 92px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.fade-in { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1360px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-1-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-date { display: none; }
}
@media (max-width: 860px) {
  .app { display: block; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 12px 16px; }
  .nav { display: flex; overflow-x: auto; padding: 6px 10px; gap: 3px; }
  .nav-group, .side-foot { display: none; }
  .nav-item { white-space: nowrap; margin: 0; }
  .nav-item span { font-size: 11.5px; }
  .main { height: auto; min-height: calc(100vh - 110px); }
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .view { padding: 14px; overflow: visible; }
  .g-2, .g-3, .g-1-1-1 { grid-template-columns: minmax(0, 1fr); }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .statusbar { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
