/* =====================================================================
   Portaria — Design System
   Tokens → base → layout → componentes → telas
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Superfícies e texto */
  --fundo: #f3f5f9;
  --superficie: #ffffff;
  --superficie-2: #f8fafc;
  --superficie-3: #eef2f7;
  --borda: #e2e8f0;
  --borda-forte: #cbd5e1;
  --texto: #0f172a;
  --texto-2: #475569;
  --texto-3: #64748b;

  /* Marca e semânticas (cada uma com versão "suave" para fundos) */
  --primaria: #2563eb;
  --primaria-hover: #1d4ed8;
  --primaria-suave: #dbeafe;
  --primaria-texto: #1e40af;
  --ok: #15803d;
  --ok-suave: #dcfce7;
  --aviso: #b45309;
  --aviso-suave: #fef3c7;
  --perigo: #b91c1c;
  --perigo-suave: #fee2e2;

  /* Barra lateral (sempre escura) */
  --lateral: #0b1220;
  --lateral-2: #131c2e;
  --lateral-texto: #cbd5e1;
  --lateral-texto-2: #94a3b8;

  /* Tipografia */
  --fonte: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --fonte-mono: "JetBrains Mono", Consolas, "Courier New", monospace;
  --t-xs: 12px; --t-sm: 13px; --t-md: 14px; --t-base: 16px;
  --t-lg: 20px; --t-xl: 24px; --t-2xl: 32px; --t-3xl: 44px;

  /* Espaçamento (base 4) */
  --e-1: 4px; --e-2: 8px; --e-3: 12px; --e-4: 16px; --e-5: 20px; --e-6: 24px; --e-8: 32px;

  /* Forma e elevação */
  --raio-sm: 6px; --raio: 10px; --raio-lg: 14px; --raio-total: 999px;
  --sombra-sm: 0 1px 2px rgb(15 23 42 / .06);
  --sombra: 0 4px 12px rgb(15 23 42 / .08);
  --sombra-lg: 0 20px 50px rgb(15 23 42 / .22);
  --foco: 0 0 0 3px rgb(37 99 235 / .35);

  /* Movimento */
  --rapido: 120ms; --medio: 220ms;
  --suave: cubic-bezier(.2, .8, .2, 1);

  --altura-topo: 68px;
  color-scheme: light;
}

