/* ==========================================================================
   InfraCrítica — estilos (identidade visual do GeoRota)
   Tokens → base → painel flutuante → componentes (busca, importação, resumo,
   lista, admin, diálogo, toasts) → Leaflet (controles, popups, legenda) →
   marcadores e áreas → responsivo (bottom sheet) → animações
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --fonte: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --primaria: #2563eb;
  --primaria-forte: #1d4ed8;
  --verde: #16a34a;
  --vermelho: #dc2626;
  --ambar: #f59e0b;

  /* Risco (iguais aos do mapa) */
  --risco-alto: #dc2626;
  --risco-medio: #f59e0b;
  --risco-baixo: #facc15;
  --seguro: #2563eb;
  --inundacao: #0284c7;
  --limite: #334155;

  --fundo: #e9eef5;
  --superficie: rgba(255, 255, 255, 0.84);
  --superficie-solida: #ffffff;
  --superficie-2: #f1f5f9;
  --superficie-3: #e2e8f0;
  --borda: rgba(15, 23, 42, 0.08);
  --borda-forte: rgba(15, 23, 42, 0.16);
  --texto: #0f172a;
  --texto-2: #475569;
  --texto-3: #8a99ad;
  --brilho-skeleton: rgba(255, 255, 255, 0.7);
  --mascara: rgba(15, 23, 42, 0.2);
  --risco-texto: #b91c1c;
  --risco-fundo: rgba(220, 38, 38, 0.09);

  --sombra-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --sombra-2: 0 12px 32px -12px rgba(15, 23, 42, 0.35), 0 4px 12px -4px rgba(15, 23, 42, 0.12);
  --sombra-3: 0 24px 60px -18px rgba(15, 23, 42, 0.45);

  --raio: 16px;
  --raio-m: 12px;
  --raio-p: 8px;
  --painel-largura: 410px;
  --margem: 16px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --foco: 0 0 0 3px rgba(37, 99, 235, 0.45);

  color-scheme: light;
}

[data-tema="escuro"] {
  --fundo: #0b1220;
  --superficie: rgba(15, 23, 42, 0.82);
  --superficie-solida: #0f172a;
  --superficie-2: #1e293b;
  --superficie-3: #334155;
  --borda: rgba(148, 163, 184, 0.14);
  --borda-forte: rgba(148, 163, 184, 0.28);
  --texto: #e2e8f0;
  --texto-2: #9fb0c6;
  --texto-3: #6b7c93;
  --brilho-skeleton: rgba(148, 163, 184, 0.16);
  --mascara: rgba(2, 6, 23, 0.45);
  --risco-texto: #fca5a5;
  --risco-fundo: rgba(248, 113, 113, 0.12);
  --limite: #cbd5e1;
  --sombra-2: 0 12px 32px -12px rgba(0, 0, 0, 0.7), 0 4px 12px -4px rgba(0, 0, 0, 0.4);
  --sombra-3: 0 24px 60px -18px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--fonte);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primaria); }
[data-tema="escuro"] a { color: #93c5fd; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }

:focus-visible { outline: none; box-shadow: var(--foco); }
a:focus-visible { border-radius: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.defs-svg { position: absolute; width: 0; height: 0; overflow: hidden; }

[data-lucide],
svg.lucide { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2; }
.icone { display: inline-flex; flex-shrink: 0; }

#mapa {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--fundo);
}

/* ---------- Painel flutuante (glass) ---------- */
.painel {
  position: fixed;
  z-index: 1000;
  top: var(--margem);
  left: var(--margem);
  bottom: var(--margem);
  width: var(--painel-largura);
  display: flex;
  flex-direction: column;
  background: var(--superficie);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra-3);
  overflow: hidden;
  transition: background-color 0.3s, transform 0.35s var(--ease);
}

.painel__alca { display: none; }

.painel__topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
}

.marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.marca__logo { border-radius: 12px; box-shadow: 0 6px 16px -6px rgba(37, 99, 235, 0.6); }
.marca h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.marca p { margin: 0; font-size: 12px; color: var(--texto-2); }

.painel__conteudo {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--superficie-3) transparent;
}
.painel__conteudo::-webkit-scrollbar { width: 8px; }
.painel__conteudo::-webkit-scrollbar-thumb { background: var(--superficie-3); border-radius: 8px; }

