/* =========================================================================
   CCTV Planet — "soft clay" design system (neumorphism)

   One surface colour for everything. Elements are shaped by light, not by
   borders: a raised piece throws a dark shadow bottom-right and a light one
   top-left; a sunken piece (an input, a groove, a pressed button) does the
   reverse, inset. The brand gradient - crimson -> magenta -> indigo, sampled
   from the logo - is kept for the things that matter: the primary action,
   the selected state, the live signal, and the glow behind them.

   Two palettes: the dark one is the default (a control room is a dim place
   and the video is black anyway); data-theme="light" on <html> is the pale
   clay version. Everything below reads from tokens, so the swap is complete.
   ========================================================================= */

/* Typefaces, served from this site (app.js /vendor/fonts) instead of Google
   Fonts. Variable fonts: one file per script covers every weight. Latin plus
   Latin-extended (names with accents); anything else falls back to the
   system font. font-display: swap - text shows at once in the fallback and
   switches when the file lands (it is preloaded in partials/head.ejs). */
@font-face {
  font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/vendor/fonts/inter/inter-latin-wght-normal.woff2?v=5.3.0') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/vendor/fonts/inter/inter-latin-ext-wght-normal.woff2?v=5.3.0') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Outfit'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/vendor/fonts/outfit/outfit-latin-wght-normal.woff2?v=5.3.0') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Outfit'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/vendor/fonts/outfit/outfit-latin-ext-wght-normal.woff2?v=5.3.0') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}


:root {
  /* ---- Surface & light ---- */
  --bg: #1b202a;
  --bg-deep: #161a22;           /* a slightly deeper well, for sunken areas */
  --shadow-dark: #0f1219;
  --shadow-light: #272f3c;
  --edge: rgba(255, 255, 255, 0.045); /* a hairline of light on a raised top edge */
  --text: #e9edf4;
  --muted: #9aa6b8;
  --faint: #7b879b;             /* >= 4.5:1 on --bg for small text */
  --screen: #000;               /* the picture itself is always black-backed */

  /* ---- Brand ---- */
  --brand-red: #e5382a;
  --brand-magenta: #9a2f91;
  --brand-indigo: #473c86;
  --brand-pink: #e31c79;        /* reserved: live badge / alert state only */
  --accent: #b043a6;            /* links and selected outlines, lifted for dark */
  --gradient-brand: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-magenta) 55%, var(--brand-indigo) 100%);
  --glow: rgba(176, 67, 166, 0.38);
  --glow-strong: rgba(229, 56, 42, 0.35);

  /* ---- Ambient blobs (behind everything, slowly drifting) ---- */
  --blob-1: rgba(229, 56, 42, 0.13);
  --blob-2: rgba(71, 60, 134, 0.20);
  --blob-3: rgba(154, 47, 145, 0.12);

  /* ---- Semantic ---- */
  --success: #34c46a;
  --warn: #e8b84a;
  --danger: #f4574d;
  --info: #5aa7ff;

  /* ---- Shadows: the whole language ---- */
  --raise:     10px 10px 22px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
  --raise-sm:   5px  5px 12px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  --raise-xs:   3px  3px  7px var(--shadow-dark), -2px -2px  6px var(--shadow-light);
  --inset:      inset 6px 6px 14px var(--shadow-dark), inset -5px -5px 12px var(--shadow-light);
  --inset-sm:   inset 3px 3px  8px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  --inset-xs:   inset 2px 2px  5px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
  --ring:       0 0 0 3px var(--glow);

  /* ---- Spacing (8px grid) ---- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* ---- Radius / motion ---- */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-full: 999px;
  --ease: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --spring: 260ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  color-scheme: dark;
}

/* Pale clay: same shapes, lit from a bright room. */
:root[data-theme="light"] {
  --bg: #e3e8f1;
  --bg-deep: #d9dfe9;
  --shadow-dark: #b9c2d2;
  --shadow-light: #ffffff;
  --edge: rgba(255, 255, 255, 0.6);
  --text: #222a38;
  --muted: #5b6a80;
  --faint: #6d7b90;
  --accent: #9a2f91;
  --glow: rgba(154, 47, 145, 0.28);
  --blob-1: rgba(229, 56, 42, 0.10);
  --blob-2: rgba(71, 60, 134, 0.12);
  --blob-3: rgba(154, 47, 145, 0.10);
  --success: #1f9d4f;
  --warn: #b7841a;
  --danger: #d63b31;
  --info: #2a6fd6;
  color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
/* The hidden attribute must win over any display rule, or a flex/grid item
   that a script hides (a filtered-out camera, a folded panel) stays visible. */
[hidden] { display: none !important; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-size: 14.5px; line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative; z-index: 0;
}
/* The room's light: three soft colour pools that drift very slowly. Painted
   on a fixed layer behind the page - no filter, so it costs almost nothing. */
body::before {
  content: '';
  position: fixed; inset: -22%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 42% at 18% 22%, var(--blob-1), transparent 62%),
    radial-gradient(38% 38% at 82% 12%, var(--blob-2), transparent 62%),
    radial-gradient(46% 46% at 55% 92%, var(--blob-3), transparent 62%);
  animation: ambient 42s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes ambient {
  from { transform: translate3d(-2.5%, -1.5%, 0) rotate(-2deg) scale(1.02); }
  to   { transform: translate3d(2.5%, 1.5%, 0) rotate(3deg) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

a { color: var(--accent); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--text); }
::selection { background: rgba(154, 47, 145, 0.35); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

h1, h2, h3, .brand, .tf-name, .nvr-camname { font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 var(--sp-4); font-weight: 700; }
h2 { font-size: 1.05rem; color: var(--text); margin: var(--sp-6) 0 var(--sp-3); font-weight: 600; }

/* Scrollbars that belong to the surface. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--shadow-light); border-radius: var(--r-full); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ---------- Surface helpers ---------- */
.card { background: var(--bg); box-shadow: var(--raise); border-radius: var(--r-lg); }

/* ---------- Top navigation ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6);
  background: var(--bg);
  /* Attached to the top edge, so it only casts downward. */
  box-shadow: 0 8px 22px var(--shadow-dark), inset 0 -1px 0 var(--edge);
  position: sticky;
  top: 0;
  z-index: 10;
}
/* The back arrow, first thing on the bar on every page below the menu tabs. */
.topbar .nav-back { flex: none; width: 38px; height: 38px; color: var(--text); box-shadow: var(--raise-xs); }
.topbar .nav-back svg { width: 18px; height: 18px; }
.topbar img.logo { height: 32px; width: auto; display: block; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)); }
.topbar .brand-link {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  color: var(--text); text-decoration: none; flex: none;
  padding: var(--sp-1) var(--sp-2); margin-left: calc(-1 * var(--sp-2));
  border-radius: var(--r-md);
  transition: box-shadow var(--ease), transform var(--ease);
}
.topbar .brand-link:hover { box-shadow: var(--raise-xs); }
.topbar .brand-link:active { box-shadow: var(--inset-xs); transform: scale(0.99); }
.topbar .brand { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.topbar nav { display: flex; gap: var(--sp-1); margin-left: var(--sp-4); min-width: 0; }
.topbar nav a {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--sp-1);
  color: var(--muted);
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.topbar nav .nav-ic { display: none; }
.topbar nav a:hover { color: var(--text); box-shadow: var(--raise-xs); transform: translateY(-1px); }
.topbar nav a:active { box-shadow: var(--inset-xs); transform: none; }
/* The current page sits pressed into the bar with the brand line lit under it. */
.topbar nav a.active { color: var(--text); box-shadow: var(--inset-sm); transform: none; }
.topbar nav a.active::after {
  content: '';
  position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: 4px; height: 2px;
  border-radius: var(--r-full);
  background: var(--gradient-brand);
  box-shadow: 0 0 10px var(--glow);
}
.topbar .spacer { flex: 1; }
.topbar .who {
  color: var(--muted); font-size: 0.82rem; white-space: nowrap; text-decoration: none;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  transition: color var(--ease), box-shadow var(--ease);
}
.topbar .who:hover { color: var(--text); box-shadow: var(--raise-xs); }
.topbar .who-icon { display: none; }
.topbar .btn { margin-top: 0; padding: var(--sp-2) var(--sp-3); font-size: 0.82rem; white-space: nowrap; }
.topbar form { flex: none; }
.theme-toggle { flex: none; }
.theme-toggle .ic-sun, .theme-toggle .ic-moon { display: inline-flex; }
:root[data-theme="light"] .theme-toggle .ic-moon { display: none; }
:root:not([data-theme="light"]) .theme-toggle .ic-sun { display: none; }

@media (max-width: 1100px) {
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .topbar nav { margin-left: var(--sp-2); }
  .topbar nav a { padding: var(--sp-2) var(--sp-2); }
  .topbar .who { display: none; }
  .topbar .who-icon { display: inline-flex; }
}

/* ---------- Layout ---------- */
.container { max-width: 1400px; margin: 0 auto; padding: var(--sp-6); }
.container.narrow { max-width: 640px; }
.card + .card { margin-top: var(--sp-5); }

.card {
  position: relative;
  padding: var(--sp-6);
  overflow: hidden;
  transition: box-shadow var(--ease);
}
/* The brand's signature: a thin lit line inset along the card's top. */
.card::before {
  content: '';
  position: absolute; top: 0; left: var(--sp-6); right: var(--sp-6); height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--gradient-brand); opacity: 0.85;
  box-shadow: 0 2px 12px var(--glow);
}

.flash, .error-box {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  font-size: 0.9rem;
  background: var(--bg-deep);
  box-shadow: var(--inset-sm);
}
.flash.ok { color: var(--success); }
.flash.warn { color: var(--warn); }
.error-box { color: var(--danger); }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.8rem; color: var(--muted); margin: var(--sp-4) 0 var(--sp-2); font-weight: 600; letter-spacing: 0.01em; }
/* :where() keeps this base rule at zero specificity, so a plain class such as
   .search-field input can override its padding - five :not()s made it beat
   every class rule and the search icon sat on top of the placeholder text. */
