/* ==========================================================================
   CAMPUS DESIGN SYSTEM
   Campus — Smart School Management & Communication Platform, by Branova.

   One stylesheet, no framework, no build step, no CDN, no web fonts.
   Everything is driven by custom properties so a school's own colour can be
   injected at runtime (white-label) without touching this file.

   Contents
     1  Tokens
     2  Reset & base
     3  Layout shell (sidebar / topbar / bottom nav)
     4  Typography
     5  Cards & stat tiles
     6  Buttons
     7  Forms
     8  Tables (with mobile card-collapse)
     9  Badges, chips, alerts
    10  Tabs, modals, drawers, dropdowns
    11  Timeline, list rows, avatars
    12  Charts (inline SVG support classes)
    13  Attendance grid
    14  Empty states, skeletons, pagination
    15  Login / auth screens
    16  Utilities
    17  Print
    18  Dark mode
   ========================================================================== */

/* 1 ─ TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  /* Brand — sampled from the Campus logo */
  --brand-500: #0A6ADD;
  --brand-600: #0857ba;
  --brand-700: #06459a;
  --brand-400: #3d8bea;
  --brand-100: #dfeefe;
  --brand-050: #f2f8ff;

  --accent-500: #27A967;
  --accent-600: #1d8a53;
  --accent-100: #dff5e9;

  --slate-900: #16202e;
  --slate-800: #24303f;
  --slate-700: #3a4657;
  --slate-600: #4d5a6c;
  --slate-500: #5E6E83;
  --slate-400: #8695a8;
  --slate-300: #b3c0ce;
  --slate-200: #d7dee6;
  --slate-100: #e9eef3;
  --slate-050: #f4f7fa;

  --danger-500: #d92d20;
  --danger-100: #fee4e2;
  --warn-500:   #dc8a04;
  --warn-100:   #fef3c7;
  --info-500:   #0a6add;
  --info-100:   #dfeefe;
  --success-500: #17924f;
  --success-100: #dff5e9;

  /* Semantic (re-mapped in dark mode) */
  --bg:            #f4f7fa;
  --bg-raised:     #ffffff;
  --bg-sunken:     #eef2f7;
  --bg-hover:      #f4f7fa;
  --surface-line:  #e3e9ef;
  --text:          #16202e;
  --text-muted:    #5E6E83;
  --text-subtle:   #8695a8;
  --text-invert:   #ffffff;
  --primary:       var(--brand-500);
  --primary-hover: var(--brand-600);
  --primary-soft:  var(--brand-100);
  --primary-text:  #ffffff;
  --sidebar-bg:    #0f1d31;
  --sidebar-text:  #cbd7e6;
  --sidebar-hover: #1a2c47;
  --sidebar-active: var(--brand-500);

  /* Type scale */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
          "Noto Sans Tamil", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --fs-xs: .75rem;   --fs-sm: .8125rem; --fs-md: .875rem;
  --fs-base: .9375rem; --fs-lg: 1.0625rem; --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;  --fs-3xl: 1.875rem; --fs-4xl: 2.25rem;

  /* Space, radius, shadow, motion */
  --sp-1: .25rem; --sp-2: .5rem;  --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem;  --sp-10: 2.5rem; --sp-12: 3rem;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --sh-xs: 0 1px 2px rgba(22,32,46,.06);
  --sh-sm: 0 1px 3px rgba(22,32,46,.08), 0 1px 2px rgba(22,32,46,.04);
  --sh-md: 0 4px 12px rgba(22,32,46,.08), 0 2px 4px rgba(22,32,46,.04);
  --sh-lg: 0 12px 32px rgba(22,32,46,.12), 0 4px 8px rgba(22,32,46,.05);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: 160ms;

  /* Shell metrics */
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --bottomnav-h: 62px;

  color-scheme: light;
}

