/*
 * Redesign — PRÉVIA (01/12/2026, ramo redesign/central-alarmes).
 *
 * Etapa 1 (cores, fonte, cantos) para o sistema inteiro + o desenho novo da
 * Central de Alarmes. Carregado por último (depois do mobile.css), então só
 * sobrescreve; apagar este arquivo e o <link> volta tudo ao visual de antes.
 *
 * Direção: grafite neutro, branco como cor de ação, verde só na marca e no
 * "online", gravidade em quadradinho de cor + texto, IBM Plex Sans, cantos de
 * 6/8 px, borda de 1 px no lugar de sombra, ícones de linha no lugar de emoji.
 */

/* ---------- tokens (escuro) ---------- */
html body.legacy-shell {
  --bg: #0F1215;
  --bg-alt: #0F1215;
  --panel: #161A1F;
  --panel2: #1D2228;
  --border: #272D35;
  --border-strong: #333A43;
  --muted: #A3ABB5;
  --text: #E8EBEF;
  --text-3: #6F7884;
  --accent: #2FA866;          /* ação principal = verde da marca, fosco (lote 7); texto 5,6:1 */
  --accent-text: #06210F;
  --accent-dim: rgba(47, 168, 102, .14);
  --c-live: #F0524F;          /* ícones por significado (lote 7) */
  --c-rec: #5B9BF0;
  --c-ok: #3DBE7A;
  --c-fav: #E2A93B;
  --c-off: #E58A3A;
  --c-ia: #A78BFA;
  --c-dash: #4CB5C4;          /* seções e conceitos (lote 9): mesma luminosidade, saturação moderada */
  --c-alarm: #EC7A5E;
  --c-equip: #3FB39B;
  --c-report: #CDA35E;
  --c-admin: #93A4B8;
  --c-sair: #D98A8F;
  --brand: #3DBE7A;           /* só marca e "online" */
  --green: #3DBE7A;
  --red: #F0524F;
  --yellow: #E2C044;
  --blue: #7AA2D6;
  --sev-crit: #F0524F;
  --sev-high: #F28C38;
  --sev-med: #E2C044;
  --sev-low: #8B95A1;
  --thumb-bg: #0A0C0E;
  --shadow: none;
  --hover: #1D2228;
  --hover-strong: #262C33;
  --hover-sticky: #1A1F24;
  --radius: 8px;
  --radius-ctl: 6px;
  font-size: var(--fs-14);
  -webkit-font-smoothing: antialiased;
}
/* ---------- tokens (claro) ---------- */
html[data-theme="light"] body.legacy-shell {
  --bg: #F6F7F9;
  --bg-alt: #F6F7F9;
  --panel: #FFFFFF;
  --panel2: #F0F2F5;
  --border: #E1E4E9;
  --border-strong: #D0D5DC;
  --muted: #4E5763;
  --text: #14181D;
  --text-3: #7A838F;
  --accent: #1A7F4B;          /* verde fechado; texto branco 5,0:1 */
  --accent-text: #FFFFFF;
  --accent-dim: rgba(26, 127, 75, .10);
  --c-live: #D93A37;
  --c-rec: #2F6FD0;
  --c-ok: #1F8A50;
  --c-fav: #B7791F;
  --c-off: #C2611C;
  --c-ia: #7C3AED;
  --c-dash: #1B7D8B;
  --c-alarm: #C04A2E;
  --c-equip: #177F6B;
  --c-report: #8F661D;
  --c-admin: #52667B;
  --c-sair: #A9464E;
  --brand: #1F9D5C;
  --green: #1F9D5C;
  --red: #D93A37;
  --yellow: #9A7A0C;
  --blue: #2F5E9E;
  --sev-crit: #E0443F;
  --sev-high: #E07A26;
  --sev-med: #D4AC1E;
  --sev-low: #8B95A1;
  --thumb-bg: #1B1F24;
  --hover: #ECEFF2;
  --hover-strong: #E3E7EB;
  --hover-sticky: #F0F2F5;
}

/* ---------- base ---------- */
body.legacy-shell { font-size: var(--fs-14); line-height: 1.45; }
.ic { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; max-width: none; }
button {
  border-radius: var(--radius-ctl); font-size: var(--fs-14); font-weight: 500; padding: 7px 12px;
  line-height: 18px; transition: background .12s ease, border-color .12s ease, color .12s ease;
}
/* Hover genérico: só escurece um pouco (lote 3). Antes trocava o FUNDO de todo botão pelo
   --accent, e botão transparente sem :hover próprio (ex.: .ap-tab) ficava branco ao passar o mouse. */
button:hover { filter: none; opacity: .88; }
button:active { transform: none; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button.ghost, a.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border-strong);
}
button.ghost:hover, a.ghost:hover { background: var(--panel2); }
button:has(> .ic), summary:has(> .ic) { display: inline-flex; align-items: center; gap: 6px; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-ctl);
  font-size: var(--fs-14); padding: 6px 10px; color: var(--text);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---------- moldura: barra de cima, lateral, título ---------- */
.topcats { height: 52px; background: var(--bg); padding: 0 12px; }
.topcats-brand .brand-name { font-weight: 600; font-size: var(--fs-16); letter-spacing: 0; }
html body .brand-accent, html[data-theme="light"] body .topcats .brand-accent { color: var(--brand); }
.brand-beta, html[data-theme="light"] body .topcats .brand-beta {
  border-color: var(--border-strong); color: var(--text-3); font-size: var(--fs-11); font-weight: 600;
  letter-spacing: .08em; padding: 0 6px; border-radius: 4px;
}
.topcat { font-size: var(--fs-14); padding: 7px 10px; border-radius: var(--radius-ctl); color: var(--muted); }
.topcat svg { width: 16px; height: 16px; opacity: .85; }
.topcat:hover { background: var(--panel2); }
.topcat:hover svg { transform: none; }
.topcat.active, html[data-theme="light"] body .topcat.active { background: var(--panel2); color: var(--text); }
.topcat.active::after, html[data-theme="light"] body .topcat.active::after { display: none; }
.topcat-util { border-radius: var(--radius-ctl); }
.sidebar { background: var(--bg); width: 232px; }
.tabs > button { font-size: var(--fs-14); padding: 7px 10px; border-radius: var(--radius-ctl); }
.tabs > button svg { width: 16px; height: 16px; }
.tabs > button.active { background: var(--panel2); color: var(--text); }
.topbar { background: var(--bg); padding: 14px 24px 12px; }
.page-title { font-size: var(--fs-20); font-weight: 600; letter-spacing: -.005em; }
main { padding: 16px 24px 32px; }

/* Botão do Eyes: neutro, sem bolha verde. */
.iaf-botao {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 12px; width: 48px; height: 48px; box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}
.iaf-botao:hover { transform: none; background: var(--hover-strong); }
.iaf-botao .eyes-estrela { width: 22px; height: 22px; stroke-width: 1.75; }

/* ---------- Central de Alarmes: barra de filtros ---------- */
#view-alarm-history .ap-night-strip {
  display: flex; align-items: flex-start; gap: 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted);
  font-size: var(--fs-13); padding: 9px 12px; margin-bottom: 14px;
}
#view-alarm-history .ap-night-strip.hidden { display: none; }
#view-alarm-history .ap-night-strip .ic { color: var(--sev-med); margin-top: 1px; }
#view-alarm-history .ap-night-strip b { color: var(--text); font-weight: 600; }