input:where(:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button])),
select, textarea {
  width: 100%;
  background: var(--bg-deep);
  border: 0;
  color: var(--text);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  font-size: 0.93rem;
  font-family: inherit;
  box-shadow: var(--inset-sm);
  transition: box-shadow var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled { opacity: 0.55; cursor: not-allowed; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: var(--inset-sm), 0 0 0 1000px var(--bg-deep) inset;
  box-shadow: var(--inset-sm), 0 0 0 1000px var(--bg-deep) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}
input:focus, textarea:focus, select:focus { outline: none; box-shadow: var(--inset-sm), var(--ring); }
input[type=file] { color: var(--muted); padding-left: 0; background: none; box-shadow: none; }
textarea { min-height: 84px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0; }
.checkbox-row input { width: auto; accent-color: var(--brand-magenta); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-magenta); width: 16px; height: 16px; }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3e%3cpath d='M1 1L5 5L9 1' stroke='%239aa6b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
:root[data-theme="light"] select { background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3e%3cpath d='M1 1L5 5L9 1' stroke='%235b6a80' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e"); }

/* Buttons are pieces you can press: raised at rest, sunk while held. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--gradient-brand);
  color: #fff;
  border: 0;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  margin-top: var(--sp-4);
  box-shadow: var(--raise-sm), 0 6px 18px var(--glow-strong);
  transition: transform var(--spring), box-shadow var(--ease), filter var(--ease);
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--raise), 0 10px 26px var(--glow-strong); filter: brightness(1.06); color: #fff; }
.btn:active { transform: translateY(0) scale(0.98); box-shadow: var(--inset-sm), 0 2px 10px var(--glow-strong); filter: brightness(0.96); }
.btn.secondary { background: var(--bg); color: var(--text); box-shadow: var(--raise-sm); }
.btn.secondary:hover { box-shadow: var(--raise); filter: none; color: var(--text); }
.btn.secondary:active { box-shadow: var(--inset-sm); }
.btn.danger { background: var(--bg); color: var(--danger); box-shadow: var(--raise-sm); }
.btn.danger:hover { box-shadow: var(--raise); filter: none; color: var(--danger); }
.btn.danger:active { box-shadow: var(--inset-sm); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: var(--raise-xs); filter: grayscale(0.4); }
.btn-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ---------- Page header (list pages) ---------- */
.page-header { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-header h1 { margin: 0; }
.page-header .btn { margin-top: 0; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 calc(-1 * var(--sp-2)); padding: 0 var(--sp-2); }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 480px; }
table th, table td { text-align: left; padding: var(--sp-3) var(--sp-3); font-size: 0.88rem; vertical-align: middle; }
table th { color: var(--faint); font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; }
/* Embossed hairlines between rows: a dark line with a light line under it. */
table tbody td { border-top: 1px solid var(--shadow-dark); box-shadow: inset 0 1px 0 var(--shadow-light); }
table tbody tr { transition: background var(--ease); }
table tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
:root[data-theme="light"] table tbody tr:hover td { background: rgba(0, 0, 0, 0.03); }
td.row-actions { white-space: nowrap; vertical-align: middle; text-align: right; }
td.row-actions > * { display: inline-flex; vertical-align: middle; margin-left: var(--sp-1); }
td.row-actions > *:first-child { margin-left: 0; }
.row-actions:not(td) { display: flex; gap: var(--sp-1); }
tr[data-href] { cursor: pointer; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--bg); border: 0; color: var(--muted);
  cursor: pointer; box-shadow: none;
  transition: box-shadow var(--ease), color var(--ease), transform var(--spring);
}
.icon-btn:hover { box-shadow: var(--raise-xs); color: var(--text); transform: translateY(-1px); }
.icon-btn:active { box-shadow: var(--inset-xs); transform: none; }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn svg { width: 15px; height: 15px; }