/* 2 ─ RESET & BASE ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Accessible skip link, visible only on keyboard focus */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--primary); color: #fff;
  padding: var(--sp-3) var(--sp-4); border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* 3 ─ LAYOUT SHELL ───────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  z-index: 40;
}
.sidebar::-webkit-scrollbar-thumb { background: #2a3d59; border-color: var(--sidebar-bg); }

.sidebar__brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: sticky; top: 0; background: var(--sidebar-bg); z-index: 2;
}
.sidebar__brand img {
  width: 34px; height: 34px; flex: 0 0 34px; padding: 4px;
  background: #fff; border-radius: 9px;     /* same reason as .auth__brand img */
}
.sidebar__brand-text { min-width: 0; }
.sidebar__brand-name {
  font-size: var(--fs-lg); font-weight: 700; color: #fff;
  letter-spacing: -.01em; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__brand-sub { font-size: var(--fs-xs); color: #7f93ad; line-height: 1.2; }

.sidebar__school {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: var(--fs-xs); color: #8fa3bd;
}
.sidebar__school strong { display: block; color: #e6edf6; font-size: var(--fs-sm); font-weight: 600; }

.sidebar__nav { padding: var(--sp-3) var(--sp-3) var(--sp-8); flex: 1; }
.sidebar__section {
  font-size: .6875rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: #6b7f99;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
button.nav-item {
  background: none; border: 0; width: 100%; font: inherit;
  text-align: left; cursor: pointer;
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: .5625rem var(--sp-3);
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  font-size: var(--fs-md); font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item.is-active .icon { color: #fff; }
.nav-item .icon { flex: 0 0 20px; color: #8fa3bd; }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item__chev { transition: transform var(--dur) var(--ease); flex: 0 0 16px; }
.nav-item[aria-expanded="true"] .nav-item__chev { transform: rotate(90deg); }
.nav-item__badge {
  background: var(--danger-500); color: #fff;
  font-size: .625rem; font-weight: 700;
  padding: .0625rem .3125rem; border-radius: var(--r-full); min-width: 18px; text-align: center;
}
.nav-sub { padding-left: calc(var(--sp-3) + 20px + var(--sp-3)); }
.nav-sub a {
  display: block; padding: .375rem var(--sp-3);
  color: #9fb2c9; font-size: var(--fs-sm); border-radius: var(--r-sm);
}
.nav-sub a:hover { color: #fff; background: var(--sidebar-hover); text-decoration: none; }
.nav-sub a.is-active { color: #fff; font-weight: 600; }

.sidebar__footer {
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
  font-size: var(--fs-xs); color: #6b7f99;
  border-top: 1px solid rgba(255,255,255,.07);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--surface-line);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5);
  position: sticky; top: 0; z-index: 30;
}
.topbar__toggle { display: none; }
.topbar__spacer { flex: 1; }

.topbar__search { position: relative; width: min(340px, 34vw); }
.topbar__search input {
  width: 100%; padding: .4375rem var(--sp-3) .4375rem 2.25rem;
  border: 1px solid var(--surface-line); border-radius: var(--r-full);
  background: var(--bg-sunken); font-size: var(--fs-md);
}
.topbar__search input:focus { background: var(--bg-raised); border-color: var(--brand-400); outline: none; }
.topbar__search .icon { position: absolute; left: .6875rem; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent;
  color: var(--text-muted); cursor: pointer; position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn__dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--danger-500); color: #fff;
  font-size: .5625rem; font-weight: 700; line-height: 16px;
  border-radius: var(--r-full); text-align: center;
  border: 2px solid var(--bg-raised);
}

.page { padding: var(--sp-6) var(--sp-5) var(--sp-10); flex: 1; }
.page__head {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.page__head-main { flex: 1; min-width: 220px; }
.page__title { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.page__subtitle { color: var(--text-muted); font-size: var(--fs-md); margin-top: var(--sp-1); }
.page__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

.breadcrumb { display: flex; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-subtle); margin-bottom: var(--sp-2); flex-wrap: wrap; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span::after { content: "/"; margin-left: var(--sp-2); color: var(--slate-300); }
.breadcrumb span:last-child::after { content: ""; }

/* Bottom navigation — phones only, for parent/teacher/student roles */
.bottomnav { display: none; }

/* 4 ─ TYPOGRAPHY ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5 { font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-base); }
p  { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }
small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-danger { color: var(--danger-500); }
.text-success { color: var(--success-500); }
.text-warning { color: var(--warn-500); }
.text-warn { color: var(--warn-500); }
.text-primary { color: var(--primary); }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.lead { font-size: var(--fs-lg); color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }

/* 5 ─ CARDS & STAT TILES ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--surface-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--surface-line);
  flex-wrap: wrap;
}
.card__title { font-size: var(--fs-base); font-weight: 650; flex: 1; min-width: 0; }
.card__sub { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 400; }
.card__body { padding: var(--sp-5); }
.card__body--tight { padding: var(--sp-3) var(--sp-4); }
.card__body--flush { padding: 0; }
.card__foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--surface-line);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: var(--fs-sm);
}

.grid { display: grid; gap: var(--sp-4); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }

.stat {
  background: var(--bg-raised);
  border: 1px solid var(--surface-line);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  display: flex; gap: var(--sp-4); align-items: flex-start;
  box-shadow: var(--sh-xs);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
a.stat:hover { box-shadow: var(--sh-md); transform: translateY(-1px); text-decoration: none; }
.stat__icon {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.stat__icon--accent  { background: var(--accent-100);  color: var(--accent-600); }
.stat__icon--danger  { background: var(--danger-100);  color: var(--danger-500); }
.stat__icon--warn    { background: var(--warn-100);    color: var(--warn-500); }
.stat__icon--success { background: var(--success-100); color: var(--success-500); }
.stat__icon--muted   { background: var(--slate-100);   color: var(--slate-600); }
.stat__body { min-width: 0; flex: 1; }
/* .stat is an <a>, so its children are spans — force them to stack. */
.stat__label, .stat__value, .stat__meta { display: block; }
.stat__label {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-subtle);
}
.stat__value {
  font-size: var(--fs-2xl); font-weight: 700; line-height: 1.15;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  margin-top: .125rem; color: var(--text);
}
.stat__meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: .125rem; }
.stat__delta { font-weight: 600; }
.stat__delta--up { color: var(--success-500); }
.stat__delta--down { color: var(--danger-500); }

/* 6 ─ BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: .5rem var(--sp-4);
  min-height: 40px;                     /* touch target */
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 600;
  cursor: pointer; white-space: nowrap;
  background: var(--primary); color: var(--primary-text);
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .icon { flex: 0 0 auto; }

.btn--secondary {
  background: var(--bg-raised); color: var(--text);
  border-color: var(--surface-line); box-shadow: var(--sh-xs);
}
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--slate-300); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn--accent { background: var(--accent-500); }
.btn--accent:hover { background: var(--accent-600); }
.btn--danger { background: var(--danger-500); }
.btn--danger:hover { background: #b42318; }
.btn--outline-danger { background: transparent; color: var(--danger-500); border-color: var(--danger-100); }
.btn--outline-danger:hover { background: var(--danger-100); }
.btn--sm { min-height: 32px; padding: .25rem var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { min-height: 46px; padding: .625rem var(--sp-6); font-size: var(--fs-base); }
.btn--block { width: 100%; }
.btn--icon { padding: .5rem; width: 40px; }

.btn-group { display: inline-flex; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--sh-xs); }
.btn-group .btn { border-radius: 0; border-right-width: 0; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; border-right-width: 1px; }

/* 7 ─ FORMS ──────────────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.field { display: block; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field__label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  margin-bottom: var(--sp-2); color: var(--text);
}
.field__label .req { color: var(--danger-500); margin-left: 2px; }
.field__hint { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: var(--sp-1); }

.input, .select, .textarea {
  width: 100%;
  padding: .5rem var(--sp-3);
  min-height: 40px;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  font-size: var(--fs-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--slate-300); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-sunken); color: var(--text-muted); cursor: not-allowed; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E6E83' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .625rem center;
  padding-right: 2.25rem;
}
.input--error, .select--error, .textarea--error { border-color: var(--danger-500); }
.input--error:focus { box-shadow: 0 0 0 3px var(--danger-100); }
.field-error { display: block; color: var(--danger-500); font-size: var(--fs-xs); margin-top: var(--sp-1); font-weight: 500; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .btn { border-radius: 0 var(--r-md) var(--r-md) 0; }

.check {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-2) 0; cursor: pointer; font-size: var(--fs-md);
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 18px;
  accent-color: var(--primary); cursor: pointer;
}
.check__text { min-width: 0; }
.check__desc { font-size: var(--fs-xs); color: var(--text-muted); }

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 42px; height: 24px; border-radius: var(--r-full);
  background: var(--slate-300); position: relative;
  transition: background var(--dur) var(--ease); flex: 0 0 42px;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: var(--sh-sm); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--primary); outline-offset: 2px; }

.filters {
  display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end;
  padding: var(--sp-4); background: var(--bg-raised);
  border: 1px solid var(--surface-line); border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
}
.filters .field { flex: 1 1 170px; min-width: 140px; }
.filters__actions { display: flex; gap: var(--sp-2); }

.form-actions {
  display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap;
  padding-top: var(--sp-5); margin-top: var(--sp-5);
  border-top: 1px solid var(--surface-line);
}
.form-actions--sticky {
  position: sticky; bottom: 0; background: var(--bg-raised);
  padding: var(--sp-4); margin: var(--sp-5) calc(var(--sp-5) * -1) calc(var(--sp-5) * -1);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  z-index: 5;
}

.fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-6); }
.fieldset__legend {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-subtle);
  padding: 0 0 var(--sp-3); width: 100%;
  border-bottom: 1px solid var(--surface-line); margin-bottom: var(--sp-4);
}

.photo-field { display: flex; align-items: center; gap: var(--sp-4); }
.photo-field__preview {
  width: 72px; height: 72px; border-radius: var(--r-md);
  object-fit: cover; background: var(--bg-sunken);
  border: 1px solid var(--surface-line);
}

/* 8 ─ TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td {
  padding: .6875rem var(--sp-4);
  text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--surface-line);
}
.table thead th {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-subtle);
  background: var(--bg-sunken); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.center, .table th.center { text-align: center; }
.table .actions { display: flex; gap: var(--sp-1); justify-content: flex-end; }
.table--compact th, .table--compact td { padding: .4375rem var(--sp-3); }
.table tfoot td,
.table tfoot th { font-weight: 700; background: var(--bg-sunken); border-top: 2px solid var(--surface-line); }

.cell-primary { font-weight: 600; color: var(--text); }
.cell-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.cell-person { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }

/* 9 ─ BADGES, CHIPS, ALERTS ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .1875rem .5rem;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4;
  border-radius: var(--r-full); white-space: nowrap;
}
.badge--success { background: var(--success-100); color: #0e6b39; }
.badge--danger  { background: var(--danger-100);  color: #912018; }
.badge--warning { background: var(--warn-100);    color: #92600a; }
.badge--info    { background: var(--info-100);    color: #06459a; }
.badge--muted   { background: var(--slate-100);   color: var(--slate-600); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: .3125rem var(--sp-3);
  background: var(--bg-raised); border: 1px solid var(--surface-line);
  border-radius: var(--r-full); font-size: var(--fs-sm); color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { border-color: var(--slate-300); text-decoration: none; }
.chip.is-active { background: var(--primary-soft); border-color: var(--brand-400); color: var(--brand-700); font-weight: 600; }
.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.alert {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border-left: 3px solid;
  font-size: var(--fs-md);
  margin-bottom: var(--sp-4);
}
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 650; }
.alert--success { background: var(--success-100); border-color: var(--success-500); color: #0e6b39; }
.alert--error   { background: var(--danger-100);  border-color: var(--danger-500);  color: #912018; }
.alert--warning { background: var(--warn-100);    border-color: var(--warn-500);    color: #92600a; }
.alert--info    { background: var(--info-100);    border-color: var(--info-500);    color: #06459a; }
.alert .icon { flex: 0 0 20px; margin-top: 1px; }

.toast-stack {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5);
  z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: min(380px, calc(100vw - 2rem));
}
.toast {
  background: var(--slate-900); color: #fff;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); font-size: var(--fs-md);
  display: flex; gap: var(--sp-3); align-items: flex-start;
  animation: toast-in 200ms var(--ease);
}
.toast--success { background: #0e6b39; }
.toast--error { background: #912018; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 10 ─ TABS, MODALS, DRAWERS, DROPDOWNS ──────────────────────────────────── */
.tabs {
  display: flex; gap: var(--sp-1); overflow-x: auto;
  border-bottom: 1px solid var(--surface-line);
  margin-bottom: var(--sp-5); -webkit-overflow-scrolling: touch;
}
.tabs__item {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-md); font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
  background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer;
}
.tabs__item:hover { color: var(--text); text-decoration: none; }
.tabs__item.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(22,32,46,.5);
  display: grid; place-items: center; padding: var(--sp-4);
  z-index: 150; animation: fade-in 140ms var(--ease);
}
.modal {
  background: var(--bg-raised); border-radius: var(--r-xl);
  box-shadow: var(--sh-lg); width: min(560px, 100%);
  max-height: 88vh; display: flex; flex-direction: column;
  animation: modal-in 180ms var(--ease);
}
.modal--wide { width: min(860px, 100%); }
.modal__head {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--surface-line);
  display: flex; align-items: flex-start; gap: var(--sp-3);
}
.modal__title { font-size: var(--fs-lg); font-weight: 650; flex: 1; }
.modal__body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal__foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--surface-line);
  display: flex; gap: var(--sp-3); justify-content: flex-end; flex-wrap: wrap;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; background: var(--bg-raised);
  border: 1px solid var(--surface-line); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); padding: var(--sp-2); z-index: 60;
  animation: fade-in 120ms var(--ease);
  max-height: 70vh; overflow-y: auto;
}
.dropdown__item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: .5rem var(--sp-3); border-radius: var(--r-sm);
  font-size: var(--fs-md); color: var(--text); width: 100%;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.dropdown__item:hover { background: var(--bg-hover); text-decoration: none; }
