:root {
  --bg: #0b0f14;
  --bg-2: #10161d;
  --panel: #141b23;
  --panel-2: #1a232d;
  --line: #233040;
  --text: #e6edf3;
  --muted: #8b98a7;
  --accent: #38bdf8;
  --accent-ink: #04111a;
  --rec: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --bg-2: #eef1f5; --panel: #ffffff; --panel-2: #f3f5f8; --line: #dfe4ea;
    --text: #0f172a; --muted: #5b6676; --accent: #0284c7; --accent-ink: #ffffff;
    --shadow: 0 8px 24px rgba(15, 23, 42, .08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--muted); }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1100;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.brand h1 span { color: var(--rec); font-weight: 700; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.brand .sub b { color: var(--text); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); animation: pulse 1.8s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

.search {
  flex: 1; max-width: 520px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 10px; height: 40px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; }
.search kbd { font: 11px "JetBrains Mono", monospace; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

.views { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.views button {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: none; padding: 7px 12px; border-radius: 7px; color: var(--muted); font-weight: 500;
}
.views button[aria-selected="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.pill { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center; }
.pill:empty, .pill[data-n="0"] { display: none; }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 15%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.error { background: color-mix(in srgb, var(--rec) 15%, var(--panel)); border-color: color-mix(in srgb, var(--rec) 40%, transparent); }

/* ---------- Layout ---------- */
.layout { flex: 1 0 auto; display: grid; grid-template-columns: 360px minmax(0, 1fr); align-items: start; }
.sidebar {
  border-right: 1px solid var(--line); background: var(--bg-2);
  display: flex; flex-direction: column;
  height: calc(100vh - 65px); position: sticky; top: 65px;
}
.filters { padding: 14px 14px 8px; display: grid; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 4px 10px; font-size: 12.5px; color: var(--muted);
  display: inline-flex; gap: 6px; align-items: center;
}
.chip b { font-weight: 600; color: var(--text); font-size: 11px; opacity: .7; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] b { color: var(--accent-ink); }
.toggles { display: flex; gap: 16px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 30px; height: 18px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.list-meta { display: flex; justify-content: space-between; padding: 6px 16px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.cam-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; position: relative; }
.cam {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center;
  padding: 6px; border-radius: 10px; cursor: pointer; position: relative;
}
.cam:hover { background: var(--panel); }
.cam[aria-current="true"] { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.thumb {
  width: 72px; aspect-ratio: 16 / 10; border-radius: 7px; overflow: hidden; position: relative;
  background: linear-gradient(135deg, var(--h1, #1e3a5f), var(--h2, #0f172a));
  display: grid; place-items: center; color: rgba(255, 255, 255, .55);
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 20px; height: 20px; }
.cam-name { font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cam-sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.tag { font-size: 10.5px; font-weight: 600; letter-spacing: .02em; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.tag.portal { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.cam-actions { display: flex; flex-direction: column; gap: 2px; opacity: .55; }
.cam:hover .cam-actions, .cam[aria-current="true"] .cam-actions { opacity: 1; }
.icon-btn { border: 0; background: none; padding: 4px; border-radius: 6px; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.on { color: #facc15; }
.icon-btn.on svg { fill: currentColor; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

/* ---------- Stage ---------- */
.stage { padding: 20px; min-width: 0; }
.player {
  position: relative; aspect-ratio: 16 / 9; width: 100%; max-height: calc(100vh - 180px);
  background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  margin-inline: auto;
}
.player video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.hud { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; pointer-events: none; }
.live, .clock {
  font: 600 12px "JetBrains Mono", monospace; color: #fff; padding: 4px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); display: inline-flex; gap: 6px; align-items: center;
}
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
.player:not(.playing) .live { opacity: .4; }
.player:not(.playing) .live i { animation: none; background: #888; }
@keyframes blink { 50% { opacity: .2; } }
.overlay {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  text-align: center; color: #cbd5e1; background: radial-gradient(circle at center, rgba(15, 23, 42, .65), rgba(0, 0, 0, .9));
  padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay p { margin: 0; max-width: 420px; }
.overlay .big { font-size: 16px; font-weight: 600; color: #fff; }
.overlay .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.spinner { width: 36px; height: 36px; border: 3px solid rgba(255, 255, 255, .15); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 10px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7)); opacity: 0; transition: opacity .2s;
}
.player:hover .controls, .player:focus-within .controls { opacity: 1; }
@media (hover: none) { .controls { opacity: 1; } }
.controls button { border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; }
.controls button:hover { background: rgba(255, 255, 255, .25); }
.grow { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 12px; font-weight: 500;
}
.btn:hover { border-color: var(--accent); }
.btn.on { color: #facc15; }
.btn.on svg { fill: currentColor; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); text-decoration: none; }

.details { margin-top: 18px; }
.title-row { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.title-row h2 { margin: 2px 0 2px; font-size: 22px; letter-spacing: -.01em; }
.title-row p { margin: 0; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.info-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-top: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.addr { margin: 0 0 4px; }
.minimap { height: 340px; border-radius: 10px; margin-top: 12px; border: 1px solid var(--line); }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* Legenda peta */
.legend {
  display: flex; gap: 10px; flex-wrap: wrap; font: 500 11.5px Inter, sans-serif; color: var(--text);
  background: color-mix(in srgb, var(--panel) 90%, transparent); border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 8px; backdrop-filter: blur(4px);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; display: inline-block; }
.legend i.cur { background: var(--rec); }
.legend i.rain { background: rgba(37, 99, 235, .6); border-radius: 3px; border-color: transparent; }
.leaflet-tooltip { font: 12.5px Inter, sans-serif; border-radius: 7px; }

/* Pin kamera yang sedang dilihat */
.cur-pin { position: relative; }
.cur-pin svg { width: 30px; height: 40px; position: relative; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.cur-pulse {
  position: absolute; left: 50%; bottom: 0; width: 14px; height: 6px; margin-left: -7px; border-radius: 50%;
  background: rgba(239, 68, 68, .55); animation: groundpulse 1.6s ease-out infinite;
}
@keyframes groundpulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(4); opacity: 0; } }
.leaflet-tooltip.cur-label {
  background: var(--rec); color: #fff; border: 0; font-weight: 600; padding: 3px 9px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leaflet-tooltip.cur-label::before { border-top-color: var(--rec); }
.leaflet-tooltip.cur-label small { font-weight: 400; opacity: .85; }

/* Kontrol pilihan layer */
.leaflet-control-layers { border-radius: 10px !important; font: 13px Inter, sans-serif; }
.leaflet-control-layers-expanded { padding: 8px 12px; }
@media (prefers-color-scheme: dark) {
  .leaflet-control-layers, .leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); }
  .leaflet-control-layers-separator { border-top-color: var(--line); }
}

/* Status cuaca */
.hud-right { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.wx {
  font: 600 12px Inter, sans-serif; color: #fff; padding: 4px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); display: inline-flex; gap: 5px; align-items: center;
  pointer-events: auto; cursor: help; white-space: nowrap;
}
.wx[hidden] { display: none; }
.wx.wet { background: rgba(37, 99, 235, .85); }
.tile-wx { position: absolute; top: 8px; left: 8px; font-size: 11.5px; }

/* Hitung orang & kendaraan */
.det-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.det-canvas[hidden] { display: none; }
.count-panel {
  position: absolute; top: 44px; left: 12px; z-index: 1;
  background: rgba(0, 0, 0, .62); backdrop-filter: blur(4px); color: #fff; border-radius: 8px;
  padding: 6px 9px; font: 600 12.5px Inter, sans-serif; display: grid; gap: 3px; min-width: 180px;
  pointer-events: none;
}
.count-panel[hidden] { display: none; }
.cp-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.cp-row span:last-child { display: inline-flex; gap: 8px; white-space: nowrap; }
.cp-label { font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.cp-note { font-weight: 400; font-size: 10px; opacity: .65; }
/* Bar pilihan AI di atas video */
.ai-bar {
  display: flex; align-items: center; gap: 12px; margin: 0 auto 12px;
  padding: 10px 14px; border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, var(--panel)), var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  transition: background .2s, border-color .2s;
}
.ai-bar[data-mode="on"] {
  background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 22%, var(--panel)), var(--panel));
  border-color: color-mix(in srgb, var(--ok) 60%, var(--line));
}
.ai-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink);
}
.ai-bar[data-mode="on"] .ai-icon { background: var(--ok); color: #052e12; }
.ai-icon svg { width: 20px; height: 20px; }
.ai-text { display: grid; min-width: 0; flex: 1; }
.ai-text b { font-size: 14.5px; }
.ai-text small { color: var(--muted); font-size: 12.5px; }
.ai-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: none; user-select: none; }
.ai-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ai-track {
  width: 52px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.ai-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); transition: transform .15s;
}
.ai-switch input:checked + .ai-track { background: var(--ok); }
.ai-switch input:checked + .ai-track::after { transform: translateX(22px); }
.ai-switch input:focus-visible + .ai-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-bar[data-mode="loading"] .ai-track { background: var(--warn); }
.ai-state { font: 700 12px "JetBrains Mono", monospace; min-width: 26px; color: var(--muted); }
.ai-bar[data-mode="on"] .ai-state { color: var(--ok); }
@media (max-width: 520px) {
  .ai-bar { padding: 8px 10px; gap: 10px; }
  .ai-icon { width: 30px; height: 30px; }
  .ai-text small { font-size: 11.5px; }
  .ai-state { display: none; }
}
@media (max-width: 520px) {
  .count-panel { top: auto; bottom: 50px; left: 8px; font-size: 10.5px; min-width: 0; padding: 3px 6px; gap: 1px; }
  .count-panel .cp-label { font-size: 9px; }
  .count-panel .cp-row span:last-child { gap: 5px; }
  .count-panel .cp-note { display: none; }
}

/* Titik lokasi di pojok video */
button.wx { border: 0; cursor: pointer; }
.wx.loc { max-width: 240px; }
.wx.loc span:last-child { overflow: hidden; text-overflow: ellipsis; }
.wx.loc.on { background: rgba(239, 68, 68, .85); }
.wx.loc:disabled { cursor: default; opacity: .8; }
.wx.loc:not(:disabled):hover { filter: brightness(1.15); }
.loc-pop {
  position: absolute; top: 46px; right: 12px; width: 220px; aspect-ratio: 4 / 3;
  border-radius: 10px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45); z-index: 2; background: #111;
}
.loc-pop[hidden] { display: none; }
.loc-pop { cursor: grab; touch-action: none; user-select: none; }
.loc-pop.dragging { cursor: grabbing; box-shadow: 0 12px 32px rgba(0, 0, 0, .6); border-color: #fff; }
.loc-map { width: 100%; height: 100%; pointer-events: none; }
.loc-grip {
  position: absolute; top: 5px; left: 50%; width: 34px; height: 4px; margin-left: -17px; border-radius: 4px;
  background: rgba(255, 255, 255, .85); box-shadow: 0 1px 3px rgba(0, 0, 0, .5); z-index: 500; pointer-events: none;
}
.loc-reset {
  position: absolute; top: 4px; right: 4px; z-index: 500; width: 24px; height: 24px; border: 0; border-radius: 6px;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
}
.loc-reset:hover { background: rgba(0, 0, 0, .8); }
.loc-map .leaflet-control-attribution { font-size: 9px; padding: 0 4px; background: rgba(0, 0, 0, .45); color: #ddd; }
.loc-map .leaflet-control-attribution a { color: #ddd; }
.player:fullscreen .loc-pop { width: 300px; }
@media (max-width: 520px) {
  .loc-pop { width: 140px; top: 42px; right: 8px; }
  .wx.loc { max-width: 120px; }
}
.wx-line { margin: 2px 0 6px; font-size: 13px; }
.wx-line small { color: var(--muted); font-size: 11.5px; }
.wx-line.wet b { color: #3b82f6; }
.pin.cur { animation: ring 1.6s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .7); } 100% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); } }

/* Player mengambang di peta */
.map-wrap { position: relative; }
.float {
  position: absolute; top: 12px; right: 12px; z-index: 1000; width: min(380px, calc(100% - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px; display: grid; gap: 10px;
}
.float[hidden] { display: none; }
.float-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.float-head p { margin: 0; }
.float-head b { font-size: 15px; line-height: 1.3; }
.float-video { border-radius: 10px; max-height: none; box-shadow: none; }
.float-video .overlay p { font-size: 12.5px; }
.float-video .overlay .big { font-size: 14px; }
.float-addr { margin: 0; font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.float-addr:empty { display: none; }
.float-actions { display: flex; gap: 8px; }
.float-actions .btn { flex: 1; justify-content: center; }
.nearby { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nearby li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.nearby li:hover { background: var(--panel-2); }
.nearby .dist { font: 12px "JetBrains Mono", monospace; color: var(--muted); white-space: nowrap; }

/* ---------- Multi-view ---------- */
.grid-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.grid-head p { margin: 0; margin-right: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 7px 12px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.grid.s9 { grid-template-columns: repeat(3, 1fr); }
.tile { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .label {
  position: absolute; left: 8px; bottom: 8px; right: 44px; color: #fff; font-size: 12.5px; font-weight: 500;
  background: rgba(0, 0, 0, .55); padding: 3px 8px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .x { position: absolute; top: 8px; right: 8px; border: 0; width: 28px; height: 28px; border-radius: 7px; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; }
.tile .state { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd5e1; font-size: 12.5px; text-align: center; padding: 10px; }
.tile.empty { background: var(--panel); border: 1.5px dashed var(--line); display: grid; place-items: center; color: var(--muted); }
.tile.ok .state { display: none; }
.tile video { cursor: zoom-in; }

/* ---------- Map ---------- */
.map { height: calc(100vh - 105px); border-radius: var(--radius); border: 1px solid var(--line); }
.leaflet-container { background: var(--panel-2); }
@media (prefers-color-scheme: dark) {
  .osm-tiles { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) saturate(.6); }
}
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; font: 13px Inter, sans-serif; }
.leaflet-popup-content b { display: block; margin-bottom: 2px; }
.leaflet-popup-content button { margin-top: 8px; }
.pin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.pin.play { background: var(--ok); }
.pin.portal { background: var(--warn); }
.pin.cur { background: var(--rec); width: 18px; height: 18px; }

/* ---------- Footer & toast ---------- */
.foot { padding: 14px 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-weight: 500;
  transition: all .2s; pointer-events: none; z-index: 2000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .info-grid { grid-template-columns: 1fr; }
  .views button { padding: 7px 9px; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search { order: 3; max-width: none; flex-basis: 100%; margin: 0; }
  .views { margin-left: auto; }
  .views button { font-size: 0; gap: 0; }
  .views button .pill { font-size: 11px; margin-left: 4px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; position: static; height: auto; border-right: 0; border-top: 1px solid var(--line); }
  .cam-list { max-height: 60vh; }
  .stage { padding: 12px 16px; }
  .player { border-radius: 10px; }
  .map { height: 70vh; }
  .float { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
  .minimap { height: 260px; }
  .grid.s9 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .brand .sub { display: none; }
  .grid, .grid.s9 { grid-template-columns: 1fr; }
  .title-row h2 { font-size: 19px; }
}