/* Tema escuro: segue o sistema, a menos que o usuário escolha "light" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fundo: #070c17; --superficie: #0f172a; --superficie-2: #131d33; --superficie-3: #1a2540;
    --borda: #22304b; --borda-forte: #334366;
    --texto: #e7ecf4; --texto-2: #a8b3c7; --texto-3: #8592a8;
    --primaria: #3b82f6; --primaria-hover: #60a5fa; --primaria-suave: #172a4d; --primaria-texto: #93c5fd;
    --ok: #4ade80; --ok-suave: #0f2e1d; --aviso: #fbbf24; --aviso-suave: #33240a; --perigo: #f87171; --perigo-suave: #3a1414;
    --lateral: #050913; --lateral-2: #0d1526;
    --sombra-sm: 0 1px 2px rgb(0 0 0 / .4); --sombra: 0 4px 14px rgb(0 0 0 / .45); --sombra-lg: 0 20px 50px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fundo: #070c17; --superficie: #0f172a; --superficie-2: #131d33; --superficie-3: #1a2540;
  --borda: #22304b; --borda-forte: #334366;
  --texto: #e7ecf4; --texto-2: #a8b3c7; --texto-3: #8592a8;
  --primaria: #3b82f6; --primaria-hover: #60a5fa; --primaria-suave: #172a4d; --primaria-texto: #93c5fd;
  --ok: #4ade80; --ok-suave: #0f2e1d; --aviso: #fbbf24; --aviso-suave: #33240a; --perigo: #f87171; --perigo-suave: #3a1414;
  --lateral: #050913; --lateral-2: #0d1526;
  --sombra-sm: 0 1px 2px rgb(0 0 0 / .4); --sombra: 0 4px 14px rgb(0 0 0 / .45); --sombra-lg: 0 20px 50px rgb(0 0 0 / .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--fonte); font-size: var(--t-md); line-height: 1.5;
  background: var(--fundo); color: var(--texto);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primaria); }
:focus-visible { outline: none; box-shadow: var(--foco); border-radius: var(--raio-sm); }
.texto-2 { color: var(--texto-2); }
.texto-3 { color: var(--texto-3); font-size: var(--t-sm); }
.num { font-variant-numeric: tabular-nums; }
.msg-erro { color: var(--perigo); font-size: var(--t-sm); min-height: 1.4em; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- Layout ---------- */
#app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.lateral {
  background: var(--lateral); color: var(--lateral-texto);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  padding: var(--e-5) var(--e-3);
}
.marca { display: flex; align-items: center; gap: var(--e-3); font-weight: 800; font-size: var(--t-lg); color: #fff; padding: 0 var(--e-3) var(--e-6); }
.marca-icone {
  width: 34px; height: 34px; border-radius: var(--raio); flex: none;
  background: var(--primaria) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 24V10l7-3 7 3v14' fill='none' stroke='white' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M13 24v-6h6v6' fill='none' stroke='white' stroke-width='2.5'/%3E%3C/svg%3E") center/26px no-repeat;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: var(--e-3); min-height: 42px; padding: 0 var(--e-3);
  color: var(--lateral-texto); text-decoration: none; border-radius: var(--raio); font-weight: 500;
  transition: background var(--rapido), color var(--rapido);
}
.nav a:hover { background: var(--lateral-2); color: #fff; }
.nav a.ativo { background: var(--primaria); color: #fff; }
.nav a.ativo svg { opacity: 1; }
.nav a svg { opacity: .8; }
.nav-grupo { font-size: var(--t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--lateral-texto-2); padding: var(--e-5) var(--e-3) var(--e-2); }
.lateral-rodape { border-top: 1px solid var(--lateral-2); padding: var(--e-4) var(--e-2) 0; display: grid; gap: var(--e-3); }
.usuario { display: flex; align-items: center; gap: var(--e-3); }
.usuario-info { min-width: 0; }
#nome-usuario { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lateral .texto-3 { color: var(--lateral-texto-2); }
.avatar-iniciais { width: 36px; height: 36px; border-radius: 50%; background: var(--lateral-2); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: var(--t-sm); flex: none; }
.lateral-acoes { display: flex; gap: var(--e-2); }
.lateral .btn-fantasma { color: var(--lateral-texto); }
.lateral .btn-fantasma:hover { background: var(--lateral-2); color: #fff; }

.principal { display: flex; flex-direction: column; min-width: 0; }
.topo {
  height: var(--altura-topo); display: flex; align-items: center; justify-content: space-between; gap: var(--e-4);
  padding: 0 var(--e-6); background: var(--superficie); border-bottom: 1px solid var(--borda);
  position: sticky; top: 0; z-index: 5;
}
.topo h1 { font-size: var(--t-lg); font-weight: 700; }
.topo-direita { display: flex; align-items: center; gap: var(--e-4); }
.relogio { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
#relogio-hora { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
#relogio-data { font-size: var(--t-xs); color: var(--texto-3); }
main { padding: var(--e-6); min-width: 0; }

/* ---------- Status ---------- */
.status {
  display: inline-flex; align-items: center; gap: var(--e-2); height: 30px; padding: 0 var(--e-3);
  border-radius: var(--raio-total); font-size: var(--t-sm); font-weight: 500;
  background: var(--superficie-3); color: var(--texto-2);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.ok { background: var(--ok-suave); color: var(--ok); }
.status.ok::before { animation: pulso 2s infinite; }
.status.falha { background: var(--perigo-suave); color: var(--perigo); }
@keyframes pulso { 50% { opacity: .35; } }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2);
  min-height: 40px; padding: 0 var(--e-4); border-radius: var(--raio);
  font: 600 var(--t-md) / 1 var(--fonte); text-decoration: none; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--borda-forte); background: var(--superficie); color: var(--texto);
  transition: background var(--rapido), border-color var(--rapido), color var(--rapido), transform var(--rapido);
}
.btn:hover { background: var(--superficie-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: default; pointer-events: none; }
.btn-primario { background: var(--primaria); border-color: var(--primaria); color: #fff; }
.btn-primario:hover { background: var(--primaria-hover); border-color: var(--primaria-hover); }
.btn-saida { background: var(--aviso-suave); border-color: transparent; color: var(--aviso); }
.btn-saida:hover { background: var(--aviso); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); }
.btn-perigo { background: var(--perigo-suave); border-color: transparent; color: var(--perigo); }
.btn-perigo:hover { background: var(--perigo); color: #fff; }
.btn-fantasma { background: transparent; border-color: transparent; color: var(--texto-2); }
.btn-fantasma:hover { background: var(--superficie-3); color: var(--texto); }
.btn-sm { min-height: 34px; padding: 0 var(--e-3); font-size: var(--t-sm); }
.btn-lg { min-height: 48px; padding: 0 var(--e-6); font-size: var(--t-base); }
.btn-bloco { width: 100%; }
.btn-icone { width: 40px; padding: 0; }
.acoes { display: flex; gap: var(--e-2); flex-wrap: wrap; align-items: center; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: var(--e-4); align-content: start; }
.form-linha { display: grid; grid-template-columns: 1fr 1fr; gap: var(--e-4); }
.campo { display: grid; gap: 6px; }
.campo > span { font-size: var(--t-sm); font-weight: 600; color: var(--texto-2); }
.campo > span .obrig { color: var(--perigo); }
.campo small { font-size: var(--t-xs); color: var(--texto-3); }
input, select, textarea {
  font: var(--t-md) / 1.4 var(--fonte); color: var(--texto); width: 100%;
  min-height: 42px; padding: var(--e-2) var(--e-3);
  background: var(--superficie); border: 1px solid var(--borda-forte); border-radius: var(--raio);
  transition: border-color var(--rapido), box-shadow var(--rapido);
}
textarea { resize: vertical; min-height: 72px; }
input::placeholder, textarea::placeholder { color: var(--texto-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primaria); box-shadow: var(--foco); }
input[aria-invalid="true"] { border-color: var(--perigo); }
input.grande { font-size: var(--t-xl); font-weight: 700; min-height: 56px; letter-spacing: .02em; }
input.placa-input { font-family: var(--fonte-mono); text-transform: uppercase; letter-spacing: .12em; }
.check { display: flex; align-items: center; gap: var(--e-2); font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primaria); }
.busca { position: relative; }
.busca svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--texto-3); }
.busca input { padding-left: 38px; }

/* ---------- Cards ---------- */
.card { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg); box-shadow: var(--sombra-sm); }
.card-corpo { padding: var(--e-5); }
.card-cabecalho { display: flex; align-items: center; justify-content: space-between; gap: var(--e-3); padding: var(--e-4) var(--e-5); border-bottom: 1px solid var(--borda); }
.card-cabecalho h2, .card-cabecalho h3 { font-size: var(--t-base); font-weight: 700; display: flex; align-items: center; gap: var(--e-2); white-space: nowrap; }
.contagem { background: var(--superficie-3); color: var(--texto-2); font-size: var(--t-xs); font-weight: 700; padding: 2px 8px; border-radius: var(--raio-total); }
.cabecalho-pagina { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--e-4); margin-bottom: var(--e-5); flex-wrap: wrap; }
.cabecalho-pagina p { color: var(--texto-2); margin-top: var(--e-1); }
.secao-titulo { font-size: var(--t-base); font-weight: 700; margin-bottom: var(--e-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 var(--e-2);
  border-radius: var(--raio-total); font-size: var(--t-xs); font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  background: var(--superficie-3); color: var(--texto-2);
}
.badge svg.ic { width: 14px; height: 14px; stroke-width: 2.5; }
.badge-E { background: var(--ok-suave); color: var(--ok); }
.badge-S { background: var(--aviso-suave); color: var(--aviso); }
.badge-perigo { background: var(--perigo-suave); color: var(--perigo); }
.badge-info { background: var(--primaria-suave); color: var(--primaria-texto); }
.badge-lg { height: 34px; padding: 0 var(--e-3); font-size: var(--t-md); }

/* ---------- Avatar / foto ---------- */
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--superficie-3); flex: none; border: 2px solid var(--superficie); box-shadow: 0 0 0 1px var(--borda); }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 132px; height: 132px; border-radius: var(--raio-lg); border-width: 0; }

