:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --accent: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.45;
}
header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
header h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: -.2px; white-space: nowrap; }
header h1 span { color: var(--muted); font-weight: 500; }
.sub { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs a {
  text-decoration: none; color: var(--muted); font-weight: 550; font-size: 13px;
  padding: 6px 12px; border-radius: 8px;
}
nav.tabs a:hover { background: #eef2ff; color: var(--accent); }
nav.tabs a.active { background: var(--accent); color: #fff; }
.statusbox { text-align: right; line-height: 1.5; }
.pulled { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.freshness { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11.5px; }
.freshness .lag { font-weight: 600; }
.freshness.warn .lag { color: var(--amber); }
.freshness.bad .lag { color: var(--red); }
.freshness.fresh .lag { color: var(--green); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; vertical-align: middle; }
.status-dot.error { background: var(--red); }
.toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
button#refresh {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; cursor: pointer; font-weight: 550;
  display: inline-flex; align-items: center; gap: 7px;
}
button#refresh:hover { border-color: var(--accent); color: var(--accent); }
button#refresh:disabled { opacity: .55; cursor: default; }
.spinner { width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

main { padding: 22px; max-width: 1320px; margin: 0 auto; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 4px 0 14px; font-weight: 650; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 550; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.panel h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; }
.panel .chart-wrap { position: relative; height: 280px; }
.full { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--card); color: var(--muted); padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-weight: 550; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #fff; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
.rank { color: var(--muted); width: 26px; }
.tok { font-weight: 600; }

.banner { background: #fef2f2; border: 1px solid #fecaca; color: var(--red); padding: 9px 14px; border-radius: 9px; font-size: 12.5px; margin-bottom: 16px; }
.gapbanner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 9px 14px; border-radius: 9px; font-size: 12.5px; margin-bottom: 16px; }
.note { color: var(--muted); font-size: 12px; margin-top: 16px; }
