/* Ekiller VMS — tema scuro minimale */
:root {
  color-scheme: dark;   /* controlli nativi (occhio della password, frecce dei numeri, menu a tendina, scrollbar) scuri */
  --bg: #0b0c0e;
  --surface: #121418;
  --surface-2: #181b20;
  --surface-3: #20242a;
  --line: #24282f;
  --line-soft: #1b1e23;
  --text: #eceef1;
  --text-2: #b4bac3;
  --muted: #7d848f;
  --brand: #318fc2;
  --brand-hi: #43a3d8;
  --brand-soft: rgba(49, 143, 194, .14);
  --ok: #3fb97a;
  --flag: #f2b630; --flag-ink: #3a2600;   /* ultimo caso lavorato di Autosave: giallo, testo sopra il giallo */
  --flag-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 21V4h11l-1.5 4L16 12H7v9z'/%3E%3C/svg%3E");
  --bad: #e5534b;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --warn: #e0812e;
  --off: #4a4f57;
  --faint: #3a3f47;
  --line-strong: #3a404a;
  --scrim: rgba(0, 0, 0, .6);
  --ovl: rgba(14, 16, 19, .72);
  --ovl-hover: rgba(40, 44, 50, .9);
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: var(--radius); --r-xl: 14px; --r-pill: 999px;
  --h-sm: 30px; --h-md: 36px;
  /* spaziature, righe e controlli: ogni padding, gap e margin dei componenti passa da qui */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --h-row: 36px; --h-xs: 28px; --h-bar: 14px;
  /* glifi delle icone: piccolo (predefinito), medio, grande */
  --ic-sm: 16px; --ic-md: 20px; --ic-lg: 24px;
  /* comandi di riproduzione (pulsante icona grande) */
  --h-transport: 40px;
  /* video e timeline: distanza tra i riquadri del mosaico, corsia, colonna delle etichette, tasto del giorno */
  --sp-video: 2px;
  --h-lane: 20px; --w-tl-labels: 96px;
  --h-day: 46px; --w-day: 46px;
  /* comando delle schede principali sul telefono (barra in basso) */
  --h-tabbtn: 52px;
  --w-ctl: 220px; --w-ctl-sm: 140px; --w-num: 96px;
  /* altezza minima del corpo dei dialoghi a linguette: cambiando linguetta il dialogo non salta */
  --h-dlg-body: 420px;
  /* ora legale nella timeline e ombre sopra il video */
  --dst: #1d6fe0; --dst-soft: #6aa8ff; --dst-ink: #9cc4ff;
  --shadow-ink: #000;
  /* scala dei caratteri: l'opzione «Grande» cambia solo --fs-k (15 / 13.5) e la scala la segue tutta */
  --fs-k: 1;
  --fs-2xs: calc(10px * var(--fs-k)); --fs-xs: calc(11px * var(--fs-k)); --fs-sm: calc(12px * var(--fs-k));
  --fs-md: calc(12.5px * var(--fs-k)); --fs-base: calc(13.5px * var(--fs-k)); --fs-lg: calc(15px * var(--fs-k));
  --fs-xl: calc(18px * var(--fs-k)); --fs-2xl: calc(20px * var(--fs-k));
  --font-mono: ui-monospace, Consolas, monospace;
  /* testo e comandi sopra il video: il fondo è sempre nero, quindi restano fuori dal tema */
  --vid-fg: #fff;
  --vid-fg-2: rgba(255, 255, 255, .75);
  --vid-muted: rgba(255, 255, 255, .6);
  --vid-faint: rgba(255, 255, 255, .4);
  --vid-fill: rgba(255, 255, 255, .08);
  --vid-fill-hi: rgba(255, 255, 255, .14);
  --side-w: 270px;
  --c-rec: var(--ok); --c-motion: #e8c53a; --c-ivs: var(--bad);
  --top-h: 56px; --tabbar-h: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: var(--fs-base)/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.srch-off { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; font-size: var(--fs-md); text-align: center; }
.spacer { flex: 1; }
code { background: var(--surface-3); padding: 0 var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-sm); }
/* impronte e identificativi da leggere carattere per carattere */
.mono { font-family: var(--font-mono); overflow-wrap: anywhere; }
i[data-ic] { display: inline-flex; width: var(--ic-sm); height: var(--ic-sm); flex: none; }
i[data-ic] svg { width: 100%; height: 100%; }
.ring { display: inline-block; flex: none; width: var(--ic-lg); height: var(--ic-lg); border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 20%, transparent);
  border-top-color: currentColor; animation: spin 1s linear infinite; }
.ring.sm { width: var(--ic-sm); height: var(--ic-sm); }

/* ---------- controlli ---------- */
.btn { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--h-md); padding: 0 var(--sp-4);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-md);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn[hidden] { display: none; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: var(--h-sm); padding: 0 var(--sp-3); font-size: var(--fs-md); }
.btn.block { width: 100%; justify-content: center; height: calc(var(--h-md) + var(--sp-1)); }
.btn.danger { color: var(--bad); }
/* pulsante che resta premuto (sincronia, taglio, flag, dimensioni delle regole): una sola classe di stato */
.btn.active, .icon-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--text); }
.btn.primary.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.primary.danger:hover { background: color-mix(in srgb, var(--bad) 85%, #fff); border-color: transparent; }
.icon-btn { width: var(--h-md); height: var(--h-md); display: inline-grid; place-items: center; background: transparent;
  color: var(--text-2); border: 0; border-radius: var(--r-md); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: var(--h-sm); height: var(--h-sm); }
/* taglia grande: comandi di riproduzione (Playback, Autosave, Flash) */
.icon-btn.lg { width: var(--h-transport); height: var(--h-transport); border-radius: var(--r-lg); }
.icon-btn.lg i[data-ic], .icon-btn.lg svg { width: var(--ic-lg); height: var(--ic-lg); }
.icon-btn svg { width: 1.2em; height: 1.2em; }
.icon-btn.danger { color: var(--bad); }
/* stato disabilitato: unico per pulsanti, icone, selettori a segmenti e voci di menu */
.btn:disabled, .icon-btn:disabled, .layouts button:disabled, .ctx button:disabled { opacity: .45; cursor: default; }
input, select, textarea { background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 0 var(--sp-3); height: var(--h-md); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: var(--sp-2) var(--sp-3); font: var(--fs-sm)/1.5 var(--font-mono); width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.select { height: var(--h-md); }
.select.sm { height: var(--h-sm); font-size: var(--fs-md); }
.field { display: flex; flex-direction: column; gap: var(--sp-1); flex: 1; min-width: 120px; }
.field > span { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.field.grow { flex: 2; } .field.small { flex: .5; min-width: 80px; }
/* Casella di spunta standard: unica per tutto il VMS (gli interruttori usano .switch) */
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; min-width: 16px; margin: 0; padding: 0;
  display: inline-grid; place-content: center; flex: none; vertical-align: middle; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--muted); border-radius: var(--r-xs); transition: background .15s, border-color .15s; }
input[type=checkbox]:hover { border-color: var(--brand); }
input[type=checkbox]:checked, input[type=checkbox]:indeterminate { background: var(--brand); border-color: var(--brand); }
input[type=checkbox]:checked::after { content: ""; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
input[type=checkbox]:indeterminate::after { content: ""; width: 8px; height: 2px; border-radius: 1px; background: #fff; }
.switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; color: var(--text-2); user-select: none; }
.switch input { display: none; }
.switch span { width: 32px; height: 18px; border-radius: var(--r-lg); background: var(--surface-3); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(14px); }
/* pallino di stato: stessa geometria del badge */
.dot, .badge-s.ok::before, .badge-s.no::before, .badge-s.warn::before, .badge-s.bad::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot { background: var(--off); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 15%, transparent); }
.dot.off { background: var(--bad); }
.dot.wait { background: var(--warn); }

/* ---------- accesso ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; z-index: 10;
  background: radial-gradient(1200px 600px at 50% -10%, #15202a 0%, var(--bg) 60%); }
.login-box { width: min(360px, 92vw); display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-6);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); }
.login-logo { height: 46px; align-self: center; }
.login-sub { text-align: center; color: var(--muted); font-size: var(--fs-sm); letter-spacing: .14em; text-transform: uppercase; margin: calc(var(--sp-1) * -1) 0 var(--sp-2); }

/* ---------- struttura ---------- */
/* dvh: sui telefoni 100vh comprende la barra dell'indirizzo; i margini env() evitano notch e barra di sistema (viewport-fit=cover) */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar { height: var(--top-h); flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 var(--sp-4); border-bottom: 1px solid var(--line-soft); background: var(--bg); }
/* il corpo della "e" (metà bassa del logo) pesa più delle aste: 3px verso l'alto compensano senza staccare il logo dal bordo */
.brand-box { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; }
.brand { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; position: relative; top: -3px; }
.brand img { height: 26px; }
/* altezza delle maiuscole = corpo della "e" del logo (54% di 26px ≈ 14px): Inter ha maiuscole a 0.727em, quindi 19px */
/* il corpo della "e" occupa la metà bassa del logo: line-height e padding-top (14+12 = 26px) portano le maiuscole in quella fascia */
.brand span { font-size: 19px; line-height: 14px; padding-top: 12px; font-weight: 600; letter-spacing: .1em; color: var(--muted); padding-left: 7px; border-left: 1px solid var(--line); }
.tabs, .layouts { display: flex; gap: var(--sp-1); background: var(--surface); border: 1px solid var(--line-soft); padding: var(--sp-1); border-radius: var(--r-lg); }
.tabs button { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--h-sm); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--muted); font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; transition: color .15s, background .15s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface-3); color: var(--text); }
/* taglia piccola: le schede di Gestione */
.tabs.sm button { height: var(--h-xs); font-size: var(--fs-md); }
/* la descrizione delle sezioni di Gestione si legge solo nell'elenco del telefono (mobile.css) */
.adm-lab small { display: none; }
.top-right { display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-2); }
.view { flex: 1; min-height: 0; }

/* ---------- live ---------- */
#view-live { display: flex; }
.side-grip { position: absolute; top: 0; bottom: 0; right: -3px; width: 6px; z-index: 2; cursor: col-resize; touch-action: none; }
.side-grip:hover, .side-grip.drag { background: var(--brand); opacity: .55; }
.sidebar, .pc-side { position: relative; width: var(--side-w); flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line-soft); padding: var(--sp-3); gap: var(--sp-2); }
.search { display: flex; align-items: center; gap: var(--sp-2); height: var(--h-md); padding: 0 var(--sp-3); background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); color: var(--muted); }
.search input { border: 0; background: transparent; height: 100%; padding: 0; flex: 1; box-shadow: none; }
.search.sm { height: var(--h-sm); }
.side-search { display: flex; align-items: center; gap: var(--sp-1); }
.side-search .search { flex: 1; min-width: 0; }
.side-search .search input { min-width: 0; }
.cam-sort { flex: none; display: inline-flex; align-items: center; gap: 0; height: var(--h-md); padding: 0 var(--sp-1); border: 0; background: none; color: var(--muted); cursor: pointer; }
.cam-sort:hover { color: var(--text); }
.cam-sort .az { display: flex; flex-direction: column; font-size: var(--fs-2xs); font-weight: 600; line-height: 1.05; }
.cam-sort svg { width: 12px; height: var(--ic-md); }
.tree { flex: 1; overflow: auto; margin: 0 calc(var(--sp-1) * -1); padding: 0 var(--sp-1); }
/* riga selezionabile di un elenco (dispositivi, organizzazioni, gruppi di utenti, picker, permessi): stessa altezza, stesso padding,
   stesso passaggio del mouse; --row-hover cambia dove lo sfondo è già quello della superficie (barre laterali) */
.cam-item, .pc-tree .dev, .org-head, .group-item, .otree-row, .opick-row, .perm {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--h-row); padding: 0 var(--sp-2); border-radius: var(--r-md);
  cursor: pointer; user-select: none; color: var(--text-2); }
