:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #16223c;
  --text: #e6edf7;
  --muted: #8aa0c0;
  --accent: #38bdf8;
  --info: #4a9eff;
  --warning: #ffb020;
  --alert: #ff7043;
  --critical: #f43f5e;
  --line: #22314f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
}
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1200;
  display: flex; align-items: baseline; gap: 12px; padding: 10px 16px;
  background: linear-gradient(180deg, rgba(11,18,32,.95), rgba(11,18,32,.55));
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
header h1 { font-size: 17px; letter-spacing: .5px; }
header h1 span { color: var(--accent); font-weight: 700; }
header .sub { font-size: 11px; color: var(--muted); }
.status-row { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.lang {
  cursor: pointer; font-weight: 700; color: var(--accent); border-color: var(--accent);
  background: rgba(56,189,248,.12);
}
.badge.lang:hover { background: rgba(56,189,248,.25); }
#map { position: absolute; inset: 0; }
#panel {
  position: fixed; z-index: 1100; top: 52px; right: 12px; bottom: 12px; width: 300px;
  overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  scrollbar-width: thin;
}
.panel-section { margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tab { flex: 1; font-size: 12px; padding: 7px 0; border: none; border-radius: 7px; cursor: pointer; background: transparent; color: var(--muted); transition: all .15s; }
.tab.active { background: var(--accent); color: #06121f; font-weight: 700; }
.hidden { display: none; }
.about { font-size: 12px; line-height: 1.65; padding-left: 18px; color: var(--text); }
.about li { margin-bottom: 6px; }
.src-list { font-size: 12px; line-height: 1.55; }
.src-item { padding: 8px 10px; margin-bottom: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.src-item a { color: var(--accent); display: block; font-size: 11px; margin-top: 2px; word-break: break-all; }
.contact { font-size: 12px; margin-bottom: 6px; }
.mailto { color: var(--accent); font-weight: 600; word-break: break-all; }
.kofi {
  display: block; text-align: center; margin: 10px 0; padding: 10px;
  background: linear-gradient(135deg, #ff5e5b, #ff9345); color: #fff;
  font-weight: 700; border-radius: 10px; text-decoration: none; font-size: 13px;
  box-shadow: 0 4px 14px rgba(255,94,91,.35); transition: transform .15s;
}
.kofi:hover { transform: translateY(-2px); }
.links { display: flex; flex-direction: column; gap: 4px; font-size: 12px; margin-top: 8px; }
.links a { color: var(--accent); text-decoration: none; }
.links a:hover { text-decoration: underline; }
.legal { font-size: 11px; line-height: 1.6; color: var(--muted); }

.kofi-fixed {
  position: fixed; bottom: 20px; left: 20px; z-index: 9999;
  background: #ff5e5b; color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 14px; font-weight: bold; text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .5s, transform .5s;
}
.kofi-fixed:hover { transform: scale(1.05); }
.kofi-fixed.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.panel-section h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); margin: 12px 0 8px;
}
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  font-size: 11px; padding: 5px 9px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); transition: all .15s;
}
.filters button.active { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.level-filters button.lvl-warning { border-left: 3px solid var(--warning); }
.level-filters button.lvl-alert { border-left: 3px solid var(--alert); }
.level-filters button.lvl-critical { border-left: 3px solid var(--critical); }
.chk { display: block; font-size: 12px; margin: 6px 0; cursor: pointer; color: var(--text); }
.chk input { accent-color: var(--accent); margin-right: 6px; }
.year-select {
  width: 100%; font-size: 12px; padding: 6px 8px; border-radius: 8px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  cursor: pointer; accent-color: var(--accent);
}
.route-legend { font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.route-legend b { color: var(--text); }
.swatch { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.summary, .sources { font-size: 12px; line-height: 1.6; }
.summary .row, .sources .row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 2px 0; }
.summary .row:last-child, .sources .row:last-child { border-bottom: none; }
.summary .dot, .sources .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.ok { color: #4ade80; } .err { color: var(--critical); }
.foot { font-size: 10px; color: var(--muted); margin-top: 10px; text-align: center; }

.flow-marker { background: transparent; border: none; }
.flow-marker div {
  width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 0 6px rgba(0,0,0,.6);
}
.leaflet-popup-content-wrapper { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; }
.leaflet-popup-tip { background: var(--panel-2); }
.popup h3 { font-size: 13px; margin-bottom: 4px; }
.popup .meta { font-size: 11px; color: var(--muted); }
.popup .val { font-size: 14px; font-weight: 700; margin: 4px 0; }
.popup .desc { font-size: 11px; color: var(--muted); white-space: pre-wrap; max-height: 120px; overflow: auto; }
.popup .lvl { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.lvl-info { background: var(--info); color: #04121f; }
.lvl-warning { background: var(--warning); color: #241603; }
.lvl-alert { background: var(--alert); color: #2a0d02; }
.lvl-critical { background: var(--critical); color: #fff; }

.popup-footer { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.popup-btn { background: var(--accent); border: 0; color: #06121f; font-size: 11px; font-weight: 700;
  padding: 5px 10px; border-radius: 7px; cursor: pointer; width: 100%; }
.popup-btn:hover { filter: brightness(1.1); }
.country-popup .cp-sub { font-size: 11px; font-weight: 600; margin: 8px 0 4px; color: var(--muted); }
.country-popup .cp-date { font-weight: 400; }
.country-popup .cp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.country-popup .cp-table td { padding: 2px 0; }
.country-popup .cp-table td.cp-v { text-align: right; font-weight: 700; }
.country-popup .cp-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 2px 0; }
.country-popup .cp-row b { font-weight: 700; }
.country-popup .cp-none { font-size: 11px; color: var(--muted); font-style: italic; }
.country-popup .cp-delta { font-size: 10px; font-weight: 700; }
.country-popup .cp-foot { font-size: 9px; color: var(--muted); margin-top: 4px; }
.cp-delta.up { color: #34d399; }
.cp-delta.down { color: #f87171; }
.cp-delta.flat { color: var(--muted); }

.intro {
  position: fixed; inset: 0; z-index: 10001; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(5,10,20,.82);
  backdrop-filter: blur(4px);
}
.intro-card {
  position: relative; max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.intro-card h2 { font-size: 22px; margin-bottom: 10px; }
.intro-card h2 span { color: var(--accent); }
.intro-lead { font-size: 13px; line-height: 1.7; color: var(--muted); margin-bottom: 16px; }
.intro-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.intro-stat {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; text-align: center;
}
.intro-stat b { display: block; font-size: 20px; color: var(--accent); }
.intro-stat span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.intro-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 14px 0 8px; }
.intro-list { padding-left: 18px; font-size: 13px; line-height: 1.8; }
.intro-method { font-size: 13px; line-height: 1.6; color: var(--muted); }
.intro-cta { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.btn-primary {
  border: none; cursor: pointer; padding: 12px 22px; font-size: 14px; font-weight: 700;
  color: #06121f; background: linear-gradient(135deg, #38bdf8, #22d3ee);
  border-radius: 12px; box-shadow: 0 6px 18px rgba(56,189,248,.35); transition: transform .15s;
}
.btn-primary:hover { transform: translateY(-2px); }
.intro-link { font-size: 13px; color: var(--accent); text-decoration: none; }
.intro-link:hover { text-decoration: underline; }
.intro-foot { font-size: 11px; color: var(--muted); margin-top: 16px; text-align: center; }
.intro-close {
  position: absolute; top: 12px; right: 12px; border: none; cursor: pointer;
  background: var(--panel-2); color: var(--text); width: 30px; height: 30px;
  border-radius: 50%; font-size: 18px; line-height: 1; border: 1px solid var(--line);
}
.intro-close:hover { background: var(--critical); color: #fff; }
.intro.hidden { display: none; }

.choropleth-legend {
  position: absolute; z-index: 1000; right: 322px; bottom: 24px;
  background: rgba(17,26,46,.92); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 10px; color: var(--text);
  box-shadow: 0 6px 20px rgba(0,0,0,.4); backdrop-filter: blur(4px);
}
.choropleth-legend .cl-title { font-weight: 700; margin-bottom: 5px; color: var(--accent); text-transform: uppercase; letter-spacing: .8px; }
.choropleth-legend .cl-bar {
  width: 160px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, #fbe6d6, #fec884, #fd8d3c, #d94815, #8c2d04);
}
.choropleth-legend .cl-scale { display: flex; justify-content: space-between; margin-top: 3px; color: var(--muted); }

@media (max-width: 720px) {
  #panel { width: min(300px, 82vw); top: 90px; }
  header .sub { display: none; }
}