.dropdown__item--danger { color: var(--danger-500); }
.dropdown__divider { height: 1px; background: var(--surface-line); margin: var(--sp-2) 0; }
.dropdown__label {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-subtle);
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
}

/* 11 ─ TIMELINE, LIST ROWS, AVATARS ─────────────────────────────────────── */
.avatar {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 50%; object-fit: cover;
  background: var(--primary-soft); color: var(--brand-700);
  display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase;
  overflow: hidden;
}
.avatar--sm { width: 30px; height: 30px; flex-basis: 30px; font-size: var(--fs-xs); }
.avatar--lg { width: 64px; height: 64px; flex-basis: 64px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.avatar--xl { width: 96px; height: 96px; flex-basis: 96px; font-size: var(--fs-2xl); border-radius: var(--r-lg); }

.timeline { position: relative; padding-left: var(--sp-2); }
.timeline__day { margin-bottom: var(--sp-5); }
.timeline__date {
  display: inline-flex; align-items: baseline; gap: var(--sp-2);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-subtle); margin-bottom: var(--sp-3);
}
.timeline__items { position: relative; padding-left: var(--sp-8); }
.timeline__items::before {
  content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px;
  width: 2px; background: var(--surface-line);
}
.timeline__item { position: relative; padding-bottom: var(--sp-4); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__marker {
  position: absolute; left: calc(var(--sp-8) * -1); top: 2px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-raised); border: 2px solid var(--surface-line);
  display: grid; place-items: center; color: var(--text-muted); z-index: 1;
}
.timeline__marker--attendance { border-color: var(--success-500); color: var(--success-500); }
.timeline__marker--homework   { border-color: var(--brand-500);   color: var(--brand-500); }
.timeline__marker--exam       { border-color: var(--warn-500);    color: var(--warn-500); }
.timeline__marker--result     { border-color: var(--accent-500);  color: var(--accent-600); }
.timeline__marker--fee        { border-color: var(--accent-500);  color: var(--accent-600); }
.timeline__marker--announcement { border-color: var(--info-500);  color: var(--info-500); }
.timeline__marker--event      { border-color: var(--brand-400);   color: var(--brand-500); }
.timeline__body {
  background: var(--bg-raised); border: 1px solid var(--surface-line);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
}
.timeline__title { font-weight: 600; font-size: var(--fs-md); }
.timeline__meta { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: .125rem; }
.timeline__summary { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-1); }