.cam-item:hover, .pc-tree .dev:hover, .org-head:hover, .group-item:hover, .otree-row:hover, .opick-row:hover, .perm:hover { background: var(--row-hover, var(--surface-2)); color: var(--text); }
.sidebar, .pc-side { --row-hover: var(--surface); }
.cam-item .name, .pc-tree .dev .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cam-item .more { opacity: 0; color: var(--muted); width: var(--h-xs); height: var(--h-xs); display: grid; place-items: center; border-radius: var(--r-sm); }
.cam-item:hover .more { opacity: 1; }
.cam-item .more:hover { background: var(--surface-3); color: var(--text); }
/* stato vuoto: unico per elenchi, tabelle e viste */
.empty-box, .tree-empty, .cam-empty, .ev-empty { text-align: center; padding: var(--sp-5) var(--sp-4); color: var(--muted); font-size: var(--fs-base); line-height: 1.5; border: 1px dashed var(--line); border-radius: var(--r-lg); }
.tree-empty { margin: var(--sp-2); font-size: var(--fs-md); }
/* fisarmonica delle organizzazioni */
.org-head { width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; text-align: left; }
.org-head svg { width: 1.2em; height: 1.2em; flex: none; color: var(--muted); transform: rotate(-90deg); transition: transform .15s; }
.org.open > .org-head svg { transform: none; }
.org-head .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.org-head .count { color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }
.org > .org-body { display: none; padding-left: var(--sp-3); }
.org.open > .org-body { display: block; }
.org-body > .cam-item + .cam-item, .org-body > .dev + .dev { margin-top: var(--sp-1); }
/* sezione «Locale» del toolkit */
.org.local { position: relative; }
.org.local > .org-head { padding-right: calc(var(--h-sm) + var(--sp-3)); }
.org.local > .local-add { position: absolute; top: calc((var(--h-row) - var(--h-sm)) / 2); right: var(--sp-2); }
.local-note { padding: var(--sp-1) var(--sp-2) var(--sp-2); color: var(--muted); font-size: var(--fs-md); }

.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #070809; }
.stage-bar { height: calc(var(--h-md) + var(--sp-3)); flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-3); }
.layouts button { width: var(--h-sm); height: var(--h-xs); display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer; }
.layouts button svg { width: var(--ic-sm); height: var(--ic-sm); }
.layouts button:hover { color: var(--text); }
.layouts button.active { background: var(--surface-3); color: var(--text); }
/* riga bloccata da un'altra impostazione: appare sulla scelta «0» senza cambiare il valore salvato */
.layouts.locked button.active { background: transparent; color: var(--muted); }
.layouts.locked button[data-v="0"] { background: var(--surface-3); color: var(--text); }
/* varianti con testo: stessa larghezza automatica, stesso corpo */
.tl-head .layouts button, .opt-ctl .layouts button, .audit-bar .layouts button { width: auto; padding: 0 var(--sp-3); font: inherit; font-size: var(--fs-md); white-space: nowrap; }
.stage-actions { display: flex; gap: var(--sp-1); align-items: center; }
.grid { flex: 1; display: grid; gap: var(--sp-video); padding: 0 var(--sp-video) var(--sp-video); min-height: 0; position: relative; }
.grid:fullscreen { background: #000; padding: 0; }

.tile { position: relative; background: #000; overflow: hidden; min-height: 0; border-radius: var(--r-xs); outline: 1px solid transparent; outline-offset: -1px; transition: outline-color .15s; }
.tile.sel { outline-color: var(--brand); }
.tile.drop { outline-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, #000); }
.tile ek-stream { position: absolute; inset: 0; display: block; }
.tile ek-stream video { width: 100%; height: 100%; object-fit: contain; }
.tile ek-stream.swap { visibility: hidden; }
/* nome in alto, seguito dal pulsante dell'istantanea; a destra lascia il posto ai comandi (PTZ, altro, rimuovi) */
.tile .label { position: absolute; top: var(--sp-2); left: var(--sp-3); right: calc(var(--sp-2) + 3 * var(--h-xs) + 3 * var(--sp-1));
  height: var(--h-xs); display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); pointer-events: none; z-index: 2;
  text-shadow: 0 0 2px var(--shadow-ink), 0 1px 3px color-mix(in srgb, var(--shadow-ink) 80%, transparent); }
.tile .label .tile-name { font-size: var(--fs-base); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* velo sfumato sotto nome e comandi: li rende leggibili anche su un'immagine chiara senza togliere spazio al video */
.tile[data-cam]::after { content: ""; position: absolute; inset: 0 0 auto; height: calc(var(--h-xs) + 3 * var(--sp-2)); z-index: 1; pointer-events: none;
  background: linear-gradient(color-mix(in srgb, var(--shadow-ink) 62%, transparent), transparent); }
.tile .tools { position: absolute; top: var(--sp-2); right: var(--sp-2); display: flex; gap: var(--sp-1); z-index: 3; opacity: 0; transition: opacity .15s; }
.tile:hover .tools, .tile .tools.pin { opacity: 1; }
/* pulsante icona sopra il video: stesso corpo per i comandi del riquadro, dell'anteprima e delle impostazioni del dispositivo */
.vid-btn { display: grid; place-items: center; width: var(--h-xs); height: var(--h-xs); padding: 0; border: 0; border-radius: var(--r-md); cursor: pointer;
  background: var(--ovl); color: var(--vid-fg); backdrop-filter: blur(6px); }
.vid-btn:hover { background: var(--ovl-hover); }
.vid-btn[hidden] { display: none; }
.vid-btn i[data-ic], .vid-btn svg { width: var(--ic-sm); height: var(--ic-sm); }
.vid-btn.active { background: var(--brand); }
/* etichetta di testo (HD/SD) al posto dell'icona: senza fondo */
.vid-btn.txt { width: auto; padding: 0 var(--sp-1); background: none; backdrop-filter: none; font: inherit; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; color: var(--vid-fg-2);
  text-shadow: 0 1px 3px color-mix(in srgb, var(--shadow-ink) 80%, transparent); }
.vid-btn.txt:hover { background: none; color: var(--vid-fg); }
.vid-btn.txt:disabled { color: var(--vid-faint); cursor: default; }
.tile .maxbtn, .tile .snapbtn { opacity: 0; transition: opacity .15s; }
.tile .maxbtn { position: absolute; right: var(--sp-2); bottom: var(--sp-2); z-index: 3; }
.tile .snapbtn { flex: none; pointer-events: auto; }
.tile:hover .maxbtn, .tile:hover .snapbtn { opacity: 1; }
.tile .qualbtn { position: absolute; left: var(--sp-2); bottom: var(--sp-2); z-index: 3; }
.tile .tools .close:hover { background: var(--bad); color: #fff; }
/* blocco a SD piena: contorno rosso e striscia in alto sul riquadro (live e playback); i comandi che compaiono al passaggio
   del mouse scendono sotto la striscia */
.tile .sdblock { position: absolute; inset: 0; z-index: 2; border: 3px solid var(--bad); pointer-events: none; }
.sdblock-bar { position: absolute; left: -3px; right: -3px; top: -3px; display: flex; align-items: center; gap: var(--sp-2); height: var(--h-xs); padding: 0 var(--sp-3);
  border: 0; background: var(--bad); color: #fff; font: inherit; font-size: var(--fs-sm); font-weight: 600; text-align: left; white-space: nowrap;
  overflow: hidden; pointer-events: auto; }
button.sdblock-bar { cursor: pointer; }
.sdblock-bar svg { width: var(--ic-sm); height: var(--ic-sm); flex: none; }
.sdblock-t { flex: none; }
.sdblock-d { font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.sdblock-d::before { content: "· "; }
.tile.sdblock-on .tools, .tile.sdblock-on .label { top: calc(var(--h-xs) + var(--sp-2)); }
/* triangolino dopo il nome nelle liste dei dispositivi */
.sdwarn { display: inline-grid; place-items: center; flex: none; margin-left: var(--sp-2); padding: 0; border: 0; background: none; color: var(--bad); cursor: default; }
button.sdwarn { cursor: pointer; }
.sdwarn svg { width: var(--ic-sm); height: var(--ic-sm); }
.state { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; pointer-events: none; color: var(--vid-muted); font-size: var(--fs-sm); text-align: center; }
.state .ring { display: block; margin: 0 auto var(--sp-3); }
.state.err { color: var(--vid-fg-2); }
.state.err .ico { width: var(--ic-lg); height: var(--ic-lg); margin: 0 auto var(--sp-2); color: var(--bad); }
.state small { display: block; color: var(--vid-faint); margin-top: var(--sp-1); font-size: var(--fs-xs); }
@keyframes spin { to { transform: rotate(360deg); } }

/* PTZ */
.ptz { position: absolute; z-index: 4; padding: var(--sp-3); border-radius: var(--r-xl);
  background: rgba(14, 16, 19, .82); backdrop-filter: blur(10px); border: 1px solid var(--vid-fill); display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; }
.ptz .pad { position: relative; width: 116px; height: 116px; border-radius: 50%; background: var(--vid-fill); }
.ptz .pad button { position: absolute; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--vid-fg); cursor: pointer; display: grid; place-items: center; touch-action: none; }
.ptz .pad button:hover { background: var(--vid-fill-hi); }
.ptz .pad button:active, .ptz button.active { background: var(--brand) !important; }
.ptz .pad .pt { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .6; }
.ptz .pad .c { left: 40px; top: 40px; background: var(--vid-fill); cursor: default; }
.ptz .row { display: flex; gap: var(--sp-2); align-items: center; width: 100%; font-size: var(--fs-xs); color: var(--vid-muted); }
.ptz .row button { height: var(--h-xs); min-width: var(--h-xs); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-md); background: var(--vid-fill); color: var(--vid-fg); cursor: pointer; font: inherit; font-size: var(--fs-sm); touch-action: none; }
.ptz .row button:hover { background: var(--vid-fill-hi); }
.ptz .row input[type=number] { width: 48px; height: var(--h-xs); padding: 0 var(--sp-1); font-size: var(--fs-sm); background: color-mix(in srgb, var(--shadow-ink) 35%, transparent); border-color: var(--vid-fill-hi); }
.ptz .row input[type=range] { flex: 1; height: auto; padding: 0; accent-color: var(--brand); background: none; border: 0; box-shadow: none; }
/* leva dello zoom: la tacca segna il centro, dove torna al rilascio */
.ptz .row input.lever { background: linear-gradient(var(--vid-muted), var(--vid-muted)) center / 2px 60% no-repeat; touch-action: none; }
.tile.focus-arm { cursor: crosshair; touch-action: none; }
.focus-box { position: absolute; border: 1px dashed var(--brand); pointer-events: none; }

/* ---------- pagine ---------- */
.page { height: 100%; overflow: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.page-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-xl); font-weight: 600; margin: 0 var(--sp-2) 0 0; letter-spacing: -.01em; }
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }

/* riproduzione */
.sw { display: inline-block; width: 9px; height: 9px; border-radius: var(--r-xs); flex: none; }
.sw.rec { background: var(--c-rec); } .sw.motion { background: var(--c-motion); } .sw.ivs { background: var(--c-ivs); }
.pb-top { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.pb-cam { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-box { position: absolute; inset: 0; overflow: hidden; }
.pb-box ek-stream { position: absolute; inset: 0; display: block; }
.pb-box ek-stream video { width: 100%; height: 100%; object-fit: contain; }
/* riproduzione sincronizzata: riquadro coperto finché il gruppo non parte, avviso sopra il fermo immagine */
.pb-box.sync-wait > :not(.sync-note, .state-holder) { visibility: hidden; }
.sync-note .state { z-index: 2; background: var(--ovl); color: var(--vid-fg); }
.placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--sp-3); color: var(--muted); text-align: center; padding: var(--sp-4); }
.placeholder i[data-ic] { width: var(--ic-lg); height: var(--ic-lg); opacity: .5; }
.placeholder p { margin: 0; }
/* dispositivo scaduto: al posto del video, sopra lo stato di connessione (z-index 1) e sotto l'etichetta e i comandi */
.expired-box { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: #000; overflow: hidden; }
.expired-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.expired-text { color: var(--vid-muted); font-size: var(--fs-sm); text-align: center; }
.ev-expired .shot { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-sm); overflow: hidden; }
.ev-expired .c { color: var(--muted); font-size: var(--fs-sm); }
.srv-expiry-prev { display: block; max-width: 320px; max-height: 180px; margin: var(--sp-2) 0 var(--sp-3); border-radius: var(--r-sm); background: #000; }
/* in fondo al modulo: il calendario si apre verso l'alto, senza allungare il dialogo */
#camExpiryCal { top: auto; bottom: calc(100% + var(--sp-2)); }
.tl-card { flex: none; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4) var(--sp-2); user-select: none; }
.tl-clock { font-size: var(--fs-lg); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--muted); line-height: 1.2; }
.tl { position: relative; display: flex; gap: var(--sp-3); }
.tl-labels { width: var(--w-tl-labels); flex: none; display: flex; flex-direction: column; }
.tl-labels span { height: var(--h-lane); display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.tl-labels span + span { margin-top: var(--sp-1); }
.tl-track { position: relative; flex: 1; display: flex; flex-direction: column; gap: var(--sp-1); cursor: pointer; }
.tl-track.drag { cursor: grabbing; }
.lane { position: relative; height: var(--h-lane); background: var(--bg); border-radius: var(--r-xs); overflow: hidden; }
.lane .seg { position: absolute; top: 3px; bottom: 3px; min-width: 2px; }
.lane .seg.rec { background: var(--c-rec); opacity: .85; }
.lane .seg.motion { background: var(--c-motion); }
.lane .seg.ivs { background: var(--c-ivs); min-width: 3px; }
/* buchi da recuperare dalla SD: tratteggiati se in coda o in corso, pieni se non recuperabili */
.tl-recovery { position: relative; height: 6px; overflow: hidden; border-radius: var(--r-xs); }
.tl-recovery i { position: absolute; top: 0; bottom: 0; min-width: 1px; }
.tl-recovery i.queued, .tl-recovery i.running { background: repeating-linear-gradient(135deg, var(--warn) 0 3px, transparent 3px 6px); }
.tl-recovery i.lost { background: var(--bad); }
.gap-pop.tl-gap-pop { top: calc(100% + var(--sp-1)); bottom: auto; }
.tl-flt { position: relative; }
.tl-filter { position: absolute; left: 0; bottom: calc(100% + var(--sp-2)); z-index: 20; display: flex; flex-direction: column; min-width: 150px; padding: var(--sp-1); }
.tl-filter label { display: flex; align-items: center; gap: var(--sp-2); height: var(--h-row); padding: 0 var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-md); color: var(--text); cursor: pointer; }
.tl-filter label:hover { background: var(--surface-3); }
.tl-cursor { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff; border-radius: 2px; pointer-events: none; z-index: 2; box-shadow: 0 0 0 1px color-mix(in srgb, var(--shadow-ink) 40%, transparent); }
/* --at: posizione in % sulla traccia; lo spostamento proporzionale tiene l'etichetta dentro la traccia anche agli estremi,
   altrimenti sporgerebbe dalla pagina e le barre di scorrimento che compaiono la farebbero tremolare */
