:root {
  /* Identidade laranja — tom leve como identidade e destaque, não como
     preenchimento predominante. Vive no menu lateral, na barra superior e nos
     elementos de ação/indicador (botões, badges de estado, links, barras de
     progresso). Áreas de conteúdo — cards, tabelas, formulários, modais —
     ficam claras e neutras, garantindo contraste e uma interface limpa. */
  --teal: #cc6a1e;                 /* accent laranja — preenchimento de botões/badges/indicadores */
  --teal-dark: #7a3e12;            /* laranja profundo — texto de título/legend sobre fundo claro */
  --teal-light: #fbdcb0;           /* tingido claro do laranja — fundo de badges/foco */
  --accent-on: #ffffff;            /* texto claro sobre fundo cheio do accent (botão laranja, etc.) */

  --sidebar-bg: #fbf0e4;           /* menu lateral e barra superior — laranja bem leve, não cinza chapado */
  --sidebar-bg-2: #f5dfc4;         /* variação leve p/ hover dentro do menu/barra */

  --bg: #f4f7f7;                   /* fundo da área de conteúdo — claro e neutro */
  --card-bg: #ffffff;              /* cards, tabelas, modais, formulários — sempre claros */
  --border: #e3e8e8;
  --text: #1f2b2a;
  --text-muted: #647372;

  --danger: #c0392b;
  --danger-bg: #fdecea;
  --warning: #b8860b;
  --warning-bg: #fff6e0;
  --track: #eef2f2;

  --sidebar-w: 232px;
  --sidebar-w-collapsed: 68px;
  --radius: 12px;

  --font-title: 'Archivo', system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-title);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar — preenchimento cheio do laranja de destaque, mas com 30% menos
   saturação que o --teal usado em botões/badges (cor própria, não a
   variável, pra não escurecer o resto do app junto) — menos vívido pra uma
   área tão grande da tela. Só a barra vertical: a barra superior de título
   (.topbar) continua no --sidebar-bg leve, cor à parte. */
.sidebar {
  width: var(--sidebar-w);
  background: #b36d39;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .15s ease;
  overflow: hidden;
  border-right: none;
}

.sidebar-brand {
  padding: 22px 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
  color: #ffffff;
}
.sidebar-brand .brand-mark { display: none; }

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}

.nav-item svg { width: 18px; height: 18px; opacity: .85; flex-shrink: 0; }

.nav-item:hover { background: rgba(255,255,255,0.14); color: #ffffff; }

.nav-item.active {
  background: #ffffff;
  color: var(--teal-dark);
}
.nav-item.active svg { opacity: 1; }

/* Item de menu desativado — visível (não removido do menu), mas sem link,
   sem hover de destaque e com uma tag deixando claro que está inativo. */
.nav-item.disabled { color: rgba(255,255,255,0.4); cursor: not-allowed; }
.nav-item.disabled svg { opacity: .4; }
.nav-item.disabled:hover { background: none; color: rgba(255,255,255,0.4); }
.nav-item-tag {
  margin-left: auto; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.35); border-radius: 4px; padding: 1px 5px;
  flex-shrink: 0;
}
html.sidebar-collapsed .nav-item-tag { display: none; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 4px auto 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.2); }
.sidebar-toggle svg { width: 16px; height: 16px; transition: transform .15s ease; }

