:root {
  --green: #2e7d32;
  --yellow: #f9a825;
  --orange: #ef6c00;
  --red: #c62828;
  --gray: #9e9e9e;
  --ink: #1a1a2e;
  --bg: #f7f7fa;
  --card: #ffffff;
  --border: #e0e0e6;
  /* One dedicated accent for factual historical stats (the success-rate meter),
     kept deliberately separate from the green/yellow/orange/red verdict colors so a
     "49% of applicants got in last year" fact never reads as this year's prediction. */
  --meter-fill: #1565c0;
  --meter-track: #e0e0e6;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  padding: 0 24px 48px;
}

header {
  padding: 32px 0 8px;
}

h1 { margin: 0 0 4px; font-size: 1.8rem; }
.tagline { margin: 0; color: #555; }

.banner {
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 8px;
  padding: 10px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.4;
}
.banner.interim {
  background: #e3f2fd;
  border-color: #90caf9;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.controls label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  gap: 4px;
}

.controls select, .controls input {
  font-size: 0.95rem;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 160px;
}

.search-label { flex-grow: 1; }
.search-label input { width: 100%; min-width: 200px; }

.status {
  min-height: 1.2em;
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  /* No overflow:hidden here - it would establish a scroll-clip ancestor that
     silently defeats `position: sticky` on the header cells below (a well-known
     CSS gotcha). Rounded corners are done per-cell instead. */
}
thead tr:first-child th:first-child { border-top-left-radius: 8px; }
thead tr:first-child th:last-child { border-top-right-radius: 8px; }
tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  background: #fafafa;
  padding: 10px 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
  border-bottom: 1px solid var(--border);
}

.phase-th {
  cursor: help;
  border-bottom: 1px dotted #999 !important;
  position: sticky; /* keep the sticky top-offset from the rule above; this adds the tooltip anchor */
}

.phase-th .tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
  width: 220px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.phase-th:hover .tooltip,
.phase-th:focus .tooltip,
.phase-th:focus-visible .tooltip {
  visibility: visible;
  opacity: 1;
}

tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: #fafbff; }

tbody td { padding: 10px 12px; vertical-align: middle; }

.school-name { font-weight: 600; }
.school-sub { font-size: 0.8rem; color: #888; }

.dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.08);
}
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.orange { background: var(--orange); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--gray); }

.relocating-badge {
  display: inline-block;
  background: #ede7f6;
  color: #5e35b1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100; /* must clear the sticky table header (z-index: 2) and its tooltips
                   (z-index: 10) - without this, position:sticky + z-index on the header
                   cells wins the root stacking context over a later, but un-indexed,
                   fixed-position sibling, so the modal rendered underneath it */
  background: rgba(20, 20, 30, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--card);
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  padding: 28px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #888;
}

.modal h2 { margin-top: 0; }
.modal .meta { color: #666; font-size: 0.9rem; margin-bottom: 20px; }

.phase-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.phase-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.phase-desc {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.4;
  margin: 0 0 10px;
}

.summary-stats {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: #fafbff;
}
.summary-stats h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.verdict-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  color: white;
  text-transform: uppercase;
}
.verdict-pill.green { background: var(--green); }
.verdict-pill.yellow { background: var(--yellow); color: #3a2c00; }
.verdict-pill.orange { background: var(--orange); }
.verdict-pill.red { background: var(--red); }
.verdict-pill.gray { background: var(--gray); }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 2px 0 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-label {
  font-size: 0.7rem;
  color: #888;
  cursor: help;
  position: relative;
  width: fit-content;
  border-bottom: 1px dotted #bbb;
}

.stat-label .tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  width: 190px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.stat-label:hover .tooltip,
.stat-label:focus .tooltip,
.stat-label:focus-visible .tooltip {
  visibility: visible;
  opacity: 1;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.years-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 6px;
}
.years-table th, .years-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid #f0f0f0;
}

.result-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.meter-track {
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: var(--meter-track);
  overflow: hidden;
  flex-shrink: 0;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--meter-fill);
}

.result-label {
  font-variant-numeric: tabular-nums;
  color: #444;
  font-size: 0.8rem;
}

.note-text {
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
  margin-top: 6px;
}

.explain-btn {
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #90caf9;
  background: #e3f2fd;
  color: #1565c0;
  cursor: pointer;
}
.explain-btn:hover { background: #bbdefb; }
.explain-btn:disabled { cursor: default; opacity: 0.6; }

.narrative {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #333;
  margin-top: 8px;
  white-space: pre-wrap;
}
.narrative:empty { display: none; }

.admin-panel {
  margin: 24px 0 40px;
}

.admin-toggle {
  background: none;
  border: none;
  color: #888;
  font-size: 0.8rem;
  text-decoration: underline dotted;
  cursor: pointer;
  padding: 0;
}
.admin-toggle:hover { color: #555; }

.admin-form {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
  gap: 3px;
}
.admin-form input {
  font-size: 0.9rem;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.admin-form button {
  align-self: flex-start;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #90caf9;
  background: #e3f2fd;
  color: #1565c0;
  cursor: pointer;
}
.admin-form button:hover { background: #bbdefb; }
.admin-form button:disabled { cursor: default; opacity: 0.6; }

.site-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.site-footer p {
  font-size: 0.75rem;
  color: #888;
  line-height: 1.5;
  max-width: 760px;
}
.site-footer a {
  color: #888;
  text-decoration: underline;
}
.site-footer a:hover { color: #555; }

.source-badge {
  cursor: help;
  color: #1565c0;
  font-weight: 700;
}