.tl-hover { position: absolute; top: -26px; left: calc(var(--at, 50) * 1%); transform: translateX(calc(var(--at, 50) * -1%)); font-size: var(--fs-xs); background: var(--surface-3); border: 1px solid var(--line); padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm); pointer-events: none; z-index: 3; white-space: nowrap; }
.tl-ticks { position: relative; height: calc(var(--sp-4) + var(--sp-1)); margin-left: calc(var(--w-tl-labels) + var(--sp-3)); font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-1); }
.tl-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
/* ritorno all'ora solare: fascia blu sulla prima volta delle ore ripetute (ora legale), volta sotto l'orario delle tacche */
.tl-dst { position: absolute; top: -3px; bottom: -3px; z-index: 1; pointer-events: none; border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--dst) 30%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--dst-soft) 60%, transparent); }
.tl-ticks.dst { height: var(--sp-6); }
.tl-ticks small { display: block; text-align: center; font-size: inherit; line-height: 1.1; }
.tl-ticks small.dst, .tl-hover.legale { color: var(--dst-ink); }
/* passaggio all'ora legale: tacchetta blu sul punto del salto */
.tl-ticks span.jump::before { content: ""; position: absolute; left: 50%; top: -5px; width: 2px; height: 5px; margin-left: -1px;
  border-radius: 1px; background: color-mix(in srgb, var(--dst-soft) 90%, transparent); }
.tl-hover.legale { border-color: color-mix(in srgb, var(--dst-soft) 60%, transparent); }

/* filtri a chip ed elenco degli allarmi (Autosave, ricerca nella riproduzione) */
.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--h-sm); padding: 0 var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--line);
  background: transparent; color: var(--text-2); font: inherit; font-size: var(--fs-md); font-weight: 500; cursor: pointer; }
/* chip di un elenco di valori: il × sta a destra, il resto non si clicca */
.chip:has(.chip-x) { gap: var(--sp-1); padding: 0 var(--sp-1) 0 var(--sp-3); cursor: default; }
.chip:hover { background: var(--surface); color: var(--text); }
.chip.active { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.ev-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.ev, .ev-expired { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2); background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); }
.ev { cursor: pointer; }
.ev:hover { border-color: var(--line); }
.ev .shot { width: 100%; aspect-ratio: 16 / 9; flex: none; border-radius: var(--r-sm); background: #000 center/cover no-repeat; display: grid; place-items: center; color: var(--muted); position: relative; overflow: hidden; }
.ev .when { display: flex; align-items: baseline; gap: var(--sp-2); }
.ev .when b { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.ev .when span { font-size: var(--fs-sm); color: var(--muted); }
.ev .what { flex: 1; min-width: 0; }
.ev .what .t { font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); }
.ev .what .c { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.ev .acts { display: flex; justify-content: flex-end; gap: var(--sp-1); }

/* tabelle */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: var(--fs-sm); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--surface); }
.table td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table td.empty-cell { padding: var(--sp-3); }

/* dispositivi */
.cam-cards { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow-x: auto; overflow-y: hidden; }
.cam-card { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line-soft); }
.cam-card:first-child { border-top: 0; }
.cam-card > .st { flex: 0 0 auto; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: var(--sp-2); }
.cam-card .body { flex: 1; min-width: 0; }
.cam-card .title { font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); }
.cam-card .meta { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.cam-card .info { font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--sp-1); line-height: 1.6; }
.cam-card .info.bad { color: var(--bad); }
.cam-card .acts { display: flex; gap: var(--sp-1); flex-shrink: 0; }
.cam-card .acts .btn { justify-content: center; }
.cam-card .cam-prev { position: relative; flex: 0 0 240px; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-sm); overflow: hidden; }
.cam-prev ek-stream { position: absolute; inset: 0; display: block; }
.cam-prev ek-stream video { width: 100%; height: 100%; object-fit: contain; }
.cam-prev .prev-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: var(--fs-sm); }
.cam-cards:has(.cam-empty) { background: none; border: 0; }
@media (max-width: 760px) { .cam-card { flex-wrap: wrap; } .cam-card .acts { width: 100%; } .cam-card .acts .btn { flex: 1; } .cam-card .cam-prev { flex-basis: 100%; order: 3; } }
.cam-empty, .ev-empty { grid-column: 1 / -1; padding: calc(var(--sp-6) + var(--sp-5)) var(--sp-4); }

/* superficie dei menu e dei pannelli a comparsa (menu contestuale, download, calendario, filtri, tendina con ricerca, nota sul buco) */
.ctx, .dl-panel, .cal, .tl-filter, .pop { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: pop .12s ease-out; }
.ctx { position: fixed; z-index: 60; min-width: 230px; padding: var(--sp-1); }
.ctx .h { padding: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-1); }
.ctx .h b { display: block; color: var(--text); font-size: var(--fs-base); font-weight: 600; }
/* voce di menu: stessa altezza e stesso padding in tutti i menu */
.ctx button, .combo-list button, .speed-menu button { width: 100%; display: flex; align-items: center; gap: var(--sp-2); height: var(--h-row); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.ctx button:hover { background: var(--surface-3); }
.ctx button:disabled { background: none; }
.ctx button i[data-ic] { color: var(--text-2); }
.ctx button .k { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
.ctx button.danger { color: var(--bad); } .ctx button.danger i[data-ic] { color: var(--bad); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-1) 0; }
/* voci d'azione del menu Assistenza (Chiama, mail): pulsante in evidenza con numero o indirizzo sotto l'etichetta */
.ctx button.act { height: auto; min-height: var(--h-transport); margin-bottom: var(--sp-1); padding: var(--sp-2); border: 1px solid var(--line); }
.ctx button.act :is(b, span) { display: block; }
.ctx button.act b { font-weight: 600; }
.ctx button.act span { font-size: var(--fs-sm); color: var(--muted); }
/* pulsante diviso: azione semplice a sinistra, freccetta con il menu delle varianti (in #ctx) */
.split { display: inline-flex; position: relative; }
#toolkitActs { display: inline-flex; align-items: center; gap: var(--sp-2); }
.split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split > .btn:first-child:has(+ .caret.hidden) { border-radius: var(--r-md); }
.split > .btn.caret { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 var(--sp-2); margin-left: 0; }
/* pannello della freccetta di un download: slider Hash e Password, campi della password e pulsante Scarica */
.ctx.dl-menu { width: 310px; display: flex; flex-direction: column; gap: var(--sp-1); }
/* parti disattive: restano al loro posto, così il pannello non cambia misura */
.dl-menu .dl-pw.off, .dl-menu .opt-row:has(.switch input:disabled) { opacity: .45; }
.dl-menu .dl-pw { display: flex; flex-direction: column; gap: var(--sp-2); }
.dl-menu .opt-row { padding: var(--sp-2) 0; }
.dl-menu .dl-pw .opt-row { border-bottom: 0; }
.dl-menu .pw-eye { display: flex; }
.dl-menu .pw-eye input { width: 100%; }
.dl-menu .opt-ctl .pw-eye { flex: 1; min-width: 0; }
/* le regole di .ctx button (larghezza piena, 32 px) non valgono per l'occhio della password */
.ctx .pw-eye-btn { width: var(--h-xs); height: var(--h-xs); padding: 0; display: grid; }
.meter { height: var(--sp-1); border-radius: var(--r-sm); background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .15s, background .15s; }
/* avanzamento (progress di widgets.js): la larghezza la dà la pagina */
.meter.progress { margin: var(--sp-2) 0; }
.meter.progress i { background: var(--brand); transition: width .3s; }
.meter.indet i { width: 30% !important; animation: dl-indet 1.3s ease-in-out infinite; }
.meter[data-level="1"] i { width: 33%; background: var(--bad); }
.meter[data-level="2"] i { width: 66%; background: var(--warn); }
.meter[data-level="3"] i { width: 100%; background: var(--ok); }
/* altezza fissa anche da vuoto: il pannello non cambia misura quando il messaggio compare o sparisce */
.dl-menu #dlMsg { min-height: 1.45em; color: var(--warn); }
.dl-menu #dlMsg.bad { color: var(--bad); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }

/* gestore download (icona in testata) */
.dl-btn { position: relative; }
.dl-btn.busy { color: var(--brand-hi); }
.dl-badge { position: absolute; top: 0; right: 0; min-width: var(--sp-4); height: var(--sp-4); padding: 0 var(--sp-1); border-radius: var(--r-pill);
  background: var(--brand); color: #fff; font-size: var(--fs-2xs); font-weight: 600; line-height: var(--sp-4); text-align: center; }
.dl-panel { position: fixed; z-index: 60; width: 360px; max-width: calc(100vw - var(--sp-4)); max-height: 70vh; overflow-y: auto; padding: var(--sp-1); }
.dl-head { display: flex; align-items: center; justify-content: space-between; min-height: var(--h-row); padding: 0 var(--sp-1) 0 var(--sp-2);
  border-bottom: 1px solid var(--line); margin-bottom: var(--sp-1); }
.dl-item { padding: var(--sp-2); border-radius: var(--r-sm); }
.dl-item + .dl-item { border-top: 1px solid var(--line-strong); }
.dl-row { display: flex; align-items: center; gap: var(--sp-1); }
.dl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dl-row .icon-btn { flex: none; }
.dl-row .icon-btn:hover { background: var(--surface-3); }
@keyframes dl-indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.dl-item.paused .meter i { background: var(--muted); }
.dl-item.done .meter i { background: var(--ok); }
.dl-item.error .meter i, .dl-item.cancelled .meter i { background: var(--bad); }
.dl-info { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--muted); }
.dl-item.error .dl-info span:last-child { color: var(--bad); text-align: right; }
.dl-when { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.dl-lock { flex: none; display: inline-flex; margin-right: var(--sp-1); color: var(--text-2); }
.dl-lock i[data-ic] { width: 1.1em; height: 1.1em; }
.dl-hash { display: inline-flex; align-items: center; gap: var(--sp-1); flex: none; }
.dl-hash i[data-ic] { width: 1.1em; height: 1.1em; }
.dl-hash code { font-family: var(--font-mono); color: var(--text-2); }
.dl-empty { padding: var(--sp-4) var(--sp-3); text-align: center; color: var(--muted); }

/* finestre */
dialog, .pc-preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); }
.pc-modal { position: fixed; inset: 0; z-index: 50; background: var(--scrim); backdrop-filter: blur(3px); display: grid; place-items: center; }