.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--surface-line);
  transition: background var(--dur) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--bg-hover); text-decoration: none; }
.list-row__body { flex: 1; min-width: 0; }
.list-row__title { font-weight: 600; font-size: var(--fs-md); color: var(--text); }
.list-row__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.list-row__aside { text-align: right; flex: 0 0 auto; font-size: var(--fs-sm); }
.list-row.is-unread { background: var(--brand-050); }
.list-row.is-unread .list-row__title::after {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: var(--primary); margin-left: var(--sp-2);
}

/* 12 ─ CHARTS ────────────────────────────────────────────────────────────── */
.chart { width: 100%; overflow: hidden; }
/* A donut is square: cap its width so it does not stretch a card to full height. */
.chart--donut { max-width: 240px; margin-inline: auto; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart__legend {
  display: flex; gap: var(--sp-4); flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--text-muted);
  margin-top: var(--sp-3); justify-content: center;
}
.chart__legend-item { display: inline-flex; align-items: center; gap: var(--sp-2); }
.chart__swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.chart__grid line { stroke: var(--surface-line); stroke-width: 1; }
.chart__axis text { fill: var(--text-subtle); font-size: 10px; }
.chart__bar { transition: opacity var(--dur) var(--ease); }
.chart__bar:hover { opacity: .8; }
.chart__label { fill: var(--text-muted); font-size: 10px; }
.chart__value { fill: var(--text); font-size: 11px; font-weight: 600; }

.meter { height: 8px; background: var(--slate-100); border-radius: var(--r-full); overflow: hidden; }
.meter__fill { height: 100%; border-radius: var(--r-full); background: var(--primary); transition: width 400ms var(--ease); }
.meter__fill--success { background: var(--success-500); }
.meter__fill--warn { background: var(--warn-500); }
.meter__fill--danger { background: var(--danger-500); }
.meter-row { display: flex; align-items: center; gap: var(--sp-3); }
.meter-row .meter { flex: 1; }
.meter-row__value { font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }

/* 13 ─ ATTENDANCE GRID ──────────────────────────────────────────────────── */
.att-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.att-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-raised); border: 1px solid var(--surface-line);
  border-radius: var(--r-md);
}
.att-row__name { flex: 1; min-width: 0; font-weight: 600; font-size: var(--fs-md); }
.att-row__roll { font-size: var(--fs-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.att-options { display: flex; gap: .25rem; flex-wrap: wrap; }
.att-opt { position: relative; }
.att-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.att-opt__label {
  display: grid; place-items: center;
  min-width: 42px; height: 38px; padding: 0 var(--sp-2);
  border: 1px solid var(--surface-line); border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 700; cursor: pointer;
  color: var(--text-muted); background: var(--bg-raised);
  transition: all var(--dur) var(--ease); user-select: none;
}
.att-opt__label:hover { border-color: var(--slate-300); }
.att-opt input:checked + .att-opt__label { color: #fff; border-color: transparent; }
.att-opt--present input:checked + .att-opt__label { background: var(--success-500); }
.att-opt--absent  input:checked + .att-opt__label { background: var(--danger-500); }
.att-opt--late    input:checked + .att-opt__label { background: var(--warn-500); }
.att-opt--half    input:checked + .att-opt__label { background: var(--brand-500); }
.att-opt--excused input:checked + .att-opt__label { background: var(--slate-500); }
.att-opt input:focus-visible + .att-opt__label { outline: 2px solid var(--primary); outline-offset: 2px; }

.att-bulk {
  display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center;
  padding: var(--sp-3) var(--sp-4); background: var(--brand-050);
  border: 1px solid var(--brand-100); border-radius: var(--r-md);
  margin-bottom: var(--sp-4); font-size: var(--fs-sm);
}

/* 14 ─ EMPTY STATES, SKELETONS, PAGINATION ──────────────────────────────── */
.empty { text-align: center; padding: var(--sp-10) var(--sp-5); color: var(--text-muted); }
.empty__icon {
  width: 56px; height: 56px; margin: 0 auto var(--sp-4);
  border-radius: var(--r-lg); background: var(--bg-sunken);
  display: grid; place-items: center; color: var(--text-subtle);
}
.empty__title { font-size: var(--fs-lg); font-weight: 650; color: var(--text); margin-bottom: var(--sp-2); }
.empty__text { font-size: var(--fs-md); max-width: 34rem; margin: 0 auto var(--sp-4); }

.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-050) 50%, var(--slate-100) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm); height: 1em;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.pagination {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4); flex-wrap: wrap;
  border-top: 1px solid var(--surface-line);
}
.pagination__info { font-size: var(--fs-sm); color: var(--text-muted); flex: 1; }
.pagination__pages { display: flex; gap: .25rem; }
.pagination__link {
  display: grid; place-items: center; min-width: 36px; height: 36px;
  padding: 0 var(--sp-2); border-radius: var(--r-sm);
  border: 1px solid var(--surface-line); font-size: var(--fs-sm);
  color: var(--text-muted); background: var(--bg-raised);
}
.pagination__link:hover { background: var(--bg-hover); text-decoration: none; }
.pagination__link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pagination__link.is-disabled { opacity: .45; pointer-events: none; }

/* 15 ─ LOGIN / AUTH ─────────────────────────────────────────────────────── */
.auth {
  min-height: 100vh; display: grid;
  grid-template-columns: 1fr min(460px, 100%);
  background: var(--bg-raised);
}
.auth__aside {
  background:
    radial-gradient(1000px 600px at 15% 20%, rgba(255,255,255,.14), transparent 60%),
    linear-gradient(145deg, var(--brand-700) 0%, var(--brand-500) 55%, #0b7fd6 100%);
  color: #fff; padding: var(--sp-12) var(--sp-10);
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth__aside::after {
  content: ""; position: absolute; right: -120px; bottom: -140px;
  width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.auth__aside-dots {
  position: absolute; top: var(--sp-8); right: var(--sp-8);
  display: grid; grid-template-columns: repeat(3, 8px); gap: 10px; opacity: .28;
}
.auth__aside-dots i { width: 8px; height: 8px; border-radius: 50%; background: #fff; display: block; }
.auth__brand { display: flex; align-items: center; gap: var(--sp-3); position: relative; z-index: 1; }
.auth__brand img {
  width: 46px; height: 46px; padding: 5px;
  background: #fff; border-radius: 11px;   /* the mark is blue: a white tile keeps it legible on the blue panel */
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.auth__brand-name { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.auth__brand-sub { font-size: var(--fs-sm); opacity: .8; }
.auth__pitch { position: relative; z-index: 1; max-width: 30rem; }
.auth__pitch h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 700; letter-spacing: -.025em; margin-bottom: var(--sp-4); }
.auth__pitch p { font-size: var(--fs-lg); opacity: .88; }
.auth__features { list-style: none; padding: 0; margin: var(--sp-6) 0 0; display: grid; gap: var(--sp-3); }
.auth__features li { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-md); opacity: .92; }
.auth__features .icon { flex: 0 0 18px; }
.auth__foot { font-size: var(--fs-sm); opacity: .7; position: relative; z-index: 1; }

.auth__panel {
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--sp-10) var(--sp-8); max-width: 100%;
}
.auth__panel-inner { width: 100%; max-width: 24rem; margin: 0 auto; }
.auth__mobile-brand { display: none; text-align: center; margin-bottom: var(--sp-6); }
.auth__mobile-brand img {
  width: 56px; height: 56px; margin: 0 auto var(--sp-3);
  padding: 6px; background: var(--brand-050); border-radius: 14px;
}
.auth__title { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; }
.auth__subtitle { color: var(--text-muted); margin: var(--sp-2) 0 var(--sp-6); }
.auth__form { display: grid; gap: var(--sp-4); }
.auth__meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); flex-wrap: wrap; gap: var(--sp-2); }
.auth__divider {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text-subtle); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: .06em; margin: var(--sp-6) 0;
}
.auth__divider::before, .auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--surface-line); }
.auth__demo { background: var(--bg-sunken); border: 1px solid var(--surface-line); border-radius: var(--r-md); padding: var(--sp-4); font-size: var(--fs-sm); }
.auth__demo-title { font-weight: 650; margin-bottom: var(--sp-2); font-size: var(--fs-sm); }
.auth__demo-grid { display: grid; gap: var(--sp-2); }
.auth__demo-row { display: flex; align-items: center; gap: var(--sp-2); justify-content: space-between; }
.auth__demo-row code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); }
.auth__legal { text-align: center; font-size: var(--fs-xs); color: var(--text-subtle); margin-top: var(--sp-6); }
.auth__alt { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-5); }

