/* CCTV web UI — dark theme, no external assets. */

:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --bg-2: #0f141b;
  --panel: #141a23;
  --panel-2: #1a2230;
  --panel-3: #222c3b;
  --border: #263142;
  --border-2: #34425a;
  --text: #e6ebf2;
  --text-2: #bac4d2;
  --muted: #8693a7;
  --accent: #4c8dff;
  --accent-2: #3a78ea;
  --ok: #3ccf74;
  --warn: #f0b429;
  --bad: #f2555a;
  --off: #6b778a;
  --g-person: #ff9f1c;
  --g-animal: #2ec4b6;
  --g-vehicle: #4c8dff;
  --coverage: #3b6fb8;
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 54px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(76, 141, 255, 0.35); }
.noscript { padding: 24px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ icons */
.icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.icon.big { width: 36px; height: 36px; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h);
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: rgba(15, 20, 27, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; letter-spacing: 0.06em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 24px; height: 24px; color: var(--accent); }
.nav { display: flex; gap: 2px; flex: 1 1 auto; min-width: 0; }
.nav a {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 8px;
  color: var(--text-2); font-weight: 550;
}
.nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--panel-3); color: var(--text); }
.nav a.active svg { color: var(--accent); }
.topbar-right { position: relative; display: flex; align-items: center; gap: 6px; }
.account-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 230px; min-height: 34px; padding: 3px 11px 3px 3px;
  border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--text-2);
  font: inherit; font-weight: 550; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
  width: 300px; max-width: calc(100vw - 16px); padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.account-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-id { display: flex; flex-direction: column; min-width: 0; }
.account-id strong, .account-id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-id span { color: var(--muted); font-size: 12.5px; }
.account-role { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; color: var(--text-2); font-size: 12.5px; }
.account-app:empty { display: none; }

main { padding: 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); max-width: 1680px; margin: 0 auto; outline: none; }

