:root {
  --azul: #1e3a8a;
  --azul-claro: #2563eb;
  --verde: #16a34a;
  --amarelo: #eab308;
  --laranja: #f97316;
  --vermelho: #dc2626;
  --cinza: #64748b;
  --fundo: #f1f5f9;
  --card: #ffffff;
  --borda: #e2e8f0;
  --texto: #0f172a;
  --texto-suave: #64748b;
  --sombra: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --raio: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--azul-claro); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* ---------------- Login / cadastro ---------------- */
.tela-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  padding: 20px;
}
.card-auth {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
}
.card-auth h1 { font-size: 22px; margin-bottom: 4px; color: var(--azul); }
.card-auth .sub { color: var(--texto-suave); font-size: 14px; margin-bottom: 24px; }

.campo { margin-bottom: 16px; }
.campo label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.linha-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--azul-claro); color: #fff; border: none;
  padding: 11px 18px; border-radius: 8px; font-size: 15px; font-weight: 600;
  transition: filter .15s;
}
.btn:hover { filter: brightness(.94); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-bloco { width: 100%; }
.btn-sec { background: #fff; color: var(--azul-claro); border: 1px solid var(--borda); }
.btn-sec:hover { background: #f8fafc; }
.btn-perigo { background: var(--vermelho); }
.btn-mini { padding: 6px 10px; font-size: 13px; border-radius: 6px; }

.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.msg-erro { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.msg-ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ---------------- App shell ---------------- */
.app { display: none; min-height: 100vh; }
.topo {
  background: var(--azul);
  color: #fff;
  padding: 0 20px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topo .marca { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topo .marca small { font-weight: 400; opacity: .7; font-size: 12px; }
.topo .usuario { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topo .usuario button { background: rgba(255, 255, 255, .15); color: #fff; border: none; padding: 7px 12px; border-radius: 6px; font-size: 13px; }

.layout { display: flex; }
.menu {
  width: 220px; background: var(--card); border-right: 1px solid var(--borda);
  min-height: calc(100vh - 58px); padding: 16px 12px; flex-shrink: 0;
}
.menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: #334155; font-size: 14px; font-weight: 500;
  margin-bottom: 2px;
}
.menu a:hover { background: #f1f5f9; }
.menu a.ativo { background: #eff6ff; color: var(--azul-claro); }
.menu a .ic { width: 18px; text-align: center; }

.conteudo { flex: 1; padding: 24px; max-width: 1200px; }
.conteudo h2 { font-size: 22px; margin-bottom: 4px; }
.conteudo .desc { color: var(--texto-suave); margin-bottom: 20px; font-size: 14px; }

/* ---------------- Cards / KPIs ---------------- */
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px 18px; box-shadow: var(--sombra); }
.kpi .rot { font-size: 13px; color: var(--texto-suave); margin-bottom: 6px; }
.kpi .val { font-size: 28px; font-weight: 700; }
.kpi .val small { font-size: 14px; font-weight: 500; color: var(--texto-suave); }
.kpi.azul .val { color: var(--azul-claro); }
.kpi.verde .val { color: var(--verde); }
.kpi.laranja .val { color: var(--laranja); }

.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 20px; box-shadow: var(--sombra); margin-bottom: 20px; }
.card h3 { font-size: 16px; margin-bottom: 14px; }

/* Barra de progresso */
.progresso { background: #e2e8f0; border-radius: 999px; height: 22px; overflow: hidden; position: relative; }
.progresso > span { display: block; height: 100%; background: linear-gradient(90deg, #16a34a, #22c55e); transition: width .5s; }
.progresso.grande { height: 28px; }
.progresso-rotulo { text-align: center; font-size: 13px; margin-top: 6px; color: var(--texto-suave); }

/* ---------------- Tabelas ---------------- */
.tabela-wrap { overflow-x: auto; border-radius: var(--raio); border: 1px solid var(--borda); }
table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--borda); white-space: nowrap; }
th { background: #f8fafc; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--texto-suave); }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-sim { background: #dcfce7; color: #15803d; }
.badge-nao { background: #fee2e2; color: #b91c1c; }
.badge-indeciso { background: #fef9c3; color: #a16207; }
.badge-ativo { background: #dcfce7; color: #15803d; }
.badge-bloqueado { background: #fee2e2; color: #b91c1c; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.pill .ponto { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------------- Barra de ações / filtros ---------------- */
.barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.barra input, .barra select { padding: 8px 10px; border: 1px solid var(--borda); border-radius: 8px; font-size: 14px; background: #fff; }
.barra .cresce { flex: 1; min-width: 160px; }
.espaco { flex: 1; }

/* ---------------- Alertas ---------------- */
.alerta { padding: 12px 14px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.alerta-sucesso { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alerta-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alerta-aviso { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* ---------------- Mapa ---------------- */
.mapa-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
#mapa-svg { width: 100%; height: auto; background: #f8fafc; border-radius: var(--raio); border: 1px solid var(--borda); }
#mapa-svg path { stroke: #fff; stroke-width: .5; cursor: pointer; transition: opacity .15s; }
#mapa-svg path:hover { opacity: .75; stroke: #0f172a; stroke-width: 1; }
.legenda { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; height: fit-content; box-shadow: var(--sombra); }
.legenda h4 { font-size: 14px; margin-bottom: 12px; }
.legenda .item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.legenda .cx { width: 16px; height: 16px; border-radius: 4px; }
.detalhe-mun { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--borda); }
.detalhe-mun.vazio { color: var(--texto-suave); font-size: 13px; }
.detalhe-mun h4 { font-size: 15px; margin-bottom: 8px; }
.detalhe-mun .lin { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }

/* ---------------- Grade de municípios ---------------- */
.grade-mun { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mun-chip { padding: 10px 12px; border-radius: 8px; color: #fff; font-size: 13px; cursor: pointer; box-shadow: var(--sombra); }
.mun-chip .n { font-weight: 600; display: block; }
.mun-chip .p { font-size: 12px; opacity: .9; }

/* ---------------- Modal ---------------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h3 { margin-bottom: 16px; font-size: 18px; }
.modal .rodape { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.acoes-linha { display: flex; gap: 6px; }

.vazio-estado { text-align: center; padding: 40px; color: var(--texto-suave); }

.spinner { text-align: center; padding: 30px; color: var(--texto-suave); }

/* Ranking pos */
.pos { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: #e2e8f0; color: #334155; font-weight: 700; font-size: 12px; align-items: center; justify-content: center; }
.pos.ouro { background: #fde68a; color: #92400e; }
.pos.prata { background: #e2e8f0; color: #475569; }
.pos.bronze { background: #fed7aa; color: #9a3412; }

/* ---------------- Responsivo ---------------- */
.menu-toggle { display: none; background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 20px; padding: 4px 10px; border-radius: 6px; }
@media (max-width: 860px) {
  .menu { position: fixed; left: 0; top: 58px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .menu.aberto { transform: translateX(0); }
  .menu-toggle { display: block; }
  .conteudo { padding: 16px; }
  .mapa-wrap { grid-template-columns: 1fr; }
  .linha-2 { grid-template-columns: 1fr; }
}
