:root {
  color-scheme: light;
  --ink: #1b222b;
  --muted: #66717f;
  --line: #dce3e8;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --blue: #3477bd;
  --blue-strong: #1458a8;
  --red: #c84c42;
  --red-strong: #a8302a;
  --gold: #b7812d;
  --green: #3f8068;
  --panel-soft: #f8fafb;
  --panel-quiet: #fbfcfd;
  --input: #ffffff;
  --hover: #edf4f7;
  --sidebar: rgba(255, 255, 255, 0.86);
  --tabs: rgba(255, 255, 255, 0.82);
  --gold-ink: #664915;
  --shadow: 0 22px 60px rgba(41, 51, 64, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(52, 119, 189, 0.08), transparent 34%),
    linear-gradient(210deg, rgba(183, 129, 45, 0.1), transparent 30%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: clamp(300px, 25vw, 360px) minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  min-width: 0;
  padding: clamp(18px, 2vw, 28px);
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  backdrop-filter: blur(10px);
}

.brand-block h1,
.toolbar h2,
.source-note h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  max-width: 13ch;
  font-size: clamp(2rem, 3.3vw, 2.9rem);
  line-height: 0.98;
}

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

.subcopy {
  margin: 14px 0 0;
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.5;
}

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

.sidebar-scope {
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(41, 51, 64, 0.07);
}

.sidebar-scope-heading,
.sidebar-baseline-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.sidebar-scope-heading span,
.sidebar-baseline-row span,
.sidebar-section-label,
.sidebar-shortcuts > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-scope-heading strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.sidebar-scope p {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.sidebar-year-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.sidebar-year-row span {
  padding: 5px 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.sidebar-year-row .active {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.sidebar-baseline-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.sidebar-baseline-row div {
  display: grid;
  gap: 2px;
}

.sidebar-baseline-row strong {
  font-size: 0.86rem;
}

.sidebar-baseline-row button {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid rgba(52, 119, 189, 0.38);
  border-radius: 6px;
  color: var(--blue-strong);
  background: rgba(52, 119, 189, 0.08);
  font-size: 0.75rem;
  font-weight: 900;
  cursor: pointer;
}

.sidebar-baseline-row button:hover {
  background: rgba(52, 119, 189, 0.15);
}

.sidebar-section-label {
  margin: 2px 0 -6px;
}

.summary-grid article,
.status-panel,
.eta-panel,
.coverage-panel,
.source-note,
.about-panel,
.methodology-thresholds,
.methodology-links,
.flagged-areas-panel,
.review-drilldown,
.details-strip,
.confidence-panel,
.candidate-breakdown,
.city-split-panel,
.coverage-table-panel,
.graph-card,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(41, 51, 64, 0.07);
}

.sidebar-shortcuts {
  display: grid;
  gap: 8px;
}

.sidebar-shortcuts > span {
  margin-bottom: -2px;
}

.theme-toggle {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-soft);
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
}

.theme-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.sidebar-shortcuts button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--blue-strong);
  background: rgba(52, 119, 189, 0.06);
  font-weight: 900;
  cursor: pointer;
}

.sidebar-shortcuts button:hover {
  border-color: rgba(52, 119, 189, 0.45);
  background: rgba(52, 119, 189, 0.12);
}

.summary-grid article {
  padding: 14px;
}

.summary-grid span,
.details-strip span,
.breakdown-heading span,
.graph-heading span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-grid strong,
.details-strip strong,
.breakdown-heading strong,
.graph-heading strong {
  font-size: 1.18rem;
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-panel .primary-button {
  grid-column: span 2;
}

.primary-button,
.secondary-button,
.mode-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.primary-button {
  color: white;
  background: var(--ink);
}

.secondary-button,
.mode-button {
  color: var(--ink);
  border-color: var(--line);
  background: white;
}

.primary-button:hover,
.secondary-button:hover,
.mode-button:hover {
  transform: translateY(-1px);
}

.mode-button.active {
  color: white;
  background: var(--green);
}

.field-label {
  margin-bottom: -10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
}

.search-input:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(52, 119, 189, 0.18);
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.status-panel,
.eta-panel,
.coverage-panel,
.source-note {
  padding: 15px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf1;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--gold));
  transition: width 180ms ease;
}