/* ---------- Botões ---------- */
.botao-icone {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--superficie-2);
  transition: transform 0.15s, background-color 0.2s;
}
.botao-icone:hover { background: var(--superficie-3); }
.botao-icone:active { transform: scale(0.94); }
.botao-icone--pequeno { width: 32px; height: 32px; border-radius: 10px; }
.botao-icone--pequeno svg.lucide { width: 16px; height: 16px; }
.icone-sol { display: none; }
[data-tema="escuro"] .icone-sol { display: block; }
[data-tema="escuro"] .icone-lua { display: none; }

.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--raio-m);
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.2s, background-color 0.2s, opacity 0.2s;
}
.botao:active { transform: scale(0.97); }
.botao:disabled { opacity: 0.6; cursor: progress; }
.botao--largo { width: 100%; }
.botao__giro {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
}
.botao--primario {
  color: #fff;
  background: linear-gradient(135deg, var(--primaria) 0%, #4f46e5 100%);
  box-shadow: 0 10px 22px -10px rgba(37, 99, 235, 0.8);
}
.botao--primario:hover { box-shadow: 0 14px 26px -10px rgba(37, 99, 235, 0.95); }
.botao--primario:focus-visible { box-shadow: var(--foco), 0 10px 22px -10px rgba(37, 99, 235, 0.8); }
.botao--secundario { background: var(--superficie-2); border: 1px solid var(--borda); }
.botao--secundario:hover { background: var(--superficie-3); }
.botao--perigo { color: #fff; background: var(--vermelho); }
.botao--perigo:hover { background: #b91c1c; }
.botao--ativo { background: var(--vermelho); box-shadow: 0 10px 22px -10px rgba(220, 38, 38, 0.8); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  background: var(--superficie-solida);
  color: var(--texto);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--sombra-1);
  transition: transform 0.15s, background-color 0.2s, border-color 0.2s;
}
[data-tema="escuro"] .chip { color: var(--texto); }
.chip [data-lucide],
.chip svg.lucide { width: 15px; height: 15px; }
.chip:hover { border-color: var(--borda-forte); background: var(--superficie-2); }
.chip:active { transform: scale(0.96); }
.chip--pequeno { height: 28px; padding: 0 10px; font-size: 12px; box-shadow: none; }

/* ---------- Busca de cidade (autocomplete) ---------- */
.busca { position: relative; }
.busca input {
  width: 100%;
  height: 46px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--borda);
  border-radius: var(--raio-m);
  background: var(--superficie-2);
  outline: none;
  font-weight: 500;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.busca input::placeholder { color: var(--texto-3); font-weight: 400; }
.busca input:focus {
  background: var(--superficie-solida);
  border-color: var(--primaria);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
.busca input:disabled { opacity: 0.6; }
.busca input::-webkit-search-cancel-button { cursor: pointer; }
.busca__lupa { position: absolute; top: 50%; left: 13px; margin-top: -9px; color: var(--texto-3); pointer-events: none; }

.busca__carregando {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid var(--superficie-3);
  border-top-color: var(--primaria);
  border-radius: 50%;
  opacity: 0;
  animation: girar 0.8s linear infinite;
  transition: opacity 0.2s;
  pointer-events: none;
}
.busca.buscando .busca__carregando { opacity: 1; }

.sugestoes {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--superficie-solida);
  border: 1px solid var(--borda);
  border-radius: var(--raio-m);
  box-shadow: var(--sombra-2);
  max-height: 340px;
  overflow-y: auto;
  display: none;
}
.sugestoes.aberta { display: block; animation: surgir 0.18s var(--ease); }
.sugestao {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--raio-p);
  cursor: pointer;
}
.sugestao:hover,
.sugestao.ativa { background: var(--superficie-2); }
.sugestao__icone {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  color: var(--primaria);
  background: rgba(37, 99, 235, 0.1);
}
.sugestao__icone--salva { color: var(--verde); background: rgba(22, 163, 74, 0.12); }
.sugestao__texto { min-width: 0; }
.sugestao__texto strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sugestao__texto small { display: block; color: var(--texto-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sugestao__selo {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--verde);
  background: rgba(22, 163, 74, 0.12);
}
.sugestao--vazia { color: var(--texto-2); cursor: default; justify-content: center; text-align: center; }

/* ---------- Cartões (importar / progresso) ---------- */
.importar { margin-top: 12px; }
.cartao {
  position: relative;
  padding: 16px;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  background: var(--superficie-solida);
  box-shadow: var(--sombra-1);
  overflow: hidden;
  animation: entrar 0.35s var(--ease) both;
}
.cartao__topo { display: flex; align-items: center; gap: 12px; }
.selo-cidade {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #60a5fa, var(--primaria));
  box-shadow: 0 8px 18px -8px var(--primaria);
}
.cartao__titulo { min-width: 0; }
.cartao__titulo h2 { margin: 0; font-size: 16px; font-weight: 700; }
.cartao__titulo p { margin: 0; font-size: 12px; color: var(--texto-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cartao__texto { margin: 12px 0; color: var(--texto-2); font-size: 13px; }
.cartao__acoes { display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; }

.cartao--progresso { border-color: rgba(37, 99, 235, 0.3); }
.cartao--pronta { display: grid; gap: 12px; border-color: rgba(22, 163, 74, 0.4); }
.progresso__topo { display: flex; align-items: center; gap: 10px; }
.progresso__topo strong { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progresso__giro {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2.5px solid var(--superficie-3);
  border-top-color: var(--primaria);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
.progresso__tempo { font-weight: 700; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.progresso__mensagem { margin: 10px 0 8px; font-weight: 500; }
.progresso__dica { margin: 8px 0 12px; font-size: 12px; color: var(--texto-2); }
.progresso__barra { position: relative; height: 4px; border-radius: 4px; background: var(--superficie-3); overflow: hidden; }
.progresso__barra span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primaria), #4f46e5);
  animation: vai-e-vem 1.6s var(--ease) infinite;
}
.cartao--progresso .skeleton { padding: 0; border: 0; background: none; }

/* Skeleton */
.skeleton { display: grid; gap: 10px; padding: 14px; border-radius: var(--raio); border: 1px solid var(--borda); background: var(--superficie-solida); }
.skeleton__bloco {
  height: 14px;
  border-radius: 8px;
  background: var(--superficie-2) linear-gradient(90deg, transparent, var(--brilho-skeleton), transparent) 0 0 / 200% 100% no-repeat;
  animation: brilho 1.2s ease-in-out infinite;
}
.skeleton__bloco--titulo { width: 45%; height: 18px; }
.skeleton__bloco--linha:nth-child(odd) { width: 82%; }
.skeleton__grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skeleton__grade .skeleton__bloco { height: 74px; border-radius: var(--raio-m); }

/* ---------- Cidade aberta ---------- */
.cidade { margin-top: 14px; }
.cidade__topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cidade__titulo { min-width: 0; }
.cidade__titulo h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; }
.cidade__titulo p { margin: 3px 0 0; font-size: 12.5px; color: var(--texto-2); }

/* Resumo por tipo: o número em risco é o protagonista */
.resumo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.resumo > .skeleton { grid-column: 1 / -1; }
.resumo__cartao {
  display: grid;
  gap: 6px;
  padding: 11px 11px 10px;
  border: 1px solid var(--borda);
  border-radius: var(--raio-m);
  background: var(--superficie-solida);
  text-align: left;
  box-shadow: var(--sombra-1);
  transition: opacity 0.2s, border-color 0.2s, transform 0.15s, background-color 0.2s;
  animation: entrar 0.4s var(--ease) both;
}
.resumo__cartao:nth-child(2) { animation-delay: 50ms; }
.resumo__cartao:nth-child(3) { animation-delay: 100ms; }
.resumo__cartao:hover { border-color: var(--borda-forte); }
.resumo__cartao:active { transform: scale(0.97); }
.resumo__cartao[aria-pressed="false"] { opacity: 0.45; box-shadow: none; background: var(--superficie-2); }
.resumo__topo { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--texto-2); }
.resumo__topo svg.lucide { width: 15px; height: 15px; }
.resumo__numeros { display: flex; align-items: baseline; font-variant-numeric: tabular-nums; white-space: nowrap; }
.resumo__numeros strong { font-size: 28px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; color: var(--texto-3); }
.resumo__cartao--risco .resumo__numeros strong { color: var(--vermelho); }
[data-tema="escuro"] .resumo__cartao--risco .resumo__numeros strong { color: #f87171; }
.resumo__total { font-size: 14px; font-weight: 600; color: var(--texto-2); }
.resumo__barra { height: 5px; border-radius: 5px; background: var(--superficie-3); overflow: hidden; }
.resumo__barra span { display: block; height: 100%; border-radius: 5px; background: var(--vermelho); transform-origin: left; animation: crescer 0.8s var(--ease) 0.2s both; }
.resumo__legenda { font-size: 11px; color: var(--texto-2); }
.resumo__cartao--risco .resumo__legenda { color: var(--risco-texto); font-weight: 600; }

/* Filtros */
.filtros { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 8px; }
.segmentado {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--borda);
  background: var(--superficie-2);
}
.segmentado button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--texto-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: background-color 0.2s, color 0.2s;
}
.segmentado button[aria-checked="true"] { background: var(--superficie-solida); color: var(--texto); box-shadow: var(--sombra-1); }
.segmentado button[data-filtro="risco"][aria-checked="true"] { color: var(--vermelho); }
.filtros__contagem { font-size: 12px; color: var(--texto-2); font-variant-numeric: tabular-nums; }

/* Lista de infraestruturas */
.lista-infra { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0 -6px; }
.infra {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: var(--raio-m);
  background: transparent;
  text-align: left;
  transition: background-color 0.15s;
}
.infra:hover { background: var(--superficie-2); }
.infra__icone {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  color: var(--seguro);
  background: rgba(37, 99, 235, 0.1);
}
[data-tema="escuro"] .infra__icone { color: #93c5fd; background: rgba(96, 165, 250, 0.14); }
.infra--risco .infra__icone { color: #fff; background: var(--vermelho); box-shadow: 0 6px 12px -6px var(--vermelho); }
.infra__texto { flex: 1; min-width: 0; }
.infra__texto strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.infra__texto small { display: block; font-size: 12px; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.infra--risco .infra__texto small { color: var(--risco-texto); }
.nivel-selo {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.nivel-selo--alto { color: #fff; background: var(--risco-alto); }
.nivel-selo--medio { color: #451a03; background: var(--risco-medio); }
.nivel-selo--baixo { color: #422006; background: var(--risco-baixo); }
.lista__mais { margin: 8px 6px 2px; width: calc(100% - 12px); }
.lista__vazia { margin: 0; padding: 12px 8px; color: var(--texto-2); font-size: 12.5px; }

/* Exportar */
.exportar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--borda);
}
.exportar > span { flex: 1 0 100%; font-size: 12.5px; font-weight: 600; color: var(--texto-2); }

/* Cidades salvas */
.salvas { margin-top: 18px; }
.secao-titulo { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--texto-2); }
.lista { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0 -6px; }
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: var(--raio-m);
  background: transparent;
  text-align: left;
  transition: background-color 0.15s;
}
.item:hover { background: var(--superficie-2); }
.item__icone { display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 11px; color: #fff; background: linear-gradient(145deg, #60a5fa, var(--primaria)); }
.item__texto { flex: 1; min-width: 0; }
.item__texto strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__texto small { display: block; font-size: 12px; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__seta { color: var(--texto-3); }

.vazio { display: grid; justify-items: center; gap: 6px; padding: 22px 14px; margin: 0 6px; text-align: center; border: 1px dashed var(--borda-forte); border-radius: var(--raio); color: var(--texto-2); }
.vazio .icone { color: var(--primaria); }
.vazio strong { color: var(--texto); }
.vazio p { margin: 0; font-size: 12.5px; max-width: 30ch; }

/* ---------- Administrador ---------- */
.admin {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--raio);
  background: rgba(37, 99, 235, 0.05);
}
.admin h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; }
.admin h3 svg.lucide { color: var(--primaria); }
.admin__dica { margin: 8px 0 0; font-size: 12px; color: var(--texto-2); }
.larguras { margin-top: 14px; }
.larguras fieldset { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; padding: 0; border: 0; }
.larguras legend { margin-bottom: 8px; font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.larguras label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--texto-2); }
.larguras input,
.campo input,
.campo select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--borda-forte);
  border-radius: var(--raio-p);
  background: var(--superficie-solida);
  color: var(--texto);
  font-weight: 600;
  outline: none;
}
.larguras input:focus,
.campo input:focus,
.campo select:focus { border-color: var(--primaria); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }
.larguras .botao { width: 100%; }
.selo-admin { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 700; color: var(--primaria); background: rgba(37, 99, 235, 0.12); }

/* Diálogo da área */
.dialogo {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  background: var(--superficie-solida);
  color: var(--texto);
  box-shadow: var(--sombra-3);
}
.dialogo[open] { animation: surgir 0.2s var(--ease); }
.dialogo::backdrop { background: rgba(15, 23, 42, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dialogo form { display: grid; gap: 12px; padding: 18px; }
.dialogo__topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialogo__topo h2 { margin: 0; font-size: 17px; }
.campo { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.niveis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; padding: 0; border: 0; }
.niveis legend { margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.nivel { position: relative; }
.nivel input { position: absolute; opacity: 0; pointer-events: none; }
.nivel span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  border: 1px solid var(--borda-forte);
  border-radius: var(--raio-p);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.nivel span::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--cor-nivel); }
.nivel--alto { --cor-nivel: var(--risco-alto); }
.nivel--medio { --cor-nivel: var(--risco-medio); }
.nivel--baixo { --cor-nivel: var(--risco-baixo); }
.nivel input:checked + span { border-color: var(--cor-nivel); background: color-mix(in srgb, var(--cor-nivel) 16%, transparent); color: var(--texto); }
.nivel input:focus-visible + span { box-shadow: var(--foco); }
.dialogo__erro { min-height: 1.2em; margin: 0; font-size: 12.5px; font-weight: 500; color: var(--vermelho); }
.dialogo__erro:empty { display: none; }
.dialogo__acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.dialogo__espaco { flex: 1; }

.rodape { display: grid; gap: 4px; margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--texto-3); }
.rodape a { font-weight: 600; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  z-index: 3000;
  right: 20px;
  bottom: 28px;
  display: grid;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--raio-m);
  background: var(--superficie-solida);
  border: 1px solid var(--borda);
  border-left: 4px solid var(--cor-toast, var(--vermelho));
  box-shadow: var(--sombra-2);
  animation: toast-entrar 0.35s var(--ease);
  font-weight: 500;
}
.toast svg.lucide { color: var(--cor-toast, var(--vermelho)); margin-top: 1px; }
.toast--sucesso { --cor-toast: var(--verde); }
.toast--info { --cor-toast: var(--primaria); }
.toast--saindo { animation: toast-sair 0.3s var(--ease) forwards; }

/* ==========================================================================
   Leaflet: controles, popups, tooltips, legenda
   ========================================================================== */
.leaflet-container { font-family: var(--fonte); background: var(--fundo); }
.leaflet-top.leaflet-right { margin-top: 6px; margin-right: 6px; }
.leaflet-container a.leaflet-popup-close-button:focus-visible,
.leaflet-bar a:focus-visible { box-shadow: var(--foco); }

.leaflet-bar,
.leaflet-control-layers {
  border: 1px solid var(--borda) !important;
  border-radius: var(--raio-m) !important;
  box-shadow: var(--sombra-2) !important;
  overflow: hidden;
}
.leaflet-bar a,
.leaflet-control-layers {
  background: var(--superficie-solida) !important;
  color: var(--texto) !important;
}
.leaflet-bar a { width: 38px !important; height: 38px !important; line-height: 38px !important; border-bottom-color: var(--borda) !important; }
.leaflet-bar a:hover { background: var(--superficie-2) !important; }
.leaflet-control-layers-toggle { width: 40px !important; height: 40px !important; }
[data-tema="escuro"] .leaflet-control-layers-toggle { filter: invert(1) hue-rotate(180deg); }
.leaflet-control-layers-expanded { padding: 10px 12px; font-size: 13px; }
.leaflet-control-layers-separator { border-top-color: var(--borda) !important; }
.leaflet-control-layers label { margin: 3px 0; }
.leaflet-control-scale-line {
  border-color: var(--texto-2) !important;
  color: var(--texto) !important;
  background: color-mix(in srgb, var(--superficie-solida) 80%, transparent) !important;
  font-weight: 600;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--superficie-solida) 75%, transparent) !important;
  color: var(--texto-2) !important;
  border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: var(--texto-2) !important; }
