/* OSMC Leaderboards — purple & gold theme
   Layout: 1290px centred container on an 8px spacing grid. Two-column deep-purple header,
   metric cards overlapping its lower edge, then white cards on a pale lilac ground. */

:root {
  --plum: #241342;        /* deep purple: header band, text on gold */
  --purple: #5A35B8;      /* accent purple: primary values, bars */
  --purple-2: #7651D6;    /* lighter purple */
  --purple-ink: #3A2180;  /* purple text on lilac */
  --lilac: #EEE8FB;       /* tinted surfaces */
  --lilac-2: #F8F6FD;     /* zebra rows, soft fills */
  --bg: #F7F5FC;          /* page background */
  --sun: #FFD238;         /* gold: primary actions & achievements only */
  --sun-deep: #E6B400;    /* gold edge/hover */
  --sun-soft: #FFF6D6;
  --sun-ink: #5A4100;     /* text on soft gold */
  --ink: #1C1530;
  --muted: #5E5873;
  --label: #2F2745;       /* labels above/beside values: dark so they stand out */
  --line: #E9E4F5;
  --white: #FFFFFF;
  --danger: #B42318;
  --danger-soft: #FEF3F2;

  --display: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
  --body: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;

  --container: 1290px;
  --gutter: 32px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(36, 19, 66, 0.04), 0 8px 24px rgba(36, 19, 66, 0.06);
  color-scheme: light; /* single light look by design; keeps form controls readable in dark-mode browsers */
}

/* Standalone pages use body; WordPress embeds use #osmc-leaderboards (see wp-scope.css). */
* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--purple); text-underline-offset: 2px; }
a:hover { color: var(--purple-ink); }

#osmc-leaderboards {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  min-height: 40vh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.phone-only { display: none; }
@media (max-width: 640px) { .phone-only { display: inline; } .wide-only { display: none; } }

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

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

