:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #66717f;
  --border: #d9dee5;
  --accent: #173f5f;
  --accent-soft: #e9f0f5;
  --positive: #276749;
  --negative: #9b2c2c;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, select, input {
  font: inherit;
}

.topbar {
  padding: 28px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar h1 {
  margin: 4px 0 6px;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.03em;
}

main {
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.controls label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

select, .search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  margin: 20px 0;
  padding-bottom: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

.tab, .link-button {
  border: 0;
  cursor: pointer;
}

.tab {
  border-radius: 999px;
  padding: 9px 14px;
  background: #e9ecef;
  color: var(--text);
}

.tab.is-active {
  background: var(--accent);
  color: white;
}

.view { display: none; }
.view.is-active { display: block; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 26px 0 14px;
}

.section-heading.compact {
  margin: 0 0 18px;
  align-items: start;
}

.section-heading h2,
.section-heading h3 {
  margin: 3px 0 0;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.muted { color: var(--muted); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi {
  padding: 18px;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  min-height: 32px;
}

.kpi .value {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.kpi a {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--accent);
}

#overview > .panel,
#series .panel,
#compare .panel,
#map .panel,
#dictionary .panel {
  padding: 20px;
}

.selected-value {
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.link-button {
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 700;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  font-size: 12px;
  color: var(--muted);
}

.dictionary-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.dictionary-item,
.methodology-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 16px;
}

.dictionary-item h3,
.methodology-item h3 {
  margin: 0 0 8px;
}

.dictionary-item p,
.methodology-item p {
  margin: 6px 0;
}

.methodology-list {
  display: grid;
  gap: 14px;
}

#series-chart {
  width: 100%;
  min-height: 320px;
  background: linear-gradient(to bottom, rgba(23,63,95,.03), transparent);
  border-radius: 10px;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(760px, calc(100% - 28px));
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}

dialog::backdrop {
  background: rgba(22, 30, 38, .48);
}

.dialog-shell {
  position: relative;
  padding: 26px;
}

.dialog-close {
  position: absolute;
  right: 14px;
  top: 10px;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}

.definition-grid {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 10px 16px;
}

.definition-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.definition-grid dd {
  margin: 0;
}

@media (max-width: 900px) {
  .controls,
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .controls,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  main {
    width: min(100% - 20px, 1440px);
  }

  .definition-grid {
    grid-template-columns: 1fr;
  }
}


.map-panel {
  position: relative;
  overflow: hidden;
}

#municipal-map {
  width: 100%;
  min-height: 520px;
  background: #eef2f5;
  border-radius: 10px;
}

.map-feature {
  stroke: #ffffff;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: opacity .12s ease, stroke-width .12s ease;
}

.map-feature:hover,
.map-feature.is-selected {
  stroke: #111827;
  stroke-width: 2.5;
}

.map-feature.is-missing {
  fill: #dfe4e9;
}

.map-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-swatch {
  width: 18px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.08);
}

.map-empty {
  padding: 28px;
  color: var(--muted);
}


.profile-grid,
.sources-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.profile-panel,
.sources-grid > .panel,
#crosswalk .panel {
  padding: 18px;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.pair-item,
.source-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.pair-item:last-child,
.source-item:last-child {
  border-bottom: 0;
}

.theme-groups {
  display: grid;
  gap: 16px;
}

.theme-section {
  padding: 18px;
}

.theme-section h3 {
  margin: 0 0 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

.metric-card .metric-name {
  color: var(--muted);
  font-size: 12px;
  min-height: 34px;
}

.metric-card .metric-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 8px;
}

.coverage-good { color: var(--positive); }
.coverage-warning { color: var(--negative); }

@media (max-width: 900px) {
  .profile-grid,
  .sources-grid,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .profile-grid,
  .sources-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}
