/* 设计令牌 —— 深色为选定模式（非从浅色自动翻转），
   色值经 dataviz 校验器验证：
     发散对 #3987e5↔#e66767  最差相邻 CVD ΔE 66.4，对比度均 ≥3:1
     哑铃双阶 #256abf↔#3987e5 对比度 3.23:1 / 4.79:1，CVD ΔE 11.6（配位置+连线+直接标注）
     序列色阶 明度严格递增，≥step500 均 ≥3:1 */
:root {
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --surface-2: #232321;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-1-dim: #256abf;
  --div-pos: #3987e5;
  --div-neg: #e66767;
  --div-mid: #383835;
  --noise-band: rgba(255, 255, 255, 0.045);

  --seq-1: #256abf;
  --seq-2: #3987e5;
  --seq-3: #5598e7;
  --seq-4: #86b6ef;
  --seq-5: #cde2fb;

  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
}
.topbar nav a:hover { color: var(--text-primary); }
.topbar nav a.active { color: var(--text-primary); font-weight: 600; }

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.card > h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.card > .sub {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- 英雄数字 */

.hero {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  flex-wrap: wrap;
}

.hero-figure {
  font-size: 76px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  /* 比例数字，不用 tabular-nums —— 大号字下等宽数字会显得松散 */
}

.hero-figure .unit {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 8px;
  letter-spacing: 0;
}

.hero-meta { flex: 1; min-width: 260px; }
.hero-meta .label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: none;
  margin-bottom: 8px;
}

.balls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.ball.special {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
  font-weight: 600;
}

/* ---------------------------------------------------------------- 指标砖 */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat .label {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat .value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.stat .value.small { font-size: 17px; font-weight: 600; }

.stat .delta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat .delta.good { color: var(--good); }
.stat .delta.bad { color: var(--critical); }

/* ---------------------------------------------------------------- 说明块 */

.note {
  border-left: 2px solid var(--axis);
  padding: 10px 0 10px 14px;
  margin: 16px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.65;
}

.note strong { color: var(--text-primary); font-weight: 600; }
.note.warn { border-left-color: var(--warning); }
.note.danger { border-left-color: var(--critical); }

/* ---------------------------------------------------------------- 图表 */

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-family: var(--font); }

/* 图例：≥2 个序列时始终存在 */
.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend .item { display: inline-flex; align-items: center; gap: 7px; }
.legend .key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .key.line { width: 16px; height: 2px; border-radius: 2px; }
.legend .key.dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------------------------------------------------------------- 提示层 */

.tip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: #262624;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  max-width: 280px;
  opacity: 0;
  transition: opacity 0.1s;
}

.tip.show { opacity: 1; }
.tip .t-title { font-weight: 600; margin-bottom: 4px; }
.tip .t-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.tip .t-row .v { color: var(--text-primary); }
.tip .t-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* ---------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; margin-top: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-align: right;
}

th:first-child, td:first-child { text-align: left; }

tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

details.table-view { margin-top: 14px; }
details.table-view summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12.5px;
  list-style: none;
}
details.table-view summary::-webkit-details-marker { display: none; }
details.table-view summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}
details.table-view[open] summary::before { content: "▾ "; }
details.table-view summary:hover { color: var(--text-secondary); }

/* ---------------------------------------------------------------- 徽标 */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 1.6;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.badge.ok { color: var(--good); border-color: rgba(12, 163, 12, 0.35); }
.badge.warn { color: var(--warning); border-color: rgba(250, 178, 25, 0.35); }
.badge.bad { color: var(--critical); border-color: rgba(208, 59, 59, 0.35); }

/* ---------------------------------------------------------------- 表单 */

label.field { display: block; margin-bottom: 14px; }
label.field .name {
  display: block;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
label.field .hint {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13.5px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--series-1);
}

button {
  padding: 9px 18px;
  background: var(--series-1);
  border: 1px solid var(--series-1);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

button:hover { background: #4a93e8; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
button.ghost:hover { background: var(--surface-2); color: var(--text-primary); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 20px;
}

/* ---------------------------------------------------------------- 杂项 */

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty h2 { color: var(--text-secondary); font-size: 16px; margin: 0 0 10px; }
.empty code {
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-primary);
  display: inline-block;
  margin: 4px 0;
}

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--series-1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 7px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.log {
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.hidden { display: none !important; }

.login-wrap {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 0 20px;
}

@media (max-width: 620px) {
  .wrap { padding: 16px 14px 60px; }
  .hero-figure { font-size: 56px; }
  .card { padding: 16px; }
}
