:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --ink: #1b2330;
  --ink-2: #4a5462;
  --ink-3: #6f7782;
  --line: #dedcd4;
  --accent: #1f3864;
  --accent-2: #2c4d86;
  --accent-tint: #dfe6f2;
  --dot: #c0661c;
  --ok: #2f6b3b;
  --ok-tint: #e3efe4;
  --err: #9c2f22;
  --err-tint: #f6e1dc;
  --warn: #8a5a00;
  --warn-tint: #f7ecd3;
  --radius: 8px;
  --font: 'General Sans', 'Segoe UI', system-ui, sans-serif;
  --text-xs: 12px; --text-sm: 14px; --text-base: 16px; --text-lg: 18px; --text-xl: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: var(--text-base); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.boot { padding: 48px; color: var(--ink-3); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }

/* Shell */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 600; font-size: var(--text-lg); letter-spacing: -0.01em; white-space: nowrap; }
.brand small { display: block; font-weight: 400; font-size: var(--text-xs); color: var(--ink-3); letter-spacing: 0; }
nav.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 6px; font-size: var(--text-sm); font-weight: 500; color: var(--ink-2); cursor: pointer; }
nav.tabs button:hover { background: var(--surface-2); color: var(--ink); }
nav.tabs button[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.who { font-size: var(--text-xs); color: var(--ink-3); text-align: right; line-height: 1.3; }
.who b { color: var(--ink); font-weight: 500; }
main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { font-size: var(--text-xl); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); font-weight: 600; margin: 0 0 12px; }
h3 { font-size: var(--text-base); font-weight: 600; margin: 0 0 8px; }
.lede { color: var(--ink-2); margin: 0 0 24px; max-width: 70ch; font-size: var(--text-sm); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.muted { color: var(--ink-3); font-size: var(--text-sm); }
.small { font-size: var(--text-xs); }

/* Forms */
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.field label, .field .lbl { font-size: var(--text-xs); font-weight: 500; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
input[type=text], input[type=email], input[type=password], select { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 8px 10px; font-size: var(--text-sm); min-height: 38px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; padding: 8px 16px; font-size: var(--text-sm); font-weight: 500; cursor: pointer; min-height: 38px; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.secondary:hover { background: var(--accent-tint); }
.btn.danger { background: var(--surface); color: var(--err); border-color: #d8b2aa; }
.btn.danger:hover { background: var(--err-tint); }
.btn.link { background: none; border: 0; color: var(--accent-2); padding: 0; min-height: 0; text-decoration: underline; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 8px 12px; font-size: var(--text-sm); cursor: pointer; color: var(--ink-2); min-height: 38px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.years { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--text-sm); }
.years label { display: inline-flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink); font-size: var(--text-sm); }

/* Drop zone */
.drop { display: block; border: 1.5px dashed #b9b6aa; border-radius: var(--radius); padding: 28px; text-align: center; background: var(--surface-2); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-tint); }
.drop strong { display: block; margin-bottom: 4px; }

/* Alerts */
.alert { border-radius: 6px; padding: 12px 14px; font-size: var(--text-sm); margin: 12px 0; border: 1px solid transparent; }
.alert.ok { background: var(--ok-tint); color: var(--ok); border-color: #c4dcc7; }
.alert.err { background: var(--err-tint); color: var(--err); border-color: #e7c3bb; }
.alert.warn { background: var(--warn-tint); color: var(--warn); border-color: #ead7a8; }
.alert.info { background: var(--accent-tint); color: var(--accent); border-color: #c6d2e6; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.compact th, table.compact td { padding: 8px 8px; }
table.compact th { white-space: normal; vertical-align: bottom; }
th { background: var(--surface-2); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafaf7; }
tr.grade-start td { border-top: 2px solid var(--line); }
td.nodata { color: var(--ink-3); font-style: normal; }
tr.selected td { background: var(--accent-tint) !important; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; background: var(--surface-2); color: var(--ink-2); }
.pill.low { background: var(--err-tint); color: var(--err); }
.pill.caution { background: #fbeea6; color: #5c4600; }
.pill.mid { background: var(--ok-tint); color: var(--ok); }
.pill.high { background: var(--accent-tint); color: var(--accent); }
.pill.pending { background: var(--warn-tint); color: var(--warn); }

/* Chart */
.chart-wrap { overflow-x: auto; }
svg.boxchart { width: 100%; min-width: 360px; height: auto; display: block; }
svg.boxchart .grid { stroke: #ebe9e2; stroke-width: 1; }
svg.boxchart .tick { font-size: 11px; fill: var(--ink-3); font-family: var(--font); }
svg.boxchart .axis-label { font-size: 12px; fill: var(--ink-2); font-family: var(--font); }
svg.boxchart .grade-label { font-size: 12px; font-weight: 600; fill: var(--ink); font-family: var(--font); }
svg.boxchart .season-label { font-size: 11px; fill: var(--ink-3); font-family: var(--font); }
svg.boxchart .n-label { font-size: 10px; fill: var(--ink-3); font-family: var(--font); }
svg.boxchart .box-body { fill: var(--accent-tint); stroke: var(--accent); stroke-width: 1.5; }
svg.boxchart .median { stroke: var(--accent); stroke-width: 3; }
svg.boxchart .whisker { stroke: var(--accent); stroke-width: 1.5; }
svg.boxchart .whisker-cap { stroke: var(--accent); stroke-width: 1.5; }
svg.boxchart .box-empty { fill: none; stroke: #c9c6bc; stroke-dasharray: 3 3; }
svg.boxchart .pt { fill: var(--dot); fill-opacity: .75; stroke: #fff; stroke-width: 1; }
svg.boxchart .pt-hi { fill: var(--dot); fill-opacity: 1; stroke: #5a2c06; stroke-width: 2; }
svg.boxchart .pp { fill: #fff; fill-opacity: .9; stroke: var(--dot); stroke-opacity: .7; stroke-width: 1.2; }
svg.boxchart .pp-hi { fill: #fff; fill-opacity: 1; stroke: #5a2c06; stroke-opacity: 1; stroke-width: 2; }
svg.boxchart .pp-label { font-size: 11px; fill: #7a3b0a; font-family: var(--font); }
svg.boxchart .pt-range { stroke: #5a2c06; stroke-width: 1; stroke-dasharray: 2 2; }
svg.boxchart .dim { opacity: .35; }
svg.boxchart .halo { paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
svg.boxchart .pt-label { font-size: 12px; font-weight: 600; fill: #7a3b0a; font-family: var(--font); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: var(--text-xs); color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-box { width: 14px; height: 10px; background: var(--accent-tint); border: 1.5px solid var(--accent); display: inline-block; }
.lg-diamond { width: 8px; height: 8px; background: var(--dot); display: inline-block; transform: rotate(45deg); margin: 0 2px; }
.lg-ring { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--dot); background: #fff; display: inline-block; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); display: inline-block; }

/* Auth */
.auth { max-width: 420px; margin: 72px auto; padding: 0 20px; }
.auth .card { padding: 28px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth .field { min-width: 0; }
.auth-switch { margin-top: 14px; font-size: var(--text-sm); color: var(--ink-2); }

.split { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 980px) { .split.two { grid-template-columns: 1.25fr 1fr; } }
.stack > * + * { margin-top: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  main { padding: 20px 16px 48px; }
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .who { text-align: left; order: 2; flex: 1; font-size: var(--text-xs); }
  .brand { order: 1; }
  nav.tabs { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 12px; }
  nav.tabs button { white-space: nowrap; }
  .field { min-width: 100%; }
}
@media print {
  .topbar, .no-print, .controls { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}

/* Qualitative Features Checklist text box (below the student chart) */
.qual-box { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 12px 14px; }
.qual-title { font-weight: 600; font-size: var(--text-sm); margin-bottom: 6px; }
.qual-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 2px 32px; font-size: var(--text-sm); }
.qual-list li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.qual-list b { font-weight: 600; white-space: nowrap; }
.qual-list .qo { color: var(--ok); }
.qual-list .qn { color: var(--warn); }
.qual-list .qx { color: var(--ink-3); font-weight: 400; }

/* License gate */
.gate .card { max-width: 640px; }
.gate-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.tier { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.tier-link:hover { border-color: var(--accent); background: var(--accent-tint); }
.tier-name { font-weight: 600; font-size: var(--text-sm); line-height: 1.25; }
.tier-price { font-size: var(--text-xl); font-weight: 600; color: var(--accent); }
.tier-who { font-size: var(--text-xs); color: var(--ink-2); }
.tier-buy { font-size: var(--text-xs); font-weight: 600; color: var(--dot); margin-top: auto; }
.gate-beta { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius); background: var(--warn-tint); color: #5c4600; font-size: var(--text-sm); }
.gate-foot { margin-top: 16px; font-size: var(--text-sm); color: var(--ink-3); }
.gate-foot a { color: var(--accent); }
.lic-dialog { border: 1px solid var(--line); border-radius: 10px; padding: 22px; max-width: 520px; width: calc(100% - 32px); }
.lic-dialog::backdrop { background: rgba(20, 25, 35, .4); }
.lic-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0 0 12px; font-size: var(--text-sm); }
.lic-list dt { color: var(--ink-3); }
.lic-list dd { margin: 0; }
@media (max-width: 640px) { .gate-tiers { grid-template-columns: 1fr; } }
.auth.gate { max-width: 680px; }
