:root {
  --bg: #07111f;
  --panel: #0e1b2e;
  --panel-2: #13243b;
  --text: #eef5ff;
  --muted: #a7b6ca;
  --line: rgba(255,255,255,.12);
  --accent: #59c1ff;
  --danger: #ff7171;
  --shadow: 0 20px 50px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar, .footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #0a1830, #102a44);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.8rem); }
.topbar p { margin: .25rem 0 0; color: var(--muted); }
.stats { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
.stats span {
  border: 1px solid var(--line);
  padding: .45rem .7rem;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(310px, 380px) 1fr;
  min-height: calc(100vh - 138px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar label { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .9rem; }
input, select, button {
  width: 100%;
  min-height: 42px;
  border-radius: .75rem;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: .7rem .8rem;
  font: inherit;
}
input:focus, select:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
button { cursor: pointer; font-weight: 700; background: #143150; margin-top: .75rem; }
button:hover { background: #1a426c; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .75rem; }
.notice { color: var(--muted); font-size: .85rem; line-height: 1.45; }

.camera-list { display: grid; gap: .7rem; margin-top: 1rem; }
.camera-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: .8rem;
  background: rgba(255,255,255,.03);
  cursor: pointer;
}
.camera-card:hover, .camera-card.active { border-color: var(--accent); background: rgba(89,193,255,.08); }
.camera-card h3 { margin: 0 0 .25rem; font-size: 1rem; }
.camera-card p { margin: .25rem 0; color: var(--muted); font-size: .88rem; }
.badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.badge { font-size: .75rem; color: #dcefff; background: rgba(89,193,255,.15); padding: .2rem .45rem; border-radius: 999px; }

.map-panel { position: relative; display: grid; grid-template-rows: minmax(360px, 1fr) auto; }
.map { width: 100%; min-height: 58vh; background: #102039; }
.leaflet-container { background: #102039; color: #111; }

.player-panel {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: var(--shadow);
}
.player-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.player-head h2 { margin: 0; font-size: 1.2rem; }
.player-head p { margin: .25rem 0 0; color: var(--muted); }
.player-head a { color: var(--accent); text-decoration: none; font-weight: 700; white-space: nowrap; }
.player-body {
  margin-top: .9rem;
  background: #02060d;
  border: 1px solid var(--line);
  border-radius: 1rem;
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.player-body.empty { color: var(--muted); }
.player-body iframe, .player-body video, .player-body img {
  display: block;
  width: 100%;
  height: min(55vh, 520px);
  border: 0;
  object-fit: contain;
  background: #000;
}
.error { color: var(--danger); padding: 1rem; text-align: center; }
.footer { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 42vh; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats { justify-content: flex-start; }
}

.update-warnings {
  border: 1px solid rgba(255, 180, 80, .35);
  background: rgba(255, 180, 80, .08);
  color: #ffd49b;
  border-radius: .8rem;
  padding: .65rem .75rem;
  font-size: .82rem;
}
.update-warnings summary { cursor: pointer; font-weight: 700; }
.update-warnings ul { margin: .5rem 0 0 1rem; padding: 0; }

.player-body.frame-mode,
.player-body.image-mode {
  display: block;
  place-items: initial;
}
.player-body.frame-mode iframe,
.player-body.image-mode img {
  height: min(55vh, 520px);
}
.player-help {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: center;
  padding: .65rem .85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  font-size: .86rem;
}
.player-help a,
.external-card a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.external-card {
  max-width: 680px;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
}
.external-card .small-note {
  font-size: .84rem;
  line-height: 1.45;
  margin-top: .9rem;
}