/* Registration asks for more than a login does, so its panel is wider and
   pairs short fields side by side — collapsing to one column on a phone. */
.auth__panel-inner--wide { max-width: 30rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
@media (max-width: 30rem) { .grid-2 { grid-template-columns: 1fr; } }

/* Honeypot: off-screen rather than display:none, which some bots skip. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* AI provider picker — radio cards, one per supported provider. The whole
   card is the label, so the hit area is the card rather than the dot. */
.ai-providers { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--sp-3); }
.ai-provider {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  border: 1px solid var(--surface-line); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ai-provider:hover { border-color: var(--brand-400); }
.ai-provider.is-chosen { border-color: var(--brand-500); background: var(--primary-soft); }
.ai-provider input { margin-top: .2rem; flex: 0 0 auto; }
.ai-provider__body { display: grid; gap: 2px; min-width: 0; }
.ai-provider__name { font-weight: 650; }
.ai-provider__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.ai-provider__meta code { font-size: var(--fs-xs); }
.ai-provider__link { font-size: var(--fs-xs); justify-self: start; }

/* Password strength meter on the change-password screen */
.pw-meter { display: flex; gap: 4px; margin-top: var(--sp-2); }
.pw-meter i { height: 4px; flex: 1; border-radius: 2px; background: var(--slate-200); transition: background var(--dur) var(--ease); }
.pw-meter.is-1 i:nth-child(1) { background: var(--danger-500); }
.pw-meter.is-2 i:nth-child(-n+2) { background: var(--warn-500); }
.pw-meter.is-3 i:nth-child(-n+3) { background: var(--brand-500); }
.pw-meter.is-4 i { background: var(--success-500); }

/* 16 ─ UTILITIES ────────────────────────────────────────────────────────── */
.flex { display: flex; } .inline-flex { display: inline-flex; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; } .justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; } .flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); }
.p-0 { padding: 0; } .p-4 { padding: var(--sp-4); } .p-5 { padding: var(--sp-5); }
.w-full { width: 100%; }
.text-left { text-align: left; } .text-center { text-align: center; } .text-right { text-align: right; }
.font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.uppercase { text-transform: uppercase; letter-spacing: .04em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.rounded { border-radius: var(--r-md); }
.hide-mobile { display: initial; }
.show-mobile { display: none; }
.divider { height: 1px; background: var(--surface-line); margin: var(--sp-4) 0; }

/* 17 ─ RESPONSIVE ───────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 268px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: var(--sh-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0;
    background: rgba(22,32,46,.5); z-index: 35;
  }
  .topbar__toggle { display: inline-flex; }
  .topbar__search { display: none; }
  .page { padding: var(--sp-4) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-8)); }
  .page__title { font-size: var(--fs-xl); }
  .hide-mobile { display: none; }
  .show-mobile { display: initial; }

  /* Bottom navigation for parent/teacher/student on phones */
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--bg-raised);
    border-top: 1px solid var(--surface-line);
    z-index: 45; padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 3px rgba(22,32,46,.05);
  }
  .bottomnav__item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px;
    font-size: .625rem; font-weight: 600; color: var(--text-subtle);
    padding: var(--sp-2) 0; min-width: 0;
  }
  .bottomnav__item:hover { text-decoration: none; }
  .bottomnav__item.is-active { color: var(--primary); }
  .bottomnav__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

  /* Tables collapse to labelled cards — each cell carries data-label */
  .table--responsive thead { display: none; }
  .table--responsive tbody tr {
    display: block; margin-bottom: var(--sp-3);
    border: 1px solid var(--surface-line); border-radius: var(--r-md);
    background: var(--bg-raised); padding: var(--sp-2) var(--sp-3);
  }
  .table--responsive tbody td {
    display: flex; justify-content: space-between; gap: var(--sp-3);
    padding: .375rem 0; border: 0; text-align: right;
  }
  .table--responsive tbody td::before {
    content: attr(data-label);
    font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em;
    text-transform: uppercase; color: var(--text-subtle);
    text-align: left; flex: 0 0 42%;
  }
  .table--responsive tbody td:not(:last-child) { border-bottom: 1px solid var(--slate-050); }
  .table--responsive .actions { justify-content: flex-end; }

  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .auth__mobile-brand { display: block; }
  .auth__panel { padding: var(--sp-8) var(--sp-5); }

  .filters { padding: var(--sp-3); }
  .filters .field { flex: 1 1 100%; }

  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; align-self: end; }
  .modal-backdrop { padding: 0; place-items: end center; }

  .toast-stack { left: var(--sp-4); right: var(--sp-4); bottom: calc(var(--bottomnav-h) + var(--sp-4)); max-width: none; }

  .att-row { flex-wrap: wrap; }
  .att-options { width: 100%; }
  .att-opt { flex: 1; }
  .att-opt__label { width: 100%; min-width: 0; }
}

