/* v2 — styl wzorowany na z-dykty.pl: biel, granat, karmazynowy akcent, karty z cienką ramką */

:root {
  --bg: #fff;
  --bg-alt: #f5f6fa;
  --bg-hover: #e9ebf2;
  --fg: #1a2350;
  --muted: #535d7e;
  --border: #e2e5ee;
  --accent: #b3122b;
  --accent-hover: #9a1530;
  --accent-tint: #f6e3e6;
  --accent-solid: #b3122b; /* tło przycisków z białym tekstem; w jasnym motywie równe --accent */
  --accent-solid-hover: #9a1530;
  --data-1: #2a78d6;
  --data-2: #199e70;
  --data-3: #c98500;
  --data-5: #4a3aa7;
  --data-6: #e34948;
  --data-7: #d55181;
  --data-8: #d95926;
  --map-empty: #e6e8ef;
  --shadow: 0 10px 30px rgba(26, 35, 80, .12);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1017; --bg-alt: #141a24; --bg-hover: #1b2230; --fg: #d7dee8; --muted: #7e8aa0;
    --border: #232c3a; --accent: #f06a7d; --accent-hover: #f27a8b; --accent-tint: #3a1c24;
    --accent-solid: #c42d45; --accent-solid-hover: #a8263b;
    --data-1: #3987e5; --map-empty: #2a2f38; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1017; --bg-alt: #141a24; --bg-hover: #1b2230; --fg: #d7dee8; --muted: #7e8aa0;
  --border: #232c3a; --accent: #f06a7d; --accent-hover: #f27a8b; --accent-tint: #3a1c24;
  --accent-solid: #c42d45; --accent-solid-hover: #a8263b;
  --data-1: #3987e5; --map-empty: #2a2f38; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
/* przed pierwszym rysowaniem strony #view jest pusty; bez tego stopka miga u góry i skacze w dół (CLS) */
#view:empty { min-height: 100vh; }
a { color: inherit; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* fokus ustawiany przez router po zmianie strony: bez ramki */
h1:focus, h2[tabindex="-1"]:focus, #view:focus, .widget[tabindex="-1"]:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 2000; padding: 10px 14px;
  background: var(--bg); color: var(--fg); border: 2px solid var(--accent); border-radius: 8px;
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: 8px; }
#view { min-height: calc(100vh - 61px); } /* stopka nie skacze w trakcie ładowania */
.view-loading { margin: 40px 0; color: var(--muted); font-size: 15px; }
.view-loading.tall {
  margin: 18px 0 0; min-height: 640px; display: grid; place-items: center;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px;
}
.load-error .btn-accent { margin-top: 16px; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 0 24px; }

/* --- nagłówek --- */
.site-header {
  position: sticky; top: 0; z-index: 1000; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 24px; height: 60px; }
.logo { font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -.01em; font-feature-settings: "cv11"; } /* bez tnum: łącznik w nazwie ma zwykłą szerokość */
.logo span, .site-footer strong span { color: var(--accent); }
.main-nav { display: flex; gap: 20px; margin-left: auto; font-size: 15px; }
.main-nav a { text-decoration: none; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.main-nav a:hover { color: var(--fg); }
.main-nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.header-tools { display: flex; gap: 8px; padding-left: 16px; border-left: 1px solid var(--border); }
.menu-btn {
  display: none; margin-left: auto; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 6px 12px; min-height: 36px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px;
}
.menu-btn::after { content: " ▾"; }
.menu-btn[aria-expanded="true"]::after { content: " ▴"; }
@media (max-width: 1100px) { .main-nav { gap: 14px; font-size: 14.5px; } .header-row { gap: 16px; } }
@media (min-width: 761px) and (max-width: 900px) { .main-nav { gap: 10px; font-size: 13.5px; } .header-row { gap: 12px; } }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-hover); }

