:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2dd;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --bar: #2a78d6;
  --good: #0f7a3a; --good-bg: #dcf3e4;
  --info: #1c5cab; --info-bg: #dde9fa;
  --warn: #8a5a00; --warn-bg: #fbecc8;
  --bad: #b3261e;  --bad-bg: #fbe0de;
  --neutral: #52514e; --neutral-bg: #ebeae6;
  --hero-glow: radial-gradient(1200px 400px at 10% -10%, #cde2fb 0%, transparent 60%), radial-gradient(800px 300px at 90% -20%, #e9e0fb 0%, transparent 60%);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #3987e5; --accent-soft: #184f95; --bar: #3987e5;
    --good: #7fd8a0; --good-bg: #133222;
    --info: #9ec5f4; --info-bg: #15294a;
    --warn: #f2c35b; --warn-bg: #3a2c0c;
    --bad: #f39a95; --bad-bg: #3d1716;
    --neutral: #c3c2b7; --neutral-bg: #2a2a27;
    --hero-glow: radial-gradient(1200px 400px at 10% -10%, #15294a 0%, transparent 60%), radial-gradient(800px 300px at 90% -20%, #2a1f4a 0%, transparent 60%);
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #3987e5; --accent-soft: #184f95; --bar: #3987e5;
  --good: #7fd8a0; --good-bg: #133222;
  --info: #9ec5f4; --info-bg: #15294a;
  --warn: #f2c35b; --warn-bg: #3a2c0c;
  --bad: #f39a95; --bad-bg: #3d1716;
  --neutral: #c3c2b7; --neutral-bg: #2a2a27;
  --hero-glow: radial-gradient(1200px 400px at 10% -10%, #15294a 0%, transparent 60%), radial-gradient(800px 300px at 90% -20%, #2a1f4a 0%, transparent 60%);
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: 13px; }

.hero { background: var(--hero-glow); border-bottom: 1px solid var(--border); padding-top: 40px; }
.hero-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pulse.live { background: #1baf7a; box-shadow: 0 0 0 0 rgba(27,175,122,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(27,175,122,0); } 100% { box-shadow: 0 0 0 0 rgba(27,175,122,0); } }
h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.1; margin: 0 0 10px; letter-spacing: -0.02em; font-weight: 700; }
.lede { margin: 0; color: var(--text-2); max-width: 620px; }
.hero-actions { display: flex; gap: 8px; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }

.tabs { display: flex; gap: 4px; margin-top: 28px; overflow-x: auto; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2);
  font: inherit; font-weight: 600; padding: 12px 14px; cursor: pointer; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.count { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); font-size: 12px; color: var(--text-2); }

main { padding-top: 24px; padding-bottom: 24px; }
.view { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chart svg { display: block; width: 100%; height: auto; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g.col:hover .bar { opacity: .75; }

.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 44px; gap: 10px; align-items: center; cursor: pointer; padding: 3px 6px; border-radius: 8px; border: 0; background: none; font: inherit; color: inherit; text-align: left; }
.hbar:hover, .hbar.on { background: var(--surface-2); }
.hbar-label { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; }
.hbar-fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; color: var(--text); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.pill b { color: var(--text-2); font-weight: 600; margin-left: 4px; }
.pill:hover { border-color: var(--accent); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; min-width: 0;
}
.toolbar input { flex: 1 1 260px; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; user-select: none; white-space: nowrap; }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
td.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--text-2); }
td.notes { min-width: 260px; max-width: 460px; color: var(--text-2); }
td.notes .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
td.notes .clamp.open { -webkit-line-clamp: unset; }
td.strong { font-weight: 600; }
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.good { color: var(--good); background: var(--good-bg); }
.chip.info { color: var(--info); background: var(--info-bg); }
.chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.bad { color: var(--bad); background: var(--bad-bg); }
.chip.neutral { color: var(--neutral); background: var(--neutral-bg); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pager .btn { padding: 6px 12px; }
.pager .btn[disabled] { opacity: .4; cursor: default; }

.empty { padding: 32px; text-align: center; color: var(--muted); }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px 16px; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; padding-top: 8px; padding-bottom: 40px; }

.tip { position: fixed; pointer-events: none; z-index: 10; background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 30px; width: 60%; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 600px) {
  .hero { padding-top: 24px; }
  .kpi-value { font-size: 24px; }
  .card { padding: 14px; }
}
td.wide { min-width: 220px; }
.view[hidden] { display: none; }
