/* Layout: cabeçalho fixo com abas; conteúdo em cartões; no celular as abas viram barra inferior.
   Paleta inspirada no teclado da urna: verde CONFIRMA, laranja CORRIGE, papel térmico do boletim. */
:root {
  /* Identidade da Rádio Osório FM 106.9: azul #334d99 e marinho #1a1b2e do logo.
     Verde CONFIRMA e laranja CORRIGE (teclado da urna) ficam só para estado: apurada / digitada. */
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #e4e8f1;
  --ink: #121527;
  --muted: #525a73;
  --line: #d2d8e6;
  --marca: #334d99;
  --marca-escuro: #1a1b2e;
  --confirma: #1d7f46;
  --confirma-ink: #ffffff;
  --corrige: #b9561a;
  --bar: #334d99;
  --bar-fundo: #dfe4f0;
  --alerta: #b3261e;
  --alerta-fundo: #fbe9e7;
  --aviso-fundo: #fbf0e3;
  --ok-fundo: #e3f2e8;
  --papel: #f7f8fb;
  --sombra: 0 1px 2px rgba(18, 21, 39, .06), 0 4px 16px rgba(18, 21, 39, .05);

  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-corpo: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --raio: 10px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f1c; --surface: #151a2e; --surface-2: #1d2340; --ink: #e8ebf5; --muted: #9aa3bf;
    --line: #2a3152; --marca: #8fa6e8; --marca-escuro: #dfe6fb; --confirma: #2f9e5d; --confirma-ink: #06140c; --corrige: #e08a4a; --bar: #8fa6e8;
    --bar-fundo: #232a47; --alerta: #ef8a80; --alerta-fundo: #3a1d1a; --aviso-fundo: #35281a; --ok-fundo: #173323;
    --papel: #171c31; --sombra: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f1c; --surface: #151a2e; --surface-2: #1d2340; --ink: #e8ebf5; --muted: #9aa3bf;
  --line: #2a3152; --marca: #8fa6e8; --marca-escuro: #dfe6fb; --confirma: #2f9e5d; --confirma-ink: #06140c; --corrige: #e08a4a; --bar: #8fa6e8;
  --bar-fundo: #232a47; --alerta: #ef8a80; --alerta-fundo: #3a1d1a; --aviso-fundo: #35281a; --ok-fundo: #173323;
  --papel: #171c31; --sombra: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-corpo);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: .01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bar); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num, .tab-num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); }
.nota { color: var(--muted); font-size: .875rem; }
.erro { color: var(--alerta); font-size: .9rem; min-height: 1.2em; }

/* ---------- topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 3px double var(--marca); padding-top: env(safe-area-inset-top, 0px); /* filete duplo, como no logo */
}
.topo-in {
  max-width: 1240px; margin: 0 auto; padding: 10px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.marca { display: flex; align-items: center; gap: 14px; min-width: 0; color: inherit; text-decoration: none; }
.marca-logo { display: block; height: 46px; width: auto; flex: none; }
.marca-logo.escuro { display: none; }
.marca-txt { display: flex; flex-direction: column; min-width: 0; padding-left: 14px; border-left: 2px solid var(--line); }
.marca-tit { font-family: var(--f-display); font-weight: 700; font-size: 1.4rem; line-height: 1; letter-spacing: .02em; color: var(--marca); text-transform: uppercase; }
.marca-sub { color: var(--muted); font-size: .8rem; }
.topo-acoes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ao-vivo { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); padding: 4px 8px; border-radius: 99px; background: var(--surface-2); white-space: nowrap; }
.ao-vivo i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.ao-vivo[data-estado="ok"] i { background: var(--confirma); box-shadow: 0 0 0 0 var(--confirma); animation: pulso 2s infinite; }
.ao-vivo[data-estado="erro"] i { background: var(--alerta); }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--confirma) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .ao-vivo i { animation: none !important; } * { transition: none !important; } }
.usuario { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: .85rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.abas { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); display: flex; gap: 4px; }
.abas button {
  display: flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer;
  padding: 8px 12px 10px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; font-size: .9rem;
}
.abas svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.abas button[aria-current="page"] { color: var(--marca); border-bottom-color: var(--marca); }