/* --- typografia stron --- */
.page { padding: 28px 0 64px; }
.crumbs { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { color: var(--fg); }
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 6px;
}
h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 8px; font-weight: 800; }
.page-lead { font-size: 17px; color: var(--muted); margin: 0; max-width: 680px; }
.meta { font-size: 13px; color: var(--muted); margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; }

/* --- strona główna --- */
.hero {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center;
  padding: 40px 0 36px; border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 52px; line-height: 1.05; letter-spacing: -.03em; }
.hero .page-lead { max-width: 440px; margin-bottom: 26px; }
.stats { display: grid; gap: 18px; }
.stat { display: grid; grid-template-columns: 180px 1fr; align-items: baseline; gap: 16px; }
.stat b { font-size: 28px; font-weight: 800; text-align: right; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 15px; }

.search { position: relative; max-width: 760px; }
.search input {
  width: 100%; font: inherit; font-size: 17px; color: var(--fg);
  padding: 13px 16px 13px 46px; border-radius: 8px;
  border: 2px solid var(--accent); background: var(--accent-tint); outline: none;
}
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search.small input { font-size: 15px; padding: 9px 12px 9px 38px; border-width: 1px; background: var(--bg); border-color: var(--muted); }
.search.small svg { left: 12px; }
.suggestions {
  position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  max-height: min(340px, 40svh); overflow-y: auto;
}
.suggestions li { padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.suggestions li small { display: block; color: var(--muted); font-size: 12.5px; }
.suggestions li[aria-selected="true"], .suggestions li[role="option"]:hover { background: var(--bg-alt); }
.suggestions li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.suggestions li.empty { cursor: default; color: var(--muted); font-size: 14px; }
.suggestions li.empty a { color: var(--fg); }

/* linki-przyciski: szybkie drogi do narzędzi */
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg);
  font-size: 14.5px; font-weight: 600; text-decoration: none;
}
.btn-link:hover { background: var(--bg-alt); border-color: color-mix(in srgb, var(--fg) 30%, var(--border)); }
.widgets-more { margin-top: 16px; }
@media (min-width: 761px) { .widgets-more { display: none; } }
@media (max-width: 760px) { .widgets:not(.all) .widget:nth-child(n+7) { display: none; } }