/* Pills sit in the surface (sunken) with their meaning in the colour. */
.pill {
  display: inline-flex; align-items: center; padding: 3px 11px; border-radius: var(--r-full);
  background: var(--bg-deep); box-shadow: var(--inset-xs);
  font-size: 0.72rem; color: var(--muted); font-weight: 600; white-space: nowrap;
}
.pill.admin { color: #fff; background: var(--gradient-brand); box-shadow: var(--raise-xs); }
.pill.live { color: #fff; background: var(--brand-pink); box-shadow: var(--raise-xs), 0 0 12px rgba(227, 28, 121, 0.5); font-weight: 700; letter-spacing: 0.03em; }
.pill.ok { color: var(--success); }
.pill.down { color: var(--danger); }
.pill.warn { color: var(--warn); }

/* Status pills used by the complaint and health pages. */
.t-status, .health-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: var(--r-full);
  background: var(--bg-deep); box-shadow: var(--inset-xs);
  font-size: 0.74rem; font-weight: 700; white-space: nowrap;
}
.t-status.is-open, .health-badge.is-down { color: var(--danger); }
.t-status.is-in_progress, .health-badge.is-warn { color: var(--warn); }
.t-status.is-resolved, .health-badge.is-ok { color: var(--success); }

/* Key/value blocks (site recorder card, account page, complaint meta). */
.kv { display: grid; grid-template-columns: 116px 1fr; gap: var(--sp-2) var(--sp-3); margin: 0; }
.kv dt { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.kv dd { margin: 0; font-size: 0.9rem; word-break: break-word; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.86em; }
.muted { color: var(--muted); }
.static-field { padding: var(--sp-3) 0; font-size: 0.95rem; font-weight: 600; }
.field-hint { color: var(--muted); font-size: 0.78rem; margin: 6px 0 4px; }
/* ── Site check card (partials/site-check.ejs) ──────────────────── */
.chk .chk-when { font-size: 0.78rem; }
.chk-verdict { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-2) 0 var(--sp-3); }
.chk-pill { padding: 5px 12px; border-radius: var(--r-full); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.03em; background: var(--bg-deep); box-shadow: var(--inset-xs); }
.chk-verdict.is-ok .chk-pill { color: var(--success); }
.chk-verdict.is-attention .chk-pill { color: var(--warn); }
.chk-verdict.is-down .chk-pill { color: var(--danger); }
.chk-summary { font-weight: 700; }
.chk-next { padding: 10px 14px; margin: 0 0 var(--sp-3); border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-sm), 0 0 0 1px var(--glow); font-size: 0.9rem; }
.chk-next-label { display: block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 3px; }
.chk-who { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: var(--r-full); font-size: 0.68rem; font-weight: 700; color: var(--muted); background: var(--bg); box-shadow: var(--raise-xs); white-space: nowrap; vertical-align: middle; }
.chk-actions { margin-bottom: var(--sp-3); }
.chk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.chk-item { display: flex; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--bg-deep); box-shadow: var(--inset-xs); font-size: 0.85rem; }
.chk-ic { flex: 0 0 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; background: var(--bg); box-shadow: var(--raise-xs); color: var(--muted); }
.chk-item.status-ok .chk-ic { color: var(--success); }
.chk-item.status-warn .chk-ic { color: var(--warn); }
.chk-item.status-fail .chk-ic { color: var(--danger); }
.chk-item.status-skip { opacity: 0.6; }
.chk-body { min-width: 0; flex: 1; }
.chk-title { font-weight: 700; }
.chk-detail { color: var(--muted); font-size: 0.8rem; margin-top: 2px; word-break: break-word; }
.chk-cause { font-size: 0.8rem; margin-top: 4px; }
.chk-action { font-size: 0.82rem; margin-top: 4px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--bg); box-shadow: var(--raise-xs); }
.chk-fixed { margin-left: 8px; padding: 1px 7px; border-radius: var(--r-full); font-size: 0.66rem; font-weight: 800; text-transform: uppercase; color: var(--success); background: var(--bg); box-shadow: var(--raise-xs); }
.chk-cams { margin-top: var(--sp-3); display: grid; gap: 6px; }
/* "Show N checks that passed" / "Show N working cameras" - the card leads with problems. */
.chk-more { display: block; margin: 8px 0 0; padding: 0; background: none; border: 0; cursor: pointer; color: var(--accent); font-size: 0.8rem; font-weight: 700; }
.chk-more:hover { text-decoration: underline; }
.chk-cams-head { font-weight: 800; font-family: var(--font-display); font-size: 0.85rem; margin: 4px 0 2px; }
.chk-cam { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-sm); background: var(--bg-deep); box-shadow: var(--inset-xs); font-size: 0.85rem; }
.chk-cam .health-dot { margin-top: 6px; }
.chk-cam.is-focus { box-shadow: var(--inset-xs), 0 0 0 2px var(--glow); }
.chk-state { margin-left: 8px; font-weight: 600; font-size: 0.75rem; color: var(--muted); }
.chk-cam.state-camera_offline .chk-state { color: var(--danger); }
.chk-cam.state-stream_failed .chk-state { color: var(--warn); }
.chk-cam.state-site_offline .chk-state { color: #f97316; }
.chk-focus { margin-left: 8px; padding: 1px 7px; border-radius: var(--r-full); font-size: 0.66rem; font-weight: 800; text-transform: uppercase; color: var(--accent); background: var(--bg); box-shadow: var(--raise-xs); }
.chk-log { margin: var(--sp-3) 0 0; max-height: 200px; overflow: auto; font-size: 0.75rem; color: var(--muted); background: var(--bg-deep); box-shadow: var(--inset-sm); padding: 10px 12px; border-radius: var(--r-md); white-space: pre-wrap; }

.health-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: middle; background: #64748b; box-shadow: 0 0 6px currentColor; }
.health-dot.state-online         { background: var(--success); color: var(--success); }
.health-dot.state-camera_offline { background: var(--danger); color: var(--danger); }
.health-dot.state-site_offline   { background: #f97316; color: #f97316; }
.health-dot.state-stream_failed  { background: var(--warn); color: var(--warn); }
.health-line .muted { color: var(--muted); font-size: 0.86em; }

/* ---------- List tools: search + filter above a long table ---------- */
.list-tools { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.list-tools select { width: auto; min-width: 170px; }
.list-tools .list-count { color: var(--faint); font-size: 0.78rem; font-variant-numeric: tabular-nums; margin-left: auto; }
.search-field { position: relative; flex: 1 1 240px; min-width: 0; }
.search-field svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.search-field input { padding-left: 38px; }
.list-empty { margin: var(--sp-4) 0 0; text-align: center; }

/* ---------- Login ---------- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  position: relative; overflow: hidden; padding: var(--sp-6);
}
/* Caution tape drifting behind the card - kept from the first design, but
   quieter, so the card reads as clay and the tape as a distant wall. */
.tapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.tape {
  position: absolute; left: -30%; width: 160%;
  display: flex; align-items: stretch; height: 44px;
  background: #f2c21a;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.tape-run::before, .tape-run::after {
  content: '';
  position: absolute; left: 0; width: 100%; height: 6px;
  background: repeating-linear-gradient(135deg, #15171c 0 6px, transparent 6px 14px);
}
.tape-run::before { top: 0; }
.tape-run::after { bottom: 0; }
.tape-run {
  position: relative;
  display: flex; flex: none; align-items: center; white-space: nowrap;
  animation-name: tape-scroll; animation-timing-function: linear; animation-iteration-count: infinite;
  will-change: transform;
}
.tape-run span { flex: none; padding: 0 22px; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: #15171c; }
.tape-run span + span::before { content: '\2605'; margin-right: 22px; }
@keyframes tape-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tape-run { animation-duration: var(--speed); animation-direction: var(--dir); }
.tape-1 { top: 13%; transform: rotate(-13deg); opacity: 0.22; --speed: 40s; --dir: normal; }
.tape-2 { top: 50%; transform: rotate(8deg); opacity: 0.14; filter: blur(0.8px); --speed: 55s; --dir: reverse; }
.tape-3 { top: 81%; transform: rotate(-5deg); opacity: 0.09; filter: blur(1.6px); --speed: 72s; --dir: normal; }
@media (prefers-reduced-motion: reduce) { .tape-run { animation: none; } }

.login-card {
  width: 100%; max-width: 400px; position: relative; z-index: 1;
  padding: var(--sp-8) var(--sp-6);
  border-radius: var(--r-xl);
  box-shadow: var(--raise), 0 30px 70px rgba(0, 0, 0, 0.35);
  transition: transform 420ms cubic-bezier(0.16, 0.84, 0.28, 1), box-shadow 420ms ease;
}
.login-card:hover { transform: translateY(-3px); box-shadow: var(--raise), 0 36px 80px rgba(0, 0, 0, 0.4), 0 0 50px var(--glow); }
@media (prefers-reduced-motion: reduce) { .login-card, .login-card:hover { transform: none; } }
.login-card .brand-header { text-align: center; margin-bottom: var(--sp-6); }
/* The logo sits on a raised coin with a slowly turning brand ring behind it. */
.login-card .logo-glow {
  position: relative; width: 132px; height: 132px; margin: 0 auto var(--sp-4);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg); box-shadow: var(--raise);
}
.login-card .logo-glow::before {
  content: ''; position: absolute; inset: -6px; z-index: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--brand-red), var(--brand-magenta), var(--brand-indigo), var(--brand-red));
  opacity: 0.55;
  animation: spin 14s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
.login-card .logo-glow::after {
  content: ''; position: absolute; inset: 10px; border-radius: 50%; z-index: 0;
  background: var(--bg-deep); box-shadow: var(--inset-sm);
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .login-card .logo-glow::before { animation: none; } }
.login-card .logo-glow img { position: relative; z-index: 1; height: 88px; width: 88px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4)); }
.login-card h1 {
  font-size: 1.45rem; margin: 0;
  background: var(--gradient-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .btn { width: 100%; justify-content: center; }

.pw-field { position: relative; }
.pw-field input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: var(--r-full);
  color: var(--muted); cursor: pointer; transition: color var(--ease), box-shadow var(--ease);
}
.pw-toggle:hover { color: var(--text); box-shadow: var(--raise-xs); }
.pw-toggle:active { box-shadow: var(--inset-xs); }
.pw-toggle svg { width: 17px; height: 17px; }

.wa-help {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  margin-top: var(--sp-5); padding: var(--sp-3);
  border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-xs);
  color: var(--muted); font-size: 0.85rem; font-weight: 600;
  text-decoration: none; transition: color var(--ease);
}
.wa-help svg { color: #25d366; flex: none; transition: transform var(--spring); }
.wa-help:hover { color: var(--text); }
.wa-help:hover svg { transform: scale(1.15); }

/* ---------- Login page: the camera that watches the form ---------- */
.cctv-cam { position: absolute; top: 4px; right: 8px; width: 118px; height: 100px; perspective: 620px; pointer-events: none; z-index: 3; }
.cam-plate { position: absolute; top: 0; right: 11px; width: 32px; height: 7px; border-radius: 0 0 50% 50% / 0 0 100% 100%; background: linear-gradient(180deg, #f7f9fb 0%, #dde1e8 45%, #9ba3b1 100%); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); }
.cam-pole { position: absolute; top: 4px; right: 22px; width: 10px; height: 38px; border-radius: 2px; background: linear-gradient(90deg, #9aa2b0 0%, #f4f6f9 38%, #dde1e8 58%, #a2aab8 100%); }
.cam-rig { position: absolute; top: 30px; right: 30px; width: 38px; height: 38px; transform-style: preserve-3d; transform-origin: 50% 50% -27px; transform: rotateY(-50deg) rotateX(-8deg); transition: transform 300ms cubic-bezier(0.16, 0.84, 0.28, 1); will-change: transform; }
.cam-slice { position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; }
.cam-tail { position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(172deg, #aeb5c1 0%, #d6dbe3 45%, #8f97a5 100%); transform: translateZ(-56px); }
.cam-hood { position: absolute; top: 0; left: 0; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(172deg, #b6bdc9 0%, #fbfcfd 16%, #e6eaf0 44%, #c3cad5 72%, #929aa8 100%); transform: translateZ(5px); }
.cam-lens { position: absolute; top: 5px; left: 5px; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 50% 42%, #2b3038 0%, #171b21 52%, #0a0d12 100%); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.75); transform: translateZ(8px); transition: opacity var(--ease); }
.cam-iris { position: absolute; top: 10px; left: 10px; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 42%), radial-gradient(circle at 66% 76%, rgba(80, 200, 215, 0.35) 0%, rgba(80, 200, 215, 0) 55%), radial-gradient(circle at 50% 50%, #12222f 0%, #070d16 68%, #01040a 100%); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.9); transform: translateZ(10px); transition: opacity var(--ease), box-shadow var(--ease); }
.cam-shutter { position: absolute; top: 5px; left: 5px; width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(180deg, #3a2a56, #241640); transform: translateZ(12px) scaleY(0); transform-origin: 50% 0; transition: transform 130ms ease; }
.cctv-cam.is-blinking .cam-shutter { transform: translateZ(12px) scaleY(1); }
.cam-glint { position: absolute; top: 12px; left: 13px; width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%); transform: translateZ(10.6px); transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1); }
.cam-ir { position: absolute; top: 26px; left: 13px; width: 12px; height: 7px; border-radius: 50%; background: radial-gradient(circle, #ffd9a8 0%, #ff8f4d 45%, #8e3d1c 100%); box-shadow: 0 0 9px rgba(255, 150, 80, 0.75); transform: translateZ(10.4px); transition: opacity var(--ease), box-shadow var(--ease); }
.cam-beam { position: absolute; border-radius: 50%; opacity: var(--o); background: radial-gradient(circle, rgba(226, 240, 255, 0.95) 0%, rgba(178, 212, 255, 0.4) 52%, rgba(150, 190, 255, 0) 78%); transition: opacity var(--ease); }
.cctv-cam.is-private .cam-beam { opacity: 0; }
.cctv-cam.is-private .cam-ir { opacity: 0.25; box-shadow: none; }
.cam-led { position: absolute; top: 2px; left: 16px; width: 5px; height: 5px; border-radius: 50%; background: #ff4d4d; box-shadow: 0 0 7px #ff4d4d; transform: translateZ(-24px); animation: cam-rec 2.4s ease-in-out infinite; }
@keyframes cam-rec { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.cctv-cam.is-private .cam-lens { opacity: 0.6; }
.cctv-cam.is-private .cam-iris { opacity: 0.45; box-shadow: none; }
.cctv-cam.is-private .cam-led { background: #f5a524; box-shadow: 0 0 7px #f5a524; animation: none; opacity: 0.9; }
@media (max-width: 560px) { .cctv-cam { transform: scale(0.8); transform-origin: top right; } }
@media (max-width: 400px) {
  .cctv-cam { transform: scale(0.66); transform-origin: top right; }
  .login-card .logo-glow { width: 108px; height: 108px; }
  .login-card .logo-glow img { height: 72px; width: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .cam-rig, .cam-glint, .cam-shutter { transition: none; }
  .cam-led { animation: none; }
}

/* ---------- Recording ---------- */
.rec-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3); min-height: 30px;
  border: 0; border-radius: var(--r-full);
  background: var(--bg); box-shadow: var(--raise-xs); color: var(--muted);
  font-size: 0.78rem; font-weight: 700; font-family: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: color var(--ease), box-shadow var(--ease);
}
/* A toggle switch: a sunken track, a raised knob that lights up in the brand. */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); margin: 0; cursor: pointer; font-size: 1rem; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; flex: none; width: 56px; height: 32px; border-radius: var(--r-full);
  background: var(--bg-deep); box-shadow: var(--inset-sm);
  transition: background var(--ease), box-shadow var(--ease);
}
.switch .track::after {
  content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg); box-shadow: var(--raise-xs);
  transition: transform var(--spring), background var(--ease), box-shadow var(--ease);
}
.switch input:checked + .track { box-shadow: var(--inset-sm), 0 0 16px var(--glow-strong); }
.switch input:checked + .track::after { transform: translateX(24px); background: var(--gradient-brand); box-shadow: var(--raise-xs), 0 0 10px var(--glow-strong); }
.switch input:focus-visible + .track { box-shadow: var(--inset-sm), var(--ring); }
.switch .switch-label { font-weight: 700; font-family: var(--font-display); font-size: 1.05rem; }
.rec-btn:hover { color: var(--text); box-shadow: var(--raise-sm); }
.rec-btn:active { box-shadow: var(--inset-xs); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #55606f; }
.rec-btn.on { color: #ff6b6b; box-shadow: var(--inset-xs); }
.rec-btn.on .rec-dot { background: #ff4d4d; box-shadow: 0 0 7px #ff4d4d; animation: cam-rec 2.4s ease-in-out infinite; }
.rec-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 0.72rem; }
.rec-disk {
  margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-sm);
  color: var(--muted); font-size: 0.82rem;
}
.rec-disk.blocked { color: #ffb4b4; }
@media (prefers-reduced-motion: reduce) { .rec-btn.on .rec-dot { animation: none; } }

/* ---------- Site selector ---------- */
.site-selector { display: flex; align-items: center; gap: var(--sp-2); }
.site-selector label { margin: 0; color: var(--muted); font-size: 0.82rem; }
.site-selector select { width: auto; min-width: 200px; }

/* ---------- The wall ----------
   Tiles are small monitors set into the surface: black glass, a soft bezel,
   a live lamp. The stage they sit on is the room, so the ambient light shows
   between them. */
.wall-shell {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h, 62px));
  height: calc(100dvh - var(--topbar-h, 62px));
  padding: 0;
}
.wall-bar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5); flex: 0 0 auto;
}
.wall-bar h1 { margin: 0; font-size: 1.25rem; }
.wall-bar .spacer { flex: 1; }
.wall-bar .flash { margin: 0; }

.wall-stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-3);
  overflow: hidden;
}
.camera-wall {
  display: grid;
  gap: 12px;
  overflow: visible;
}
.camera-wall[data-cols="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.camera-wall[data-cols="2"] { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.camera-wall[data-cols="3"] { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.camera-wall[data-cols="4"] { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }

.wall-shell.scroll-mode { height: auto; min-height: calc(100dvh - var(--topbar-h, 62px)); }
.wall-shell.scroll-mode .wall-stage { display: block; height: auto; overflow: visible; padding: var(--sp-2) var(--sp-5) var(--sp-8); }
.wall-shell.scroll-mode .wall-bar {
  position: sticky; top: var(--topbar-h, 0px); z-index: 5;
  background: var(--bg);
  box-shadow: 0 8px 20px var(--shadow-dark);
}
/* Three-part selector on purpose: the width breakpoints further down set
   grid-template-rows for the fixed wall with the same specificity as a
   two-part one, and being later in the file they won - in a window under
   1200px the scrolling wall got "repeat(3, 1fr)" rows, so the site heading
   (its own grid row) stretched to a third of the wall's height. */
.wall-stage .camera-wall.scrolling {
  grid-template-rows: none; grid-auto-rows: auto;
  width: auto !important; height: auto !important;
  padding: var(--sp-2) 0;
  overflow: visible;
}
/* A tile keeps the last frame it showed as a poster once its stream is
   released off-screen, and its <video> stays transparent until the next first
   frame - so scrolling back shows the scene at once instead of a black box. */
.camera-tile.has-poster { background-size: contain; background-position: center; background-repeat: no-repeat; }
.camera-tile video { transition: opacity 160ms ease-out; }
.camera-tile video.is-dark { opacity: 0; }
.camera-wall.scrolling .camera-tile { aspect-ratio: 4 / 3; }
.camera-wall.scrolling .wall-site-head {
  display: block;
  grid-column: 1 / -1;
  margin: var(--sp-3) 0 var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--bg-deep); box-shadow: var(--inset-sm);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  position: sticky; z-index: 3;
  top: calc(var(--topbar-h, 0px) + var(--wallbar-h, 0px) + 6px);
}

html.is-fullscreen .topbar { display: none; }
html.is-fullscreen .wall-shell { height: 100vh; height: 100dvh; }

.camera-tile {
  position: relative; display: block; min-height: 0; min-width: 0;
  background: var(--screen);
  border-radius: var(--r-md);
  overflow: hidden;
  text-decoration: none; color: var(--text);
  box-shadow: var(--raise-sm), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: transform var(--spring), box-shadow var(--ease);
}
.camera-tile:hover { transform: translateY(-2px); box-shadow: var(--raise), 0 0 0 2px var(--glow), 0 0 24px var(--glow); z-index: 1; }
.camera-tile:active { transform: translateY(0) scale(0.995); }
/* A faint vignette, like glass in a bezel. */
.camera-tile::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
}
.camera-tile video {
  width: 100%; height: 100%; display: block; background: var(--screen); object-fit: contain;
}
.camera-tile video.anamorphic { object-fit: fill; }
.snapshot-view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: var(--screen); object-fit: contain; }
.camera-tile .snapshot-view { z-index: 1; }
/* A still that has stopped updating is dimmed so an old frame never reads as now. */
.snapshot-view.is-stale { opacity: .5; filter: grayscale(.6); }

.camera-tile .label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--sp-5) var(--sp-3) var(--sp-2);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  z-index: 2; pointer-events: none; color: #fff;
}
.camera-tile .label .name { font-weight: 700; font-size: 0.82rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A name a customer may rename: it answers to the pointer on its own, and
   turns into a text box on double-click (see dashboard.ejs). */
.renamable { pointer-events: auto; cursor: text; }
.camera-tile .label .name.renamable:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
.name-edit {
  width: 100%; margin: 0; padding: 3px 8px;
  font: inherit; font-weight: 700; color: #fff;
  background: rgba(10, 13, 18, 0.85); border: 0; border-radius: 8px;
  box-shadow: 0 0 0 2px var(--glow), 0 4px 14px rgba(0, 0, 0, 0.4);
  text-shadow: none;
}
.name-edit:focus { outline: none; box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(0, 0, 0, 0.4); }
.wall-site-head .name-edit { font-size: 0.85rem; letter-spacing: 0; text-transform: none; background: var(--bg); color: var(--text); }
.wall-site-head.renamable { cursor: text; }
/* One-line confirmation after a rename, bottom centre. */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 40; padding: 10px 18px; border-radius: var(--r-full);
  background: var(--bg); color: var(--text); box-shadow: var(--raise), 0 0 24px var(--glow);
  font-size: 0.85rem; font-weight: 700; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
  animation: pop-in var(--spring);
}
.toast.is-bad { color: var(--danger); }
/* A toast whose text matters in full (why the recorder was not renamed): wraps. */
.toast.toast-wrap { white-space: normal; text-align: center; width: max-content; max-width: min(90vw, 560px); border-radius: var(--r-lg, 16px); }
/* Pencil next to a camera name on the site / camera page (admin, engineer):
   renames on the platform and on the recorder (public/js/camera-rename.js). */
.rename-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-left: 6px; padding: 0; vertical-align: middle;
  border: 0; border-radius: var(--r-full); cursor: pointer;
  background: var(--bg); color: var(--muted); box-shadow: var(--raise-sm);
  font-size: 0.8rem; line-height: 1;
}
.rename-btn:hover, .rename-btn:focus-visible { color: var(--accent); outline: none; }
.cam-label .rename-btn { position: absolute; right: 6px; bottom: 6px; margin: 0; pointer-events: auto; }
@media (max-width: 700px) { .toast { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); } }
.camera-tile .label .site { color: #c7cfda; font-size: 0.7rem; line-height: 1.2; }
.camera-wall.scrolling .camera-tile .label .site { display: none; }

.stream-msg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(10, 13, 18, 0.72); color: #c7cfda;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-full);
  font-size: 0.78rem; font-weight: 600; text-align: center; max-width: 90%;
  pointer-events: none; z-index: 2;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

/* The live lamp. */
.camera-tile .status-dot {
  position: absolute; top: var(--sp-3); right: var(--sp-3); z-index: 2;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--faint); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35);
}
.camera-tile .status-dot.live { background: #22c55e; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 10px #22c55e; animation: pulse-live 2s ease-in-out infinite; }
.camera-tile .status-dot.error { background: var(--danger); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 10px var(--danger); }
@keyframes pulse-live {
  0%, 100% { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(34, 197, 94, 0.55), 0 0 10px #22c55e; }
  50% { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 0 7px rgba(34, 197, 94, 0), 0 0 10px #22c55e; }
}

.camera-tile .tile-reported {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 10px; font-weight: 800; letter-spacing: 0.03em; line-height: 16px;
  color: #fff; background: rgba(239, 68, 68, 0.92);
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.45);
  pointer-events: none;
}
.camera-tile .tile-reported.is-in_progress { background: rgba(234, 179, 8, 0.95); color: #1f2937; box-shadow: 0 3px 10px rgba(234, 179, 8, 0.4); }
/* A tile showing its kept poster (the last frame before it stopped streaming)
   says so, so a camera that went offline while scrolled away can't pass for a
   live picture. Removed on the stream's first 'playing' (dashboard.ejs). */
.camera-tile.is-still::before {
  content: 'Last frame'; position: absolute; top: 7px; right: 24px; z-index: 3;
  padding: 1px 7px; border-radius: var(--r-full);
  font-size: 10px; font-weight: 700; line-height: 15px; letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.85); background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* ---------- Segmented controls (wall size, mode, timeline zoom) ----------
   A sunken track with the chosen option standing proud in the brand colour. */
.grid-controls, .tl-zoom {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1);
  border-radius: var(--r-full);
  background: var(--bg-deep); box-shadow: var(--inset-sm);
}
.grid-controls .gc-divider { width: 1px; height: 18px; background: var(--shadow-dark); box-shadow: 1px 0 0 var(--shadow-light); margin: 0 var(--sp-1); }
.grid-controls .gc-mobile { display: none; }
.grid-controls .gc-mode { font-size: 0.74rem; }
.wall-site-head { display: none; }
.grid-controls .gc-paging { display: inline-flex; align-items: center; gap: var(--sp-1); }
.grid-controls .gc-paging.is-hidden { visibility: hidden; }
.grid-controls .gc-page { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; min-width: 46px; text-align: center; }
.grid-controls .gc-icon svg { width: 15px; height: 15px; }
.grid-controls button, .tl-zoom button {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  min-width: 36px; height: 32px; padding: 0 var(--sp-3);
  background: transparent; border: 0; border-radius: var(--r-full);
  color: var(--muted); font-size: 0.78rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: color var(--ease), box-shadow var(--ease), background var(--ease), transform var(--spring);
}
.grid-controls button:hover, .tl-zoom button:hover { color: var(--text); background: var(--bg); box-shadow: var(--raise-xs); }
.grid-controls button:active, .tl-zoom button:active { box-shadow: var(--inset-xs); transform: scale(0.97); }
.grid-controls button.active, .tl-zoom button.active {
  background: var(--gradient-brand); color: #fff;
  box-shadow: var(--raise-xs), 0 4px 14px var(--glow-strong);
}
.grid-controls button:disabled { opacity: 0.35; cursor: default; box-shadow: none; background: transparent; }

/* ---------- Camera view: rail + screen + timeline ---------- */
.nvr-shell {
  display: grid;
  grid-template-columns: 272px 1fr;
  height: calc(100vh - var(--topbar-h, 62px));
  height: calc(100dvh - var(--topbar-h, 62px));
  min-height: 0;
}
.nvr-side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg);
  box-shadow: 8px 0 22px var(--shadow-dark);
  overflow-y: auto; z-index: 1;
}
.nvr-side-section { padding: var(--sp-4) var(--sp-4); flex: none; }
.nvr-side-section + .nvr-side-section { border-top: 1px solid var(--shadow-dark); box-shadow: inset 0 1px 0 var(--shadow-light); }
.nvr-side-section > label { margin-top: 0; }
.nvr-cam-select { display: none; }
.nvr-cams { flex: 1 1 auto; min-height: 140px; overflow-y: auto; }
.nvr-cams label .count { color: var(--faint); font-weight: 400; margin-left: 2px; }
.nvr-cams ul { list-style: none; margin: 0; padding: 2px; }
.nvr-cams li {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-1); border-radius: var(--r-md);
  color: var(--muted); font-size: 0.88rem; font-weight: 500; cursor: pointer;
  transition: box-shadow var(--ease), color var(--ease), transform var(--spring);
}
.nvr-cams li:hover { color: var(--text); box-shadow: var(--raise-xs); transform: translateX(2px); }
.nvr-cams li:active { box-shadow: var(--inset-xs); transform: none; }
.nvr-cams li.active { background: var(--gradient-brand); color: #fff; box-shadow: var(--raise-xs), 0 6px 16px var(--glow-strong); }
.nvr-cams li svg { width: 14px; height: 14px; flex-shrink: 0; }

.nvr-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
/* The screen: black glass in a clay bezel. */
.nvr-video-wrap {
  flex: 1 1 auto; min-height: 0; position: relative;
  margin: var(--sp-4) var(--sp-4) 0;
  background: var(--screen);
  border: 10px solid var(--bg); border-radius: var(--r-lg);
  box-shadow: var(--inset), 0 0 0 10px var(--bg), var(--raise);
}
.nvr-video-wrap video { width: 100%; height: 100%; object-fit: contain; background: var(--screen); display: block; border-radius: calc(var(--r-lg) - 10px); }
.nvr-video-wrap video.anamorphic { position: absolute; inset: 0; margin: auto; object-fit: fill; }
.nvr-mode {
  position: absolute; top: var(--sp-3); left: var(--sp-3); z-index: 2;
  padding: 4px 11px; border-radius: var(--r-full);
  background: #22c55e; color: #05230f; font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em;
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.6);
}
.nvr-mode.recorded { background: var(--brand-pink); color: #fff; box-shadow: 0 0 14px rgba(227, 28, 121, 0.6); }

.nvr-controls {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  flex: 0 0 auto;
}
.nvr-controls .spacer { flex: 1; }
.nvr-controls .btn { margin-top: 0; }
.nvr-controls select { width: auto; }
.nvr-camname { font-weight: 700; font-size: 1.05rem; }
.dl-compat {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  margin: 0; color: var(--muted); font-size: 0.78rem; cursor: pointer; white-space: nowrap;
}
.dl-compat input { width: auto; margin: 0; }
.dl-compat-sub { color: var(--faint); font-weight: 400; }
.nvr-status { color: var(--muted); font-size: 0.82rem; }

/* Scrubber: a groove cut into the surface, footage glowing inside it. */
.nvr-timeline { flex: 0 0 auto; padding: var(--sp-2) var(--sp-4) var(--sp-4); position: relative; }
.tl-tools { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); color: var(--muted); font-size: 0.78rem; }
.tl-tools .spacer { flex: 1; }
.tl-zoom button { min-width: 40px; height: 28px; font-size: 0.74rem; }
.tl-window { font-variant-numeric: tabular-nums; }
.tl-jump { display: inline-flex; align-items: center; gap: var(--sp-2); margin: 0; color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.tl-jump input { width: auto; padding: 5px 10px; font-size: 0.8rem; }
.tl-track {
  position: relative; height: 38px; cursor: crosshair;
  background: var(--bg-deep);
  box-shadow: var(--inset-sm);
  border-radius: var(--r-full);
  touch-action: none; user-select: none; -webkit-user-select: none;
  /* hour ticks */
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(100% / 24 - 1px), rgba(255, 255, 255, 0.05) calc(100% / 24 - 1px), rgba(255, 255, 255, 0.05) calc(100% / 24));
}
.tl-track.has-index { background-image: none; }
.tl-ranges { position: absolute; inset: 5px; pointer-events: none; border-radius: var(--r-full); overflow: hidden; }
.tl-range {
  position: absolute; top: 0; bottom: 0;
  background: var(--gradient-brand); opacity: 0.85;
  box-shadow: 0 0 14px var(--glow);
}
.tl-now { position: absolute; top: -3px; bottom: -3px; width: 2px; z-index: 1; background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.8); pointer-events: none; }
.tl-hover {
  position: absolute; top: -32px; transform: translateX(-50%); z-index: 3;
  background: var(--bg); box-shadow: var(--raise-xs); color: var(--text);
  padding: 3px 9px; border-radius: var(--r-full); font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
  pointer-events: none; white-space: nowrap;
}
.tl-hover[hidden] { display: none; }
.tl-playhead {
  position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px;
  background: #fff; box-shadow: 0 0 10px var(--brand-pink), 0 0 0 1px var(--brand-pink);
  pointer-events: none; z-index: 2;
}
.tl-labels { display: flex; justify-content: space-between; margin-top: var(--sp-2); color: var(--faint); font-size: 0.68rem; font-variant-numeric: tabular-nums; }

