/* ==========================================================================
   IUBAT EEE Academic Dashboard
   Independent student project. Not an official IUBAT website.

   Design system: blue / indigo, light + dark, mobile-first, accessible.
   ========================================================================== */

/* ---------------------------------------------------------------------- */
/* 1. Design tokens                                                        */
/* ---------------------------------------------------------------------- */

:root {
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3.5rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --container: 1180px;
  --container-narrow: 760px;

  --transition-fast: 140ms ease;
  --transition-med: 220ms ease;

  /* Brand palette — indigo / blue */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #4f5fe0;
  --brand-600: #3949c9;
  --brand-700: #2d38a3;
  --brand-800: #212a78;
  --brand-900: #171d54;

  --success-500: #12876a;
  --warn-500: #b5750a;
  --danger-500: #c2372c;

  color-scheme: light;

  --bg: #f4f6fc;
  --bg-alt: #eaeef8;
  --surface: #ffffff;
  --surface-2: #f8f9ff;
  --border: #dfe3f2;
  --border-strong: #c7cee6;
  --text: #12162b;
  --text-dim: #4a4f6b;
  --text-faint: #6b7190;
  --link: var(--brand-600);

  --primary: var(--brand-600);
  --primary-dark: var(--brand-700);
  --primary-contrast: #ffffff;
  --primary-tint: var(--brand-50);

  --success: var(--success-500);
  --success-tint: #e6f5ef;
  --warn: var(--warn-500);
  --warn-tint: #fdf3e2;
  --danger: var(--danger-500);
  --danger-tint: #fdeceb;

  --shadow-sm: 0 1px 2px rgba(23, 29, 84, .06), 0 1px 1px rgba(23, 29, 84, .04);
  --shadow-md: 0 8px 24px rgba(23, 29, 84, .09), 0 2px 6px rgba(23, 29, 84, .06);
  --shadow-lg: 0 20px 48px rgba(23, 29, 84, .14), 0 6px 16px rgba(23, 29, 84, .08);

  --focus-ring: 0 0 0 3px var(--brand-200);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b0e1c;
  --bg-alt: #10142a;
  --surface: #141935;
  --surface-2: #191f40;
  --border: #262d55;
  --border-strong: #333c6e;
  --text: #eef0fb;
  --text-dim: #b3b8e0;
  --text-faint: #8a90bd;
  --link: var(--brand-300);

  --primary: var(--brand-400);
  --primary-dark: var(--brand-300);
  --primary-contrast: #0b0e1c;
  --primary-tint: #1b2050;

  --success: #4fd8ac;
  --success-tint: #103224;
  --warn: #f2b94f;
  --warn-tint: #3a2c0f;
  --danger: #ff8a80;
  --danger-tint: #3a1512;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, .55);

  --focus-ring: 0 0 0 3px var(--brand-700);
}

/* ---------------------------------------------------------------------- */
/* 2. Reset & base                                                         */
/* ---------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-med), color var(--transition-med);
}

img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--link); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

ul, dl { margin: 0; padding: 0; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

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

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -3rem;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 200;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: var(--space-3); }

.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.wrap--narrow { max-width: var(--container-narrow); }

/* ---------------------------------------------------------------------- */
/* 3. Buttons / inputs / form controls                                    */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--primary-dark); }

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--primary); }

.btn--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn--danger:hover { background: var(--danger-tint); }

.btn--sm { min-height: 36px; padding: 0 var(--space-4); font-size: .875rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn:hover { background: var(--danger-tint); color: var(--danger); }

.label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: var(--space-2);
}