#view-alarm-history .ap-filtros-toggle-bar { gap: 8px; margin-bottom: 12px; flex-wrap: nowrap; }
#view-alarm-history .ap-filtros-resumo { flex: 1 1 auto; min-width: 0; }
#view-alarm-history .apf-toggle-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
#view-alarm-history .ap-hist-auto-info { white-space: normal; max-width: 172px; line-height: 1.3; font-size: var(--fs-12); }
@media (max-width: 860px) {
  #view-alarm-history .ap-filtros-toggle-bar { flex-wrap: wrap; }
  #view-alarm-history .apf-toggle-actions { display: contents; }
  #view-alarm-history .ap-hist-auto-info { max-width: none; }
}
#view-alarm-history .ap-filtros-toggle-bar button { font-size: var(--fs-14); padding: 6px 10px; }
#ap-hist-toggle-filtros { font-weight: 500 !important; }
.rd-count {
  font-family: var(--font-mono); font-size: var(--fs-12); line-height: 16px; padding: 0 5px;
  border-radius: 4px; background: var(--panel2); color: var(--text);
}
.ap-filtros-resumo { color: var(--text-3); font-size: var(--fs-13); gap: 6px; }
.ap-filtro-ativo {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 4px; font-size: var(--fs-13); padding: 2px 2px 2px 8px; gap: 2px;
}
.ap-filtro-x {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  margin: 0; padding: 0; border-radius: 3px; color: var(--text-3); opacity: 1;
}
.ap-filtro-x:hover { color: var(--text); background: var(--hover-strong); }
.ap-filtro-x .ic { width: 13px; height: 13px; }
.ap-hist-auto-info { color: var(--text-3); font-size: var(--fs-12); }

#view-alarm-history .ap-exibicao-bar {
  gap: 8px 14px; padding: 10px 0; margin-bottom: 16px; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
#view-alarm-history .apf-label-inline { display: none; }
#view-alarm-history .ap-page-size { font-size: var(--fs-13); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
#view-alarm-history .ap-page-size select { padding: 5px 28px 5px 8px; }
#view-alarm-history .ap-ordem-inverter { border-color: transparent; color: var(--muted); }
#view-alarm-history .ap-ordem-inverter:hover { color: var(--text); }
/* Cards | Lista como controle segmentado */
#view-alarm-history .ap-view-toggle {
  gap: 0; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-ctl);
}
#view-alarm-history .ap-view-toggle button {
  border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 4px;
}
#view-alarm-history .ap-view-toggle button.active { background: var(--panel2); color: var(--text); }
#view-alarm-history .ap-hist-legend summary {
  border: 1px solid transparent; border-radius: var(--radius-ctl); padding: 5px 8px;
  color: var(--muted); font-size: var(--fs-13); background: transparent; list-style: none; cursor: pointer;
}
#view-alarm-history .ap-hist-legend summary::-webkit-details-marker { display: none; }
#view-alarm-history .ap-hist-legend summary:hover { color: var(--text); background: var(--panel2); }

/* Título de grupo ("Fixados", "Por usina") */
#view-alarm-history .ap-hist-group-header {
  display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 0 0 8px; border: 0; background: transparent; margin: 4px 0 10px;
}
#view-alarm-history .ap-hist-group-header .ic { width: 14px; height: 14px; }
#view-alarm-history .ap-hist-fixados { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 18px; }

/* ---------- gravidade: quadradinho de cor + texto ---------- */
.crit-badge {
  background: transparent !important; color: var(--text) !important; padding: 0; gap: 6px;
  font-size: var(--fs-13); font-weight: 500; border-radius: 0; line-height: 18px;
}
.crit-badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--sev, var(--sev-low)); }
.crit-badge b { font-family: var(--font-mono); font-weight: 500; color: var(--muted); font-size: var(--fs-12); }
.crit-critical { --sev: var(--sev-crit); }
.crit-high { --sev: var(--sev-high); }
.crit-medium { --sev: var(--sev-med); }
.crit-low { --sev: var(--sev-low); }

/* ---------- card ---------- */
#view-alarm-history .ap-cards-grid { grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }
#view-alarm-history .ap-card {
  background: var(--panel); border: 1px solid var(--border); border-left-width: 1px;
  border-left-color: var(--border); border-radius: var(--radius); box-shadow: none; transition: border-color .12s ease;
}
#view-alarm-history .ap-card:hover { transform: none; border-color: var(--border-strong); }
#view-alarm-history .ap-card.ap-status-acked,
#view-alarm-history .ap-card.ap-status-snoozed { opacity: 1; }
#view-alarm-history .ap-card.ap-status-acked .ap-card-thumb img { filter: grayscale(.6) brightness(.8); }
#view-alarm-history .ap-card-thumb { background: var(--thumb-bg); border-bottom: 1px solid var(--border); }
#view-alarm-history .ap-no-img { color: var(--text-3); }
#view-alarm-history .ap-no-img .ic { width: 24px; height: 24px; }
#view-alarm-history .ap-card-2fotos {
  display: inline-flex; align-items: center; gap: 3px; background: rgba(10, 12, 14, .72);
  color: #E8EBEF; border-radius: 4px; font-family: var(--font-mono); font-size: var(--fs-12); padding: 1px 5px;
}
#view-alarm-history .ap-card-2fotos .ic { width: 12px; height: 12px; }
#view-alarm-history .ap-card.ap-card-infra { background: var(--panel); }
#view-alarm-history .ap-card-infra .ap-card-thumb-infra { background: var(--panel2); color: var(--text-3); }
#view-alarm-history .ap-card-thumb-infra .ic { width: 28px; height: 28px; stroke-width: 1.5; }
#view-alarm-history .ap-card-body { padding: 10px 12px 10px; gap: 3px; }
#view-alarm-history .ap-card-top { font-size: var(--fs-12); }
#view-alarm-history .ap-card-top .ap-time { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-3); }
#view-alarm-history .ap-card-event {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px;
  font-size: var(--fs-14); font-weight: 600; margin-top: 4px; letter-spacing: 0;
}
.ap-ev-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px;
  background: var(--ap-ev-color, var(--text-3)); flex-shrink: 0;
}
#view-alarm-history .ap-card-sub { font-size: var(--fs-13); color: var(--muted); display: flex; align-items: center; gap: 5px; }
#view-alarm-history .ap-card-sub .ic { width: 14px; height: 14px; color: var(--text-3); }
#view-alarm-history .ap-card-usina { color: var(--text); opacity: 1; display: block; }
#view-alarm-history .ap-card-area { color: var(--text-3); opacity: 1; }
#view-alarm-history .ap-card-meta { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-3); margin-top: 4px; }
#view-alarm-history .ap-chip {
  display: inline-flex; align-items: center; gap: 3px; background: transparent; border: 1px solid var(--border);
  border-radius: 4px; color: var(--muted); padding: 0 5px; line-height: 18px; font-size: var(--fs-12);
}
#view-alarm-history .ap-chip .ic { width: 12px; height: 12px; vertical-align: 0; }
#view-alarm-history .ap-chip-watch { color: var(--sev-med); background: transparent; }
#view-alarm-history .ap-chip-pin { background: transparent; color: var(--text); }
#view-alarm-history .ap-chip-noisy { color: var(--sev-high); }
#view-alarm-history .ap-chip-disparos { font-family: var(--font-mono); }
#view-alarm-history .ap-chip-disparos:hover { border-color: var(--border-strong); color: var(--text); }