.section { padding: 32px 0; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 20px; margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 15px; max-width: 560px; }
.more { font-size: 13px; color: var(--muted); }
.more:hover { color: var(--fg); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.chips > span { color: var(--muted); margin-right: 4px; }
.chip {
  font-size: 13px; padding: 4px 11px; border-radius: 6px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); color: var(--fg); line-height: 1.4;
}
.chip:hover { background: var(--bg-alt); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); font-weight: 600; }
/* w ciemnym motywie akcent na --accent-tint ma kontrast 3,9:1, więc tekst wybranego chipa jest jasny */
:root[data-theme="dark"] .chip[aria-pressed="true"] { color: var(--fg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[aria-pressed="true"] { color: var(--fg); } }

.swarm-wrap { margin-top: 14px; position: relative; }
.swarm-tip { position: absolute; transform: translate(-50%, calc(-100% - 8px)); pointer-events: none; white-space: nowrap; font-size: 12.5px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--fg); box-shadow: var(--shadow); z-index: 5; }
.swarm-tip.tap { pointer-events: auto; white-space: normal; max-width: 260px; font-size: 13.5px; padding: 6px 10px; }
.swarm-tip.tap a { display: inline-block; padding: 4px 0; font-weight: 600; color: var(--accent); }
.swarm-tip[hidden] { display: none; }
.swarm { width: 100%; height: auto; display: block; overflow: visible; }
/* przezroczysty obrys powiększa obszar trafienia kropki */
.swarm circle { cursor: pointer; stroke: transparent; stroke-width: 10px; }
.swarm circle:hover { stroke: var(--fg); stroke-width: 1.5px; }
.swarm .median { stroke: var(--fg); stroke-dasharray: 3 3; }
.swarm .tick { stroke: var(--border); }
.swarm-axis { position: relative; height: 34px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.swarm-axis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.swarm-axis .start { transform: none; }
.swarm-axis .end { transform: translateX(-100%); }
.swarm-axis .med { top: 17px; color: var(--fg); }
.swarm-data { margin-top: 12px; }
.swarm-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px 24px; margin-top: 8px; }
.swarm-lists h3 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.swarm-lists ol { margin: 0; padding-left: 22px; }
.swarm-lists li { padding: 2px 0; }
.swarm-lists .num { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

/* --- widgety na stronie głównej --- */
.widgets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.widget { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-width: 0; }
.widget .eyebrow { font-size: 11.5px; }
.widget h3 { font-size: 17px; line-height: 1.35; margin: 0 0 10px; }
.widget a { color: inherit; }
.w-big { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.w-big small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.w-text { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 8px 0 0; }
.w-sub { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.w-unit { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.w-foot { font-size: 13px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); }
.w-line { width: 100%; height: auto; display: block; margin-top: 8px; overflow: visible; }
.w-line .axis { font-size: 11px; fill: var(--muted); font-family: var(--mono); }
.w-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.w-bars li { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 13.5px; }
.w-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-bar { height: 8px; background: var(--bg-alt); border-radius: 4px; overflow: hidden; }
.w-bar i { display: block; height: 100%; border-radius: 4px; }
.w-val { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.w-note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -4px; }
.w-scatter { width: 100%; height: auto; display: block; margin-top: 4px; overflow: visible; }
.w-scatter .axis { font-size: 10px; fill: var(--muted); font-family: var(--mono); }
.w-scatter .grid { stroke: var(--border); }
.w-scatter circle { cursor: pointer; }
.w-scatter circle:hover { stroke: var(--fg); stroke-width: 1.2; fill-opacity: 1; }
.duel.rec td { text-align: right; }
.duel { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.duel th, .duel td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: right; }
.duel th:first-child { text-align: left; font-weight: 500; color: var(--muted); }
.duel thead th { font-weight: 700; color: var(--fg); }
.duel td { font-family: var(--mono); font-size: 12.5px; }
.duel td.win { font-weight: 800; color: var(--fg); }
@media (max-width: 1100px) { .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .widgets { grid-template-columns: 1fr; } }

/* --- karty --- */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  display: block; text-decoration: none; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px; padding: 16px 16px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--fg) 30%, var(--border)); box-shadow: 0 2px 10px rgba(26, 35, 80, .06); }
.card .eyebrow { font-size: 11.5px; }
.card h3 { font-size: 17px; line-height: 1.35; margin: 0 0 8px; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.card .card-meta { font-size: 13px; color: var(--muted); margin-top: 12px; }
.group-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 28px 0 10px; }

.panel { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.panel-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }

/* --- strona mapy --- */
.metric-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin: 18px 0 16px;
}
.metric-bar .label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.metric-bar .metric-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.metric-bar .metric-name::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--data-1); }
.metric-bar .metric-sub { color: var(--muted); font-size: 14px; }
.metric-bar .spacer { flex: 1; }
.btn-accent {
  background: var(--accent-solid); color: #fff; border: 0; border-radius: 6px; cursor: pointer;
  font-weight: 600; font-size: 14px; padding: 9px 14px;
}
.btn-accent:hover { background: var(--accent-solid-hover); }
.metric-menu {
  display: grid; grid-template-columns: repeat(3, auto); gap: 18px 28px; justify-content: start;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: -6px 0 16px;
}
.metric-menu .chips { max-width: 520px; }
.metric-menu h2 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.map-card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
/* isolation: kontrolki Leaflet (z-index 1000) zostają pod przyklejonym nagłówkiem */
.map-frame { position: relative; isolation: isolate; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.map-status {
  position: absolute; z-index: 600; left: 50%; top: 12px; transform: translateX(-50%); max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; box-shadow: var(--shadow);
}
.map-poland button {
  display: block; border: 0; background: var(--bg); color: var(--fg); cursor: pointer;
  font-size: 12.5px; font-weight: 600; padding: 0 10px; height: 30px; border-radius: 6px;
}
.map-poland button:hover { background: var(--bg-alt); }
.popup-link { display: inline-block; margin-top: 6px; font-weight: 600; color: var(--accent); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head .panel-label { margin: 0; }
.close-card { font-size: 13px; color: var(--muted); text-decoration: none; padding: 4px 0; white-space: nowrap; }
.close-card:hover { color: var(--fg); text-decoration: underline; }
.map-frame #map { height: 640px; }
.map-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.map-tools .search { flex: 1; min-width: 220px; max-width: 360px; }

#map { background: var(--bg); }
.leaflet-container { font-family: var(--font); background: var(--bg); }
.leaflet-bar a { background: var(--bg); color: var(--fg); border-color: var(--border) !important; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: none !important; border-radius: 6px !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--bg) 80%, transparent) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-tooltip { font-family: var(--font); font-size: 12.5px; border-radius: 6px; border-color: var(--border); box-shadow: var(--shadow); background: var(--bg); color: var(--fg); }
.leaflet-tooltip-left::before { border-left-color: var(--bg); } .leaflet-tooltip-right::before { border-right-color: var(--bg); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg); color: var(--fg); box-shadow: var(--shadow); }
.leaflet-popup-content-wrapper { border-radius: 8px; }