.input, select.input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input::placeholder { color: var(--text-faint); }
.input:focus-visible { border-color: var(--primary); box-shadow: var(--focus-ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px var(--danger-tint); }

.input--sm { min-height: 40px; font-size: .9rem; padding: 0 var(--space-2); }
.input--big { font-size: 1.4rem; font-weight: 600; text-align: center; font-family: var(--font-mono); }

select.input { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7190' stroke-width='2'%3E%3Cpath d='M5 8l5 5 5-5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  background-size: 18px;
  padding-right: var(--space-6);
}

.field { min-width: 0; }
.field--wide { max-width: 320px; margin: 0 auto var(--space-5); }

.grid { display: grid; gap: var(--space-4); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .grid--4 { grid-template-columns: 1fr; } }

.msg {
  min-height: 1.3em;
  margin: var(--space-2) 0 0;
  font-size: .875rem;
  color: var(--danger);
  font-weight: 500;
}
.msg--hint { color: var(--text-faint); font-weight: 400; }

/* ---------------------------------------------------------------------- */
/* 4. Header / nav                                                        */
/* ---------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}
.brand__mark { width: 34px; height: 34px; color: var(--primary); flex-shrink: 0; }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__name { font-weight: 700; font-size: .98rem; }
.brand__note { font-size: .72rem; color: var(--text-faint); font-weight: 500; }

.nav__list {
  list-style: none;
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.nav__list a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 600;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.nav__list a:hover { background: var(--surface-2); color: var(--text); }
.nav__list a[aria-current="true"] { background: var(--primary-tint); color: var(--primary-dark); }

.navtoggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
}
.navtoggle__bars { display: flex; flex-direction: column; gap: 3px; width: 18px; }
.navtoggle__bars span { display: block; height: 2px; background: currentColor; border-radius: 2px; }

.themebtn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  color: var(--text);
  font-weight: 600;
  font-size: .85rem;
}
.themebtn:hover { border-color: var(--primary); }
.themebtn__icon { width: 17px; height: 17px; }
.themebtn__icon--sun { display: none; color: var(--warn); }
.themebtn__icon--moon { display: block; color: var(--brand-400); }
[data-theme="dark"] .themebtn__icon--sun { display: block; }
[data-theme="dark"] .themebtn__icon--moon { display: none; }

@media (max-width: 860px) {
  .navtoggle { display: inline-flex; }
  .nav {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-med);
  }
  .nav.is-open { max-height: 480px; }
  .nav__list { flex-direction: column; padding: var(--space-3) var(--space-5) var(--space-4); gap: 0; }
  .nav__list a { padding: var(--space-3); }
  .themebtn__label, #themeLabel { display: none; }
}
@media (min-width: 861px) {
  .navtoggle__label { display: inline; }
}

/* ---------------------------------------------------------------------- */
/* 5. Hero                                                                 */
/* ---------------------------------------------------------------------- */

.hero {
  background:
    radial-gradient(1100px 420px at 15% -10%, var(--primary-tint), transparent 60%),
    var(--bg);
  padding: var(--space-8) 0 var(--space-7);
  border-bottom: 1px solid var(--border);
}
.hero__grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: var(--space-7);
  align-items: center;
}
@media (max-width: 900px) { .hero__grid { grid-template-columns: 1fr; } }

.hero__kicker {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-tint);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-4);
}
.hero__title {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.12;
  margin-bottom: var(--space-4);
}
.hero__sub { font-size: 1.08rem; color: var(--text-dim); max-width: 46ch; margin-bottom: var(--space-5); }
.hero__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.hero__disclaimer { font-size: .8rem; color: var(--text-faint); max-width: 52ch; }

.demo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  text-align: center;
}
.demo__title { font-size: 1rem; margin-bottom: var(--space-4); }
.demo__label { display: block; font-size: .8rem; color: var(--text-faint); margin-bottom: var(--space-2); }
.demo__input { margin: 0 auto var(--space-4); }
.demo__out { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); margin-bottom: var(--space-2); }
.demo__grade { font-family: var(--font-mono); font-size: 2.4rem; font-weight: 700; color: var(--primary); transition: color var(--transition-fast); }
.demo__grade.is-fail { color: var(--danger); }
.demo__point { font-size: .9rem; color: var(--text-dim); }
.demo__band { font-size: .8rem; color: var(--text-faint); }

/* ---------------------------------------------------------------------- */
/* 6. Dashboard                                                            */
/* ---------------------------------------------------------------------- */

.dashboard { padding: var(--space-7) 0; border-bottom: 1px solid var(--border); }

.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.statcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.statcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.statcard__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.statcard__icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
}
.statcard__icon svg { width: 18px; height: 18px; }
.statcard__label { font-size: .78rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.statcard__value { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; line-height: 1; margin-bottom: var(--space-1);
  transition: color var(--transition-fast); }
.statcard__sub { font-size: .8rem; color: var(--text-faint); }
.statcard__value.is-muted { color: var(--text-faint); }

.statcard--target { display: flex; flex-direction: column; }
.statcard--target .input { margin-top: var(--space-2); }

.progresscard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
}
.progresscard__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.progresscard__title { font-size: .95rem; font-weight: 700; }
.progresscard__meta { font-size: .82rem; color: var(--text-faint); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.progresscard__meta .input { width: 90px; min-height: 32px; padding: 0 var(--space-2); display: inline-block; }

.progressbar {
  height: 12px;
  background: var(--bg-alt);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progressbar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-400), var(--primary));
  border-radius: var(--radius-pill);
  transition: width var(--transition-med);
  width: 0%;
}
.progressbar__text { margin-top: var(--space-2); font-size: .8rem; color: var(--text-dim); }

.charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 860px) { .charts-grid { grid-template-columns: 1fr; } }

.chartcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.chartcard__title { font-size: .95rem; font-weight: 700; margin-bottom: var(--space-1); }
.chartcard__sub { font-size: .8rem; color: var(--text-faint); margin-bottom: var(--space-4); }
.chartcard__canvaswrap { position: relative; height: 240px; }
.chartcard__empty { font-size: .85rem; color: var(--text-faint); text-align: center; padding: var(--space-6) 0; }

.datatools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.datatools__hidden-input { display: none; }
.datatools__note { font-size: .78rem; color: var(--text-faint); width: 100%; margin-top: var(--space-1); }

/* ---------------------------------------------------------------------- */
/* 7. Section scaffolding                                                  */
/* ---------------------------------------------------------------------- */

.section { padding: var(--space-8) 0; border-bottom: 1px solid var(--border); }
.section--alt { background: var(--bg-alt); }
.section:last-of-type { border-bottom: none; }

.section__head { max-width: 68ch; margin-bottom: var(--space-6); }
.section__title { font-size: clamp(1.4rem, 2.6vw, 1.85rem); margin-bottom: var(--space-3); }
.section__lede { color: var(--text-dim); font-size: 1rem; }
.verified { font-size: .8rem; color: var(--text-faint); margin-top: var(--space-2); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.panel + .callout, .panel + aside { margin-top: var(--space-4); }
.panel__hint { font-size: .85rem; color: var(--text-faint); margin-bottom: var(--space-4); }
.panel__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-4) 0 0; }
.panel--marks { text-align: center; }

.gpa section .panel, #gpa .panel, #cgpa .panel, #planner .panel { margin-bottom: 0; }
#gpa .callout, #planner .callout { margin-top: var(--space-4); }

.callout {
  background: var(--primary-tint);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}
.callout--warn { background: var(--warn-tint); border-left-color: var(--warn); }
.callout__title { font-size: .9rem; margin-bottom: var(--space-2); }
.callout p { color: var(--text-dim); font-size: .9rem; }

/* ---------------------------------------------------------------------- */
/* 8. Tables                                                               */
/* ---------------------------------------------------------------------- */

.tablewrap { overflow-x: auto; margin: 0 calc(var(--space-5) * -1) var(--space-4); padding: 0 var(--space-5); -webkit-overflow-scrolling: touch; }
.panel .tablewrap:first-child { margin-top: calc(var(--space-1) * -1); }

.ctable, .gtable { width: 100%; border-collapse: collapse; min-width: 560px; }
.gtable { min-width: 420px; }
.ctable th, .ctable td, .gtable th, .gtable td { padding: var(--space-2) var(--space-2); text-align: left; vertical-align: middle; }
.ctable thead th, .gtable thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  border-bottom: 1.5px solid var(--border);
  padding-bottom: var(--space-3);
}
.ctable tbody tr, .gtable tbody tr { border-bottom: 1px solid var(--border); }
.ctable tbody tr:last-child, .gtable tbody tr:last-child { border-bottom: none; }
.ctable__c-name { min-width: 200px; }
.ctable__c-code { min-width: 190px; }
.ctable__c-cr { width: 88px; }
.ctable__c-gr { width: 130px; }
.ctable__c-act { width: 44px; text-align: center; }

.gtable__grade { font-family: var(--font-mono); font-weight: 700; }
.gtable__grade--fail { color: var(--danger); }
.gtable__point { font-family: var(--font-mono); }

/* ---------------------------------------------------------------------- */
/* 9. Results                                                              */
/* ---------------------------------------------------------------------- */