/* dialoghi */
dialog { color: var(--text); padding: 0; width: min(600px, 94vw); }
dialog:focus { outline: none; }
#confirmDlg { width: min(420px, 94vw); }
.tutorial-head { display: flex; align-items: center; gap: var(--sp-2); }
.tutorial-head h2 { flex: 1; }
.tutorial-videos { display: flex; flex-direction: column; gap: var(--sp-2); }
.tutorial-items { display: flex; flex-direction: column; gap: var(--sp-1); max-height: 60vh; overflow-y: auto; }
.tutorial-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-2); border: 0; border-radius: var(--r-md); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.tutorial-item:hover { background: var(--surface-3); }
.tutorial-item img { flex: none; width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-3); }
.tutorial-player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-lg); overflow: hidden; }
.tutorial-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
/* corpo dei dialoghi di servizio: testo, card e piè a distanza uguale */
#credBody, #restartBody, #restoreBody, #lanBody { display: flex; flex-direction: column; gap: var(--sp-3); }
.form { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.form h2 { margin: 0; font-size: var(--fs-xl); font-weight: 600; }
.form p { margin: 0; line-height: 1.7; }
/* Interruttore spento ben visibile (bordo e pallino) e voce attenuata; acceso: colore del brand e testo pieno */
.form .switch:has(input:not(:checked)) { color: var(--muted); }
.form .switch:has(input:checked) { color: var(--text); }
.form .switch input:not(:checked) + span { box-shadow: inset 0 0 0 1px var(--muted); background: var(--surface-2); }
.form .switch input:not(:checked) + span::after { background: var(--muted); }
#camForm:not(.is-onvif) .onvif-only, #camForm.is-onvif .dahua-only, #localForm.is-onvif .dahua-only { display: none; }
.found-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.found-list:empty { display: none; }
.found-list button { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); text-align: left; background: var(--surface-2);
  color: var(--text); border: 1px solid var(--line); border-radius: var(--r-md); font: inherit; cursor: pointer; }
.found-list button:hover { border-color: var(--brand); }
.found-list button small { margin-left: auto; color: var(--muted); }
.found-list .muted { font-size: var(--fs-sm); }
.check-scroll { max-height: 220px; overflow: auto; margin-bottom: 0; border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--sp-1); }
.check-scroll > .muted { padding: var(--sp-2); font-size: var(--fs-md); }
.perm:has(input:disabled) { cursor: default; }
.found-list button:disabled { opacity: .55; cursor: default; }
.found-list button:disabled:hover { border-color: var(--line); }
.chip-x { padding: 0 var(--sp-1); border: 0; background: none; color: inherit; font: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.chip-x:hover { color: var(--bad); }

/* popover: annulla posizione e margini predefiniti del browser (inset: 0, margin: auto) */
/* banner di notifica: stesso stile per toast e avvisi nei dialoghi, colore dato da --c */
/* box di avviso unico (toast, avvisi nei dialoghi e nelle pagine): il colore lo dà il modificatore ok | bad | warn */
.notice { --c: var(--brand); padding: var(--sp-2) var(--sp-3); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: var(--r-lg); background: color-mix(in srgb, var(--c) 14%, var(--surface-3)); color: var(--text); font-size: var(--fs-base); }
.notice:not(.toast), .toast:popover-open { display: flex; align-items: center; gap: var(--sp-3); }
.notice.sd { align-items: flex-start; }
.notice svg { flex: none; width: 1.2em; height: 1.2em; color: var(--c); }
.notice.ok { --c: var(--ok); }
.notice.bad { --c: var(--bad); }
.notice.warn { --c: var(--warn); }
.notice .btn { margin-left: auto; }
.toast { position: fixed; inset: calc(var(--top-h) + var(--sp-2)) auto auto 50%; margin: 0; transform: translateX(-50%); width: max-content; max-width: min(700px, calc(100vw - 24px));
  z-index: 70; box-shadow: var(--shadow); padding: var(--sp-3) var(--sp-4); font-size: calc(16px * var(--fs-k)); line-height: 1.35; }
.toast svg { width: 1.4em; height: 1.4em; }

::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-lg); border: 4px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  :root { --w-tl-labels: 22px; }
  .topbar { grid-template-columns: auto 1fr auto; gap: var(--sp-2); padding: 0 var(--sp-2); }
  .top-right { gap: var(--sp-1); }
  .tabs:not(.sm) { justify-self: center; overflow-x: auto; }
  .tabs button { padding: 0 var(--sp-2); }
  .tabs:not(.sm) button i[data-ic] { display: none; }
  .tl-labels span { font-size: 0; } .tl-labels span.tl-flt { font-size: var(--fs-md); }
  .page { padding: var(--sp-4); }
}

/* ---------- accesso a più passaggi ---------- */
.login-step { display: flex; flex-direction: column; gap: var(--sp-3); }
.login-help { margin: 0; color: var(--text-2); font-size: var(--fs-md); line-height: 1.6; text-align: center; }
.otp { height: calc(var(--h-md) + var(--sp-4)); text-align: center; font-size: 26px; letter-spacing: .5em; font-variant-numeric: tabular-nums; padding-left: .5em; }
.qr { width: 188px; height: 188px; align-self: center; border-radius: var(--r-lg); background: #fff; }
.secret { text-align: center; font: var(--fs-sm)/1.4 var(--font-mono); color: var(--muted); word-break: break-all; user-select: all; }

/* ---------- utente in alto ---------- */
.user-btn { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--h-md); padding: 0 var(--sp-2) 0 var(--sp-1); border-radius: var(--r-pill); border: 1px solid var(--line-soft);
  background: var(--surface); color: var(--text-2); font: inherit; cursor: pointer; }
.user-btn:hover { color: var(--text); border-color: var(--line); }
.user-btn i[data-ic] { width: var(--ic-sm); height: var(--ic-sm); }
.avatar { width: var(--h-xs); height: var(--h-xs); border-radius: 50%; background: var(--brand-soft); color: var(--brand-hi); display: inline-grid; place-items: center; font-size: var(--fs-sm); font-weight: 600; flex: none; }
.avatar.big { width: calc(var(--h-md) + var(--sp-2)); height: calc(var(--h-md) + var(--sp-2)); font-size: var(--fs-lg); }
.avatar.xs { width: calc(var(--sp-4) + var(--sp-1)); height: calc(var(--sp-4) + var(--sp-1)); font-size: var(--fs-2xs); }

/* ---------- amministrazione ---------- */
.sub { color: var(--muted); font-size: var(--fs-sm); }
.sub.err { color: var(--bad); text-align: left; min-height: 0; }
/* etichetta: un solo stile, il colore lo dà il modificatore (bad, warn, brand, flag, dst) */
.tag { display: inline-flex; align-items: center; gap: var(--sp-1); margin-left: var(--sp-2); padding: 0 var(--sp-2); border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.7; vertical-align: middle; }
.title .tag, td > .tag:first-child { margin-left: 0; }
.tag.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.tag i[data-ic] { width: 1.2em; height: 1.2em; }
.utable .acts { text-align: right; white-space: nowrap; }
.utable .acts .btn, .utable .acts .icon-btn { vertical-align: middle; }
.admin-search { width: 280px; }
.utable .who { display: flex; gap: var(--sp-3); align-items: center; }
.utable .sel { width: 40px; padding-right: 0; }
/* contatori nelle schede di Gestione */
.chip-count { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
#adminTabs { max-width: 100%; overflow-x: auto; }
.chip-count:empty { display: none; }
.table-head { padding: var(--sp-2) var(--sp-3) 0; font-size: var(--fs-sm); }
.adm-devices { display: flex; flex-direction: column; gap: var(--sp-3); }
/* utenti: colonna dei filtri, barra dei filtri e delle azioni di gruppo, tabella */
.adm-users { display: flex; gap: var(--sp-4); align-items: flex-start; }
.group-list { width: 220px; flex: none; padding: var(--sp-1); display: flex; flex-direction: column; }
.group-item .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.group-item .count { color: var(--muted); font-size: var(--fs-sm); }
.adm-users-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.adm-bar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.batch-bar { display: contents; }
#batchErrors { flex-direction: column; align-items: flex-start; gap: var(--sp-1); }
/* organizzazioni: albero delle sole organizzazioni a sinistra, contenuto di quella scelta a destra */
.adm-orgs { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.org-tree { padding: var(--sp-1); position: sticky; top: var(--sp-3); max-height: calc(100vh - 220px); overflow: auto; }
.otree-row, .opick-row { padding-left: calc(var(--sp-2) + var(--depth) * var(--sp-4)); }
.otree-row.found .name { color: var(--brand-hi); }
.otree-row .name, .opick-row .name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.otree-row .count { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.otree-ic svg { width: 1.2em; height: 1.2em; color: var(--muted); display: block; }
.otree-tog { flex: none; color: var(--muted); }
.otree-tog:hover { background: var(--surface-3); }
.otree-tog svg { transform: rotate(-90deg); transition: transform .15s; }
.otree-tog.open svg { transform: none; }
.otree-tog.leaf { visibility: hidden; }
.org-detail { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); min-height: calc(var(--h-row) * 6); }
.oc-head { display: flex; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap; }
.oc-head h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); font-weight: 600; }
.oc-pills { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.oc-pills .tag { margin-left: 0; }
.oc-acts { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.oc-switch { align-self: flex-start; }
.oc-list .table { margin: 0; }
.pad { padding: var(--sp-3) var(--sp-1); margin: 0; font-size: var(--fs-md); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
/* vista Dispositivi: un solo elenco (tabella) oppure riquadri con l'anteprima */
.dev-table .tinfo .info { margin: 0; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }
.dev-table .tinfo .info.bad { color: var(--bad); }
.dev-table .acts { text-align: right; white-space: nowrap; }
.dev-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.dev-tiles .cam-card { flex-direction: column; align-items: stretch; border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: var(--surface); position: relative; }
.dev-tiles .cam-card > .st { position: absolute; top: var(--sp-4); left: var(--sp-4); z-index: 1; }
.dev-tiles .cam-card .cam-prev { flex: none; width: 100%; }
/* riquadro di associazione: disponibili (albero) a sinistra, assegnate a destra */
.opick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: hidden; }
.opick-col { padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.opick-col + .opick-col { border-left: 1px solid var(--line-soft); background: var(--surface-2); }
.opick-tree { max-height: 240px; overflow: auto; }
.opick-row input { margin: 0; pointer-events: none; }
.opick-row.on { color: var(--text); }
.opick-row.off { cursor: default; }
.opick-row small { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.opick-sel { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-content: flex-start; }
.opick-tag { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-md); padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3); border-radius: var(--r-md);
  background: var(--brand-soft); color: var(--text); }
.opick-tag .icon-btn { color: var(--muted); }
.opick-tag:not(:has(button)) { padding-right: var(--sp-3); }
.opick-note { margin: 0; font-size: var(--fs-sm); }
.opick-note:empty { display: none; }
/* riquadri di scelta piatti con ricerca (preset, permessi) */
.picker { display: flex; flex-direction: column; gap: var(--sp-2); }
.picker-foot { font-size: var(--fs-sm); }
.picker-foot:empty { display: none; }
/* stato del preset di un utente: messaggio e, se serve, il pulsante che lo riporta al preset */
.preset-state { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-3) 0 0; }
.preset-state .notice { align-self: stretch; }
.picker.readonly .perm { opacity: .5; }
@media (max-width: 900px) { .adm-orgs { grid-template-columns: 1fr; } .org-tree { position: static; max-height: 320px; } }
@media (max-width: 600px) { .opick { grid-template-columns: 1fr; } .opick-col + .opick-col { border-left: 0; border-top: 1px solid var(--line-soft); } }
@media (max-width: 760px) {
  .admin-search { width: 100%; }
  .adm-users { flex-direction: column; align-items: stretch; }
  .group-list { width: auto; }
}
/* le tabelle larghe scorrono di lato dentro il loro riquadro invece di essere tagliate, a ogni larghezza */
:has(> .table) { overflow-x: auto; }
.badge-s { display: inline-flex; align-items: flex-start; gap: var(--sp-2); min-width: 0; font-size: var(--fs-sm); color: var(--text-2); }
/* lo stato può essere una frase: va a capo e il pallino resta alla prima riga */
.badge-s::before { margin-top: .43em; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.badge-s.ok::before { background: var(--ok); } .badge-s.no::before { background: var(--off); } .badge-s.warn::before { background: var(--warn); }
.badge-s.bad { color: var(--bad); } .badge-s.bad::before { background: var(--bad); }

/* ---------- impostazioni: righe, card, schede ---------- */
/* card appaiate: le due di una riga hanno sempre la stessa altezza; .full solo per tabelle e grafici */
.opt-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: stretch; margin-bottom: var(--sp-4); }
.opt-pair.full { grid-template-columns: minmax(0, 1fr); }
.opt-card { display: flex; flex-direction: column; min-width: 0; padding: var(--sp-4); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); }
/* testo lungo, anche senza spazi (email, percorsi): va a capo dentro la card invece di uscirne; le tabelle restano com'erano */
.opt-card, .notice { overflow-wrap: anywhere; }
.opt-card table { overflow-wrap: normal; }
/* il contenuto della card non si comprime: la card cresce, la riga di card si allinea alla più alta */
.opt-card > * { flex-shrink: 0; }
.opt-card > .act-bar { margin-top: auto; }
.opt-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); }
.opt-head h3 { margin: 0; min-width: 0; font-size: var(--fs-lg); font-weight: 600; }
.opt-head > :not(h3) { margin-left: auto; min-width: 0; text-align: right; }
.opt-card > .help { margin-top: var(--sp-1); }
/* stati lunghi o più di uno (disco, prenotazioni): sotto il titolo; vuoti non occupano spazio */
.opt-states { display: flex; flex-direction: column; gap: var(--sp-1); padding-top: var(--sp-2); }
.opt-states:empty { display: none; }
/* la colonna del controllo prende lo spazio che le serve ma non oltre il 60% della riga: un valore lungo va a capo e non schiaccia l'etichetta */
.opt-row { display: grid; grid-template-columns: minmax(0, 1fr) fit-content(60%); align-items: center; column-gap: var(--sp-4); row-gap: var(--sp-1);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line-soft); }
.opt-row:last-child { border-bottom: 0; }
.opt-row.has-ico { grid-template-columns: auto minmax(min-content, 1fr) fit-content(60%); }
.opt-row > .help, .opt-row > .opt-tags { grid-column: 1 / -1; }
.opt-row.has-ico > .help, .opt-row.has-ico > .opt-tags { grid-column: 2 / -1; }
.opt-lab { min-width: 0; font-weight: 600; overflow-wrap: normal; }
.opt-ico { display: grid; place-items: center; width: var(--h-sm); height: var(--h-sm); border-radius: var(--r-md);
  background: var(--brand-soft); color: var(--brand-hi); }
