@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Libre+Franklin:wght@400;500;600&display=swap");
:root {
  --font-title: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
}
/* Estilos globais e componentes comuns a todas as páginas */
:root {
  --forest: #2f4468;
  --forest-2: #4a78b0;
  --lime: #e6c565;
  --river: #b7d3ee;
  --coral: #ef9a93;
  --paper: #faf5e4;
  --white: #fff;
  --ink: #26364d;
  --muted: #667790;
  --line: #e6dfc6;
  --rail: 250px;
  --blue: #b7d3ee;
  --mint: #bfe0c7;
  --yellow: #f7e3a3;
  --red: #f2b0aa;
  --blue-ink: #3f6ea6;
  --green-ink: #3a8458;
  --yellow-ink: #a87c10;
  --red-ink: #c4564d;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
}
button,
select,
input {
  font: inherit;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-title);
  font-weight: 500;
  letter-spacing: -0.015em;
}
body {
  -webkit-font-smoothing: antialiased;
}
.kpi .value,
.indicator strong,
.detail-value strong,
.bar-value,
.section-index {
  font-variant-numeric: lining-nums tabular-nums;
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  padding: 28px 24px;
  background: #fff;
  color: var(--ink);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 13px;
}
.brand-symbol {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  overflow: hidden;
}
.brand-symbol img {
  display: block;
  width: auto;
  max-width: none;
  height: 46px;
}
.brand b {
  display: block;
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}
.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.rail nav {
  display: grid;
  gap: 4px;
  margin-top: 70px;
}
.rail nav a {
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  transition: 0.2s ease;
}
.rail nav a span {
  display: inline-block;
  width: 34px;
  color: #9aabc2;
  font-size: 11px;
}
/* Fundo de cada página: cores pastel ligeiramente escurecidas, alinhadas com a barra lateral */
body[data-page="retrato"],
body[data-page="municipio"] {
  --paper: #e9f1fb;
}
body[data-page="indicadores"] {
  --paper: #fbebe9;
}
body[data-page="comparar"] {
  --paper: #f8f0d4;
}
body[data-page="metodologia"] {
  --paper: #e6f0da;
}
body[data-page="transferencias"] {
  --paper: #e9f1fb;
}
/* Cores da barra lateral: texto e fundo pastel ao selecionar cada aba */
.rail nav a:nth-child(4n + 1) {
  --tc: #1f5fae;
  --tb: #e6effa;
}
.rail nav a:nth-child(4n + 2) {
  --tc: #c0332b;
  --tb: #fbe7e4;
}
.rail nav a:nth-child(4n + 3) {
  --tc: #8a680c;
  --tb: #fcf4d8;
}
.rail nav a:nth-child(4n + 4) {
  --tc: #2e7d46;
  --tb: #e4f2e8;
}
.rail nav a[href$="transferencias.html"] {
  --tc: #1f5fae;
  --tb: #e6effa;
}
.rail nav a[href$="forms.html"] {
  --tc: #c0332b;
  --tb: #fbe7e4;
}
.rail nav a {
  color: var(--tc);
  border-radius: 6px;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    padding-left 0.2s ease;
}
.rail nav a:hover,
.rail nav a.active {
  color: var(--tc);
  background-color: var(--tb);
  padding-left: 6px;
  font-weight: 600;
}
.rail nav a.active span {
  color: var(--tc);
}
.rail-note {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
}
.source-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--green-ink);
}
.rail-note p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.rail-note strong {
  color: var(--ink);
  font-weight: 500;
}
.source-link {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: var(--forest);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
}
.source-link span {
  color: var(--blue-ink);
}

/* Seletor de território na barra lateral: discreto, no mesmo estilo do menu */
.rail-territory {
  margin-top: 34px;
}
.rail-territory label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}
.rail-territory select {
  width: 100%;
  min-height: 38px;
  padding: 0 24px 0 0;
  border: 0;
  border-bottom: 1px solid #b9c9dd;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  color-scheme: light;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.rail-territory select:hover {
  border-bottom-color: var(--blue-ink);
}
.rail-territory select:focus-visible {
  outline: 0;
  border-bottom-color: var(--blue-ink);
}
.rail-territory option {
  background: #fff;
  color: var(--ink);
}
.rail-territory p {
  margin: 8px 0 0;
  color: #8a9bb3;
  font-size: 11px;
  line-height: 1.4;
}
.rail-territory--hidden {
  visibility: hidden;
}
.rail-territory + nav {
  margin-top: 22px;
}