/* ---------- Placa (padrão Mercosul) ---------- */
.placa {
  display: inline-flex; flex-direction: column; align-items: stretch; border: 2px solid #1e293b; border-radius: 5px;
  background: #fff; color: #0f172a; font: 700 var(--t-md) / 1 var(--fonte-mono); letter-spacing: .1em; overflow: hidden; flex: none;
}
.placa::before { content: "BRASIL"; background: #1d4ed8; color: #fff; font: 700 7px/1 var(--fonte); letter-spacing: .2em; text-align: center; padding: 2px 0; }
.placa span { padding: 3px 8px 4px; text-align: center; }

/* ---------- Listas ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: var(--e-3); padding: var(--e-3) var(--e-5); border-bottom: 1px solid var(--borda); }
.item:last-child { border-bottom: 0; }
.item-info { flex: 1; min-width: 0; }
.item-titulo { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.item-det { font-size: var(--t-sm); color: var(--texto-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-lado { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.item-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; font-size: var(--t-sm); color: var(--texto-2); }
.item-hora { font-size: var(--t-sm); color: var(--texto-3); font-variant-numeric: tabular-nums; }
.item.novo { animation: destaque 2.4s var(--suave); }
@keyframes destaque { 0% { background: var(--primaria-suave); } 100% { background: transparent; } }
.vazio { display: grid; place-items: center; gap: var(--e-2); text-align: center; color: var(--texto-3); padding: var(--e-8) var(--e-5); }
.vazio svg.ic { width: 32px; height: 32px; stroke-width: 1.5; opacity: .6; }

/* ---------- Tabelas ---------- */
.tabela-rolagem { overflow: auto; max-height: calc(100vh - 290px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--t-md); }
th, td { text-align: left; padding: var(--e-3) var(--e-4); border-bottom: 1px solid var(--borda); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--superficie-2); font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-2); z-index: 1; }
tbody tr:hover td { background: var(--superficie-2); }
td.celula-pessoa { display: flex; align-items: center; gap: var(--e-3); }

