:root {
  --bg: #f7f8f5;
  --panel: #ffffff;
  --ink: #1f2a24;
  --muted: #68746d;
  --line: #dce2dd;
  --accent: #1f7a5a;
  --accent-2: #d96c2c;
  --accent-3: #2456a6;
  --danger: #b83232;
  --topbar-height: 74px;
  --footer-height: 38px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  min-height: var(--topbar-height);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  height: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 20px;
  line-height: 1;
}

.brand-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-title {
  display: none;
}

.app-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f3;
}

.nav-button {
  height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.nav-button.active {
  background: var(--ink);
  color: #fff;
}

.doc-link {
  height: 34px;
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
  white-space: nowrap;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  margin-bottom: 12px;
}

.topbar p,
.source-note,
.empty,
.detail-header p {
  color: var(--muted);
  font-size: 13px;
}

.source-note {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  white-space: nowrap;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfa;
}

.docs-view.active {
  display: block;
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
  padding: 18px;
}

.docs-panel {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.docs-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4fbf6;
}

.docs-hero span,
.docs-grid span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.docs-hero h2 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.1;
}

.docs-hero p {
  max-width: 720px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.docs-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.docs-hero a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.docs-grid,
.docs-flow,
.docs-notes {
  display: grid;
  gap: 12px;
}

.docs-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.docs-flow {
  grid-template-columns: 1fr 1fr;
}

.docs-grid > section,
.docs-flow > section,
.docs-notes > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.docs-grid h3,
.docs-notes h3 {
  margin: 8px 0 0;
  font-size: 18px;
}

.docs-grid p,
.docs-notes p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.docs-steps {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.docs-steps li {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.docs-steps b {
  color: var(--accent-3);
}

.docs-steps span,
.docs-cnaes span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.docs-cnaes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.docs-cnaes > div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.docs-cnaes b {
  color: var(--ink);
  font-size: 13px;
}

.docs-notes {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.source-note span,
.source-note strong {
  display: block;
  padding: 4px 7px;
}

.source-note strong {
  border-radius: 999px;
  background: #edf3ee;
  color: var(--ink);
  font-size: 12px;
}

.view[hidden] {
  display: none;
}

#mapView.active {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-view.active {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
  padding: 18px;
}

.content-view {
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
  padding: 18px;
}

#citiesView.active {
  height: calc(100vh - var(--topbar-height) - var(--footer-height));
  min-height: 0;
  overflow: hidden;
}

#docsView.active {
  display: block;
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
  padding: 18px;
  overflow: visible;
}

.state-view.active {
  display: block;
  height: calc(100vh - var(--topbar-height) - var(--footer-height));
  padding: 12px;
  overflow: hidden;
}

.state-panel {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.state-header {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}

.state-title-block {
  grid-column: 2;
  text-align: center;
}

.state-title-block h2 {
  font-size: 30px;
  line-height: 1.05;
}

.state-title-block p {
  margin-top: 4px;
}

.state-header p {
  color: var(--muted);
  font-size: 13px;
}

.state-filter-box {
  grid-column: 3;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.state-filter-box label {
  width: 100%;
}

.state-filter-box select {
  width: 100%;
}

.state-grid {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(300px, 1fr) minmax(280px, .9fr);
  gap: 10px;
  min-height: 0;
}

.state-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.state-card.is-selected {
  border-color: rgba(31, 122, 90, .55);
  box-shadow: inset 0 0 0 1px rgba(31, 122, 90, .16);
}

.state-card .ranking,
.state-card .category-bars {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #f3f6f2;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 52px;
  padding: 8px 10px;
  background: #fff;
}

.metric-primary {
  border-color: var(--line);
  background: #fff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 19px;
  line-height: 1;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input,
button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

select,
input {
  min-width: 0;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

button {
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.city-search {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  gap: 8px;
}

.panel-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 16px;
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 560px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 360px);
  min-height: calc(100vh - var(--topbar-height) - var(--footer-height) - 74px);
}

#map {
  height: 100%;
  min-height: inherit;
}

.map-mode {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 500;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.map-heat-legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 500;
  display: grid;
  grid-template-columns: auto 120px auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .94);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.heat-gradient {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2b83ba, #44b7a5, #abdda4, #fdae61, #f46d43, #d73027);
}

.map-filter-control {
  position: absolute;
  right: 16px;
  top: 58px;
  z-index: 600;
  display: grid;
  justify-items: end;
  gap: 8px;
  width: min(340px, calc(100% - 32px));
}

.filter-toggle {
  width: max-content;
  height: 34px;
  padding: 0 12px;
  border-color: var(--line);
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-summary {
  width: max-content;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-panel {
  display: grid;
  gap: 9px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 8px 24px rgba(31, 42, 36, .12);
}

.filter-panel label {
  font-size: 11px;
}

.filter-panel select {
  height: 34px;
  font-size: 12px;
}

.filter-panel .clear-filters {
  height: 34px;
  font-size: 12px;
  font-weight: 800;
}

.filter-panel[hidden],
.filter-summary[hidden],
.clear-filters[hidden] {
  display: none;
}

.clear-filters {
  background: #fff;
  color: var(--accent);
  border-radius: 16px;
}

.map-empty {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  z-index: 500;
  max-width: 620px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.map-summary,
.list-panel,
.detail-panel,
.data-panel {
  padding: 14px;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
}

.map-summary section {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.list-panel,
.detail-panel,
.data-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#citiesView .list-panel {
  overflow: hidden;
}

.list-panel > .ranking {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.detail-panel {
  min-height: 520px;
}

.data-panel {
  grid-column: 1 / -1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
}

.insight-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4fbf6;
}

.insight-hero span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.insight-hero h2 {
  margin-top: 4px;
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

.insight-hero strong {
  max-width: 460px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  text-transform: uppercase;
}

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

.data-grid.insight-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

.data-grid > div,
.insight-panels > section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.insight-card {
  min-height: 118px;
  display: grid;
  align-content: start;
  position: relative;
  overflow: visible;
}

.insight-card.is-primary {
  border-color: rgba(31, 122, 90, .42);
  background: #f4fbf6;
}

.insight-card.is-primary strong {
  font-size: 34px;
}

.insight-card.is-primary p {
  max-width: 360px;
}

.data-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.data-grid p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.insight-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.insight-panels > section {
  min-height: 0;
  overflow: visible;
  background: #fff;
}

.donut-panel {
  display: grid;
  grid-template-columns: minmax(170px, 210px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.donut-wrap {
  position: relative;
  width: min(100%, 210px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg,
.donut-segment {
  fill: transparent;
  stroke-width: 5;
}

.donut-bg {
  stroke: #e7ece8;
}

.donut-segment {
  transition: stroke-dasharray .2s ease;
}

.donut-center {
  position: absolute;
  inset: 28%;
  display: grid;
  place-content: center;
  text-align: center;
}

.donut-center strong {
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.donut-center span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.donut-legend {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.legend-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-row strong {
  color: var(--ink);
  font-size: 13px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.insight-deep-grid {
  display: grid;
  grid-template-columns: 1.2fr .9fr 1fr;
  gap: 12px;
}

.insight-deep-grid > section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.insight-rank-bars {
  display: grid;
  gap: 10px;
}

.rank-bar-row {
  display: grid;
  gap: 6px;
}

.rank-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  color: var(--muted);
  font-size: 13px;
}

.rank-bar-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar-label b,
.rank-bar-label strong {
  color: var(--accent-3);
}

.insight-band-list,
.insight-narratives {
  display: grid;
  gap: 8px;
}

.band-card,
.insight-narratives > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.band-card:first-child,
.insight-narratives > div:first-child {
  border-color: rgba(36, 86, 166, .28);
  background: #f4f7fd;
}

.band-card span,
.insight-narratives span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.band-card strong,
.insight-narratives strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.band-card p,
.insight-narratives p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.state-card .section-title {
  margin-bottom: 8px;
}

.section-title h2 {
  margin-bottom: 0;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.category-bars {
  display: grid;
  grid-auto-rows: minmax(58px, 1fr);
  gap: 8px;
  flex: 1;
}

.bar-row {
  height: auto;
  display: grid;
  gap: 6px;
  width: 100%;
  align-content: center;
  padding: 10px;
  border-color: var(--line);
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
}

.bar-row:hover,
.linklike:hover {
  border-color: rgba(31, 122, 90, .48);
  background: #f5faf6;
}

.bar-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-heading strong {
  color: var(--accent);
}

.bar-track {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece8;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.ranking {
  padding-left: 0;
  margin: 0;
  list-style: none;
}

.ranking li {
  margin: 8px 0;
}

.state-card .ranking li {
  margin: 5px 0;
}

.linklike {
  width: 100%;
  height: auto;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.state-card .linklike {
  min-height: 34px;
  padding: 6px 8px;
}

.state-card .bar-row {
  padding: 6px 8px;
}

.state-card .category-bars {
  grid-auto-rows: minmax(40px, 1fr);
  gap: 5px;
}

.state-card .bar-track {
  height: 5px;
}

.linklike span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linklike strong {
  color: var(--accent-3);
  font-size: 13px;
}

.ranked-link b {
  display: inline-flex;
  min-width: 32px;
  color: var(--accent-3);
}

.ranked-link.is-selected {
  border-color: rgba(31, 122, 90, .55);
  background: #f4fbf6;
}

.empty-list {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 14px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.detail-header h2 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.12;
}

.city-rank {
  display: inline-block;
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.chip {
  height: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--ink);
  font-size: 13px;
  background: #fbfcfa;
}

.category-chip {
  cursor: pointer;
}

.category-chip.is-selected {
  border-color: rgba(31, 122, 90, .55);
  background: #f4fbf6;
  color: var(--accent);
}

.table-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 12px 0;
}

.table-tools input {
  width: 100%;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f2f5f1;
  font-size: 12px;
}

.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
}

.pager button {
  background: #fff;
  color: var(--accent);
}

.notice {
  margin-top: 10px;
  padding: 10px;
  border-left: 4px solid var(--accent-2);
  background: #fff7f0;
  color: #6b3a1e;
  font-size: 14px;
}

.error {
  border-left-color: var(--danger);
  background: #fff4f4;
  color: #7a1f1f;
}

@media (max-width: 980px) {
  .content-view,
  .map-layout,
  .state-header,
  .state-grid {
    grid-template-columns: 1fr;
  }

  #citiesView.active {
    height: auto;
    overflow: visible;
  }

  #citiesView .list-panel {
    max-height: min(620px, 70vh);
  }

  .map-layout {
    min-height: 0;
  }

  .map-wrap {
    min-height: min(68vh, 620px);
  }

  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-summary {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }

  .topbar,
  .state-header {
    align-items: stretch;
    gap: 10px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .state-view.active {
    height: auto;
    min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
    overflow: visible;
  }

  .content-view.active {
    height: auto;
    min-height: calc(100vh - var(--topbar-height) - var(--footer-height));
    overflow: visible;
  }

  .state-panel {
    height: auto;
    overflow: visible;
  }

  .state-card {
    overflow: visible;
  }

  .state-title-block,
  .state-filter-box {
    grid-column: auto;
  }

  .state-title-block h2 {
    font-size: 28px;
  }

  .source-note {
    text-align: left;
    border-radius: 8px;
    width: max-content;
    max-width: 100%;
  }

  .city-search {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

  .app-nav {
    width: 100%;
    overflow-x: auto;
  }

  .nav-button {
    flex: 1;
  }

  .doc-link {
    flex: 1;
  }

  .docs-hero {
    align-items: start;
    flex-direction: column;
  }

  .docs-actions {
    justify-content: flex-start;
  }

  .docs-grid,
  .docs-flow,
  .docs-notes {
    grid-template-columns: 1fr;
  }

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

  .data-grid.insight-grid,
  .insight-panels,
  .insight-deep-grid {
    grid-template-columns: 1fr;
  }

  .insight-hero {
    align-items: start;
    flex-direction: column;
  }

  .insight-hero strong {
    max-width: none;
    text-align: left;
  }

  .donut-panel {
    grid-template-columns: 1fr;
  }

  .insight-panels > section {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
    gap: 6px;
  }

  .metric {
    min-height: 54px;
    padding: 8px;
  }

  .metric span {
    font-size: 10px;
  }

  .metric strong {
    font-size: 18px;
  }

  .state-title-block h2 {
    font-size: 24px;
  }

  .map-wrap {
    min-height: 62vh;
  }

  .map-filter-control {
    left: 10px;
    right: 10px;
    top: 48px;
    width: auto;
  }

  .filter-panel {
    max-height: calc(62vh - 24px);
    overflow: auto;
  }

  .map-mode {
    top: 10px;
    right: 10px;
    padding: 6px 8px;
  }

  .map-heat-legend {
    left: 10px;
    right: auto;
    bottom: 10px;
    grid-template-columns: auto 88px auto;
    padding: 6px 8px;
  }

  .city-search,
  .panel-search {
    grid-template-columns: 1fr;
  }

  .source-note {
    white-space: normal;
  }

  .brand-copy span {
    display: none;
  }

  .docs-hero h2 {
    font-size: 24px;
  }

  .docs-cnaes,
  .docs-steps li {
    grid-template-columns: 1fr;
  }

  .content-view.active,
  .state-view.active {
    padding: 10px;
  }
}

/* Footer Styling */
.app-footer {
  height: var(--footer-height);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  z-index: 1000;
  position: relative;
  opacity: 0.85;
}

.footer-content {
  width: 100%;
  max-width: 1200px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-content p {
  margin: 0;
}

.app-footer a {
  color: var(--muted);
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s ease;
}

.app-footer a:hover {
  color: var(--ink);
}

@media (max-width: 600px) {
  .app-footer {
    height: auto;
    padding: 8px 0;
  }
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 4px;
  }
}
