:root {
  --paper: #f8f6f0;
  --canvas: #eeeadf;
  --ink: #182018;
  --muted: #687061;
  --moss: #2d5b45;
  --moss-soft: #d9e8df;
  --pond: #245f73;
  --pond-soft: #dcebf0;
  --clay: #8b4d2f;
  --sun: #b8861b;
  --line: rgba(32, 39, 30, 0.16);
  --line-strong: rgba(32, 39, 30, 0.28);
  --surface: rgba(255, 255, 255, 0.62);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --shadow: 0 14px 34px rgba(36, 47, 32, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--paper), var(--canvas));
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--pond);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 28px 44px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--clay);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(1.8rem, 3.2vw, 3.1rem);
  line-height: 1.02;
  font-weight: 850;
}

.subhead {
  max-width: 800px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.mode-tabs,
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.mode-tab svg,
.search-field svg {
  width: 17px;
  height: 17px;
}

.mode-tab.is-active {
  background: var(--ink);
  color: #fff;
}

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

.summary-cell {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-label,
.summary-cell small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-cell strong {
  display: block;
  margin: 7px 0 3px;
  font-size: 2rem;
  line-height: 1;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 190px minmax(420px, auto);
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.search-field,
.select-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.search-field input,
.select-field select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.select-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.toggle-row {
  min-height: 44px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.matrix-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.school-matrix {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.school-matrix th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-strong);
  background: #f4f1e8;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: left;
  text-transform: uppercase;
}

.school-matrix td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.school-matrix tr:last-child td {
  border-bottom: 0;
}

.school-cell {
  width: 260px;
}

.school-title-line,
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.school-name {
  display: block;
  font-size: 0.98rem;
}

.school-location {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.rank-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 25px;
  height: 25px;
  border-radius: 999px;
  background: var(--sun);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.rank-badge.has-rank {
  display: inline-flex;
}

.fit-stack {
  max-width: 360px;
}

.style-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--moss-soft);
  color: var(--moss);
  font-size: 0.72rem;
  font-weight: 850;
}

.style-pill[data-style="Learner-led / Acton"] {
  background: #e7e0f1;
  color: #594078;
}

.style-pill[data-style="Reggio"] {
  background: var(--pond-soft);
  color: var(--pond);
}

.style-pill[data-style="Waldorf"] {
  background: #f1e4d7;
  color: var(--clay);
}

.style-pill[data-style="Montessori"] {
  background: #e7ead8;
  color: #53602c;
}

.fit-note {
  margin: 7px 0 0;
  color: #2d332b;
  font-size: 0.86rem;
  line-height: 1.38;
}

.metric-cell {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-cell small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.rating-missing {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: normal;
}

.link-cell {
  min-width: 126px;
}

.external-cell {
  min-width: 190px;
}

.external-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.external-list li {
  color: #30362d;
  font-size: 0.78rem;
  line-height: 1.28;
}

.external-list strong {
  color: var(--clay);
}

.external-empty {
  color: var(--muted);
  font-size: 0.78rem;
}

.link-cell a,
.card-actions a {
  display: inline-flex;
  margin-right: 10px;
  font-size: 0.85rem;
}

.status-select {
  min-width: 128px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.decision-note {
  width: 220px;
  min-height: 48px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fffefb;
  color: var(--ink);
}

.board-columns {
  display: grid;
  grid-template-columns: repeat(6, minmax(210px, 1fr));
  gap: 10px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.board-column {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  transition:
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.board-column.is-drop-target {
  border-color: var(--pond);
  background: rgba(220, 235, 240, 0.76);
  box-shadow: inset 0 0 0 2px rgba(36, 95, 115, 0.16);
}

.board-column h2 {
  margin: 0;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.board-stack {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.school-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 8px 20px rgba(36, 47, 32, 0.06);
  cursor: grab;
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    border-color 120ms ease;
}

.school-card:active {
  cursor: grabbing;
}

.school-card.is-dragging {
  opacity: 0.52;
  transform: scale(0.985);
}

.drag-handle {
  width: 17px;
  height: 17px;
  margin-left: auto;
  color: var(--muted);
  flex: 0 0 auto;
}

.school-card h3 {
  margin: 10px 0 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.card-metrics div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.card-metrics dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card-metrics dd {
  margin: 4px 0 0;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions a {
  margin-right: 0;
}

.card-status-select {
  min-width: 112px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffefb;
  color: var(--ink);
  font-size: 0.82rem;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  align-items: stretch;
}

.map-panel,
.map-side {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.map-panel {
  overflow: hidden;
}

.school-map {
  width: 100%;
  min-height: 620px;
  background: #dfe8df;
}

.leaflet-container {
  color: var(--ink);
  font: inherit;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

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

.legend-dot,
.legend-ring {
  display: inline-flex;
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.legend-dot.nature {
  background: var(--moss);
}

.legend-dot.learner {
  background: #6b4a8e;
}

.legend-dot.reggio {
  background: var(--pond);
}

.legend-dot.waldorf {
  background: var(--clay);
}

.legend-dot.montessori {
  background: #64733a;
}

.legend-ring {
  border: 2px solid var(--sun);
  background: #fff;
}

.map-side {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 620px;
  overflow: hidden;
}

.map-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.map-side-header h2 {
  margin: 0;
  font-size: 0.88rem;
  text-transform: uppercase;
}

.map-side-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.map-list {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 568px;
  overflow: auto;
  padding: 10px;
}

.map-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefb;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.map-list-item:hover,
.map-list-item.is-selected {
  border-color: var(--pond);
  background: var(--pond-soft);
}

.map-item-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.map-item-copy strong {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  line-height: 1.2;
}

.map-item-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.28;
}

.school-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(24, 32, 24, 0.26);
}

.school-marker.nature {
  background: var(--moss);
}

.school-marker.learner {
  background: #6b4a8e;
}

.school-marker.reggio {
  background: var(--pond);
}

.school-marker.waldorf {
  background: var(--clay);
}

.school-marker.montessori {
  background: #64733a;
}

.school-marker.is-top {
  border-color: #f7d36b;
  box-shadow:
    0 0 0 3px rgba(184, 134, 27, 0.34),
    0 5px 14px rgba(24, 32, 24, 0.3);
}

.map-popup {
  display: grid;
  gap: 7px;
}

.map-popup strong {
  font-size: 0.96rem;
  line-height: 1.2;
}

.map-popup span,
.map-popup p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.map-popup-links {
  display: flex;
  gap: 12px;
  padding-top: 2px;
}

.map-unavailable {
  display: grid;
  min-height: 620px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state {
  padding: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1060px) {
  .topbar,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .controls {
    display: grid;
  }

  .mode-tabs {
    justify-self: start;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

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

  .map-list {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 20px 14px 34px;
  }

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

  .toggle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .mode-tabs {
    flex-wrap: wrap;
  }

  .school-map,
  .map-unavailable {
    min-height: 430px;
  }
}