/* ---------- Câmera ---------- */
.camera { display: grid; gap: var(--e-3); }
.camera-quadro {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--raio-lg); overflow: hidden;
  background: #0b1220; display: grid; place-items: center;
}
.camera-quadro video, .camera-quadro img { width: 100%; height: 100%; object-fit: cover; }
.camera-quadro video { transform: scaleX(-1); }
.camera-guia { position: absolute; inset: 12% 28%; border: 2px dashed rgb(255 255 255 / .55); border-radius: 50% / 42%; pointer-events: none; }
.camera-vazia { display: grid; place-items: center; gap: var(--e-2); color: #94a3b8; text-align: center; padding: var(--e-5); font-size: var(--t-sm); }
.camera-vazia svg.ic { width: 40px; height: 40px; stroke-width: 1.5; }
.camera .acoes { justify-content: center; }

/* ---------- Painel ---------- */
.painel { display: grid; gap: var(--e-5); }
.painel-topo { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--e-5); }
.ultima {
  display: flex; align-items: center; gap: var(--e-6); padding: var(--e-5) var(--e-6);
  border-left: 8px solid var(--borda-forte); min-height: 176px;
}
.ultima.E { border-left-color: var(--ok); }
.ultima.S { border-left-color: var(--aviso); }
.ultima.desconhecido { border-left-color: var(--perigo); background: linear-gradient(90deg, var(--perigo-suave), var(--superficie) 60%); }
.ultima.flash { animation: flash 1.6s var(--suave); }
@keyframes flash { 0% { box-shadow: 0 0 0 6px var(--primaria-suave); } 100% { box-shadow: var(--sombra-sm); } }
.ultima-rotulo { font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-3); }
.ultima-nome { font-size: var(--t-2xl); font-weight: 800; margin: var(--e-1) 0; line-height: 1.15; }
.ultima-det { color: var(--texto-2); font-size: var(--t-base); }
.ultima-linha { display: flex; align-items: center; gap: var(--e-3); flex-wrap: wrap; margin-top: var(--e-3); }
.ultima-hora { font-size: var(--t-xl); font-weight: 700; font-variant-numeric: tabular-nums; }

.contadores { display: grid; grid-template-rows: repeat(3, 1fr); gap: var(--e-3); }
.contador { display: flex; align-items: center; gap: var(--e-4); padding: var(--e-3) var(--e-5); }
.contador-icone { width: 44px; height: 44px; border-radius: var(--raio); display: grid; place-items: center; flex: none; }
.contador-icone svg.ic { width: 22px; height: 22px; }
.contador-valor { font-size: var(--t-2xl); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.contador-rotulo { color: var(--texto-2); font-size: var(--t-sm); font-weight: 500; }
.cor-ok { background: var(--ok-suave); color: var(--ok); }
.cor-info { background: var(--primaria-suave); color: var(--primaria-texto); }
.cor-aviso { background: var(--aviso-suave); color: var(--aviso); }

.painel-colunas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--e-5); }
.painel-colunas .card { display: flex; flex-direction: column; height: calc(100vh - var(--altura-topo) - 290px); min-height: 360px; }
.painel-colunas .rolagem { overflow-y: auto; flex: 1; }