.opt-ico svg { width: 18px; height: 18px; }
.opt-ctl { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); min-width: 0; }
.opt-ctl > span { min-width: 0; text-align: right; }
.opt-ctl input:not([type=checkbox]), .opt-ctl .select { width: var(--w-ctl); max-width: 100%; min-width: 0; }
.opt-ctl input.num { width: var(--w-num); }
.opt-ctl input.num:disabled { opacity: .45; }
.opt-ctl .unit { color: var(--muted); }
.opt-ctl .layouts { max-width: 100%; flex-wrap: wrap; }
/* scelta di un file: pulsante e nome del file; il campo nativo resta nascosto */
.file-pick { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.file-name { min-width: 0; max-width: var(--w-ctl-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.opt-row.stack { grid-template-columns: minmax(0, 1fr); }
.opt-row.stack > .opt-ctl { justify-content: stretch; }
.opt-ctl textarea { width: 100%; }
/* dialoghi Dispositivo: l'ultima riga visibile di una card non ha la riga di separazione (la segna dialogform.js) */
.opt-row.is-last { border-bottom: 0; }
/* l'elenco dei risultati della ricerca sta sotto la riga, a tutta larghezza */
.opt-sub > .found-list { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line-soft); }
.opt-sub > .found-list:empty { padding: 0; border: 0; }
/* l'albero delle organizzazioni in una card sta su una colonna: la scelta compare sotto l'albero */
.opt-row.stack > .opt-ctl > div { flex: 1; min-width: 0; }
.opt-pair:not(.full) .opt-row.stack .opick { grid-template-columns: minmax(0, 1fr); }
.opt-ctl .opick-row input { width: auto; }
.opt-ctl .picker input:not([type=search]) { width: auto; }
.opt-ctl .picker .search input { width: 100%; }
.dlg-panel, #setBody .tf-panel { min-height: var(--h-dlg-body); }
.opt-ctl .opick .search input { width: 100%; }
.opt-pair:not(.full) .opt-row.stack .opick-col + .opick-col { border-left: 0; border-top: 1px solid var(--line-soft); }
.opt-pair:not(.full) .opt-row.stack .opick-tree { max-height: 160px; }
/* il piè dei dialoghi con le card resta visibile quando il corpo scorre */
#camBody > .act-bar, #localBody > .act-bar, #accBody > .act-bar, #userBody > .act-bar, #orgBody > .act-bar, #presetBody > .act-bar, #setBody .tf-panel > .act-bar { position: sticky; bottom: 0; margin: 0 calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)); padding: var(--sp-3) var(--sp-5);
  background: var(--surface); border-top: 1px solid var(--line-soft); }
/* nelle Impostazioni il piè sta sempre in fondo al pannello, anche con poco contenuto, a filo del bordo del dialogo */
#setBody .tf-panel { display: flex; flex-direction: column; }
#setBody .tf-panel > .act-bar { margin: auto calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)); }
/* Sicurezza e Server (Gestione): lo stesso piè con «Salva», in fondo alla pagina e fisso anche scorrendo */
#adminSecurity, #adminServer { flex: 1; }
:is(#adminSecurity, #adminServer) > [data-tabform], :is(#adminSecurity, #adminServer) .tf-panel:not(.hidden) { flex: 1; display: flex; flex-direction: column; }
:is(#adminSecurity, #adminServer) .tf-panel > .act-bar { position: sticky; bottom: calc(-1 * var(--sp-5)); margin: auto calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)); padding: var(--sp-3) var(--sp-5);
  background: var(--bg); border-top: 1px solid var(--line-soft); }
/* azione distruttiva del piè di un dialogo: a sinistra, lontana da Annulla e Salva */
.act-bar [data-act="delete"] { margin-right: auto; }
/* tasto di una scorciatoia: stessa larghezza per tutti; la scheda Tastiera ha molte righe, quindi più compatte */
.opt-ctl [data-w="key"] { min-width: var(--w-num); justify-content: center; }
.tf-panel[data-panel="keys"] .opt-row { padding: var(--sp-2) 0; }
/* scheda Tastiera: una tab per gruppo e le righe su due colonne; il titolo della card ripeterebbe quello della tab */
.key-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.key-tabs button { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-3); background: none;
  border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--muted); font: inherit; cursor: pointer; }
.key-tabs button:hover { color: var(--text); }
.key-tabs button.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-hi); }
.key-tabs small { font-size: var(--fs-xs); }
.key-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--sp-5); }
.key-rows > .sect { grid-column: 1 / -1; }
/* le tre card occupano lo stesso spazio e le non attive restano invisibili: il dialogo non cambia altezza passando da una tab all'altra */
.key-stack { display: grid; }
.key-stack > .opt-pair { grid-area: 1 / 1; margin-bottom: 0; }
.key-stack > .opt-pair.hidden { display: grid !important; visibility: hidden; }
.tf-panel[data-panel="keys"] .opt-head { display: none; }
@media (max-width: 700px) { .key-rows { grid-template-columns: minmax(0, 1fr); } }
.opt-card:inert { opacity: .45; }
/* per attributo: dove il browser non conosce `:inert` l'intera regola verrebbe scartata */
#lanNetRows[inert] { opacity: .45; }
#set-lan .opt-ctl input:not([type=checkbox]) { width: var(--w-ctl-sm); }
#fnPreview { word-break: break-all; }
/* parti di una card mostrate solo con una scelta attiva: l'ultima riga del gruppo tiene la sua riga di separazione */
.opt-sub > .opt-row:last-child { border-bottom: 1px solid var(--line-soft); }
.opt-sub:last-child > .opt-row:last-child { border-bottom: 0; }
.opt-ctl .meter { width: var(--w-ctl); }
.kit-msg { min-height: 1.45em; margin: var(--sp-2) 0 0; color: var(--warn); font-size: var(--fs-md); }
.kit-msg.is-bad { color: var(--bad); }
.opt-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.opt-tags .tag { margin-left: 0; }
.help { margin: 0; color: var(--text-2); font-size: var(--fs-md); }
.help.bad { color: var(--bad); }
.subtabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); }
.subtabs button { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
.subtabs button:hover { color: var(--text); }
.subtabs button.active { color: var(--text); box-shadow: inset 0 -2px var(--brand); }
/* linguetta con risultati della ricerca */
.subtabs button.found { color: var(--brand-hi); }
/* linguetta ancora in lettura o non supportata dal dispositivo: resta al suo posto */
.subtabs button.loading { opacity: .6; }
.subtabs button.unsupported { opacity: .4; cursor: not-allowed; }
.subtabs button.dirty::after, .subtabs button.ok::after, .subtabs button.bad::after { content: ''; width: 7px; height: 7px;
  border-radius: 50%; background: var(--brand); }
.subtabs button.ok::after { background: var(--ok); }
.subtabs button.bad::after { background: var(--bad); }
.subtabs button.saving::after { content: ''; width: 9px; aspect-ratio: 1; box-sizing: border-box; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--brand) 25%, transparent); border-top-color: var(--brand); animation: spin 1s linear infinite; }
.act-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-3); }
.tag.brand { background: var(--brand-soft); color: var(--brand-hi); }
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.dst { background: color-mix(in srgb, var(--dst) 28%, transparent); color: var(--dst-ink); }
.tag.flag { background: var(--flag); color: var(--flag-ink); }
button.tag { border: 0; font: inherit; cursor: pointer; }
@media (max-width: 900px) { .opt-pair { grid-template-columns: minmax(0, 1fr); } }
/* telefono: il controllo va sotto l'etichetta, che così non si riduce a poche lettere per riga; gli interruttori e i numeri,
   che sono piccoli, restano a destra della loro etichetta */
@media (max-width: 520px) {
  .opt-row { grid-template-columns: minmax(0, 1fr); }
  .opt-row.has-ico { grid-template-columns: auto minmax(0, 1fr); }
  .opt-row.has-ico > .opt-ctl { grid-column: 2; }
  .opt-ctl { flex-wrap: wrap; justify-content: flex-start; }
  .opt-ctl > span { text-align: left; }
  .opt-row:has(> .opt-ctl > :is(.switch, input.num)) { grid-template-columns: minmax(0, 1fr) auto; }
  .opt-row.has-ico:has(> .opt-ctl > :is(.switch, input.num)) { grid-template-columns: auto minmax(0, 1fr) auto; }
  .opt-row.has-ico:has(> .opt-ctl > :is(.switch, input.num)) > .opt-ctl { grid-column: 3; }
  .opt-row:has(> .opt-ctl > :is(.switch, input.num)) > .opt-ctl { flex-wrap: nowrap; justify-content: flex-end; }
}
/* caselle raggruppate per menu */
dialog.wide { width: min(860px, 96vw); }
#camDlg, #localDlg, #userDlg { width: min(920px, 96vw); }
/* titolo di un gruppo di righe dentro una card */
.sect { margin: var(--sp-3) 0 0; font-size: var(--fs-xs); font-weight: 600; color: var(--brand-hi); letter-spacing: .08em; text-transform: uppercase; }
.opt-head + .sect { margin-top: var(--sp-2); }
.perm-list { display: flex; flex-direction: column; margin-bottom: var(--sp-3); }
.perm { padding-top: var(--sp-1); padding-bottom: var(--sp-1); }
.perm b { font-weight: 500; display: block; }
.perm small { color: var(--muted); font-size: var(--fs-sm); }
/* albero dei permessi: figli rientrati di --depth livelli, padre con freccia, contatore e casella a tre stati */
.perm { padding-left: calc(var(--sp-2) + var(--depth, 0) * var(--sp-5)); }
.perm-parent { cursor: default; }
.perm-parent .perm-lab { flex: 1; min-width: 0; display: flex; gap: var(--sp-2); align-items: center; cursor: pointer; }
.perm-parent .perm-lab:has(input:disabled) { cursor: default; }
.perm-count { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.perm-gap { width: var(--h-sm); flex: none; }
.pw-eye { position: relative; display: inline-flex; max-width: 100%; }
.field > .pw-eye { display: flex; }
.pw-eye input { flex: 1 1 auto; min-width: 0; padding-right: calc(var(--h-xs) + var(--sp-2)); }
.pw-eye-btn { position: absolute; right: var(--sp-1); top: 50%; width: var(--h-xs); height: var(--h-xs); transform: translateY(-50%); display: grid; place-items: center;
  padding: 0; background: transparent; border: 0; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; }
.pw-eye-btn:hover { color: var(--text); background: var(--surface-3); }
.pw-eye-btn svg { width: 1.2em; height: 1.2em; }
/* le date del dialogo Utente sono in righe che non lasciano spazio né sopra né sotto: il calendario si apre al centro dello schermo */
#userForm .cal { position: fixed; inset: 0; margin: auto; height: fit-content; }
#userForm [data-name="password"] { flex: 1; width: auto; font-family: var(--font-mono); }
.cred { margin: 0; padding: var(--sp-3); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); font: var(--fs-base)/1.7 var(--font-mono); white-space: pre-wrap; user-select: all; }
.acc-head { display: flex; gap: var(--sp-3); align-items: center; }
.acc-setup { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-3) 0; }
.opt-ctl .otp { height: var(--h-md); font-size: var(--fs-xl); }
#forcePwDlg .form, #accountDlg .form { gap: var(--sp-3); }

