:root {
  --bg: #0f1418;
  --panel: #182027;
  --panel-2: #212b34;
  --line: #2c3842;
  --text: #e6edf3;
  --muted: #8b9aa7;
  --accent: #3aa0ff;
  --live: #e5484d;
  --warn: #f5a524;
  --keep: #f5c542;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--live); min-height: 1.4em; }

.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.icon { padding: 4px 7px; }
.badge { border-radius: 4px; padding: 2px 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.badge.live { background: var(--live); color: #fff; }
.badge.warn { background: var(--warn); color: #000; }

/* Kirjautuminen */
.login { display: grid; place-items: center; height: 100%; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px;
  width: min(340px, 92vw); display: grid; gap: 14px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-box label { display: grid; gap: 4px; color: var(--muted); }
.login-box input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px; font: inherit; }
.login-box button { background: var(--accent); border: 0; color: #fff; border-radius: 6px; padding: 10px; font: inherit;
  font-weight: 600; cursor: pointer; }

/* Sovellus */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; margin-right: 6px; display: flex; gap: 8px; align-items: center; }
.layouts { display: flex; gap: 4px; }
.spacer { flex: 1; }

.streams-panel { position: absolute; z-index: 20; top: 52px; left: 10px; width: min(460px, calc(100vw - 20px));
  max-height: calc(100vh - 70px); overflow: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.follow { color: var(--muted); font-size: 12px; }
#streams-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#streams-list li { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; background: var(--panel-2); }
#streams-list li.current { border-color: var(--accent); }
#streams-list li .meta { flex: 1; min-width: 0; }
#streams-list li .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#streams-list li .keep { color: var(--muted); }
#streams-list li .keep.on { color: var(--keep); }
#streams-list .empty { cursor: default; color: var(--muted); }

.main { flex: 1; min-height: 0; display: grid; gap: 1px; background: var(--line); }
.pane { background: var(--bg); min-width: 0; min-height: 0; position: relative; }
.layout-video { grid-template: "video" 1fr / 1fr; }
.layout-video .map-pane, .layout-video .tele-pane { display: none; }
.layout-video-map { grid-template: "video map" 1fr / 3fr 2fr; }
.layout-video-map .tele-pane { display: none; }
.layout-video-map-tele { grid-template: "video map" 3fr "video tele" 2fr / 3fr 2fr; }
.layout-map-tele { grid-template: "map tele" 1fr / 3fr 1fr; }
.layout-map-tele .video-pane { display: none; }
.video-pane { grid-area: video; background: #000; }
.map-pane { grid-area: map; }
.tele-pane { grid-area: tele; overflow: auto; padding: 10px 14px; }
@media (max-width: 800px) {
  .layout-video-map { grid-template: "video" 1fr "map" 1fr / 1fr; }
  .layout-video-map-tele { grid-template: "video" 2fr "map" 2fr "tele" 1fr / 1fr; }
  .layout-map-tele { grid-template: "map" 2fr "tele" 1fr / 1fr; }
  .layouts .btn { padding: 6px 7px; }
}

video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; }
.video-empty .big { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.video-overlay { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between;
  pointer-events: none; }
.video-overlay > * { pointer-events: auto; }
.clock { background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.clock:empty { display: none; }
.golive { background: var(--live); border-color: var(--live); color: #fff; font-weight: 600; margin-left: auto; }

#map { position: absolute; inset: 0; }
.tele-pane h3 { margin: 6px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tele-pane dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 14px; }
.tele-pane dt { color: var(--muted); }
.tele-pane dd { margin: 0; font-variant-numeric: tabular-nums; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  width: min(620px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; }
dialog h3 { font-size: 14px; margin: 18px 0 6px; }
.url-row { display: flex; gap: 6px; margin-bottom: 6px; }
.url-row input { flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px; font: 12px ui-monospace, monospace; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
