:root {
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1c232c;
  --line: #2a323d;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --accent: #7dd3fc;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --alert-full: #ef4444;
  --alert-part: #f97316;
  --alert-yellow: #eab308;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }

#app { display: grid; grid-template-columns: 1fr 360px; height: 100vh; height: 100dvh; }
.map-wrap { position: relative; min-height: 0; }
#map { height: 100%; background: #0b0e12; }

#panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px; overflow-y: auto; min-height: 0;
}

h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: var(--accent); }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill[data-state="live"] .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.pill[data-state="rest-fallback"] .dot { background: var(--warn); }
.pill[data-state="reconnecting"] .dot, .pill[data-state="offline"] .dot { background: var(--bad); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.kpi .num { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .lbl { font-size: 11px; color: var(--muted); }
#updated { margin: -6px 0 0; }

.filters { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.filters label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 3px 0; }
.filters input { accent-color: var(--accent); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.filters .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.list-section { flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; border-top: 1px solid var(--line); }
.list li { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: start;
  padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:hover, .list li.sel { background: var(--panel-2); }
.list .t { font-size: 13px; font-weight: 600; }
.list .d { font-size: 12px; color: var(--muted); }
.list .age { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .swatch { margin-top: 4px; }
.list .empty { display: block; color: var(--muted); cursor: default; font-size: 13px; }
.list .empty:hover { background: none; }

.stats .row { display: flex; justify-content: space-between; padding: 2px 0; color: var(--text); }
.stats .row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

.panel-foot { border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); }
.panel-foot p { margin: 0 0 6px; }
.panel-foot .warn { color: #fbbf24; }
.panel-foot .credit { margin: 10px 0 0; color: var(--text); }
.panel-foot .legal-links { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; }
.panel-foot .legal-links li + li::before { content: "·"; margin: 0 6px; }

/* map markers */
.threat-icon { background: none; border: none; }
.threat-icon svg { overflow: visible; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.threat-icon .badge { position: absolute; top: -8px; right: -10px; background: #0b0e12; color: #fff; border: 1px solid currentColor;
  font: 600 10px/1 system-ui, sans-serif; padding: 2px 4px; border-radius: 8px; }
.threat-icon.stale svg { opacity: .55; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.popup h3 { margin: 0 0 4px; font-size: 14px; }
.popup .meta { color: var(--muted); font-size: 12px; }
.popup dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0 0; font-size: 12px; }
.popup dt { color: var(--muted); }
.popup dd { margin: 0; }
.leaflet-tooltip.oblast-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-size: 12px;
  width: max-content; max-width: 280px; white-space: normal; }
/* Chrome focuses a clicked SVG path and outlines its bounding box. Paths are not keyboard
   targets (markers are, and keep their outline), and hover already highlights the oblast. */
.leaflet-container path.leaflet-interactive:focus { outline: none; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: rgba(14,17,22,.75) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }

.legend { background: rgba(21,26,33,.92); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--text); }
.legend div { display: flex; align-items: center; gap: 6px; margin: 2px 0; }

/* border watch ("kierunek Polska") */
.border-list { max-height: 210px; }
.border-list .swatch { border-radius: 50%; }
.border-list .eta { font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.push-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.push-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#push-hint { margin: 6px 0 0; }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.on { border-color: var(--ok); }
.btn.ghost { background: none; font-size: 12px; padding: 4px 10px; }
select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font: inherit; font-size: 12px; }
.border-banner { position: absolute; z-index: 1000; top: 10px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 110px); border: 0; border-radius: 10px; padding: 8px 14px;
  font: 600 13px/1.35 system-ui, sans-serif; color: #fff; text-align: left; cursor: pointer;
  background: #b45309; box-shadow: 0 4px 18px rgba(0,0,0,.45); }
.border-banner[data-level="imminent"] { background: #b91c1c; }
.border-banner.flash { animation: flash .5s ease-in-out 4; }
@keyframes flash { 50% { filter: brightness(1.6); } }

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; grid-template-rows: 55dvh 1fr; }
  #panel { border-left: none; border-top: 1px solid var(--line); padding: 12px 16px; }
  .list-section { min-height: 200px; }
  .legend { display: none; }
}

.stats .row .pill { padding: 2px 8px; font-size: 11px; }
.stats code { font-size: 11px; background: var(--panel-2); padding: 1px 4px; border-radius: 4px; }

/* legal pages: regulamin.html, prywatnosc.html */
.legal main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; font-size: 15px; line-height: 1.6; }
.legal h1 { font-size: 24px; margin: 12px 0 4px; }
.legal h2 { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 28px 0 8px; }
.legal ol, .legal ul { padding-left: 22px; }
.legal li { margin: 4px 0; }
.legal code { font-size: 13px; background: var(--panel-2); padding: 1px 4px; border-radius: 4px; }
.legal .table-wrap { overflow-x: auto; }
.legal table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13px; line-height: 1.45; }
.legal th, .legal td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.legal th { background: var(--panel-2); }

/* "about the service" notice at the top of the map panel */
.notice { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--warn);
  border-radius: 8px; padding: 9px 12px; font-size: 12px; line-height: 1.45; }
.notice p { margin: 0 0 4px; }
.notice strong { color: var(--text); }
.notice a { font-weight: 600; }

/* methodology page: metodologia.html */
.legal.method main { max-width: 920px; }
.legal.method h2 { margin-top: 36px; }
.legal.method h3 { font-size: 14px; margin: 0 0 6px; }
.legal.method p { margin: 8px 0; }
.legal.method .lead { font-size: 16px; color: var(--muted); margin: 4px 0 0; }
.legal.method .fine { font-size: 13px; color: var(--muted); }

.callout { background: color-mix(in srgb, var(--warn) 16%, var(--panel)); border: 1px solid var(--warn);
  border-radius: 12px; padding: 20px 22px; margin: 18px 0 8px; }
.legal .callout h2 { font-size: 24px; line-height: 1.25; margin: 0 0 10px; }
.callout p { margin: 8px 0; }
.callout.contact { background: var(--panel); border-color: var(--accent); }

.badges { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.legal .badges, .legal .chain { padding-left: 0; }
.legal .badges li { margin: 0; padding: 4px 12px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 13px; font-weight: 600; }

.chain { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; }
.legal .chain > li { position: relative; margin: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; font-size: 13px; line-height: 1.5; }
.chain > li + li::before { content: "→"; position: absolute; left: -22px; top: 50%; transform: translateY(-50%);
  color: var(--warn); font-size: 18px; font-weight: 700; }
.chain .step { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.chain .self { border-color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 14px 0 0; }
.cards > div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 14px; line-height: 1.5; }
.cards.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cards.is > div { border-top: 3px solid var(--ok); }
.cards.isnt > div { border-top: 3px solid var(--bad); }
.legal .cards ul { margin: 6px 0 0; }

.legal tr.main-source td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.legal .pagefoot { margin-top: 32px; }
.legal .english { margin-top: 36px; padding-top: 4px; border-top: 1px solid var(--line); }

@media (max-width: 800px) {
  .chain { grid-template-columns: 1fr; gap: 26px; }
  .chain > li + li::before { content: "↓"; left: 50%; top: -22px; transform: translateX(-50%); }
  .legal .callout h2 { font-size: 20px; }
}