/* calendario della riproduzione */
.datepick { position: relative; }
.datepick .cal { left: auto; right: 0; }
.cal { position: absolute; top: calc(100% + var(--sp-2)); left: 0; z-index: 40; width: 292px; padding: var(--sp-3); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.cal-head b { font-weight: 600; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp-1); }
.cal-grid .wd { font-size: var(--fs-xs); color: var(--muted); text-align: center; padding: var(--sp-1) 0; text-transform: uppercase; }
.cal-grid button { position: relative; height: var(--h-row); border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-2); font: inherit; cursor: pointer; font-variant-numeric: tabular-nums; }
.cal-grid button:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.cal-grid button.rec { color: var(--text); font-weight: 600; }
.cal-grid button.rec::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--ok); }
.cal-grid button.today { box-shadow: inset 0 0 0 1px var(--line); }
.cal-grid button.sel { background: var(--brand); color: #fff; }
.cal-grid button.sel::after { background: #fff; }
.cal-grid button:disabled { color: var(--faint); cursor: default; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.cal-foot .dotlg { display: inline-flex; align-items: center; gap: var(--sp-2); }
.cal-foot .dotlg::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.cal-loading { position: absolute; inset: 44px 12px 50px; display: grid; place-items: center; background: color-mix(in srgb, var(--surface-2) 60%, transparent); border-radius: var(--r-md); }
.cal-loading .ring { width: var(--ic-md); height: var(--ic-md); }

/* riproduzione: striscia dei giorni */
.daystrip { display: inline-flex; align-items: center; gap: var(--sp-2); }
.daystrip .day { position: relative; width: var(--w-day); height: var(--h-day); border-radius: var(--r-lg); border: 1px solid var(--line-soft); background: var(--surface-2);
  color: var(--text-2); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; transition: background .12s, border-color .12s; }
.daystrip .day:hover { background: var(--surface-3); border-color: var(--line); }
.daystrip .day small { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.daystrip .day b { font-size: var(--fs-lg); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.daystrip .day em { position: absolute; top: -7px; right: -5px; font-style: normal; font-size: var(--fs-2xs); text-transform: uppercase; background: var(--surface-3); color: var(--text-2); padding: 0 var(--sp-1); border-radius: var(--r-xs); }
.daystrip .day.rec::after { content: ""; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--ok); }
/* giorno con l'ultimo caso lavorato di un dispositivo: bandierina in alto a destra, il pallino resta in basso */
.daystrip .day.flag::before, .cal-grid button.flag::before { content: ""; position: absolute; top: 3px; right: 3px; width: 10px; height: 10px; background: var(--flag);
  -webkit-mask: var(--flag-icon) center / contain no-repeat; mask: var(--flag-icon) center / contain no-repeat; }.daystrip .day.sel { background: var(--brand); border-color: var(--brand); }
.daystrip .day.sel small, .daystrip .day.sel b { color: #fff; }
.daystrip .day.sel::after { background: #fff; }
.daystrip .day.jump { width: auto; padding: 0 var(--sp-3); flex-direction: row; gap: var(--sp-2); font-size: var(--fs-base); color: var(--text); border-style: dashed; }
.day-cal { width: var(--w-day); height: var(--h-day); border-radius: var(--r-lg); border: 1px dashed var(--line); background: transparent; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.day-cal:hover { background: var(--surface-2); color: var(--text); border-style: solid; }
.day-cal i[data-ic], .day-cal svg { width: var(--ic-md); height: var(--ic-md); }

.lane .seg.hit { box-shadow: 0 0 0 1px rgba(255,255,255,.85); z-index: 1; }

/* pre-accertamento */
#view-precheck { display: flex; }
.pc { flex: 1; display: flex; min-width: 0; }
.pc-side-head { display: flex; align-items: baseline; justify-content: flex-end; padding: 0 var(--sp-1); }
.pc-all { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2); color: var(--text-2); cursor: pointer; font-size: var(--fs-md); }
.pc-tree { flex: 1; overflow: auto; }
.pc-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) var(--sp-2); }
.pc-range { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-types { position: relative; }
.pc-types .tl-filter { top: calc(100% + var(--sp-2)); bottom: auto; left: auto; right: 0; min-width: 210px; }
.cal-grid button.inrange, .cal-grid button.inrange:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 26%, transparent); color: var(--text); border-radius: 0; }
.cal-time { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.cal-time label { flex: 1; display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--muted); }
.pc-body { flex: 1; display: flex; gap: var(--sp-3); min-height: 0; padding: 0 var(--sp-5) var(--sp-4); }
.pc-results { flex: 1; overflow: auto; min-width: 0; }
/* senza ricerca fatta il messaggio vuoto sta al centro dell'area, largo quanto il suo testo e con gli stessi margini di quello di Flash */
.pc-results:has(> .pc-info > .empty-box) { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.pc-results:has(> .pc-info > .empty-box) > .pc-info { padding: 0; }
.pc-info > .empty-box { padding: var(--sp-5) var(--sp-6); }
.pc-info { padding: var(--sp-2) var(--sp-1) var(--sp-3); font-size: var(--fs-base); }
.pc-info.has-sort { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.pc-info .err { text-align: left; flex-basis: 100%; }
.pc-info b { color: var(--text); }
.pc-info .pc-wait { display: inline-flex; gap: var(--sp-2); align-items: center; }
/* riga selezionata in un elenco: stesso evidenziatore ovunque */
.cam-item.inuse, .pc-tree .dev.on, .group-item.active, .otree-row.sel { background: var(--brand-soft); color: var(--text); }
.ev.sel { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); box-shadow: 0 0 0 1px var(--brand); }
.ev .src { font-size: var(--fs-xs); color: var(--muted); }
/* ultimo caso lavorato: scheda e anteprima in giallo, distinte dal blu dell'ultimo allarme aperto (.sel) */
.ev.flagged { position: relative; border-color: var(--flag); background: color-mix(in srgb, var(--flag) 14%, var(--surface)); box-shadow: 0 0 0 1px var(--flag); }
/* allarmi che precedono il flag: già lavorati, giallo tenue con bordo giallo senza l'alone del flag; .sel (blu) prevale se è l'allarme aperto */
.ev.worked:not(.sel) { border-color: var(--flag); background: color-mix(in srgb, var(--flag) 6%, var(--surface)); }
.ev .when .flag-btn { align-self: center; margin-left: auto; color: var(--muted); }
.flag-btn.active, .ev .when .flag-btn.active { background: var(--flag); color: var(--flag-ink); border-color: var(--flag); }
/* etichetta «Ultimo caso lavorato» sull'anteprima della scheda */
.ev > .tag.flag { position: absolute; left: var(--sp-3); top: var(--sp-3); z-index: 2; margin: 0; font-weight: 600; pointer-events: none; }
/* stessa misura del glifo in elenco e in anteprima */
.flag-btn i { display: inline-flex; width: var(--ic-lg); height: var(--ic-lg); }
/* username di chi ha segnato l'allarme: a sinistra della bandierina, che resta all'estremità destra */
.ev .when .flag-by { align-self: center; margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.ev .when .flag-by + .flag-btn { margin-left: 0; }
.pc-modal { padding: var(--sp-4); }
.pc-preview { width: min(960px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3); }
.pc-prev-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.pc-prev-title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.pc-prev-head .muted { font-size: var(--fs-sm); margin-top: var(--sp-1); }
.pc-prev-acts { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.pc-preview.max { width: 100%; height: 100%; }
.pc-preview.max .pc-player { flex: 1; min-height: 0; aspect-ratio: auto; }
.pc-player-box { position: relative; display: flex; flex-direction: column; border-radius: var(--r-md); }
.pc-preview.max .pc-player-box { flex: 1; min-height: 0; }
/* come la scheda dell'elenco (.ev.flagged): si illumina tutta la finestra, non solo il video */
.pc-preview.flagged { border-color: var(--flag); background: color-mix(in srgb, var(--flag) 14%, var(--surface)); box-shadow: 0 0 0 1px var(--flag), var(--shadow); }
.pc-player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-md); overflow: hidden; }
.pc-player ek-stream { position: absolute; inset: 0; display: block; }
@media (max-width: 1000px) { .ev-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .pc-bar, .pc-body { padding-inline: var(--sp-4); } }
@media (max-width: 600px) { .ev-list { grid-template-columns: 1fr; } }

/* ---------- Flash ---------- */
#view-flash { display: flex; }
.fl-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-3); padding: 0 var(--sp-5) var(--sp-4); }
/* palco: riquadro 16:9 più grande possibile nello spazio rimasto */
.fl-stage { flex: 1; min-height: calc(var(--h-row) * 4); position: relative; container-type: size; display: grid; place-items: center; }
.fl-frame { position: relative; width: min(100cqw, 100cqh * 16 / 9); aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-md); overflow: hidden; }
.fl-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.fl-frame.fl-zoomon { cursor: zoom-in; touch-action: none; }
.fl-frame.fl-zoomon.fl-zoomed { cursor: grab; }
.fl-frame.fl-zoomon.panning { cursor: grabbing; }
.fl-frame .zoom-badge { left: auto; right: 10px; }
.fl-frame.fl-zoomed canvas { will-change: transform; }
.fl-ovl { position: absolute; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm); background: var(--ovl); color: var(--vid-fg); font-size: var(--fs-md); pointer-events: none; }
.fl-hd { top: 10px; left: 10px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; color: var(--vid-fg-2); }
.fl-miss { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--sp-2); background: #0d0f12; color: var(--vid-muted); text-align: center; }
.fl-miss i[data-ic] { width: var(--ic-lg); height: var(--ic-lg); opacity: .5; }
.fl-miss b { color: var(--vid-fg-2); font-weight: 500; }
.fl-msg .empty-box { padding: var(--sp-5) var(--sp-6); }
.fl-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-4); color: var(--muted); font-size: var(--fs-lg); text-align: center; }
.fl-bar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--sp-2); }
@media (max-width: 900px) { .fl-bar { grid-template-columns: 1fr; justify-items: center; } .fl-bar > .tl-side:first-child { display: none; } }
.fl-power > .btn { min-width: 0; white-space: nowrap; }
.fl-film { flex: none; display: grid; grid-template-columns: repeat(var(--fl-strip), minmax(0, 1fr)); gap: var(--sp-2); }
.fl-th { position: relative; aspect-ratio: 16 / 9; padding: 0; border: 2px solid transparent; border-radius: var(--r-sm); background: #000; overflow: hidden; cursor: pointer; }
.fl-th:hover:not(.cur) { border-color: var(--line-strong); }
.fl-th.cur { border-color: var(--brand); }
.fl-th.empty { visibility: hidden; }
.fl-th img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fl-th.miss img { visibility: hidden; }
.fl-th span { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 var(--sp-1); background: var(--ovl); color: var(--vid-fg-2); font: var(--fs-2xs)/1.4 var(--font-mono); white-space: nowrap; overflow: hidden; }
.fl-ruler { flex: none; position: relative; }
#flRuler { display: block; width: 100%; height: 40px; font-size: var(--fs-xs); touch-action: none; cursor: pointer; }
#flWarn { flex: none; }
.gap-pop { position: absolute; bottom: calc(100% + var(--sp-2)); z-index: 20; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); white-space: nowrap; }
.gap-pop b { font-weight: 500; }
.gap-pop small { color: var(--muted); font: var(--fs-xs) var(--font-mono); }
.pc-tree .dev .fl-note { flex: none; font-size: var(--fs-2xs); color: var(--muted); }
@media (max-width: 900px) { .fl-body { padding-inline: var(--sp-4); } }
/* telefono: solo le miniature centrali */
@media (max-width: 600px) {
  .fl-film { grid-template-columns: repeat(var(--fl-strip-phone), minmax(0, 1fr)); }
  .fl-th.far { display: none; }
}

