:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #17181a;
  --muted: #6b6e75;
  --line: #e4e4df;
  --accent: #2f6fed;
  --accent-soft: rgba(47, 111, 237, 0.14);
  --up: #1f8a5b;
  --down: #c2483d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --surface: #191b1e;
    --text: #ececea;
    --muted: #8d9097;
    --line: #2a2d31;
    --accent: #6b9bff;
    --accent-soft: rgba(107, 155, 255, 0.18);
    --up: #4cc38a;
    --down: #ef7a6e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --surface: #191b1e; --text: #ececea; --muted: #8d9097; --line: #2a2d31;
  --accent: #6b9bff; --accent-soft: rgba(107, 155, 255, 0.18); --up: #4cc38a; --down: #ef7a6e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.top, main { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-top: 32px; padding-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 14px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.controls { display: flex; gap: 8px; align-items: center; }

button {
  font: inherit; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 6px 12px;
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost { background: transparent; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 6px 12px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.gate { text-align: center; padding: 120px 0; }
.gate button { background: var(--text); color: var(--bg); border-color: var(--text); padding: 8px 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font: 500 26px/1.2 "JetBrains Mono", ui-monospace, monospace; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.chart { position: relative; height: 180px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg);
  font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }
td.spark { width: 120px; }
td .ref { color: var(--muted); font-size: 12px; }
.delta { font-size: 12px; margin-left: 6px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.empty { color: var(--muted); padding: 12px 8px; }
.error { color: var(--down); }

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 20px; }
  td.spark { width: 80px; }
}