/* ações do card: só ícones, quadrados de 30 px */
#view-alarm-history .ap-card-actions {
  display: flex; gap: 2px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border);
}
#view-alarm-history .ap-card-actions button,
#view-alarm-history .ap-hist-row-actions button {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; width: 30px; height: 30px; min-width: 0; padding: 0;
  background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: var(--radius-ctl);
}
#view-alarm-history .ap-card-actions button:hover,
#view-alarm-history .ap-hist-row-actions button:hover { background: var(--panel2); color: var(--text); }
#view-alarm-history .ap-card-actions .ap-ack-btn,
#view-alarm-history .ap-hist-row-actions .ap-ack-btn { border-color: var(--border-strong); color: var(--text); }
#view-alarm-history .ap-card-actions [data-hist-pin] { margin-left: auto; }
#view-alarm-history .ap-pin-on { color: var(--text) !important; background: var(--panel2) !important; }

/* ---------- lista: tabela densa ---------- */
#view-alarm-history .ap-hist-list {
  gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--panel);
}
#view-alarm-history .ap-hist-row {
  background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  padding: 7px 12px; gap: 12px; min-height: 52px;
}
#view-alarm-history .ap-hist-row:last-child { border-bottom: 0; }
#view-alarm-history .ap-hist-row:hover { background: var(--hover-sticky); border-color: var(--border); }
#view-alarm-history .ap-hist-row.ap-status-acked,
#view-alarm-history .ap-hist-row.ap-status-snoozed { opacity: 1; }
#view-alarm-history .ap-hist-row.ap-status-acked .ap-hist-row-event { color: var(--muted); }
#view-alarm-history .ap-hist-row.ap-hist-row-infra { background: transparent; }
#view-alarm-history .ap-hist-row-thumb { width: 64px; height: 36px; border-radius: 4px; background: var(--thumb-bg); }
#view-alarm-history .ap-hist-row-infra .ap-card-thumb-infra { background: var(--panel2); color: var(--text-3); }
#view-alarm-history .ap-hist-row-thumb .ic { width: 18px; height: 18px; }
#view-alarm-history .ap-hist-row-main { gap: 4px 12px; flex-wrap: nowrap; }
#view-alarm-history .ap-hist-row-main > .dot {
  width: 6px; height: 6px; min-width: 6px; box-shadow: none !important; order: 1;
}
#view-alarm-history .ap-hist-row-main > .crit-badge { order: 0; min-width: 92px; }
#view-alarm-history .ap-hist-row-event { order: 2; font-size: var(--fs-14); font-weight: 600; }
#view-alarm-history .ap-hist-row-sub {
  order: 3; display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-13); color: var(--muted); min-width: 0;
}
#view-alarm-history .ap-hist-row-sub .ic { width: 14px; height: 14px; color: var(--text-3); }
#view-alarm-history .ap-hist-row-sub .aid { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-3); }
#view-alarm-history .ap-hist-row-main > .pill,
#view-alarm-history .ap-hist-row-main > .ap-chip { order: 4; }
#view-alarm-history .ap-hist-row .pill {
  display: inline-flex; align-items: center; background: transparent; border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 4px; color: var(--muted);
}
#view-alarm-history .ap-hist-row .pill .ic { width: 12px; height: 12px; vertical-align: 0; }
#view-alarm-history .ap-hist-row .ap-watch-pill { color: var(--sev-med); }
#view-alarm-history .ap-hist-row-time {
  order: 9; font-family: var(--font-mono); font-size: var(--fs-12); color: var(--muted); text-align: right;
  display: flex; flex-direction: column; line-height: 1.3;
}
#view-alarm-history .ap-hist-row-time-abs { color: var(--text-3); opacity: 1; font-size: var(--fs-12); }
#view-alarm-history .ap-hist-row-time-abs::before { content: none; }
#view-alarm-history .ap-hist-row-actions { gap: 2px; }

/* ---------- celular ---------- */
@media (max-width: 860px) {
  main { padding: 12px 14px 96px; }
  .topbar { padding: 12px 14px 10px; }
  #view-alarm-history .ap-night-strip { font-size: var(--fs-13); }
  #view-alarm-history .apf-toggle-actions button,
  #view-alarm-history .ap-filtros-toggle-bar button { min-height: 40px; font-size: var(--fs-14); justify-content: center; }
  #view-alarm-history .ap-exibicao-bar { padding: 10px 0; border-top: 0; }
  #view-alarm-history .ap-exibicao-bar .ap-page-size { flex-direction: column; align-items: stretch; }
  #view-alarm-history .ap-exibicao-bar .ap-page-size select { min-height: 40px; }
  #view-alarm-history .ap-exibicao-bar .ap-view-toggle button { min-height: 36px; }
  #view-alarm-history .ap-ordem-inverter { border-color: var(--border-strong); min-height: 40px; align-self: end; }
  .ap-filtro-ativo { min-height: 34px; }
  .ap-filtro-x { min-width: 32px; min-height: 32px; }
  #view-alarm-history .ap-card-actions { display: flex; }
  #view-alarm-history .ap-card-actions button,
  #view-alarm-history .ap-card-actions .ap-card-pin-btn { width: 44px; height: 40px; min-height: 40px; }
  #view-alarm-history .ap-hist-row-main { flex-wrap: wrap; }
  #view-alarm-history .ap-hist-row-actions button { width: auto; height: 40px; }
  .iaf-botao { width: 44px; height: 44px; }
}

/* ---------- ajustes da 2ª passada ---------- */
/* tema claro: as regras antigas do claro miram `.topcats .x` com :root[data-theme] */
html[data-theme="light"] body.legacy-shell .topcats .topcat.active { color: var(--text); background: var(--panel2); }
html[data-theme="light"] body.legacy-shell .topcats .topcat.active::after { display: none; }
html[data-theme="light"] body.legacy-shell .topcats .brand-beta { color: var(--text-3); border-color: var(--border-strong); }
html[data-theme="light"] body.legacy-shell .topcats .brand-accent { color: var(--brand); }
/* linha "Exibição" numa linha só: legenda antes de Cards|Lista */
#view-alarm-history .ap-exibicao-bar { gap: 8px 12px; }
#view-alarm-history .ap-hist-legend { order: 1; margin-left: auto; }
#view-alarm-history .ap-exibicao-bar .ap-view-toggle { order: 2; margin-left: 0; }
#view-alarm-history .ap-exibicao-bar select { max-width: 170px; }
/* lista: coluna de ações com largura fixa (alinha mesmo sem Gravação/Ao vivo) */
#view-alarm-history .ap-hist-row-actions { width: 128px; justify-content: flex-end; }
#view-alarm-history .ap-hist-row-main > .crit-badge { min-width: 84px; }
/* barra de baixo do celular com ícones de linha */
.bottom-nav button > .ic, .bottom-nav .bn-ic .ic { width: 22px; height: 22px; }
.bottom-nav .bn-ic { display: inline-flex; font-size: 0; }
@media (max-width: 860px) {
  .bottom-nav { background: var(--bg); box-shadow: none; }
  .bottom-nav button.active { color: var(--text); }
  #view-alarm-history .ap-hist-legend { margin-left: 0; }
  #view-alarm-history .ap-exibicao-bar select { max-width: none; }
  #view-alarm-history .ap-hist-row-actions { width: 100%; justify-content: flex-start; }
  #view-alarm-history .ap-juntar-camera { flex-direction: row !important; align-items: center !important; gap: 8px; min-height: 40px; align-self: end; }
  .ap-filtro-ativo { min-height: 34px; padding: 0 2px 0 10px; }
}
#view-alarm-history .ap-exibicao-bar { gap: 8px 10px; }
#view-alarm-history .ap-exibicao-bar select { max-width: 150px; }
@media (max-width: 860px) {
  #view-alarm-history .ap-hist-legend { order: 3; grid-column: 1 / -1; }
  #view-alarm-history .ap-exibicao-bar .ap-view-toggle { order: 0; }
  #view-alarm-history .ap-exibicao-bar select { max-width: none; }
}

