:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #1c5cab;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --good: #006300;
  --bad: #b42b2b;
  --hover: rgba(42, 120, 214, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #86b6ef;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --good: #0ca30c; --bad: #e66767;
    --hover: rgba(57, 135, 229, 0.12); --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #86b6ef;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --good: #0ca30c; --bad: #e66767;
  --hover: rgba(57, 135, 229, 0.12); --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 130px; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 40px 0 4px; }
h3 { font-size: 14px; margin: 0; }
.sub, .note, .card-sub { color: var(--ink-2); margin: 2px 0 0; }
.note { margin-bottom: 16px; }
.card-sub { font-size: 13px; margin-bottom: 12px; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.jump { display: flex; gap: 4px; align-items: center; }
.jump a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.jump a:hover { background: var(--hover); color: var(--ink); }

.filters-bar { position: sticky; top: 0; z-index: 5; background: var(--page); border-bottom: 1px solid var(--border); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding-top: 10px; padding-bottom: 10px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-2); gap: 3px; }
.filters .custom { display: none; }
.filters.show-custom .custom { display: flex; }
select, input[type=date], button {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; min-height: 34px;
}
button { cursor: pointer; }
.ghost { background: transparent; }
.ghost:hover { background: var(--hover); }
select:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible, th:focus-visible, tr:focus-visible { outline: 2px solid var(--s1); outline-offset: 1px; }

main { padding-bottom: 48px; transition: opacity .15s; }
main.loading { opacity: .55; }
.error { background: var(--surface); border: 1px solid var(--bad); color: var(--ink); border-radius: 8px; padding: 12px 14px; margin-top: 20px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; color: var(--ink-2); }
.tile .v { font-size: 24px; font-weight: 600; margin-top: 2px; letter-spacing: -0.01em; }
.tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin-bottom: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .xhair { stroke: var(--axis); stroke-width: 1; }
.chart .lbl { fill: var(--ink-2); font-size: 11px; }
.chart .bar:hover, .chart .bar:focus { opacity: .8; outline: none; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.data th { font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; position: relative; }
table.data th.nosort { cursor: default; }
table.data th.sorted::after { content: attr(data-dir); color: var(--muted); margin-left: 4px; }
table.data .t { text-align: left; }
table.data tbody tr:hover { background: var(--hover); }
table.data tr.click { cursor: pointer; }
table.data tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--axis); }
.barcell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.barcell b { font-weight: 400; min-width: 44px; display: inline-block; }
.barcell span { display: inline-block; height: 8px; background: var(--s2); border-radius: 0 4px 4px 0; }
.barcell .track { width: 80px; background: var(--grid); border-radius: 4px; display: inline-flex; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); color: var(--ink-2); }
.ok { color: var(--good); }
.warn { color: var(--bad); }

.tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12); min-width: 140px; font-variant-numeric: tabular-nums;
}
.tip .h { color: var(--ink-2); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r em { font-style: normal; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.tip .r em i { width: 12px; height: 2px; display: inline-block; }
.tip .r strong { font-weight: 600; }

.foot { color: var(--muted); font-size: 12px; margin-top: 32px; }

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .filters label { flex: 1 1 140px; }
  .filters select, .filters input { width: 100%; }
  .tile .v { font-size: 20px; }
  .jump a { padding: 6px 6px; }
  html { scroll-padding-top: 220px; }
}
@media (forced-colors: active) { .barcell span, .legend i { forced-color-adjust: none; } }
@media (max-width: 600px) { .filters-bar { position: static; } html { scroll-padding-top: 12px; } }
.table-wrap.tall { max-height: 440px; overflow: auto; }
.table-wrap.tall thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; box-shadow: inset 0 -1px 0 var(--grid); }