#statusText {
  margin: 11px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.collector-log {
  display: grid;
  gap: 5px;
  max-height: 170px;
  margin: 12px 0 0;
  padding: 0;
  overflow: auto;
  list-style-position: inside;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.08rem;
}

.eta-tests {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.eta-test {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.eta-badge {
  min-width: 78px;
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.eta-badge.pass {
  background: var(--green);
}

.eta-badge.flag {
  background: var(--red-strong);
}

.eta-badge.needs-data {
  background: var(--gold);
}

.eta-badge.partial {
  background: var(--gold);
}

.eta-test strong {
  display: block;
  margin-bottom: 2px;
}

.eta-test p,
.eta-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.eta-test .eta-warning {
  margin-top: 7px;
  padding: 8px 9px;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  color: #664915;
  background: rgba(183, 129, 45, 0.13);
  font-weight: 700;
}

.eta-note {
  margin-top: 11px;
}

.coverage-summary {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.coverage-list {
  display: grid;
  gap: 6px;
  max-height: 230px;
  overflow: auto;
}

.coverage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.coverage-row strong {
  font-size: 0.9rem;
}

.coverage-row span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.coverage-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.coverage-sources a {
  color: var(--blue-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.coverage-status {
  padding: 3px 7px;
  border-radius: 999px;
  color: white;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.coverage-status.partial {
  background: var(--gold);
}

.coverage-status.missing {
  background: #7c8795;
}

.coverage-status.complete {
  background: var(--green);
}

.source-note {
  margin-top: auto;
}

.source-note h2 {
  font-size: 1rem;
}

.source-note p,
.source-note span {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.source-list article {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.source-list strong,
.source-list span {
  display: block;
}

.source-list strong {
  color: var(--ink);
}

.source-list span {
  margin: 0 0 7px;
  font-size: 0.82rem;
  font-weight: 800;
}

.source-note a {
  display: inline-block;
  margin: 0 12px 6px 0;
  color: var(--blue-strong);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.map-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  min-width: 0;
  overflow-x: hidden;
}

.app-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: inline-flex;
  flex-wrap: wrap;
  align-self: start;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tabs);
  box-shadow: 0 8px 24px rgba(41, 51, 64, 0.06);
}

.app-tab-button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.app-tab-button:hover {
  color: var(--ink);
  background: rgba(52, 119, 189, 0.08);
}

.app-tab-button.active {
  color: white;
  background: var(--ink);
}

.tab-panel[hidden] {
  display: none !important;
}

.tab-panel {
  min-width: 0;
}

#dashboardPanel {
  display: grid;
  grid-template-rows: auto minmax(360px, 58vh) repeat(4, auto);
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.workspace-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.history-warning,
.history-controls,
.history-summary-panel,
.history-notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(41, 51, 64, 0.07);
}

.history-warning {
  padding: 15px 17px;
  border-left: 4px solid var(--gold);
  background: rgba(183, 129, 45, 0.1);
}

.history-warning p,
.history-summary,
.history-notes li {
  color: var(--muted);
  line-height: 1.55;
}

.history-warning p {
  margin: 6px 0 0;
}

.history-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.history-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-controls select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--input);
  font-weight: 800;
  text-transform: none;
}

.history-summary-panel,
.history-notes {
  padding: 16px;
}

.history-summary {
  margin: 9px 0 12px;
  font-weight: 700;
}

.history-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.history-table {
  min-width: 880px;
}

.history-table th,
.history-table td {
  padding: 10px 12px;
  font-size: 0.86rem;
}

.history-source-pill {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 999px;
  color: white;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: normal;
}

.history-source-pill.native {
  background: var(--green);
}

.history-source-pill.harmonized {
  background: var(--gold);
}

.history-graphs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.history-comparison-guide {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue-strong);
  border-radius: 8px;
  background: var(--panel);
}

.history-comparison-guide h3 {
  margin: 4px 0 8px;
}

.history-comparison-guide ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.history-comparison-guide li + li {
  margin-top: 4px;
}

.history-primary-graph {
  border-top: 4px solid var(--blue-strong);
}

.history-notes h3 {
  margin: 0;
}

.history-notes ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.history-notes li + li {
  margin-top: 7px;
}

.workspace-intro {
  padding: 2px 2px 4px;
}

.workspace-intro h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.55rem);
}

.workspace-intro p:last-child {
  max-width: 58rem;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.55;
}

#dashboardPanel > *,
.flagged-areas-panel,
.review-drilldown,
.coverage-table-panel,
.table-wrap,
.graph-card,
.city-split-panel {
  min-width: 0;
  max-width: 100%;
}

.about-panel {
  padding: 22px;
}

.about-hero {
  max-width: 860px;
}

.about-hero h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  letter-spacing: 0;
}