/* The date row and the month behind it. */
.cal-bar { display: flex; align-items: center; gap: var(--sp-2); }
.cal-bar > button { flex: none; }
.cal-bar button:not(.cal-toggle) {
  width: 34px; height: 36px; border-radius: var(--r-full);
  background: var(--bg); border: 0; color: var(--muted);
  cursor: pointer; font-size: 1rem; line-height: 1; box-shadow: var(--raise-xs);
  transition: box-shadow var(--ease), color var(--ease);
}
.cal-bar button:not(.cal-toggle):hover:not(:disabled) { color: var(--text); box-shadow: var(--raise-sm); }
.cal-bar button:not(.cal-toggle):active { box-shadow: var(--inset-xs); }
.cal-bar button:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.cal-toggle {
  flex: 1 1 auto; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-3);
  background: var(--bg); border: 0; border-radius: var(--r-full);
  color: var(--text); font: inherit; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; box-shadow: var(--raise-xs);
  transition: box-shadow var(--ease);
}
.cal-toggle:hover { box-shadow: var(--raise-sm); }
.cal-toggle[aria-expanded="true"] { box-shadow: var(--inset-xs); color: var(--accent); }
.cal-toggle svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.cal-toggle span { overflow: hidden; text-overflow: ellipsis; }
.cal-panel { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-sm); }
.cal-panel .cal-grid { max-width: 340px; }
.nvr-cal .btn { margin-top: var(--sp-3); }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.cal-head span { font-size: 0.85rem; font-weight: 700; }
.cal-head button {
  width: 28px; height: 28px; border-radius: var(--r-full);
  background: var(--bg); border: 0; color: var(--muted); box-shadow: var(--raise-xs);
  cursor: pointer; font-size: 0.9rem; line-height: 1;
}
.cal-head button:hover { color: var(--text); }
.cal-head button:active { box-shadow: var(--inset-xs); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .cal-dow { text-align: center; color: var(--faint); font-size: 0.62rem; font-weight: 700; padding: 2px 0; }
.cal-grid button {
  aspect-ratio: 1; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font-size: 0.76rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}
.cal-grid button:hover:not(:disabled) { background: var(--bg); color: var(--text); box-shadow: var(--raise-xs); }
.cal-grid button:disabled { opacity: 0.25; cursor: default; }
.cal-grid button.today { box-shadow: inset 0 0 0 1px var(--faint); }
.cal-grid button.selected { background: var(--gradient-brand); color: #fff; font-weight: 800; box-shadow: var(--raise-xs), 0 4px 12px var(--glow-strong); }
.cal-grid button.has-footage { position: relative; color: var(--text); }
.cal-grid button.has-footage::after {
  content: ''; position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--info); box-shadow: 0 0 6px var(--info);
}
.cal-grid button.has-footage.selected::after { background: #fff; box-shadow: none; }

/* ---------- Empty states ---------- */
.empty-state {
  color: var(--muted); text-align: center; padding: var(--sp-10) var(--sp-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.empty-state .empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-deep); box-shadow: var(--inset-sm);
  display: flex; align-items: center; justify-content: center; color: var(--faint);
  margin-bottom: var(--sp-2);
}
.empty-state .empty-icon svg { width: 22px; height: 22px; }
.empty-state .empty-title { color: var(--text); font-weight: 700; font-size: 1rem; font-family: var(--font-display); }
.empty-state .empty-sub { font-size: 0.85rem; max-width: 360px; }
table .empty-state { padding: var(--sp-6) var(--sp-4); }


/* ---------- Sites hub: one card per site ----------
   Read top to bottom: what it is, whether it is well, how well, what next.
   The state colours the lamp, the top edge and the label together, so a
   wall of cards scans by colour before anyone reads a word. */
.page-sub { color: var(--muted); margin: 4px 0 0; font-size: 0.85rem; }
.page-sub .bad { color: var(--danger); font-weight: 700; }
.page-sub .good { color: var(--success); font-weight: 700; }
.site-search { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-5); align-items: center; }
.site-search .search-field { flex: 1 1 auto; }
.site-search input { margin: 0; }
.site-search .btn { margin-top: 0; }
@media (max-width: 560px) {
  .site-search { flex-wrap: wrap; }
  .site-search .search-field { flex: 1 1 100%; }
  .site-search .btn { flex: 1 1 0; justify-content: center; }
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: var(--sp-5);
}
.site-card {
  position: relative;
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--bg); box-shadow: var(--raise-sm);
  transition: transform var(--spring), box-shadow var(--ease);
  --state: var(--success);
}
.site-card.is-warn  { --state: var(--warn); }
.site-card.is-down  { --state: var(--danger); }
.site-card.is-empty { --state: var(--faint); }
.site-card:hover { transform: translateY(-3px); box-shadow: var(--raise), 0 0 0 2px var(--glow); }
.site-card::before {
  content: ''; position: absolute; top: 0; left: var(--sp-5); right: var(--sp-5); height: 3px;
  border-radius: 0 0 4px 4px; background: var(--state); opacity: 0.9;
  box-shadow: 0 2px 10px var(--state);
}
.site-card.is-empty::before { box-shadow: none; opacity: 0.5; }

