/* propuh — light, green-leaning theme with a matching dark mode.
   Tokens first; components below only use tokens. */

:root {
  /* Dark (default): slate surfaces, cyan accent — after the original mockups,
     one step lighter. Light is opt-in via the toggle ([data-theme="light"]). */
  --bg: #0f1621;
  --surface: #151f2d;
  --surface-2: #1d2939;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.30);
  --ink: #e6ebf2;
  --ink-2: #b3bfce;
  --muted: #8593a5;
  --brand: #22b8cf;
  --brand-strong: #5fd4e6;
  --brand-soft: rgba(34, 184, 207, 0.14);
  --on-brand: #04222a;
  --map-land: #1c2838;
  --map-stroke: #4b5d75;
  --map-entity: #34455c;
  --grid: #243246;
  --shadow: none;

  /* Air quality bands (EEA thresholds, 4 levels) — same in both modes. */
  --band-good: #0ca30c;
  --band-moderate: #fab219;
  --band-poor: #ec835a;
  --band-very-poor: #d03b3b;
  --band-none: #6b7a8c;

  /* Categorical series (fixed order; see assets/common.js), dark steps. */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;

  --font-head: "Geist", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 10px;
  --radius-sm: 6px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #eef2f6;
  --border: rgba(15, 23, 42, 0.12); --border-strong: rgba(15, 23, 42, 0.22);
  --ink: #0f172a; --ink-2: #475569; --muted: #64748b;
  --brand: #0e8fa3; --brand-strong: #0b6f7f; --brand-soft: #e0f4f7; --on-brand: #ffffff;
  --map-land: #e8edf3; --map-stroke: #94a3b8; --map-entity: #cbd5e1; --grid: #e2e8f0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 16px rgba(15, 23, 42, 0.05);
  --band-none: #a3adb9;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  color-scheme: light;
}

/* ---- Base ---------------------------------------------------------------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* components with display:flex must still hide */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
}
a { color: var(--brand-strong); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem); line-height: 1.1; }
h2 { font-size: 1.25rem; line-height: 1.3; }
h3 { font-size: 1rem; }
p { margin: 0; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.unit, .label.unit, .label .unit { text-transform: none; letter-spacing: 0; }
.small { font-size: 0.8125rem; }
.label {
  font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 24px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- Header / footer ----------------------------------------------------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-logo { width: 36px; height: 36px; display: block; flex: none; }
.brand-name { font: 600 1.25rem/1 var(--font-head); letter-spacing: -0.02em; }
.brand-tag { font-size: 0.75rem; color: var(--muted); display: none; }
@media (min-width: 640px) { .brand-tag { display: block; } }
.nav { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.nav a {
  text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 0.875rem;
  padding: 6px 14px; border-radius: 999px; white-space: nowrap;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow); }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer; display: grid; place-items: center;
}
.theme-toggle svg { width: 18px; height: 18px; }

.site-footer { margin-top: 56px; border-top: 1px solid var(--border); background: var(--surface); }
.site-footer .wrap { padding-block: 28px; display: grid; gap: 16px; }
@media (min-width: 768px) { .site-footer .wrap { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer p { color: var(--ink-2); font-size: 0.875rem; max-width: 60ch; }

/* ---- Layout pieces ------------------------------------------------------- */

main.wrap { padding-top: 36px; }  /* main.wrap: beats .wrap's padding shorthand */
@media (min-width: 768px) { main.wrap { padding-top: 52px; } }
.page-head { display: grid; gap: 8px; margin-bottom: 24px; }
.page-head p { color: var(--ink-2); max-width: 70ch; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head p { color: var(--ink-2); font-size: 0.875rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* KPI tile */
.kpi { display: grid; gap: 6px; align-content: start; }
.kpi .value { font: 500 2rem/1.05 var(--font-mono); letter-spacing: -0.04em; }
.kpi .value small { font-size: 0.875rem; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.kpi .sub { color: var(--ink-2); font-size: 0.8125rem; }

/* Band pill + dot */
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 2px 10px 2px 8px; font: 600 0.75rem/1.6 var(--font-body); color: var(--ink);
  background: color-mix(in srgb, var(--c, var(--band-none)) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--band-none)) 45%, transparent);
  white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--band-none)); flex: none; }

/* Segmented control */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); font: 500 0.8125rem var(--font-body);
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; cursor: pointer;
  padding: 9px 16px; font: 600 0.875rem var(--font-body); text-decoration: none;
  background: var(--brand); color: var(--on-brand); border: 1px solid var(--brand);
}
.btn:hover { background: var(--brand-strong); }
.btn-ghost { background: transparent; color: var(--brand-strong); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--brand-soft); }

select, input[type="date"] {
  font: 500 0.875rem var(--font-body); color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px;
}