.leaflet-bottom.leaflet-left { left: calc(var(--painel-largura) + var(--margem) * 2 - 10px); }

/* Legenda */
.legenda {
  min-width: 190px;
  margin-bottom: 4px !important;
  border: 1px solid var(--borda);
  border-radius: var(--raio-m);
  background: var(--superficie);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  color: var(--texto);
  box-shadow: var(--sombra-2);
  font-size: 12.5px;
}
.legenda summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: var(--raio-m);
}
.legenda summary::-webkit-details-marker { display: none; }
.legenda ul { display: grid; gap: 7px; margin: 0; padding: 2px 12px 12px; list-style: none; }
.legenda li { display: flex; align-items: center; gap: 9px; color: var(--texto-2); }
.amostra { width: 18px; height: 14px; flex-shrink: 0; border-radius: 4px; }
.amostra--risco,
.amostra--seguro { width: 14px; height: 14px; margin: 0 2px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--borda-forte); }
.amostra--risco { background: var(--risco-alto); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3); }
.amostra--seguro { background: var(--seguro); }
.amostra--alto { background: color-mix(in srgb, var(--risco-alto) 30%, transparent); border: 2px solid var(--risco-alto); }
.amostra--medio { background: color-mix(in srgb, var(--risco-medio) 30%, transparent); border: 2px solid var(--risco-medio); }
.amostra--baixo { background: color-mix(in srgb, var(--risco-baixo) 35%, transparent); border: 2px solid var(--risco-baixo); }
.amostra--inundacao {
  border: 2px dashed var(--inundacao);
  background: repeating-linear-gradient(45deg, rgba(2, 132, 199, 0.45) 0 2px, rgba(2, 132, 199, 0.1) 2px 6px);
}
.amostra--limite { height: 0; border-top: 3px dotted var(--limite); border-radius: 0; }

