/*
 * --text, --accent, --accent-text e --radius NÃO estão mais aqui --
 * moveram pra tokens.css (item 25), que agora é a única fonte desses 4
 * nomes. A aparência de hoje é preservada pela classe .legacy-shell (no
 * <body> de index/wall/tutorial), que redeclara os valores antigos
 * exatos abaixo. --accent-dim fica aqui mesmo -- não colide, e seu valor
 * rgba já é literal (não referencia var(--accent)).
 *
 * Rebrand Greyes (ver PROJECT.md): paleta abaixo trocada de âmbar/Élis
 * pra verde/Greyes -- --green/--red/--yellow continuam nomes semânticos
 * (sucesso/erro/atenção), só os valores hex mudaram.
 */
:root {
  --bg: #1A2225;
  --bg-alt: #20292D;
  --panel: #232C30;
  --panel2: #2B353B;
  --border: #333B40;
  --muted: #9BA1A7;
  --accent-dim: rgba(53, 208, 126, .14);
  --green: #35D07E;
  --red: #F26D6D;
  --yellow: #F5C453;
  --shadow: 0 6px 20px rgba(0, 0, 0, .28);
}

/* Item pedido pelo cliente: modo claro, escolha do usuário (persistido em
   users.preferences.theme via PUT /api/auth/me/preferences, aplicado no
   boot -- ver applyTheme() em app.js). Derivado da mesma paleta Greyes --
   fundo/superfícies claros, verde de marca recalibrado mais escuro nos
   três semânticos (--green/--red/--yellow) pra manter contraste AA sobre
   branco (--accent/--accent-text vêm do .legacy-shell, ver nota abaixo). */
:root[data-theme="light"] {
  --bg: #F4F6F5;
  --bg-alt: #FFFFFF;
  --panel: #FFFFFF;
  --panel2: #EEF2F0;
  --border: #D8DEDB;
  --muted: #5C6560;
  --accent-dim: rgba(43, 184, 108, .12);
  --green: #1F9D5C;
  --red: #C0392B;
  --yellow: #8A6100;
  --shadow: 0 2px 12px rgba(20, 30, 25, .08);
}
/* --text/--accent-text são redeclarados pelo .legacy-shell (ver tokens.css)
   direto no <body>, o que vence a herança de :root -- precisa de uma regra
   pelo menos tão específica quanto essa, mirando body, pra ganhar no claro. */
html[data-theme="light"] body.legacy-shell {
  --text: #182022;
  --accent-text: #12181B;
}

* { box-sizing: border-box; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
body {
  margin: 0;
  font-family: var(--font-sans, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif);
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
}
button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 500;
  transition: filter .15s ease, transform .05s ease;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost, a.ghost { background: var(--panel2); color: var(--text); }
button.ghost:hover, a.ghost:hover { background: #232f3d; filter: none; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 15px;
}
textarea { font-family: inherit; resize: vertical; width: 100%; }
/* Multi-select nativo (config em lote, rota de notificação) fica muito cru
   por padrão -- só o hint "Ctrl/Cmd+clique" dava conta de indicar o
   comportamento. Opção marcada ganha destaque de cor + linha lateral,
   linhas ganham respiro/hover -- sem trocar o <select multiple> nativo por
   um componente customizado (menor risco, mesmo comportamento de teclado
   e acessibilidade já esperado pelo usuário). */
select[multiple] { padding: 6px; }
select[multiple] option {
  padding: 9px 12px; margin: 2px 0; border-radius: 6px; cursor: pointer;
  border-left: 3px solid transparent;
}
select[multiple] option:checked {
  background: linear-gradient(0deg, var(--accent-dim), var(--accent-dim));
  color: var(--accent); border-left-color: var(--accent); font-weight: 600;
}
select[multiple] option:hover { background: var(--panel2); }

/* QR Code do setup de 2FA -- fundo branco fixo (não segue tema claro/
   escuro) porque QR precisa de contraste alto pra escanear bem, seja
   qual for o tema do app. */
.totp-qr { display: inline-block; background: #fff; padding: 12px; border-radius: 10px; margin: 6px 0; }
.totp-qr img { display: block; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type="checkbox"], input[type="radio"] {
  width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--accent);
  margin: 0;
}
/* Papéis customizados (item 17): lista de sites/categorias -- linhas
   ficavam praticamente coladas umas nas outras (só o `gap` interno da
   label, nada entre linhas), dentro de uma caixa já com scroll aninhado
   no bottom-sheet do modal. Aqui o alvo de toque tem consequência de
   permissão (é o controle de "quais sites esse papel enxerga"), então
   folga própria em vez de só herdar o checkbox global de 15px (que é
   suficiente pros outros toggles isolados do app, mas não pra uma lista
   longa e densa como esta). */
.role-check-row { padding: 3px 0; }
code {
  background: var(--panel2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13.5px; }
.error { color: var(--red); min-height: 18px; font-size: 14.5px; }

/* ---------- login ---------- */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  background: radial-gradient(circle at 25% 20%, #3a464c, var(--bg) 55%);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  padding: 36px 32px;
  border-radius: 16px;
  display: flex; flex-direction: column; gap: 12px;
  width: 320px;
  align-items: center;
  animation: loginCardIn .45s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.login-logo { width: 56px; height: 56px; }
.login-card h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.login-sub { margin: -6px 0 10px; color: var(--muted); font-size: 14px; text-align: center; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 4px; padding: 10px; }
.login-privacy-link {
  width: auto !important; margin-top: 6px !important; padding: 4px !important;
  background: transparent !important; color: var(--muted); font-size: 13px;
  text-decoration: underline; text-underline-offset: 2px;
}
.login-privacy-link:hover { color: var(--text); }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }

/* menu superior: categorias -- clicar numa abre o submenu correspondente
   na barra lateral recolhível abaixo. */
.topcats {
  display: flex; align-items: center; gap: 2px;
  padding: 0 14px; height: 56px; flex-shrink: 0;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.topcats-brand { display: flex; align-items: center; gap: 9px; padding-right: 16px; margin-right: 6px; border-right: 1px solid var(--border); flex-shrink: 0; cursor: pointer; }
.topcats-brand:hover .brand-name { color: var(--accent); }
.topcats-brand img { width: 24px; height: 24px; }
.topcats-brand .brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: .1px; white-space: nowrap; }
/* Wordmark Greyes: "Gr" na cor de texto padrão, "eyes" no verde de marca. */
.brand-accent { color: var(--accent); }
.beta-badge {
  background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent);
  font-size: 10px; font-weight: 700; letter-spacing: .4px; line-height: 1;
  padding: 3px 5px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
}
/* Ícone + nome sempre visíveis (revertido do modo compacto "só ícone,
   nome no hover" -- item pedido pelo cliente). */
.topcat {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; color: var(--muted);
  padding: 11px; border-radius: 8px;
  font-size: 15px; font-weight: 500; white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease;
}
.topcat svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; transition: opacity .15s ease, transform .15s ease; }
.topcat:hover { background: var(--panel2); color: var(--text); }
.topcat:hover svg { transform: translateY(-1px); }
.topcat.active { background: var(--accent-dim); color: var(--accent); }
.topcat.active svg { opacity: 1; }
.topcat.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--accent);
}

.topcat > span, .topcat-util > span {
  display: inline-block;
  white-space: nowrap;
}