/* ---------- segmentado / chips / botões ---------- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sombra); }
.seg-peq button { padding: 3px 8px; font-size: .8rem; }
.seg-largo { display: flex; width: 100%; max-width: 480px; }
.seg-largo button { flex: 1; padding: 9px 10px; font-size: .95rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: .9rem; text-decoration: none; color: var(--ink);
  min-height: 42px;
}
.btn:hover { border-color: var(--muted); }
.btn-confirma { background: var(--confirma); border-color: var(--confirma); color: var(--confirma-ink); }
.btn-confirma:hover { filter: brightness(1.06); border-color: var(--confirma); }
.btn-corrige { border-color: var(--corrige); color: var(--corrige); }
.btn-perigo { border-color: var(--alerta); color: var(--alerta); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--bar); cursor: pointer; padding: 0; font-weight: 600; font-size: .875rem; text-decoration: underline; text-underline-offset: 3px; }
.linha-botoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chips button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer;
  font-family: var(--f-display); font-weight: 600; font-size: 1rem; white-space: nowrap; letter-spacing: .02em;
}
.chips button[aria-selected="true"] { background: var(--marca); color: var(--surface); border-color: var(--marca); }

/* ---------- conteúdo ---------- */
.conteudo { max-width: 1240px; margin: 0 auto; padding-inline: var(--gutter); padding-block: 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.aba { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cartao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cartao-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cartao.vazio { align-items: flex-start; }
.faixa { border-radius: var(--raio); padding: 10px 14px; background: var(--alerta-fundo); color: var(--ink); font-size: .9rem; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.faixa-aviso { background: var(--aviso-fundo); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-rot { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.kpi-val { font-family: var(--f-display); font-weight: 700; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.kpi-det { font-size: .8rem; color: var(--muted); }
.trilho { height: 6px; border-radius: 99px; background: var(--bar-fundo); overflow: hidden; }
.trilho > i { display: block; height: 100%; background: var(--marca); border-radius: 99px; }

.cargos-barra { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--altura-topo, 104px)); z-index: 5; background: var(--bg); padding-block: 4px; margin-block: -4px; }
.grade-painel { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }

/* Barras do ranking */
.barras { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.barra { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; }
.barra-nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.barra-nome .mono { font-weight: 500; color: var(--muted); }
.barra-nome .sigla { color: var(--muted); font-weight: 500; font-size: .85rem; }
.barra-val { font-variant-numeric: tabular-nums; font-size: .9rem; white-space: nowrap; }
.barra-val b { font-family: var(--f-display); font-size: 1.15rem; font-weight: 700; margin-left: 6px; }
.barra-trilho { grid-column: 1 / -1; height: 10px; background: var(--bar-fundo); border-radius: 4px; overflow: hidden; }
.barra-trilho > i { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; transition: width .4s ease; }
.barra.lider .barra-trilho > i { background: var(--marca-escuro); }
.resumo-votos { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 0; padding-top: 12px; border-top: 1px dashed var(--line); }
.resumo-votos div { display: flex; flex-direction: column; }
.resumo-votos dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.resumo-votos dd { margin: 0; font-family: var(--f-display); font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tabela de bairros */
.campo-inline { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); min-width: 0; flex: 1 1 220px; justify-content: flex-end; }
.campo-inline select { max-width: 100%; min-width: 0; flex: 1; }
select, input[type="text"], input[type="number"], input[type="search"], input[type="password"], input:not([type]), textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { font-family: var(--f-mono); font-size: .8rem; resize: vertical; }
.tabela-rolagem { overflow-x: auto; margin-inline: -16px; padding-inline: 16px; }
table { border-collapse: collapse; width: 100%; }
.tab-bairros { min-width: 560px; }
.tab-bairros th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tab-bairros th.num, .tab-bairros td.num { text-align: right; }
.ord { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.ord[aria-sort="descending"]::after { content: " ↓"; }
.ord[aria-sort="ascending"]::after { content: " ↑"; }
.tab-bairros td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.tab-bairros tr.bairro-linha { cursor: pointer; }
.tab-bairros tr.bairro-linha:hover td { background: var(--surface-2); }
.tab-bairros tr.bairro-linha td:first-child { font-weight: 600; }
.tab-bairros tr.bairro-linha td:first-child::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
.tab-bairros tr.bairro-linha[aria-expanded="true"] td:first-child::before { transform: rotate(90deg); }
.tab-bairros tr.local-linha td { font-size: .85rem; background: var(--papel); }
.tab-bairros tr.local-linha td:first-child { padding-left: 26px; }
.apur { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.apur .trilho { flex: 1; min-width: 50px; }
.apur span { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.pct { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.pct .barra-trilho { flex: 1; height: 8px; min-width: 50px; }
.pct b { font-family: var(--f-display); font-size: 1.05rem; min-width: 3.4em; text-align: right; }
.lider-cel { font-size: .85rem; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.lider-cel .mono { color: var(--muted); }
.sem-dado { color: var(--muted); font-size: .85rem; }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: 4.2em minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { font-family: var(--f-mono); color: var(--muted); font-size: .8rem; padding-top: 2px; }
.feed .det { color: var(--muted); font-size: .82rem; }
.feed button.link { font-size: .9rem; }

/* ---------- Lançar ---------- */
.lanc-grade { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 16px; align-items: start; }
.camera { position: relative; aspect-ratio: 4 / 3; max-width: 100%; background: #0b0f0d; border-radius: 8px; overflow: hidden; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mira { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.mira span { width: 72%; aspect-ratio: 1; max-height: 86%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .28); }
.camera.lendo .mira span { border-color: #3fd27f; }
.camera-vazia { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; background: var(--surface-2); color: var(--ink); }
.camera-vazia p { max-width: 42ch; color: var(--muted); font-size: .9rem; }
.camera.ativa .camera-vazia { display: none; }
.camera:not(.ativa) .mira { display: none; }
.leitor-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.leitor-status { font-size: .9rem; min-height: 1.4em; color: var(--muted); }
.leitor-status.ok { color: var(--confirma); font-weight: 600; }
.leitor-status.erro { color: var(--alerta); font-weight: 600; }
.colar { display: flex; flex-direction: column; gap: 8px; }
.colar label { font-size: .85rem; color: var(--muted); }

.partes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.parte { font-family: var(--f-mono); font-size: .85rem; border: 1.5px dashed var(--line); border-radius: 6px; padding: 4px 9px; color: var(--muted); }
.parte.lida { border-style: solid; border-color: var(--confirma); background: var(--ok-fundo); color: var(--ink); }

.previa { display: flex; flex-direction: column; gap: 12px; }
.recibo {
  background: var(--papel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px;
  font-family: var(--f-mono); font-size: .82rem; line-height: 1.55;
}
.recibo h3 { font-family: var(--f-mono); font-size: .9rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.recibo-linha { display: flex; justify-content: space-between; gap: 10px; }
.recibo-linha span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recibo-sep { border-top: 1px dashed var(--muted); margin: 6px 0; }
.selos { display: flex; gap: 6px; flex-wrap: wrap; }
.selo { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; border-radius: 99px; padding: 3px 9px; background: var(--surface-2); }
.selo.ok { background: var(--ok-fundo); color: var(--confirma); }
.selo.mal { background: var(--alerta-fundo); color: var(--alerta); }
.selo.aviso { background: var(--aviso-fundo); color: var(--corrige); }
.avisos { margin: 0; padding-left: 18px; font-size: .85rem; color: var(--corrige); display: flex; flex-direction: column; gap: 2px; }
.confirma-box { border: 1.5px solid var(--corrige); background: var(--aviso-fundo); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* Formulário manual */
.form-manual { gap: 16px; }
.form-linha { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-linha .campo, .totais-cargo .campo { flex: 1 1 140px; }
.campo > span { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.campo-largo { flex: 3 1 220px; }
.local-info { font-size: .9rem; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.local-info:empty { display: none; }
.local-info b { font-weight: 600; }
.cargo-form { border: 1px solid var(--line); border-radius: 8px; }
.cargo-form > summary { cursor: pointer; padding: 10px 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; list-style: none; font-family: var(--f-display); font-size: 1.15rem; font-weight: 600; }
.cargo-form > summary::-webkit-details-marker { display: none; }
.cargo-form > summary::before { content: "▸"; color: var(--muted); margin-right: 6px; transition: transform .15s; }
.cargo-form[open] > summary::before { transform: rotate(90deg); }
.cargo-form > summary .soma { font-family: var(--f-mono); font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: auto; }
.cargo-corpo { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.linhas-votos { display: flex; flex-direction: column; gap: 6px; }
.linha-voto { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 6.5em 36px; gap: 6px; align-items: center; }
.linha-voto input { min-height: 38px; padding: 6px 8px; }
.linha-voto .nome-auto { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-voto .rem { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1.2rem; height: 36px; border-radius: 6px; }
.linha-voto .rem:hover { background: var(--surface-2); color: var(--alerta); }
.cab-votos { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 6.5em 36px; gap: 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.totais-cargo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* ---------- Seções ---------- */
#lista-secoes { columns: 3 340px; column-gap: 16px; }
#lista-secoes > * { break-inside: avoid; margin-bottom: 18px; }
#lista-secoes .locais-grade { grid-template-columns: minmax(0, 1fr); }
.lider-mob { display: none; font-size: .78rem; color: var(--muted); font-weight: 400; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.campo-busca { flex: 1 1 200px; }
.legenda-chips { display: flex; gap: 12px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.legenda-chips span { display: inline-flex; align-items: center; gap: 5px; }
.legenda-chips .chip-sec { width: 14px; height: 14px; min-width: 0; padding: 0; }
.bairro-bloco { display: flex; flex-direction: column; gap: 8px; }
.bairro-cab { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; border-bottom: 2px solid var(--marca); padding-bottom: 4px; }
.bairro-cab h2 { font-size: 1.4rem; }
.bairro-cab span { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.locais-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.local-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.local-card h3 { font-family: var(--f-corpo); font-size: .88rem; font-weight: 700; letter-spacing: 0; }
.local-card p { font-size: .8rem; color: var(--muted); }
.secoes-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-sec {
  position: relative; font-family: var(--f-mono); font-size: .8rem; font-weight: 500; min-width: 3.1em; text-align: center;
  border: 1.5px dashed var(--line); background: none; border-radius: 5px; padding: 3px 5px; cursor: pointer; display: inline-block;
}
.chip-sec.qr { background: var(--confirma); border: 1.5px solid var(--confirma); color: var(--confirma-ink); }
.chip-sec.manual { border: 1.5px solid var(--corrige); color: var(--corrige); background: var(--aviso-fundo); }
.chip-sec.alerta::after { content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--alerta); border: 1.5px solid var(--surface); }

/* ---------- Sala de cinema: seções como assentos ---------- */
.sala { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 2px; }
.tela { width: 86%; text-align: center; border-top: 4px solid var(--marca); border-radius: 50% 50% 0 0 / 12px 12px 0 0; padding-top: 6px; box-shadow: 0 -6px 14px -8px color-mix(in srgb, var(--marca) 70%, transparent); }
.tela span { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.fileiras { display: flex; flex-direction: column; gap: 7px; align-items: center; max-width: 100%; }
.fileira { display: flex; align-items: center; gap: 6px; }
.fila { width: 1em; text-align: center; font: 600 .66rem var(--f-mono); color: var(--muted); }
.corredor { width: 10px; flex: none; }
.assento {
  position: relative; width: 2.9em; height: 2.55em; flex: none; cursor: pointer; padding: 0 0 .3em;
  font: 600 .74rem/1 var(--f-mono); font-variant-numeric: tabular-nums; color: var(--muted);
  background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--muted) 55%, transparent);
  border-radius: .75em .75em .3em .3em; /* encosto arredondado */
  box-shadow: inset 0 -.38em 0 color-mix(in srgb, var(--muted) 18%, transparent); /* almofada do assento */
  transition: transform .12s ease;
}
.assento:hover { transform: translateY(-2px); border-color: var(--marca); color: var(--marca); }
.assento.qr { background: var(--confirma); border-color: var(--confirma); color: var(--confirma-ink); box-shadow: inset 0 -.38em 0 rgba(0, 0, 0, .18); }
.assento.manual { background: var(--corrige); border-color: var(--corrige); color: #fff; box-shadow: inset 0 -.38em 0 rgba(0, 0, 0, .18); }
.assento.qr:hover, .assento.manual:hover { color: #fff; filter: brightness(1.08); }
.assento.alerta::after { content: ""; position: absolute; top: -4px; right: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--alerta); border: 1.5px solid var(--surface); }
.assento.apagado { opacity: .22; }
.legenda-chips .assento { width: 18px; height: 15px; font-size: 0; padding: 0; pointer-events: none; }
@media (max-width: 400px) { .assento { width: 2.6em; height: 2.35em; font-size: .7rem; } .fileira { gap: 4px; } }

/* ---------- Mapa dos locais ---------- */
.mapa-cartao { margin-bottom: 18px; }
/* isolation: os z-index internos do Leaflet não passam por cima do cabeçalho e da barra de abas */
.mapa { height: clamp(320px, 58vh, 520px); border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); position: relative; z-index: 0; isolation: isolate; }
.mapa .leaflet-container, .mapa.leaflet-container { font: inherit; background: var(--surface-2); }
.pino-ancora { background: none; border: 0; }
.pino {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; cursor: pointer;
  font: 600 .78rem/1 var(--f-mono); padding: 4px 6px; border-radius: 999px; border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.pino.completo { background: var(--confirma); color: var(--confirma-ink); }
.pino.parcial { background: var(--corrige); color: #fff; }
.pino.pendente { background: var(--surface); color: var(--ink); border-color: var(--muted); }
.pino.aprox { border-style: dashed; }
.pino-leg { display: inline-block; width: 18px; height: 12px; border-radius: 999px; border: 2px solid var(--muted); }
.pino-leg.completo { background: var(--confirma); border-color: var(--confirma); }
.pino-leg.parcial { background: var(--corrige); border-color: var(--corrige); }
.pino-leg.pendente { background: var(--surface); }
.pino-leg.aprox { border-style: dashed; }
.pop { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; }
.pop b { font-size: .88rem; }
.pop .secoes-chips { margin-top: 4px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: 12px 14px; }
.secoes-chips.em-linha { display: inline-flex; vertical-align: middle; }
#mapa-nota { line-height: 1.8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .marca-logo.claro { display: none; } :root:not([data-theme="light"]) .marca-logo.escuro { display: block; } }
:root[data-theme="dark"] .marca-logo.claro { display: none; }
:root[data-theme="dark"] .marca-logo.escuro { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mapa .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }
:root[data-theme="dark"] .mapa .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }

/* ---------- Ajustes ---------- */
.grade-ajustes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.passos { margin: 0; padding-left: 20px; font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.url-box { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.url-box code { flex: 1 1 240px; min-width: 0; font-family: var(--f-mono); font-size: .78rem; background: var(--papel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow-wrap: anywhere; user-select: all; }
.mais summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.mais[open] summary { margin-bottom: 10px; }
.mais form + form { margin-top: 10px; }
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 99px; padding: 4px 6px 4px 10px; font-size: .85rem; }
.tags button { border: 0; background: none; cursor: pointer; color: var(--muted); border-radius: 50%; width: 22px; height: 22px; }
.lista-simples { margin: 0; padding-left: 18px; font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Diálogos ---------- */
.dialogo { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.dialogo-largo { width: min(760px, calc(100vw - 24px)); }
.dialogo::backdrop { background: rgba(10, 14, 12, .5); }
.dialogo form, .dialogo > div { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.det-cargos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.det-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 14px; font-size: .85rem; margin: 0; }
.det-meta dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.det-meta dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.qr-bruto { font-family: var(--f-mono); font-size: .72rem; max-height: 220px; overflow: auto; background: var(--papel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: .9rem; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast.erro { background: var(--alerta); color: #fff; }

/* ---------- Responsivo ---------- */
@media (max-width: 960px) {
  .grade-painel, .lanc-grade { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .abas {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); justify-content: space-around; max-width: none;
  }
  .abas button { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 4px; border-bottom: 0; border-top: 3px solid transparent; flex: 1; }
  .abas button[aria-current="page"] { border-top-color: var(--marca); border-bottom-color: transparent; }
  .abas svg { width: 22px; height: 22px; }
  .topo-in { padding-block: 8px; flex-wrap: nowrap; }
  .topo-acoes { flex-wrap: nowrap; gap: 6px; }
  .seg .txt-turno { display: none; }
  .seg button { padding: 5px 8px; }
  .usuario { max-width: 96px; padding: 5px 9px; }
  .marca-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .marca-logo { height: 34px; }
  .marca-txt { display: none; }
  .tab-bairros { min-width: 0; }
  .tab-bairros th:last-child, .tab-bairros td:last-child { display: none; }
  .tab-bairros td, .tab-bairros th { padding: 7px 4px; }
  .apur { min-width: 0; }
  .apur .trilho { display: none; }
  .pct { min-width: 0; }
  .pct .barra-trilho { display: none; }
  .pct b { min-width: 0; }
  .marca-tit { font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lider-mob { display: block; max-width: 38vw; }
  .tab-bairros th { white-space: normal; font-size: .64rem; letter-spacing: .04em; }
  .tabela-rolagem { margin-inline: -8px; padding-inline: 8px; }
  .ao-vivo #ao-vivo-txt { display: none; }
  .kpi-val { font-size: 1.6rem; }
  .linha-voto, .cab-votos { grid-template-columns: 4.8em minmax(0, 1fr) 5.4em 32px; }
  .totais-cargo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