main {
  margin-left: var(--rail);
}
.workspace {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px clamp(24px, 5vw, 78px) 64px;
}
.page-workspace {
  min-height: 100vh;
}
body[data-page] main {
  background: var(--paper) !important;
}
body[data-page="metodologia"] .method-section {
  min-height: 100vh;
}
body[data-page="metodologia"] .method-section {
  margin-bottom: 0;
}
.subpage-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 60px;
  align-items: end;
  padding: 18px 0 46px;
  border-bottom: 1px solid var(--line);
}
.compare-page-header {
  margin: 0 calc(clamp(24px, 5vw, 78px) * -1);
  padding: 28px clamp(24px, 5vw, 78px) 22px;
  background: var(--paper);
}
.subpage-toolbar h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.05;
}
.territory-picker.compact {
  align-self: auto;
  margin-bottom: 0;
}
.overline {
  margin-bottom: 12px;
  color: var(--forest-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.page-intro {
  min-height: 0;
  padding-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 60px;
  align-items: center;
}
.page-intro h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.05;
}
.page-intro .overline {
  margin-bottom: 6px;
}
.page-intro p {
  margin: 12px 0 0;
  max-width: 760px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--muted);
}
.page-intro h1 em {
  color: var(--forest-2);
  font-style: italic;
}
.territory-picker {
  align-self: end;
  margin-bottom: 34px;
  padding-left: 24px;
  border-left: 3px solid var(--yellow-ink);
}
.territory-picker label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.territory-picker select,
.compare-control select {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 1px solid #b9c9dd;
  border-radius: 0;
  padding: 0 28px 0 0;
  background: transparent;
  color: var(--forest);
  font-weight: 600;
  cursor: pointer;
}
.territory-picker p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.territory-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0;
}
.territory-title-row h2 {
  margin: 4px 0 0;
  font-size: clamp(32px, 4vw, 50px);
}
.territory-title-row > p {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}
.territory-title-row i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--forest-2);
}

.territory-stage {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 550px;
  border: 1px solid var(--line);
  background: white;
}
.map-panel {
  position: relative;
  overflow: hidden;
  padding: 24px;
  background: #f6efd6;
}
.map-panel::after {
  content: "";
  position: absolute;
  width: 310px;
  height: 310px;
  right: -180px;
  bottom: -170px;
  border: 70px solid rgba(168, 124, 16, 0.07);
  border-radius: 50%;
}
.map-caption {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 2;
}
.map-caption span {
  font-family: var(--font-body);
  font-size: 23px;
}
.map-caption p {
  max-width: 170px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.region-map {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 560px;
  margin-top: 2px;
  overflow: visible;
}
.mini-map {
  position: absolute;
  left: 24px;
  top: 72px;
  z-index: 3;
  width: 20%;
  min-width: 130px;
  cursor: pointer;
  outline: none;
}
.mini-map svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}
.mini-map path {
  fill: #a9c8ea;
  stroke: #a9c8ea;
  stroke-width: 2;
  stroke-linejoin: round;
  transition:
    fill 0.18s ease,
    stroke 0.18s ease;
}
.mini-map:hover path,
.mini-map:focus-visible path {
  fill: #8fb4de;
  stroke: #8fb4de;
}
.mini-map.active path {
  fill: #5f93cf;
  stroke: #5f93cf;
}
.mini-map text {
  fill: var(--forest);
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}
.mini-map.active text {
  fill: #fff;
  stroke: rgba(47, 68, 104, 0.45);
}
.municipality-node {
  cursor: pointer;
  outline: none;
}
.municipality-node path {
  fill: #a9c8ea;
  stroke: #fff;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
  transition:
    fill 0.18s ease,
    filter 0.18s ease;
}
.municipality-node:hover path,
.municipality-node:focus path {
  filter: brightness(0.94) drop-shadow(0 3px 3px rgba(47, 68, 104, 0.18));
}
.municipality-node:focus path {
  stroke: var(--forest);
  stroke-width: 3;
}
.municipality-node.active path {
  fill: #5f93cf;
  stroke: #fff;
}
.municipality-node text {
  fill: var(--forest);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 2px;
  stroke-linejoin: round;
}
.municipality-node.active text {
  fill: #fff;
  stroke: rgba(47, 68, 104, 0.45);
}
.map-key {
  position: absolute;
  left: 24px;
  bottom: 22px;
  z-index: 3;
  color: var(--muted);
  font-size: 12px;
}
.map-key span {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  background: #5f93cf;
}
.map-key small {
  margin-left: 16px;
  color: #8a9bb3;
  font-size: 10px;
}
.map-key .map-sources {
  display: block;
  margin: 6px 0 0;
}