.topcats-account {
  display: flex; align-items: center; gap: 2px;
  margin-left: auto; padding-left: 14px; flex-shrink: 0;
}
.topcats-who { color: var(--muted); font-size: 14px; white-space: nowrap; margin-right: 8px; }
.topcats-clock {
  color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums; margin-right: 12px; padding-right: 12px;
  border-right: 1px solid var(--border);
}
.topcat-util {
  position: relative;
  font-size: 14.5px; padding: 9px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap; color: var(--muted); border-radius: 8px;
}
.topcat-util svg { width: 18px; height: 18px; opacity: .8; }
.topcat-util:hover { background: var(--panel2); color: var(--text); }

.app-body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: relative;
  transition: width .16s ease;
}
.sidebar.collapsed { width: 60px; }
.sidebar.no-submenu { display: none; }

#sidebar-resize-handle {
  position: absolute; top: 0; right: -3px; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 5;
}
#sidebar-resize-handle:hover, #sidebar-resize-handle.dragging { background: var(--accent-dim); }
.sidebar.collapsed #sidebar-resize-handle { display: none; }

.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: flex-end;
  width: 100%; height: 34px; flex-shrink: 0; padding: 0 12px;
  background: transparent; color: var(--muted);
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.sidebar-collapse-btn:hover { color: var(--text); }
.sidebar-collapse-btn svg { width: 15px; height: 15px; transition: transform .16s ease; }
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.tabs { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; flex: 1; overflow-y: auto; }
.tabs[hidden] { display: none; }
/* Bug encontrado (2026-08): estas regras eram `.tabs button` (descendente
   -- combina QUALQUER botão dentro de .tabs, não só os itens de navegação
   do topo do menu). O botão de editar dentro de cada linha da árvore
   (.lt-row-edit, vários níveis mais fundo dentro de .tabs) também é um
   <button>, então herdava width:100% -- com flex-shrink:0 ele nunca
   devolvia esse espaço, espremendo pra 0px os vizinhos que encolhem
   (.lt-nvr-name, .dot), fazendo nome e bolinha de status sumirem. `>`
   restringe pros filhos DIRETOS de .tabs (os botões reais de navegação),
   sem afetar nada aninhado mais fundo como a árvore de NVR/câmera. */