.result {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-top: var(--space-4);
}
.result__main { min-width: 140px; }
.result__label { font-size: .78rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--space-1); }
.result__value { font-family: var(--font-mono); font-size: 2.1rem; font-weight: 700; color: var(--primary); transition: color var(--transition-fast); }
.result__value.is-muted { color: var(--text-faint); }
.result__value.is-warn { color: var(--danger); font-size: 1.15rem; line-height: 1.35; font-family: var(--font-sans); font-weight: 600; }
.result__stats { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.result__stats dt { font-size: .74rem; color: var(--text-faint); margin-bottom: 2px; }
.result__stats dd { margin: 0; font-family: var(--font-mono); font-weight: 600; }

.note { font-size: .85rem; color: var(--text-dim); background: var(--bg-alt); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin-top: var(--space-4); }

/* Marks-to-grade */
.markout { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin-bottom: var(--space-5); }
@media (max-width: 560px) { .markout { grid-template-columns: 1fr; } }
.markout__cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.markout__grade { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; color: var(--primary); }
.markout__grade.is-fail { color: var(--danger); }
.markout__point { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; }
.markout__band { font-size: .95rem; font-weight: 600; }

.ladder { display: flex; border-radius: var(--radius-pill); overflow: hidden; border: 1px solid var(--border); }
.ladder__seg { flex: 1; text-align: center; padding: var(--space-2) 0; font-size: .72rem; font-weight: 700; color: var(--text-faint); background: var(--surface-2); font-family: var(--font-mono); transition: background-color var(--transition-fast), color var(--transition-fast); }
.ladder__seg.is-fail { color: var(--danger); }
.ladder__seg.is-on { background: var(--primary); color: var(--primary-contrast); }

/* ---------------------------------------------------------------------- */
/* 10. Tabs                                                                */
/* ---------------------------------------------------------------------- */

.tabs__list { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

/* ---------------------------------------------------------------------- */
/* 11. Rules grid / sources / prose                                       */
/* ---------------------------------------------------------------------- */

.rulegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.rulecard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.rulecard--flag { border-color: var(--warn); background: var(--warn-tint); }
.rulecard__title { font-size: .95rem; margin-bottom: var(--space-3); }
.list { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); font-size: .875rem; color: var(--text-dim); }
.list li { position: relative; padding-left: var(--space-4); }
.list li::before { content: ''; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.rulecard--flag .list li::before { background: var(--warn); }

.sources { padding: var(--space-4) 0 0; }
.sources__title { font-size: .9rem; margin-bottom: var(--space-3); }
.sources__list { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); font-size: .875rem; }

.prose { font-size: 1rem; color: var(--text-dim); }
.prose__strong { font-weight: 700; color: var(--text); }

/* ---------------------------------------------------------------------- */
/* 12. Toasts                                                              */
/* ---------------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(92vw, 380px);
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-med), transform var(--transition-med);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--success); color: #06251c; }

/* ---------------------------------------------------------------------- */
/* 13. Footer                                                              */
/* ---------------------------------------------------------------------- */

.foot { padding: var(--space-6) 0; }
.foot__inner { display: flex; flex-direction: column; gap: var(--space-2); }
.foot__line { font-size: .82rem; color: var(--text-dim); }
.foot__line--dim { color: var(--text-faint); }

/* ---------------------------------------------------------------------- */
/* 14. Reveal-on-scroll & number transitions                               */
/* ---------------------------------------------------------------------- */

.section, .dashboard { opacity: 1; }
.statcard, .chartcard, .progresscard, .panel, .rulecard, .demo {
  animation: fadeUp .5s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .statcard, .chartcard, .progresscard, .panel, .rulecard, .demo { animation: none; }
}

/* ---------------------------------------------------------------------- */
/* 15. Print                                                               */
/* ---------------------------------------------------------------------- */

@media print {
  .topbar, .navtoggle, .themebtn, .hero__actions, .panel__actions, .toasts,
  .datatools, .foot, .skip-link, .charts-grid, #clearAll, #clearMsg,
  .callout, .rulegrid, .sources, .hero__demo, .tabs__list { display: none !important; }

  body { background: #fff; color: #000; }
  .section, .dashboard { border: none; padding: var(--space-4) 0; break-inside: avoid; }
  .panel, .statcard, .progresscard, .rulecard { box-shadow: none; border: 1px solid #ccc; }
  a { color: #000; text-decoration: none; }
  .wrap { max-width: 100%; padding: 0; }
  .ctable, .gtable { min-width: 0; }
  .tablewrap { overflow: visible; margin: 0; padding: 0; }
}