.metric-panel {
  padding: 30px 34px;
  background: #fff;
  color: var(--ink);
}
.metric-heading {
  display: flex;
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.metric-heading p {
  margin-bottom: 0;
  font-family: var(--font-body);
  font-size: 25px;
}
.metric-heading span {
  color: var(--muted);
  font-size: 12px;
}
.kpis {
  display: grid;
}
.kpi {
  position: relative;
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: baseline;
  min-height: 102px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.kpi .year {
  grid-column: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.kpi .value {
  grid-column: 2;
  font-family: var(--font-body);
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1;
}
.kpi .label {
  grid-column: 3;
  max-width: 150px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.themes {
  display: grid;
  grid-template-columns: 56px 260px 1fr;
  align-items: end;
  gap: 24px;
  padding: 58px 0 24px;
  border-bottom: 1px solid var(--line);
}
.section-index {
  color: var(--blue-ink);
  font-family: var(--font-title);
  font-size: 48px;
  font-style: italic;
  line-height: 1;
}
.section-copy h2,
.compare-head h2,
.catalog-head h2,
.method-intro h2 {
  margin-bottom: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1;
}
.theme-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}
.theme {
  min-height: 39px;
  padding: 8px 14px;
  border: 1px solid #c4d3e5;
  border-radius: 999px;
  background: #fff;
  color: #55657d;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s ease;
}
.theme:hover {
  border-color: var(--blue-ink);
  color: var(--forest);
}
.theme.active {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--forest);
  font-weight: 600;
}

.theme-overview {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 56px;
  padding: 60px 0 70px;
}
.overview-copy h2 {
  font-size: clamp(38px, 5vw, 62px);
  line-height: 1.02;
}
.overview-copy > p:last-child {
  max-width: 430px;
  color: var(--muted);
  line-height: 1.65;
}
.indicator-cards {
  border-top: 1px solid var(--forest);
}
.indicator {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: center;
  min-height: 86px;
  border-bottom: 1px solid var(--line);
}
.indicator strong {
  font-family: var(--font-body);
  font-size: 30px;
  font-weight: 400;
}
.indicator span {
  color: #3b4b63;
}
.indicator small {
  color: var(--muted);
  font-size: 12px;
}

.compare-section {
  position: relative;
  margin: 0 calc(clamp(24px, 5vw, 78px) * -1);
  padding: 76px clamp(24px, 5vw, 78px);
  background: #fdf9ec;
}
.compare-section > .section-index {
  position: absolute;
  top: 76px;
  left: clamp(24px, 5vw, 78px);
}
.compare-head {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 60px;
  margin-left: 80px;
}
.compare-control {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
}
.compare-control select {
  margin-top: 8px;
  border-color: #b9c9dd;
  color: var(--forest);
}
.chart {
  display: grid;
  gap: 11px;
  margin: 42px 0 0 80px;
}
.bar-row {
  display: grid;
  grid-template-columns: 170px 1fr 80px;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.bar-track {
  height: 9px;
  background: rgba(47, 68, 104, 0.09);
  overflow: hidden;
  border-radius: 5px;
}
.bar-fill {
  width: var(--bar);
  height: 100%;
  border-radius: 5px;
  background: #8fb7e3;
  transition: width 0.35s ease;
}
.bar-fill.negative {
  background: var(--red);
}
.bar-row.selected .bar-fill {
  background: #86c99d;
}
.bar-row.selected .bar-value {
  color: var(--green-ink);
}
.bar-value {
  color: var(--blue-ink);
}
.bar-row:has(.negative) .bar-value {
  color: var(--red-ink);
}
.bar-value {
  text-align: right;
  font-weight: 600;
}

.catalog-section {
  padding: 76px 0;
}
.catalog-head {
  display: grid;
  grid-template-columns: 56px 1fr minmax(250px, 330px);
  align-items: end;
  gap: 24px;
}
.search-control input {
  width: 100%;
  height: 48px;
  border: 0;
  border-bottom: 1px solid #b9c9dd;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
}
.indicator-detail {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(190px, 0.65fr);
  gap: 26px 42px;
  margin-top: 38px;
  padding: 30px;
  background: #f6efd6;
  border-left: 6px solid #8fb7e3;
  border-radius: 0 8px 8px 0;
}
.detail-copy h3 {
  margin: 0 0 10px;
  font-family: var(--font-title);
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 400;
  line-height: 1.05;
}
.detail-copy > p:last-child {
  max-width: 630px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}
.detail-value {
  align-self: center;
  text-align: right;
}
.detail-value span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.detail-value strong {
  font-family: var(--font-body);
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 500;
  color: var(--blue-ink);
}
.detail-meta {
  display: flex;
  gap: 34px;
  margin: 0;
}
.detail-meta div {
  min-width: 90px;
}
.detail-meta dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.detail-meta dd {
  margin: 0;
  color: var(--forest);
  font-weight: 600;
}
.detail-meta a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.detail-action {
  justify-self: end;
  align-self: end;
  border: 0;
  border-bottom: 1px solid var(--forest);
  padding: 8px 0;
  background: transparent;
  color: var(--forest);
  cursor: pointer;
  font-weight: 600;
}
.detail-action span {
  margin-left: 8px;
  color: var(--red-ink);
}
.detail-action:disabled {
  color: #8a9bb3;
  cursor: default;
  opacity: 0.72;
}
.catalog-table-wrap {
  overflow-x: auto;
  margin-top: 34px;
  border-top: 2px solid var(--forest);
}
table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}
th,
td {
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
td {
  font-size: 14px;
}
td:first-child {
  font-weight: 600;
}
td:last-child {
  color: var(--forest-2);
  font-weight: 600;
}
.catalog-row {
  cursor: pointer;
  transition: background 0.15s ease;
}
.catalog-row:hover,
.catalog-row:focus {
  background: rgba(247, 227, 163, 0.35);
  outline: none;
}
.catalog-row.active {
  background: rgba(183, 211, 238, 0.4);
  box-shadow: inset 4px 0 0 var(--blue-ink);
}
.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.method-section {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 70px;
  margin: 0 calc(clamp(24px, 5vw, 78px) * -1) -80px;
  padding: 78px clamp(24px, 5vw, 78px);
  background: #f3ebcf;
  color: var(--ink);
}
.method-intro .overline {
  color: var(--blue-ink);
}
.method-intro .section-index {
  margin-bottom: 24px;
  color: var(--yellow-ink);
}
.method-intro > p:last-child {
  max-width: 410px;
  margin-top: 24px;
  color: var(--muted);
  line-height: 1.65;
}
.method-list {
  border-top: 1px solid rgba(47, 68, 104, 0.25);
}
.method-list article {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 20px;
  padding: 22px 0;
  border-bottom: 1px solid rgba(47, 68, 104, 0.14);
}
.method-list b {
  color: var(--blue-ink);
  font-weight: 600;
}
.method-list article:nth-child(4n + 2) b {
  color: var(--green-ink);
}
.method-list article:nth-child(4n + 3) b {
  color: var(--yellow-ink);
}
.method-list article:nth-child(4n) b {
  color: var(--red-ink);
}
.method-list p {
  margin-bottom: 0;
  color: #44546c;
  font-size: 14px;
  line-height: 1.55;
}
.prototype-note {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 28px;
  border-top: 1px solid rgba(47, 68, 104, 0.16);
  color: var(--muted);
  font-size: 12px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1080px) {
  :root {
    --rail: 210px;
  }
  .territory-stage {
    grid-template-columns: 1fr;
  }
  .region-map {
    height: 440px;
  }
  .themes {
    grid-template-columns: 48px 1fr;
  }
  .theme-tabs {
    grid-column: 2;
    justify-content: flex-start;
  }
  .theme-overview {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .rail {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: 0;
    padding: 16px 20px 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  .rail nav {
    order: 3;
    display: flex;
    width: 100%;
    gap: 0;
    margin-top: 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rail nav::-webkit-scrollbar {
    display: none;
  }
  .rail nav a {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    font-size: 13px;
  }
  .rail nav a span {
    width: 24px;
  }
  .rail nav a:hover,
  .rail nav a.active {
    padding-left: 14px;
    border-bottom-color: var(--yellow-ink);
  }
  .rail-note {
    display: none;
  }
  .rail-territory {
    order: 2;
    flex: 1 1 100%;
    margin-top: 12px;
  }
  .rail-territory p {
    display: none;
  }
  .rail-territory + nav {
    margin-top: 14px;
  }
  .source-link {
    text-align: right;
  }
  main {
    margin-left: 0;
  }
  .workspace {
    padding: 34px 18px 60px;
  }
  .subpage-toolbar {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-top: 4px;
  }
  .compare-page-header {
    margin: 0 -18px;
    padding: 34px 18px 32px;
  }
  .page-intro {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 35px;
    padding-bottom: 38px;
  }
  .page-intro h1 {
    font-size: 34px;
  }
  .territory-picker {
    margin-bottom: 0;
  }
  .territory-title-row {
    display: block;
  }
  .territory-title-row > p {
    margin-top: 14px;
  }
  .metric-panel {
    padding: 24px 20px;
  }
  .kpi {
    grid-template-columns: 64px 1fr;
  }
  .kpi .label {
    grid-column: 2;
    margin-top: 7px;
    text-align: left;
  }
  .themes {
    grid-template-columns: 42px 1fr;
    padding-top: 42px;
  }
  .section-index {
    font-size: 38px;
  }
  .compare-section,
  .method-section {
    margin-left: -18px;
    margin-right: -18px;
    padding-left: 18px;
    padding-right: 18px;
  }
  .compare-section > .section-index {
    left: 18px;
  }
  .compare-head {
    grid-template-columns: 1fr;
    margin-left: 55px;
  }
  .chart {
    margin-left: 0;
  }
  .bar-row {
    grid-template-columns: 112px 1fr 65px;
    gap: 8px;
  }
  .catalog-head {
    grid-template-columns: 42px 1fr;
  }
  .search-control {
    grid-column: 2;
  }
  .indicator-detail {
    grid-template-columns: 1fr;
  }
  .detail-value {
    text-align: left;
  }
  .detail-action {
    justify-self: start;
  }
  .method-section {
    grid-template-columns: 1fr;
    gap: 36px;
    margin-bottom: -60px;
  }
}
@media (max-width: 460px) {
  .brand small,
  .source-link {
    display: none;
  }
  .page-intro h1 {
    font-size: 30px;
  }
  .map-panel {
    padding: 18px;
  }
  .region-map {
    height: 360px;
  }
  .map-caption {
    display: block;
  }
  .indicator {
    grid-template-columns: 100px 1fr;
  }
  .indicator small {
    grid-column: 2;
    margin-top: 4px;
  }
  .indicator-detail {
    padding: 22px 18px;
  }
  .detail-meta {
    flex-wrap: wrap;
    gap: 18px;
  }
}

/* Página Comparar: gráfico de comparação entre anos */
.history-section {
  margin: 64px 0 0 80px;
}
.history-head {
  margin-bottom: 24px;
}
.history-head h2 {
  margin: 0;
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1;
}
.history-chart svg {
  display: block;
  width: 100%;
  height: auto;
}
.history-chart .grid {
  stroke: rgba(47, 68, 104, 0.12);
  stroke-width: 1;
}
.history-chart .axis {
  fill: var(--muted);
  font-size: 11px;
}
.history-chart .zero {
  stroke: var(--muted);
  stroke-width: 1;
}
.history-chart .year-group {
  opacity: 0.55;
}
.history-chart .year-group.selected,
.history-chart:not(:has(.selected)) .year-group {
  opacity: 1;
}
.history-chart .year-group.selected .axis {
  fill: var(--forest);
  font-weight: 600;
}
.year-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.year-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.year-legend i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}
.history-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.history-note strong {
  color: var(--forest);
}
.history-empty {
  color: var(--muted);
}
@media (max-width: 760px) {
  .history-section {
    margin-left: 0;
  }
}

/* ===== Números em cores pastel (tons mais escuros para leitura) ===== */
.kpi:nth-child(4n + 1) .value,
.indicator:nth-child(4n + 1) strong {
  color: var(--blue-ink);
}
.kpi:nth-child(4n + 2) .value,
.indicator:nth-child(4n + 2) strong {
  color: var(--green-ink);
}
.kpi:nth-child(4n + 3) .value,
.indicator:nth-child(4n + 3) strong {
  color: var(--yellow-ink);
}
.kpi:nth-child(4n) .value,
.indicator:nth-child(4n) strong {
  color: var(--red-ink);
}
.kpi:nth-child(4n + 1) .year {
  color: var(--blue-ink);
}
.kpi:nth-child(4n + 2) .year {
  color: var(--green-ink);
}
.kpi:nth-child(4n + 3) .year {
  color: var(--yellow-ink);
}
.kpi:nth-child(4n) .year {
  color: var(--red-ink);
}
.indicator {
  transition: background 0.15s ease;
}
.indicator:hover {
  background: rgba(247, 227, 163, 0.3);
}

/* Aplicar o fundo pastel escurecido da página a toda a área de fundo */
body[data-page],
body[data-page] main,
body[data-page] .workspace,
body[data-page] .page-workspace {
  background-color: var(--paper) !important;
}
body[data-page="comparar"] .compare-page-header,
body[data-page="comparar"] .compare-section,
body[data-page="metodologia"] .method-section {
  background-color: var(--paper) !important;
}
body[data-page="comparar"] .page-workspace,
body[data-page="metodologia"] .page-workspace {
  min-height: 100vh;
}
/* Gráfico de linhas (evolução por município) */
.line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-bottom: 12px;
}
.line-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--forest);
  font-size: 12px;
  cursor: pointer;
}
.line-toggle i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.line-toggle.off {
  opacity: 0.4;
  text-decoration: line-through;
}
.history-chart .line-group.dim {
  opacity: 0.5;
}
.history-chart .hover-line {
  stroke: var(--muted);
  stroke-dasharray: 3 3;
}
.line-tip {
  position: absolute;
  z-index: 5;
  min-width: 190px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  pointer-events: none;
}
.line-tip strong {
  display: block;
  margin-bottom: 6px;
  color: var(--forest);
}
.line-tip div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 1px 0;
}
.line-tip div.sel {
  font-weight: 700;
  color: var(--forest);
}

/* Rodapé */
.site-footer {
  margin-left: var(--rail);
  padding: 28px 40px;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.footer-logo {
  height: 44px;
  width: auto;
}
.footer-mail {
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
}
.footer-mail:hover {
  color: var(--blue-ink);
  text-decoration: underline;
}
.footer-social {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.footer-social a {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e6effa;
  color: var(--blue-ink);
  transition: 0.2s ease;
}
.footer-social a:hover {
  background: var(--blue-ink);
  color: #fff;
}
.footer-social svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
@media (max-width: 760px) {
  .site-footer {
    margin-left: 0;
    padding: 24px 18px;
    flex-direction: column;
    align-items: flex-start;
  }
}
/* Acesso admin (botão no fundo da barra lateral) */
.admin-toggle {
  box-sizing: border-box;
  text-decoration: none;
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: 0.2s ease;
}
.admin-toggle b {
  font-weight: 600;
  color: var(--ink);
}
.admin-toggle.on {
  border-color: #2e7d46;
  background: #e4f2e8;
}
.admin-toggle.on b {
  color: #2e7d46;
}
body:not([data-admin="on"]) #drop,
body:not([data-admin="on"]) #clear {
  display: none !important;
}

/* Controlos de administrador (só visíveis com sessão admin) */
.admin-box[hidden] {
  display: none !important;
}
.admin-box {
  margin: 0 0 20px;
  padding: 16px;
  border: 1px dashed var(--forest-2);
  border-radius: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
  max-width: 520px;
}
.admin-box h3 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--forest);
}
.admin-box input,
.admin-box textarea {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.admin-btn,
.admin-del {
  padding: 9px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--forest);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.admin-del {
  background: var(--red-ink);
  font-size: 12px;
  margin-top: 8px;
}
.admin-msg {
  font-size: 0.85rem;
  color: var(--red-ink);
  margin: 0;
}
.admin-vis {
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}
.catalog-row.is-hidden td {
  opacity: 0.45;
}
