:root {
  --primary: #1F1A4F;
  --secondary: #E6E5F0;
  --accent: #1F1A4F;
  --text: #2b2b2b;
  --muted: #5f5b68;
  --border: #e2e0e6;
  --bg: #ffffff;
  --panel-w: 440px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex; flex-direction: column;
}
button { font: inherit; }

.topbar {
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; min-height: 52px;
}
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { height: 38px; width: 38px; object-fit: contain; }
.topbar h1 { font-size: 1.2rem; margin: 0; font-weight: 600; }
.subtitle { opacity: .85; font-size: .9rem; }
.icon-btn { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.only-mobile { display: none; }

.layout { flex: 1; display: flex; min-height: 0; }
.panel {
  width: var(--panel-w); max-width: 100%;
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.map-wrap { flex: 1; min-width: 0; position: relative; }
.map { position: absolute; inset: 0; }

.search-block { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-block .esri-search { width: 100%; }
.panel-body { flex: 1; overflow: auto; padding: 16px 18px; }

.intro { font-size: .95rem; line-height: 1.6; color: #3a3a3a; }
.intro h2 { font-size: 1rem; margin: 0 0 10px; }
.intro h3 { font-size: .95rem; margin: 16px 0 6px; }
.intro p { margin: 0 0 8px; }
.intro ol, .intro ul { margin: 0; padding-left: 22px; }
.intro li { margin: 2px 0; }

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

#results-status:not(:empty) { margin-bottom: 12px; }

/* Scenario cards */
.scard {
  --c: #8c8c8c;
  background: color-mix(in srgb, var(--c) 10%, #ffffff);
  border-radius: 6px;
  padding: 12px 18px;
  margin: 0 0 14px;
}
.scard.current { margin-bottom: 28px; }
.scard h4 {
  margin: 0 0 6px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  color: color-mix(in srgb, var(--c) 75%, #000000); font-weight: 600;
}
.scard.current h4 { color: #444; }
.school { font-weight: 600; font-size: .92rem; line-height: 1.6; color: #222; }
.school.none { color: var(--muted); font-style: italic; font-weight: 400; }

/* Clear button at the top of the map, beside the zoom buttons */
.clear-btn {
  position: absolute; top: 15px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; border: 0; border-radius: 6px; font-weight: 600;
  padding: 9px 18px; font-size: .95rem; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  pointer-events: auto; white-space: nowrap;
}
.clear-btn:hover { background: #2e2870; }
.clear-btn[hidden] { display: none; }

/* Results: compact cards with even gaps */
#cards:not([hidden]) { display: flex; flex-direction: column; gap: 8px; }
#cards .scard, #cards .scard.current { margin: 0; padding: 8px 14px; }
#cards .scard h4 { margin: 0 0 2px; font-size: .7rem; }
#cards .school { font-size: .85rem; line-height: 1.35; }

/* Floating single-select boundary picker: an always-open grid */
.layer-pane { background: #fff; font-size: .88rem; padding: 10px 12px 10px; max-height: 75vh; overflow: auto; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 4px; cursor: pointer; user-select: none; }
.picker-title { font-weight: 700; color: var(--primary); font-size: .92rem; }
.pane-min { position: relative; width: 18px; height: 18px; border: 0; background: none; padding: 0; color: #555; cursor: pointer; flex-shrink: 0; }
.pane-min::before, .pane-min::after { content: ""; position: absolute; left: 50%; top: 50%; background: currentColor; transform: translate(-50%, -50%); }
.pane-min::before { width: 11px; height: 2px; }
.pane-min::after { width: 2px; height: 11px; display: none; }
.layer-pane.minimized .pane-min::after { display: block; }
.pane-min:hover { color: #000; }
.pane-min:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.layer-pane.minimized .picker-head { margin: 0; }
.layer-pane.minimized .pane-body { display: none; }
.layer-pane { box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.pgrid { border-collapse: collapse; }
.pgrid th, .pgrid td { padding: 0; text-align: center; }
.pgrid thead th { font-size: .74rem; font-weight: 600; color: var(--muted); padding: 2px 6px 6px; }
.pgrid tbody th { text-align: left; font-weight: 600; white-space: nowrap; padding: 0 10px 0 0; color: #333; }
.pgrid tbody tr + tr th, .pgrid tbody tr + tr td { border-top: 1px solid #f0eff3; }
.pgrid .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: 1px; }
.pgrid .cell { display: flex; align-items: center; justify-content: center; width: 100%; min-width: 64px; height: 32px; cursor: pointer; border-radius: 4px; }

.picker input[type=radio] { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; cursor: pointer; border: 1.5px solid #8a8794; border-radius: 50%; background: #fff; display: inline-grid; place-content: center; }
.picker input[type=radio]:checked { border-color: var(--accent); }
.picker input[type=radio]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.picker input[type=radio]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-opt { display: flex; align-items: center; gap: 8px; padding: 6px 2px; cursor: pointer; border-radius: 4px; }
.none-opt { color: var(--muted); border-top: 1px solid #f0eff3; margin-top: 4px; padding-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #222; color: #fff; padding: 8px 14px; border-radius: 6px; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--secondary); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .only-mobile { display: inline-block; }
  .layout { flex-direction: column-reverse; }
  .panel { width: 100%; height: 55%; border-right: 0; border-top: 1px solid var(--border); }
  .panel.collapsed { height: auto; }
  .panel.collapsed .panel-body { display: none; }
  .map-wrap { min-height: 45%; }
  .layer-pane { max-height: 45vh; }
  .pgrid .cell { min-width: 44px; height: 30px; }
}

@media print {
  .topbar, .map-wrap, .search-block, .layer-pane { display: none !important; }
  .layout, .panel { display: block; width: 100%; border: 0; height: auto; }
  .panel-body { overflow: visible; }
  .scard { -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
}
.pgrid thead th.corner { text-align: left; padding-left: 0; }
