:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1b1d22; --muted: #6b6f78; --line: #e4e2dc;
  --accent: #e8483b; --accent-ink: #ffffff; --chip: #f0eee9; --shadow: 0 6px 24px rgba(20,20,30,.12);
  --top-h: 52px; --panel-w: 320px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216; --panel: #171a20; --ink: #eceef2; --muted: #9aa0ab; --line: #2a2e37; --chip: #222630;
    --shadow: 0 6px 24px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #101216; --panel: #171a20; --ink: #eceef2; --muted: #9aa0ab; --line: #2a2e37; --chip: #222630;
  --shadow: 0 6px 24px rgba(0,0,0,.5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.4 Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
#map { position: fixed; top: var(--top-h); left: var(--panel-w); right: 0; bottom: 0; }

.top { position: fixed; inset: 0 0 auto 0; height: var(--top-h); display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 10; }
.brand { font-weight: 700; letter-spacing: .02em; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand .dot { color: var(--accent); }
.logo { width: 18px; height: 18px; border-radius: 4px; background: var(--accent); display: inline-block;
  box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 5px #fff; }
.burger { display: none; border: 0; background: var(--chip); color: var(--ink); border-radius: 8px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.ticker { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.ticker::-webkit-scrollbar { display: none; }
.kpi { flex: 0 0 auto; background: var(--chip); border-radius: 8px; padding: 4px 10px; display: flex; flex-direction: column; line-height: 1.15; }
.kpi b { font: 500 13px/1.2 "JetBrains Mono", ui-monospace, monospace; }
.kpi small { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }

.panel { position: fixed; top: var(--top-h); left: 0; bottom: 0; width: var(--panel-w); background: var(--panel);
  border-right: 1px solid var(--line); z-index: 9; }
.panel-scroll { height: 100%; overflow-y: auto; padding: 8px 16px 24px; }
.panel section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.panel h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: #2fbf71; box-shadow: 0 0 0 0 rgba(47,191,113,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,191,113,.6); } 70% { box-shadow: 0 0 0 8px rgba(47,191,113,0); } 100% { box-shadow: 0 0 0 0 rgba(47,191,113,0); } }
.row { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.row label { color: var(--muted); font-size: 12.5px; }
select { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
.tog { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; user-select: none; }
.tog input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.tog .sw { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.tog span.lbl { flex: 1; }
.tog .n { color: var(--muted); font: 500 11.5px "JetBrains Mono", monospace; }
.sub { padding-left: 26px; display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.sub button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 2px 8px; font-size: 11.5px; cursor: pointer; }
.sub button.on { background: var(--chip); color: var(--ink); border-color: transparent; }
.legend { margin: 6px 0 8px; }
.legend .bar { height: 8px; border-radius: 4px; }
.legend .ends { display: flex; justify-content: space-between; color: var(--muted); font: 500 11px "JetBrains Mono", monospace; margin-top: 3px; }
.legend .src { color: var(--muted); font-size: 11px; margin-top: 2px; }
.seg { display: flex; background: var(--chip); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12.5px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.status { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.status li { display: flex; justify-content: space-between; padding: 3px 0; gap: 8px; }
.status li span:last-child { color: var(--muted); font: 500 11.5px "JetBrains Mono", monospace; white-space: nowrap; }
.status .ok::before, .status .ko::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: #2fbf71; }
.status .ko::before { background: #c9a227; }
.credits { color: var(--muted); font-size: 11px; padding-top: 12px; }

.maplibregl-popup-content { background: var(--panel); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; font: 13px/1.4 Inter, system-ui, sans-serif; max-width: 300px; }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 6px; }
.pop h3 { margin: 0 0 2px; font-size: 14px; padding-right: 14px; }
.pop .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.pop table { border-collapse: collapse; width: 100%; }
.pop td { padding: 2px 0; vertical-align: top; }
.pop td:last-child { text-align: right; font: 500 12px "JetBrains Mono", monospace; padding-left: 12px; }
.pop .bar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.pop .bar i { display: block; height: 100%; background: var(--accent); }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.toast.show { opacity: .92; }

@media (max-width: 760px) {
  :root { --panel-w: 0px; }
  .burger { display: block; }
  .top { padding: 0 12px; gap: 10px; }
  .brand { font-size: 15px; }
  .panel { width: min(88vw, 340px); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .panel.open { transform: none; }
  #map { left: 0; }
}