@media (max-width: 720px) {
  :root { --topbar-h: 56px; }
  .topbar { gap: 4px; padding: 0 6px; }
  .brand, .account-name { display: none; }
  .nav { justify-content: space-around; gap: 0; }
  .nav a { flex: 1 1 0; flex-direction: column; gap: 2px; padding: 5px 1px; font-size: 10px; font-weight: 600; letter-spacing: -0.01em; min-width: 0; }
  .account-btn { padding: 1px; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav a svg { width: 20px; height: 20px; }
  main { padding: 10px; }
}

/* ------------------------------------------------------------------ buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--panel-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { background: #3a1719; border-color: #6d2a2e; color: #ffb3b6; }
.btn.danger:hover { background: #4d1d20; }
.btn.danger.solid { background: #c93b40; border-color: #c93b40; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.icon { padding: 6px; width: 34px; min-width: 34px; }
.btn.small { min-height: 28px; padding: 3px 9px; font-size: 13px; }
.btn.small.icon { width: 28px; min-width: 28px; padding: 4px; }
.btn.block { width: 100%; }
.btn[aria-pressed="true"] { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.input, select.input {
  min-height: 34px; padding: 6px 10px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--text); font: inherit;
  min-width: 0;
}
select.input { padding-right: 28px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.25); }
.input[aria-invalid="true"] { border-color: var(--bad); }
input[type="date"].input { min-width: 140px; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span:first-child { font-weight: 600; color: var(--text-2); font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--border-2); transition: background 0.15s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s; }
.switch input:checked + .switch-ui { background: var(--accent-2); border-color: var(--accent-2); }
.switch input:checked + .switch-ui::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-ui { opacity: 0.5; }

.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--border-2); background: var(--panel-2); color: var(--text-2); font: inherit; font-weight: 600; padding: 5px 10px; min-height: 32px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--panel-3); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent-2); color: #fff; }

.btn-group { display: inline-flex; align-items: center; gap: 4px; }

input[type="range"] { accent-color: var(--accent); }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar h1 { margin-right: 8px; }

/* ------------------------------------------------------------------ cards, pills, banners, bars */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--panel-3); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.ok { color: var(--ok); background: rgba(60, 207, 116, 0.12); }
.pill.warn { color: var(--warn); background: rgba(240, 180, 41, 0.12); }
.pill.bad { color: var(--bad); background: rgba(242, 85, 90, 0.13); }
.pill.off { color: var(--muted); }
.pill.admin { color: #a9c7ff; background: rgba(76, 141, 255, 0.16); }
.warn-text { color: var(--warn); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  background: var(--panel-3); color: #fff; font-weight: 700; font-size: 13px; line-height: 1; user-select: none;
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 44px; height: 44px; font-size: 18px; }
.avatar.local { background: rgba(240, 180, 41, 0.16); color: var(--warn); }
.avatar.local .icon { width: 58%; height: 58%; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(60, 207, 116, 0.18); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.off { background: var(--off); }

.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius); border: 1px solid; margin-bottom: 14px; }
.banner .icon { margin-top: 1px; }
.banner.warn { background: rgba(240, 180, 41, 0.09); border-color: rgba(240, 180, 41, 0.35); color: #f7d27a; }
.banner.bad { background: rgba(242, 85, 90, 0.09); border-color: rgba(242, 85, 90, 0.4); color: #ffb3b6; }
.banner.ok { background: rgba(60, 207, 116, 0.07); border-color: rgba(60, 207, 116, 0.3); color: #a6e9bf; }
.banner.info { background: rgba(76, 141, 255, 0.08); border-color: rgba(76, 141, 255, 0.35); color: #b9d0ff; }
.banner strong { color: inherit; }
.banner .muted { color: inherit; opacity: 0.8; }

.bar { position: relative; height: 8px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--accent); }
.bar > span.warn { background: var(--warn); }
.bar > span.bad { background: var(--bad); }
.bar > span.person { background: var(--g-person); }
.bar.stack > span { border-radius: 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

.err-text { color: #ffb3b6; overflow-wrap: anywhere; }
.form-error { color: #ffb3b6; background: rgba(242, 85, 90, 0.1); border: 1px solid rgba(242, 85, 90, 0.35); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }

/* ------------------------------------------------------------------ empty / loading */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 48px 16px; color: var(--muted); }
.empty-title { font-size: 16px; font-weight: 650; color: var(--text); }
.empty p { max-width: 520px; }
.empty.error .icon { color: var(--bad); }
.empty-actions { display: flex; gap: 8px; margin-top: 6px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--muted); }
.spin { width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
.spin.big { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* ------------------------------------------------------------------ toasts & dialogs */
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 24px)); }
.toast { pointer-events: auto; background: var(--panel-3); border: 1px solid var(--border-2); color: var(--text); padding: 9px 14px; border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); font-size: 13.5px; transition: opacity 0.3s, transform 0.3s; }
.toast.error { border-color: rgba(242, 85, 90, 0.6); background: #2c1517; }
.toast.ok { border-color: rgba(60, 207, 116, 0.5); }
.toast.warn { border-color: rgba(240, 180, 41, 0.5); }
.toast.out { opacity: 0; transform: translateY(8px); }

.dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border-2); border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.dialog::backdrop { background: rgba(3, 5, 8, 0.7); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 0 18px; }
.dialog-body { padding: 14px 18px 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.dialog .warnbox { background: rgba(242, 85, 90, 0.08); border: 1px solid rgba(242, 85, 90, 0.35); border-radius: var(--radius-sm); padding: 10px 12px; color: #ffcfd1; margin-bottom: 12px; }

/* ------------------------------------------------------------------ live */
.live-toolbar .delay { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.live-toolbar .delay input { width: 160px; }
.live-toolbar output { font-family: var(--mono); font-size: 12.5px; color: var(--text); min-width: 58px; }
.live-grid { --cols: 2; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .live-grid { grid-template-columns: minmax(0, 1fr); } }

.tile { position: relative; background: #000; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100vh - var(--topbar-h) - 90px); width: 100%; cursor: pointer; }
.tile:fullscreen, .tile:-webkit-full-screen { max-height: none; border-radius: 0; border: 0; aspect-ratio: auto; }
.tile video-stream { position: absolute; inset: 0; display: block; }
.tile video-stream video { width: 100%; height: 100%; object-fit: contain; background: #000; }
video-stream .info { display: none !important; } /* go2rtc's built-in status line; we draw our own */
.tile .overlay, .pb-player .overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tile-head { position: absolute; inset: 0 0 auto 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 8px 8px 22px 12px; background: linear-gradient(rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0)); pointer-events: none; }
.tile-title { display: flex; align-items: center; gap: 8px; min-width: 0; padding-top: 5px; text-shadow: 0 1px 2px #000; }
.tile-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-badge { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: rgba(240, 180, 41, 0.18); color: #f7d27a; white-space: nowrap; }
.tile-actions { display: flex; gap: 4px; pointer-events: auto; }
.tile-actions .btn { background: rgba(10, 14, 20, 0.55); border-color: rgba(255, 255, 255, 0.12); backdrop-filter: blur(4px); }
.tile-actions .btn:hover { background: rgba(30, 38, 52, 0.85); }
.tile-actions .btn[aria-pressed="true"] { background: var(--accent-2); }
.tile-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px 20px 20px; text-align: center; color: var(--text-2); background: radial-gradient(circle at 50% 40%, #121924, #07090d); }
.tile-state.over { background: rgba(5, 7, 10, 0.72); }
.tile-state .icon { width: 34px; height: 34px; color: var(--muted); }
.tile-state.bad .icon { color: var(--bad); }
.tile-state .state-title { font-weight: 650; color: var(--text); font-size: 15px; }
.tile-state .state-text { max-width: 560px; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 860px) {
  .tile-state { padding: 40px 14px 10px; gap: 6px; }
  .tile-state .icon { display: none; }
  .tile-state .state-text { -webkit-line-clamp: 3; }
}
.tile-foot { position: absolute; left: 10px; bottom: 8px; font-size: 11.5px; color: rgba(255, 255, 255, 0.75); text-shadow: 0 1px 2px #000; pointer-events: none; }

/* ------------------------------------------------------------------ playback */
.playback { display: flex; flex-direction: column; gap: 10px; }
.pb-toolbar { margin-bottom: 0; }
.pb-toolbar select.input { min-width: 150px; }
.pb-player { position: relative; background: #000; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100vh - var(--topbar-h) - 262px); min-height: 200px; width: 100%; }
.pb-player:fullscreen, .pb-player:-webkit-full-screen { max-height: none; border: 0; border-radius: 0; aspect-ratio: auto; }
.pb-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.pb-clock { position: absolute; left: 10px; top: 10px; padding: 4px 9px; border-radius: 7px; background: rgba(5, 8, 12, 0.66); font-family: var(--mono); font-size: 14px; color: #fff; pointer-events: none; display: flex; gap: 10px; align-items: baseline; }
.pb-clock .d { color: #c6cfdc; font-size: 12.5px; }
.pb-clock.scrub { outline: 1px solid var(--accent); }
.pb-badge { position: absolute; right: 10px; top: 10px; max-width: 60%; padding: 4px 9px; border-radius: 7px; background: rgba(5, 8, 12, 0.7); color: var(--text-2); font-size: 12.5px; pointer-events: none; }
.pb-spinner { position: absolute; left: 50%; top: 50%; margin: -17px 0 0 -17px; pointer-events: none; }
.pb-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px; background: rgba(5, 7, 10, 0.82); color: var(--text-2); }
.pb-msg .state-title { font-size: 16px; font-weight: 650; color: var(--text); }
.pb-msg .icon { width: 34px; height: 34px; color: var(--muted); }
.pb-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.pb-controls .spacer { flex: 1 1 auto; }
.pb-controls .readout { font-family: var(--mono); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.pb-controls .readout .ev-kind { margin-right: 6px; }
.pb-play { width: 42px !important; min-width: 42px !important; }
@media (max-width: 720px) {
  .pb-player { max-height: none; }
  .pb-controls { gap: 8px; }
  .pb-controls .pb-transport { order: 1; }
  .pb-controls .spacer { order: 2; }
  .pb-controls .pb-extra { order: 3; }
  .pb-controls .pb-speed { order: 4; }
  .pb-controls .switch { order: 5; }
  .pb-controls .readout { order: 10; width: 100%; text-align: center; }
  .pb-clock { font-size: 12.5px; }
}
@media (max-width: 380px) {
  .pb-controls .btn.icon { width: 32px; min-width: 32px; }
  .pb-play { width: 38px !important; min-width: 38px !important; }
}

/* ------------------------------------------------------------------ timeline */
.timeline { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px 6px; }
.tl-canvas-wrap { position: relative; height: 78px; cursor: pointer; touch-action: none; border-radius: 6px; user-select: none; -webkit-user-select: none; }
.tl-canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.tl-tip { position: absolute; bottom: calc(100% + 4px); transform: translateX(-50%); padding: 3px 8px; border-radius: 6px; background: var(--panel-3); border: 1px solid var(--border-2); color: var(--text); font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 5; }
.tl-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; }
.tl-span { min-width: 56px; text-align: center; font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }

/* ------------------------------------------------------------------ events */
.ev-filters select.input { min-width: 130px; }
.ev-filters .range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.ev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
@media (max-width: 560px) { .ev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.ev-day { grid-column: 1 / -1; margin: 10px 0 0; font-size: 13px; font-weight: 650; color: var(--text-2); text-transform: none; }
.ev-day:first-child { margin-top: 0; }
.ev-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: inherit; cursor: pointer; }
.ev-card:hover { border-color: var(--border-2); background: var(--panel-2); }
.ev-thumb { position: relative; aspect-ratio: 16 / 9; background: #06080b; overflow: hidden; }
.ev-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; }
.ev-thumb .ev-box { position: absolute; border: 2px solid; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); pointer-events: none; }
.ev-thumb .ev-noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.ev-tag { position: absolute; left: 6px; top: 6px; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 700; color: #0b0e13; text-transform: capitalize; }
.ev-dur { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 5px; font-size: 11.5px; font-family: var(--mono); background: rgba(0, 0, 0, 0.7); color: #fff; }
.ev-live { position: absolute; right: 6px; top: 6px; padding: 1px 6px; border-radius: 5px; font-size: 11px; font-weight: 700; background: var(--bad); color: #fff; }
.ev-meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.ev-kind { width: 16px; height: 16px; vertical-align: -3px; margin-right: 5px; }
.ev-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-sentinel { height: 1px; }
.ev-foot { padding: 18px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ status */
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 14px; }
.st-cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.st-metric { display: flex; flex-direction: column; gap: 6px; }
.st-metric + .st-metric { margin-top: 12px; }
.st-metric .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.st-metric .row b { font-weight: 650; }
.st-big { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.st-sec { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.st-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; font-weight: 650; }
.st-updated { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ cameras */
.cam-list { display: flex; flex-direction: column; gap: 10px; }
.cam-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.cam-order { display: flex; flex-direction: column; gap: 4px; }
.cam-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cam-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cam-title h2 { font-size: 15px; }
.cam-id { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.cam-url { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; }
.cam-err { color: #ffb3b6; font-size: 12.5px; overflow-wrap: anywhere; }
.cam-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cam-test { margin-top: 6px; }
.pill.vehicles { gap: 5px; color: var(--g-vehicle); background: rgba(76, 141, 255, 0.14); background: color-mix(in srgb, var(--g-vehicle) 15%, transparent); }
.pill.vehicles .icon { width: 14px; height: 14px; }
.switch-field > .switch { align-self: flex-start; }
@media (max-width: 720px) {
  .cam-row { grid-template-columns: auto minmax(0, 1fr); }
  .cam-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.house-list { display: flex; flex-direction: column; gap: 20px; }
.house-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 0 2px; }
.house-head > .icon { color: var(--muted); }
.house-head h2 { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.house-count { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.house-head .spacer { flex: 1 1 auto; }
.house-empty { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 14px; border: 1px dashed var(--border-2); border-radius: var(--radius); }
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 18px; flex-wrap: wrap; }
.test-result { border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13px; border: 1px solid var(--border-2); background: var(--bg-2); }
.test-result.ok { border-color: rgba(60, 207, 116, 0.45); color: #b8f0cd; }
.test-result.bad { border-color: rgba(242, 85, 90, 0.45); color: #ffc4c6; }
.test-result .hint { margin-top: 6px; color: var(--text-2); }
.test-result .line { display: flex; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------ settings */
.settings-card { max-width: 860px; margin-bottom: 14px; }
.settings-card .card-head h2 { font-size: 16px; }
.form-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
@media (max-width: 640px) { .form-cols { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.form-actions .spacer { flex: 1 1 auto; }
.advanced > summary, .howto > summary, .policy-wrap > summary { cursor: pointer; color: var(--text-2); font-weight: 600; padding: 4px 0; }
.advanced[open] > summary { margin-bottom: 8px; }
.howto ol { margin: 10px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.howto code, .settings code { background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.policy-wrap { margin-top: 8px; }
.policy { margin: 8px 0; padding: 10px 12px; max-width: 100%; overflow-x: auto; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font: 12.5px/1.45 var(--mono); color: var(--text-2); user-select: text; }
.save-anyway { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.st-status .banner { margin-bottom: 10px; }
.banner.small { font-size: 13px; padding: 8px 12px; }
.banner a { color: inherit; text-decoration: underline; font-weight: 650; }

/* ------------------------------------------------------------------ login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 50% 20%, #142033, var(--bg) 60%); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 26px 24px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); max-width: none; margin: 0; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-brand svg { width: 30px; height: 30px; color: var(--accent); }
.login-brand h1 { letter-spacing: 0.08em; }
#login-form { display: flex; flex-direction: column; gap: 14px; }
#login-form .input { min-height: 40px; font-size: 15px; }
#login-form .btn { min-height: 42px; font-size: 15px; margin-top: 4px; }
.login-lead { color: var(--text-2); margin-bottom: 14px; }
.login-card > .loading { padding: 18px 0; }
.login-notice { margin-bottom: 16px; }
.login-notice p { margin-top: 4px; font-size: 13px; }
.login-notice .btn { margin-top: 10px; }
.btn.google {
  min-height: 44px; gap: 12px; background: #fff; border-color: #747775; color: #1f1f1f;
  font-family: Roboto, var(--font); font-size: 15px; font-weight: 600;
}
.btn.google:hover { background: #eef1f5; }
.btn.google[aria-busy="true"] { opacity: 0.7; pointer-events: none; }
.g-logo { width: 20px; height: 20px; flex: none; }
.login-help h2 { margin-bottom: 8px; }
.login-help p { color: var(--text-2); margin-bottom: 10px; }
.login-local > summary { cursor: pointer; color: var(--text-2); font-weight: 600; padding: 2px 0; }
.login-local[open] > summary { margin-bottom: 6px; }
.login-local > p { margin-bottom: 12px; }
.login-google:not([hidden]) ~ .login-local { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ accounts */
.acct-section { max-width: 980px; margin-bottom: 22px; }
.acct-section > h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.acct-section > h2 .count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--panel-3); color: var(--text-2); font-size: 12px; text-align: center; }
.acct-intro { margin: -2px 0 10px; }
.acct-list { display: flex; flex-direction: column; gap: 8px; }
.acct-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; }
.acct-row > .avatar { width: 40px; height: 40px; font-size: 16px; }
.acct-row.off .acct-title strong, .acct-row.off > .avatar { opacity: 0.6; }
.acct-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.acct-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.acct-title strong { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-email { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 12.5px; }
.acct-meta .warn-text { color: var(--warn); }
.acct-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.acct-foot { max-width: 980px; }
@media (max-width: 720px) {
  .acct-row { grid-template-columns: auto minmax(0, 1fr); }
  .acct-actions { grid-column: 2 / -1; justify-content: flex-start; }
}

.acct-dialog { width: min(620px, calc(100vw - 24px)); }
.acct-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.acct-form .banner { margin: 0; }
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 6px; font-weight: 600; color: var(--text-2); font-size: 13px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 520px) { .choices { grid-template-columns: minmax(0, 1fr); } }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--bg-2); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: rgba(76, 141, 255, 0.09); }
.choice input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice .help { color: var(--muted); font-size: 12px; }
.access-house { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-2); }
.access-house + .access-house { margin-top: 8px; }
.access-house-head .icon { width: 16px; height: 16px; color: var(--muted); }
.access-cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; margin: 8px 0 0 24px; }
.access-cams .check { min-width: 0; }
.access-cams .check > span:not(.included) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.access-cams .check:has(input:disabled) { cursor: default; }
.access .help { margin-top: 6px; }
.access .help.warn-text { color: var(--warn); }
.included { flex: none; padding: 0 6px; border-radius: 999px; background: rgba(60, 207, 116, 0.12); color: var(--ok); font-size: 11px; font-weight: 650; }
.acct-danger { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.acct-danger-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
