/* GeoVoto — folha de estilo única, sem build. */

:root {
  --azul: #2563eb;
  --azul-escuro: #1e3a8a;
  --texto: #0f172a;
  --texto-suave: #475569;
  --borda: #e2e8f0;
  --fundo: #f8fafc;
  --branco: #fff;
  --verde: #16a34a;
  --ambar: #d97706;
  --vermelho: #dc2626;
  --raio: 8px;
  --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

/* O atributo `hidden` é o que o app.js usa para trocar entre a tela de login e
   a aplicação. O `[hidden] { display: none }` do navegador é regra de
   user-agent, e QUALQUER regra de autor a vence — inclusive
   `.tela-login { display: grid }` logo abaixo. Sem este !important, a tela de
   login continua ocupando a viewport (min-height: 100vh) depois do login
   e o app fica renderizado fora do campo de visão. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--fundo);
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: .95rem; margin-top: 1.25rem; }
code { background: #f1f5f9; padding: .1rem .3rem; border-radius: 4px; font-size: .9em; }

/* --- Login ---------------------------------------------------------------- */

.tela-login {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  padding: 1rem;
}
.cartao-login {
  background: var(--branco); padding: 2.5rem; border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .2); width: min(24rem, 100%);
}
.cartao-login h1 { color: var(--azul-escuro); margin-bottom: .25rem; }
.cartao-login .sub { color: var(--texto-suave); font-size: .875rem; margin: 0 0 1.5rem; }
.cartao-login label { display: block; font-weight: 600; margin: 1rem 0 .3rem; font-size: .875rem; }
.cartao-login input {
  width: 100%; padding: .65rem; border: 1px solid #cbd5e1;
  border-radius: var(--raio); font-size: 1rem;
}
.cartao-login button {
  width: 100%; margin-top: 1.5rem; padding: .75rem; background: var(--azul);
  color: #fff; border: 0; border-radius: var(--raio); font-size: 1rem;
  font-weight: 600; cursor: pointer;
}
.cartao-login button:hover { background: var(--azul-escuro); }

/* --- Estrutura ------------------------------------------------------------ */

.topo {
  display: flex; align-items: center; gap: 1.5rem; padding: 0 1.25rem;
  background: var(--branco); border-bottom: 1px solid var(--borda);
  position: sticky; top: 0; z-index: 500; min-height: 3.5rem; flex-wrap: wrap;
}
.marca { font-weight: 700; color: var(--azul-escuro); font-size: 1.1rem; }

#menu { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
#menu a {
  padding: .5rem .75rem; color: var(--texto-suave); text-decoration: none;
  border-radius: var(--raio); font-size: .9rem;
}
#menu a:hover { background: var(--fundo); color: var(--texto); }
#menu a.ativo { background: #eff6ff; color: var(--azul); font-weight: 600; }