/* ---------- lote 2 (01/12/2026): ícones de linha no lugar dos emojis em todas as telas ---------- */
/* .ie = ícone que substituiu um emoji no meio do texto: acompanha o tamanho da letra. */
.ic.ie { width: 1.15em; height: 1.15em; min-width: 14px; min-height: 14px; vertical-align: -.2em; }
.ic.rd-ok { color: var(--green); }
.ic.rd-warn { color: var(--sev-high); }
.ic.rd-med { color: var(--sev-med); }
.ic.rd-bad { color: var(--red); }
.m-mais-ico .ic { width: 20px; height: 20px; }
.dash-quick-icon .ic { width: 22px; height: 22px; stroke-width: 1.5; }
.dash-quick-icon { color: var(--muted); line-height: 0; }
.arvore-toggle::before { content: "Esconder lista de NVRs e câmeras"; }
.arvore-recolhida .arvore-toggle::before { content: "NVRs e câmeras"; }
a:has(> .ic), .tab-inline:has(> .ic) { display: inline-flex; align-items: center; gap: 6px; }
/* texto sobre --accent (verde desde o lote 7) */
.evrule-modo button.active, .iaa-auto { color: var(--accent-text); }
/* ação principal do detalhe do alarme: botão principal, não verde */
.aed-confirm-btn { background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); box-shadow: none; }
.aed-confirm-btn:hover { background: color-mix(in srgb, var(--accent) 88%, var(--bg)); }

/* ---------- lote 3 (01/12/2026): consistência de componentes ---------- */
/* Botões quadrados da janela do Eyes — causa: o cabeçalho da caixa flutuante (`.iaf-cab-acoes`)
   usava o botão genérico `.ghost` (36x36, canto 7 px = quadrado), enquanto toda outra janela usa
   `.modal-ctls` (círculos de 30 px com sombra) e o toast um "×" solto. Agora os controles de
   janela seguem uma regra só: ícone em quadrado de 28 px, canto 6 px, sem fundo e sem sombra. */
.modal-ctls > button, .modal-ctls .modal-close, .modal-close, .iaf-cab-acoes button, .toast-close {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  min-width: 28px; min-height: 28px; padding: 0; border-radius: var(--radius-ctl);
  background: transparent; border: 1px solid transparent; color: var(--muted); box-shadow: none;
  font-size: var(--fs-16); line-height: 1;
}
.modal-ctls > button:hover, .modal-close:hover, .iaf-cab-acoes button:hover, .toast-close:hover {
  background: var(--panel2); color: var(--text); opacity: 1;
}
.modal-ctls > button .ic, .modal-close .ic, .iaf-cab-acoes button .ic { width: 16px; height: 16px; }
.toast-close { width: 24px; height: 24px; min-width: 24px; min-height: 24px; }
.toast-close .ic { width: 14px; height: 14px; }
.modal-ctls { gap: 4px; }
@media (max-width: 860px) {
  .modal-ctls > button, .modal-ctls .modal-close { width: 40px; height: 40px; min-width: 40px; min-height: 40px; }
  .iaf-cab-acoes button { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .toast-close { width: 32px; height: 32px; }
}
/* Janelas: borda de 1 px, canto 8 px, sombra discreta só para destacar do fundo escurecido. */
.modal-body { border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.iaf-painel { border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.toast { border-radius: var(--radius); }

/* Abas: os 4 desenhos (abas do detalhe, abas internas, período e categoria) com uma aparência só. */
.tab-inline, .ap-tab, .ap-hist-range-tab, .ap-hist-category-tab {
  background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-ctl);
  padding: 6px 12px; font-size: var(--fs-13); font-weight: 500; line-height: 18px; box-shadow: none;
}
.ap-tab, .tab-inline { border-color: transparent; }
.tab-inline:hover, .ap-tab:hover, .ap-hist-range-tab:hover, .ap-hist-category-tab:hover {
  background: var(--panel2); color: var(--text); border-color: var(--border-strong); opacity: 1;
}
.tab-inline.active, .ap-tab.active, .ap-hist-range-tab.active, .ap-hist-category-tab.active {
  background: var(--panel2); color: var(--text); border-color: var(--border-strong); font-weight: 600;
}
.ap-tabs { gap: 6px; padding-bottom: 8px; }
.tabs-inline { gap: 6px; }

/* Dashboard: KPIs sem barra colorida à esquerda e sem "pular" ao passar o mouse. */
.dash-kpi::before, .dash-kpi-alert::before { display: none; }
.dash-kpi { border-radius: var(--radius); }
.dash-kpi:hover, .dash-extra-panel:hover { transform: none; box-shadow: none; border-color: var(--border-strong); }
.dash-kpi-value { font-size: var(--fs-28); font-weight: 600; }
.dash-kpi-label { font-size: var(--fs-13); }
.dash-kpi-sub { font-size: var(--fs-12); }
.dash-quick-btn { border-radius: var(--radius); }
.dash-quick-btn:hover { opacity: 1; }

/* Escala de letra (12/13/14/16/20/28): título da página 20, título de janela/painel 16. */
.page-title { font-size: var(--fs-20); }
.modal-body h3, .modal-body > h2 { font-size: var(--fs-16); font-weight: 600; }

/* Foco visível também em campos de texto e itens clicáveis que não são botão. */
textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Seletor de 2 opções das Regras (Lista | Cards) no mesmo desenho do Cards | Lista da Central. */
.evrule-modo button { background: transparent; color: var(--muted); border: 1px solid var(--border-strong); }
.evrule-modo button.active { background: var(--panel2); color: var(--text); border-color: var(--border-strong); }
.evrule-modo button:first-child { border-radius: var(--radius-ctl) 0 0 var(--radius-ctl); }
.evrule-modo button:last-child { border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; }
/* Eyes: chips com o canto dos outros controles; caixa de ação proposta com borda neutra. */
.iaa-chip { border-radius: var(--radius-ctl); }
.iaa-acao { border-color: var(--border-strong); border-radius: var(--radius); background: var(--panel); }
.iaa-acao-botoes button { border-radius: var(--radius-ctl); }
.iaa-balao { border-radius: var(--radius) var(--radius) 2px var(--radius); }

/* ---------- lote 4 (01/12/2026): janela "Nova versão do Greyes" (NOVIDADES em app.js) ---------- */
.novidades { max-width: 560px; }
.novidades h3 { font-size: var(--fs-20); margin: 0 0 4px; }
.novidades > .muted { margin: 0 0 14px; font-size: var(--fs-13); }
.novidades-lista { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.novidades-lista li { display: flex; gap: 12px; align-items: flex-start; }
.novidades-ic {
  flex: 0 0 32px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-ctl); color: var(--text); background: var(--panel2);
}
.novidades-ic .ic { width: 16px; height: 16px; }
.novidades-lista b { font-size: var(--fs-14); font-weight: 600; }
.novidades-lista p { margin: 2px 0 0; font-size: var(--fs-13); color: var(--muted); line-height: 1.45; }
.novidades .evrule-modal-footer { justify-content: flex-end; }
#novidades-ok { min-width: 120px; }
.modal-body:has(.novidades) { width: min(92vw, 600px); }

/* ---------- lote 5b (01/12/2026): leitura — pedido do dono "nada de letra pequena" ----------
   Menu do topo 16 (14 abaixo de 1400 px, onde não cabe), sub-abas do celular 14/500,
   barra de baixo 13/500; 12 fica só para metadado (hora, ID, rótulo de tabela). */
html body.legacy-shell .topcat { font-size: var(--fs-16); font-weight: 500; }
@media (max-width: 1399px) { html body.legacy-shell .topcat { font-size: var(--fs-14); } }
@media (max-width: 860px) {
  html body.legacy-shell .m-subabas > button { font-size: var(--fs-14); font-weight: 500; }
  html body.legacy-shell .bottom-nav button { font-size: var(--fs-13); font-weight: 500; }
  html body.legacy-shell .crit-badge, html body.legacy-shell .alarme-alvo { font-size: var(--fs-13); }
}
html body.legacy-shell .tabs > button { font-size: var(--fs-14); font-weight: 500; }
.dash-kpi-sub { font-size: var(--fs-13); }
#view-alarm-history .ap-card-top { font-size: var(--fs-13); }
.iaa-todos, .ap-hist-auto-info, #view-alarm-history .ap-hist-auto-info { font-size: var(--fs-13); }
.art-label { font-size: var(--fs-13); }

/* ---------- lote 7 (01/12/2026): cor e ajustes — pedido do dono ("o sistema ficou sem cor") ----------
   Verde da marca (fosco) no botão principal, aba ativa, seleção e foco; alarmes crítico/alto com
   fundo tingido; KPIs e ícones com cor por significado. O resto continua grafite. */
button:not(.ghost):not([class*="ptz"]):not(.tab-inline):not(.ap-tab):hover { opacity: 1; filter: brightness(1.08); }
/* aba ativa = sublinhado verde */
html body.legacy-shell .topcat.active::after,
html[data-theme="light"] body.legacy-shell .topcats .topcat.active::after {
  display: block; content: ""; position: absolute; left: 12px; right: 12px; bottom: -9px; height: 2px;
  border-radius: 2px; background: var(--accent);
}
html body.legacy-shell .topcat.active svg { opacity: 1; }
.tab-inline.active, .ap-tab.active, .ap-hist-range-tab.active, .ap-hist-category-tab.active,
.evrule-modo button.active, .ap-view-toggle button.active {
  box-shadow: inset 0 -2px 0 var(--accent);
}
.evrule-modo button.active { background: var(--panel2); color: var(--text); }
html body.legacy-shell .tabs > button.active { box-shadow: inset 2px 0 0 var(--accent); }

@media (max-width: 860px) {
  html body.legacy-shell .m-subabas > button.active { background: var(--accent-dim); color: var(--text); border-color: var(--accent); }
  html body.legacy-shell .bottom-nav button.active { color: var(--accent); }
}
/* seleção */
.ap-card.ap-selected, #view-alarm-history .ap-card.ap-selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.cell.selected, .cell.cell-target { outline-color: var(--accent); }

/* alarmes: borda esquerda com a cor do evento (volta, item 9) e fundo tingido nos críticos/altos */
#view-alarm-history .ap-card,
#view-alarm-history .ap-hist-row { border-left: 3px solid var(--ap-ev-color, var(--border-strong)); }
#view-alarm-history .ap-card .ap-ev-dot, #view-alarm-history .ap-hist-row-main > .dot { display: none; }
#view-alarm-history .ap-card.ap-sev-critical,
#view-alarm-history .ap-hist-row.ap-sev-critical {
  background: color-mix(in srgb, var(--sev-crit) 10%, var(--panel));
  border-top-color: color-mix(in srgb, var(--sev-crit) 35%, var(--border));
  border-right-color: color-mix(in srgb, var(--sev-crit) 35%, var(--border));
  border-bottom-color: color-mix(in srgb, var(--sev-crit) 35%, var(--border));
}
#view-alarm-history .ap-card.ap-sev-high,
#view-alarm-history .ap-hist-row.ap-sev-high {
  background: color-mix(in srgb, var(--sev-high) 8%, var(--panel));
  border-top-color: color-mix(in srgb, var(--sev-high) 30%, var(--border));
  border-right-color: color-mix(in srgb, var(--sev-high) 30%, var(--border));
  border-bottom-color: color-mix(in srgb, var(--sev-high) 30%, var(--border));
}
#view-alarm-history .ap-hist-row.ap-sev-critical:hover { background: color-mix(in srgb, var(--sev-crit) 14%, var(--panel)); }
#view-alarm-history .ap-hist-row.ap-sev-high:hover { background: color-mix(in srgb, var(--sev-high) 12%, var(--panel)); }
#view-alarm-history .ap-hist-list { gap: 4px; border: 0; background: transparent; overflow: visible; }
#view-alarm-history .ap-hist-row { border: 1px solid var(--border); border-left: 3px solid var(--ap-ev-color, var(--border-strong)); border-radius: var(--radius-ctl); background: var(--panel); }
#view-alarm-history .ap-hist-row:last-child { border-bottom: 1px solid var(--border); }