/* ---------- Popup de passagem de cartão ---------- */
.popup-acesso {
  position: fixed; top: calc(var(--altura-topo) + 16px); right: 24px; z-index: 40; width: 440px;
  background: var(--superficie); border-radius: var(--raio-lg); box-shadow: var(--sombra-lg);
  border-left: 10px solid var(--ok); overflow: hidden; cursor: pointer;
  animation: entrar var(--medio) var(--suave);
}
.popup-acesso.S { border-left-color: var(--aviso); }
.popup-acesso.desconhecido { border-left-color: var(--perigo); }
.popup-conteudo { display: flex; gap: var(--e-4); align-items: center; padding: var(--e-5); }
.popup-acesso .avatar-xl { width: 112px; height: 112px; }
.popup-nome { font-size: var(--t-xl); font-weight: 800; line-height: 1.2; margin: 6px 0 2px; }
.popup-barra { height: 4px; background: var(--primaria); transform-origin: left; animation: encolher 8s linear forwards; }
@keyframes encolher { to { transform: scaleX(0); } }
@keyframes entrar { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Modal ---------- */
.modal {
  border: 0; padding: 0; border-radius: var(--raio-lg); width: min(560px, calc(100vw - 32px));
  background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-lg);
}
.modal.largo { width: min(860px, calc(100vw - 32px)); }
.modal::backdrop { background: rgb(2 6 23 / .55); backdrop-filter: blur(2px); }
.modal[open] { animation: subir var(--medio) var(--suave); }
@keyframes subir { from { transform: translateY(12px); opacity: 0; } }
.modal-cabecalho { padding: var(--e-5) var(--e-6) 0; }
.modal-cabecalho h2 { font-size: var(--t-lg); font-weight: 700; }
.modal-corpo { padding: var(--e-5) var(--e-6); }
.modal-rodape { display: flex; justify-content: flex-end; gap: var(--e-2); padding: var(--e-4) var(--e-6); background: var(--superficie-2); border-top: 1px solid var(--borda); flex-wrap: wrap; }
.modal-rodape .esquerda { margin-right: auto; }
.modal-pessoa { display: flex; align-items: center; gap: var(--e-4); }
.modal-pessoa .nome { font-size: var(--t-lg); font-weight: 700; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 24px; right: 24px; display: grid; gap: var(--e-2); z-index: 60; }
.toast {
  display: flex; align-items: flex-start; gap: var(--e-3); min-width: 300px; max-width: 420px;
  padding: var(--e-3) var(--e-4); border-radius: var(--raio); background: var(--superficie); color: var(--texto);
  box-shadow: var(--sombra-lg); border-left: 4px solid var(--ok); animation: entrar var(--medio) var(--suave); font-weight: 500;
}
.toast svg.ic { color: var(--ok); margin-top: 1px; }
.toast.erro { border-left-color: var(--perigo); }
.toast.erro svg.ic { color: var(--perigo); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-lado {
  background: radial-gradient(circle at 20% 20%, #1e3a8a 0, transparent 50%), var(--lateral); color: var(--lateral-texto);
  display: flex; flex-direction: column; justify-content: center; padding: 64px; gap: var(--e-4);
}
.login-lado p { font-size: var(--t-lg); max-width: 380px; color: var(--lateral-texto-2); }
.marca-grande { font-size: var(--t-3xl); padding: 0; }
.marca-grande .marca-icone { width: 56px; height: 56px; background-size: 42px; border-radius: var(--raio-lg); }
.login-form { display: grid; place-items: center; padding: var(--e-8); background: var(--superficie); }
.login-box { width: min(380px, 100%); }
.login-box h1 { font-size: var(--t-2xl); font-weight: 800; }

/* ---------- Telas de formulário ---------- */
.grade-form { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--e-5); align-items: start; }
.aviso-inline { display: flex; gap: var(--e-3); align-items: flex-start; padding: var(--e-3) var(--e-4); border-radius: var(--raio); font-size: var(--t-sm); font-weight: 500; }
.aviso-inline.info { background: var(--primaria-suave); color: var(--primaria-texto); }
.aviso-inline.ok { background: var(--ok-suave); color: var(--ok); }
.aviso-inline.perigo { background: var(--perigo-suave); color: var(--perigo); }
.filtros { display: flex; gap: var(--e-3); align-items: flex-end; flex-wrap: wrap; padding: var(--e-4) var(--e-5); }
.filtros .campo { min-width: 150px; }
.filtros .campo.cresce { flex: 1; min-width: 220px; }
.abas { display: inline-flex; padding: 4px; background: var(--superficie-3); border-radius: var(--raio); gap: 2px; }
.abas button { border: 0; background: transparent; font: 600 var(--t-md) var(--fonte); color: var(--texto-2); padding: 0 var(--e-4); min-height: 34px; border-radius: var(--raio-sm); cursor: pointer; }
.abas button[aria-selected="true"] { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-sm); }

