:root {
  --bg: #0d1117;
  --card: #161b22;
  --card-border: #21262d;
  --red: #f0334b;
  --green: #00b050;
  --yellow: #f0b90b;
  --gray: #484f58;
  --blue: #58a6ff;
  --orange: #ff9f45;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --radius: 10px;
  --mono: Consolas, 'JetBrains Mono', 'SF Mono', 'Cascadia Mono', monospace;
  --sans: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.brand::before {
  content: "◆";
  color: var(--red);
  margin-right: 8px;
  font-size: 13px;
}
.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}
.tab {
  position: relative;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  font-weight: 600;
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px;
  bottom: 2px;
  height: 2px;
  background: var(--red);
  border-radius: 1px;
}
.updated {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------- 页面 ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 14px; }

/* ---------- 信号灯卡 ---------- */
.signal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.signal-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.signal-lights {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.signal-meta {
  font-size: 12px;
  color: var(--gray);
}
.light {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 74px;
}
.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-block;
}
.dot.on {
  background: var(--red);
  box-shadow: 0 0 12px rgba(240, 51, 75, 0.85), 0 0 4px rgba(240, 51, 75, 0.9);
}
.dot.off {
  background: transparent;
  border: 2px solid var(--gray);
}
.light .label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* 徽章 */
.badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.badge {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--yellow);
  border: 1px solid var(--yellow);
  border-radius: 8px;
  padding: 10px 22px;
  letter-spacing: 1px;
  background: rgba(240, 185, 11, 0.06);
}
.badge.empty {
  color: var(--gray);
  border-color: var(--gray);
  background: transparent;
}
.badge-date {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- 图表卡片 ---------- */
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 6px;
}
.chart-head h2 {
  font-size: 15px;
  font-weight: 600;
}
.chart-sub {
  font-size: 12px;
  color: var(--text-dim);
}
.chart { width: 100%; height: 340px; }
.chart-sm { height: 220px; }

/* ---------- 明细表 ---------- */
.table-scroll { overflow-x: auto; }
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 820px;
}
.detail-table thead th {
  position: sticky;
  top: 0;
  background: #1b2129;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  padding: 9px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--card-border);
  z-index: 1;
}
.detail-table thead th:first-child,
.detail-table tbody td:first-child {
  text-align: left;
}
.detail-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-border);
  text-align: right;
  font-family: var(--mono);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.detail-table tbody td.date-cell {
  font-family: var(--sans);
  color: var(--text);
}
.detail-table tbody tr:last-child td { border-bottom: none; }
.detail-table tbody tr:hover td { background: rgba(88, 166, 255, 0.05); }
.detail-table tbody tr.signal-row td { background: rgba(240, 185, 11, 0.07); }
.detail-table tbody tr.signal-row:hover td { background: rgba(240, 185, 11, 0.12); }
.cell-null { color: #3d444d; }
.cell-good { color: var(--text); }
.cell-bad { color: var(--red); }
.cell-sig { color: var(--yellow); font-weight: 600; }

.cond-dots { display: flex; gap: 4px; justify-content: flex-end; }
.cond-dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
}
.cond-dot.y { background: var(--red); }
.cond-dot.n { background: transparent; border: 1.5px solid var(--gray); }

/* ---------- 占位 Tab ---------- */
.placeholder { display: none; }
.placeholder-box {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 22px;
  letter-spacing: 2px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius);
}
.placeholder-box small {
  font-size: 13px;
  color: var(--gray);
}

/* ---------- 底部 ---------- */
.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 32px;
  font-size: 12px;
  color: var(--gray);
}

/* ---------- 图表尺寸变体 ---------- */
.chart-md { height: 300px; }
.chart-lg { height: 420px; }

/* ---------- 日期导航条 ---------- */
.navbar { display: flex; align-items: center; gap: 12px; }
.nav-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.nav-btn:hover { border-color: var(--red); color: var(--red); }
.nav-btn:disabled { color: var(--gray); cursor: not-allowed; border-color: var(--card-border); }
.nav-latest { width: auto; padding: 0 16px; color: var(--yellow); border-color: var(--yellow); font-size: 13px; }
.nav-latest:hover { color: var(--yellow); border-color: var(--yellow); background: rgba(240,185,11,0.08); }
.nav-date { font-family: var(--mono); font-size: 22px; font-weight: 700; min-width: 130px; text-align: center; color: var(--text); }

/* ---------- 指标卡 ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.rv-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 14px 16px; }
.rv-card-label { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; letter-spacing: 0.5px; }
.rv-card-value { font-family: var(--mono); font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.rv-card-value.text { font-size: 15px; line-height: 1.45; font-weight: 600; }
.rv-card-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; font-family: var(--mono); }
.rv-card-delta { font-size: 13px; margin-top: 8px; font-family: var(--mono); }
.rv-card-delta.up { color: var(--red); }
.rv-card-delta.down { color: var(--green); }
.rv-card-delta.flat { color: var(--gray); }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .topbar-inner { gap: 16px; flex-wrap: wrap; }
  .updated { flex-basis: 100%; }
  .signal-lights { gap: 10px; }
  .light { min-width: 60px; }
  .badge { font-size: 17px; padding: 8px 16px; }
  .badge-wrap { align-items: flex-start; width: 100%; }
  .chart { height: 238px; }
  .chart-sm { height: 154px; }
  .chart-md { height: 220px; }
  .chart-lg { height: 300px; }
  .signal-card { justify-content: flex-start; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .rv-card-value { font-size: 24px; }
  .nav-date { min-width: 100px; font-size: 18px; }
}