/* card: ações sempre no rodapé e sempre na mesma posição (item 10) */
#view-alarm-history .ap-cards-grid { align-items: stretch; }
#view-alarm-history .ap-card { display: flex; flex-direction: column; }
#view-alarm-history .ap-card-body { flex: 1 1 auto; display: flex; flex-direction: column; }
#view-alarm-history .ap-card-actions { margin-top: auto; }
#view-alarm-history .ap-card-meta { margin-bottom: 8px; }
.ap-acao-vazia { display: inline-block; flex: 0 0 30px; width: 30px; height: 30px; }
@media (max-width: 860px) { .ap-acao-vazia { flex-basis: 44px; width: 44px; height: 40px; } }

/* KPIs do Dashboard com cor quando tem significado */
.dash-kpi-ok .dash-kpi-value { color: var(--green); }
.dash-kpi-alert .dash-kpi-value { color: var(--red); }

/* MAPA CONCEITO -> ÍCONE -> COR (lote 9, 01/12/2026). Um ícone por conceito no sistema todo;
   a cor vem do ícone, então o mesmo conceito tem a mesma cor em qualquer tela (menu, abas,
   cards, celular, Modo TV, guia). Tabela completa no PROJECT.md ("Ícones: conceito, ícone e cor").
   Ícone novo: escolha o do conceito na tabela; conceito novo: entra na tabela E aqui. */
.ic:is(:has(> use[href="#i-dashboard"]), :has(> use[href="#i-help"]), :has(> use[href="#i-headphones"]), :has(> use[href="#i-send"])) { color: var(--c-dash); }
.ic:is(:has(> use[href="#i-video"]), :has(> use[href="#i-film"]), :has(> use[href="#i-monitor"]), :has(> use[href="#i-move"])) { color: var(--c-rec); }
.ic:is(:has(> use[href="#i-live"]), :has(> use[href="#i-record"]), :has(> use[href="#i-flame"])) { color: var(--c-live); }
.ic:is(:has(> use[href="#i-siren"]), :has(> use[href="#i-bell"]), :has(> use[href="#i-zap"]), :has(> use[href="#i-home"])) { color: var(--c-alarm); }
.ic:is(:has(> use[href="#i-network"]), :has(> use[href="#i-cctv"]), :has(> use[href="#i-server"]), :has(> use[href="#i-factory"]), :has(> use[href="#i-map"]), :has(> use[href="#i-megaphone"])) { color: var(--c-equip); }
.ic:is(:has(> use[href="#i-chart"]), :has(> use[href="#i-moon"]), :has(> use[href="#i-sun"])) { color: var(--c-report); }
.ic:is(:has(> use[href="#i-gear"]), :has(> use[href="#i-user"]), :has(> use[href="#i-key"]), :has(> use[href="#i-tag"]), :has(> use[href="#i-clipboard"]), :has(> use[href="#i-plug"]), :has(> use[href="#i-building"]), :has(> use[href="#i-layers"]), :has(> use[href="#i-lock"])) { color: var(--c-admin); }
.ic:has(> use[href="#i-check"]) { color: var(--c-ok); }
.ic:is(:has(> use[href="#i-pin"]), :has(> use[href="#i-star"])) { color: var(--c-fav); }
.ic:is(:has(> use[href="#i-camera-off"]), :has(> use[href="#i-activity"])) { color: var(--c-off); }
.ic:has(> use[href="#i-sparkles"]) { color: var(--c-ia); }
.ic:has(> use[href="#i-alert"]) { color: var(--sev-med); }
.ic:has(> use[href="#i-logout"]) { color: var(--c-sair); }
.lt-row-fav.is-fav, .lt-row-fav:hover { color: var(--c-fav); }
/* menu de cima, menu lateral, barra de baixo e topo: o texto continua neutro, só o ícone tem cor;
   inativo um pouco mais apagado, ativo com a cor cheia */