.usuario { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.etiqueta {
  background: var(--fundo); border: 1px solid var(--borda); padding: .1rem .5rem;
  border-radius: 999px; font-size: .75rem; color: var(--texto-suave);
}

main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.cabecalho-secao {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.ferramentas { display: flex; gap: .5rem; align-items: center; }

/* --- Botões --------------------------------------------------------------- */

button { font: inherit; }
.primario {
  background: var(--azul); color: #fff; border: 0; padding: .55rem 1.1rem;
  border-radius: var(--raio); cursor: pointer; font-weight: 600;
}
.primario:hover { background: var(--azul-escuro); }
.link {
  background: none; border: 0; color: var(--azul); cursor: pointer;
  padding: .25rem .4rem; font-size: .875rem; border-radius: 4px;
}
.link:hover { background: #eff6ff; }
.link.perigo { color: var(--vermelho); }
.link.perigo:hover { background: #fef2f2; }

input[type="search"], input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"],
select, textarea {
  padding: .5rem; border: 1px solid #cbd5e1; border-radius: var(--raio);
  font: inherit; background: var(--branco); max-width: 100%;
}
input[type="range"] { width: 100%; }

/* --- Cartões e painéis ---------------------------------------------------- */

.cartoes {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.cartao {
  background: var(--branco); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: 1.1rem; box-shadow: var(--sombra);
  display: flex; flex-direction: column; gap: .2rem;
}
.cartao-valor { font-size: 1.9rem; font-weight: 700; color: var(--azul-escuro); }
.cartao-rotulo { font-size: .8rem; color: var(--texto-suave); }

.painel {
  background: var(--branco); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: 1.25rem; box-shadow: var(--sombra);
  margin-bottom: 1.5rem;
}
.painel-atencao { border-left: 4px solid var(--ambar); }
.painel-ok {
  background: #f0fdf4; border-left: 4px solid var(--verde);
  padding: .8rem 1rem; border-radius: var(--raio); margin-bottom: 1.5rem;
  font-size: .9rem;
}
.colunas { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.5rem; }

.nota, .dica {
  font-size: .8rem; color: var(--texto-suave); line-height: 1.45;
  display: block; margin-top: .4rem;
}
.aviso-forte { color: #92400e; }
.vazio, .carregando { color: var(--texto-suave); font-style: italic; }
.contagem { font-size: .85rem; color: var(--texto-suave); margin: 0 0 .75rem; }

/* --- Tabelas -------------------------------------------------------------- */

.tabela-rolagem { overflow-x: auto; }
.tabela {
  width: 100%; border-collapse: collapse; background: var(--branco);
  border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden;
}
.tabela th, .tabela td {
  padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--borda);
  font-size: .875rem; vertical-align: top;
}
.tabela th { background: var(--fundo); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: #fafbfc; }
.tabela.compacta th, .tabela.compacta td { padding: .4rem .6rem; }
.acoes-linha { white-space: nowrap; text-align: right; }
.amostra-cor {
  display: inline-block; width: .85rem; height: .85rem; border-radius: 3px;
  vertical-align: middle; border: 1px solid var(--borda);
}

/* --- Barras (painel) ------------------------------------------------------ */

.barras { list-style: none; padding: 0; margin: 0; }
.barras li { margin-bottom: .8rem; }
.barra-topo { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .25rem; }
.barra { height: .5rem; background: var(--fundo); border-radius: 999px; overflow: hidden; }
.barra-preenchida { height: 100%; border-radius: 999px; }
.chave {
  display: inline-block; width: .7rem; height: .7rem; border-radius: 3px;
  margin-right: .4rem; vertical-align: middle;
}

/* --- Faixas de aviso ------------------------------------------------------ */

.faixa-lgpd {
  background: #fffbeb; border-left: 4px solid var(--ambar);
  padding: .75rem 1rem; border-radius: var(--raio); margin: 1rem 0; font-size: .85rem;
}
.faixa-info {
  background: #eff6ff; border-left: 4px solid var(--azul);
  padding: .75rem 1rem; border-radius: var(--raio); margin-bottom: 1.5rem; font-size: .875rem;
}
.erro-bloco {
  background: #fef2f2; border-left: 4px solid var(--vermelho);
  padding: 1rem; border-radius: var(--raio);
}
.erro-inline { color: var(--vermelho); font-size: .85rem; margin: .5rem 0 0; }
.obrigatorio { color: var(--vermelho); }

/* Advertências metodológicas — o §9 na tela. */
.avisos-metodo {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--raio);
  padding: .75rem 1rem; margin: 1rem 0; font-size: .85rem;
}
.avisos-metodo summary { cursor: pointer; font-weight: 600; color: #92400e; }
.avisos-metodo ul { margin: .6rem 0 0; padding-left: 1.2rem; }
.avisos-metodo li { margin-bottom: .4rem; }
.avisos-metodo p { margin: .6rem 0 0; }

.fonte {
  font-size: .78rem; color: var(--texto-suave); margin: .75rem 0 0;
  padding-top: .5rem; border-top: 1px solid var(--borda);
}

/* --- Avisos flutuantes ---------------------------------------------------- */

.avisos {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 2000;
  display: flex; flex-direction: column; gap: .5rem; max-width: 26rem;
}
.aviso {
  background: var(--branco); border-left: 4px solid var(--azul);
  border-radius: var(--raio); padding: .75rem 1rem; box-shadow: 0 4px 12px rgba(0,0,0,.15);
  display: flex; gap: .75rem; align-items: flex-start; font-size: .875rem;
}
.aviso-sucesso { border-left-color: var(--verde); }
.aviso-alerta  { border-left-color: var(--ambar); }
.aviso-erro    { border-left-color: var(--vermelho); }
.aviso .fechar { background: none; border: 0; cursor: pointer; font-size: 1.2rem; line-height: 1; color: var(--texto-suave); }

/* --- Modal / formulário --------------------------------------------------- */

.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: grid; place-items: center; z-index: 1500; padding: 1rem;
}
.modal-caixa {
  background: var(--branco); border-radius: 12px; padding: 1.5rem;
  width: min(46rem, 100%); max-height: 90vh; overflow-y: auto;
}
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.campo { display: flex; flex-direction: column; }
.campo label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.campo-texto_longo, .campo-geo { grid-column: 1 / -1; }
.campo .caixa { font-weight: 400; display: flex; align-items: center; gap: .4rem; }
.modal-rodape {
  display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem;
  padding-top: 1rem; border-top: 1px solid var(--borda);
}

.linha-geo { display: flex; gap: .5rem; flex-wrap: wrap; }
.linha-geo input { flex: 1; min-width: 8rem; }
.linha-geo button {
  background: var(--fundo); border: 1px solid #cbd5e1; border-radius: var(--raio);
  padding: .5rem .8rem; cursor: pointer; white-space: nowrap;
}
.mini-mapa { height: 220px; border-radius: var(--raio); margin: .6rem 0; border: 1px solid var(--borda); }

.geo-resultado { border: 1px solid var(--borda); border-radius: var(--raio); padding: .8rem; margin-top: .6rem; }
.geo-ok      { border-left: 4px solid var(--verde); }
.geo-alerta  { border-left: 4px solid var(--ambar); }
.geo-erro    { border-left: 4px solid var(--vermelho); }
.geo-rotulo  { font-size: .8rem; color: var(--texto-suave); }
.geo-explicacao { font-size: .85rem; }
.geo-conferencia { font-weight: 600; font-size: .85rem; }

/* --- Mapa ----------------------------------------------------------------- */

.mapa-layout { display: grid; grid-template-columns: 18rem 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .mapa-layout { grid-template-columns: 1fr; } }

.painel-controles {
  background: var(--branco); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: 1rem; box-shadow: var(--sombra);
  position: sticky; top: 4.5rem; max-height: calc(100vh - 6rem); overflow-y: auto;
}
.grupo-controle { margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--borda); }
.grupo-controle:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.grupo-controle > label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .4rem; }
.grupo-controle select { width: 100%; }
.grupo-controle .caixa { font-weight: 400; display: flex; align-items: center; gap: .5rem; margin: .35rem 0; font-size: .875rem; }

.area-mapa { background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; }
.mapa { height: 70vh; min-height: 480px; }

.legenda {
  background: rgba(255,255,255,.95); padding: .7rem .85rem; border-radius: var(--raio);
  box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: .8rem; line-height: 1.5; max-width: 15rem;
}
.legenda .unidade { display: block; color: var(--texto-suave); font-size: .75rem; }
.legenda ul { list-style: none; margin: .5rem 0 0; padding: 0; }
.legenda .gradiente { height: .6rem; border-radius: 3px; margin: .5rem 0 .25rem; }
.legenda .gradiente-rotulos { display: flex; justify-content: space-between; font-size: .7rem; color: var(--texto-suave); }

.pop-alerta {
  background: #fffbeb; border-left: 3px solid var(--ambar);
  padding: .4rem .5rem; margin: .5rem 0 0; font-size: .78rem; border-radius: 3px;
}
.pop-valor { font-size: 1.2rem; font-weight: 700; color: var(--azul-escuro); }

.meta-arquivo { font-size: .85rem; color: var(--texto-suave); }

/* --- Impressão: o Ctrl+P precisa gerar algo utilizável -------------------- */

@media print {
  .topo, .painel-controles, .ferramentas, .avisos { display: none !important; }
  main { padding: 0; }
  .area-mapa { border: 0; }
  .mapa { height: 60vh; }
  .avisos-metodo { break-inside: avoid; }
}
