:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #5b686d;
  --line: #cfd8dc;
  --panel: #f7f8f7;
  --water: #e9f2f1;
  --neighborhood: #f8f5ea;
  --region: #006d77;
  --accent: #c94833;
  --focus: #163b73;
}

* {
  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: var(--water);
}

button,
select,
input {
  font: inherit;
}

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

.sidebar,
.detail-sidebar {
  z-index: 2;
  overflow: auto;
  max-height: 100vh;
  padding: 18px;
  background: var(--panel);
}

.sidebar {
  border-right: 1px solid var(--line);
}

.detail-sidebar {
  border-left: 1px solid var(--line);
}

.brand h1 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.1;
}

.brand p,
.metadata,
.selection,
.legend {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.control-section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.control-section h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.segmented {
  display: grid;
  gap: 7px;
}

.segmented button {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.segmented button[aria-checked="true"] {
  color: #fff;
  border-color: var(--focus);
  background: var(--focus);
}

.segmented.compact {
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
}

.segmented.compact button {
  min-height: 34px;
  text-align: center;
}

.background-note,
.school-metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.school-metric-note {
  padding: 8px 10px;
  border-left: 3px solid var(--focus);
  background: #fff;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.range-field {
  margin: 12px 0 0;
}

.range-field span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-field output {
  color: var(--ink);
  font-weight: 650;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--focus);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
}

.toggle input:disabled + span {
  color: #9aa3a7;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  background: #e6eeee;
}

#map {
  display: block;
  width: 100%;
  height: 100vh;
}

.loading {
  position: absolute;
  inset: 16px auto auto 16px;
  z-index: 3;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 13px;
}

.map-legend {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: min(300px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.feedback-link {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 3;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  color: var(--focus);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.feedback-link:hover,
.feedback-link:focus-visible {
  border-color: var(--focus);
  outline: none;
}

.feedback-modal {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.feedback-modal::backdrop {
  background: rgba(29, 37, 40, 0.38);
}

.feedback-modal__content {
  position: relative;
  padding: 20px 22px 22px;
}

.feedback-modal h2 {
  margin: 0 36px 10px 0;
  font-size: 18px;
  line-height: 1.2;
}

.feedback-modal p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.feedback-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.feedback-modal__close:hover,
.feedback-modal__close:focus-visible {
  border-color: var(--line);
  color: var(--ink);
  outline: none;
  background: var(--panel);
}

.map-legend h2 {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.neighborhood {
  pointer-events: none;
  fill: none;
  stroke: #b5c0c4;
  stroke-width: 0.65;
  stroke-opacity: 0.72;
}

.demographic {
  stroke: #ffffff;
  stroke-width: 0.4;
  opacity: 0.82;
}

.region {
  fill: var(--region);
  fill-opacity: 0.12;
  stroke: var(--region);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-opacity: 0.9;
  cursor: help;
}

.tornado-path {
  fill: none;
  stroke: #8b1e3f;
  stroke-width: 2.5;
}

.tornado-poly {
  fill: #b42318;
  fill-opacity: 0.22;
  stroke: #8b1e3f;
  stroke-width: 1;
}

.label {
  pointer-events: none;
  fill: #263238;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.86);
  stroke-width: 3px;
  font-size: 10px;
  font-weight: 650;
}

.school-glyph {
  cursor: pointer;
}

.school-glyph:focus-visible .school-outline,
.school-glyph:hover .school-outline {
  stroke-width: 3;
  stroke: #111;
}

.school-outline {
  fill: rgba(255, 255, 255, 0.86);
  stroke-width: 2;
}

.closure-slash {
  pointer-events: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 2.6;
}

.waffle-square {
  stroke: rgba(255, 255, 255, 0.88);
  stroke-width: 0.5;
}

.pto-marker {
  pointer-events: none;
}

.pto-status-text {
  pointer-events: none;
  fill: #fff;
  font-size: 8px;
  font-weight: 800;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.28);
  stroke-width: 1px;
}

.pto-unknown + .pto-status-text,
.pto-not_applicable + .pto-status-text {
  fill: #263238;
  stroke: rgba(255, 255, 255, 0.72);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}

.legend-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.legend-title {
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 650;
}

.legend-gradient {
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
}

.selection > strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 16px;
}

.selection .selection-subtitle {
  margin-bottom: 10px;
}

.selection .selection-status {
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 650;
}

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

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

.selection dd {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  text-align: right;
}

.selection a {
  color: var(--focus);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.metadata a {
  color: var(--focus);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.metadata-sources-title {
  margin-top: 12px;
  color: var(--ink);
  font-weight: 650;
}

.metadata-source-list {
  display: grid;
  gap: 7px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.metadata-source-list li {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.metadata-source-list strong {
  color: var(--ink);
  font-weight: 650;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.selection-chart-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.selection-chart-block h3,
.summary-group h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.summary-group {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.summary-group > .selection-chart-block {
  margin-top: 14px;
}

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

.summary-kpis div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.summary-kpis span,
.summary-kpis strong {
  display: block;
}

.summary-kpis span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.summary-kpis strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.selection-chart-row {
  display: grid;
  grid-template-columns: minmax(116px, 0.9fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.selection-chart {
  min-width: 0;
}

.selection-waffle,
.selection-bars {
  display: block;
  width: 100%;
  max-height: 120px;
}

.selection-waffle rect {
  stroke: rgba(255, 255, 255, 0.86);
  stroke-width: 0.7;
}

.selection-bar-bg {
  fill: rgba(68, 68, 85, 0.15);
}

.selection-empty-chart {
  display: grid;
  min-height: 86px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
}

.assessment-bars {
  display: grid;
  gap: 10px;
  padding: 8px 0;
}

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

.assessment-bar-row > span {
  min-width: 0;
}

.assessment-bar-row > strong {
  color: var(--ink);
  font-size: 12px;
}

.assessment-bar-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}

.assessment-bar-fill {
  height: 100%;
}

.selection-chart-details,
.selection-plan-list {
  display: grid;
  gap: 7px;
}

.selection-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.selection-detail-row > span:first-child {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.selection-detail-row strong {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: inherit;
  font-weight: 650;
  text-align: right;
}

.selection-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.selection-pto-marker {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--pto-color);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 30px;
  font-weight: 800;
  paint-order: stroke;
}

.tooltip {
  position: fixed;
  z-index: 4;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}

.tooltip dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  margin: 6px 0 0;
}

.tooltip dt,
.tooltip dd {
  margin: 0;
}

.tooltip dd {
  color: var(--ink);
  font-weight: 650;
}

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

  .sidebar,
  .detail-sidebar {
    max-height: none;
  }

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

  .detail-sidebar {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .map-panel {
    min-height: 68vh;
  }

  #map {
    height: 68vh;
  }

  .map-legend {
    max-height: calc(68vh - 32px);
  }

  .selection-chart-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .selection-waffle,
  .selection-bars {
    max-height: 150px;
  }
}