html body.legacy-shell :is(.topcat, .tabs > button, .topcat-util, .bottom-nav button, .m-subabas > button) > .ic { opacity: .82; }
html body.legacy-shell :is(.topcat.active, .tabs > button.active, .topcat-util:hover, .topcat:hover, .tabs > button:hover, .bottom-nav button.active, .m-subabas > button.active) > .ic { opacity: 1; }
#view-alarm-history .ap-card-actions button:hover .ic,
#view-alarm-history .ap-hist-row-actions button:hover .ic { filter: brightness(1.15); }
/* botão principal (verde cheio): o ícone dentro dele acompanha o texto; navegação e abas ficam fora */
button:not(.ghost):not(.tab-inline):not(.ap-tab):not(.topcat):not(.m-mais-item):not(.ap-hist-category-tab):not(.dropdown-item):not([role="menuitem"]):not([data-view]):not([data-bn-view]):not(.rep-card):not([class*="ptz"]) > .ic { color: inherit; }

/* IA (Eyes): brilho violeta em vez do balão de conversa (item 4) */
.eyes-estrela, .ia-ic { color: var(--c-ia); }
html body.legacy-shell .iaa-ia { color: var(--c-ia); }
.eyes-marca .eyes-estrela { color: var(--c-ia); }
.iaf-botao .eyes-estrela { color: var(--c-ia); }
html body.legacy-shell .tabs > button .ia-ic { color: var(--c-ia) !important; }
.novidades-ic:has(use[href="#i-sparkles"]) { color: var(--c-ia); }

/* sino: contador pequeno no canto, sem cobrir o ícone (item 7) */
#notif-bell-btn { position: relative; overflow: visible; }
#notif-bell-badge {
  /* acima do desenho do sino (o ícone começa 10px abaixo do topo do botão) */
  top: -6px; right: -5px; left: auto; width: max-content; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  font-family: var(--font-mono); font-size: var(--fs-11); font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; border: 2px solid var(--bg); pointer-events: none;
}
#notif-bell-badge.hidden { display: none; }
.bottom-nav .bn-ic { position: relative; }
.bottom-nav-badge {
  position: absolute; top: -9px; left: 19px; width: max-content; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  font-family: var(--font-mono); font-size: var(--fs-11); line-height: 1; border: 2px solid var(--bg);
}
.bottom-nav-badge.hidden { display: none; }

/* PTZ: as 8 direções com o mesmo botão (item 6) */
.ptz-pad button, .cell-ptz-pad button, .cell-ptz-zoom button {
  display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 1;
}
.ptz-pad button { width: 100%; height: 100%; border-radius: var(--radius-ctl); }
.ptz-pad button .ic { width: 22px; height: 22px; }
.cell-ptz-pad button .ic, .cell-ptz-zoom button .ic { width: 16px; height: 16px; }
.cell-ptz-zoom button { min-height: 27px; }
.ptz-pad .ic, .cell-ptz-pad .ic, .cell-ptz-zoom .ic { color: inherit !important; }
/* teclado PTZ da janela da câmera: controle secundário (neutro), não 9 botões verdes */
html body.legacy-shell .ptz-pad button, html body.legacy-shell .ptz-zoom button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border-strong); filter: none;
}
html body.legacy-shell .ptz-pad button:hover, html body.legacy-shell .ptz-zoom button:hover { background: var(--hover-strong); }
html body.legacy-shell .ptz-pad button:active, html body.legacy-shell .ptz-zoom button:active { background: var(--accent-dim); border-color: var(--accent); }
html body.legacy-shell .ptz-pad .ptz-center[data-ptz-home] { background: var(--panel2) !important; opacity: 1; }

/* Gravação: trecho selecionado ao lado do 1× (item 5) */
.rec-tc-trecho {
  flex-shrink: 0; white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-13);
  font-variant-numeric: tabular-nums; color: var(--text); padding: 3px 8px;
  border: 1px solid var(--accent); border-radius: var(--radius-ctl); background: var(--accent-dim);
}
.rec-tc-trecho .rotulo { font-family: var(--font-sans); color: var(--muted); }
.rec-tc-trecho.hidden { display: none; }

/* texto dos botões centralizado (item 8): todo botão flex centraliza ícone + texto; menus,
   listas e as abas laterais continuam alinhados à esquerda */
:where(button:not(.tabs > button, .dropdown-item, [role="menuitem"], .m-mais-item, .ms-btn, [data-iaa-exemplo])) {
  align-items: center; justify-content: center;
}
button:has(> .ic):not(.tabs > button):not(.dropdown-item):not([role="menuitem"]):not(.m-mais-item):not(.ms-btn) {
  justify-content: center; text-align: center;
}

/* legenda de cores compacta: uma entrada por cor (item 11) */
.ap-hist-legend-panel { width: min(560px, 92vw); }
.ap-hist-legend-body {
  display: grid !important; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px;
  max-height: 50vh; overflow-y: auto;
}
.ap-hist-legend-item {
  display: flex !important; align-items: flex-start; gap: 8px; font-size: var(--fs-13); color: var(--text); line-height: 1.35;
}
.ap-hist-legend-item > span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ap-hist-legend-dot { width: 10px; height: 10px; border-radius: 3px; margin-top: 3px; }

/* ---------- Login: links discretos (lote 10) ----------
   "Esqueci a senha" e "Privacidade" eram botões .ghost (com moldura) empilhados, com o espaço do
   #login-error vazio entre eles e o Entrar. Agora são links de texto, sem moldura, numa linha só. */
.login-card .login-links {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 2px 18px; width: 100%; margin-top: -2px;
}
.login-card button.login-privacy-link {
  width: auto !important; min-height: 0; height: auto; margin: 0 !important; padding: 6px 4px !important;
  border: 0 !important; box-shadow: none !important; background: transparent !important; filter: none;
  color: var(--muted); font-size: var(--fs-13); font-weight: 400; line-height: 1.4;
  text-decoration: none; border-radius: 4px; opacity: 1;
}
.login-card button.login-privacy-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; opacity: 1; }
.login-card #login-error:empty, .login-card #forcar-erro:empty { display: none; }

/* ---------- Janela padrão (lote 10B) ----------
   `rdJanelaPreparar` (app.js) marca título, rodapé e largura de toda janela aberta por
   openModal. Título e rodapé grudam no topo/fundo do #modal-content, que é quem rola. */
.modal:not(.is-expanded) .modal-body.rd-janela.rd-larg-440 { width: min(92vw, 440px); }
.modal:not(.is-expanded) .modal-body.rd-janela.rd-larg-640 { width: min(92vw, 640px); }
.modal:not(.is-expanded) .modal-body.rd-janela.rd-larg-960 { width: min(94vw, 960px); }
.modal-body.rd-janela:focus { outline: none; }
#modal-content > .rd-modal-titulo {
  position: sticky; top: 0; z-index: 3; background: var(--panel);
  margin: 0 0 14px; padding-top: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