@media (max-width: 560px) {
  .page__head { flex-direction: column; }
  .page__actions { width: 100%; }
  .page__actions .btn { flex: 1; }
  .grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .stat { padding: var(--sp-3); flex-direction: column; gap: var(--sp-2); }
  .stat__icon { width: 34px; height: 34px; flex-basis: 34px; }
  .stat__value { font-size: var(--fs-xl); }
  .card__body { padding: var(--sp-4); }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

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

/* 18 ─ PRINT ────────────────────────────────────────────────────────────── */
@media print {
  :root { --bg: #fff; --bg-raised: #fff; --surface-line: #ccc; }
  .sidebar, .topbar, .bottomnav, .page__actions, .filters,
  .pagination, .no-print, .toast-stack, .btn { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .shell { display: block; }
  .page { padding: 0; }
  .card { border: 0; box-shadow: none; break-inside: avoid; }
  .table { font-size: 10pt; }
  .table thead th { background: #f0f0f0 !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
  .print-only { display: block !important; }
  @page { margin: 12mm; }
}
.print-only { display: none; }

/* 18b ─ TIMETABLE GRID, PROGRESS, SMALL CONTROLS ───────────────────────── */

.block { display: block; }

/* Progress meter — used for timetable completeness and fee collection. */
.progress {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--slate-100);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--primary);
  transition: width var(--dur) var(--ease);
}
.progress.is-full .progress__bar    { background: var(--accent); }
.progress.is-partial .progress__bar { background: var(--warn-500); }
.progress.is-empty .progress__bar   { background: var(--slate-300); }

/* A whole card that behaves as a link. */
.card--link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.card--link:hover,
.card--link:focus-visible {
  border-color: var(--primary);
  box-shadow: var(--sh-md);
  transform: translateY(-1px);
}

/* Compact form controls for inline table editing. */
.input--sm,
.select--sm {
  padding: .3rem .5rem;
  font-size: var(--fs-sm);
  min-height: 2rem;
}
.select--sm { padding-right: 1.6rem; background-size: 14px; }

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: .5rem;
}
.field--inline .field__label { margin: 0; white-space: nowrap; }

.filters__meta {
  margin-left: auto;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Fully ruled table, for grids where every cell is a data cell. */
.table--grid th,
.table--grid td { border: 1px solid var(--surface-line); }

/* Weekly timetable ----------------------------------------------------- */
.timetable { min-width: 46rem; }
.timetable__period-col {
  width: 7.5rem;
  background: var(--bg-sunken);
  text-align: left;
  font-weight: 600;
  vertical-align: middle;
}
.timetable__cell { padding: 2px; vertical-align: stretch; }
.timetable__break td { background: var(--bg-sunken); font-style: italic; }

.timetable__slot {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  min-height: 3.6rem;
  padding: .4rem .5rem;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--brand-050);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), outline-color var(--dur) var(--ease);
  outline: 2px solid transparent;
  outline-offset: -2px;
}
.timetable__slot:hover        { background: var(--brand-100); }
.timetable__slot:focus-visible { outline-color: var(--primary); }
.timetable__slot.is-free {
  background: transparent;
  color: var(--text-subtle);
  align-items: center;
  justify-content: center;
}
.timetable__slot.is-free:hover { background: var(--bg-hover); color: var(--primary); }

.timetable__free    { display: inline-flex; align-items: center; gap: .25rem; font-size: var(--fs-xs); }
.timetable__subject { font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; }
.timetable__teacher { font-size: var(--fs-xs); color: var(--text-muted); }
.timetable__room    { font-size: var(--fs-xs); color: var(--text-subtle); }

@media (max-width: 640px) {
  .timetable { min-width: 34rem; }
  .timetable__period-col { width: 5.5rem; }
}

/* Simple linked list inside a card (search results, side panels) -------- */
.listing { list-style: none; margin: 0; padding: 0; }
.listing__item + .listing__item { border-top: 1px solid var(--surface-line); }
.listing__link {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: .6rem .95rem;
  color: inherit;
  text-decoration: none;
}
.listing__link:hover { background: var(--bg-hover); }
.listing__title { font-weight: 600; font-size: var(--fs-sm); }
.listing__meta  { font-size: var(--fs-xs); color: var(--text-muted); }

/* Explanatory bullet list with a tick marker --------------------------- */
/* A row the model was unsure of — the review screen's whole point is that
   these are visible without hunting for them. */
tr.is-unsure > td { background: var(--warn-100); }
:root:not([data-theme="light"]) tr.is-unsure > td { background: rgba(214, 158, 46, .14); }
:root[data-theme="dark"] tr.is-unsure > td { background: rgba(214, 158, 46, .14); }

/* Public legal pages — read by a parent on a phone and by an app-store
   reviewer, neither of whom is signed in. Plain, wide-margined, printable. */
.legal { max-width: 44rem; margin: 0 auto; padding: var(--sp-8) var(--sp-5) var(--sp-10); }
.legal__brand { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 650;
  color: var(--text-strong); text-decoration: none; margin-bottom: var(--sp-6); }
.legal__head h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; margin: 0; }
.legal__meta { color: var(--text-muted); font-size: var(--fs-sm); margin: var(--sp-2) 0 var(--sp-6); }
.legal__body { line-height: 1.7; }
.legal__body h2 { font-size: var(--fs-lg); font-weight: 650; margin: var(--sp-6) 0 var(--sp-2); }
.legal__body p, .legal__body ul { margin: 0 0 var(--sp-3); }
.legal__body ul { padding-left: var(--sp-5); display: grid; gap: var(--sp-2); }
.legal__foot { margin-top: var(--sp-8); padding-top: var(--sp-4); border-top: 1px solid var(--surface-line);
  font-size: var(--fs-sm); color: var(--text-muted); }

/* Numbered steps — used where the order is the information (the setup
   assistant explaining what it does with a school's file). */
.list-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: var(--sp-2); }
.list-steps li { padding-left: .25rem; }

