:root {
  --bg-white: #ffffff;
  --text-grey: #333333;
  --accent-teal: #008b8b;
  --teal-secondary: #20b2aa;
  --teal-light: #48d1cc;
  --teal-dark: #006b6b;
  --surface-soft: #f3fafa;
  --text-muted: #526775;
  --border-soft: #dce9e9;
  --radius-panel: 14px;
  --shadow-soft: 0 4px 18px rgb(0 80 80 / 6%);
  --font-corp: "Open Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-white);
  color: var(--text-grey);
  font-family: var(--font-corp);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { line-height: 1.25; }
p { margin: 8px 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--teal-dark); text-underline-offset: 3px; }
a:hover { color: #004e4e; }

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid var(--teal-dark);
  outline-offset: 4px;
}

header {
  padding: 28px max(24px, calc((100% - 1392px) / 2));
  background: var(--bg-white);
  border-top: 4px solid var(--accent-teal);
  border-bottom: 1px solid var(--border-soft);
}

header h1 {
  margin: 0;
  color: var(--text-grey);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

header > p {
  max-width: 900px;
  margin-top: 12px;
  color: var(--text-muted);
}

.resumo-projeto {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px;
}

.etiqueta-projeto {
  display: inline-block;
  color: var(--teal-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cabecalho-resumo h2 {
  max-width: 850px;
  margin: 12px 0;
  color: var(--text-grey);
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  letter-spacing: -0.02em;
}

.cabecalho-resumo > p {
  max-width: 900px;
  color: var(--text-muted);
}

.indicadores-destaque {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 26px;
}

.caixa-indicador {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border-soft);
  border-top: 3px solid var(--teal-secondary);
  border-radius: var(--radius-panel);
  background: var(--bg-white);
  box-shadow: var(--shadow-soft);
}

.valor-indicador {
  display: block;
  margin-bottom: 12px;
  color: var(--teal-dark);
  font-size: clamp(1.7rem, 2.6vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.caixa-indicador h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.4;
}

.caixa-indicador p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.secao-mapa { border-top: 1px solid var(--border-soft); }

#status {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

#ver-tudo {
  min-height: 44px;
  margin-top: 10px;
  padding: 10px 18px;
  border: 1px solid var(--accent-teal);
  border-radius: 10px;
  background: var(--accent-teal);
  color: #ffffff;
  font-weight: 700;
  transition: background 180ms ease, box-shadow 180ms ease;
}

#ver-tudo:hover:not(:disabled) {
  background: var(--teal-dark);
  box-shadow: 0 4px 12px rgb(0 139 139 / 15%);
}

#ver-tudo:disabled { opacity: 0.55; cursor: wait; }

.conteudo-mapa {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  width: calc(100% - 48px);
  max-width: 1392px;
  height: 78vh;
  min-height: 540px;
  max-height: 850px;
  margin: 0 auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-panel);
  /* Avoid clipping Leaflet pop-ups and focus outlines. */
  background: var(--bg-white);
  box-shadow: var(--shadow-soft);
}

#mapa {
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #edf5f5;
  border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
  font-family: var(--font-corp);
}

#painel-regiao {
  min-width: 0;
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--border-soft);
  border-radius: var(--radius-panel) 0 0 var(--radius-panel);
  background: var(--bg-white);
  scrollbar-width: thin;
  scrollbar-color: #a6c6c3 transparent;
}

#painel-regiao h2 {
  margin: 0 0 20px;
  color: var(--teal-dark);
  font-size: 1.2rem;
  line-height: 1.4;
}

#painel-regiao .secao-indicadores {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

#painel-regiao .secao-indicadores h3 {
  margin: 0 0 10px;
  color: var(--teal-dark);
  font-size: 1rem;
  line-height: 1.45;
}

#painel-regiao dl {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 0 12px;
  margin: 0;
}

#painel-regiao dt,
#painel-regiao dd {
  padding: 11px 0;
  border-bottom: 1px solid #edf2f2;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#painel-regiao dt { color: var(--text-muted); font-weight: 500; }

#painel-regiao dd {
  margin: 0;
  color: #244c4c;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#painel-regiao .aviso-indicador {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

#painel-regiao details {
  margin-top: 24px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

#painel-regiao summary {
  color: var(--teal-dark);
  font-weight: 700;
  cursor: pointer;
}

#painel-regiao details p { margin-top: 12px; }
#instrucao-mapa { color: var(--text-muted); font-size: 0.9rem; }

/* Leaflet controls: retain the existing layers, panes and interactions. */
.leaflet-control-layers {
  max-width: min(300px, calc(100vw - 48px));
  padding: 12px;
  border-radius: 10px;
  font-family: var(--font-corp);
  font-size: 0.875rem;
  box-shadow: var(--shadow-soft);
}

.leaflet-control-layers label { padding: 5px 0; cursor: pointer; }
.leaflet-control-layers-overlays label > span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaflet-control-layers-selector {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  top: 0;
  flex: 0 0 36px;
  width: 36px;
  height: 20px;
  margin: 0;
  border: 1px solid #819596;
  border-radius: 20px;
  background: #dce5e5;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

.leaflet-control-layers-selector::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px #0003;
  transition: transform 180ms ease;
}