/* ---------- Prototype banner ---------- */
.proto-banner {
  background: var(--sun); color: var(--plum);
  font-size: 13px; text-align: center;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.proto-banner a { color: var(--plum); font-weight: 700; }

/* ---------- Header band (two columns: identity left, actions right) ---------- */
.hero { color: var(--white); background: var(--plum); }
.hero-inner {
  max-width: calc(var(--container) + 2 * var(--gutter)); margin: 0 auto;
  padding-block: 32px 88px;                 /* bottom = 48px card overlap + 40px breathing room */
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 24px 48px;
}
.hero-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hero-top { display: flex; margin-bottom: 16px; }
/* Student page: larger logo, centred above the header columns */
.hero.logo-center .hero-top { grid-column: 1 / -1; justify-content: center; margin-bottom: 8px; }
.hero.logo-center .logo-badge { padding: 12px 24px; border-radius: 16px; }
.hero.logo-center .logo-badge img { width: 260px; }
.logo-badge {
  background: var(--white); border-radius: 12px; padding: 8px 16px;
  display: inline-flex; align-items: center;
}
.logo-badge img { width: 176px; height: auto; display: block; }
.eyebrow {
  margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sun);
}
.hero h1 {
  margin: 0; font-family: var(--display); font-weight: 800; font-size: 48px;
  line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance;
}
.hero-sub { margin: 0; font-size: 18px; color: #D9D0F0; }
.hero-sub .sep { color: #8E80B8; margin: 0 8px; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 16px; }
.hero-actions a { font-size: 15px; font-weight: 500; color: #D9D0F0; text-decoration: none; border-bottom: 1px solid rgba(217, 208, 240, 0.4); padding-bottom: 2px; }
.hero-actions a:hover { color: var(--white); border-bottom-color: var(--white); }

/* ---------- Page column ---------- */
.page {
  max-width: calc(var(--container) + 2 * var(--gutter)); margin: -48px auto 0; position: relative;
  padding-block: 0 64px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 40px;
}

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; min-width: 0;
}

/* ---------- Key metric cards (student) ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.kpi {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; min-width: 0;
  display: grid; grid-template-rows: auto 56px; row-gap: 16px;   /* label row, then a fixed value row = shared baseline */
}
.kpi .label { font-size: 15px; font-weight: 700; color: var(--label); line-height: 1.4; }
.kpi .value-row { display: flex; align-items: flex-end; min-width: 0; }
.kpi .value {
  font-family: var(--display); font-weight: 800; font-size: 42px; line-height: 1; letter-spacing: -0.02em;
  color: var(--purple); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kpi .value .unit { font-size: 18px; font-weight: 700; letter-spacing: 0; margin-left: 4px; color: var(--purple-2); }

/* Awarded title badge */
.award {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 20px 0 16px;
  border-radius: 999px; background: var(--purple); color: var(--white);
  font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: 0.01em;
  box-shadow: 0 0 0 4px var(--sun-soft), 0 0 0 5px rgba(255, 210, 56, 0.55);
}
.award svg { flex: none; }
.award.champion { background: var(--sun); color: var(--plum); box-shadow: 0 0 0 4px var(--lilac), 0 0 0 5px rgba(90, 53, 184, 0.35); }
.award.none { background: transparent; color: var(--muted); box-shadow: none; padding: 0; font-size: 42px; }
.card.flush { padding: 0; overflow: hidden; }

.section { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.section-head { display: flex; flex-direction: column; gap: 2px; }
.section-head h2 {
  margin: 0; font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -0.01em; text-wrap: balance;
}
.section-head p { margin: 0; font-size: 14.5px; color: var(--muted); }

.site-foot { margin: 8px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.site-foot a { font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 15px;
  min-height: 48px; padding: 0 24px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--sun-deep); background: var(--sun); color: var(--plum);
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { background: #FFC800; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(230, 180, 0, 0.3); }
@media (prefers-reduced-motion: reduce) { .btn, .btn:hover { transition: none; transform: none; } }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.7; cursor: progress; transform: none; }
.btn.secondary { background: var(--purple); border-color: var(--purple); color: var(--white); box-shadow: 0 6px 16px rgba(91, 43, 181, 0.25); }
.btn.secondary:hover { background: var(--purple-ink); }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.tile {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.tile .label { font-size: 14px; font-weight: 700; color: var(--label); line-height: 1.35; }
.tiles .tile { justify-content: space-between; }   /* numbers line up at the bottom even when labels differ in length */
.tiles .legend { grid-column: span 2; }
.tile .value {
  font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; color: var(--purple);
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.tile .value small { font-size: 0.5em; font-weight: 700; margin-left: 2px; }
/* tone variants kept as no-ops: all tiles share the same white card for symmetry */

/* compact metrics row (comparison values, test stats, key statistics) */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric {
  background: var(--lilac-2); border-radius: var(--radius-sm); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.metric .label { font-size: 13px; font-weight: 600; color: var(--label); line-height: 1.35; }
.metric .value { font-family: var(--display); font-weight: 800; font-size: 24px; color: var(--purple-ink); font-variant-numeric: tabular-nums; }
.metric.own { background: var(--sun-soft); box-shadow: inset 0 0 0 1px #F6DE92; }
.metric.own .value { color: var(--sun-ink); }

/* ---------- Title pills & legend ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.pill.champion { background: var(--sun); color: var(--plum); }
.pill.elite { background: #E4D8FF; color: var(--purple-ink); }
.pill.none { background: transparent; color: var(--muted); padding: 4px 0; font-weight: 500; }
.pill.big { font-size: 22px; padding: 6px 18px; font-family: var(--display); font-weight: 800; }

.legend { display: flex; flex-direction: column; gap: 14px; justify-content: flex-start !important; }
.legend .label { font-size: 14px; font-weight: 700; color: var(--label); }
.title-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.title-card {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.title-card.champion { background: linear-gradient(135deg, #FFF6D6 0%, #FFE98F 100%); border-color: #F5D66A; }
.title-card.elite { background: linear-gradient(135deg, #F5F0FF 0%, #E4D8FF 100%); border-color: #D6C7FA; }
.tc-icon {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.champion .tc-icon { background: var(--plum); color: var(--sun); }
.elite .tc-icon { background: var(--purple); color: #fff; }
.tc-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.tc-name { font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.champion .tc-name { color: var(--sun-ink); }
.elite .tc-name { color: var(--purple-ink); }
.tc-range { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--ink); margin-top: 2px; white-space: nowrap; }
.tc-sub { font-size: 12.5px; color: var(--label); margin-top: 2px; }

/* 0–100 World percentile scale (student page) */
.ptrack-caption { font-size: 13px; font-weight: 600; color: var(--label); margin-top: 4px; }
.ptrack { padding: 30px 2px 0; margin-top: -14px; }
.ptrack-bar { position: relative; display: flex; height: 12px; border-radius: 999px; }
.ptrack-bar .seg { height: 100%; }
.seg-none { background: var(--lilac); border-radius: 999px 0 0 999px; }
.seg-elite { background: #C9B6FA; }
.seg-champion { background: var(--sun); border-radius: 0 999px 999px 0; }
.ptrack-you {
  position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%; background: var(--purple); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(36, 19, 66, .35);
}
.ptrack-tag {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--plum); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
}
.ptrack-tag.at-end { left: auto; right: -6px; transform: none; }
.ptrack-tag.at-start { left: -6px; transform: none; }
.ptrack-scale { position: relative; height: 18px; margin-top: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.ptrack-scale span { position: absolute; transform: translateX(-50%); }
.ptrack-scale span:first-child { transform: none; }

/* ---------- Tables ---------- */
.table-scroll { width: 100%; overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.rtable th, .rtable td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.rtable.centered th, .rtable.centered td, .rtable.centered .num { text-align: center; }
/* sortable column headers (teacher table) — the whole heading is a button with a visible sort icon */
.sort-btn {
  font: inherit; color: inherit; background: none; border: 0; padding: 6px 8px; margin: -6px -8px; cursor: pointer;
  border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-align: center; line-height: 1.3;
}
.sort-btn:hover { color: var(--purple); background: rgba(90, 53, 184, 0.08); }
.sort-btn .arrow {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; font-size: 12px;
  color: var(--purple); background: var(--white); box-shadow: inset 0 0 0 1px #D9CFF2;
}
.sort-btn[data-active="true"] .arrow { color: var(--white); background: var(--purple); box-shadow: none; }

/* toolbar above the teacher table: filters + count (+ "Sort by" on phones) */
.table-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.table-toolbar .filter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.table-toolbar label { font-size: 13px; font-weight: 700; color: var(--label); }
.table-toolbar select, .sort-bar select {
  font: inherit; font-size: 14px; min-height: 42px; padding: 0 36px 0 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: var(--white); color: var(--ink); cursor: pointer;
}
.table-toolbar select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(90, 53, 184, 0.15); }
.table-toolbar .sort-bar { display: none; }
.table-count { margin: 0 0 10px auto; font-size: 14px; font-weight: 600; color: var(--label); }
.sort-bar { display: none; align-items: center; gap: 8px; font-size: 14px; }

/* long lists (more than 15 students) scroll inside the card; column headings stay visible */
.table-scroll.scroll-y { max-height: 860px; overflow: auto; overscroll-behavior: contain; }
.table-scroll.scroll-y thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--line); }
.table-empty { margin: 0; padding: 28px 16px; text-align: center; font-size: 15px; color: var(--muted); }
.rtable thead th {
  background: var(--lilac); color: var(--purple-ink); font-size: 13px; font-weight: 700; line-height: 1.3;
  vertical-align: bottom;
}
.rtable tbody td { white-space: nowrap; }
.rtable tbody tr:nth-child(even) td { background: var(--lilac-2); }
.rtable tbody tr:last-child td { border-bottom: 0; }
.rtable .num { text-align: right; }
.rtable .strong { font-weight: 700; }
.rtable .pct { font-weight: 700; color: var(--purple); }
.students-table { min-width: 980px; }

/* key/value details list */
.details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin: 0; }
.details div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.details dt { font-size: 13px; font-weight: 600; color: var(--label); }
.details dd { margin: 0; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }

/* overview groups inside student sections */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.ovtable { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--lilac-2); border-radius: var(--radius-sm); overflow: hidden; }
.ovtable caption {
  caption-side: top; text-align: left; font-family: var(--display); font-size: 16px; font-weight: 800;
  color: var(--ink); padding: 0 2px 8px;
}
.ovtable th, .ovtable td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ovtable tr:last-child th, .ovtable tr:last-child td { border-bottom: 0; }
.ovtable th { font-weight: 600; font-size: 13.5px; color: var(--label); text-align: left; line-height: 1.35; }
.ovtable td { font-weight: 800; font-family: var(--display); font-size: 17px; color: var(--purple-ink); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ovtable tr.own td { color: var(--sun-ink); }
.ovtable tr.own th { color: var(--ink); font-weight: 700; }
.ovtable tr.own { background: var(--sun-soft); }

/* ---------- Charts (PDF report-card structure, restyled) ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.chart-grid.wide { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
/* Consolidated overview: 3 charts on top, the remaining 2 centred below */
.chart-row-3 { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.chart-row-3 > .chart { flex: 0 1 calc((100% - 32px) / 3); }

.chart {
  margin: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.chart figcaption { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); text-align: center; }
.chart-body { display: flex; gap: 4px; }
.chart-ytitle { width: 18px; display: flex; align-items: center; justify-content: center; }
.chart-ytitle span { transform: rotate(-90deg); white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--muted); }
.chart-ticks { position: relative; width: 34px; height: 200px; }
.chart-ticks span {
  position: absolute; right: 0; display: flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 14px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chart-ticks span::after { content: ""; display: inline-block; width: 4px; height: 1px; background: #B9ACDA; }
.chart-plot {
  flex: 1; height: 200px; min-width: 0;
  border-left: 1.5px solid #B9ACDA; border-bottom: 1.5px solid #B9ACDA;
  display: flex; align-items: flex-end; padding: 0 8px; position: relative;
}
.chart-zero { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px solid #B9ACDA; }
.chart-col { flex: 1; height: 100%; position: relative; min-width: 0; }
.chart-col .val {
  position: absolute; left: 0; right: 0; text-align: center;
  font-size: 11.5px; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chart-col .bar {
  position: absolute; left: 22%; width: 56%; border-radius: 8px 8px 0 0; background: var(--purple);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.chart-col.neg .bar { border-radius: 0 0 8px 8px; }
.chart-col.zero .bar { border-radius: 2px; }
.chart-col.own .bar { background: var(--sun); box-shadow: inset 0 0 0 1.5px var(--sun-deep); }
.chart-labels { display: flex; padding: 0 8px 0 68px; }
.chart-labels span {
  flex: 1; text-align: center; font-size: 12.5px; font-weight: 700; line-height: 1.3; color: var(--ink);
  min-width: 0; overflow-wrap: normal; word-break: keep-all;
}
.chart-labels span.own { color: var(--sun-ink); }
.chart.many .chart-col .val { font-size: 10.5px; }
.chart.many .chart-labels span { font-size: 11px; }
.chart.many .chart-plot { padding: 0 4px; }
.chart.many .chart-labels { padding: 0 4px 0 64px; }

/* ---------- Teacher comparison cards ---------- */
.comp-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: center; }
.comp-card .chart { border: 0; padding: 0; background: transparent; }
.comp-card h3 { margin: 0 0 12px; font-family: var(--display); font-size: 19px; font-weight: 800; }
.comp-card .metrics { grid-template-columns: minmax(0, 1fr); }

/* ---------- Collapsible sections (student) ---------- */
.sections { display: flex; flex-direction: column; gap: 16px; }
.collapsible { padding: 0; overflow: hidden; }
.collapse-btn {
  font: inherit; width: 100%; min-height: 76px; padding: 18px 56px 18px 22px;
  border: 0; background: var(--white); color: var(--ink); cursor: pointer; position: relative;
  display: flex; align-items: center; gap: 16px; text-align: left;
}
.collapse-btn:hover { background: var(--lilac-2); }
.collapse-btn .num {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--purple); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 18px;
}
.collapse-btn .text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.collapse-btn .label { font-family: var(--display); font-weight: 800; font-size: 19px; }
.collapse-btn .desc { font-size: 14px; color: var(--muted); }
.collapse-btn svg { position: absolute; right: 20px; top: 50%; margin-top: -12px; transition: transform 0.18s ease; }
.collapse-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.collapse-body { padding: 4px 22px 24px; display: flex; flex-direction: column; gap: 20px; border-top: 1px solid var(--line); }
/* Percentile intros under each v/s section: one line on desktop (full card width). */
.collapse-body > p { margin: 16px 0 0; font-size: 15px; line-height: 1.6; white-space: nowrap; }
.collapse-body > .metrics:first-child, .collapse-body > .ov-grid:first-child { margin-top: 18px; }
.collapse-body .chart { box-shadow: none; }

.summary-line {
  margin: 0; padding: 18px 22px; border-radius: var(--radius);
  background: var(--sun); color: var(--plum);
  font-family: var(--display); font-weight: 800; font-size: 20px; text-align: center; text-wrap: balance;
}
/* The result line ("<name> has scored <p> percentile in OSMC and earned the title <title>") fits on one line on
   desktop for names up to ~25 characters; it wraps on tablets and phones, and only wraps on desktop for unusually
   long names rather than overflowing the box. */

/* ---------- Review-your-exam offer (student page) ---------- */
.review { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.review-btn { min-height: 52px; padding: 12px 28px; line-height: 1.35; text-align: center; max-width: 100%; white-space: normal; }
.review-btn::after { content: "\25BE"; margin-left: 4px; font-size: 13px; display: inline-block; transition: transform 0.15s ease; }
.review-btn[aria-expanded="true"]::after { transform: rotate(180deg); }
.review-note {
  width: 100%; max-width: 720px; box-sizing: border-box; text-align: left;
  background: var(--lilac-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 20px 24px; display: flex; flex-direction: column; gap: 8px;
}
.review-note h3 { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 800; color: var(--purple-ink); }
.review-note p { margin: 0; font-size: 15px; line-height: 1.6; }
.review-note a { font-weight: 700; }
.review-note .fee { align-self: flex-start; background: var(--sun-soft); color: var(--sun-ink); border-radius: 10px; padding: 6px 14px; font-size: 14px; }
@media (max-width: 640px) {
  .review-btn { width: 100%; padding: 12px 16px; font-size: 14.5px; }
  /* student page on phones */
  .details .wide { grid-column: 1 / -1; }
  .details { grid-auto-flow: row dense; }   /* fill the half-rows left beside full-width fields */
  .details dd { overflow-wrap: break-word; }
  .collapse-body .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collapse-body .metric { justify-content: space-between; }   /* values share a baseline within each row */
  .end-actions .btn { width: 100%; }
  .review-note { padding: 16px; }
}

/* ---------- States ---------- */
.state-box { max-width: 560px; width: 100%; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.state-box .badge {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--purple); background: var(--lilac); padding: 4px 12px; border-radius: 999px;
}
.state-box h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 24px; }
.state-box p { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.6; }

.loading { text-align: center; font-size: 15px; color: var(--muted); padding: 32px 0; }

/* ---------- Lookup form ---------- */
.lookup-card { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.lookup-card h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 24px; }
.lookup-card .intro { margin: 0; color: var(--muted); font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 700; }
.field input {
  font: inherit; font-size: 16px; min-height: 50px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--white); color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field input::placeholder { color: #8C83A3; }
.field-help {
  margin: 2px 0 0; display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px; line-height: 1.5; color: var(--muted);
  background: var(--lilac-2); border-radius: 10px; padding: 10px 12px;
}
.field-help svg { flex: none; margin-top: 2px; color: var(--purple); }
.field-help a { font-weight: 700; overflow-wrap: anywhere; }
.field input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(91, 43, 181, 0.15); }
.form-error {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); border: 1px solid #FDA29B;
  font-size: 14px; line-height: 1.5;
}
.form-error a { color: var(--danger); font-weight: 700; }
.privacy { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.lookup-card .btn { width: 100%; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .chart-row-3 > .chart { flex-basis: calc((100% - 16px) / 2); }
  :root { --gutter: 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .hero-inner { grid-template-columns: minmax(0, 1fr); align-items: start; padding-block: 24px 80px; }
  .hero-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
  .hero h1 { font-size: 38px; }
  .hero-sub { font-size: 16px; }
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .comp-card { grid-template-columns: minmax(0, 1fr); }
  .comp-card .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .hero-inner { padding-block: 24px 72px; }
  .hero-top { margin-bottom: 8px; }
  .logo-badge img { width: 144px; }
  .hero.logo-center .logo-badge img { width: 200px; }
  .hero h1 { font-size: 32px; }
  .hero-sub { font-size: 15px; }
  .hero-sub .sep { margin: 0 4px; }
  .hero-actions .btn { width: 100%; }
  .page { margin-top: -40px; gap: 32px; }
  .kpis { gap: 16px; }
  .kpi { padding: 16px; row-gap: 8px; grid-template-rows: auto 40px; }
  .kpi .label { font-size: 13.5px; min-height: calc(1.4em * 2); }   /* two-line label box keeps values aligned across a row */
  .kpi .value { font-size: 28px; }
  .kpi .value .unit { font-size: 13px; margin-left: 2px; }
  /* percentile cards: "percentile" sits on its own line under the number so it fits half-width cards */
  .kpi { grid-template-rows: auto auto; }
  .kpi .value-row { align-items: flex-start; min-height: 40px; }
  .kpi .value:has(.unit) { display: flex; flex-direction: column; gap: 4px; }
  .kpi .value .unit { margin-left: 0; }
  .award { height: 36px; font-size: 16px; padding: 0 14px 0 10px; gap: 6px; }
  .award.none { font-size: 28px; }
  .card { padding: 18px; }
  .card.flush { padding: 0; }
  .section-head h2 { font-size: 21px; }
  .tile .value { font-size: 32px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 16px; }
  .comp-card .metrics { grid-template-columns: minmax(0, 1fr); }
  .chart-grid, .chart-grid.wide { grid-template-columns: minmax(0, 1fr); }
  .chart-row-3 > .chart { flex-basis: 100%; }
  .chart { padding: 14px 10px 12px; }
  .chart-ticks, .chart-plot { height: 160px; }
  .chart-ticks { width: 28px; }
  .chart-labels { padding-left: 62px; }
  .chart.many .chart-labels { padding-left: 58px; }
  .chart-labels span { font-size: 11px; }
  .chart.many .chart-labels span { font-size: 10px; }
  .chart-col .val { font-size: 10px; }
  .chart.many .chart-col .val { font-size: 9px; }
  .collapse-btn { padding: 14px 44px 14px 14px; gap: 12px; min-height: 64px; }
  .collapse-btn .num { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
  .collapse-btn .label { font-size: 16.5px; }
  .collapse-btn .desc { font-size: 12.5px; }
  .collapse-btn svg { right: 12px; }
  .collapse-body { padding: 4px 14px 18px; }
  .collapse-body > p { white-space: normal; }
  .summary-line { font-size: 17px; }

  /* Student table becomes one card per student */
  .students-table { min-width: 0; }
  .stack-table thead { display: none; }
  .sort-bar { display: flex; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr { border-bottom: 8px solid var(--bg); }
  .stack-table tbody tr:nth-child(even) td { background: var(--white); }
  .tiles .legend { grid-column: 1 / -1; }
  .title-cards { grid-template-columns: 1fr; gap: 10px; }
  .tc-range { font-size: 18px; }
  .stack-table td {
    white-space: normal;
    display: grid; grid-template-columns: 1.15fr 1fr; gap: 8px; text-align: left;
    padding: 9px 16px; border-bottom: 1px solid var(--line);
  }
  .stack-table td::before { content: attr(data-label); color: var(--label); font-size: 13px; font-weight: 600; }
  /* cards on phones: left-aligned label | value rows that may wrap (beats the desktop centring / no-wrap rules) */
  .rtable.stack-table tbody td, .rtable.centered.stack-table td, .rtable.centered.stack-table .num {
    white-space: normal; text-align: left; align-items: center;
  }
  .stack-table td > .pill { justify-self: start; }
  .sort-bar label { white-space: nowrap; }
  .sort-bar select { flex: 1; min-width: 0; }
  /* teacher toolbar on phones: School Year | Title side by side, Sort by full width, count below */
  .table-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
  .table-toolbar .sort-bar { display: flex; flex-direction: column; align-items: stretch; gap: 4px; grid-column: 1 / -1; }
  .table-toolbar select { width: 100%; }
  .table-count { grid-column: 1 / -1; margin: 0; }
  .table-scroll.scroll-y { max-height: 75vh; }
  /* comparison cards: compact label | value rows above the chart */
  .comp-card { gap: 16px; }
  .comp-card h3 { margin-bottom: 8px; }
  .comp-card .metrics { gap: 8px; }
  .comp-card .metric { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; }
  .comp-card .metric .value { font-size: 19px; white-space: nowrap; }
  .stack-table td.num { text-align: left; }
  .stack-table td.name-cell { background: var(--lilac) !important; font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--purple-ink); }
  .stack-table td.name-cell::before { color: var(--purple); }
}

@media (max-width: 359px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi .label { min-height: 0; }
}

/* ---------- Print / Save as PDF ---------- */
@media print {
  /* A4 scorecard: desktop arrangement (4 cards, 3 charts per row), compact, headings kept with their content.
     The printed page is ~720px wide, so the tablet rules would otherwise apply; these override them. */
  @page { size: A4 portrait; margin: 10mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: var(--white); font-size: 12px; }
  .no-print { display: none !important; }

  .hero-inner { grid-template-columns: minmax(0, 1fr) !important; padding: 14px 20px 20px !important; gap: 4px; }
  .hero.logo-center .logo-badge { padding: 8px 16px; }
  .hero.logo-center .logo-badge img { width: 170px; }
  .hero h1 { font-size: 30px; }
  .hero-sub { font-size: 14px; }
  .page { margin-top: 14px !important; padding: 0 !important; gap: 14px; }
  #result { gap: 14px !important; }
  .section, .sections { gap: 8px; }
  .section-head h2 { font-size: 17px; }

  .card, .tile, .chart, .kpi { box-shadow: none; }
  .card { padding: 12px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 10px; }
  .kpi { padding: 12px; grid-template-rows: auto 36px !important; row-gap: 6px; }
  .kpi .label { font-size: 12px; min-height: 0 !important; }
  .kpi .value { font-size: 26px; }
  .kpi .value:has(.unit) { display: inline !important; }
  .kpi .value .unit { font-size: 11px; margin-left: 3px !important; }
  .award { height: 32px; font-size: 14px; padding: 0 12px 0 10px; box-shadow: none; }

  .details { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 10px; }
  .details dd { font-size: 13px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 10px; }
  .tile { padding: 12px; }
  .tile .value { font-size: 22px; }
  .legend { gap: 8px; }
  .title-card { padding: 8px 10px; }
  .tc-icon { width: 30px; height: 30px; }
  .tc-range { font-size: 16px; }
  .ptrack-you { box-shadow: none; }
  .title-card, .seg, .ptrack-you, .ptrack-tag, .tc-icon { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .collapse-body { display: flex !important; padding: 10px 12px 12px; gap: 10px; }
  .collapse-btn { min-height: 0; padding: 10px 12px; }
  .collapse-btn .num { width: 28px; height: 28px; font-size: 14px; }
  .collapse-btn .label { font-size: 15px; }
  .collapse-btn svg { display: none; }
  .collapse-body > p { margin-top: 6px; font-size: 12px; white-space: normal; }
  .metrics { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; gap: 8px; }
  .metric { padding: 8px 10px; }
  .metric .value { font-size: 17px; }
  .ov-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px; }
  .ovtable caption { font-size: 13px; padding-bottom: 4px; }
  .ovtable th, .ovtable td { padding: 6px 8px; font-size: 11px; }
  .ovtable td { font-size: 13px; }

  .chart-grid, .chart-grid.wide { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px; }
  .chart-row-3 { gap: 8px; }
  .chart-row-3 > .chart { flex-basis: calc((100% - 16px) / 3) !important; }
  .chart { padding: 8px 6px 6px; gap: 6px; }
  .chart figcaption { font-size: 12px; }
  .chart-ticks, .chart-plot { height: 120px !important; }
  .chart-ticks { width: 26px !important; }
  .chart-labels { padding-left: 52px !important; }
  .chart.many .chart-labels { padding-left: 48px !important; }
  .chart-labels span { font-size: 9px !important; }
  .chart-col .val { font-size: 9px !important; }
  .summary-line { font-size: 15px; padding: 10px 14px; }

  /* keep things whole and headings with what follows */
  .kpis, .card, .tile, .chart, .metric, .ov-grid, .ovtable, .summary-line, .collapsible { break-inside: avoid; }
  .section-head, .section-head h2, .collapse-btn, h2, h3 { break-after: avoid; }
}

