/* Stats page. Builds on ../app/app.css (tokens, header, panels, tables). The site is dark-only,
   so chart colors use the dark steps, validated against --bg-soft. */
:root {
  --series-1: #3987e5;      /* categorical slot 1 (dark step), passes on #0b0e16 */
  --grid: rgba(255, 255, 255, 0.07);
  --axis: rgba(255, 255, 255, 0.16);
  --good: #0ca30c;
  --critical: #d03b3b;
}

#root.loading > :not(#notice) { opacity: .55; transition: opacity .2s; }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: .88rem; cursor: pointer; color: var(--muted);
  background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); background: var(--panel); border-color: rgba(255, 255, 255, .22); }
.filters .hint { margin-left: auto; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: .82rem; }
.kpi .value { font-size: 1.6rem; font-weight: 650; margin-top: 2px; overflow-wrap: anywhere; }
.kpi .value .unit { font-size: .9rem; font-weight: 500; color: var(--muted); }
.kpi .sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.kpi.hero .value { font-size: 2.6rem; line-height: 1.1; }
.delta-up { color: var(--good); }
.delta-down { color: #e66767; }

/* Column chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .col { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:hover + .col, .chart .hit:focus + .col { fill: #6da7ec; }
.chart .hit:focus-visible { stroke: rgba(255, 255, 255, .5); stroke-width: 1; }
.chart .peak { fill: var(--text); font-size: 11px; font-weight: 600; }
.empty-chart { color: var(--muted); padding: 40px 0; text-align: center; }

/* Horizontal bars */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 10px; }
.hbar .name { color: var(--text); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar .fill { height: 16px; min-width: 2px; background: var(--series-1); border-radius: 0 4px 4px 0; flex: none; }
.hbar .val { color: var(--text); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hbar .val .hint { margin-left: 4px; }

h2.sub { font-size: .95rem; margin: 22px 0 10px; }
.statuses { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .9rem; }
.statuses .n { font-weight: 600; margin-left: 6px; font-variant-numeric: tabular-nums; }

/* Tables */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.source { text-align: center; }

/* Tooltip */
.viz-tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--bg-soft); border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px;
  padding: 8px 12px; font-size: .85rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.viz-tip .v { font-weight: 650; font-size: 1rem; color: var(--text); }
.viz-tip .k { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.viz-tip .key { width: 12px; height: 2px; background: var(--series-1); border-radius: 1px; }