.about-hero p,
.about-grid p,
.contact-grid p,
.about-sources li {
  color: var(--muted);
  line-height: 1.55;
}

.about-hero p {
  margin: 12px 0 0;
  font-size: 1.05rem;
}

.about-grid,
.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.about-grid article,
.contact-grid article,
.about-sources {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.about-grid strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.about-grid p,
.contact-grid p {
  margin: 0;
}

.contact-grid h3,
.about-sources h3 {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

.contact-link,
.about-link-list a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-top: 12px;
  color: var(--blue-strong);
  font-weight: 900;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.about-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.about-sources {
  margin-top: 18px;
}

.about-sources ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.about-sources li + li {
  margin-top: 8px;
}

#dataPanel .coverage-panel,
#dataPanel .source-note,
#reviewPanel .eta-panel {
  padding: 18px;
}

#dataPanel .coverage-list {
  max-height: 320px;
}

#dataPanel .source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.review-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-steps li {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.review-steps li > span {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--blue-strong);
  font-weight: 900;
}

.review-steps strong,
.review-steps small {
  display: block;
}

.review-steps small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

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

.terminology-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.terminology-panel h3 {
  margin: 3px 0 12px;
  font-size: 1.15rem;
}

.terminology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 10px;
  margin: 0;
}

.terminology-grid div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.terminology-grid dt {
  color: var(--ink);
  font-weight: 900;
}

.terminology-grid dd {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.methodology-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.methodology-card h3,
.methodology-thresholds h3 {
  margin: 0;
  font-size: 1.15rem;
}

.methodology-card dl {
  display: grid;
  grid-template-columns: minmax(112px, 0.32fr) minmax(0, 1fr);
  gap: 9px 12px;
  margin: 16px 0 0;
}

.methodology-card dt {
  color: var(--ink);
  font-weight: 900;
}

.methodology-card dd,
.methodology-thresholds p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.methodology-thresholds {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  padding: 18px;
}

.methodology-thresholds p {
  margin-top: 10px;
}

.methodology-table-wrap {
  min-width: 0;
  overflow-x: auto;
}

.methodology-table-wrap table {
  width: 100%;
  min-width: 460px;
  box-shadow: none;
}

.methodology-table-wrap th,
.methodology-table-wrap td {
  padding: 9px 10px;
  font-size: 0.88rem;
}

.methodology-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  padding: 14px 18px;
}

.methodology-links a {
  color: var(--blue-strong);
  font-weight: 900;
}

.flagged-areas-panel {
  padding: 18px;
}

.flagged-areas-heading {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.flagged-areas-heading h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.flagged-areas-summary,
.flagged-areas-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}

.flagged-area-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(4, minmax(130px, 0.8fr));
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.flagged-area-filters label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.flagged-area-filters input,
.flagged-area-filters select {
  width: 100%;
  min-height: 38px;
  min-width: 0;
  padding: 0 9px;
  border: 1px solid #cfd8e3;
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: none;
}

.flagged-areas-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: 420px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.flagged-areas-table {
  min-width: 1120px;
  box-shadow: none;
}