.sidebar-footer {
  padding: 14px 20px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  border-top: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Versão do sistema — centralizada, acima do selo de ambiente. O tooltip
   (passar o mouse) mostra a versão completa com data/hora exata do deploy. */
.sidebar-version {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgba(255,255,255,0.85);
  cursor: default;
}

/* Selo de ambiente (Produção/Desenvolvimento) — bem mais chamativo que o
   texto discreto de versão, de propósito: DEV e PRD podem ter dados
   idênticos (ex.: logo depois de um dump PRD->DEV), então é fácil confundir
   em qual ambiente se está sem um sinal visual forte. Vermelho = cuidado,
   dado real; verde = à vontade, é sandbox — convenção já conhecida. */
.env-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.env-badge-producao { background: var(--danger); color: #fff; }
.env-badge-dev { background: var(--cor-rede); color: #fff; }

/* Sidebar collapsed state */
html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
html.sidebar-collapsed .sidebar-brand { padding: 22px 0; text-align: center; }
html.sidebar-collapsed .sidebar-brand .brand-full { display: none; }
html.sidebar-collapsed .sidebar-brand .brand-mark { display: inline; }
html.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
html.sidebar-collapsed .nav-label { display: none; }
html.sidebar-collapsed .sidebar-footer { text-align: center; padding: 14px 6px; }
html.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* Abaixo de 880px o menu lateral recolhe automaticamente para a faixa só de
   ícones (mesmo visual do recolhimento manual) — libera espaço de conteúdo
   em tablet/celular sem depender do usuário lembrar de recolher primeiro.
   O botão de expandir/recolher some aqui porque, nessa largura, teria efeito
   nenhum (a media query manda de volta pro recolhido de qualquer forma). */
@media (max-width: 880px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar-brand { padding: 22px 0; text-align: center; }
  .sidebar-brand .brand-full { display: none; }
  .sidebar-brand .brand-mark { display: inline; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-label { display: none; }
  .sidebar-footer { text-align: center; padding: 14px 6px; }
  .sidebar-toggle { display: none; }
}

/* Sidebar nav groups — blocos expansíveis */
.nav-group { margin-bottom: 2px; }

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.nav-group-header:hover { background: rgba(255,255,255,0.14); color: #ffffff; }

.nav-group-icon { display: flex; flex-shrink: 0; opacity: .8; }
.nav-group-icon svg { width: 13px; height: 13px; }

.nav-group-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-group-chevron { display: flex; flex-shrink: 0; opacity: .8; }
.nav-group-chevron svg { width: 13px; height: 13px; transition: transform .15s ease; }
.nav-group.open .nav-group-chevron svg { transform: rotate(90deg); }

.nav-group-items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .18s ease;
}
.nav-group-items-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}
.nav-group.open .nav-group-items { grid-template-rows: 1fr; }

.nav-group-items-inner .nav-item { padding-left: 34px; }

html.sidebar-collapsed .nav-group-header { display: none; }
html.sidebar-collapsed .nav-group-items { grid-template-rows: 1fr !important; }
html.sidebar-collapsed .nav-group-items-inner .nav-item { padding: 10px; }

@media (max-width: 880px) {
  .nav-group-header { display: none; }
  .nav-group-items { grid-template-rows: 1fr !important; }
  .nav-group-items-inner .nav-item { padding: 10px; }
}

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }

/* Barra superior — mesmo cinza leve do menu lateral, formando o "chrome" da
   aplicação sem pesar visualmente; laranja só aparece nos elementos de ação. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 28px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 600px) {
  .topbar { padding: 14px 16px; }
  .content { padding: 16px; }
}

.topbar h1 { font-size: 19px; margin: 0; color: var(--text); }
.page-desc { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Indicador leve do usuário logado, no canto superior direito — só o avatar
   (inicial do nome) e o botão de Sair ficam visíveis por padrão; Cliente e
   Login só aparecem no painel que abre ao clicar no avatar, mesmo padrão do
   painel de período do Dashboard. O nome/papel completo vira tooltip nativo
   (passar o mouse) em vez de ocupar espaço fixo na barra. */
.topbar-account-group { display: flex; align-items: center; gap: 8px; }
.topbar-account-wrap { position: relative; }
.topbar-account-trigger {
  display: flex; align-items: center; justify-content: center; padding: 2px;
  border: 1px solid transparent; border-radius: 50%; background: transparent; cursor: pointer;
}
.topbar-account-trigger:hover { border-color: var(--border); background: var(--sidebar-bg-2); }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--teal); color: var(--accent-on);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.topbar-account-menu {
  position: absolute; z-index: 30; top: 100%; right: 0; margin-top: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: 12px; flex-direction: column; gap: 8px; width: 230px;
}
.topbar-account-menu-row { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; }
.topbar-account-menu-row span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.topbar-account-menu-row strong { color: var(--text); font-weight: 600; word-break: break-word; }

.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.content { padding: 24px 28px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.pagination-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagination-pages { font-size: 12.5px; color: var(--text-muted); font-weight: 600; font-family: var(--font-mono); }
.pagination-per-page { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.pagination-per-page select { padding: 5px 8px; font-size: 12.5px; width: auto; }
.btn.disabled, .btn:disabled { opacity: .45; pointer-events: none; }

/* Cards — superfície clara e neutra, nunca verde. */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card + .card { margin-top: 18px; }

/* align-items:stretch já é o padrão do Grid, mas fica explícito de propósito —
   cards na mesma linha de qualquer .grid (Dashboard, Eleições, etc.)
   sempre esticam para a altura do maior vizinho, nunca ficam com alturas
   diferentes entre si. O "+ .card" acima é pensado para cards empilhados fora
   de um grid — dentro de um .grid o gap já cuida do espaçamento, então essa
   margem precisa ser zerada aqui, senão todo card menos o primeiro da linha
   nasce empurrado 18px pra baixo e a linha para de estar alinhada no topo. */
.grid { display: grid; gap: 16px; align-items: stretch; }
.grid > .card { margin-top: 0; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .grid-4, .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-4, .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Cards de indicador — mesmo tamanho/altura sempre, independente do conteúdo
   (rótulo curto ou longo, número pequeno ou nome de candidato) para manter
   a linha de cards visualmente uniforme em qualquer tela que os use. Valor
   neutro por padrão — usar .value.accent só quando o número for de fato o
   dado-chave do bloco (o verde marca o dado importante, não decora tudo). */
.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  min-height: 86px;
}
.stat-card .label {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card .value {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.stat-card .value.accent { color: var(--teal-dark); }
.stat-card .value.warning { color: var(--warning); }

.stat-card-head { display: flex; align-items: center; gap: 10px; }
.stat-icon-bg { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.stat-icon-bg svg { width: 18px; height: 18px; }
.stat-icon-bg.icon-total { background: #dcfce7; color: #16a34a; }
.stat-icon-bg.icon-masc { background: #dbeafe; color: #2563eb; }
.stat-icon-bg.icon-fem { background: #f3e8ff; color: #9333ea; }
.stat-icon-bg.icon-inc { background: #ccfbf1; color: #0d9488; }
.stat-breakdown { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-breakdown .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.stat-breakdown .dot.ativista { background: var(--cor-ativista); }
.stat-breakdown .dot.rede { background: var(--cor-rede); }

/* Identidade Ativista (laranja) / Rede (verde) — usada nos chips selecionados,
   cards e mapa do Dashboard Rede; escopo intencionalmente restrito a esta tela
   (não mexe nos badges de tipo usados em Pessoas/Prospecção, paleta própria). */
:root { --cor-ativista: #e07b1c; --cor-rede: #1f8a3d; --cor-meta: #e07b1c; }

.card-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

/* Botão + painel de período (Cadastro em) — colapsado por padrão no cabeçalho da página. */
.periodo-btn { display: inline-flex; align-items: center; gap: 8px; }
.periodo-btn svg { width: 15px; height: 15px; }
.periodo-wrap { position: relative; }
.periodo-painel {
  position: absolute; z-index: 30; top: 100%; right: 0; margin-top: 6px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: 14px; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; width: 300px;
}

.bairro-chart-vert { display: flex; gap: 8px; margin-top: 10px; }
.bairro-chart-eixo { display: flex; flex-direction: column; justify-content: space-between; font-size: 10.5px; color: var(--text-muted); text-align: right; width: 28px; flex-shrink: 0; height: 200px; }
.bairro-chart-body { flex: 1; min-width: 0; }
.bairro-chart-track { position: relative; height: 200px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; align-items: flex-end; gap: 10px; padding: 0 4px; }
.bairro-chart-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); }
.bairro-chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: pointer; position: relative; z-index: 1; }
.bairro-chart-valor { font-size: 11px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.bairro-chart-barra { width: 60%; max-width: 34px; background: var(--teal-dark); border-radius: 4px 4px 0 0; transition: background .12s ease; }
.bairro-chart-col:hover .bairro-chart-barra, .bairro-chart-col.highlight .bairro-chart-barra { background: var(--teal); }
.bairro-chart-labels { display: flex; gap: 10px; padding: 6px 4px 0; }
.bairro-chart-labels span { flex: 1; min-width: 0; text-align: center; font-size: 10.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Números tabulares em qualquer lugar do sistema (ex.: colunas numéricas de
   tabela alinhadas à direita) — pega inline style="text-align:right" sem
   precisar editar cada template. */
td[style*="text-align:right"], th[style*="text-align:right"] {
  font-variant-numeric: tabular-nums;
}

/* Buttons — o verde-limão aparece aqui de propósito (indicador de ação),
   sempre com texto escuro por cima para manter contraste. Tamanho padrão é o
   mesmo do antigo ".btn.small" (ex.: Excel/PDF) — unificado pra todo botão de
   toolbar/ação de página ficar do mesmo tamanho, em qualquer aba do sistema. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  background: var(--teal);
  color: var(--accent-on);
}
.btn:hover { background: #93e05f; }
.btn.secondary { background: var(--card-bg); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0d5d1; }
.btn.danger:hover { background: var(--danger-bg); }

/* Botão de ação única em página pública (Login, Autocadastro) — maior de
   propósito, pra ter um alvo de toque confortável num formulário mobile-first. */
.btn.large { padding: 11px 16px; font-size: 14px; }

/* Forms — superfícies claras, foco com anel verde discreto. */
label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: var(--font-title);
  background: #fff;
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: #9aa6a5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal-dark); box-shadow: 0 0 0 3px var(--teal-light); }
/* Campo preenchido automaticamente (ex.: UF pelo CEP/endereço) — nunca
   digitado à mão, então não pode parecer um campo comum esperando entrada. */
input[readonly] { background: var(--bg); color: var(--text-muted); cursor: default; }
input[readonly]:focus { box-shadow: none; border-color: var(--border); }
.field { margin-bottom: 14px; }
fieldset { border: none; padding: 0; margin: 0 0 18px 0; }
legend {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--teal-dark);
  margin-bottom: 10px;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* Linha de campos flexível: cada campo declara sua própria largura (ver .field-xs/sm/md
   abaixo) em vez de uma grade de colunas iguais — assim CPF/CEP/UF ficam compactos e
   Nome/Logradouro esticam para aproveitar o espaço que sobra na linha. */
.form-row { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-start; min-width: 0; }
.form-row .field { flex: 1 1 200px; min-width: 0; margin-bottom: 10px; }
.form-row .field-xs { flex: 0 1 90px; min-width: 70px; }
.form-row .field-sm { flex: 0 1 160px; min-width: 110px; }
.form-row .field-md { flex: 0 1 210px; min-width: 140px; }

/* Modal — padrão único reutilizado em qualquer cadastro simples; superfície clara,
   fundo desfocado. Paleta e tipografia própria do modal (Inter + laranja),
   deliberadamente diferente do resto do app (Archivo) — escopada via
   redefinição local das mesmas variáveis (--teal/--border/--text/...) direto no
   `.modal`, então todo componente que já usa var(--teal)/var(--border)/etc. (botão,
   campo, legend, tipo-option, view-toggle) se re-tinge sozinho, sem duplicar regras. */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 22, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding: 3vh 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  --teal: #cc6a1e;
  --teal-dark: #7a3e12;
  --teal-light: #fbdcb0;
  --accent-on: #ffffff;
  --border: #e5e7eb;
  --text: #374151;
  --text-muted: #6b7280;
  --card-bg: #ffffff;
  --radius: 12px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  min-width: 0;
  max-width: 540px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  overflow: hidden;
}
.modal-lg { max-width: 900px; }
.modal-sm { max-width: 420px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 24px 2px; flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; line-height: 1; padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
.modal-desc { color: var(--text-muted); font-size: 12px; margin: 2px 24px 2px; }
.modal form { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.modal-body { overflow-y: auto; overflow-x: hidden; padding: 8px 24px; flex: 1; min-width: 0; min-height: 0; }
/* Formulários largos com poucos campos (ex.: Nova Prospecção) ficavam baixos
   demais, deixando pouco espaço pra lista suspensa de busca abrir antes de
   precisar rolar. Um pouco mais de altura mínima resolve sem tirar a
   compactação dos formulários que já são naturalmente maiores. */
.modal-lg .modal-body { min-height: 340px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 10px 24px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* Dentro do modal: rótulos e campos seguem Inter (não o mono maiúsculo do resto do
   app), campos com altura/raio fixos, botão primário com sombra de foco verde e
   estado desabilitado enquanto o formulário não estiver válido. Espaçamento
   deliberadamente compacto (formulários de modal costumam ter muitos campos) —
   padrão único pra qualquer modal do sistema, não só Pessoa. */
.modal label { font-family: inherit; font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: normal; color: var(--text-muted); margin-bottom: 4px; }
.modal fieldset { margin-bottom: 12px; }
.modal legend {
  font-family: inherit; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: normal;
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding-bottom: 6px; margin-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--teal-dark);
}
.modal legend svg { width: 15px; height: 15px; flex-shrink: 0; }
.modal .field { margin-bottom: 8px; }
.modal .form-row { gap: 8px 12px; }
.modal .form-row .field { margin-bottom: 6px; }
.modal input, .modal select, .modal textarea { font-family: inherit; height: 38px; padding: 8px 12px; border-radius: 8px; font-size: 12px; }
.modal textarea { height: auto; }
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(34,197,94,0.15); }
.modal .btn { height: 38px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.modal .btn:hover { background: #16a34a; }
.modal .btn.secondary:hover { background: #f9fafb; }
.modal .btn[disabled] { opacity: .55; cursor: not-allowed; }
.modal .btn[disabled]:hover { background: var(--teal); }
/* Ícone dentro de campo: envolve só o input (não o label nem texto de status
   abaixo) num wrapper próprio, relativo — assim o ícone fica sempre centralizado
   na altura do input (38px fixos), não importa se o rótulo tem 1 ou 2 linhas
   ou se há um texto de status depois do campo. */
.modal .campo-icone-wrap { position: relative; }
.modal .campo-icone-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-muted); pointer-events: none; }
.modal .campo-icone-wrap input { padding-left: 34px; width: 100%; }
/* Toggle "Buscar por CEP/Endereço" alinhado à mesma altura dos campos (38px) —
   senão o grupo de botões fica mais baixo que o input ao lado na mesma linha,
   com align-items:flex-start do .form-row deixando as bases desencontradas. */
.modal .view-toggle { height: 38px; }
.modal .view-toggle button { height: 100%; padding: 0 14px; font-size: 12px; }

/* Seletor "Tipo de Cadastro" — mesmo padrão compacto do resto do modal. */
.modal .tipo-selector { margin-bottom: 10px; }
.modal .tipo-option { padding: 8px 14px; font-size: 12px; }

/* Type selector */
.tipo-selector { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.tipo-option {
  flex: 1 1 120px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
}
.tipo-option svg.tipo-icon { width: 18px; height: 18px; flex-shrink: 0; }
.tipo-option .tipo-check { display: none; position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; color: var(--teal); }
.tipo-option.selected { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-light); }
.tipo-option.selected .tipo-check { display: block; }

/* Table — superfície clara; nada de fundo verde em linhas/células. O
   cabeçalho (th) é a única exceção: leva um fundo suave (tingido do laranja
   já usado em badges/foco) só para destacar a faixa de títulos das colunas. */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--teal-dark);
  background: var(--teal-light);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 11px; color: var(--text); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--text-muted); }

/* Cabeçalhos de coluna clicáveis para ordenação — mesmo th, só ganha cursor e
   uma seta (▲/▼) indicando a coluna/direção ativa. */
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { background: var(--teal); color: var(--accent-on); }
.th-sort:hover .sort-arrow { color: var(--accent-on); }
.sort-arrow { display: inline-block; font-size: 9px; margin-left: 2px; color: var(--teal-dark); }

/* Mesma ideia, versão link (listagens com round-trip de servidor, macro
   _ordenacao.html) — herda a fonte/cor/tamanho do <th> em vez de parecer um
   link azul solto. */
.th-sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; cursor: pointer; }
th:has(.th-sort-link):hover { background: var(--teal); }
th:has(.th-sort-link):hover .th-sort-link,
th:has(.th-sort-link):hover .sort-arrow { color: var(--accent-on); }

/* Nomes de bairro podem ser longos — quebra em várias linhas em vez de
   empurrar a tabela pra fora do card (que só gera scroll horizontal e some
   com o fim do nome). */
.tabela-bairro-quebra td:first-child {
  white-space: normal;
  word-break: break-word;
  max-width: 220px;
}

/* Tabelas responsivas — abaixo de 720px cada linha vira um card (rótulo em
   cima, valor embaixo — não lado a lado, para não arriscar estourar a
   largura com e-mails/textos longos que não têm onde quebrar). Todo <td> de
   dado real precisa de data-label="..." para o rótulo aparecer; cabeçalhos
   (<thead>) somem, já que a informação migra para o próprio card. */
@media (max-width: 720px) {
  .table-wrap { overflow-x: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 14px;
    margin-bottom: 10px;
    background: var(--card-bg);
  }
  .table-wrap tbody tr:last-child { margin-bottom: 0; }
  .table-wrap td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    text-align: left !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
  }
  .table-wrap .actions-cell { width: 100%; }
}

/* Badges — cada categoria com tom próprio e discreto; só "ativo"/"positivo"
   usa o verde, como indicador de estado (não como decoração geral). */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
}
.badge-administrador { background: #eef1fb; color: #3a4bb0; }
.badge-ativista { background: var(--teal-light); color: var(--teal-dark); }

/* Coluna combinada Tipo+Origem (ex.: listagem de Pessoas) — o tipo vira um
   selo redondo só com a inicial (cores herdadas do .badge-{tipo} já usado),
   e o ícone de origem fica ao lado, tudo numa linha só, poupando duas
   colunas largas por uma estreita. */
.tipo-origem-cell { display: inline-flex; align-items: center; gap: 6px; }
.badge-inicial {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
}
.badge-rede { background: #fff2e2; color: #a5650c; }
.badge-status-ativo { background: #e7f8ec; color: #1f8a3d; }
.badge-status-pendente { background: var(--warning-bg); color: var(--warning); }
.badge-status-inativo { background: var(--danger-bg); color: var(--danger); }

/* Filters bar */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin-bottom: 0; min-width: 160px; flex: 1; }

/* Flash */
.flash { padding: 11px 16px; border-radius: 9px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: #e7f8ec; color: #1f8a3d; }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--teal-light); color: var(--teal-dark); }

/* Toast/snackbar — substitui alert() nativo do navegador por notificação própria
   do sistema, no mesmo padrão de cor das mensagens flash. Empilha no canto
   inferior direito e some sozinho depois de alguns segundos. */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  padding: 12px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 20px rgba(0,0,0,.14);
  opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #e7f8ec; color: #1f8a3d; }
.toast-error { background: var(--danger-bg); color: var(--danger); }
.toast-warning { background: var(--warning-bg); color: var(--warning); }
.toast-info { background: var(--teal-light); color: var(--teal-dark); }

/* Modal de confirmação genérico — substitui confirm() nativo do navegador,
   mesmo padrão visual de .modal/.modal-backdrop já usado pros cadastros. */
#modal-confirmar .modal-body p { margin: 0; color: var(--text); font-size: 14px; line-height: 1.5; }

.actions-cell { display: flex; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: #fff; color: var(--text-muted); }
.icon-btn:hover { background: var(--bg); color: var(--teal-dark); }
.icon-btn svg { width: 15px; height: 15px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { margin: 0; font-size: 20px; color: var(--text); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* Login — o "shell" ao redor do card pode ser verde (é chrome, como o menu),
   mas o card do formulário em si fica claro, como qualquer formulário. */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); padding: 16px; }
.login-card { background: var(--card-bg); border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.login-card h1 { font-size: 20px; margin: 0 0 4px 0; color: var(--teal-dark); }
.login-card p.subtitle { color: var(--text-muted); margin: 0 0 22px 0; font-size: 13px; }

/* Autocadastro público (Link de Cadastro) — mesma "casca" do login, card mais
   largo pra caber o formulário simplificado com folga, mobile-first. */
.autocadastro-card { background: var(--card-bg); border-radius: 16px; padding: 32px 28px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.autocadastro-card h1 { font-size: 19px; margin: 0 0 10px 0; color: var(--teal-dark); }
.autocadastro-card .autocadastro-texto { color: var(--text); font-size: 14px; line-height: 1.55; margin: 0 0 6px 0; text-align: justify; text-justify: inter-word; }
.autocadastro-convidado { display: inline-flex; align-items: center; gap: 8px; background: var(--teal-light); color: var(--teal-dark); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 20px; }
.autocadastro-consent { display: flex; align-items: flex-start; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 20px 0; }
.autocadastro-consent input[type="checkbox"] { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; }
.autocadastro-consent label { text-transform: none; font-family: var(--font-title); font-weight: 400; font-size: 13.5px; color: var(--text); letter-spacing: normal; margin: 0; }
.autocadastro-sucesso { text-align: center; padding: 12px 0; }
.autocadastro-sucesso svg { width: 52px; height: 52px; color: var(--teal); margin-bottom: 14px; }
.autocadastro-sucesso .autocadastro-texto { text-align: center; }

.autocadastro-versiculo { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.autocadastro-sucesso .autocadastro-versiculo-icon { width: 24px; height: 24px; color: var(--teal); margin-bottom: 8px; }
.autocadastro-versiculo-intro { font-size: 12px; color: var(--text-muted); margin: 0 0 10px 0; }
.autocadastro-versiculo-texto { font-size: 15px; font-style: italic; color: var(--teal-dark); font-weight: 600; line-height: 1.5; margin: 0 0 6px 0; }
.autocadastro-versiculo-ref { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin: 0; }

.view-toggle { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.view-toggle button { border: none; background: #fff; padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--text-muted); }
.view-toggle button.active { background: var(--teal); color: var(--accent-on); }

/* Combobox pesquisável — padrão único para campos de busca que selecionam um
   registro de uma lista fechada (ex.: Pesquisar Ativista). A seta deixa
   visualmente claro que existe uma lista antes do usuário digitar; o clique
   em qualquer parte do campo abre a lista completa (ver JS de cada tela). */
.combo-search { position: relative; }
.combo-search input[type="text"] { padding-right: 32px; }
.combo-search .combo-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  display: flex;
}
.combo-search .combo-chevron svg { width: 14px; height: 14px; }

/* Lista de sugestões do combo-search (ativista, candidato, membro da rede
   etc.) — mesmo item em todo o sistema: sem cara de link solto, com
   destaque claro ao passar o mouse e separação entre os registros. */
.combo-dropdown {
  padding: 4px;
  /* A rolagem (roda do mouse) fica contida na própria lista — ao chegar no
     fim das opções, não deve "vazar" e rolar o modal ou a página por trás. */
  overscroll-behavior: contain;
}
.combo-dropdown::-webkit-scrollbar { width: 8px; }
.combo-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.combo-item {
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background-color .12s ease;
}
.combo-item + .combo-item { margin-top: 1px; }
.combo-item:hover, .combo-item.combo-item-ativo { background: var(--teal-light); }
.combo-item .muted { font-weight: 400; }
.combo-item-vazio { padding: 12px 10px; font-size: 12.5px; color: var(--text-muted); }

.wa-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.wa-item:last-child { border-bottom: none; }
.wa-preview-bubble { background: #dcf8c6; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; white-space: pre-wrap; max-width: 320px; }

/* Perfil de detalhe (telas "Visualizar" com foto/iniciais + resumo + dados em
   colunas) — padrão reutilizável para qualquer cadastro com essa necessidade,
   não só Pessoas. */
.perfil-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.perfil-identidade { display: flex; align-items: center; gap: 16px; }
.perfil-avatar {
  width: 68px; height: 68px; border-radius: 50%; flex-shrink: 0;
  background: var(--teal-light); color: var(--teal-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px; font-family: var(--font-title);
}
.perfil-nome-linha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.perfil-nome-linha h2 { margin: 0; font-size: 20px; color: var(--text); }
.perfil-id { display: block; margin-top: 3px; color: var(--text-muted); font-family: var(--font-mono); font-size: 12.5px; }
.perfil-meta { text-align: right; }
.perfil-origem { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--teal-dark); }
.perfil-origem svg { width: 15px; height: 15px; }
.perfil-datas { margin-top: 4px; color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }

.perfil-fatos { display: flex; flex-wrap: wrap; gap: 24px; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.perfil-fato { display: flex; align-items: center; gap: 10px; }
.perfil-fato svg { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.perfil-fato-valor { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.3; }
.perfil-fato-legenda { font-size: 12px; color: var(--text-muted); line-height: 1.3; }

.detalhe-lista { display: flex; flex-direction: column; }
.detalhe-linha { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.detalhe-linha:last-child { border-bottom: none; padding-bottom: 0; }
.detalhe-linha:first-child { padding-top: 0; }
.detalhe-label { color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
.detalhe-valor { font-weight: 600; font-size: 13.5px; color: var(--text); text-align: right; }
.detalhe-valor a { color: var(--teal-dark); }
.detalhe-valor-whatsapp { display: inline-flex; align-items: center; gap: 8px; }
.detalhe-valor-whatsapp svg { width: 18px; height: 18px; color: #1f8a3d; }

.card-titulo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; color: var(--teal-dark); margin-bottom: 14px; }
.card-titulo svg { width: 18px; height: 18px; flex-shrink: 0; }

.info-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; background: var(--teal-light); color: var(--teal-dark); border-radius: var(--radius); padding: 14px 16px; margin-top: 18px; }
.info-banner-corpo { display: flex; align-items: flex-start; gap: 10px; }
.info-banner svg.info-banner-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.info-banner strong { display: block; font-size: 13.5px; }
.info-banner p { margin: 2px 0 0; font-size: 13px; color: var(--teal-dark); opacity: .9; }
.info-banner-fechar { background: none; border: none; color: inherit; cursor: pointer; padding: 2px; line-height: 1; flex-shrink: 0; }
.info-banner-fechar svg { width: 16px; height: 16px; }