.list-check { list-style: none; margin: 0; padding: 0; }
.list-check li {
  position: relative;
  padding-left: 1.35rem;
  margin-bottom: .45rem;
  color: var(--text-muted);
}
.list-check li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: 700;
}
.list-check li:last-child { margin-bottom: 0; }

.text-accent { color: var(--accent); }

/* Support-ticket / comment thread -------------------------------------- */
.thread { display: flex; flex-direction: column; gap: .75rem; max-width: 52rem; }
.thread__item {
  padding: .75rem 1rem;
  border: 1px solid var(--surface-line);
  border-left: 3px solid var(--slate-300);
  border-radius: var(--r-md);
  background: var(--bg-raised);
}
.thread__item--mine {
  border-left-color: var(--primary);
  background: var(--primary-soft);
}
.thread__meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .35rem;
  font-size: var(--fs-sm);
}
.thread__body { line-height: 1.6; }

/* Small colour dot, for house / category legends ----------------------- */
.dot {
  display: inline-block;
  width: .6rem;
  height: .6rem;
  margin-right: .35rem;
  border-radius: var(--r-full);
  vertical-align: baseline;
}

/* Inline disclosure inside a table cell -------------------------------- */
.details-inline > summary {
  cursor: pointer;
  color: var(--primary);
  margin-top: .2rem;
}
.details-inline[open] > summary { margin-bottom: .2rem; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li + li { margin-top: .15rem; }

/* Requirement / health check rows -------------------------------------- */
.checklist { display: grid; gap: 1px; background: var(--surface-line); border-radius: var(--r-md); overflow: hidden; }
.checklist__row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: .75rem;
  align-items: start;
  padding: .6rem .85rem;
  background: var(--bg-raised);
}
.checklist__row.is-bad     { background: var(--danger-100); }
.checklist__row.is-warn    { background: var(--warn-100); }
.checklist__name { font-weight: 600; }
.checklist__note { font-size: var(--fs-xs); color: var(--text-muted); }
.checklist__value { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); }

/* Permission matrix ----------------------------------------------------- */
.matrix { min-width: 52rem; font-size: var(--fs-sm); }
.matrix th.matrix__role {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 8rem;
  white-space: nowrap;
  font-size: var(--fs-xs);
  padding: .4rem .2rem;
}
.matrix td { text-align: center; }
.matrix__module {
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.matrix__yes { color: var(--accent); font-weight: 700; }
.matrix__no  { color: var(--slate-300); }

/* Wizard step rail ------------------------------------------------------ */
.steps { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.steps__item {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .7rem;
  border: 1px solid var(--surface-line);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: var(--bg-raised);
}
.steps__item.is-current { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.steps__item.is-done    { border-color: var(--accent); color: var(--accent); }
.steps__num {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--r-full);
  background: var(--slate-100);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.steps__item.is-current .steps__num { background: var(--primary); color: #fff; }
.steps__item.is-done .steps__num    { background: var(--accent); color: #fff; }

/* 19 ─ DARK MODE ────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0d1520;
    --bg-raised:    #16202e;
    --bg-sunken:    #111a26;
    --bg-hover:     #1c2836;
    --surface-line: #253243;
    --text:         #e7edf4;
    --text-muted:   #9aabbf;
    --text-subtle:  #75879d;
    --primary-soft: #12304f;
    --sidebar-bg:   #0a121d;
    --sidebar-hover: #16202e;
    --slate-100:    #253243;
    --slate-050:    #1c2836;
    --slate-200:    #2e3d51;
    --slate-300:    #3d5069;
    --brand-050:    #101f33;
    --brand-100:    #14304e;
    --success-100:  #10301f;
    --danger-100:   #351714;
    --warn-100:     #33260a;
    --info-100:     #14304e;
    --accent-100:   #10301f;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .badge--success { color: #6ee7a5; }
  :root:not([data-theme="light"]) .badge--danger  { color: #fda29b; }
  :root:not([data-theme="light"]) .badge--warning { color: #fdd47e; }
  :root:not([data-theme="light"]) .badge--info    { color: #93c5fd; }
  :root:not([data-theme="light"]) .alert--success { color: #6ee7a5; }
  :root:not([data-theme="light"]) .alert--error   { color: #fda29b; }
  :root:not([data-theme="light"]) .alert--warning { color: #fdd47e; }
  :root:not([data-theme="light"]) .alert--info    { color: #93c5fd; }
  :root:not([data-theme="light"]) .avatar { background: #14304e; color: #93c5fd; }
  :root:not([data-theme="light"]) .select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aabbf' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  }
}

:root[data-theme="dark"] {
  --bg:           #0d1520;
  --bg-raised:    #16202e;
  --bg-sunken:    #111a26;
  --bg-hover:     #1c2836;
  --surface-line: #253243;
  --text:         #e7edf4;
  --text-muted:   #9aabbf;
  --text-subtle:  #75879d;
  --primary-soft: #12304f;
  --sidebar-bg:   #0a121d;
  --sidebar-hover: #16202e;
  --slate-100:    #253243;
  --slate-050:    #1c2836;
  --slate-200:    #2e3d51;
  --slate-300:    #3d5069;
  --brand-050:    #101f33;
  --brand-100:    #14304e;
  --success-100:  #10301f;
  --danger-100:   #351714;
  --warn-100:     #33260a;
  --info-100:     #14304e;
  --accent-100:   #10301f;
  color-scheme: dark;
}
:root[data-theme="dark"] .badge--success { color: #6ee7a5; }
:root[data-theme="dark"] .badge--danger  { color: #fda29b; }
:root[data-theme="dark"] .badge--warning { color: #fdd47e; }
:root[data-theme="dark"] .badge--info    { color: #93c5fd; }
:root[data-theme="dark"] .avatar { background: #14304e; color: #93c5fd; }