.legend {
  position: absolute; z-index: 500; right: 12px; top: 12px; width: 270px; max-width: calc(100% - 24px);
  background: color-mix(in srgb, var(--bg) 94%, transparent); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-size: 12px;
}
.legend strong { display: block; font-size: 12px; margin-bottom: 2px; line-height: 1.3; }
.legend .unit { color: var(--muted); margin-bottom: 6px; }
.legend .ramp { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: 12px; border-radius: 3px; }
.legend .ramp i:first-child { border-radius: 3px 0 0 3px; }
.legend .ramp i:last-child { border-radius: 0 3px 3px 0; }
.legend .ramp i.sel { outline: 2px solid var(--fg); outline-offset: 0; position: relative; z-index: 1; }
/* progi na stykach pól: dwa rzędy na przemian, żeby sąsiednie liczby się nie nakładały */
.legend .ticks { position: relative; height: 28px; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 2px; }
.legend .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; line-height: 1.3; }
.legend .ticks span::before { content: ""; position: absolute; left: 50%; top: -3px; height: 3px; border-left: 1px solid var(--muted); }
.legend .ticks span.a { top: 1px; }
.legend .ticks span.b { top: 14px; }
.legend .ticks span.b::before { top: -16px; height: 16px; opacity: .5; }
.legend .dir { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 2px; }
.legend .cats div { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.legend .cats i { width: 12px; height: 12px; border-radius: 3px; }
.legend .hl { display: flex; align-items: center; gap: 7px; margin-top: 7px; color: var(--muted); }
.legend .hl i { width: 12px; height: 12px; border: 2px solid var(--fg); border-radius: 3px; }

.details { position: sticky; top: 76px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
/* odstęp od przyklejonego nagłówka daje już html { scroll-padding-top: 80px }; scroll-margin by się do niego dodał */
h2.panel-label { font-size: 12px; letter-spacing: .08em; margin: 0 0 10px; }
.details .hint { color: var(--muted); font-size: 14.5px; margin: 0; }
.details h2 { font-size: 22px; margin: 2px 0 2px; letter-spacing: -.01em; }
.details .sub { font-size: 13.5px; color: var(--muted); margin: 0; }
.big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 14px; }
.big small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.rank { font-size: 13.5px; margin: 4px 0 0; color: var(--muted); }
.rank b { color: var(--fg); }
.spark { margin-top: 14px; }
.spark svg { max-width: 100%; height: auto; display: block; overflow: visible; }
.spark .axis { font-size: 10px; fill: var(--muted); font-family: var(--mono); }
.spark-title { font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.spark-val { font-size: 11px; font-family: var(--mono); fill: var(--fg); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.note {
  font-size: 13px; background: var(--accent-tint); border-left: 3px solid var(--accent);
  padding: 8px 10px; margin: 14px 0 0; border-radius: 0 6px 6px 0;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 16px; }
td, th { padding: 6px 0; border-bottom: 1px solid var(--border); text-align: right; }
td:first-child, th:first-child { text-align: left; }
th { font-weight: 500; color: var(--muted); font-size: 12px; }
tr.active td { font-weight: 700; }
td.num, th.num { font-family: var(--mono); font-size: 12.5px; }
.details h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 0; font-weight: 600; }

/* --- artykuł --- */
.article-head { max-width: 1100px; padding-bottom: 8px; }
.article-head h1 { font-size: 34px; }
.article-head .page-lead { max-width: 680px; font-size: 17px; }
.article-layout { display: grid; grid-template-columns: minmax(0, 680px) minmax(0, 1fr); gap: 40px; align-items: start; margin-top: 18px; }
.prose { font-size: 17px; line-height: 1.65; }
.prose p { margin: 0 0 16px; }
.prose h2 { font-size: 22px; letter-spacing: -.01em; margin: 36px 0 12px; line-height: 1.3; }
/* nagłówek i link „↑ początek” obok niego (link nie jest częścią nagłówka) */
.prose .h2-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 36px 0 12px; }
.prose .h2-row h2 { margin: 0; }
.prose .top {
  display: inline-flex; align-items: center; min-height: 24px; padding: 2px 0;
  font-size: 13px; font-weight: 400; color: var(--muted); white-space: nowrap; flex: none;
}
.back-to-text {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 1100;
  min-height: 44px; padding: 10px 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent-solid); color: #fff; font-weight: 600; font-size: 15px; box-shadow: var(--shadow);
}
.back-to-text:hover { background: var(--accent-solid-hover); }
.prose strong { font-weight: 700; }
.prose a { text-decoration-color: color-mix(in srgb, var(--fg) 35%, transparent); text-underline-offset: 2px; }
.prose a[href^="#powiat="] { text-decoration: underline dotted; text-decoration-color: var(--accent); cursor: pointer; }
.prose a[href^="#powiat="]:hover { color: var(--accent); }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 16px; }
.prose li { margin-bottom: 6px; }
.prose table { font-size: 14px; margin: 8px 0 20px; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 7px 10px 7px 0; }
.prose th { text-align: left; }
.prose td { font-family: var(--mono); font-size: 13px; }
.prose td:first-child { font-family: var(--font); font-size: 14px; }
.sources { font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 32px; padding-top: 14px; }
.sources ol { padding-left: 20px; }
.sources li { margin: 5px 0; word-break: break-word; }