#modal-content .rd-modal-rodape-ativo {
  position: sticky; bottom: 0; z-index: 3; background: var(--panel);
  display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 16px 0 0; padding: 12px 0 2px; border-top: 1px solid var(--border);
}
#modal-content .rd-rodape-gerado > button { width: auto; margin: 0; }
@media (max-width: 600px) {
  .modal:has(> .modal-body.rd-janela) { align-items: stretch; }
  .modal-body.rd-janela {
    width: 100% !important; height: 100vh; max-height: 100vh; border-radius: 0; border: 0;
  }
  @supports (height: 100dvh) { .modal-body.rd-janela { height: 100dvh; max-height: 100dvh; } }
  html.kb-open .modal-body.rd-janela { height: var(--vvh, 100dvh); max-height: var(--vvh, 100dvh); }
  .modal-body.rd-janela #modal-content { flex: 1; min-height: 0; }
  /* Conteúdo largo (tabela, linha de campos) rola dentro da janela, não alarga a página. */
  .modal-body.rd-janela { min-width: 0; box-sizing: border-box; }
  /* Botão do Eyes (z 65) ficava por cima do rodapé da janela em tela cheia. */
  body:has(#modal:not(.hidden) > .modal-body.rd-janela) .iaf-botao { display: none; }
  #modal-content .rd-modal-rodape-ativo > button { flex: 1 1 auto; }
}

/* ---------- Confirmação própria (lote 10C): rdConfirm() no lugar do confirm() ---------- */
:root { --perigo-bg: #C2302D; }
html[data-theme="light"] { --perigo-bg: #B42B28; }
.rd-confirm-fundo {
  position: fixed; inset: 0; z-index: 250; background: rgba(6, 9, 14, .6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.rd-confirm {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35); width: min(100%, 420px); padding: 20px;
}
.rd-confirm h3 { margin: 0 0 8px; font-size: var(--fs-16); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.rd-confirm h3 .ic { color: var(--red); width: 18px; height: 18px; flex: 0 0 auto; }
.rd-confirm-texto { color: var(--muted); font-size: var(--fs-14); line-height: 1.5; white-space: pre-line; margin: 0 0 18px; }
.rd-confirm .rd-confirm-campo { display: block; width: 100%; box-sizing: border-box; margin: 0 0 16px; font-size: var(--fs-14); }
.rd-confirm-acoes { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.rd-confirm-acoes button { min-height: 32px; padding: 0 14px; font-weight: 500; }
button.rd-perigo, button.rd-perigo:hover { background: var(--perigo-bg); border: 1px solid var(--perigo-bg); color: #fff; }
@media (max-width: 600px) {
  .rd-confirm-fundo { align-items: flex-end; padding: 0; }
  .rd-confirm { width: 100%; border-radius: 12px 12px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .rd-confirm-acoes button { flex: 1 1 0; min-height: 44px; }
}

/* ---------- Aviso neutro com Desfazer (lote 10D): rdToastDesfazer() ---------- */
.toast.rd-toast-neutro {
  position: relative; overflow: hidden; align-items: center;
  border-left: 1px solid var(--border-strong); padding: 10px 10px 12px 14px;
}
.rd-toast-neutro .toast-body { flex-direction: row; align-items: center; gap: 10px; }
.rd-toast-neutro .rd-toast-ic { width: 16px; height: 16px; flex: 0 0 auto; }
.rd-toast-neutro .toast-msg { flex: 1 1 auto; }
.rd-toast-neutro .rd-toast-desfazer {
  align-self: center; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px; font-size: var(--fs-13); font-weight: 600;
}
.rd-toast-neutro .rd-toast-desfazer .ic { width: 14px; height: 14px; }
.rd-toast-tempo {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--border-strong);
  transform-origin: left center; animation-name: rdToastTempo; animation-timing-function: linear; animation-fill-mode: forwards;
}
.rd-toast-pausado .rd-toast-tempo { display: none; }
@keyframes rdToastTempo { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 860px) { .rd-toast-neutro .rd-toast-desfazer { height: 40px; padding: 0 14px; } }
/* ---------- Painel lateral (lote 10E): detalhe do alarme, Editar câmera, Editar NVR ----------
   O mesmo #modal, marcado .rd-gaveta pelo rdJanelaPreparar (app.js). Encostado à direita,
   abaixo da barra de categorias, sem escurecer a tela: a lista ao lado continua clicável.
   Expandir volta ao layout de tela cheia de antes (por isso tudo é :not(.is-expanded)). */
.aed-footer-meio { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.modal.rd-gaveta:not(.is-expanded) {
  top: var(--rd-gaveta-topo, 0px); background: transparent; pointer-events: none;
  justify-content: flex-end; align-items: stretch;
}
.modal.rd-gaveta:not(.is-expanded) > .modal-body {
  pointer-events: auto; box-sizing: border-box;
  width: min(100vw, 540px) !important; height: 100%; max-height: none !important;
  border-radius: 0; border-width: 0 0 0 1px; box-shadow: -10px 0 28px rgba(0, 0, 0, .28);
  padding: 18px 18px 0; animation: rdGavetaEntra .16s ease-out;
}
html[data-theme="light"] .modal.rd-gaveta:not(.is-expanded) > .modal-body { box-shadow: -8px 0 24px rgba(15, 23, 42, .12); }
@keyframes rdGavetaEntra { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal.rd-gaveta > .modal-body { animation: none; } }
.modal.rd-gaveta:not(.is-expanded) #modal-content {
  flex: 1; min-height: 0; overflow-y: auto !important; overscroll-behavior: contain;
  margin-right: 0; padding-right: 2px; padding-bottom: 0;
}
.modal.rd-gaveta:not(.is-expanded) #modal-content > .rd-modal-titulo { padding-right: 120px; }
/* Telas largas: a área da lista encolhe para o painel não cobrir nada. */
@media (min-width: 1200px) {
  body:has(#modal.rd-gaveta:not(.hidden):not(.is-expanded)) main { padding-right: calc(540px + 24px); }
}
/* Botão do Eyes passa para a esquerda do painel. */
@media (min-width: 601px) {
  body:has(#modal.rd-gaveta:not(.hidden):not(.is-expanded)) .iaf-botao { right: calc(min(100vw, 540px) + 16px); }
}
/* Alarme aberto marcado na lista. */
.rd-gaveta-atual { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Detalhe do alarme numa coluna só, evidência primeiro (mesma ordem do celular). */
.modal.rd-gaveta:not(.is-expanded) .aed {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  flex: none; height: auto; min-height: 0; padding-bottom: 0; min-width: 0;
}
.modal.rd-gaveta:not(.is-expanded) .aed > *,
.modal.rd-gaveta:not(.is-expanded) .aed-col-left > *,
.modal.rd-gaveta:not(.is-expanded) .aed-col-right > * { min-width: 0; max-width: 100%; flex-shrink: 0; }
.modal.rd-gaveta:not(.is-expanded) .aed-col-left,
.modal.rd-gaveta:not(.is-expanded) .aed-col-right { display: contents; }
.modal.rd-gaveta:not(.is-expanded) .aed-head { order: 1; margin-bottom: 0; padding-right: 110px; }
.modal.rd-gaveta:not(.is-expanded) .aed-status-line { order: 2; flex-wrap: wrap; }
.modal.rd-gaveta:not(.is-expanded) .aed-actions-main { order: 3; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.modal.rd-gaveta:not(.is-expanded) .aed-actions-main > * { min-width: 0; width: 100%; box-sizing: border-box; }
.modal.rd-gaveta:not(.is-expanded) .aed-actions-sec { order: 4; display: flex; flex-wrap: wrap; gap: 6px; }
.modal.rd-gaveta:not(.is-expanded) .aed-col-right > .tabs-inline { order: 5; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px; scrollbar-width: none; }
.modal.rd-gaveta:not(.is-expanded) .aed-col-right > .tabs-inline::-webkit-scrollbar { display: none; }
.modal.rd-gaveta:not(.is-expanded) .tab-inline { flex: 0 0 auto; }
.modal.rd-gaveta:not(.is-expanded) .aed-col-right > #aed-tab-body { order: 6; margin-top: 0; flex: none; overflow: visible; min-height: 0; }
.modal.rd-gaveta:not(.is-expanded) .aed-col-right > #aed-quick-comment-wrap { order: 7; }
.modal.rd-gaveta:not(.is-expanded) .aed-fields { order: 8; }
.modal.rd-gaveta:not(.is-expanded) .aed-ia-detalhe { order: 8; }
.modal.rd-gaveta:not(.is-expanded) .aed-img-wrap,
.modal.rd-gaveta:not(.is-expanded) .aed-img-zoom-box { flex: none; display: block; }
.modal.rd-gaveta:not(.is-expanded) .aed-img-main { height: auto; max-height: 52vh; object-fit: contain; }
.modal.rd-gaveta:not(.is-expanded) .aed-field { grid-template-columns: 130px 1fr; padding: 7px 0; }
/* Rodapé fixo no fim do painel: ‹ posição na lista › */
.modal.rd-gaveta:not(.is-expanded) .aed-footer {
  order: 9; position: sticky; bottom: 0; z-index: 3; background: var(--panel);
  flex-direction: row; justify-content: space-between; align-items: center; gap: 10px;
  margin: 4px 0 0; padding: 10px 0 12px; border-top: 1px solid var(--border);
}
.modal.rd-gaveta:not(.is-expanded) .aed-nav-arrow {
  position: static; transform: none; flex: 0 0 auto; width: 36px; height: 36px;
  background: var(--panel-2, var(--bg)); color: var(--text); border: 1px solid var(--border);
  box-shadow: none; font-size: var(--fs-20);
}
.modal.rd-gaveta:not(.is-expanded) .aed-nav-arrow:hover { background: var(--hover, var(--panel-2)); }
.modal.rd-gaveta:not(.is-expanded) .aed-nav-arrow:active { transform: translateY(1px); }

@media (max-width: 600px) {
  .modal.rd-gaveta:not(.is-expanded) { top: 0; }
  .modal.rd-gaveta:not(.is-expanded) > .modal-body {
    width: 100% !important; border-width: 0; box-shadow: none; animation: none;
    padding: 14px 14px 0;
  }
  .modal.rd-gaveta:not(.is-expanded) .aed-head { padding-right: 130px; }
  .modal.rd-gaveta:not(.is-expanded) .aed-actions-sec { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .modal.rd-gaveta:not(.is-expanded) .aed-nav-arrow { width: 44px; height: 44px; }
  .modal.rd-gaveta:not(.is-expanded) .aed-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .modal.rd-gaveta:not(.is-expanded) .aed-field { grid-template-columns: 120px 1fr; }
}
/* ---------- Busca rápida (lote 10F): Ctrl+K ---------- */
.topcats-account .rd-busca-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 10px;
  border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: var(--fs-13); font-weight: 500;
  background: transparent; justify-content: flex-start;
}
.topcats-account .rd-busca-btn:hover { color: var(--text); background: var(--hover); }
.topcats-account .rd-busca-btn .rd-busca-btn-txt { flex: 1; text-align: left; }
.rd-busca-kbd, .rd-busca kbd {
  font-family: inherit; font-size: var(--fs-12); line-height: 1; color: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--bg);
}
.topbar .rd-busca-btn-m { display: none; }
/* Lote 11: a categoria IA aumentou o menu de cima em ~60 px -- o botão vira só ícone já em <1500 px
   (era <1400); abaixo de 1340 px a data some do relógio (clicar na hora abre o calendário) e, abaixo
   de 1280 px, as categorias apertam o respiro lateral -- assim nenhuma largura estoura mais que antes. */
@media (max-width: 1499px) {
  .topcats-account .rd-busca-btn { width: 38px; padding: 0; justify-content: center; border-color: transparent; }
  .topcats-account .rd-busca-btn .rd-busca-btn-txt, .topcats-account .rd-busca-kbd { display: none; }
}
@media (max-width: 1339px) {
  .topcats-clock-data { display: none; }
  .topcats-clock { cursor: pointer; }
}
@media (max-width: 1279px) { html body.legacy-shell .topcat { padding-left: 8px; padding-right: 8px; } }
/* Até 1100 px a barra de categorias já não cabe: o botão vai para a linha do título. */
@media (max-width: 1100px) { .topcats-account .rd-busca-btn { display: none; } }
@media (max-width: 1100px) {
  .topbar .rd-busca-btn-m {
    display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
    width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 10px; flex: 0 0 auto;
  }
  .topbar .rd-busca-btn-m .ic { width: 20px; height: 20px; }
}
.rd-busca-fundo {
  position: fixed; inset: 0; z-index: 240; background: rgba(6, 9, 14, .55);
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px;
}
html[data-theme="light"] .rd-busca-fundo { background: rgba(15, 23, 42, .32); }
.rd-busca {
  width: min(100%, 640px); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .4); overflow: hidden;
}
.rd-busca-campo { display: flex; align-items: center; gap: 10px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--border); }
.rd-busca-campo > .ic { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }
.rd-busca .rd-busca-input {
  flex: 1; min-width: 0; height: 52px; border: 0 !important; background: transparent !important; box-shadow: none !important; outline: none !important;
  font-size: var(--fs-16); color: var(--text); padding: 0;
}
.rd-busca .rd-busca-fechar { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.rd-busca-lista { overflow-y: auto; padding: 6px; min-height: 0; flex: 1; overscroll-behavior: contain; }
.rd-busca-grupo {
  font-size: var(--fs-12); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  padding: 10px 10px 4px;
}
.rd-busca-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-height: 40px;
}
.rd-busca-item > .ic { width: 18px; height: 18px; flex: 0 0 auto; }
.rd-busca-item.is-sel { background: var(--hover-strong, var(--hover)); }
.rd-busca-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rd-busca-titulo { font-size: var(--fs-14); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-busca-sub { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-busca-acao { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; flex: 0 0 auto; visibility: hidden; }
.rd-busca-item.is-sel .rd-busca-acao { visibility: visible; }
.rd-busca-vazio { padding: 18px 12px; color: var(--muted); font-size: var(--fs-14); text-align: center; }
.rd-busca-rodape {
  display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 14px; border-top: 1px solid var(--border);
  font-size: var(--fs-12); color: var(--muted);
}
.rd-busca-rodape kbd { margin-right: 3px; }
.rd-busca-dica { margin-left: auto; }
@media (max-width: 600px) {
  .rd-busca-fundo { padding: 0; align-items: stretch; }
  .rd-busca { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; }
  @supports (height: 100dvh) { .rd-busca { height: 100dvh; } }
  html.kb-open .rd-busca { height: var(--vvh, 100dvh); }
  .rd-busca-item { min-height: 48px; }
  .rd-busca-acao { visibility: visible; }
  .rd-busca-rodape { display: none; }
  .rd-busca .rd-busca-fechar { width: 44px; height: 44px; }
}