.tabs > button {
  display: flex; align-items: center; gap: 10px;
  background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 8px;
  font-size: 15px; font-weight: 500;
  text-align: left; width: 100%;
}
.tabs > button svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.tabs > button:hover { background: var(--panel2); color: var(--text); }
.tabs > button.active { background: var(--accent-dim); color: var(--accent); }
.tabs > button.active svg { opacity: 1; }
.sidebar.collapsed .tabs > button span { display: none; }
.sidebar.collapsed .tabs > button { justify-content: center; padding: 10px; }
.sidebar.collapsed .live-tree { display: none; }
.sidebar.collapsed .live-tree-search-wrap { display: none; }
.live-tree-search-wrap { padding: 8px 10px 0; }
.live-tree-search {
  width: 100%; padding: 7px 10px; font-size: 14px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 7px; color: var(--text);
}
.live-tree-search::placeholder { color: var(--muted); }
.live-tree { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 14.5px; }
.live-tree-header {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 6px 12px 10px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.live-tree-header strong { color: var(--text); font-weight: 700; letter-spacing: .02em; }
.live-tree-header-actions { display: flex; gap: 4px; flex-shrink: 0; width: 100%; }
.live-tree-header-actions button {
  font-size: 12.5px; padding: 5px 8px; display: flex; align-items: center; gap: 4px;
  background: var(--panel2); color: var(--muted); border-radius: 6px; flex: 1; justify-content: center;
}
.live-tree-header-actions button:hover { color: var(--text); background: #3a474d; }
.live-tree-header-actions button.active { color: var(--accent); background: var(--accent-dim); }
.lt-area-name {
  padding: 6px 12px 4px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  cursor: pointer; display: flex; align-items: center; gap: 4px; user-select: none;
}
.lt-area-name:hover { color: var(--text); }
.lt-area-caret { font-size: 11px; flex-shrink: 0; }
.lt-area-body.hidden { display: none; }
/* Indicativo online/total de câmeras ao lado do NVR/área -- item pedido
   pelo cliente. Sem cor = 80%+ online; amarelo = 50-79%; vermelho = <50%. */
.lt-count {
  font-size: 12px; font-weight: 600; color: var(--muted); flex-shrink: 0;
  padding: 1px 6px; border-radius: 8px; background: var(--panel2);
}
.lt-area-name .lt-count { margin-left: 2px; }
.lt-count-good { color: #12181B; background: var(--green); }
.lt-count-warn { color: #1a1a1a; background: var(--yellow); }
.lt-count-bad { color: #fff; background: var(--red); }
.lt-nvr {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
  padding: 7px 12px; cursor: pointer; border-radius: 6px; margin: 0 4px;
  user-select: none;
}
.lt-nvr:hover { background: var(--panel2); }
.lt-nvr:hover .lt-row-edit, .lt-nvr:hover .lt-row-add, .lt-nvr:hover .lt-row-fav { opacity: 1; }
/* Seta de expandir/recolher -- item pedido pelo cliente (mobile): antes
   só um caractere de 10px, alvo de toque pequeno demais; padding negativo
   compensado por margem cresce a área clicável sem empurrar o resto da
   linha. */
.lt-nvr-caret {
  width: 10px; font-size: 11.5px; color: var(--muted); flex-shrink: 0;
  padding: 8px 6px; margin: -8px -6px -8px -8px; cursor: pointer;
}
.lt-nvr-name { overflow: visible; white-space: normal; overflow-wrap: break-word; flex: 1 1 90px; min-width: 90px; }
.lt-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: .75; }
.lt-row-edit, .lt-row-add, .lt-row-fav {
  flex-shrink: 0; opacity: 0; padding: 3px; font-size: 13.5px; line-height: 1;
  background: transparent; color: var(--muted); transition: opacity .1s ease;
}
.lt-row-edit:hover, .lt-row-add:hover, .lt-row-fav:hover { color: var(--accent); }
/* Botão "+" (adicionar sem substituir, equivalente por toque ao arrastar
   -- ver LT_ADD_ICON/onNvrAdd/onCameraAdd em app.js) só faz sentido na
   árvore do Ao Vivo -- na de Gravações (mesmo componente reaproveitado)
   fica sempre escondido. Estrela de favorito (ver LT_STAR_ICON/
   toggleFavorite) é a mesma lógica -- item pedido só pra "visualização ao
   vivo", não faz sentido em Gravações. */
.lt-row-add, .lt-row-fav { display: none; }
#live-tree .lt-row-add, #live-tree .lt-row-fav { display: inline-flex; align-items: center; justify-content: center; }
/* Favorito marcado fica sempre visível (não só no :hover da linha, ao
   contrário de editar/adicionar) -- é o próprio ponto de favoritar: dar
   pra notar de relance quais NVRs/câmeras já foram marcados. */
.lt-row-fav.is-fav { opacity: 1; color: var(--accent); }
.lt-row-fav.is-fav polygon { fill: currentColor; }
.lt-cams { padding-left: 26px; }
.lt-cams.hidden { display: none; }
.lt-cam {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 4px; cursor: pointer; border-radius: 6px; margin: 0 4px;
  font-size: 14px; color: var(--muted);
}
.lt-cam:hover { background: var(--panel2); color: var(--text); }
.lt-cam:hover .lt-row-edit, .lt-cam:hover .lt-row-add, .lt-cam:hover .lt-row-fav { opacity: 1; }
/* Bloco fixo no topo da árvore do Ao Vivo (ver renderFavoritesBlock em
   app.js) -- some inteiro (:empty) quando não há nenhum favorito ainda. */
[data-lt-favorites]:empty { display: none; }
.lt-favorites-block { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.lt-cam-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-cams-loading, .lt-cams-empty { padding: 6px 12px; font-size: 13.5px; }
.lt-hidden-by-filter { display: none !important; }
.badge {
  background: var(--red); color: #fff; border-radius: 10px;
  padding: 0 6px; font-size: 12.5px; margin-left: auto;
}
/* .badge-green já era usada na aba "Reconhecidos" mas nunca tinha sido
   definida -- caía sempre no vermelho padrão de .badge. badge-amber é nova,
   pra aba "Pausados" (redesign da Central de Alarmes via demo). */
.badge-green { background: var(--green); }
.badge-amber { background: var(--yellow); }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.page-title { font-size: 17.5px; font-weight: 600; }

main { flex: 1; overflow-y: auto; padding: 22px 26px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); min-width: 200px; padding: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
  text-align: left; width: 100%; padding: 9px 11px; border-radius: 6px;
  background: transparent; color: var(--text); white-space: nowrap; font-size: 15px;
}
.dropdown-item:hover { background: var(--panel2); }
.dropdown-menu.filter-menu { padding: 10px; gap: 10px; min-width: 220px; }
.dropdown-menu.filter-menu label {
  display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13.5px;
}
.dropdown-menu.filter-menu label.filter-check {
  flex-direction: row; align-items: center; gap: 8px; font-size: 14.5px;
}
.dropdown-menu.filter-menu select { width: 100%; }
.sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
/* Item pedido pelo cliente: "Apenas online" fora do dropdown de Filtro,
   direto na toolbar -- mesma altura/visual dos botões "ghost" ao redor. */
.live-online-toggle {
  display: flex; align-items: center; gap: 6px; font-size: 14.5px; color: var(--text);
  padding: 8px 12px; border-radius: 8px; background: var(--panel2); cursor: pointer;
  user-select: none; white-space: nowrap;
}
.live-online-toggle:hover { background: #3a474d; }
/* Botão de ícone único (ex: "✕ Limpar visualização" -> só "✕") -- mesma
   caixa de um dropdown-item normal, só centralizado e sem texto ao lado. */
.dropdown-item.icon-only { text-align: center; width: auto; min-width: 34px; }

.tabs-inline {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.tab-inline {
  background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px;
  font-size: 14.5px; font-weight: 500;
  border: 1px solid transparent;
}
.tab-inline:hover { background: var(--panel2); color: var(--text); }
.tab-inline.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ---------- live grid ---------- */
/* Item pedido pelo cliente: a quantidade de câmeras na tela deve caber
   sem barra de rolagem -- antes `.cell` tinha aspect-ratio:16/9 fixo, e
   `.grid` crescia com o conteúdo (sem altura própria), então grades
   maiores (3x3, 4x4) em telas mais baixas/janelas menores estufavam pra
   baixo do que cabia e `main` (overflow-y:auto) tinha que rolar pra ver
   as últimas linhas. `#view-live` agora preenche exatamente a altura
   disponível de `main` (flex column), e o grid usa grid-template-rows
   pra dividir essa altura entre as linhas -- célula vira o tamanho que
   cabe (aspect-ratio solto só no #grid, os outros usos de `.cell`/`.grid`
   no site, como playback sincronizado, continuam com aspect-ratio fixo).
*/
#view-live { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.live-body { display: flex; gap: 14px; align-items: flex-start; }
#view-live .live-body { flex: 1; min-height: 0; align-items: stretch; }
.live-body #grid { flex: 1; min-width: 0; }
#grid { height: 100%; }
#grid.grid-1 { grid-template-rows: repeat(1, 1fr); }
#grid.grid-4 { grid-template-rows: repeat(2, 1fr); }
#grid.grid-9 { grid-template-rows: repeat(3, 1fr); }
#grid.grid-16 { grid-template-rows: repeat(4, 1fr); }
#grid .cell { aspect-ratio: auto; min-height: 0; }
.grid { display: grid; gap: 10px; }
.grid-1 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
.grid-9 { grid-template-columns: repeat(3, 1fr); }
.grid-16 { grid-template-columns: repeat(4, 1fr); }
.cell {
  position: relative; aspect-ratio: 16/9;
  background: #000; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer;
  transition: outline-color .15s ease;
}
.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.selected-target { outline: 2px solid var(--yellow); outline-offset: -2px; }
.cell.cell-drag-over { outline: 3px dashed var(--accent); outline-offset: -3px; }
.cell iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.cell .label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  padding: 5px 10px; font-size: 13.5px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
  color: #f0f0f0;
}
.cell .label span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cell .label span:first-child {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell .label span:last-child { flex-shrink: 0; }
.cell-target-btn {
  background: transparent; padding: 0 2px; font-size: 13.5px; opacity: .7; line-height: 1;
}
.cell-target-btn:hover { opacity: 1; }
.cell .empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: #b8b8b8; gap: 4px; text-align: center; padding: 8px; }
.cell .offline-msg { gap: 6px; }
.cell .offline-msg .offline-icon { font-size: 24px; opacity: .5; filter: grayscale(1); }
.cell .offline-msg strong { color: #f0f0f0; font-size: 14.5px; }
.cell .offline-msg button { margin-top: 4px; font-size: 13.5px; padding: 5px 10px; }
.cell-loading-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; background: #000; color: #b8b8b8; font-size: 14px;
  pointer-events: none;
}
.cell-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent);
  animation: cellSpin .8s linear infinite;
}
@keyframes cellSpin { to { transform: rotate(360deg); } }

/* Pop-up de progresso do teste de conexão de NVR (item pedido pelo
   cliente) -- flutua por cima do modal de cadastro/edição (z-index acima
   de .modal, que é 50), não fecha o form em caso de erro pra não perder o
   que já foi digitado. */
.nvr-test-popup {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 300; display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 22px; box-shadow: var(--shadow); font-size: 14.5px; min-width: 260px;
}
.nvr-test-popup .nvr-test-spinner {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent);
  animation: cellSpin .8s linear infinite;
}
.nvr-test-popup .nvr-test-icon { font-size: 20px; flex-shrink: 0; }
.nvr-test-popup.ok .nvr-test-icon { color: var(--green); }
.nvr-test-popup.fail .nvr-test-icon { color: var(--red); }
.nvr-test-popup.fail .nvr-test-step { max-width: 320px; }
.ptz-lock-badge { opacity: .9; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Item pedido pelo cliente: botão de fechar (remover da visualização atual)
   no canto de cada célula -- só aparece quando a grade é uma seleção
   manual/salva (ver closeCellBtnHtml em app.js), no hover pra não poluir
   uma grade cheia. */
.cell-close-btn {
  position: absolute; top: 6px; right: 6px; z-index: 8;
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  background: rgba(0,0,0,.55); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s ease, background .15s ease;
}
.cell:hover .cell-close-btn { opacity: 1; }
.cell-close-btn:hover { background: var(--red); }

/* Item pedido pelo cliente: controle PTZ direto na célula da grade ao
   vivo (canto superior esquerdo), sem precisar abrir o modal da câmera --
   só aparece no hover pra não poluir uma grade 4x4 cheia de células PTZ. */
.cell-ptz-overlay {
  position: absolute; top: 6px; left: 6px; z-index: 6;
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.cell:hover .cell-ptz-overlay { opacity: 1; pointer-events: auto; }
.cell-ptz-pad {
  display: grid; grid-template-columns: repeat(3, 20px); grid-template-rows: repeat(3, 20px); gap: 2px;
  background: rgba(0,0,0,.6); padding: 4px; border-radius: 8px;
}
.cell-ptz-pad button {
  padding: 0; font-size: 11.5px; line-height: 1; background: rgba(255,255,255,.1); color: #fff;
  border-radius: 4px; touch-action: none;
}
.cell-ptz-pad button:hover { background: var(--accent); color: var(--accent-text); }
.cell-ptz-pad .cell-ptz-center { background: transparent !important; cursor: default; opacity: .3; }
.cell-ptz-zoom { display: flex; gap: 2px; width: 100%; }
.cell-ptz-zoom button {
  padding: 3px 0; font-size: 11.5px; flex: 1; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px;
  touch-action: none;
}
.cell-ptz-zoom button:hover { background: var(--accent); color: var(--accent-text); }

.recordings-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 70px 20px; color: var(--muted); text-align: center;
}
.recordings-empty-icon { font-size: 32px; opacity: .5; }
.dot.online { background: var(--green); box-shadow: 0 0 6px rgba(63,185,80,.7); }
.dot.offline { background: var(--muted); }
.dot.alarm { background: var(--red); box-shadow: 0 0 6px rgba(248,81,73,.8); }

@media (max-width: 960px) {
  .live-body { flex-direction: column; }
}

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.data-table th {
  color: var(--muted); font-weight: 600; font-size: 13px;
  text-transform: uppercase; letter-spacing: .4px;
}
.data-table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.data-table th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table th.sortable-th:hover { color: var(--text); }
.data-table th .sort-arrow { color: var(--accent); }
.col-sticky-actions {
  position: sticky; right: 0; background: var(--panel);
  box-shadow: -6px 0 8px -6px rgba(0,0,0,.4);
}
.data-table tbody tr:hover .col-sticky-actions { background: #2f3a3f; }
.pill { padding: 2px 9px; border-radius: 10px; font-size: 13px; font-weight: 500; white-space: nowrap; display: inline-block; }
.pill.new, .pill.active { background: rgba(248, 81, 73, .18); color: #ff8b85; }
.pill.acknowledged, .pill.snoozed { background: rgba(210, 153, 34, .18); color: #f0b445; }
.pill.completed, .pill.acked { background: rgba(63, 185, 80, .18); color: #5fd873; }
.pill.tag { background: rgba(88, 166, 255, .18); color: #79c0ff; }

/* ---------- alarm panel (Painel de Alarmes) ---------- */
.ap-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.ap-search-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ap-search-row #ap-search { flex: 1; min-width: 220px; }
.ap-search-row input[type="date"] { width: auto; }
.ap-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ap-tab {
  background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 14px; font-size: 14.5px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.ap-tab:hover { color: var(--text); filter: none; }
.ap-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ap-controls-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-viewmode { display: flex; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ap-vm { background: transparent; color: var(--muted); border-radius: 0; padding: 6px 12px; font-size: 14px; }
.ap-vm:hover { filter: none; color: var(--text); }
.ap-vm.active { background: var(--accent); color: var(--accent-text); }
.ap-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ap-chip {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 14px;
  color: var(--muted); padding: 4px 12px; font-size: 13.5px;
}
.ap-chip:hover { filter: none; color: var(--text); }
.ap-chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.ap-body { min-height: 100px; }
.ap-cluster-section { margin-bottom: 22px; }
.ap-cluster-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ap-cluster-header strong { font-size: 14.5px; }
.ap-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ap-card {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--muted);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: transform .12s ease; display: flex; flex-direction: column;
}
.ap-card:hover { transform: translateY(-2px); }
.ap-card.ap-status-active { border-left-color: var(--red); }
.ap-card.ap-status-snoozed { border-left-color: var(--yellow); opacity: .85; }
.ap-card.ap-status-acked { border-left-color: var(--green); opacity: .8; }
.ap-card.ap-status-completed { border-left-color: var(--muted); opacity: .7; }
.ap-card.ap-trashed { border-left-color: var(--muted); opacity: .6; }
.ap-card.ap-selected { outline: 2px solid var(--accent); }
.ap-card-thumb { aspect-ratio: 16/9; background: #000; position: relative; }
.ap-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-card-thumb .ap-no-img { display: flex; align-items: center; justify-content: center; height: 100%; color: #888; font-size: 22px; }
.ap-card-check {
  position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(11,16,24,.85); border: 2px solid var(--border); display: flex;
  align-items: center; justify-content: center; font-size: 12.5px;
}
.ap-card.ap-selected .ap-card-check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ap-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.ap-card-top { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.aid { font-family: var(--font-mono, monospace); }
.ap-card-top .ap-time { margin-left: auto; white-space: nowrap; }
/* Redesign da Central de Alarmes (pedido via demo): o título do card virou
   o EVENTO (o que aconteceu), não a usina -- usina/câmera desceram pra
   .ap-card-sub. Hierarquia da demo: evento -> local -> metadados. */
.ap-card-event { font-weight: 600; font-size: 15px; }
.ap-card-sub { font-size: 13.5px; color: var(--muted); }
.ap-card-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ap-card-actions button { flex: 1; padding: 5px 4px; font-size: 13px; min-width: 90px; }
.pill.pinned { background: rgba(79, 140, 247, .18); color: #79b8ff; }
.pill.noisy { background: rgba(248, 81, 73, .12); color: #ff8b85; }

.ap-bulk-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 14px; margin-top: 14px;
}
/* ---------- panels ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 12px; padding: 18px; margin-bottom: 18px;
}
.panel h3 {
  margin: 0 0 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); gap: 8px;
}
.list li:last-child { border-bottom: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 12px; padding: 18px;
}
.card .big { font-size: 26px; font-weight: 700; margin-top: 2px; }

.dash-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.dash-kpi {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px 14px 19px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.dash-kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
}
.dash-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--chrome, var(--accent)); }
.dash-kpi-value { font-size: 25px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.dash-kpi-label { font-size: 14px; color: var(--muted); }
.dash-kpi-sub { font-size: 13px; color: var(--muted); opacity: .8; }
.dash-kpi-alert::before { background: var(--red); }
.dash-kpi-alert .dash-kpi-value { color: var(--red); }

.dash-map-panel { margin-bottom: 20px; }
.dash-map-panel h3 { margin-bottom: 12px; }
/* Bug real da "faixa em cima do mapa expandido" (achado só depois de ver
   o print do cliente): nem .dash-map nem #dash-map-modal tinham
   `position` definido. O Leaflet monta seus painéis internos (tiles,
   marcadores, controles de zoom) com position:absolute e z-index de
   200 a 1000 -- isso só fica CONTIDO dentro do próprio mapa se o
   container do mapa estabelecer seu próprio contexto de empilhamento
   (position relative/absolute + z-index). Sem isso, esses z-index
   "vazam" pro contexto de empilhamento do ANCESTRAL mais próximo que
   tiver `position` -- que nesse caso claramente não continha o
   suficiente, e o mapinha do card do dashboard (z-index 1000 dos
   controles dele) vencia o z-index:50 do .modal e aparecia por cima
   do mapa expandido. `position:relative` + `z-index:0` isola cada
   mapa no seu próprio contexto, sem vazar pra lugar nenhum.  */
.dash-map { height: 230px; border-radius: var(--radius); overflow: hidden; background: var(--panel2); position: relative; z-index: 0; cursor: pointer; }
/* Miniatura clicável de coordenada no cadastro/edição de site -- mesmo
   componente do mapa do Dashboard, só menor e dentro de um modal. */
.site-picker-map { height: 200px; border-radius: var(--radius); overflow: hidden; background: var(--panel2); position: relative; z-index: 0; cursor: crosshair; margin-top: 4px; }
/* Bug encontrado: a versão expandida do mapa ficava presa no limite geral
   de `.modal-body` (width: min(90vw, 900px)) -- em telas largas isso
   deixava uma faixa do mapa cortada/não expandida, bem menor que "tela
   cheia" de verdade. modal-body-map sobrescreve pra ocupar quase a tela
   toda só nesse modal específico. */
.modal-body-map { width: min(96vw, 1400px) !important; height: 90vh; max-height: 90vh; }
/* #modal-content não é flex por padrão (outros modais só crescem com o
   conteúdo) -- vira coluna flex só quando é o modal do mapa, pra
   #dash-map-modal poder usar flex:1 e preencher a altura de verdade. */
.modal-body-map #modal-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.modal-map-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-shrink: 0; }
#dash-map-modal { flex: 1; min-height: 0; border-radius: var(--radius); overflow: hidden; margin-top: 12px; position: relative; z-index: 0; }
/* Popup do Leaflet usa fundo/texto fixos por padrão -- reveste com os
   tokens do app pra acompanhar tema claro/escuro em vez de ficar sempre
   branco (ilegível no tema escuro). */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel); color: var(--text);
}
.leaflet-popup-content { margin: 10px 12px; font-size: 14.5px; line-height: 1.5; }
.leaflet-popup-content .usina-popup button {
  font-size: 13.5px; padding: 5px 10px;
}
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--text); }
/* Bug encontrado: a "faixa" que o cliente via ao expandir o mapa era a
   barra de atribuição do Leaflet (fundo branco fixo, canto inferior) --
   nunca tinha sido revestida com os tokens do app, então ficava sempre
   um retângulo branco chamativo sobre o mapa escuro, parecendo uma parte
   "sem estilo"/"sem expandir" do mapa. Botões de zoom tinham o mesmo
   problema (fundo branco fixo do Leaflet). */
.leaflet-container .leaflet-control-attribution {
  background: var(--panel); color: var(--muted);
}
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-control-attribution a:hover, .leaflet-control-attribution a:focus { color: var(--text); }
.leaflet-bar a {
  background-color: var(--panel); color: var(--text); border-bottom-color: var(--border);
}
.leaflet-bar a:hover { background-color: var(--panel2); }
.usina-marker { background: transparent; border: none; }
/* O ponto visível é só 14x14px (ver _usinaMarkerIcon em app.js) -- alvo de
   toque real bem menor que qualquer alcance confortável de dedo, ainda
   mais quando duas usinas próximas ficam perto uma da outra no mapa.
   ::before invisível estica a área clicável sem aumentar o ponto visual
   (mesma técnica já usada no marcador da timeline de Gravações). Funciona
   porque o Leaflet já deixa `.leaflet-marker-icon` como `position:absolute`
   (vendor/leaflet/leaflet.css) -- o pseudo-elemento vira filho posicionado
   dele e continua disparando o clique no marcador de verdade. */
.usina-marker::before {
  content: ""; position: absolute; top: -10px; bottom: -10px; left: -10px; right: -10px;
}
/* Nome da usina permanente ao lado do marcador (não só no popup ao
   clicar) -- Leaflet tooltip tem fundo branco fixo por padrão, mesmo
   problema do popup, reveste com os tokens do app. */
.leaflet-tooltip.usina-label {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; padding: 3px 8px; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.leaflet-tooltip.usina-label::before { border-top-color: var(--border); }
.marker-cluster { background-clip: padding-box; }
.marker-cluster div {
  background: var(--panel); color: var(--text); border: 2px solid var(--accent);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13.5px;
}

.dash-extra-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.dash-extra-panel { margin-bottom: 0; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.dash-extra-panel:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--chrome, var(--accent)); }
.dash-extra-panel h3 { margin: 0 0 10px; font-size: 15px; border-bottom: 0; padding-bottom: 0; }
.dash-extra-panel .list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.dash-extra-panel .list li { display: flex; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.dash-extra-panel .list li span.muted { font-size: 13.5px; flex-shrink: 0; }
.dash-stat-big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-stat-big .unit { font-size: 15.5px; font-weight: 500; color: var(--muted); margin-left: 4px; }

/* Donut de NVRs/Câmeras online x offline -- sem lib de gráfico no projeto,
   conic-gradient puro CSS (mesmo espírito sem-dependência dos outros
   charts, que são divs com width/height em %). */
.donut-chart-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-chart {
  width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.donut-chart-hole {
  width: 60px; height: 60px; border-radius: 50%; background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.1;
}
.donut-chart-hole strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.donut-chart-hole span { font-size: 10.5px; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.donut-legend-item { display: flex; align-items: center; gap: 7px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-item strong { font-variant-numeric: tabular-nums; }

.dash-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.dash-card { cursor: pointer; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s; }
.dash-card:hover { border-color: var(--accent); }
.dash-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dash-card-top strong { font-size: 17px; }
.dash-card-stats { display: flex; gap: 14px; font-size: 14.5px; color: var(--muted); }
.dash-card-stats .dot { margin-right: 5px; }
.dash-card-alarm { font-size: 14.5px; color: var(--red); }
.dash-card-btn { align-self: flex-start; }

.cam-mgmt-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cam-mgmt-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.cam-mgmt-thumb {
  width: 120px; aspect-ratio: 16/9; background: #000; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; border-radius: 6px; overflow: hidden;
}
.cam-mgmt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-mgmt-thumb button { font-size: 13.5px; padding: 4px 8px; }
.cam-mgmt-thumb .muted { font-size: 12.5px; text-align: center; padding: 0 4px; }
.cam-mgmt-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.cam-mgmt-body .name { font-weight: 600; display: flex; align-items: center; gap: 6px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(6, 9, 14, .78); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-body {
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  border-radius: 14px; padding: 22px; width: min(90vw, 900px);
  max-height: 90vh; position: relative;
  display: flex; flex-direction: column;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: var(--panel);
  font-size: 22px; color: var(--muted); padding: 2px 8px; border-radius: 50%;
  z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.modal-close:hover { color: var(--text); }
#modal-content { overflow-y: auto; padding-right: 4px; }
.modal-body iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 8px; }
.modal-body video { width: 100%; border-radius: 8px; background: #000; }
.modal-body h3 { margin-top: 0; padding-right: 34px; }

/* ---------- formulário de NVR (Novo/Editar) com explicação à esquerda de
   cada campo -- item pedido pelo cliente ---------- */
.nvr-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.nvr-form-field {
  display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 16px; align-items: start;
}
.nff-label { font-weight: 600; font-size: 14px; color: var(--text); }
.nff-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.nff-input-col input, .nff-input-col select { width: 100%; }
.nvr-form button[type="submit"] { align-self: flex-start; margin-top: 4px; }
.nvr-form-actions {
  display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.nvr-form-firmware { font-size: 13px; color: var(--muted); margin: -6px 0 2px; }

/* Visualização do perímetro/linha lido da câmera (item pedido pelo
   cliente) -- SVG com viewBox 0-100 esticado sobre o snapshot via
   preserveAspectRatio="none": como as coordenadas já são fração da
   largura/altura reais (ver _extract_vca_geometry no backend), o
   esticamento não-uniforme mapeia x/y de volta certinho independente da
   proporção real da câmera, sem precisar saber a resolução de antemão. */
.perimeter-view { position: relative; max-width: 640px; border-radius: var(--radius); overflow: hidden; background: var(--void, #000); }
.perimeter-view img { display: block; width: 100%; height: auto; }
.perimeter-view svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.perimeter-shape { fill: rgba(53, 208, 126, .22); stroke: var(--green); stroke-width: .6; vector-effect: non-scaling-stroke; }
polyline.perimeter-shape { fill: none; stroke-width: 1; }
.perimeter-no-img-msg { display: none; padding: 14px; font-size: 13px; color: var(--muted); }
.perimeter-view.no-img img { display: none; }
.perimeter-view.no-img { min-height: 200px; }
.perimeter-view.no-img .perimeter-no-img-msg { display: block; }
@media (max-width: 640px) {
  .nvr-form-field { grid-template-columns: 1fr; gap: 4px; }
}

/* Miniatura do layout atual dentro do modal "Salvar visualização" -- item
   pedido pelo cliente ("mostre o layout do sistema"), só nomes/texto, sem
   vídeo de verdade. */
.save-view-preview {
  display: grid; gap: 4px; margin-top: 6px;
  background: var(--panel2); padding: 6px; border-radius: 8px;
}
.save-view-preview.grid-1 { grid-template-columns: 1fr; }
.save-view-preview.grid-4 { grid-template-columns: repeat(2, 1fr); }
.save-view-preview.grid-9 { grid-template-columns: repeat(3, 1fr); }
.save-view-preview.grid-16 { grid-template-columns: repeat(4, 1fr); }
.save-view-preview-cell {
  aspect-ratio: 16/9; background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 11.5px; padding: 4px; overflow: hidden; color: var(--text);
}

/* ---------- formulário de regra de evento (Automação) ---------- */
.evrule-form { display: flex; flex-direction: column; gap: 22px; }
.evrule-section { display: flex; flex-direction: column; gap: 12px; }
.evrule-section-title {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 6px;
}
.evrule-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.evrule-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.evrule-days { display: flex; gap: 6px; flex-wrap: wrap; }
.evrule-day-label {
  display: flex; align-items: center; gap: 4px; border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 9px; font-size: 14px; cursor: pointer; user-select: none;
}
.evrule-day-label:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.evrule-actions-list { display: flex; flex-direction: column; gap: 10px; }
.evrule-action-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; background: rgba(255,255,255,.02);
}
.evrule-action-card-head { display: flex; align-items: center; gap: 8px; }
.evrule-action-card-head select { flex: 1; }
.evrule-action-fields { display: flex; flex-direction: column; gap: 8px; }
.evrule-action-webhook { width: 100%; padding: 12px 14px; font-size: 16px; min-height: 46px; }
.evrule-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 16px; margin-top: 2px; border-top: 1px solid var(--border);
}
@media (max-width: 640px) {
  .evrule-row, .evrule-row-3 { grid-template-columns: 1fr; }
}

/* ---------- toasts ---------- */
.toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow); border-radius: 10px; padding: 12px 12px 12px 14px;
  font-size: 15px; display: flex; align-items: flex-start; gap: 8px;
  animation: toastIn .18s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--yellow); }
.toast-msg { flex: 1; word-break: break-word; }
.toast-close { background: transparent; color: var(--muted); padding: 0 2px; font-size: 17.5px; line-height: 1; flex-shrink: 0; }
.toast-close:hover { color: var(--text); }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

.ptz-panel { display: flex; gap: 20px; margin-top: 14px; align-items: flex-start; flex-wrap: wrap; }
.ptz-pad {
  display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px);
  gap: 4px; user-select: none;
}
.ptz-pad button { padding: 0; font-size: 18px; touch-action: none; }
.ptz-pad .ptz-center { background: var(--panel2) !important; cursor: default; opacity: .6; }
.ptz-zoom { display: flex; flex-direction: column; gap: 8px; min-width: 140px; }
.ptz-zoom button { touch-action: none; }
.ptz-zoom input[type="range"] { width: 100%; vertical-align: middle; margin-left: 6px; }

/* ---------- recordings / maps ---------- */
.calendar { display: flex; flex-direction: column; gap: 4px; }
.calendar .day {
  display: flex; justify-content: space-between; padding: 8px 12px;
  background: var(--panel2); border-radius: 7px; cursor: pointer;
  transition: outline-color .1s ease;
}
.calendar .day:hover { outline: 1px solid var(--accent); }

.rec-timeline {
  position: relative; height: 40px; background: var(--panel2);
  border-radius: 7px; margin: 10px 0 6px; border: 1px solid var(--border);
  cursor: pointer;
}
.rec-timeline .tl-hour {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border);
}
/* Item 37 do plano de execução ("Playback"), parte 2: períodos com
   gravação disponível no NVR (via ISAPI), como faixa de fundo -- fica
   embaixo dos marcadores de incidente (ordem no DOM: coverage primeiro,
   sem precisar de z-index já que .rec-timeline é o contexto de
   empilhamento). */
.rec-timeline .tl-coverage {
  position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 35%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
}
.rec-timeline .tl-hour-label {
  position: absolute; top: 100%; margin-top: 2px; font-size: 11.5px; color: var(--muted);
  transform: translateX(-50%);
}
.rec-timeline .tl-marker {
  position: absolute; top: 4px; bottom: 4px; width: 6px; margin-left: -3px;
  border-radius: 3px; cursor: pointer; background: var(--red);
  transition: transform .1s ease;
}
/* Alvo de toque real (6px) some pequeno demais pra tocar com o dedo, e o
   único jeito que alargaria (:hover) nunca dispara em touch -- ::before
   invisível estica a área clicável sem mudar o tamanho visual da barra
   (clique no pseudo-elemento ainda dispara no .tl-marker de verdade). */
.rec-timeline .tl-marker::before {
  content: ""; position: absolute; top: -8px; bottom: -8px; left: -9px; right: -9px;
}
.rec-timeline .tl-marker:hover { transform: scaleY(1.15) scaleX(1.6); }

/* Item 38 do plano de execução ("Playback sincronizado") */
.sync-playback-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px;
}
.sync-playback-grid:empty { display: none; }
.sync-playback-grid .sync-cell iframe {
  width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 8px; background: #000; display: block;
}
.sync-playback-grid .sync-cell-label {
  font-size: 13.5px; color: var(--muted); margin: 4px 0; text-align: center;
}

.map-canvas {
  position: relative; width: 100%; max-width: 1100px; background: #000;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  min-height: 300px; background-size: contain; background-repeat: no-repeat;
  background-position: center; box-shadow: var(--shadow);
}
.marker {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  transform: translate(-50%, -50%); cursor: pointer; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14.5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.marker.online { background: var(--green); }
.marker.offline { background: var(--muted); }
.marker.alarm { background: var(--red); animation: markerBlink 1s infinite; }
.marker.child-map { background: var(--accent); border-radius: 8px; }
@keyframes markerBlink { 50% { opacity: .25; box-shadow: 0 0 14px 4px rgba(248,81,73,.7); } }
.map-breadcrumb { margin-bottom: 10px; font-size: 14.5px; color: var(--muted); }
.map-breadcrumb button { background: transparent; color: var(--accent); padding: 2px 4px; font-size: 14.5px; }
.map-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.map-palette button { background: var(--panel2); color: var(--text); }
.rep-mini { font-size: 14.5px; }
.rep-mini div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); }

/* ---------- relatórios: dashboard ---------- */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; line-height: 1.2; }
.stat-sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; }

/* ---------- regras de evento: card de total ---------- */
.alarmrule-total-card {
  display: inline-flex; align-items: center; gap: 26px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 20px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.alarmrule-total-card .art-title {
  display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px;
  color: var(--text); padding-right: 18px; border-right: 1px solid var(--border);
}
.alarmrule-total-card .art-icon { color: var(--accent); font-size: 16px; }
.alarmrule-total-card .art-metrics { display: flex; gap: 28px; }
.alarmrule-total-card .art-metric { text-align: center; min-width: 56px; }
.alarmrule-total-card .art-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.alarmrule-total-card .art-label { font-size: 12px; color: var(--muted); margin-top: 3px; }
.alarmrule-total-card .art-metric.active .art-value { color: var(--green); }
.alarmrule-total-card .art-metric.disabled .art-value { color: var(--yellow); }

.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 56px; align-items: center; gap: 10px; font-size: 14.5px; }
.chart-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.chart-bar-track { background: var(--panel2); border-radius: 6px; height: 16px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 6px; background: var(--accent); transition: width .4s ease; }
.chart-bar-fill.good { background: var(--green); }
.chart-bar-fill.warn { background: var(--yellow); }
.chart-bar-fill.bad { background: var(--red); }
.chart-bar-value { text-align: right; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.chart-empty { color: var(--muted); font-size: 14.5px; }

.chart-trend { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.chart-trend-bar {
  flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 3px;
  position: relative; cursor: pointer; transition: filter .1s ease;
}
.chart-trend-bar:hover { filter: brightness(1.3); }
.chart-trend-bar .chart-trend-tip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border); padding: 4px 8px;
  border-radius: 6px; font-size: 12.5px; white-space: nowrap; margin-bottom: 6px; z-index: 5;
  box-shadow: var(--shadow);
}
.chart-trend-bar:hover .chart-trend-tip { display: block; }
/* Toque não tem :hover -- sem isso, o valor exato de cada barra (o dado
   que a legenda do painel diz ser importante pra reconhecer padrão de
   horário) ficava inacessível em touch. Toggle por toque, ver
   renderHourlyChart em app.js. */
.chart-trend-bar.tip-active .chart-trend-tip { display: block; }

/* Item pedido pelo cliente: espaçamento dos botões de exportação (PDF/
   Excel) embaixo de cada gráfico de relatório -- antes o .toolbar genérico
   só tinha margin-bottom, então colava direto no gráfico acima sem
   respiro, e ainda sobrava espaço indevido embaixo (dentro do padding do
   .panel). */
.panel > .toolbar:not(:first-child) {
  margin-top: 16px;
  margin-bottom: 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.reports-loading {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 14.5px; margin-left: 4px;
}
.reports-loading .cell-spinner { width: 14px; height: 14px; border-width: 2px; position: static; }
.reports-loading.hidden { display: none; }

@media (max-width: 860px) {
  .app { height: auto; min-height: 100vh; }
  .topcats { overflow-x: auto; height: auto; padding: 6px 10px; position: sticky; top: 0; z-index: 41; }
  .topcats-brand { display: none; }
  .topcat { flex-direction: column; gap: 3px; font-size: 11.5px; padding: 7px 9px; }
  .topcat svg { width: 16px; height: 16px; }
  /* Sem hover em touch -- volta o rótulo pra baixo do ícone, sempre visível
     (reverte o tooltip flutuante do desktop). */
  .topcat > span, .topcat-util > span {
    display: inline; max-width: none; overflow: visible; opacity: 1;
    font-size: 11.5px; color: inherit;
  }
  .topcats-account { gap: 10px; }
  .topcat-util { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 8px; }
  .topcats-who, .topcats-clock { display: none; }
  .app-body { flex-direction: column; }
  .sidebar { width: 100% !important; flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--border); position: sticky; top: 48px; z-index: 40; }
  .sidebar-collapse-btn { display: none; }
  .tabs[hidden] { display: none !important; }
  .tabs { flex-direction: row; overflow-x: auto; padding: 6px; -webkit-overflow-scrolling: touch; }
  .tabs > button { flex-direction: column; gap: 4px; font-size: 12px; padding: 8px 10px; white-space: nowrap; }
  .tabs > button svg { width: 16px; height: 16px; }
  /* Bug encontrado (2026-08): a regra `.tabs { flex-direction: row }` acima
     foi escrita pensando nos grupos com botões simples de navegação (Sites/
     NVRs/Câmeras etc, viram uma tira horizontal rolável no celular) -- mas
     `.tabs[data-group="live"]` e `[data-group="midia"]` não têm botões,
     têm a busca + a árvore de NVR/câmera inteira. Virando uma linha
     horizontal, a árvore ficava espremida numa largura mínima, e como
     `.lt-nvr-name`/`.dot` encolhem (flex:1 ou sem flex-shrink:0, ao
     contrário do ícone/editar que são flex-shrink:0), o nome e a bolinha de
     status sumiam por falta de espaço -- só o ícone (tamanho fixo)
     continuava aparecendo. Restaura o fluxo vertical normal só pra esses
     dois grupos. */
  .tabs[data-group="live"], .tabs[data-group="midia"] {
    flex-direction: column; overflow-x: visible; flex: 1 1 auto; min-width: 0;
  }
  #sidebar-resize-handle { display: none; }
  .badge { margin-left: 0; }
  .main-wrap { height: auto; }
  main { overflow-y: visible; padding: 16px 14px; }
  .cols { grid-template-columns: 1fr; }
  .grid-9, .grid-16 { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .table-scroll table { min-width: 640px; }
  .toast-container { left: 12px; right: 12px; top: 12px; max-width: none; }
  .modal-body { width: min(94vw, 900px); padding: 16px; }
  .inline-form input:not([type="checkbox"]):not([type="radio"]),
  .inline-form select { flex: 1 1 180px; }
  /* Bug encontrado (auditoria mobile, achado medido/reproduzido): a regra
     acima foi escrita pra formulário EM LINHA, onde `flex-basis:180px` no
     eixo principal horizontal vira largura mínima. Só que ~14 modais do
     app (NVR, Site, Câmera, Usuário, Papel, Destinatário/Rota de
     notificação, Minha conta, Config em lote, etc -- ver classe
     `.inline-form-col`) sobrescrevem pra `flex-direction:column`, e no
     eixo vertical o MESMO `flex-basis:180px` vira ALTURA mínima -- cada
     campo direto do form vira uma caixa de ~186px de altura (medido),
     formulário inteiro passando de 1500px. `.inline-form-col` marca esses
     forms explicitamente (a mesma classe já é aplicada onde o inline
     style column existe) pra sair de baixo da regra genérica e ficar do
     jeito que sempre devia: altura de campo normal, largura total. */
  .inline-form-col input:not([type="checkbox"]):not([type="radio"]),
  .inline-form-col select { flex: 0 1 auto; width: 100%; }
  /* .lt-row-edit/.lt-row-add (editar e "adicionar sem substituir" direto
     na árvore) só apareciam no :hover da linha -- em touch isso nunca
     acontece de um jeito que dê pra tocar o botão, então ficavam
     inacessíveis no celular. */
  .lt-row-edit, .lt-row-add, .lt-row-fav { opacity: .55; padding: 6px; }
  .lt-nvr, .lt-cam { padding-top: 9px; padding-bottom: 9px; }
  /* Bug encontrado: `.dropdown-menu` sempre abria ancorado no botão
     (`left:0` a partir dele) com largura mínima de 200-220px -- num
     toolbar quebrado em várias linhas (celular), o botão que abre o menu
     podia estar em QUALQUER lugar horizontal depois de quebrar linha, e
     não dá pra saber de qual lado vai sobrar espaço só em CSS (ancorar
     pela direita só troca o lado que estoura). Solução robusta sem JS:
     no celular o menu vira uma folha fixa na parte de baixo da tela,
     largura da viewport menos margem -- nunca estoura pra fora,
     independente de onde o botão que abriu está. */
  .dropdown-menu {
    position: fixed; top: auto; bottom: 12px; left: 12px; right: 12px;
    width: auto; min-width: 0; max-width: none; max-height: 70vh; overflow-y: auto;
  }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 12px 10px; }
  .topbar { padding: 10px 12px; }
  .page-title { font-size: 16.5px; }
  .sidebar-brand .brand-name { font-size: 15.5px; }
  .tabs > button { font-size: 11.5px; padding: 7px 8px; }

  /* buttons/inputs: bigger touch targets */
  button { padding: 10px 14px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select { min-height: 40px; }

  .toolbar { gap: 6px; }
  .toolbar > .sep { display: none; }
  .toolbar select, .toolbar input:not([type="checkbox"]):not([type="radio"]) { flex: 1 1 140px; }
  .toolbar button { flex: 1 1 auto; }

  /* live view: priority mobile target */
  #live-tv { display: none; }
  .grid-1, .grid-4, .grid-9, .grid-16 { grid-template-columns: 1fr; }
  .cell { aspect-ratio: 16/10; }
  .cell .label { font-size: 14px; padding: 7px 10px; }
  .cell-target-btn { padding: 4px 6px; font-size: 16.5px; }
  .live-body { gap: 10px; }
  /* "Sem barra de rolagem" (item pedido pelo cliente) é uma otimização de
     tela grande -- várias câmeras pequenas espremidas numa tela de
     celular sem poder rolar ficariam ilegíveis. Mobile já tinha seu
     próprio tratamento dedicado (item 147, lista vertical rolável de
     16/10) -- reverte pra esse comportamento aqui em vez de herdar as
     regras de #grid/#view-live da versão desktop. */
  #view-live { height: auto; display: block; }
  #view-live .live-body { flex: none; }
  #grid { height: auto; }
  #grid.grid-1, #grid.grid-4, #grid.grid-9, #grid.grid-16 { grid-template-rows: none; }
  #grid .cell { aspect-ratio: 16/10; min-height: auto; }

  .ptz-pad { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); }
  .ptz-zoom { min-width: 0; flex: 1 1 100%; }

  .modal { align-items: flex-end; }
  .modal-body {
    width: 100%; max-width: none; max-height: 92vh;
    border-radius: 16px 16px 0 0; padding: 16px 14px;
  }

  .login-card { width: min(320px, 88vw); padding: 28px 20px; }

  .cards, .cam-mgmt-grid, .ap-cards-grid { grid-template-columns: 1fr; }

  /* Gravações: grade do playback sincronizado (item 38, até 4 câmeras) era
     fixa em 2 colunas -- em 375px isso dava vídeos de ~140px de largura,
     ilegível justamente no cenário de conferir evidência com detalhe. */
  .sync-playback-grid { grid-template-columns: 1fr; }
  /* Item "Linha do tempo de eventos": os botões desse li têm rótulo por
     extenso ("▶ Ver imagens"/"🔒 Exportar", diferente das outras listas do
     app que usam só ícone) -- sem quebra, os dois juntos podem não caber ao
     lado do horário/tipo do evento numa tela estreita. Escopado só a esse
     `<ul>` pra não alterar o layout de uma linha só das outras listas. */
  #rec-timeline-list li { flex-wrap: wrap; }

  /* Dashboard: os dois <select> do cabeçalho "Alarmes por hora do dia" já
     quebram linha (flex-wrap no próprio index.html) -- aqui só dá um
     tamanho mínimo razoável pra cada um em vez de ficarem do tamanho
     mínimo do conteúdo, mesmo tratamento já dado aos selects da toolbar
     (linha acima). */
  #dash-chart-site, #dash-chart-days { flex: 1 1 140px; }
  /* Botão "Ver alarmes" do popup do mapa tinha padding fixo menor que o
     `button` genérico do mobile (e vencia por especificidade) -- ficava
     pequeno demais pra tocar dentro de um popup do Leaflet já compacto. */
  .leaflet-popup-content .usina-popup button { padding: 8px 12px; }
  /* Botões de zoom do Leaflet (só aparecem no modal em tela cheia, ver
     _openUsinaMapModal) -- o próprio Leaflet já sobe pra 30px em touch,
     mas ainda fica abaixo do alvo confortável de dedo; sem risco pro
     resto do app porque Leaflet só existe no Dashboard. */
  .leaflet-touch .leaflet-bar a { width: 38px; height: 38px; line-height: 38px; }

  /* Cornetas: cada linha de #output-list tem um input de renomear (160px
     fixos) + um segundo grupo (duração + rótulo + Testar + Histórico +
     Excluir) sem quebra -- somado, precisa de bem mais que os ~330px
     úteis de um celular. `.lt-wrap` na própria `<li>` já separa os dois
     `<span>` em linhas próprias; o segundo `<span>` (já é `display:flex`
     via style inline) também recebe `flex-wrap` pra aguentar qualquer
     combinação de tamanho de botão sem estourar, mesmo que sobre pra 3
     linhas em telas bem estreitas. Mesmo padrão de #rec-timeline-list li
     (Gravações): escopado só a essa lista. */
  #output-list li { flex-wrap: wrap; }
  #output-list li > span { flex-wrap: wrap; }

  /* Central de Alarmes: .ap-card-actions/.ap-tab/.ap-vm/.ap-chip têm
     seletor de classe, então vencem por especificidade o `button {
     padding:10px 14px }` genérico do item 147 -- ficavam com alvo de
     toque de ~24-32px em qualquer largura de tela, sem herdar o reforço
     mobile. Escopado só ao mobile pra não engordar os botões compactos
     no desktop (onde o layout foi desenhado pra caber mais coisa por
     linha). */
  .ap-card-actions button { padding: 9px 6px; min-height: 40px; }
  .ap-tab { padding: 10px 14px; }
  .ap-vm { padding: 9px 14px; }
  .ap-chip { padding: 7px 14px; }
  /* Regras de Alarme: mesmo padrão de #rec-timeline-list/#output-list --
     nome + 2 pills + 2 linhas de metadados de um lado, 2 botões do outro,
     sem quebra nenhuma antes disso. */
  #alarmrule-list li { flex-wrap: wrap; }
  /* Chips de dia da semana (Vigência, item 42) ficavam em ~24-26px de
     altura -- o usuário normalmente marca vários em sequência, então é a
     repetição de toques pequenos que mais incomoda. */
  .evrule-day-label { padding: 9px 12px; }
  /* Relatórios: lista "Veículos" (placa + câmera à esquerda, data/hora
     por extenso à direita) tinha o mesmo padrão sem `flex-wrap` de
     #rec-timeline-list/#output-list -- nome de câmera longo + data
     completa podia quebrar de forma desalinhada dentro do item. */
  #rep-vehicles li { flex-wrap: wrap; }
  /* Câmeras: botão "Carregar" da coluna Imagem tinha 23px de altura
     medidos (seletor de 2 classes vence o `button` genérico) -- é o
     botão que o texto de ajuda da própria tela pede pra tocar linha a
     linha, com ~250 câmeras no parque. */
  .cam-mgmt-thumb button { padding: 8px 10px; min-height: 36px; }
  /* Abas "Todas/Online/Offline" (mesmo motivo de especificidade). */
  .tab-inline { padding: 9px 14px; }
  /* Sites: lista sem flex-wrap -- nome de site longo empurrava os botões
     Editar/Excluir pra uma coluna estreita de 72px, um empilhado sobre o
     outro, encostados na borda direita. */
  #site-list li { flex-wrap: wrap; }
  /* Papéis customizados: checkbox de 15px (padrão global) fica pequeno
     demais pra tocar numa lista longa e densa de sites/categorias. Só o
     alvo de toque sobe no mobile; o espaçamento entre linhas (.role-check-
     row acima) já vale em qualquer tela. Escopado só a essa lista, não ao
     checkbox global do app. */
  .role-check-row input[type="checkbox"] { width: 20px; height: 20px; }
  .role-check-row { padding: 7px 0; }
}