/* Popups */
.popup-infra-wrap .leaflet-popup-content-wrapper {
  border-radius: 14px;
  background: var(--superficie-solida);
  color: var(--texto);
  box-shadow: var(--sombra-2);
  border: 1px solid var(--borda);
}
.popup-infra-wrap .leaflet-popup-tip { background: var(--superficie-solida); box-shadow: none; }
.popup-infra-wrap .leaflet-popup-content { margin: 13px 15px; font-size: 13px; line-height: 1.4; }
.popup-infra-wrap a.leaflet-popup-close-button { color: var(--texto-3); top: 6px; right: 6px; }
.popup__topo { display: flex; align-items: center; gap: 10px; padding-right: 14px; }
.popup__selo { display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 11px; background: var(--seguro); }
.popup-infra--risco .popup__selo { background: var(--vermelho); }
.popup__titulo { display: block; font-weight: 700; font-size: 14px; line-height: 1.25; }
.popup__sub { display: block; color: var(--texto-2); font-size: 12px; margin-top: 2px; }
.popup__status { margin: 10px 0 8px; padding: 6px 9px; border-radius: var(--raio-p); font-size: 12.5px; font-weight: 700; }
.popup__status--seguro { color: var(--primaria-forte); background: rgba(37, 99, 235, 0.1); }
[data-tema="escuro"] .popup__status--seguro { color: #93c5fd; }
.popup__status--alto { color: var(--risco-texto); background: var(--risco-fundo); }
.popup__status--medio { color: #92400e; background: rgba(245, 158, 11, 0.16); }
.popup__status--baixo { color: #854d0e; background: rgba(250, 204, 21, 0.22); }
[data-tema="escuro"] .popup__status--medio { color: #fcd34d; }
[data-tema="escuro"] .popup__status--baixo { color: #fde68a; }
.popup__rotulo { display: block; margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--texto-2); }
.popup__areas { margin: 3px 0 0; padding-left: 18px; }
.popup__areas li { margin: 1px 0; }
.popup__linha { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--texto-2); font-size: 12.5px; }
.popup__linha strong { margin-left: auto; color: var(--texto); text-align: right; }
.popup__hospital { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--borda); }
.popup__hospital .popup__rotulo { margin-top: 0; }
.popup__hospital-linha { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; }
.popup__hospital-linha .icone { color: var(--seguro); }
.popup__hospital-linha strong { flex: 1; min-width: 0; }
.popup__distancia { font-weight: 700; color: var(--texto-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.popup__coord { display: block; margin-top: 8px; font-size: 11px; color: var(--texto-3); font-variant-numeric: tabular-nums; }
.popup__nota { margin: 8px 0 0; font-size: 12px; color: var(--texto-2); }
.popup__acoes { display: flex; gap: 6px; margin-top: 10px; }

.tooltip-infra {
  padding: 5px 9px;
  border: 0;
  border-radius: 9px;
  background: var(--texto);
  color: var(--superficie-solida);
  font-family: var(--fonte);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--sombra-2);
}
.tooltip-infra::before { display: none; }

/* ==========================================================================
   Áreas, limite e marcadores
   ========================================================================== */
.mascara-cidade { fill: var(--mascara); }
.limite-cidade { stroke: var(--limite); }
path.area-automatica { fill: url(#hachura-inundacao); }
path.area-desenhada { transition: fill-opacity 0.2s; }
path.area-desenhada:hover { fill-opacity: 0.38; }
.desenhando .leaflet-container { cursor: crosshair; }

.vertice-desenho {
  background: #fff;
  border: 2.5px solid var(--vermelho);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.leaflet-draw-tooltip {
  background: var(--texto);
  color: var(--superficie-solida);
  border: 0;
  border-radius: 8px;
  font-family: var(--fonte);
  font-weight: 500;
}
.leaflet-draw-tooltip::before { border-right-color: var(--texto); }

.marcador-infra { background: none; border: 0; }
.selo-infra {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--seguro);
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.35);
  transition: transform 0.18s var(--ease);
}
.leaflet-marker-icon:hover .selo-infra,
.leaflet-marker-icon:focus-visible .selo-infra { transform: scale(1.15); }
.leaflet-marker-icon:focus-visible { box-shadow: none; outline: none; }
.leaflet-marker-icon:focus-visible .selo-infra { box-shadow: var(--foco); }
.selo-infra svg { position: relative; z-index: 1; }
.selo-infra--risco { background: var(--vermelho); box-shadow: 0 3px 10px rgba(220, 38, 38, 0.55); }
.selo-infra__anel {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid var(--vermelho);
  animation: pulso-anel 1.8s ease-out infinite;
  pointer-events: none;
}
.pino-estatico--risco { filter: hue-rotate(140deg) saturate(1.4); }

.cluster-infra { background: none; border: 0; }
.cluster {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  background: radial-gradient(circle at 30% 30%, #60a5fa, #2563eb);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.22), 0 6px 14px rgba(15, 23, 42, 0.35);
}
.cluster--risco { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.22), 0 6px 14px rgba(15, 23, 42, 0.35); }
.cluster__risco {
  position: absolute;
  top: -7px;
  right: -9px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--vermelho);
  border: 2px solid #fff;
  font-size: 11px;
  line-height: 1;
}

/* ==========================================================================
   Responsivo: no celular o painel vira bottom sheet arrastável
   ========================================================================== */
@media (max-width: 768px) {
  :root { --margem: 0px; }

  .painel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 88vh;
    height: 88dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    transform: translateY(45%);
    will-change: transform;
  }
  .painel.arrastando { transition: none; }

  .painel__alca {
    display: flex;
    justify-content: center;
    padding: 10px 0 2px;
    cursor: grab;
    touch-action: none;
  }
  .painel__alca span { width: 44px; height: 5px; border-radius: 5px; background: var(--borda-forte); }
  .painel__topo { padding-top: 6px; touch-action: none; }
  .marca p { display: none; }
  .painel__conteudo { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

  .toasts { top: 16px; bottom: auto; left: 16px; right: 16px; margin: 0 auto; }
  .leaflet-bottom.leaflet-left { left: 0; }
  .leaflet-top.leaflet-left .leaflet-control-attribution { margin: 8px 0 0 8px; border-radius: 8px; font-size: 10px; }
  .legenda { min-width: 0; }
  .resumo__numeros strong { font-size: 24px; }
  .dialogo__acoes .botao { flex: 1; }
  .dialogo__espaco { display: none; }
}

@media (max-width: 380px) {
  .resumo { gap: 6px; }
  .resumo__cartao { padding: 9px 8px; }
  .resumo__numeros strong { font-size: 21px; }
  .resumo__total { font-size: 12px; }
}

/* ==========================================================================
   Animações
   ========================================================================== */
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes surgir { from { opacity: 0; transform: translateY(-4px); } }
@keyframes entrar { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
@keyframes crescer { from { transform: scaleX(0); } }
@keyframes brilho { from { background-position: -150% 0; } to { background-position: 250% 0; } }
@keyframes vai-e-vem { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@keyframes toast-entrar { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toast-sair { to { opacity: 0; transform: translateX(24px); } }
@keyframes pulso-anel { 0% { transform: scale(0.9); opacity: 0.85; } 100% { transform: scale(1.9); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .selo-infra__anel { animation: none; transform: scale(1.35); opacity: 0.5; }
}