.abas button { display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2); }
.abas button[aria-checked="true"] { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-sm); }
.abas button:disabled { opacity: .4; cursor: not-allowed; }
.abas-bloco { display: grid; grid-template-columns: 1fr 1fr; }
.abas-bloco button { min-height: 42px; }

/* ---------- Estacionamento: medidor de vagas ---------- */
.medidor { --cor-medidor: var(--ok); display: grid; gap: 6px; }
.medidor.alto { --cor-medidor: var(--aviso); }
.medidor.cheio { --cor-medidor: var(--perigo); }
.medidor.sem-limite { --cor-medidor: var(--texto-3); }
.medidor-topo { display: flex; justify-content: space-between; align-items: baseline; gap: var(--e-3); }
.medidor-nome { font-weight: 600; color: var(--texto-2); font-size: var(--t-sm); }
.medidor-valor { font-size: var(--t-xl); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--texto); }
.medidor-valor small { font-size: var(--t-sm); font-weight: 600; color: var(--texto-3); }
.medidor.cheio .medidor-valor { color: var(--perigo); }
.medidor-trilho { height: 10px; border-radius: var(--raio-total); background: var(--superficie-3); overflow: hidden; }
.medidor-barra { height: 100%; border-radius: inherit; background: var(--cor-medidor); transition: width var(--medio) var(--suave); }
.medidor-status { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--cor-medidor); }
.medidor-status svg.ic { width: 16px; height: 16px; }
.medidor.compacto { gap: 3px; }
.medidor.compacto .medidor-valor { font-size: var(--t-base); }
.medidor.compacto .medidor-nome { font-size: var(--t-xs); }
.medidor.compacto .medidor-trilho { height: 6px; }
.contador-vagas { text-decoration: none; color: inherit; transition: border-color var(--rapido); }
.contador-vagas:hover { border-color: var(--primaria); }
.vagas-mini { flex: 1; display: grid; gap: var(--e-2); min-width: 0; }
.vagas-grandes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--e-8); }
.vagas-grandes .medidor-valor { font-size: var(--t-3xl); line-height: 1; }
.vagas-grandes .medidor-trilho { height: 16px; }
.pessoa-vinculada {
  display: flex; align-items: center; gap: var(--e-4); padding: var(--e-3) var(--e-4); flex-wrap: wrap;
  border-radius: var(--raio); background: var(--primaria-suave); border: 1px solid transparent;
}
.pessoa-vinculada .texto-2, .pessoa-vinculada .texto-3 { color: var(--primaria-texto); }
.linha-veiculo { display: grid; grid-template-columns: 120px 1fr 100px auto; gap: var(--e-2); }

