:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --page: #eef2f7;
  --accent: #1d63a5;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(22, 30, 45, 0.08);
  z-index: 2;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 30px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

.summary {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-grid div,
.selected-card,
.legend,
.view-mode {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.metric-grid div {
  padding: 16px;
}

.metric-grid span {
  display: block;
  min-height: 29px;
  font-size: 24px;
  font-weight: 800;
}

.metric-grid p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.legend {
  padding: 16px;
}

.legend-head,
.legend-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.legend-ramp {
  height: 14px;
  margin: 12px 0 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(252, 174, 145, 1),
    rgba(254, 229, 217, 1),
    rgba(189, 215, 231, 1),
    rgba(158, 202, 225, 1),
    rgba(142, 191, 221, 1),
    rgba(132, 184, 218, 1),
    rgba(123, 180, 216, 1),
    rgba(115, 177, 215, 1),
    rgba(107, 174, 214, 1),
    rgba(49, 130, 189, 1),
    #08519c
  );
}

.view-mode {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.view-mode label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.view-mode select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.view-mode select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.selected-card {
  padding: 18px;
}

.selected-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.map-wrap {
  position: relative;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
}

.tooltip {
  position: fixed;
  display: none;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid rgba(24, 33, 47, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(21, 31, 47, 0.18);
  color: var(--ink);
  font-size: 13px;
  pointer-events: none;
  z-index: 5;
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.tooltip span {
  display: block;
  margin-top: 3px;
}

.tooltip-table,
.info-table,
.selected-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tooltip-table tr,
.info-table tr,
.selected-table tr {
  border-bottom: 1px solid #e8edf4;
}

.tooltip-table tr:last-child,
.info-table tr:last-child,
.selected-table tr:last-child {
  border-bottom: 0;
}

.tooltip-table .table-divider-row,
.info-table .table-divider-row,
.selected-table .table-divider-row {
  border-bottom: 0;
}

.tooltip-table th,
.tooltip-table td,
.info-table th,
.info-table td,
.selected-table th,
.selected-table td {
  padding: 5px 0;
}

.tooltip-table th,
.info-table th,
.selected-table th {
  color: var(--muted);
  font-weight: 700;
  text-align: left;
}

.tooltip-table td,
.info-table td,
.selected-table td {
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}

.tooltip-table .percentage-row,
.info-table .percentage-row,
.selected-table .percentage-row {
  background: rgba(29, 99, 165, 0.1);
  border-bottom-color: rgba(29, 99, 165, 0.22);
}

.tooltip-table .percentage-row th,
.tooltip-table .percentage-row td,
.info-table .percentage-row th,
.info-table .percentage-row td,
.selected-table .percentage-row th,
.selected-table .percentage-row td {
  color: #08519c;
  font-weight: 900;
}

.tooltip-table .percentage-row th,
.info-table .percentage-row th,
.selected-table .percentage-row th {
  padding-left: 6px;
}

.tooltip-table .percentage-row td,
.info-table .percentage-row td,
.selected-table .percentage-row td {
  padding-right: 6px;
}

.selected-table {
  font-size: 13px;
}

.selected-table th,
.selected-table td {
  padding: 8px 0;
}

.table-divider-row td {
  padding: 6px 0;
}

.table-divider-row hr {
  height: 1px;
  margin: 0;
  border: 0;
  background: #d8dee8;
}

.district-label {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
  line-height: 1.1;
  text-shadow: 0 1px 1px #ffffff;
  white-space: nowrap;
}

.district-label--imagery {
  background: rgba(15, 23, 42, 0.58);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.34);
  text-shadow: 0 1px 2px #000000;
}

.info-window {
  min-width: 260px;
  color: var(--ink);
}

.info-window h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(560px, 1fr);
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 20px;
  }

  h1 {
    font-size: 26px;
  }

  .map-wrap {
    min-height: 560px;
  }
}