.leaflet-control-layers-selector:checked {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
}

.leaflet-control-layers-selector:checked::before { transform: translateX(16px); }

.leaflet-control-layers-selector:focus-visible {
  outline: 3px solid var(--teal-dark);
  outline-offset: 3px;
}

.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content {
  font-family: var(--font-corp);
  font-size: 0.875rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.leaflet-popup-content p { margin: 8px 0; }
.leaflet-tooltip {
  max-width: 240px;
  white-space: normal;
  font-family: var(--font-corp);
  font-size: 0.875rem;
}

/* Dynamic marker dimensions remain controlled by app.js. */
.marcador-saude,
.marcador-sede { background: transparent; border: none; }

.simbolo-saude {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid #ffffff;
  box-shadow: 0 1px 3px #0005;
}

/* Keep these colors aligned with the filter labels and symbol legend. */
.simbolo-ubs { background: #174a7e; border-radius: 2px; }
.simbolo-usf { background: #982b5c; border-radius: 50%; }

.simbolo-saude::before,
.simbolo-saude::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
}
.simbolo-saude::before { width: 60%; height: 20%; }
.simbolo-saude::after { width: 20%; height: 60%; }

.simbolo-sede {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  color: #ffffff;
  background: #263746;
  box-shadow: 0 2px 5px #0005;
}
.simbolo-sede svg { width: 75%; height: 75%; }

.legenda-icones,
.legenda-proximidade {
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-soft);
  color: var(--text-grey);
  font: 0.8125rem/1.45 var(--font-corp);
  overflow-wrap: anywhere;
}

.legenda-icones { max-width: 260px; }
.legenda-proximidade { max-width: 240px; }
.legenda-icones > strong,
.legenda-proximidade > strong {
  display: block;
  margin-bottom: 9px;
  color: #244c4c;
}

.item-legenda { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.item-legenda .simbolo-saude,
.item-legenda .simbolo-sede { flex: 0 0 18px; width: 18px; height: 18px; }
.amostra-proximidade {
  display: inline-block;
  flex: 0 0 20px;
  width: 20px;
  height: 14px;
  border: 1px solid #465460;
  border-radius: 2px;
}
.legenda-proximidade p { margin: 12px 0 0; color: var(--text-muted); font-size: 0.8125rem; }

.rodape-projeto {
  margin-top: 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.rodape-projeto p { max-width: 950px; margin: 0 0 14px; }
.rodape-projeto strong { color: var(--teal-dark); }
.rodape-projeto a { display: inline-block; padding-block: 6px; font-weight: 700; }

@media (max-width: 1100px) {
  .indicadores-destaque { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conteudo-mapa { grid-template-columns: 310px minmax(0, 1fr); }
  #painel-regiao { padding: 20px; }
  .legenda-icones { max-width: 180px; }
  .legenda-proximidade { max-width: 180px; }
}

@media (max-width: 760px) {
  header { padding: 24px 20px; }
  .resumo-projeto { padding: 28px 20px; }
  .conteudo-mapa {
    grid-template-columns: minmax(0, 1fr);
    width: calc(100% - 32px);
    height: auto;
    min-height: 0;
    max-height: none;
  }

  #mapa {
    grid-row: 1;
    height: 70vh;
    height: 70svh;
    min-height: 520px;
    max-height: 720px;
    border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  }

  #painel-regiao {
    overflow-y: visible;
    border-right: 0;
    border-top: 1px solid var(--border-soft);
    border-radius: 0 0 var(--radius-panel) var(--radius-panel);
  }

  .leaflet-control-layers {
    max-width: calc(100vw - 70px);
    padding: 8px;
    font-size: 0.8125rem;
  }

  .legenda-icones,
  .legenda-proximidade {
    max-width: min(170px, calc((100vw - 76px) / 2));
    max-height: 230px;
    overflow-y: auto;
    padding: 8px;
    font-size: 0.75rem;
  }

  .legenda-proximidade p { font-size: 0.75rem; }
  .item-legenda { gap: 6px; margin-top: 7px; }
}

@media (max-width: 540px) {
  header { padding: 22px 16px; }
  .resumo-projeto { padding: 24px 16px; }
  .indicadores-destaque { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .caixa-indicador { padding: 20px; }
  .valor-indicador { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  #ver-tudo,
  .leaflet-control-layers-selector,
  .leaflet-control-layers-selector::before { transition: none; }
}
.secao-resultados {
  padding-top: 48px;
  padding-bottom: 48px;
}

.cartao-grafico {
  margin: 28px 0 0;
  padding: clamp(16px, 3vw, 32px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-panel);
  background: var(--bg-white);
  box-shadow: var(--shadow-soft);
}

.cartao-grafico h3 {
  margin: 0 0 12px;
  color: var(--teal-dark);
  font-size: 1.2rem;
}

.cartao-grafico figcaption p {
  max-width: 950px;
  color: var(--text-muted);
}

.cartao-grafico a {
  display: block;
  max-width: 1100px;
  margin: 24px auto;
  border-radius: 8px;
  cursor: zoom-in;
}

.cartao-grafico img {
  display: block;
  width: 100%;
  height: auto;
}

.cartao-grafico .nota-grafico {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}