:root {
  --ink: #172033;
  --slate: #44566d;
  --muted: #748499;
  --paper: #ffffff;
  --wash: #f5f8fb;
  --line: #d9e0ea;
  --teal: #166a8f;
  --red: #b94b4b;
  --amber: #d99a2b;
  --green: #2e7d61;
}

* {
  box-sizing: border-box;
}

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

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

.panel {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  max-height: 100vh;
  padding: 26px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 30px rgba(23, 32, 51, 0.08);
}

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

.eyebrow,
.profile-kicker {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: 2rem;
  line-height: 1.03;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.1rem;
}

p {
  color: var(--slate);
  line-height: 1.45;
}

.control-card,
.legend,
.profile,
.source-card {
  margin-top: 20px;
  padding: 18px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--slate);
  font-size: 0.82rem;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.legend-row,
.metric-row,
.district-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(217, 224, 234, 0.85);
}

.legend-row:last-child,
.metric-row:last-child,
.district-row:last-child {
  border-bottom: 0;
}

.swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 3px;
}

.metric-label,
.district-name {
  color: var(--slate);
  font-weight: 700;
}

.district-row > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.metric-value,
.district-value {
  flex: 0 0 auto;
  text-align: right;
  font-weight: 800;
}

.profile h2 {
  margin-bottom: 4px;
  font-size: 1.55rem;
}

.district-list {
  margin-top: 16px;
}

.status-pill {
  display: inline-block;
  padding: 4px 8px;
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  border-radius: 999px;
}

.map-wrap {
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100vh;
  background: #edf2f7;
}

.toolbar {
  position: absolute;
  z-index: 500;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 10px;
}

button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.14);
  cursor: pointer;
}

button:hover {
  background: #fff;
}

.county-label {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 #fff,
    1px 0 0 #fff,
    0 -1px 0 #fff,
    -1px 0 0 #fff;
}

.leaflet-tooltip.county-label {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.district-drilldown-label {
  max-width: 96px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  white-space: pre-line;
  text-shadow:
    0 1px 2px rgba(23, 32, 51, 0.85),
    1px 0 2px rgba(23, 32, 51, 0.7),
    -1px 0 2px rgba(23, 32, 51, 0.7);
  pointer-events: none;
}

.leaflet-tooltip.district-drilldown-label {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.leaflet-popup-content {
  min-width: 260px;
  margin: 16px;
}

.popup-title {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 1.15rem;
}

.popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.popup-table th,
.popup-table td {
  padding: 6px 0;
  text-align: right;
  border-bottom: 1px solid #e8edf3;
}

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

.popup-small {
  color: var(--muted);
  font-size: 0.82rem;
}

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

  .panel {
    max-height: none;
  }

  #map {
    height: 70vh;
  }
}
