:root {
  color-scheme: dark;
  --bg: #0b1424;
  --surface-1: #13203a;
  --surface-2: #1a2a48;
  --line: #24365a;
  --text-primary: #ffffff;
  --text-muted: #93a0b8;
  --gold: #d4a94a;
  --series-in: #b98a2c;   /* validated vs #13203a, dark */
  --series-out: #4d86cf;
  --bad: #ff8a80;
}
:root[data-theme="light"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.r { text-align: right; }

.top { background: var(--surface-1); border-bottom: 1px solid var(--line); padding: 18px 0 14px; }
.title-row { display: flex; align-items: center; gap: 12px; }
h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.sub { margin: 4px 0 10px; color: var(--text-muted); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.live.stale i { background: var(--bad); }
.live.pulse i { animation: pulse 1s ease-out; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(212,169,74,.7); } to { box-shadow: 0 0 0 8px rgba(212,169,74,0); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text-muted); white-space: nowrap; }
.chip b { color: var(--text-primary); font-weight: 600; }
.chip.bad { color: var(--bad); border-color: currentColor; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface-1); color: var(--text-muted); border: 0; padding: 7px 13px;
  font: inherit; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--gold); color: #0b1424; }
input[type=search] { font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 220px; flex: 0 1 280px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text-muted); cursor: pointer; font-size: 13px; }
.check input { accent-color: var(--gold); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .k { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }

.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
h2 { margin: 0; font-size: 15px; }
h2 .clear { font-weight: 400; font-size: 12.5px; margin-left: 8px; cursor: pointer; color: var(--gold); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw.in { background: var(--series-in); } .sw.out { background: var(--series-out); }

.chart { width: 100%; height: 220px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 11px; }
.chart .in { fill: var(--series-in); } .chart .out { fill: var(--series-out); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(255,255,255,.05); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface-1); }
#tokens th { cursor: pointer; user-select: none; }
#tokens th[aria-sort]::after { content: " ▾"; color: var(--gold); }
#tokens th[aria-sort="ascending"]::after { content: " ▴"; }
#tokens tbody tr { cursor: pointer; }
#tokens tbody tr:hover, #tokens tbody tr.sel { background: var(--surface-2); }
#tokens tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.sym { font-weight: 600; }
.tag { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 999px; margin-left: 6px;
  border: 1px solid var(--gold); color: var(--gold); text-transform: uppercase; letter-spacing: .04em; vertical-align: 1px; }
.tag.dim { border-color: var(--line); color: var(--text-muted); }
.dir { font-weight: 700; }
.dir.in { color: var(--gold); } .dir.out { color: var(--text-muted); }
.neg { color: var(--text-muted); }
#feed tr.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: rgba(212,169,74,.18); } to { background: transparent; } }

.tip { position: fixed; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; z-index: 10; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.tip b { display: block; margin-bottom: 4px; }

@media (max-width: 640px) {
  h1 { font-size: 19px; }
  input[type=search] { flex: 1 1 100%; min-width: 0; }
  .kpi .v { font-size: 20px; }
}