/* ---------- Autosave: la "e" del logo ---------- */
/* il corpo della "e" del logo occupa il 54% dell'immagine: 1.04em ≈ altezza delle minuscole */
.autosave { display: inline; white-space: nowrap; }
.e-mark { height: 1.04em; width: auto; margin-left: .01em; vertical-align: baseline; }

/* ---------- impostazioni ---------- */
.swatches { display: flex; gap: var(--sp-2); }
.swatches button { width: var(--h-xs); height: var(--h-xs); padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.swatches button.active { border-color: var(--text); }

:root[data-font="large"] { --fs-k: 1.111; }

/* zoom digitale */
.zoom-badge { position: absolute; left: var(--sp-3); top: var(--sp-3); z-index: 3; display: inline-flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-2);
  border-radius: var(--r-xl); background: var(--ovl); color: var(--vid-fg); font-size: var(--fs-sm); font-weight: 600; backdrop-filter: blur(6px); }
.zoom-badge button { width: var(--sp-5); height: var(--sp-5); display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--vid-fill-hi); color: var(--vid-fg); cursor: pointer; padding: 0; }
.zoom-badge button svg { width: 1em; height: 1em; }
.zoomed { cursor: grab; }
.panning { cursor: grabbing; }
.zoomed ek-stream { will-change: transform; }

/* regole di allarme sul video: zone in verde, linee in arancio */
.ivs-ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
:root[data-ivs="0"] .ivs-ov, .zoomed .ivs-ov { display: none; }
.ivs-ov polygon { fill: color-mix(in srgb, var(--c) 14%, transparent); stroke: var(--c); stroke-width: 2; vector-effect: non-scaling-stroke; }
.ivs-ov polyline { fill: none; stroke: var(--c); stroke-width: 3; vector-effect: non-scaling-stroke; }
.ivs-ov text { fill: #fff; font-weight: 600; paint-order: stroke; stroke: color-mix(in srgb, var(--shadow-ink) 70%, transparent); stroke-linejoin: round; }
/* regola in allarme nel Live: il perimetro si ispessisce e lampeggia; riempimento e nome restano fermi */
.ivs-ov g.alarm :is(polygon, polyline) { stroke-width: 5; animation: ivs-blink .5s steps(1) infinite; }
@keyframes ivs-blink { 50% { stroke-opacity: 0; } }

/* finestra «Regole di allarme»: live a sinistra, elenco e parametri a destra */
#alarmDlg { width: min(1100px, 96vw); }
#alarmDlg[open] { display: flex; max-height: min(94vh, 860px); overflow: hidden; }
#alarmDlg .form { flex: 1; min-width: 0; min-height: 0; }
.ar-dev { margin-left: var(--sp-2); font-size: var(--fs-base); font-weight: 400; }
.ar-top:empty, .ar-livebar:empty { display: none; }
.ar-livebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); }
.ar-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: var(--sp-4); align-items: start; }
.ar-live { position: sticky; top: 0; display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.ar-stage { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: var(--r-md); overflow: hidden; }
.ar-stage ek-stream { position: absolute; inset: 0; display: block; }
.ar-stage ek-stream video { width: 100%; height: 100%; object-fit: contain; }
.ar-side { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.ar-list { display: flex; flex-direction: column; gap: var(--sp-1); max-height: 200px; overflow-y: auto; }
.ar-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-3); border: 1px solid var(--line-soft); border-radius: var(--r-md); }
.ar-row.sel { border-color: var(--brand); background: var(--brand-soft); }
.ar-sw { width: var(--sp-3); height: var(--sp-3); flex: none; border-radius: var(--r-xs); }
.ar-pick { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: var(--sp-1) 0; border: 0; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.ar-pick b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ar-pick small { color: var(--muted); font-size: var(--fs-sm); }
.ar-empty { padding: var(--sp-2) 0; font-size: var(--fs-md); }
@media (max-width: 800px) { .ar-body { grid-template-columns: 1fr; } .ar-live { position: static; } }
.ar-body[inert] { opacity: .6; }

/* disegno sul video: zone, linee e rettangoli delle dimensioni; clic e maniglie solo se la regola è modificabile */
.ar-box { position: absolute; inset: 0; }
.ar-edit { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.ar-edit.editable { pointer-events: auto; cursor: crosshair; touch-action: none; }
.ar-edit polygon, .ar-edit polyline, .ar-edit .ar-sz { vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.ar-edit .ar-sz { fill: none; stroke-width: 2px; }
.ar-edit .ar-sz.dashed { stroke-dasharray: 8 5; }
.ar-edit text { fill: #fff; font-weight: 600; paint-order: stroke; stroke: color-mix(in srgb, var(--shadow-ink) 70%, transparent); stroke-linejoin: round; pointer-events: none; }
.ar-edit .ar-side { text-anchor: middle; dominant-baseline: central; }
.ar-edit .ar-shape { fill: transparent; stroke: transparent; pointer-events: all; cursor: move; }
.ar-edit .ar-shape.line { fill: none; pointer-events: stroke; }
.ar-edit .ar-hit { fill: none; stroke: transparent; pointer-events: stroke; cursor: move; }
.ar-edit .ar-h { stroke: #fff; stroke-width: 2px; vector-effect: non-scaling-stroke; cursor: grab; }
.ar-edit .ar-h.nw, .ar-edit .ar-h.se { cursor: nwse-resize; }
.ar-edit .ar-h.ne, .ar-edit .ar-h.sw { cursor: nesw-resize; }
.ar-edit .ar-shaft { fill: none; stroke: #fff; stroke-width: 3px; }
.ar-edit .ar-shaft-bg { fill: none; stroke: color-mix(in srgb, var(--shadow-ink) 65%, transparent); stroke-width: 6px; }
.ar-edit .ar-arrow { fill: #fff; stroke: color-mix(in srgb, var(--shadow-ink) 65%, transparent); stroke-width: 1.5px; }
.ar-edit .ar-shaft, .ar-edit .ar-shaft-bg { vector-effect: non-scaling-stroke; }
.ar-draw { display: flex; flex-wrap: wrap; align-items: center; align-self: flex-start; gap: var(--sp-2); margin-left: auto; font-size: var(--fs-md); }
.ar-draw .muted { min-width: 0; }
.ar-draw .muted:empty { display: none; }
.ar-edit .mg-on { fill-opacity: .55; stroke: none; pointer-events: none; }
.ar-edit .mg-lines { fill: none; stroke: rgba(255, 255, 255, .5); stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
.mg-tools, .ov-tools { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; font-size: var(--fs-md); }
.mg-tools .muted, .ov-tools .muted { min-width: 0; }
.ar-edit .ov-box { fill-opacity: .16; stroke-width: 2px; vector-effect: non-scaling-stroke; pointer-events: all; cursor: move; }
.ar-edit .ov-box.mask { fill-opacity: .42; }
.ar-edit .ov-box.off { stroke-dasharray: 8 5; fill-opacity: .1; }
#alarmDlg[data-tab="overlay"] .ar-edit.editable { cursor: default; }
.ar-view { position: relative; }
.ar-fs { position: absolute; right: var(--sp-2); bottom: var(--sp-2); z-index: 4; opacity: 0; transition: opacity .15s; }
.ar-qual { position: absolute; right: calc(var(--sp-2) + var(--h-xs) + var(--sp-1)); bottom: var(--sp-2); z-index: 4; }
.ar-view:hover .ar-fs, .ar-fs:focus-visible { opacity: 1; }
@media (hover: none) { .ar-fs { opacity: 1; } }
.ar-live.full { position: fixed; inset: 0; z-index: 10; padding: var(--sp-3); gap: var(--sp-3); background: #000; }
.ar-live.full .ar-view { flex: 1; min-height: 0; }
.ar-live.full .ar-stage { aspect-ratio: auto; height: 100%; border-radius: 0; }
.ar-sizebtns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* preset PTZ: selettore e indicatore, elenco per preset, messaggio sull'immagine quando la telecamera è altrove */
.ar-ptz { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); }
.ar-preset { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text-2); }
.ar-preset .select { width: auto; max-width: 240px; height: var(--h-sm); font-size: var(--fs-md); }
.ar-state { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); color: var(--muted); }
.ar-state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ar-state.ok { color: var(--ok); }
.ar-state.off { color: var(--warn); }
#arTop .notice, .ds-pane > .notice { margin-top: var(--sp-2); }
.ar-list.grouped { max-height: 260px; }
.ar-group { display: flex; flex-direction: column; gap: var(--sp-1); }
.ar-gh { align-self: flex-start; padding: var(--sp-1) 0; border: 0; background: none; color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.ar-group.cur .ar-gh { color: var(--brand); }
.ar-none { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-md); }
.ar-away { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; padding: var(--sp-3); pointer-events: none; }
.ar-away-card { pointer-events: auto; max-width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); background: rgba(15, 17, 21, .82); color: #fff; font-size: var(--fs-md); text-align: center; }
.ar-away-card p { margin: 0; }
.ar-away-card small { color: rgba(255, 255, 255, .7); }
@media (max-width: 800px) { .ar-away-card { gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); } }
/* impostazioni del dispositivo: schede, avviso di blocco e controlli delle schede generiche */
.ds-loading { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; font-size: var(--fs-md); }
.ds-rules, .ds-pane { display: flex; flex-direction: column; gap: var(--sp-3); }
#alarmDlg:not([data-tab="rules"]) #arTop, #alarmDlg:not([data-tab="rules"]) .ar-away { display: none; }
.ds-pane[inert] { opacity: .6; }
.ds-pane > .btn { align-self: flex-start; }
.night-card + .btn { margin-top: var(--sp-2); }
/* profilo notturno: vista semplice della scheda Regola immagine e riquadro sulla tile (stesso markup) */
.night-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); }
.night-panel { display: flex; flex-direction: column; gap: var(--sp-3); align-self: stretch; min-width: 0; }
.night-head { display: flex; align-items: center; gap: var(--sp-2); }
.night-head svg { width: var(--ic-md); height: var(--ic-md); flex: none; }
.night-title { font-size: var(--fs-lg); font-weight: 600; }
.night-warn { display: inline-flex; padding: 0; border: 0; background: none; color: var(--flag); cursor: pointer; }
.night-warn svg { width: var(--ic-sm); height: var(--ic-sm); }
.night-line { font-size: var(--fs-md); color: var(--muted); }
/* le due scelte stanno sulla stessa riga; gli otturatori scendono sotto «Priorità targhe», nella colonna di destra */
.night-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-2); }
.night-choices { display: contents; }
.night-choice, .night-shutter { display: flex; align-items: center; background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-md); font: inherit; font-size: var(--fs-md); cursor: pointer; transition: background .15s, border-color .15s; }
.night-choice { gap: var(--sp-3); min-height: var(--h-md); padding: 0 var(--sp-3); }
.night-choice svg { width: var(--ic-md); height: var(--ic-md); flex: none; }
.night-choice:hover, .night-shutter:hover { background: var(--surface-3); }
.night-choice.sel, .night-shutter.sel { background: var(--brand-soft); border-color: var(--brand); }
.night-shutters { grid-column: 2; display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.night-shutters-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); padding-bottom: var(--sp-1); }
.night-shutter { justify-content: space-between; gap: var(--sp-3); min-height: var(--h-sm); padding: 0 var(--sp-3); white-space: nowrap; }
.night-time { color: var(--muted); font-variant-numeric: tabular-nums; }
/* aperto, l'elenco prende il posto della riga del valore scelto: i tempi restano sempre nello stesso ordine e quello scelto
   è evidenziato (con la freccia in su, che richiude); ogni rilettura del pannello lo richiude */
.night-dd summary { list-style: none; }
.night-dd summary::-webkit-details-marker { display: none; }
.night-dd[open] > summary { display: none; }
.night-dd .night-time { display: inline-flex; align-items: center; gap: var(--sp-1); }
.night-dd svg { width: 1.2em; height: 1.2em; flex: none; transition: transform .15s; }
.night-dd-list .sel svg { transform: rotate(180deg); }
.night-dd-list { display: flex; flex-direction: column; gap: var(--sp-1); }
/* pastiglia in basso a destra del riquadro live, a sinistra di «ingrandisci»; sempre visibile, non solo al passaggio del mouse */
.night-pill { position: absolute; z-index: 3; bottom: var(--sp-2); right: calc(var(--sp-2) + var(--h-xs) + var(--sp-1)); display: inline-flex; align-items: center;
  gap: var(--sp-1); height: var(--h-xs); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-md); background: var(--ovl); color: var(--vid-fg);
  backdrop-filter: blur(6px); font: inherit; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; cursor: pointer; }