.flagged-areas-table th,
.flagged-areas-table td {
  padding: 10px 12px;
  font-size: 0.86rem;
  vertical-align: top;
}

.flagged-areas-table td:first-child strong,
.flagged-areas-table td:first-child span {
  display: block;
}

.flagged-areas-table td:first-child span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mini-review-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: white;
  background: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.mini-review-button:hover {
  background: var(--blue-strong);
}

.review-drilldown {
  padding: 18px;
}

.review-drilldown-heading,
.review-actions,
.sensitivity-controls {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
}

.review-drilldown-heading {
  margin-bottom: 14px;
}

.review-drilldown-heading h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.review-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review-actions label,
.sensitivity-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.review-actions select,
.sensitivity-controls input {
  min-height: 38px;
  border: 1px solid #cfd8e3;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.review-actions select {
  min-width: 210px;
  padding: 0 10px;
}

.review-link-status {
  min-height: 1.25rem;
  margin: -6px 0 10px;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 850;
}

.sensitivity-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.sensitivity-controls input {
  width: 100%;
  padding: 0 9px;
}

.review-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.review-summary-grid article,
.records-request-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.review-summary-grid article > strong,
.records-request-box strong {
  display: block;
  margin: 8px 0 7px;
}

.review-summary-grid p,
.records-request-box p,
.review-why-card li span {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.review-why-card {
  grid-column: 1 / -1;
}

.review-why-card ul {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
  padding-left: 20px;
}

.review-why-card li strong {
  margin-right: 5px;
}

.records-request-box {
  margin-top: 14px;
  border-left: 4px solid var(--gold);
}

.ward-drilldown-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: 420px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.ward-drilldown-table {
  min-width: 1120px;
  box-shadow: none;
}

.ward-drilldown-table th,
.ward-drilldown-table td {
  padding: 10px 12px;
  font-size: 0.86rem;
  vertical-align: top;
}

.ward-drilldown-table td:last-child {
  color: var(--muted);
  font-weight: 750;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.toolbar h2 {
  font-size: clamp(1.35rem, 2.4vw, 2.35rem);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

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

.legend i {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}

.legend-red {
  background: var(--red);
}

.legend-blue {
  background: var(--blue);
}

.legend-neutral {
  background: #b7c0c9;
}

.map,
.tile-fallback {
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(52, 119, 189, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(52, 119, 189, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #e8f0f4, #f7faf9);
  background-size:
    38px 38px,
    38px 38px,
    auto;
  box-shadow: var(--shadow);
}

.leaflet-container {
  font: inherit;
  background:
    radial-gradient(circle at 20% 18%, rgba(52, 119, 189, 0.13), transparent 28%),
    radial-gradient(circle at 82% 72%, rgba(63, 128, 104, 0.12), transparent 26%),
    #edf4f7;
}

.county-popup {
  min-width: 190px;
}

.county-popup h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.county-popup dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  margin: 0;
}

.county-popup dt {
  color: var(--muted);
}

.county-popup dd {
  margin: 0;
  font-weight: 800;
}

.tile-fallback {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 8px;
  padding: 12px;
  overflow: auto;
}

.county-tile {
  min-height: 78px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 7px;
  color: white;
  text-align: left;
  cursor: pointer;
}

.county-tile span,
.county-tile strong {
  display: block;
}

.county-tile span {
  font-size: 0.78rem;
  opacity: 0.9;
}

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

.confidence-panel,
.coverage-table-panel {
  padding: 14px;
}

.confidence-summary {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.confidence-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.confidence-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: normal;
}

.confidence-pill.strong {
  background: var(--green);
}

.confidence-pill.review,
.confidence-pill.partial,
.confidence-pill.warning {
  background: var(--gold);
}

.confidence-pill.missing {
  background: #7c8795;
}

.plain-method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.plain-method-grid article {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.plain-method-grid strong {
  display: block;
  margin-bottom: 5px;
}

.plain-method-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.candidate-breakdown {
  padding: 14px;
}

.breakdown-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.breakdown-heading p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
}

.candidate-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.candidate-chip span {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-chip strong {
  flex: 0 0 auto;
}

.eta-graphs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.city-split-panel {
  padding: 14px;
}

.city-split-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.city-split-heading h2 {
  margin: 0;
  font-size: 1.18rem;
}

.city-split-heading label {
  display: grid;
  gap: 5px;
  min-width: min(320px, 100%);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.city-split-heading select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: none;
}

.city-split-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
}

.city-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.split-graph {
  min-width: 0;
}

.split-graph strong {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.split-surface {
  min-height: 0;
  height: clamp(220px, 24vw, 300px);
}

.split-surface svg {
  width: 100%;
  height: 100%;
}

.graph-card {
  min-width: 0;
  padding: 14px;
}

.graph-card-wide {
  grid-column: 1 / -1;
}

.graph-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.graph-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.graph-info {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--blue-strong);
  background: white;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.graph-info-warning {
  color: white;
  border-color: var(--gold);
  background: var(--gold);
}

.graph-download {
  margin: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.graph-surface {
  min-height: 310px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
}

.graph-surface svg {
  display: block;
  width: 100%;
  height: auto;
}

.historical-distribution-surface {
  min-height: 0;
}

.graph-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 7px;
  color: #664915;
  background: rgba(183, 129, 45, 0.12);
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.35;
}

.graph-note:empty {
  display: none;
}

.graph-explainer {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.graph-explainer strong {
  display: block;
  margin-bottom: 5px;
}

.graph-explainer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.48;
}

.graph-explainer p + p {
  margin-top: 8px;
}

.warning-explainer {
  border-left: 3px solid var(--gold);
  background: rgba(183, 129, 45, 0.1);
}

.table-panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.table-panel-heading h2 {
  margin: 0;
  font-size: 1.18rem;
}

.table-panel-heading p:last-child {
  max-width: 48rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.4;
  text-align: right;
}

.coverage-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.coverage-table {
  min-width: 900px;
  table-layout: fixed;
}

.coverage-table th:nth-child(1),
.coverage-table td:nth-child(1) {
  width: 12%;
}

.coverage-table th:nth-child(2),
.coverage-table td:nth-child(2) {
  width: 14%;
}

.coverage-table th:nth-child(3),
.coverage-table td:nth-child(3) {
  width: 28%;
}

.coverage-table th:nth-child(4),
.coverage-table td:nth-child(4) {
  width: 18%;
}

.coverage-table th:nth-child(5),
.coverage-table td:nth-child(5) {
  width: 28%;
}

.coverage-table td {
  vertical-align: top;
  white-space: normal;
}

.coverage-table th,
.coverage-table td {
  padding: 10px 12px;
}

.coverage-table .confidence-pill {
  white-space: nowrap;
}

.coverage-table-sources {
  display: grid;
  gap: 4px;
}

.coverage-cell-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.coverage-table-sources span,
.coverage-table-sources a {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.coverage-table-sources a {
  color: var(--blue-strong);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.checked-log {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.checked-log > strong {
  display: block;
}

.checked-log > p {
  margin: 5px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

#checkedNotUsableList {
  display: grid;
  gap: 8px;
}

#checkedNotUsableList article {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

#checkedNotUsableList p,
#checkedNotUsableList span {
  display: block;
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

#checkedNotUsableList a {
  color: var(--blue-strong);
  font-weight: 800;
}

.graph-axis {
  stroke: #7c8795;
  stroke-width: 1;
}

.graph-grid {
  stroke: #dce3e8;
  stroke-width: 1;
}

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

.axis-help-label {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.technical-term {
  position: relative;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

.technical-term::after {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: min(320px, 78vw);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(20, 29, 39, 0.18);
  content: attr(data-definition);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.technical-term:hover::after,
.technical-term:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.audit-caution,
.audit-explainer-grid article,
.audit-simulator,
.audit-sources {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.audit-caution {
  border-left: 4px solid var(--gold);
}

.audit-caution p,
.audit-explainer-grid p,
.audit-preset-note,
.audit-distribution-note,
.audit-minimum-margin-note,
.audit-scenario-summary {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.audit-facts,
.audit-explainer-grid,
.audit-result-grid {
  display: grid;
  gap: 10px;
}

.audit-facts {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.audit-facts article,
.audit-result-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.audit-facts strong,
.audit-result-grid strong {
  display: block;
  color: var(--ink);
  font-size: 1.45rem;
}

.audit-facts span,
.audit-result-grid span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.audit-explainer-grid h3,
.audit-controls h3,
.audit-sources h3 {
  margin: 3px 0 0;
}

.audit-simulator {
  display: grid;
  grid-template-columns: minmax(250px, 0.78fr) minmax(0, 1.22fr);
  gap: 18px;
}

.audit-controls {
  display: grid;
  align-content: start;
  gap: 12px;
}

.audit-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.audit-controls label > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.audit-controls .audit-checkbox-control {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  color: var(--ink);
}

.audit-checkbox-control input {
  margin-top: 3px;
}

.audit-controls select {
  min-height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-soft);
  font: inherit;
}

.audit-controls output {
  color: var(--ink);
}

.audit-result-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.audit-result-grid strong {
  margin-top: 5px;
  font-size: 1.12rem;
}

.audit-trial-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 18px;
  align-items: center;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue-strong);
  border-radius: 7px;
  background: var(--panel-soft);
}

.audit-trial-panel h4,
.audit-trial-panel p {
  margin: 3px 0 0;
}

.audit-trial-panel > strong {
  color: var(--blue-strong);
  font-size: 1.35rem;
}

.audit-trial-progress {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
}

.audit-trial-progress[hidden] {
  display: none;
}

.audit-trial-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--blue-strong);
}

.audit-trial-progress span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.audit-trial-panel > p {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.audit-missed {
  color: var(--gold) !important;
}

.audit-touched {
  color: var(--green) !important;
}

.audit-grid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

.audit-unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18px, 1fr));
  gap: 4px;
}

.audit-unit-grid.dense {
  grid-template-columns: repeat(auto-fill, minmax(8px, 1fr));
  gap: 2px;
}

.audit-unit {
  display: inline-block;
  min-height: 18px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-soft);
}

.audit-unit-grid.dense .audit-unit {
  min-height: 8px;
}

.audit-unit.sampled {
  border-color: var(--blue-strong);
  background: var(--blue-strong);
}

.audit-unit.affected {
  border-color: var(--gold);
  background: var(--gold);
}

.audit-unit.overlap {
  border-color: var(--red-strong);
  background: var(--red-strong);
  box-shadow: inset 0 0 0 3px var(--panel);
}

.audit-sources ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.audit-sources li + li {
  margin-top: 7px;
}

.audit-sources a {
  color: var(--blue-strong);
  font-weight: 800;
}

.audit-vote-comparison {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.audit-vote-comparison h4 {
  margin: 3px 0 10px;
}

.audit-vote-comparison-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.audit-vote-comparison-grid article {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.audit-vote-comparison-grid span,
.audit-vote-comparison-grid small,
.audit-vote-comparison-grid strong {
  display: block;
}

.audit-vote-comparison-grid span,
.audit-vote-comparison-grid small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.4;
}

.audit-vote-comparison-grid strong {
  margin: 5px 0;
  color: var(--ink);
  font-size: 1.15rem;
}

.graph-title {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.graph-warning-text {
  fill: #664915;
  font-size: 15px;
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
}

.county-table-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 0;
}

.county-table-note strong {
  font-size: 1rem;
}

.county-table-note span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.county-table-note .review-flag {
  width: 18px;
  height: 18px;
  font-style: normal;
  font-size: 0.72rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

.review-cell {
  text-align: center;
}

.review-flag {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: white;
  background: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.split-review-flag {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  font-size: 0.72rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: white;
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #edf4f7;
}

.party-r {
  color: var(--red-strong);
  font-weight: 800;
}

.party-d {
  color: var(--blue-strong);
  font-weight: 800;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef3f7;
  --muted: #afbdc9;
  --line: #40505d;
  --paper: #111820;
  --panel: #1b2630;
  --blue: #65a8e8;
  --blue-strong: #8bc3f5;
  --red: #df7169;
  --red-strong: #f08b83;
  --gold: #d3a24e;
  --green: #5ea98d;
  --panel-soft: #202d37;
  --panel-quiet: #1d2933;
  --input: #14202a;
  --hover: #263846;
  --sidebar: rgba(20, 30, 39, 0.96);
  --tabs: rgba(27, 38, 48, 0.96);
  --gold-ink: #f0cf88;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] body {
  background:
    linear-gradient(120deg, rgba(101, 168, 232, 0.08), transparent 34%),
    linear-gradient(210deg, rgba(211, 162, 78, 0.08), transparent 30%),
    var(--paper);
}

html[data-theme="dark"] .secondary-button,
html[data-theme="dark"] .mode-button,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .graph-info,
html[data-theme="dark"] .graph-download,
html[data-theme="dark"] .city-split-heading select,
html[data-theme="dark"] .review-actions select,
html[data-theme="dark"] .sensitivity-controls input,
html[data-theme="dark"] .flagged-area-filters input,
html[data-theme="dark"] .flagged-area-filters select,
html[data-theme="dark"] th {
  color: var(--ink);
  background: var(--input);
}

html[data-theme="dark"] .eta-test,
html[data-theme="dark"] .coverage-row,
html[data-theme="dark"] .about-grid article,
html[data-theme="dark"] .contact-grid article,
html[data-theme="dark"] .about-sources,
html[data-theme="dark"] .review-steps li,
html[data-theme="dark"] .methodology-card,
html[data-theme="dark"] .flagged-area-filters,
html[data-theme="dark"] .sensitivity-controls,
html[data-theme="dark"] .review-summary-grid article,
html[data-theme="dark"] .records-request-box,
html[data-theme="dark"] .plain-method-grid article,
html[data-theme="dark"] .candidate-chip,
html[data-theme="dark"] .graph-surface,
html[data-theme="dark"] .graph-explainer,
html[data-theme="dark"] .checked-log,
html[data-theme="dark"] .flagged-areas-table-wrap,
html[data-theme="dark"] .ward-drilldown-table-wrap {
  background: var(--panel-soft);
}

html[data-theme="dark"] tbody tr:hover,
html[data-theme="dark"] tbody tr.is-selected {
  background: var(--hover);
}

html[data-theme="dark"] .graph-grid {
  stroke: #40505d;
}

html[data-theme="dark"] .eta-test .eta-warning,
html[data-theme="dark"] .graph-note {
  color: var(--gold-ink);
}

html[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(0.72) contrast(1.08) saturate(0.76);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow-y: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-block h1 {
    max-width: 16ch;
  }

  #dashboardPanel {
    grid-template-rows: auto minmax(340px, 58vh) repeat(4, auto);
  }

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

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

@media (max-width: 640px) {
  .sidebar,
  .map-stage {
    padding: 16px;
  }

  .toolbar,
  .details-strip,
  .breakdown-heading,
  .table-panel-heading,
  .city-split-heading,
  .flagged-areas-heading,
  .review-drilldown-heading,
  .review-actions,
  .graph-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .eta-graphs,
  .history-graphs,
  .history-controls,
  .plain-method-grid,
  .city-split-grid,
  .about-grid,
  .contact-grid,
  #dataPanel .source-list,
  .methodology-grid,
  .methodology-thresholds,
  .audit-facts,
  .audit-explainer-grid,
  .audit-simulator,
  .audit-result-grid,
  .audit-trial-panel,
  .audit-vote-comparison-grid,
  .review-steps,
  .flagged-area-filters,
  .review-summary-grid,
  .sensitivity-controls {
    grid-template-columns: 1fr;
  }


  .summary-grid,
  .control-panel,
  .mode-row,
  .app-tabs {
    grid-template-columns: 1fr;
  }

  .app-tabs {
    display: grid;
    align-self: stretch;
  }

  .control-panel .primary-button {
    grid-column: auto;
  }
}
