/* cam.shpagatka.ru — dark UI for video. No external fonts or assets (CSP self-only). */

:root {
  --bg: #0b0d10;
  --bg-2: #12161b;
  --bg-3: #1a1f26;
  --line: #2a313a;
  --text: #e6e8eb;
  --muted: #8b95a1;
  --accent: #4da3ff;
  --accent-2: #2b7fd9;
  --ok: #34a868;
  --warn: #e3a33b;
  --err: #e5534b;
  --rec: #2f8f5b;
  --radius: 8px;
  --topbar-h: 48px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 17px; }
h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 16px; }
.center { display: flex; justify-content: center; padding: 16px; }
.boot { padding: 32px; text-align: center; }

/* ---------- controls ---------- */
.btn, .icon-btn, .seg-btn, .select, .input {
  font: inherit;
  color: var(--text);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 12px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.btn:hover:not(:disabled) { border-color: #3a434e; background: #212832; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3a8fe8; border-color: #3a8fe8; }
.btn-danger { color: #ffb4ae; }
.btn-danger:hover:not(:disabled) { border-color: var(--err); }
.btn-ghost { background: rgba(0, 0, 0, .35); }
.btn-link { background: none; border: none; color: var(--accent); padding: 4px 0; min-height: 0; }
.btn-small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn-icon { display: inline-flex; width: 18px; height: 18px; }
.btn-icon svg, .icon-btn svg { width: 100%; height: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 7px; flex: none;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.select, .input {
  min-height: 36px; padding: 6px 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.select { padding-right: 28px; cursor: pointer; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; }
.input:disabled { opacity: .6; }

.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.seg-btn {
  min-height: 34px; padding: 4px 10px; border: none; border-right: 1px solid var(--line);
  background: transparent; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--bg-3); }
.seg-btn.active { background: var(--accent-2); color: #fff; }
.seg-small .seg-btn { min-height: 28px; padding: 2px 8px; font-size: 12px; }

@media (pointer: coarse) {
  .btn, .select, .input { min-height: 40px; }
  .seg-btn { min-height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
}

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 500;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted); vertical-align: middle;
}
.badge-accent { color: var(--accent); border-color: #24476b; }

.banner { margin: 8px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); }
.banner-err { border-color: #6b2a27; background: #2a1514; color: #ffc9c4; }
.banner-warn { border-color: #6b5427; background: #2a2214; color: #ffe2b0; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex: none;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) calc(8px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-icon { display: inline-flex; width: 22px; height: 22px; color: var(--accent); }
.brand-icon svg { width: 100%; height: 100%; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-link {
  padding: 7px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--bg-3); }
.nav-link.active { color: var(--text); background: var(--bg-3); box-shadow: inset 0 -2px 0 var(--accent); }
.menu { position: relative; display: flex; align-items: center; gap: 4px; }
.menu-login { color: var(--muted); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; padding: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.menu-user { padding: 6px 10px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none; color: var(--text); font: inherit; border-radius: 6px; cursor: pointer; }
.menu-item:hover { background: var(--bg-3); }

@media (max-width: 600px) {
  .hide-narrow { display: none !important; }
  .brand-text { display: none; }
  .topbar { gap: 6px; }
  .nav-link { padding: 7px 10px; }
}

.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-holder { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap;
  padding: 6px calc(8px + var(--safe-r)) 6px calc(8px + var(--safe-l));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.toolbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.live-toolbar { row-gap: 6px; }
@media (max-width: 480px) {
  .live-toolbar { gap: 6px; }
  .live-toolbar .seg-btn { padding: 4px 6px; font-size: 13px; }
  .live-toolbar .select { max-width: 86px; padding: 4px 22px 4px 8px; font-size: 13px; }
}
/* phone in landscape: compact bars, more room for video */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --topbar-h: 40px; }
  .toolbar { padding-top: 3px; padding-bottom: 3px; }
  .seg-btn { min-height: 32px; }
  .btn, .select, .input { min-height: 34px; }
  .icon-btn { width: 34px; height: 34px; }
}
.quality { display: flex; align-items: center; gap: 6px; }

/* ---------- login ---------- */
.view-login { align-items: center; justify-content: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.login-card {
  width: 100%; max-width: 360px; padding: 24px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
}
.login-title { font-size: 20px; margin-bottom: 16px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form .input { width: 100%; font-size: 16px; } /* 16px: no zoom on iOS focus */
.code-input { letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.field-label { font-size: 13px; color: var(--muted); }
.code-block { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.form-msg { margin: 0; color: var(--text); }
.form-msg:empty, .form-err:empty { display: none; }
.form-err { margin: 0; color: #ffb4ae; }

/* ---------- live ---------- */
.view-live { overflow: hidden; }
.live-stage { position: relative; flex: 1; min-height: 0; background: #000; }
.live-grid {
  position: absolute; inset: 0; display: grid; gap: 2px; background: #000;
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
}
.layout-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.layout-2x2 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.layout-3x3, .layout-1p5 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.layout-4x4, .layout-1p7 { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); }
.layout-1p5 > .tile:first-child { grid-column: span 2; grid-row: span 2; }
.layout-1p7 > .tile:first-child { grid-column: span 3; grid-row: span 3; }

.tile {
  position: relative; overflow: hidden; min-width: 0; min-height: 0;
  background: #0e1114; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  container-type: inline-size;
}
/* The DVR stores 16:9 pictures in narrower pixel grids (944x1080, 928x576, 352x288), so the video is
   stretched (object-fit: fill) into the largest box of the camera's display aspect (--ar, from /api/cameras). */
.tile-video {
  position: absolute; inset: 0; container-type: size;
  display: flex; align-items: center; justify-content: center;
}
.tile video-stream {
  display: block; flex: none;
  width: min(100cqw, calc(100cqh * var(--ar, 1.7778)));
  height: min(100cqh, calc(100cqw / var(--ar, 1.7778)));
}
.tile video-stream video, .tile video { width: 100%; height: 100%; object-fit: fill; background: #000; pointer-events: none; }
video-stream .info { display: none !important; } /* go2rtc demo overlay (mode/status text) */

.tile-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 4px;
  padding: 4px 6px 14px;
  background: linear-gradient(rgba(0, 0, 0, .6), rgba(0, 0, 0, 0));
  pointer-events: none; color: #fff; font-size: 12px; text-shadow: 0 1px 2px #000;
}
.tile-name {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 4px; min-width: 0;
  padding: 2px 6px; margin: -2px -6px; border: none; border-radius: 6px; background: transparent;
  color: #fff; font: 600 13px/1.3 inherit; cursor: pointer; text-shadow: inherit;
}
.tile-name:hover { background: rgba(255, 255, 255, .12); }
.tile-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { opacity: .7; font-size: 10px; }
.tile-clock-wrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tz { opacity: .75; font-size: 10px; }
.tile-bottom {
  position: absolute; right: 4px; bottom: 4px; z-index: 2;
  display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-bottom, .tile:focus-within .tile-bottom { opacity: 1; }
@media (hover: none) { .tile-bottom { opacity: .85; } }
.tile-qual { font-size: 10px; padding: 1px 4px; border-radius: 4px; background: rgba(0, 0, 0, .55); color: #cfd6de; }
.tile-qual:empty { display: none; }
.tile-fs { width: 32px; height: 32px; padding: 6px; background: rgba(0, 0, 0, .55); color: #fff; }
.tile-state {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  padding: 5px 10px 5px 26px; border-radius: 14px; background: rgba(0, 0, 0, .65); color: #dfe5ea;
  font-size: 12px; white-space: nowrap; pointer-events: none;
}
.tile-state::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tile-empty { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.tile.is-empty .tile-empty { display: flex; }
.tile.is-empty .tile-bottom, .tile.is-empty .tile-clock-wrap { display: none; }

@container (max-width: 240px) {
  .tz { display: none; }
  .tile-name { font-size: 11px; }
  .tile-top { font-size: 10px; }
  .tile-state { font-size: 10px; padding-left: 22px; }
  .tile-empty .btn { font-size: 12px; padding: 4px 8px; min-height: 0; white-space: normal; text-align: center; max-width: 92%; }
}
@container (max-width: 150px) {
  .tile-clock-wrap { display: none; }
  .tile-fs { width: 26px; height: 26px; padding: 4px; }
}

.tile.dragging { opacity: .45; }
.tile.drop-target { outline: 3px solid var(--accent); outline-offset: -3px; }
.drag-mode .tile { cursor: grabbing; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none;
  margin: -18px 0 0 -40px; padding: 6px 12px; border-radius: var(--radius);
  background: var(--accent-2); color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .6);
}

.live-stage:fullscreen, .live-stage:-webkit-full-screen { width: 100%; height: 100%; }
.tile:fullscreen, .tile:-webkit-full-screen { width: 100%; height: 100%; cursor: default; }
.pseudo-fs-exit { display: none; }
body.pseudo-fs .topbar, body.pseudo-fs .live-toolbar, body.pseudo-fs .banner { display: none !important; }
body.pseudo-fs .live-stage { position: fixed; inset: 0; z-index: 60; }
body.pseudo-fs .pseudo-fs-exit {
  display: inline-flex; position: absolute; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b)); background: rgba(0, 0, 0, .6); color: #fff;
}

/* ---------- modal / picker ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, .65);
}
.modal {
  width: 100%; max-width: 680px; max-height: calc(100dvh - 32px); overflow: auto;
  padding: 16px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pick-item {
  display: flex; flex-direction: column; gap: 6px; padding: 6px; text-align: left;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
  font: inherit; cursor: pointer;
}
.pick-item:hover { border-color: #3a434e; }
.pick-item.current { border-color: var(--accent); }
.thumb { position: relative; display: block; aspect-ratio: 352 / 288; background: #000; border-radius: 5px; overflow: hidden; }
.thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.thumb-ph { position: absolute; inset: 0; margin: auto; width: 32px; height: 32px; color: #3a434e; }
.thumb-ph svg { width: 100%; height: 100%; }
.pick-name { font-weight: 500; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- archive ---------- */
.view-archive { overflow-y: auto; }
.archive-toolbar { flex-wrap: wrap; }
.date-pick { position: relative; display: flex; align-items: center; gap: 2px; }
.date-btn { min-width: 150px; }
.archive-stage {
  position: relative; flex: none; background: #000;
  height: clamp(220px, 52dvh, 760px);
  container-type: size;
}
.archive-canvas {
  position: absolute; inset: 0; margin: auto; display: block; object-fit: fill;
  width: min(100cqw, calc(100cqh * var(--ar, 1.7778)));
  height: min(100cqh, calc(100cqw / var(--ar, 1.7778)));
}
.archive-stage .tile-top { font-size: 13px; padding: 6px 10px 16px; }
.stage-name { font-weight: 600; }
.stage-time { font-variant-numeric: tabular-nums; }
.stage-hint, .stage-state {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 6px 14px; border-radius: 16px; background: rgba(0, 0, 0, .65); color: #dfe5ea; text-align: center;
  max-width: 90%;
}
.archive-controls {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px calc(12px + var(--safe-r)) calc(16px + var(--safe-b)) calc(12px + var(--safe-l));
  width: 100%; max-width: 1100px; margin: 0 auto;
}
.tl-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.timeline { padding: 0 12px; }
.tl-bar {
  position: relative; height: 40px; border-radius: 6px; cursor: pointer; overflow: hidden;
  background: repeating-linear-gradient(90deg, #1a1f26 0 6px, #161a20 6px 12px);
  border: 1px solid var(--line); touch-action: manipulation;
}
.tl-seg { position: absolute; top: 7px; bottom: 7px; background: var(--rec); border-radius: 2px; min-width: 1px; }
.tl-marker {
  position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff5a5a; z-index: 2;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none;
}
.tl-marker::before {
  content: ""; position: absolute; top: -1px; left: -5px; border: 6px solid transparent; border-top-color: #ff5a5a;
}
.tl-hover {
  position: absolute; top: 0; bottom: 0; z-index: 1; pointer-events: none;
  border-left: 1px solid rgba(255, 255, 255, .55); padding-left: 3px;
  font-size: 10px; line-height: 12px; color: #fff; text-shadow: 0 1px 2px #000; white-space: nowrap;
}
.tl-ticks { position: relative; height: 22px; }
.tl-tick { position: absolute; top: 0; width: 1px; height: 4px; background: #4a525c; }
.tl-tick.major { height: 7px; background: #7d8792; }
.tl-label { position: absolute; top: 7px; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.transport { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.jump-btn { min-width: 64px; font-variant-numeric: tabular-nums; }
.play-btn { width: 56px; height: 44px; padding: 10px; }
.play-btn svg { width: 22px; height: 22px; }
.ctrl-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.goto { display: flex; align-items: center; gap: 6px; }
.time-input { width: 104px; font-variant-numeric: tabular-nums; text-align: center; }
.clip-row .btn { gap: 6px; }

@media (max-width: 420px) {
  .jump-btn { min-width: 0; padding: 6px 8px; }
  .seg-btn { padding: 4px 8px; }
  .date-btn { min-width: 0; }
}

/* phone in landscape: video left, controls right */
@media (orientation: landscape) and (max-height: 520px) {
  .view-archive {
    display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr; overflow: hidden;
  }
  .view-archive > .toolbar, .view-archive > .banner { grid-column: 1 / -1; }
  .archive-stage { grid-column: 1; height: auto; min-height: 0; }
  .archive-controls { grid-column: 2; overflow-y: auto; min-height: 0; padding-top: 6px; gap: 8px; }
}

/* calendar popover */
.popover {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  width: 292px; padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-title { font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-grid.loading { opacity: .5; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-day {
  height: 34px; border-radius: 6px; border: 1px solid transparent; background: transparent;
  color: #59616b; font: inherit; font-variant-numeric: tabular-nums;
}
.cal-day.has { background: #173325; color: var(--text); cursor: pointer; }
.cal-day.has:hover { border-color: var(--rec); }
.cal-day.today { border-color: #3a434e; }
.cal-day.sel { background: var(--accent-2); color: #fff; }
.cal-legend { margin: 8px 0 0; font-size: 11px; }

/* ---------- admin ---------- */
.view-admin { overflow-y: auto; }
.admin-body {
  display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 12px calc(12px + var(--safe-r)) calc(24px + var(--safe-b)) calc(12px + var(--safe-l));
}
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card.inactive { opacity: .6; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-sec { margin-top: 14px; }
.sec-title { font-weight: 600; margin-bottom: 8px; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.add-user { display: flex; flex-direction: column; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.add-user p { margin: 0; }
.cam-ticks { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-tick {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg-3); cursor: pointer;
}
.cam-tick input { margin: 0; accent-color: var(--accent); width: 16px; height: 16px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 40px; height: 22px; border-radius: 11px; background: #3a434e; transition: background .15s; }
.switch-track::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.cam-row { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 8px; }
.cam-id { color: var(--muted); font-variant-numeric: tabular-nums; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 7px 8px; border-bottom: 1px solid #20262e; vertical-align: top; }
.table tr.current td { background: rgba(77, 163, 255, .06); }
.table td .badge { margin-left: 6px; }
.table .actions { text-align: right; white-space: nowrap; }
.audit .detail { color: var(--muted); word-break: break-word; }
.audit tr.ev-login_fail td, .audit tr.ev-locked td { color: #ffc9c4; }
@media (max-width: 720px) {
  .table.resp thead { display: none; }
  .table.resp, .table.resp tbody, .table.resp tr, .table.resp td { display: block; width: 100%; }
  .table.resp tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .table.resp td { border: none; padding: 2px 0; display: flex; gap: 8px; }
  .table.resp td[data-label]::before { content: attr(data-label); color: var(--muted); min-width: 108px; flex: none; }
  .table.resp td.actions { text-align: left; padding-top: 6px; }
}

/* ---------- passkeys + stream quality (SURV-8) ---------- */
a.menu-item { text-decoration: none; }
a.menu-item.active { color: var(--accent); }
.passkey-block { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.passkey-block p { margin: 0; }
.passkey-btn { width: 100%; }
.or-sep { display: flex; align-items: center; gap: 10px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.quality-warn { margin: 0; }
.q-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.q-col { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.q-col legend { padding: 0 4px; font-weight: 600; }
.q-col p { margin: 0; }
.q-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: center; gap: 8px; }
.q-field .select, .q-field .input { width: 100%; min-width: 0; }
.q-actions { margin-top: 12px; flex-wrap: wrap; }
.q-status { margin: 0; }
.q-bad { color: var(--warn); }
@media (max-width: 720px) {
  .q-grid { grid-template-columns: minmax(0, 1fr); }
  .q-field { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
}

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); z-index: 120;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 8px 14px; border-radius: var(--radius); background: #222a33; border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5); transition: opacity .4s; text-align: center;
}
.toast-err { border-color: #6b2a27; background: #2a1514; color: #ffc9c4; }
.toast.hide { opacity: 0; }