.notice {
  border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
  background: color-mix(in srgb, var(--c, var(--brand)) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c, var(--brand)) 35%, transparent);
}
.notice p { color: var(--ink); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; font: 500 0.6875rem var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.link { cursor: pointer; }

/* ---- Home: map ----------------------------------------------------------- */

.map-card { display: grid; gap: 16px; }
@media (min-width: 980px) { .map-card { grid-template-columns: minmax(0, 1fr) 340px; } }
.map-box { position: relative; }
.map-box svg { width: 100%; height: auto; display: block; }
.map-land { fill: var(--map-land); stroke: var(--map-stroke); stroke-width: 1.6; }
.map-entity { fill: none; stroke: var(--map-entity); stroke-width: 1; stroke-dasharray: 5 5; }
.map-city { cursor: pointer; }
.map-city circle.mark { stroke: var(--surface); stroke-width: 3; }
.map-city text { font: 600 17px var(--font-body); fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.map-city text .v { font-family: var(--font-mono); font-weight: 500; fill: var(--ink-2); }
.map-city:hover circle.mark, .map-city:focus circle.mark, .map-city.selected circle.mark { stroke: var(--ink); }
.map-city:focus { outline: none; }
.map-city circle.halo { fill: var(--c); opacity: 0.18; }
/* Phones: the 1000-unit map shrinks ~3x, so labels get bigger and only cities
   with a value keep theirs (the table below lists every city). */
@media (max-width: 640px) {
  .map-city text { font-size: 34px; stroke-width: 7px; }
  .map-city.nodata text { display: none; }
  .kpi .value { font-size: 1.6rem; }
}
.map-tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 0.8125rem; box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - 14px)); white-space: nowrap; display: none;
}
.city-panel { display: grid; gap: 14px; align-content: start; }
.city-panel .big { font: 500 2.75rem/1 var(--font-mono); letter-spacing: -0.04em; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 0.875rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); }

/* Legend of bands */
.legend { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.legend-item { display: grid; gap: 4px; }
.legend-item .head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.legend-item p { color: var(--ink-2); font-size: 0.8125rem; }

/* ---- City page ----------------------------------------------------------- */

.city-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: end; }
.metric-card { display: grid; gap: 8px; }
.metric-card .top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.metric-card .value { font: 500 2.25rem/1 var(--font-mono); letter-spacing: -0.04em; }
.metric-card .value small { font-size: 0.8125rem; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--c, var(--brand)); }

.chart-box { position: relative; height: 300px; }
.chart-box.short { height: 220px; }
.chart-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

/* ---- Stats page ---------------------------------------------------------- */

.controls { display: grid; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 5px 12px 5px 10px; font: 500 0.8125rem var(--font-body);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 10%, var(--surface)); }
.chip .dot { background: var(--c, var(--border-strong)); }
.chip[aria-pressed="false"] .dot { background: transparent; border: 1px solid var(--border-strong); }
.control-row { display: flex; gap: 12px 20px; flex-wrap: wrap; align-items: center; }
.matrix td.cell { text-align: center; font-family: var(--font-mono); font-size: 0.8125rem; padding: 6px 4px; min-width: 44px; }
.matrix td.cell span { display: block; border-radius: 4px; padding: 4px 0; background: color-mix(in srgb, var(--c, transparent) 22%, transparent); }

.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

/* "Pratite propuh" card (Telegram + Viber), bottom right. Closing collapses it
   to a round button; the state is remembered in the visitor's browser. */
.channels { position: fixed; right: 16px; bottom: 16px; z-index: 50; }
.channels-card {
  width: min(360px, calc(100vw - 32px)); display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 12px 12px 14px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.channels-head { display: flex; justify-content: space-between; align-items: center; }
.channels-head strong { font: 600 1rem var(--font-head); }
.channels-close {
  border: 0; background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1;
  width: 32px; height: 32px; border-radius: 999px; cursor: pointer;
}
.channels-close:hover { background: var(--surface-2); color: var(--ink); }
.channel {
  display: grid; grid-template-columns: 32px 1fr auto; grid-template-rows: auto auto;
  column-gap: 10px; row-gap: 8px; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--border);
}
.channel-icon { grid-row: 1; display: block; }
.channel-text { display: grid; gap: 1px; min-width: 0; }
.channel-text strong { font-weight: 600; }
.channel-qr { grid-column: 3; grid-row: 1 / span 2; border-radius: 6px; display: block; }
.channel-open { grid-column: 2; grid-row: 2; justify-self: start; padding: 6px 14px; font-size: 0.8125rem; }
.channel .soon { grid-column: 3; font: 600 0.75rem var(--font-mono); letter-spacing: 0.12em; color: #9d8ff7; }
.channels-fab {
  display: none; width: 56px; height: 56px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28); place-items: center; padding: 0;
}
.channels-fab img { display: block; }
.channels-fab img + img { margin-top: -6px; }
.channels.collapsed .channels-card { display: none; }
.channels.collapsed .channels-fab { display: grid; align-content: center; justify-items: center; }
/* Phones can't scan their own screen: no QR codes, compact rows. */
@media (max-width: 768px), (pointer: coarse) {
  .channel-qr { display: none; }
  .channel { grid-template-columns: 32px 1fr auto; grid-template-rows: auto; }
  .channel-open { grid-column: 3; grid-row: 1; }
}
.skeleton { color: var(--muted); }