/* ---------- Liberar portão ---------- */
.btn-liberar { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-liberar:hover { background: var(--ok); filter: brightness(1.1); }
:root[data-theme="dark"] .btn-liberar { color: #052e16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-liberar { color: #052e16; } }
.chips { display: flex; flex-wrap: wrap; gap: var(--e-2); }
.chip { cursor: pointer; position: relative; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--e-4); border-radius: var(--raio-total);
  border: 1px solid var(--borda-forte); background: var(--superficie); font-weight: 500; color: var(--texto-2);
  transition: background var(--rapido), border-color var(--rapido), color var(--rapido);
}
.chip:hover span { background: var(--superficie-3); }
.chip input:checked + span { background: var(--primaria-suave); border-color: var(--primaria); color: var(--primaria-texto); font-weight: 600; }
.chip input:focus-visible + span { box-shadow: var(--foco); }

/* ---------- Lista do portão ---------- */
.situacao-lista { display: flex; align-items: center; gap: var(--e-4); margin-bottom: var(--e-5); border-left: 6px solid var(--borda-forte); flex-wrap: wrap; }
.situacao-lista.ok { border-left-color: var(--ok); }
.situacao-lista.info { border-left-color: var(--primaria); }
.situacao-lista.perigo { border-left-color: var(--perigo); background: linear-gradient(90deg, var(--perigo-suave), var(--superficie) 55%); }
.situacao-lista.inativa { border-left-color: var(--aviso); }
.situacao-icone { width: 44px; height: 44px; border-radius: var(--raio); display: grid; place-items: center; flex: none; background: var(--superficie-3); color: var(--texto-2); }
.situacao-lista.ok .situacao-icone { background: var(--ok-suave); color: var(--ok); }
.situacao-lista.info .situacao-icone { background: var(--primaria-suave); color: var(--primaria-texto); }
.situacao-lista.perigo .situacao-icone { background: var(--perigo-suave); color: var(--perigo); }
.situacao-lista.inativa .situacao-icone { background: var(--aviso-suave); color: var(--aviso); }
.situacao-texto { flex: 1; min-width: 240px; }
.situacao-titulo { font-weight: 700; font-size: var(--t-base); margin-bottom: 2px; }
.resumo-lista { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--e-3); }
.resumo-lista > div { background: var(--superficie-2); border: 1px solid var(--borda); border-radius: var(--raio); padding: var(--e-3) var(--e-4); display: grid; }
.resumo-lista .num { font-size: var(--t-2xl); font-weight: 800; line-height: 1.1; }
.resumo-lista small { color: var(--texto-2); }
.chip-botao {
  display: inline-flex; align-items: center; gap: var(--e-2); min-height: 36px; padding: 0 var(--e-3); cursor: pointer;
  border: 1px solid var(--borda-forte); border-radius: var(--raio-total); background: var(--superficie); color: var(--texto); font: 600 var(--t-sm) var(--fonte);
}
.chip-botao small { color: var(--texto-3); font-weight: 500; }
.chip-botao:hover { background: var(--superficie-3); }
.chip-botao.selecionado { background: var(--primaria-suave); border-color: var(--primaria); color: var(--primaria-texto); }

/* ---------- Verificação em duas etapas ---------- */
.passos-2fa { margin: 0; padding-left: 20px; display: grid; gap: var(--e-4); }
.passos-2fa li { padding-left: 4px; }
.qr-2fa { margin: var(--e-3) 0; padding: var(--e-3); background: #fff; border-radius: var(--raio); display: inline-block; border: 1px solid var(--borda); }
.qr-2fa img { display: block; }
.chave-2fa { font-family: var(--fonte-mono); background: var(--superficie-3); padding: 2px 6px; border-radius: 4px; letter-spacing: .05em; user-select: all; }
.codigos-recuperacao { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--e-2); max-width: 360px; padding: var(--e-4);
  background: var(--superficie-2); border: 1px dashed var(--borda-forte); border-radius: var(--raio); }
.codigos-recuperacao span { font-family: var(--fonte-mono); font-size: var(--t-base); font-weight: 700; letter-spacing: .08em; }
.conta { align-items: start; }

/* Troca de senha obrigatória: só a tela de senha fica disponível. */
body.troca-obrigatoria .nav,
body.troca-obrigatoria .lateral-acoes a,
body.troca-obrigatoria .topo-direita > :not(.relogio) { display: none !important; }

/* ---------- Responsivo ---------- */
@media (max-width: 1280px) {
  .painel-topo { grid-template-columns: 1fr; }
  .contadores { grid-template-rows: none; grid-template-columns: repeat(3, 1fr); }
  .painel-colunas .card { height: 460px; }
}
@media (max-width: 1100px) {
  .painel-colunas { grid-template-columns: 1fr; }
  .grade-form { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; padding: var(--e-3); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-grupo, .lateral-rodape .usuario { display: none; }
  .marca { padding-bottom: var(--e-3); }
  .topo { padding: 0 var(--e-4); }
  #relogio-data { display: none; }
  main { padding: var(--e-4); }
  .contadores { grid-template-columns: 1fr; }
  .form-linha, .vagas-grandes, .linha-veiculo { grid-template-columns: 1fr; }
  .ultima { flex-direction: column; align-items: flex-start; }
  .login { grid-template-columns: 1fr; }
  .login-lado { padding: var(--e-8) var(--e-6); }
  .popup-acesso { left: 16px; right: 16px; width: auto; }
}
