:root {
  color-scheme: light;
  --ink: #17213a;
  --muted: #4d5a70;
  --navy: #17365d;
  --blue: #175f8c;
  --blue-dark: #104769;
  --pale-blue: #eaf4fa;
  --gold: #f1b434;
  --cream: #fff9e8;
  --border: #c5cfda;
  --surface: #ffffff;
  --page: #f4f7fa;
  --review-bg: #fff3cd;
  --review-ink: #5f4300;
  --success-bg: #e8f5ee;
  --success-ink: #155d38;
  --focus: #9a4d00;
  font-family: "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: .75rem 1rem;
  background: var(--surface);
  color: var(--navy);
  border: 3px solid var(--focus);
}

.skip-link:focus { top: 1rem; }

.site-header {
  color: white;
  background: linear-gradient(120deg, var(--navy), var(--blue));
  border-bottom: .4rem solid var(--gold);
}

.header-inner,
footer p {
  width: min(94%, 90rem);
  margin-inline: auto;
}

main {
  width: min(98%, 110rem);
  margin-inline: auto;
}

.header-inner { padding: 2.5rem 0 2.75rem; }

.eyebrow,
.step {
  margin: 0 0 .3rem;
  color: inherit;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2 { line-height: 1.15; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.35rem); }
h2 { margin: 0; font-size: clamp(1.35rem, 2.2vw, 1.85rem); }
.lede { max-width: 48rem; margin: .8rem 0 0; font-size: 1.1rem; }

main { padding: 2rem 0 3rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  box-shadow: 0 .35rem 1.25rem rgba(23, 54, 93, .08);
  padding: clamp(1rem, 2.5vw, 2rem);
}

.results-panel { padding-inline: clamp(.5rem, 1vw, 1rem); }

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.step { color: var(--blue-dark); }
.control-grid {
  display: grid;
  grid-template-columns: minmax(15rem, 1.3fr) repeat(3, minmax(12rem, 1fr));
  gap: 1rem;
  align-items: end;
}

.field { display: grid; gap: .35rem; }
.field label { font-weight: 700; }

select,
button,
input { font: inherit; }

select {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem .7rem;
  color: var(--ink);
  background: white;
  border: 1px solid #6f7e90;
  border-radius: .35rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: .6rem;
  grid-column: 1 / -1;
}

.checkbox-field input { width: 1.15rem; height: 1.15rem; }
.checkbox-field label { font-weight: 600; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1rem 0;
}

.summary-card {
  display: grid;
  gap: .1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: .3rem solid var(--blue);
  border-radius: .5rem;
}

.summary-value { font-size: 1.75rem; font-weight: 800; }
.summary-label { color: var(--muted); }
.actions-heading { align-items: center; }
.button-row { display: flex; flex-wrap: wrap; gap: .65rem; }

button {
  min-height: 2.75rem;
  padding: .6rem 1rem;
  color: white;
  background: var(--blue-dark);
  border: 2px solid var(--blue-dark);
  border-radius: .35rem;
  font-weight: 700;
  cursor: pointer;
}

button.secondary { color: var(--blue-dark); background: white; }
button:hover:not(:disabled) { filter: brightness(.9); }
button:disabled { cursor: not-allowed; opacity: .55; }

.status {
  margin: 0 0 1rem;
  padding: .7rem .85rem;
  color: var(--navy);
  background: var(--pale-blue);
  border-left: .3rem solid var(--blue);
}

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

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: .4rem; }
table { width: 100%; border-collapse: collapse; min-width: 72rem; table-layout: fixed; }
caption { padding: .8rem; font-weight: 700; text-align: left; background: #edf2f7; }
th, td { padding: .7rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: white; background: var(--navy); }
tbody tr:nth-child(even) { background: #f7f9fb; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.empty-state { padding: 2rem; color: var(--muted); text-align: center; }

th:nth-child(1), td:nth-child(1) { width: 5rem; }
th:nth-child(2), td:nth-child(2) { width: 17rem; }
th:nth-child(3), td:nth-child(3) { width: 15rem; }
th:nth-child(4), td:nth-child(4),
th:nth-child(5), td:nth-child(5),
th:nth-child(6), td:nth-child(6) { width: 15rem; }
th:nth-child(7), td:nth-child(7) { width: 9rem; }

.action-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  text-align: left;
}

.action-list li + li { margin-top: .45rem; }

.cell-year {
  display: block;
  margin-bottom: .75rem;
  color: var(--navy);
  font-weight: 800;
}

.result-cluster + .result-cluster { margin-top: 1rem; }
.result-school { display: block; margin-bottom: .15rem; }
.result-line { display: block; font-variant-numeric: tabular-nums; }
.result-population + .result-population { margin-top: 1rem; }
.result-population-heading { display: block; margin-bottom: .15rem; }
.cell-na { color: var(--muted); font-style: italic; }

.status-pill {
  display: inline-block;
  padding: .25rem .5rem;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 800;
}

.status-pill.calculated { color: var(--success-ink); background: var(--success-bg); }
.status-pill.review { color: var(--review-ink); background: var(--review-bg); border: 1px solid #c49a00; }
.metric-name { display: block; max-width: 26rem; }
.metric-number { display: block; color: var(--muted); font-size: .85rem; font-weight: 700; }
footer { padding: 1.25rem 0; color: #eaf0f6; background: #243349; }
footer p { margin-block: 0; }

@media (max-width: 55rem) {
  .control-grid { grid-template-columns: 1fr; }
  .checkbox-field { grid-column: auto; }
  .section-heading { display: grid; }
  .summary-grid { grid-template-columns: 1fr; }
}

@media print {
  .skip-link, .controls, .summary-grid, .button-row, footer { display: none; }
  body, .panel { background: white; box-shadow: none; }
  main { width: 100%; padding: 0; }
  table { min-width: 0; table-layout: auto; font-size: 9pt; }
  th { color: black; background: #ddd; }
}

/* Eight-column Current Difference layout, including editable Metric Type. */
#results-body td { overflow-wrap: anywhere; }
.table-wrap table th:nth-child(2), .table-wrap table td:nth-child(2) { width: 12rem; }
.table-wrap table th:nth-child(3), .table-wrap table td:nth-child(3) { width: 17rem; }
.table-wrap table th:nth-child(7), .table-wrap table td:nth-child(7) { width: 15rem; }
.table-wrap table th:nth-child(8), .table-wrap table td:nth-child(8) { width: 9rem; }