.viz { margin: 22px 0 26px; padding: 16px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; }
.viz-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; line-height: 1.35; }
.viz-sub { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.chart { width: 100%; height: auto; display: block; font-size: 11px; font-family: var(--font); }
.chart .lbl { fill: var(--fg); }
.chart .lbl.hl { font-weight: 700; }
.chart .val, .chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.chart .axis-t { fill: var(--muted); font-size: 10.5px; }
.chart .grid { stroke: var(--border); }
.chart .zero { stroke: var(--muted); }
.chart .ref { stroke: var(--fg); stroke-dasharray: 4 3; }
.chart .pt-lbl { font-size: 10.5px; font-weight: 600; fill: var(--fg); paint-order: stroke; stroke: var(--bg-alt); stroke-width: 3px; }
.chart .band-lbl { font-size: 9px; fill: var(--muted); }
.chart .link { cursor: pointer; }
.chart g.link:hover rect, .chart circle.link:hover { stroke: var(--fg); stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.chart-legend i.ring { background: transparent; border: 1.5px solid var(--fg); }
.axis-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.viz figcaption { font-size: 12px; color: var(--muted); margin-top: 8px; }

.article-map { position: sticky; top: 76px; }
.article-map .map-card { padding: 14px; }
.article-map .map-frame #map { height: calc(100vh - 230px); min-height: 380px; }
.article-map .chips { margin-bottom: 10px; }
.article-map .panel-label { margin-bottom: 8px; }

/* --- metodologia --- */
.prose-page { max-width: 760px; }

/* --- stopka --- */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 32px; font-size: 14px; color: var(--muted); }
.footer-row { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.footer-row p { margin: 0; max-width: 460px; }
.footer-row strong { color: var(--fg); }
.footer-row nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-row nav a { text-decoration: none; }
.footer-row nav a:hover { color: var(--fg); text-decoration: underline; }
.footer-sources { font-size: 12.5px; margin-top: 16px; }

/* --- wąskie ekrany --- */
@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; }
  .details { position: static; }
  .article-layout { grid-template-columns: 1fr; gap: 0; }
  .article-map { position: static; order: -1; margin-bottom: 8px; }
  .article-map .map-frame #map { height: 56vh; min-height: 300px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .header-row { gap: 12px; }
  /* menu rozwijane przyciskiem „Menu”: pełna lista sekcji pod nagłówkiem */
  .menu-btn { display: inline-flex; align-items: center; }
  .main-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%; margin: 0;
    flex-direction: column; gap: 0; padding: 6px 16px 12px; font-size: 16px;
    background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .site-header.menu-open .main-nav { display: flex; }
  .main-nav a { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .main-nav a:last-child { border-bottom: 0; }
  .main-nav a[aria-current="page"] { border-bottom-color: var(--border); box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }
  .header-tools { padding-left: 10px; }
  .view-loading.tall { min-height: 62vh; }
  /* legenda pod mapą, a nie na niej */
  .map-frame { display: flex; flex-direction: column; }
  .map-frame .legend { position: static; order: 2; width: auto; max-width: none; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
  .map-frame #map { order: 1; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 24px; }
  .hero h1 { font-size: 36px; }
  .stat { grid-template-columns: 110px 1fr; }
  .stat b { font-size: 22px; }
  h1, .article-head h1 { font-size: 27px; }
  .cards { grid-template-columns: 1fr; }
  .map-frame #map { height: 62vh; }
  .metric-menu { grid-template-columns: 1fr; }
  .prose { font-size: 16px; }
}

td.num, th.num { padding-left: 10px; white-space: nowrap; }
@media (max-width: 480px) {
  .header-row { gap: 10px; }
  .logo { font-size: 15px; }
  .header-tools { border-left: 0; padding-left: 0; }
}
@media (max-width: 380px) {
  .header-row { gap: 8px; }
  .logo { font-size: 14px; }
  .menu-btn { padding: 6px 10px; }
  .header-tools { flex: none; }
}

/* mapa na niskim ekranie (telefon poziomo): mieści się w oknie, nagłówek nie jest przyklejony */
@media (max-height: 500px) {
  .map-frame #map, .article-map .map-frame #map { height: calc(100svh - 90px); min-height: 0; }
  .site-header { position: static; }
  .view-loading.tall { min-height: calc(100svh - 90px); }
}

/* cele dotyku co najmniej 44 px */
@media (pointer: coarse) {
  .main-nav a, .footer-row nav a { min-height: 44px; display: inline-flex; align-items: center; }
  .icon-btn, .menu-btn { min-width: 44px; height: 44px; min-height: 44px; }
  .chip { min-height: 44px; }
  .leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .map-poland button { height: 44px; }
  .btn-link { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
.article-layout > *, .map-layout > * { min-width: 0; } /* długie tabele i wykresy nie rozpychają kolumny */
@media (max-width: 1100px) { .article-layout, .map-layout { grid-template-columns: minmax(0, 1fr); } }

/* pełna karta powiatu pod mapą; bloki dodają karta.js i rozklad.js */
.karta { margin-top: 28px; align-items: start; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; }
.karta > * { min-width: 0; }
.karta-title { grid-column: 1 / -1; font-size: 22px; margin: 0; letter-spacing: -.01em; }
.karta-blok { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.karta-blok.szeroki { grid-column: 1 / -1; }
.karta-blok h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.karta-blok table { width: 100%; border-collapse: collapse; font-size: 14px; }
.karta-blok td, .karta-blok th { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.karta-blok .num { text-align: right; font-family: "JetBrains Mono", monospace; }
.karta-blok tr.active td { font-weight: 700; }

/* kafelki z liczbami pod tytułem artykułu */
.key-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; margin: 18px 0 6px; }
.key-number { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--bg); }
.key-number b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--accent); }
.key-number span { display: block; font-size: 13.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

/* wykres dumbbell (charts.js, typ "dumbbell"): rozpiętość wartości w grupach, np. powiaty w województwach */
.chart.db .db-name { fill: var(--fg); font-size: 11px; font-weight: 600; }
.chart.db .db-bar { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; opacity: .55; }
.chart.db .db-pt { fill: var(--data-1); fill-opacity: .45; }
.chart.db .db-pt.hl, .chart.db .db-end.hl { stroke: var(--fg); stroke-width: 1.5; fill-opacity: 1; }
.chart.db .db-end { fill: var(--data-1); }
.chart.db .db-med { fill: var(--accent); stroke: var(--bg-alt); stroke-width: 1.5; }
.chart.db .db-lbl { fill: var(--muted); font-size: 10px; paint-order: stroke; stroke: var(--bg-alt); stroke-width: 3px; }
.chart.db .db-lbl.hl { fill: var(--fg); font-weight: 700; }
.chart.db .db-lbl:hover { fill: var(--fg); }
.chart.db circle.link:hover { stroke: var(--fg); stroke-width: 1.5; fill-opacity: 1; }
.chart.db .db-ref-lbl { fill: var(--fg); font-size: 10px; }
.chart-legend i.db-k-pt { width: 7px; height: 7px; background: var(--data-1); opacity: .6; }
.chart-legend i.db-k-med { background: var(--accent); }
.chart-legend i.db-k-ref { width: 14px; height: 0; border-radius: 0; border-top: 1.5px dashed var(--fg); vertical-align: 3px; }

/* sparkline: znacznik 2020 */
.spark-event { stroke: var(--muted); stroke-dasharray: 3 3; stroke-width: 1; opacity: .7; }
.spark-event-lbl { font-size: 9px; }

/* stopka: data danych */
.footer-sources p { margin: 0 0 6px; }
.footer-sources a { color: inherit; }

/* strona 404 */
.notfound .search { max-width: 520px; margin: 20px 0; }
.notfound-links { padding-left: 18px; line-height: 1.9; }

/* link do hasła w słowniku */
a.gl { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }

/* wydruk: bez nawigacji, mapy w tle i przycisków */
@media print {
  .site-header, .site-footer nav, #theme-toggle, .metric-bar, .metric-menu, .map-tools, .chips, button, .btn-accent, .top, .search { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .wrap { max-width: none; padding: 0; }
  .article-layout, .map-layout, .karta { display: block !important; }
  .article-map, .details { position: static !important; }
  .karta-blok, .key-number, .widget, .card { break-inside: avoid; border-color: #999 !important; }
  a { color: #000; text-decoration: none; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10px; color: #555; }
  details > *:not(summary) { display: block !important; }
}

/* wykresy: dane i adnotacje */
/* charts.js: tabela „Pokaż liczby z wykresu”, adnotacje na wykresie liniowym, krzywe na wykresie punktowym */
.chart .adn { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.chart .adn-prawo { stroke: var(--accent); stroke-dasharray: 1.5 2.5; stroke-width: 1.5; }
.chart .adn-lbl { font-size: 10px; font-weight: 600; fill: var(--fg); paint-order: stroke; stroke: var(--bg-alt); stroke-width: 3px; }
.chart .band-lbl { paint-order: stroke; stroke: var(--bg-alt); stroke-width: 3px; }
.chart .curve { fill: none; stroke: var(--muted); stroke-width: 1.5; opacity: .85; }
.chart .curve.dashed { stroke-dasharray: 5 3; }
.chart-legend i.curve-k { width: 16px; height: 0; border-radius: 0; border-top: 2px solid var(--muted); vertical-align: 3px; }
.chart-legend i.curve-k.dashed { border-top-style: dashed; }
.chart-data { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; font-size: 13px; line-height: 1.45; }
.chart-data summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.chart-data summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.chart-data-wrap { max-height: 360px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.viz .chart-data table { display: table; width: 100%; margin: 0; border-collapse: collapse; font-size: 13px; }
.viz .chart-data caption { text-align: left; font-weight: 600; padding: 8px 10px 4px; color: var(--fg); }
.viz .chart-data th, .viz .chart-data td { padding: 5px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-weight: 400; font-family: var(--font); font-size: 13px; }
.viz .chart-data thead th { position: sticky; top: 0; background: var(--bg-alt); color: var(--muted); font-size: 12px; font-weight: 600; z-index: 1; }
.viz .chart-data tbody th { color: var(--fg); }
.viz .chart-data tfoot th, .viz .chart-data tfoot td { font-weight: 600; border-bottom: 0; }
.viz .chart-data .num { text-align: right; }
.viz .chart-data td.num { font-family: var(--mono); white-space: nowrap; }
.viz .chart-data td.num small { display: block; font-family: var(--font); font-size: 11px; color: var(--muted); white-space: normal; }
.viz .chart-data td.grp { white-space: nowrap; color: var(--muted); }
.chart-data-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.chart .lbl-bg { fill: var(--bg-alt); }
.chart-data summary { padding: 12px 0; }
/* obszar trafienia (przezroczysty, większy od punktu) i podświetlenie punktu w grupie g.link */
.chart .hit { fill: transparent; stroke: none; }
.chart g.link:hover rect.hit { stroke: none; }
.chart g.link:hover > circle:not(.hit) { stroke: var(--fg); stroke-width: 1.5; fill-opacity: 1; }
/* wykres słupkowy: liczby z obrysem tła, jednostka tuż pod osią, legenda */
.chart .val { paint-order: stroke; stroke: var(--bg-alt); stroke-width: 3px; stroke-linejoin: round; }
.chart .ref-lbl { fill: var(--fg); paint-order: stroke; stroke: var(--bg-alt); stroke-width: 3px; }
.axis-note.bar-unit { margin-top: 0; }
.chart-legend.bar-legend b { font-weight: 700; color: var(--fg); }
.chart-legend i.bar-k { border-radius: 2px; }
/* podpisy punktów: linia prowadząca do odsuniętego podpisu */
.chart .pt-lead { stroke: var(--muted); stroke-width: 1; }
/* dymek z wartościami (charts.js, chartTips); wygląd jak .leaflet-tooltip */
.viz { position: relative; }
.chart-tip {
  position: absolute; z-index: 20; max-width: min(260px, calc(100% - 8px)); padding: 7px 10px;
  font-family: var(--font); font-size: 12.5px; line-height: 1.4; color: var(--fg);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow);
  pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.chart-tip.touch { pointer-events: auto; }
.chart-tip strong { display: block; font-weight: 700; margin-bottom: 2px; }
.chart-tip .ct-row, .chart-tip .ct-v { display: block; color: var(--muted); }
.chart-tip .ct-row b { color: var(--fg); font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.chart-tip-hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.chart-tip-btn { display: block; width: 100%; min-height: 40px; margin-top: 8px; font-size: 14px; }
/* telefon: viewBox wykresu ma 340 jednostek (charts.js, CW_NARROW), więc napisy rosną, żeby mieć co najmniej 10 px */
@media (max-width: 559.98px) {
  .chart .val, .chart .axis { font-size: 11px; }
  .chart .lbl { font-size: 12px; }
  .chart .axis-t { font-size: 11.5px; }
  .chart .pt-lbl { font-size: 11.5px; }
  .chart.db .db-lbl, .chart.db .db-ref-lbl { font-size: 11px; }
}