.night-pill:hover { background: var(--ovl-hover); }
.night-pill:disabled { opacity: .6; cursor: progress; }
.night-pill svg { width: var(--ic-sm); height: var(--ic-sm); flex: none; }
.night-pop { position: absolute; z-index: 5; bottom: calc(var(--h-xs) + 2 * var(--sp-2)); right: var(--sp-2); box-sizing: border-box; width: min(34rem, calc(100% - 2 * var(--sp-2)));
  max-height: calc(100% - var(--h-xs) - 3 * var(--sp-2)); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); cursor: default; animation: pop .12s ease-out; }
.night-pop .night-head { padding-right: calc(var(--h-xs) + var(--sp-2)); }
.night-pop-x { position: absolute; top: var(--sp-2); right: var(--sp-2); }
.night-pop-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }
/* sparisce con le sovraimpressioni nascoste, con lo zoom digitale (come `.ivs-ov`) e con il PTZ aperto dentro il riquadro */
:root[data-night="0"] :is(.night-pill, .night-pop), .zoomed :is(.night-pill, .night-pop), .tile.ptz-in :is(.night-pill, .night-pop) { display: none; }
.opt-head .select { width: auto; max-width: 11em; height: var(--h-sm); font-size: var(--fs-md); text-align: left; }
.opt-ctl .range { padding: 0; height: auto; border: 0; background: transparent; box-shadow: none; accent-color: var(--brand); }
.opt-ctl output { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: var(--fs-md); }
.opt-ctl input[type=time] { width: calc((var(--w-ctl) - var(--sp-4)) / 2); }
/* scheda Notifiche: le regole si vedono sul video anche con «Regole di allarme sul video» spenta */
#alarmDlg[data-tab="notify"] .ivs-ov { display: block; }
.opt-ctl .ptz-spot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); width: 100%; min-width: 0; }
.opt-ctl .ptz-spot .select:first-child { flex: 1 1 100%; width: auto; }
.opt-ctl .ptz-spot .select:not(:first-child) { width: 5em; }
.opt-ctl .ptz-spot .btn { flex: none; }
.opt-ctl .ptz-spot .btn:nth-last-child(3) { margin-left: auto; }
.opt-card > .notice { margin: var(--sp-3) 0 0; }

.log-table td { font-size: var(--fs-md); vertical-align: top; }
/* log del dispositivo: tracce e dettagli su più righe restano leggibili */
.devlog-detail { white-space: pre-wrap; overflow-wrap: anywhere; }
.user-btn { white-space: nowrap; }
@media (max-width: 1500px) { #userName { display: none; } .user-btn { padding-right: var(--sp-1); } }

/* ---------- riproduzione: trasporto, velocità, post-produzione ---------- */
.pb-box video.vod, .pc-player video.vod { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.zoomed video.vod { will-change: transform; }
.tl-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.tl-side { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); min-width: 0; }
.tl-side.end { justify-content: flex-end; }
/* Taglia: stessa altezza del gruppo dello zoom; con content-box il bordo di .btn si somma come quello di .layouts */
#cutToggle, #pcCutToggle { box-sizing: content-box; height: calc(var(--h-xs) + 2 * var(--sp-1)); padding: 0 var(--sp-4); font-size: var(--fs-lg); }
.tl-center { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); }
.tl-ctrl { display: flex; align-items: center; gap: var(--sp-2); }
.tl-time { display: flex; align-items: center; gap: var(--sp-2); }
.tl-date { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .tl-head { grid-template-columns: 1fr; justify-items: center; } .tl-side.end { justify-content: center; } }
.transport { display: inline-flex; align-items: center; gap: var(--sp-1); }
.speed-pick { position: relative; }
.speed-pick > .btn { min-width: 54px; font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
.speed-menu { min-width: 84px; }
.speed-menu button { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.speed-menu button:hover { background: var(--surface-3); }
.speed-menu button.active { background: var(--surface-3); color: var(--brand-hi); }


/* logo Ekiller appena visibile sullo sfondo nero dei riquadri video */
.tile::before, .pc-player::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: url('/ek-static/logo-dark.png') center / min(34%, 220px) auto no-repeat;
  opacity: .045; filter: grayscale(1);
}
.tile .label { color: var(--vid-fg); }

/* taglio registrazione */
.cut-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: var(--surface-2); font-size: var(--fs-md); }
.cut-hint { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--muted); }
.cut-hint svg { width: var(--ic-sm); height: var(--ic-sm); }
.cut-hint b { color: var(--text); font-weight: 600; }
.cut-t { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--muted); }
.cut-t input { height: var(--h-sm); padding: 0 var(--sp-2); font-variant-numeric: tabular-nums; width: auto; }
.cut-bar .err { color: var(--bad); }
.tl-sel { position: absolute; top: 0; bottom: 0; z-index: 2; pointer-events: none; background: color-mix(in srgb, var(--brand) 62%, transparent);
  border: 2px solid var(--brand-hi); border-radius: var(--r-xs); min-width: 4px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--shadow-ink) 35%, transparent); }
.tl-sel.open { border-width: 0 0 0 3px; border-radius: 0; background: none; box-shadow: none; }
.tl-track.cutting { cursor: crosshair; }
.tile.pb:has(.placeholder)::before { background-position: center 30%; }

/* riproduzione nei riquadri della griglia */
.pb-panel { flex: none; margin: 0 var(--sp-video) var(--sp-video); }
.pb-panel .cal { top: auto; bottom: calc(100% + var(--sp-2)); }
.tile .placeholder { font-size: var(--fs-sm); }
/* nel Playback il nome del dispositivo dice quale riquadro è aperto: occupa tutta la larghezza (i comandi, visibili solo al
   passaggio del mouse, gli stanno sopra) e a restringersi per primo è il tempo, non il nome */
.tile.pb .label { right: var(--sp-2); }
.tile.pb .label .pb-time { flex: 0 100 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: clip;
  margin-left: auto; font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; padding: 0 var(--sp-2); line-height: 1.7; border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--bad) 85%, transparent); color: #fff; }
.tile.pb-active { outline-color: color-mix(in srgb, var(--brand) 55%, transparent); }

/* sicurezza e registro attività */
.nowrap { white-space: nowrap; }
.audit-bar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.audit-bar .search { width: 280px; }
.audit-pills { display: contents; }
/* tendina con ricerca: il pulsante ha l'aspetto di un select, il pannello quello del calendario */
.combo { position: relative; }
.combo-btn { display: flex; align-items: center; gap: var(--sp-2); max-width: 240px; padding: 0 var(--sp-3); background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-md); font: inherit; cursor: pointer; text-align: left; outline: none; transition: border-color .15s, box-shadow .15s; }
.combo-btn:focus-visible, .combo-btn:hover { border-color: var(--brand); }
.combo-btn:focus-visible { box-shadow: 0 0 0 3px var(--brand-soft); }
.combo-btn span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn svg { width: 1.2em; height: 1.2em; flex: none; color: var(--muted); }
.combo .pop { position: absolute; top: calc(100% + var(--sp-2)); left: 0; z-index: 40; width: 280px; max-width: calc(100vw - var(--sp-6)); padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); }
.audit-bar .datepick .cal { left: 0; right: auto; max-width: calc(100vw - var(--sp-6)); }
.combo .pop.end { left: auto; right: 0; }
.combo-list { max-height: 260px; overflow: auto; display: flex; flex-direction: column; }
/* le voci hanno la misura comune dei menu (.ctx button); qui il testo lungo si tronca.
   overflow: hidden azzera l'altezza minima dell'elemento flex: senza flex-shrink: 0 le voci si schiacciano a lista piena */
.combo-list button { flex-shrink: 0; display: block; line-height: var(--h-row); font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-list button:hover, .combo-list button.active { background: var(--surface-3); }
.combo-list button.sel { color: var(--brand-hi); font-weight: 600; }
.combo-list .muted { padding: var(--sp-2); font-size: var(--fs-sm); }
.audit-more { display: flex; justify-content: center; padding: var(--sp-3); }
.sec { display: flex; flex-direction: column; gap: var(--sp-4); }
.flash-bar { display: flex; height: var(--h-bar); margin: var(--sp-3) 0 var(--sp-2); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); }
.flash-bar i { height: 100%; }
.flash-legend { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.flash-legend span { display: inline-flex; align-items: center; gap: var(--sp-2); }
.flash-legend i { width: 10px; height: 10px; border-radius: 2px; }
.fb-other { background: var(--line-strong); }
.fb-flash { background: var(--brand); }
.fb-margin { background: color-mix(in srgb, var(--brand) 35%, transparent); }
.fb-free { background: var(--surface-3); }
.restart-veil { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); }
.restart-veil > div { display: grid; justify-items: center; gap: var(--sp-2); text-align: center; }
.restart-veil small { color: var(--muted); }

/* anteprime in caricamento */
.shot.lazy { display: grid; place-items: center; }
.shot.lazy .ring { width: var(--ic-md); height: var(--ic-md); }
.shot.nothumb { display: grid; place-items: center; color: var(--vid-faint); font-size: var(--fs-xs); text-align: center; }
.shot.nothumb svg { width: var(--ic-md); height: var(--ic-md); display: block; margin: 0 auto var(--sp-1); }

/* autosave: pannello dell'anteprima, stesso aspetto di quello del playback */
.pc-tl { min-width: 0; padding-top: 0; }
.pc-tl .tl-ticks { margin-left: 0; }

.pager { display: flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager span { min-width: 38px; text-align: center; }
.pg-dots { display: none; }
.pb-stamp, #pbMore, .pc-stamp, #pcSheetBtn, .side-lbl, #flOpenBtn, .fl-stamp, #adminTabs i[data-ic], #userGroupBtn, #selClear, #auditSheetBtn { display: none; }

/* ---------- tablet e telefono ---------- */
.side-btn, .pb-top .side-btn { display: none; }
.narrow-only, #clearGrid i[data-ic] { display: none; }
.tile .tools .tmore { display: none; }
.tl-track { touch-action: pan-y; }
.zoomed { touch-action: none; }
/* pannello dispositivi a cassetto, sopra la griglia */
@media (max-width: 900px) {
  .side-btn { display: inline-grid; flex: none; }
  .sidebar, .pc-side { position: fixed; z-index: 45; left: 0; top: calc(var(--top-h) + env(safe-area-inset-top)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    width: min(320px, 86vw); padding-left: max(var(--sp-3), env(safe-area-inset-left)); background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-102%); transition: transform .2s ease-out; }
  .side-open .sidebar, .side-open .pc-side { transform: none; box-shadow: var(--shadow); }
  .side-grip { display: none; }
  .stage-bar { justify-content: flex-start; gap: var(--sp-2); padding: 0 var(--sp-2); }
  .stage-actions { margin-left: auto; }
  #pbSync { font-size: 0; gap: 0; padding: 0 var(--sp-2); }
  .side-hint { display: none; }
  .narrow-only { display: inline; }
}
/* schermi touch: niente passaggio del mouse, comandi sempre visibili e più grandi */
@media (hover: none) {
  .cam-item .more { opacity: 1; }
  .tile.sel .tools, .tile.sel .maxbtn, .tile.sel .snapbtn { opacity: 1; }
  .tile .tools .tmore { display: grid; }
  /* riquadro vuoto: un tocco apre l'elenco dei dispositivi, e lo dice (il «+» sostituisce il logo di sfondo) */
  .tile:not([data-cam])::before { content: "+"; background: none; opacity: 1; filter: none; display: grid; place-content: center; padding-bottom: var(--sp-6);
    color: var(--muted); font-size: var(--fs-2xl); }
  .tile:not([data-cam])::after { content: "Tocca per scegliere un dispositivo"; position: absolute; inset: 0; display: grid; place-content: center; padding: var(--sp-6) var(--sp-2) 0;
    text-align: center; color: var(--muted); font-size: var(--fs-sm); pointer-events: none; }
  /* sul tocco non esistono le scorciatoie da tastiera */
  #setBody .subtabs [data-tab="keys"] { display: none; }
}
@media (pointer: coarse) {
  :root { --h-sm: 34px; --h-md: 40px; --h-row: 40px; --h-xs: 34px; --h-transport: 44px; }
  /* sotto i 16 px Safari ingrandisce la pagina a ogni campo toccato */
  input, select, textarea { font-size: 16px; }
}
