:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --border: #e2e0da;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --neutral-series: #9b9a94;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --seq: #cde2fb,#b7d3f6,#9ec5f4,#86b6ef,#6da7ec,#5598e7,#3987e5,#2a78d6,#256abf,#1c5cab,#184f95,#104281,#0d366b;
  --div-neg: #e34948; --div-mid: #f0efec; --div-pos: #2a78d6;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --border: #2e2e2b; --grid: #262624;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --accent: #3987e5; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --neutral-series: #6f6e68;
    --div-mid: #383835; --div-neg: #e66767; --div-pos: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --border: #2e2e2b; --grid: #262624;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --accent: #3987e5; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --neutral-series: #6f6e68;
  --div-mid: #383835; --div-neg: #e66767; --div-pos: #3987e5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
header.top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface-1); position: sticky; top: 0; z-index: 1000; flex-wrap: wrap; }
header.top h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
header.top h1 span { color: var(--text-muted); font-weight: 450; }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs button { border: 0; background: none; color: var(--text-secondary); padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; }
nav.tabs button:hover { background: var(--surface-0); }
nav.tabs button[aria-selected="true"] { background: var(--surface-0); color: var(--text-primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.spacer { flex: 1; }
.icon-btn { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
section.tab { display: none; }
section.tab.active { display: block; }
.lede { color: var(--text-secondary); margin: 0 0 16px; max-width: 860px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } main { padding: 12px; } }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card h2 { font-size: 14px; margin: 0 0 2px; font-weight: 620; }
.card .sub { color: var(--text-muted); font-size: 12px; margin: 0 0 10px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.controls label { color: var(--text-secondary); font-size: 12px; display: flex; gap: 6px; align-items: center; }
select, .seg button { font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
select { max-width: 420px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; cursor: pointer; color: var(--text-secondary); }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button + button { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--surface-0); color: var(--text-primary); font-weight: 600; }

.map { height: 520px; border-radius: 8px; background: var(--surface-0); }
.map.short { height: 380px; }
.leaflet-container { font: inherit; background: var(--surface-0); }
.leaflet-tooltip { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,.15); }

.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { color: var(--text-muted); font-size: 12px; }
.tile .v { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 13px; color: var(--text-secondary); font-weight: 450; margin-left: 3px; }
.tile .d { color: var(--text-secondary); font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.badge .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.note { color: var(--text-muted); font-size: 12px; margin-top: 8px; }
.proxy { color: var(--text-secondary); background: var(--surface-0); border-radius: 6px; padding: 6px 10px; font-size: 12px; margin-top: 8px; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 8px; align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.legend .ramp { width: 160px; height: 10px; border-radius: 3px; }

table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-muted); font-weight: 550; cursor: pointer; position: sticky; top: 0; background: var(--surface-1); }
table.data tr:hover td { background: var(--surface-0); }
.scroll { max-height: 520px; overflow: auto; }

.detail dl { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; margin: 0; font-size: 13px; }
.detail dt { color: var(--text-secondary); }
.detail dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.detail dd.rank { color: var(--text-muted); }
.detail h3 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px; font-weight: 600; }

/* wykresy SVG */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-muted); font-size: 11px; }
.chart .grid line { stroke: var(--grid); }
.chart .baseline { stroke: var(--border); }
.chart .ref line { stroke: var(--text-muted); stroke-dasharray: 4 3; }
.chart .ref text { fill: var(--text-muted); font-size: 11px; }
.chart .lbl { fill: var(--text-secondary); font-size: 11px; }
.chart .val { fill: var(--text-primary); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: var(--text-muted); }
.tip { position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.14); white-space: nowrap; z-index: 5; display: none; }
.tip .t { color: var(--text-muted); margin-bottom: 3px; }
.tip .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tip .row b { font-variant-numeric: tabular-nums; }

.empty { color: var(--text-muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.err { color: var(--critical); font-size: 12px; }
footer { color: var(--text-muted); font-size: 12px; padding: 20px; text-align: center; }
ul.sources { padding-left: 18px; } ul.sources li { margin-bottom: 8px; }
