:root {
  --bg: #fbfaf7;
  --fg: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2e0da;
  --accent: #b3261e;
  --panel-w: 380px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--fg);
}

#panel {
  width: var(--panel-w);
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 20px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#map { flex: 1; height: 100vh; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 2px; }
.sub, .hint, .meta { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

label { display: block; font-size: 12px; color: var(--muted); }

input, select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--fg);
}

.search { position: relative; }

#suggestions {
  position: absolute;
  z-index: 1000;
  left: 0; right: 0;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  max-height: 320px;
  overflow-y: auto;
}

#suggestions li { padding: 8px 10px; cursor: pointer; font-size: 14px; }
#suggestions li small { display: block; color: var(--muted); font-size: 12px; }
#suggestions li[aria-selected="true"], #suggestions li:hover { background: #f3f1ec; }

.controls { display: grid; gap: 10px; }

.stat-big { font-size: 34px; font-weight: 700; line-height: 1.1; margin-top: 12px; }
.stat-big small { font-size: 14px; font-weight: 400; color: var(--muted); }

.rank { font-size: 13px; margin: 6px 0 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 14px; }
td, th { padding: 5px 0; border-bottom: 1px solid var(--line); text-align: right; }
td:first-child, th:first-child { text-align: left; }
th { font-weight: 500; color: var(--muted); }

.spark { margin-top: 12px; }
.spark svg { width: 100%; height: 70px; display: block; }
.spark .axis { font-size: 10px; fill: var(--muted); }

.note {
  font-size: 12px;
  background: #fff4e5;
  border-left: 3px solid #e8a33d;
  padding: 8px 10px;
  margin-top: 12px;
}

footer { margin-top: auto; font-size: 12px; color: var(--muted); }
footer p { margin: 6px 0; }

#legend {
  position: fixed;
  right: 12px;
  bottom: 24px;
  z-index: 500;
  background: rgba(255, 255, 255, .95);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
}
#legend div { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
#legend i { width: 16px; height: 12px; display: inline-block; }

.leaflet-tooltip { font-size: 12px; }

@media (max-width: 760px) {
  body { flex-direction: column-reverse; height: auto; }
  #panel { width: 100%; height: auto; border-right: 0; padding: 16px; }
  #map { height: 60vh; flex: none; }
  #legend { bottom: auto; top: calc(60vh - 140px); }
}

#tab-map { display: flex; flex-direction: column; gap: 18px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  font: inherit; font-size: 14px; padding: 8px 12px; border: 0; background: none;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

body.reading { --panel-w: 520px; }

.card {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 10px; color: var(--fg);
}
.card:hover { border-color: #c9c6be; }
.card strong { display: block; font-size: 15px; margin-bottom: 4px; }
.card span { font-size: 13px; color: var(--muted); }

#article { font-size: 15px; line-height: 1.6; }
#article .back { font: inherit; font-size: 13px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
#article h1 { font-size: 22px; line-height: 1.25; margin: 10px 0 8px; }
#article .lead { font-size: 16px; color: #3d3c39; }
#article h2 { font-size: 17px; margin: 22px 0 6px; }
#article a { color: var(--accent); }
#article a[href^="#powiat="] { text-decoration: none; border-bottom: 1px dashed currentColor; }
#article table { font-size: 13px; }
#article .sources { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 24px; padding-top: 10px; }
#article .sources li { margin: 4px 0; word-break: break-word; }

.budget-h { font-size: 14px; margin: 20px 0 0; }
select:disabled { opacity: .5; }

.group-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.group-h:first-child { margin-top: 4px; }
[hidden] { display: none !important; }

/* wykresy i widoki mapy w artykułach */
.viz { margin: 18px 0 8px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.views { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.views button {
  font: inherit; font-size: 12px; line-height: 1.3; text-align: left; padding: 6px 10px; cursor: pointer;
  background: #f3f1ec; color: var(--fg); border: 1px solid transparent; border-radius: 14px;
}
.views button[aria-pressed="true"] { background: var(--fg); color: #fff; }
.view-name { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.viz-title { font-size: 13px; font-weight: 600; margin: 4px 0 6px; line-height: 1.35; }
.chart { width: 100%; height: auto; display: block; font-size: 11px; }
.chart .lbl { fill: var(--fg); }
.chart .lbl.hl { font-weight: 700; }
.chart .val, .chart .axis { fill: var(--muted); font-size: 10px; }
.chart .axis-t { fill: var(--muted); font-size: 10.5px; }
.chart .grid { stroke: #eee; }
.chart .ref { stroke: #1d1d1b; stroke-dasharray: 4 3; }
.chart .pt-lbl { font-size: 10px; font-weight: 600; fill: var(--fg); paint-order: stroke; stroke: #fff; 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: #000; stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.chart-legend i.ring { background: #fff; border: 1.5px solid #111; }
.axis-note { font-size: 11px; color: var(--muted); margin: 2px 0 0; }
.viz figcaption { font-size: 11px; color: var(--muted); margin-top: 6px; }
#legend { max-width: 240px; }

@media (max-width: 760px) {
  /* legenda zostaje na mapie i nie zasłania tekstu przy przewijaniu */
  #legend { position: absolute; font-size: 11px; max-width: 200px; }
}