.sc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.sc-title { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.sc-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--state); box-shadow: 0 0 10px var(--state);
}
.site-card.is-empty .sc-dot { box-shadow: none; }
.sc-name { margin: 0; font-size: 1.12rem; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-link { color: var(--text); }
.sc-link:hover { color: var(--text); }
/* The name is the card's link; stretched over the whole card so anywhere
   opens it, while the small actions below sit above it (z-index). */
.sc-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.sc-state {
  flex: none; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--bg-deep); box-shadow: var(--inset-xs); color: var(--state);
}
.sc-sub { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); color: var(--muted); font-size: 0.82rem; min-height: 1.2em; }
.sc-customer { font-weight: 700; color: var(--text); }
.sc-loc { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.sc-loc svg { width: 13px; height: 13px; color: var(--faint); flex: none; }

.sc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.sc-stat {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: var(--sp-2) var(--sp-1);
  border-radius: var(--r-sm); background: var(--bg-deep); box-shadow: var(--inset-xs);
}
.sc-stat strong { font-family: var(--font-display); font-size: 1.3rem; line-height: 1.1; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.sc-stat span { font-size: 0.64rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.sc-stat.ok strong { color: var(--success); }
.sc-stat.bad strong { color: var(--danger); }

.sc-bar { display: flex; height: 8px; border-radius: var(--r-full); overflow: hidden; background: var(--bg-deep); box-shadow: var(--inset-xs); }
.sc-bar .ok { background: linear-gradient(90deg, #22c55e, #4ade80); box-shadow: 0 0 8px rgba(34, 197, 94, 0.55); }
.sc-bar .bad { background: linear-gradient(90deg, var(--danger), #ff8a80); }

.sc-foot { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-top: auto; padding-top: var(--sp-1); }
.sc-foot .spacer { flex: 1; }
.sc-action {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: var(--r-full);
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
  background: var(--bg); box-shadow: var(--raise-xs);
  transition: color var(--ease), box-shadow var(--ease), transform var(--spring);
}
.sc-action:hover { color: var(--text); box-shadow: var(--raise-sm); transform: translateY(-1px); }
.sc-action:active { box-shadow: var(--inset-xs); transform: none; }
.sc-action svg { width: 13px; height: 13px; }
/* The one action an engineer reaches for first: directions. */
.sc-action.primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--raise-xs), 0 4px 14px var(--glow-strong); }
.sc-action.primary:hover { color: #fff; box-shadow: var(--raise-sm), 0 6px 18px var(--glow-strong); }
@media (max-width: 420px) {
  .site-card { padding: var(--sp-4); }
  .sc-name { font-size: 1.02rem; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .camera-wall[data-cols="4"] { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
  .nvr-shell { grid-template-columns: 236px 1fr; }
}

@media (max-width: 900px) {
  .container { padding: var(--sp-4); }
  .nvr-shell { display: flex; flex-wrap: wrap; height: auto; }
  .nvr-side { display: contents; }
  .nvr-side-section { background: var(--bg); }
  .nvr-main       { order: 1; flex: 1 1 100%; }
  .nvr-top        { order: 2; flex: 1 1 42%; min-width: 0; }
  .nvr-cam-select { order: 3; flex: 1 1 58%; min-width: 0; display: block; }
  .nvr-cal        { order: 4; flex: 1 1 100%; }
  .nvr-cams { display: none; }
  .nvr-side-section + .nvr-side-section { border-top: 0; box-shadow: none; }
  .cal-panel .cal-grid { margin: 0 auto; }
  .nvr-video-wrap { aspect-ratio: 16 / 9; margin: var(--sp-3); }
  .camera-wall[data-cols="3"], .camera-wall[data-cols="4"] { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
}

/* --- Phone tab bar --- */
@media (max-width: 700px) {
  .topbar nav.mainnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; margin: 0; gap: 0;
    padding: var(--sp-1) var(--sp-1) calc(var(--sp-1) + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    box-shadow: 0 -8px 22px var(--shadow-dark), inset 0 1px 0 var(--edge);
  }
  .topbar nav.mainnav a {
    flex: 1 1 0; min-width: 0;
    flex-direction: column; justify-content: center; gap: 2px;
    padding: var(--sp-1) 0;
    /* Six labels across a 360px phone: "Complaints" has to fit in ~58px. */
    font-size: clamp(8.5px, 2.5vw, 9.75px); font-weight: 700; letter-spacing: -0.01em;
    border-radius: var(--r-md);
    box-shadow: none; transform: none;
  }
  .topbar nav.mainnav a .nav-label { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .topbar nav.mainnav .nav-ic { display: inline-flex; }
  .topbar nav.mainnav .nav-ic svg { width: 20px; height: 20px; }
  .topbar nav.mainnav a:hover { box-shadow: none; transform: none; }
  .topbar nav.mainnav a.active { color: var(--accent); box-shadow: var(--inset-sm); }
  .topbar nav.mainnav a.active::after { content: none; }
  .topbar nav.mainnav .nav-badge { position: absolute; top: 2px; right: calc(50% - 22px); }
  html.has-nav body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  html.has-nav.is-fullscreen body { padding-bottom: 0; }
}

@media (max-width: 700px) {
  .topbar { padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); }
  .topbar .who { display: none; }
  .topbar .brand { font-size: 1rem; }
  .container { padding: var(--sp-3); }

  .wall-shell { height: auto; }
  .wall-bar { flex-wrap: nowrap; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); }
  .wall-bar h1 { display: none; }
  .wall-bar .spacer { display: none; }
  .wall-bar .flash { flex: 1 1 100%; }
  .site-selector { flex: 1 1 auto; min-width: 0; order: -1; }
  .site-selector label { display: none; }
  .site-selector select { min-width: 0; width: 100%; }
  .grid-controls { flex: none; }
  .wall-shell.scroll-mode .wall-stage { padding: var(--sp-2) var(--sp-3) var(--sp-6); }
  .camera-wall { gap: 10px; }

  .camera-wall.scrolling[data-cols="1"] { grid-template-columns: 1fr !important; }
  .camera-wall.scrolling[data-cols="2"] { grid-template-columns: repeat(2, 1fr) !important; }

  .grid-controls button[data-cols],
  .grid-controls button[data-mode],
  .grid-controls .gc-divider,
  .grid-controls .gc-paging { display: none; }
  .grid-controls .gc-mobile { display: inline-flex; }
  .grid-controls button { min-width: 40px; height: 36px; }

  .login-card { padding: var(--sp-6) var(--sp-4); }
  .page-header { gap: var(--sp-2); }
  .card { padding: var(--sp-5); }

  .nvr-controls { padding: var(--sp-3); gap: var(--sp-2); }
  .nvr-controls .spacer { display: none; }
  .nvr-timeline { padding: var(--sp-2) var(--sp-3) var(--sp-3); }
  .tl-track { height: 44px; }
  .tl-labels span:nth-child(even) { display: none; }
  .cal-grid button { font-size: 0.8rem; }

  table { min-width: 520px; }
}

@media (max-width: 420px) {
  .topbar { padding: var(--sp-2); }
  .topbar img.logo { height: 26px; }
  .topbar .btn { padding: var(--sp-1) var(--sp-2); font-size: 0.75rem; }
  .container { padding: var(--sp-2); }
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
  .card::before { left: var(--sp-4); right: var(--sp-4); }
  h1 { font-size: 1.25rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .topbar { position: static; }
  .wall-bar { padding: var(--sp-2) var(--sp-3); }
  .wall-bar h1 { font-size: 1rem; }
  .nvr-side { max-height: 40vh; overflow-y: auto; }
}
@media (max-height: 640px) {
  .login-wrap { padding: var(--sp-3); align-items: flex-start; }
  .login-card { padding: var(--sp-5) var(--sp-6); }
  .login-card .brand-header { margin-bottom: var(--sp-4); }
  .login-card .logo-glow { width: 96px; height: 96px; margin-bottom: var(--sp-2); }
  .login-card .logo-glow img { height: 64px; width: 64px; }
}

@media (hover: none) {
  .icon-btn { width: 38px; height: 38px; }
  .nvr-cams li { padding: var(--sp-3) var(--sp-3); }
  .cal-grid button { min-height: 34px; }
  .camera-tile:hover { transform: none; }
}

/* Open-complaint count in the nav. */
.nav-badge {
  display: inline-block;
  min-width: 18px; padding: 0 5px; margin-left: 2px;
  border-radius: var(--r-full);
  background: var(--brand-red); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; vertical-align: middle;
  box-shadow: 0 0 10px rgba(229, 56, 42, 0.6);
}

.report-link { width: 100%; justify-content: center; margin-top: var(--sp-2); }

/* ---------- Tables that stack on a phone ---------- */
@media (max-width: 640px) {
  .stack-table { min-width: 0; }
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr {
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--bg); box-shadow: var(--raise-xs);
  }
  .stack-table tr:hover td { background: transparent; }
  .stack-table td { border: 0; box-shadow: none; padding: 2px 0; display: flex; gap: var(--sp-3); align-items: baseline; }
  .stack-table td::before {
    content: attr(data-label);
    flex: 0 0 84px;
    color: var(--faint);
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
  }
  .stack-table td:empty { display: none; }
  .stack-table td.row-actions { justify-content: flex-end; padding-top: var(--sp-2); }
  .stack-table td.row-actions::before { content: none; }
}

/* ---------- Site picker ---------- */
.site-picker { margin-top: var(--sp-4); }
.sp-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.sp-head .sp-label { margin: 0; }
.sp-count { color: var(--faint); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.sp-tools { display: flex; gap: var(--sp-2); margin: var(--sp-2) 0; }
.sp-tools .sp-search { flex: 1 1 auto; min-width: 0; margin: 0; }
.sp-act {
  flex: 0 0 auto;
  background: var(--bg); border: 0; border-radius: var(--r-full); box-shadow: var(--raise-xs);
  color: var(--muted); font-size: 0.74rem; font-family: inherit; font-weight: 700;
  padding: 0 var(--sp-3); cursor: pointer; white-space: nowrap;
  transition: box-shadow var(--ease), color var(--ease);
}
.sp-act:hover { color: var(--text); box-shadow: var(--raise-sm); }
.sp-act:active { box-shadow: var(--inset-xs); }
.sp-list { max-height: 260px; overflow-y: auto; border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-sm); padding: var(--sp-1); }
/* Taller when it also lists cameras: the point is to see them. */
[data-has-cameras] .sp-list { max-height: 440px; }
.sp-camtools { margin-top: 0; }
.sp-row { border-radius: var(--r-sm); transition: background var(--ease); }
.sp-row:hover { background: rgba(255, 255, 255, 0.03); }
:root[data-theme="light"] .sp-row:hover { background: rgba(0, 0, 0, 0.04); }
.sp-site {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  margin: 0; padding: var(--sp-2) var(--sp-3);
  cursor: pointer; font-size: 0.86rem; color: var(--text); font-weight: 400;
}
.sp-site input { width: auto; margin: 3px 0 0; flex: 0 0 auto; }
.sp-text { min-width: 0; flex: 1 1 auto; }
.sp-name { display: block; font-weight: 600; }
.sp-sub { display: block; color: var(--muted); font-size: 0.74rem; }
.sp-camcount { flex: none; color: var(--faint); font-size: 0.72rem; font-weight: 700; white-space: nowrap; margin-top: 3px; }
.sp-empty { color: var(--muted); font-size: 0.8rem; padding: var(--sp-4); margin: 0; text-align: center; }

/* The camera level under a site. */
.sp-cams { padding: 0 var(--sp-3) var(--sp-3) calc(var(--sp-3) + 16px + var(--sp-3)); }
.sp-scope { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin: 2px 0 var(--sp-2); }
.sp-scope-opt { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 0.8rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.sp-scope-opt input { width: auto; margin: 0; }
.sp-scope-opt .muted { font-weight: 400; }
.sp-camgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px var(--sp-2);
  padding: var(--sp-2); border-radius: var(--r-sm);
  background: var(--bg); box-shadow: var(--raise-xs);
}
.sp-cam {
  display: flex; align-items: center; gap: 6px; margin: 0; padding: 5px 7px;
  border-radius: 8px; font-size: 0.82rem; font-weight: 500; color: var(--text); cursor: pointer;
  transition: background var(--ease);
}
.sp-cam:hover { background: var(--bg-deep); }
.sp-cam input { width: auto; margin: 0; flex: none; }
.sp-cam span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-camgrid .sp-empty { grid-column: 1 / -1; padding: var(--sp-2); }
@media (max-width: 560px) {
  .sp-cams { padding-left: var(--sp-3); }
}
@media (max-width: 560px) {
  .sp-tools { flex-wrap: wrap; }
  .sp-tools .sp-search { flex: 1 1 100%; }
  .sp-act { flex: 1 1 0; padding: var(--sp-2); }
  .sp-list { max-height: 300px; }
}

/* ---------- Enlarge in place ---------- */
html.focus-open, html.focus-open body { overflow: hidden; }
.tile-focus {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  background: rgba(8, 10, 16, 0.72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade-in 180ms ease-out;
}
:root[data-theme="light"] .tile-focus { background: rgba(60, 70, 90, 0.45); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.tile-focus[hidden] { display: none; }
.tf-box {
  width: min(100%, calc((100dvh - 140px) * 16 / 9));
  max-width: 1500px; max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: var(--r-xl);
  box-shadow: var(--raise), 0 40px 90px rgba(0, 0, 0, 0.55), 0 0 60px var(--glow);
  overflow: hidden;
  animation: pop-in var(--spring);
}
@keyframes pop-in { from { transform: scale(0.96); opacity: 0.6; } to { transform: scale(1); opacity: 1; } }
.tf-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); flex-wrap: wrap; flex: none; }
.tf-title { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; flex-wrap: wrap; }
.tf-name { font-weight: 700; font-size: 1.15rem; }
.tf-site { color: var(--muted); font-size: 0.82rem; }
.tf-actions { display: flex; align-items: center; gap: var(--sp-2); }
/* Sound toggle (enlarged view and camera page): crossed speaker when off,
   lit speaker when on. */
.snd-btn .ic-on, .snd-btn.is-on .ic-off { display: none; }
.snd-btn.is-on .ic-on { display: inline-flex; }
.snd-btn.is-on { color: var(--accent); box-shadow: var(--inset-sm), 0 0 12px var(--glow); }
.snd-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tf-actions .btn { margin-top: 0; padding: var(--sp-2) var(--sp-4); font-size: 0.82rem; }
.tf-video {
  position: relative; background: var(--screen); aspect-ratio: 16 / 9; min-height: 0;
  margin: 0 var(--sp-4) var(--sp-4); border-radius: var(--r-lg);
  box-shadow: var(--inset); overflow: hidden;
}
.tf-video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--screen); }
.tf-video video.anamorphic { object-fit: fill; }
/* The warm substream sits underneath while the main stream comes up. */
.tf-video .tf-sub-wrap { position: absolute; inset: 0; }
.tf-video .tf-sub-wrap .stream-msg { display: none !important; }
.tf-video #tfVideo { z-index: 1; }
.tf-video video { transition: opacity 200ms ease-out; }
.tf-video video.is-dark { opacity: 0; }
.tf-video .status-dot { position: absolute; top: var(--sp-3); right: var(--sp-3); z-index: 2; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.4); }
.tf-video .status-dot.live { background: #22c55e; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.4), 0 0 10px #22c55e; }
.tf-video .status-dot.error { background: var(--danger); }
.tf-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 44px; height: 60px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(20, 24, 32, 0.55); border: 0;
  color: #fff; border-radius: var(--r-md); cursor: pointer; opacity: 0.75;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity var(--ease), background var(--ease), transform var(--spring);
}
.tf-nav:hover { opacity: 1; background: rgba(20, 24, 32, 0.8); transform: translateY(-50%) scale(1.06); }
.tf-nav:active { transform: translateY(-50%) scale(0.96); }
.tf-nav svg { width: 22px; height: 22px; }
.tf-prev { left: var(--sp-3); }
.tf-next { right: var(--sp-3); }

/* PTZ pad (public/js/ptz.js): sits on the picture, bottom-right, in the same
   dark glass as the prev/next arrows - clay would vanish against video. */
.ptz {
  position: absolute; right: var(--sp-3); bottom: var(--sp-3); z-index: 4;
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: var(--sp-2);
  color: #fff; font-size: 0.78rem; user-select: none; -webkit-user-select: none;
}
/* The camera page's <video> has native controls along its bottom edge. */
.nvr-video-wrap .ptz { bottom: 58px; }
/* Clear of the enlarged view's "next camera" arrow on the right edge. */
.tf-video .ptz { right: 64px; }
.ptz-toggle, .ptz-panel, .ptz-btn, .ptz-go, .ptz-preset select {
  background: rgba(20, 24, 32, 0.62); color: #fff; border: 0;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.ptz-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--r-full); cursor: pointer; font-weight: 700; letter-spacing: 0.04em;
  opacity: 0.85; transition: opacity var(--ease), box-shadow var(--ease);
}
.ptz-toggle:hover { opacity: 1; }
.ptz-toggle.is-on { opacity: 1; box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--glow); }
.ptz-toggle svg { width: 16px; height: 16px; }
.ptz-panel {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3); border-radius: var(--r-md); width: 176px;
}
.ptz-panel[hidden] { display: none; }
.ptz-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.ptz-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; border-radius: var(--r-sm, 8px); cursor: pointer;
  background: rgba(255, 255, 255, 0.1); touch-action: none;
  transition: background var(--ease), transform var(--spring);
}
.ptz-btn:hover { background: rgba(255, 255, 255, 0.2); }
.ptz-btn.is-held { background: var(--accent); transform: scale(0.95); box-shadow: 0 0 12px var(--glow); }
.ptz-btn svg { width: 20px; height: 20px; }
.ptz-mid { display: inline-flex; align-items: center; justify-content: center; opacity: 0.35; }
.ptz-mid svg { width: 14px; height: 14px; }
.ptz-zoom { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 5px; }
.ptz-zlabel { text-align: center; opacity: 0.8; }
.ptz-speed { display: flex; align-items: center; gap: 6px; margin: 0; color: #fff; font-size: 0.78rem; }
.ptz-speed input { flex: 1; min-width: 0; accent-color: var(--accent); padding: 0; box-shadow: none; background: none; }
.ptz-speed b { width: 1ch; text-align: right; }
.ptz-preset { display: flex; align-items: center; gap: 6px; }
.ptz-preset[hidden] { display: none; }
.ptz-preset select { flex: 1; min-width: 0; height: 30px; padding: 0 6px; border-radius: var(--r-sm, 8px); background: rgba(255, 255, 255, 0.12); box-shadow: none; font-size: 0.78rem; }
.ptz-preset select option { color: #000; }
.ptz-go { height: 30px; padding: 0 10px; border-radius: var(--r-sm, 8px); cursor: pointer; font-weight: 700; background: var(--accent); }
.ptz-msg { min-height: 0; color: #fecaca; font-size: 0.72rem; line-height: 1.3; }
.ptz-msg:empty { display: none; }
.ptz.is-disabled .ptz-panel { opacity: 0.45; }
.ptz.is-disabled button, .ptz.is-disabled select, .ptz.is-disabled input { cursor: not-allowed; }
@media (max-width: 700px) {
  .ptz-panel { width: 150px; padding: var(--sp-2); }
  .ptz-btn { height: 38px; }
  .ptz-toggle-text { display: none; }
}
@media (max-width: 700px) {
  .tile-focus { padding: 0; align-items: stretch; }
  .tf-box { width: 100%; max-width: none; border-radius: 0; }
  .tf-head { padding: var(--sp-2) var(--sp-3); }
  .tf-actions .btn { padding: var(--sp-2) var(--sp-3); }
  .tf-actions .btn svg + * { display: none; }
  .tf-video { aspect-ratio: auto; flex: 1 1 auto; margin: 0 var(--sp-2) var(--sp-2); }
}

/* ── Sign-in security (passkeys / authenticator / recovery codes) ── */
.mfa-card .brand-header { margin-bottom: var(--sp-4); }
.mfa-wide { max-width: 460px; }
.mfa-logo { width: 64px; height: auto; display: block; margin: 0 auto var(--sp-3); }
.mfa-sub { color: var(--muted); margin: var(--sp-2) 0 0; font-size: 0.92rem; }
.mfa-hint { color: var(--muted); font-size: 0.85rem; margin: var(--sp-2) 0; }
.mfa-big { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.mfa-big svg, .mfa-option h2 svg, .mfa-h3 svg { width: 20px; height: 20px; }
.mfa-or { display: flex; align-items: center; gap: var(--sp-3); color: var(--muted); font-size: 0.8rem; margin: var(--sp-4) 0; }
.mfa-or::before, .mfa-or::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: 0.3; }
.mfa-option { position: relative; padding: var(--sp-4); border-radius: var(--radius, 18px); box-shadow: var(--inset-sm); }
.mfa-option h2 { display: flex; align-items: center; gap: var(--sp-2); font-size: 1.05rem; margin: 0 0 var(--sp-2); }
.mfa-option p { margin: 0 0 var(--sp-3); font-size: 0.9rem; }
.mfa-badge { position: absolute; top: var(--sp-3); right: var(--sp-3); font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent, #d6336c); color: #fff; }
.mfa-qr { width: 200px; margin: 0 auto var(--sp-2); padding: 8px; background: #fff; border-radius: 12px; }
.mfa-qr svg { display: block; width: 100%; height: auto; }
.mfa-secret { font-size: 0.85rem; letter-spacing: 0.05em; word-break: break-all; }
.mfa-remember { display: flex; align-items: center; gap: var(--sp-2); font-size: 0.88rem; margin: var(--sp-3) 0; font-weight: 500; }
.mfa-remember input { width: auto; margin: 0; }
.mfa-more { margin-top: var(--sp-4); font-size: 0.88rem; color: var(--muted); }
.mfa-more summary { cursor: pointer; }
.mfa-back { text-align: center; margin: var(--sp-4) 0 0; font-size: 0.88rem; }
.mfa-codes { columns: 2; padding-left: 1.4em; margin: 0 0 var(--sp-3); font-size: 1rem; }
.mfa-codes li { margin: 0 0 var(--sp-2); }
.mfa-codes code { font-size: 1rem; letter-spacing: 0.06em; }
.mfa-code-actions { margin-bottom: var(--sp-2); }
.mfa-h3 { display: flex; align-items: center; gap: var(--sp-2); font-size: 0.95rem; margin: var(--sp-4) 0 var(--sp-2); }
.mfa-list { list-style: none; padding: 0; margin: 0; }
.mfa-list li, .mfa-list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) 0; }
.mfa-meta { display: block; color: var(--muted); font-size: 0.8rem; }
@media print { .mfa-code-actions, .mfa-hint, .mfa-big, .tapes { display: none !important; } }

/* ── Settings page: phone-style list, one row open at a time ── */
.topbar .who { display: inline-flex; align-items: center; gap: var(--sp-2); }
@media (max-width: 1100px) { .topbar .who { display: none; } } /* the gear icon stands in */
.topbar .who-gear { display: inline-flex; opacity: 0.75; }
.topbar .who-gear svg { width: 16px; height: 16px; }
.topbar .who.active { color: var(--text); box-shadow: var(--inset-sm); }
.settings-profile { display: flex; align-items: center; gap: var(--sp-4); }
.settings-avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font: 700 1.5rem/1 'Outfit', sans-serif; color: #fff; background: var(--gradient-brand); box-shadow: var(--raise-sm);
}
.settings-name { font: 700 1.15rem/1.2 'Outfit', sans-serif; word-break: break-word; }
.settings-role { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.settings-list { padding: var(--sp-2); }
.set-item + .set-item { border-top: 1px solid color-mix(in srgb, var(--muted) 18%, transparent); }
.set-item summary, .set-row-btn {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); cursor: pointer;
  list-style: none; border-radius: var(--r-md); transition: box-shadow var(--ease);
}
.set-item summary::-webkit-details-marker { display: none; }
.set-item summary:hover, .set-row-btn:hover { box-shadow: var(--raise-xs); }
.set-item[open] > summary { box-shadow: var(--inset-sm); }
.set-ic {
  flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  box-shadow: var(--raise-xs); color: var(--accent);
}
.set-ic svg { width: 20px; height: 20px; }
.set-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.set-title { font-weight: 600; }
.set-sub { color: var(--muted); font-size: 0.82rem; margin-top: 2px; overflow-wrap: anywhere; }
.set-sub.warn { color: var(--danger); }
.set-chev { flex: none; display: inline-flex; color: var(--muted); transition: transform var(--ease); }
.set-chev svg { width: 18px; height: 18px; }
.set-item[open] .set-chev { transform: rotate(90deg); }
.set-panel { padding: var(--sp-3) var(--sp-3) var(--sp-4); }
.set-panel > :first-child { margin-top: 0; }
.settings-logout { padding: var(--sp-2); }
.set-row-btn {
  width: 100%; border: 0; background: none; font: inherit; color: var(--danger); text-align: left; margin: 0;
}
.set-row-btn .set-ic { color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .set-chev { transition: none; } }

/* ── Performance mode (html.perf, the ?perf=1 test switch) ──
   Everything here removes work the phone did on every frame while scrolling:
   - the ambient background stops drifting (a layer 1.4x the screen, animated
     forever, composited under every frame);
   - the live dot stops pulsing (it animated box-shadow, which repaints - once
     per frame per live tile);
   - the inner vignette over each video goes (one more blended layer on top
     of every video frame);
   - the last-frame poster is a canvas laid under the video instead of a JPEG
     data URL as the tile background (no encode/decode on the main thread). */
html.perf body::before { animation: none; will-change: auto; transform: none; }
html.perf .camera-tile .status-dot.live { animation: none; }
html.perf .camera-tile::after { display: none; }
html.perf .camera-tile { transition: none; }
html.perf .camera-tile video { position: relative; z-index: 1; }
.tile-poster { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; pointer-events: none; }
.perf-badge {
  position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  font: 700 0.7rem/1 var(--font-sans); letter-spacing: .04em; padding: 6px 10px; border-radius: 999px;
  background: rgba(34, 197, 94, 0.9); color: #04210f; text-decoration: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
@media (max-width: 700px) { .perf-badge { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); } }
/* A settings row that is just an on/off switch. */
.set-toggle { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); cursor: pointer; margin: 0; font-weight: normal; }
input[type=checkbox].set-switch {
  height: 26px !important; width: 46px !important;
  flex: none; appearance: none; -webkit-appearance: none; width: 46px; height: 26px; margin: 0; border-radius: 999px;
  background: var(--bg-deep); box-shadow: var(--inset-sm); position: relative; cursor: pointer; transition: background var(--ease);
}
input[type=checkbox].set-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); transition: transform var(--ease), background var(--ease);
}
input[type=checkbox].set-switch:checked { background: var(--gradient-brand); }
input[type=checkbox].set-switch:checked::after { transform: translateX(20px); background: #fff; }
input[type=checkbox].set-switch { padding: 0; border: 0; min-width: 46px; max-width: 46px; flex: 0 0 46px; box-sizing: border-box; }
.set-toggle .set-title { color: var(--text); font-size: 0.95rem; }
.set-toggle .set-sub { font-size: 0.82rem; }

/* ── Page-to-page: an app-like crossfade instead of a white flash ──
   Cross-document view transitions (Chrome / Edge 126+, Safari 18.2+; other
   browsers just navigate as before). The top bar and the phone tab bar keep
   their own names, so they stay put while only the page content changes. */
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
.topbar .mainnav { view-transition-name: tabbar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* Extra recorders on the site form: one collapsible row each. */
.rec-item { border-radius: var(--r-md); box-shadow: var(--inset-sm); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-3); }
.rec-item > summary { cursor: pointer; list-style: none; }
.rec-item > summary::-webkit-details-marker { display: none; }
.rec-item[open] > summary { margin-bottom: var(--sp-2); }

/* ---------- Dial-out setup (Add Site: brand -> setup card -> live recorder list) ---------- */
.dlo-brands { display: flex; flex-wrap: wrap; gap: var(--sp-2, 8px); }
.dlo-brand { display: inline-flex; margin: 0; cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--text); }
.dlo-brand input { position: absolute; opacity: 0; pointer-events: none; }
.dlo-brand span { padding: 8px 18px; border-radius: var(--r-full); background: var(--bg-deep); box-shadow: var(--raise-xs); }
.dlo-brand input:checked + span { color: #fff; background: var(--gradient-brand); }
.dlo-brand input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.dlo-card { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-sm); }
.dlo-path { margin: 0 0 8px; font-size: 0.9rem; }
.dlo-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dlo-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 12px 4px 0; width: 38%; vertical-align: top; }
.dlo-table td { padding: 4px 0; overflow-wrap: anywhere; }
.dlo-list { display: flex; flex-direction: column; gap: 8px; }
.dlo-dev { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-weight: normal; padding: 10px 12px; border-radius: var(--r-md); background: var(--bg-deep); box-shadow: var(--inset-xs); cursor: pointer; }
.dlo-dev-main { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.dlo-dev-sub { flex-basis: 100%; font-size: 0.82rem; }
