/* =========================================================================
   AL-MAJEED INSTITUTE — STUDENT PORTAL
   Design system: "Native Cloud" v2, inherited from the public Institute site
   so the two read as one estate — white canvas, dark-navy chrome, a single
   three-stop gradient ribbon (orange → magenta → periwinkle) as the entire
   decorative language, uppercase mono eyebrows, sentence-case display sans,
   4px chrome. The "abstract" register comes from that ribbon: blurred field
   forms and arcs, never illustration.
   Type: Inter (400/500/600) + JetBrains Mono (400/500) for all numerals.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  color-scheme: light;

  /* --- surfaces --- */
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f6;
  --canvas-dark: #010120;
  --hairline: #ebebeb;
  --dark-hairline: #26263a;
  --dark-soft: #313641;

  /* --- text ---
     The public site sets body text at #999. That is a marketing-page choice and
     it measures 2.85:1 on white — under the WCAG AA 4.5:1 floor. Here --muted
     carries real information (stat labels, axis ticks, table meta), so it is
     darkened to clear AA. The lighter tone survives only as --muted-deco, for
     non-text ornament where contrast rules do not apply. */
  --ink: #000000;
  --ink-2: #55555f;
  --muted: #6e6e78;
  --muted-deco: #999999;
  --on-dark: #ffffff;
  --on-dark-body: rgba(255, 255, 255, 0.64);

  /* --- brand ribbon --- */
  --orange: #fc4c02;
  --magenta: #ef2cc1;
  --periwinkle: #bdbbff;
  --mint: #c8f6f9;
  --peach: #ffd9c7;
  --ribbon: linear-gradient(100deg, var(--orange), var(--magenta) 52%, var(--periwinkle));

  /* --- categorical series (validated: OKLCH band, chroma floor,
         Machado CVD ΔE 28.9 worst adjacent, all ≥3:1 on white) --- */
  --c1: #4a3aa7;
  --c2: #0e8f66;
  --c3: #fc4c02;
  --c4: #2a78d6;
  --c5: #a86a00;
  --c6: #ef2cc1;
  --c7: #0d7a2f;
  --c8: #cf5a86;

  /* --- status: reserved meaning, never reused as a series --- */
  --ok: #0b7a52;
  --ok-tint: #e6f4ee;
  --warn: #8a5a00;
  --warn-tint: #fdf1dd;
  --bad: #b42318;
  --bad-tint: #fdeceb;
  --info: #4a3aa7;
  --info-tint: #ecebff;

  /* --- type --- */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* --- radii / spacing --- */
  --r-xs: 3.25px;
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-full: 9999px;
  --rail: 244px;
  --gutter: 28px;

  /* --- motion --- */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.16);
}

[data-theme='dark'] {
  color-scheme: dark;
  --canvas: #0a0a26;
  --surface: #0f0f2e;
  --surface-2: #14143a;
  --surface-3: #1b1b45;
  --hairline: #26263a;
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, 0.72);
  --muted: rgba(255, 255, 255, 0.48);

  /* Dark steps are *chosen*, not flipped — revalidated against #0a0a26. */
  --c1: #8b82ea;
  --c2: #22a87f;
  --c3: #ea5f22;
  --c4: #4e8fd8;
  --c5: #b8842a;
  --c6: #db4fb6;
  --c7: #3a9a54;
  --c8: #d1708f;

  --ok: #35c496;
  --ok-tint: rgba(53, 196, 150, 0.14);
  --warn: #d9a13c;
  --warn-tint: rgba(217, 161, 60, 0.14);
  --bad: #f2705f;
  --bad-tint: rgba(242, 112, 95, 0.14);
  --info: #8b82ea;
  --info-tint: rgba(139, 130, 234, 0.14);

  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
}

/* =========================================================================
   Base
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.tnum { font-family: var(--mono); font-variant-numeric: tabular-nums; }

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

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

.skip-link {
  position: absolute; top: 8px; left: 8px; z-index: 200;
  padding: 10px 16px; background: var(--ink); color: var(--canvas);
  border-radius: var(--r-sm); transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus { transform: none; }

/* =========================================================================
   Shell
   ========================================================================= */

.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

/* --- rail (dark chrome) --- */

.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--canvas-dark); color: var(--on-dark);
  border-right: 1px solid var(--dark-hairline);
  overflow: hidden; z-index: 40;
}

/* the abstract field: the brand ribbon, blurred, drifting */
.rail::before {
  content: ''; position: absolute; inset: -30% -60% auto -60%; height: 62%;
  background: var(--ribbon); filter: blur(64px); opacity: 0.5;
  border-radius: var(--r-full); pointer-events: none;
  animation: drift 22s var(--ease-soft) infinite alternate;
}
.rail::after {
  content: ''; position: absolute; inset: auto -50% -24% -50%; height: 40%;
  background: radial-gradient(closest-side, var(--periwinkle), transparent);
  filter: blur(48px); opacity: 0.28; pointer-events: none;
}

@keyframes drift {
  from { transform: translate3d(-6%, -4%, 0) rotate(-6deg) scale(1); }
  to   { transform: translate3d(8%, 6%, 0) rotate(8deg) scale(1.14); }
}
@media (prefers-reduced-motion: reduce) {
  .rail::before { animation: none; }
}

.brand {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 22px var(--gutter) 18px;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: var(--ribbon); flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.brand-sub {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--on-dark-body);
}

.rail-nav { position: relative; flex: 1; overflow-y: auto; padding: 8px 12px 20px; }
.rail-group { margin-bottom: 18px; }
.rail-group-label {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.16em; color: rgba(255, 255, 255, 0.38);
  padding: 0 16px; margin-bottom: 6px;
}

.rail-link {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 16px; border-radius: var(--r-sm);
  color: var(--on-dark-body); font-size: 13px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.rail-link:hover { color: var(--on-dark); background: rgba(255, 255, 255, 0.06); }
.rail-link.is-active { color: var(--on-dark); background: rgba(255, 255, 255, 0.1); }
.rail-link.is-active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: var(--r-full); background: var(--ribbon);
}
.rail-link svg { width: 15px; height: 15px; flex: none; stroke-width: 1.6; }
.rail-badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  padding: 1px 6px; border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.12);
}
.rail-badge.is-alert { background: var(--orange); color: #fff; }

.rail-foot {
  position: relative; padding: 14px var(--gutter) 18px;
  border-top: 1px solid var(--dark-hairline);
  font-family: var(--mono); font-size: 10px; color: rgba(255, 255, 255, 0.4);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.rail-foot strong { color: var(--on-dark-body); font-weight: 400; }

/* The scrim only exists for the mobile drawer, but it is a child of .shell —
   so it must be taken out of flow at every width, or it claims a grid column
   and pushes .main onto a second row. */
.rail-scrim {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(1, 1, 32, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

/* --- main --- */

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 0 var(--gutter); height: 60px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--hairline);
}

.search {
  position: relative; flex: 1; max-width: 380px;
}
.search input {
  width: 100%; padding: 8px 12px 8px 34px;
  background: var(--surface-3); border: 1px solid transparent;
  border-radius: var(--r-sm); font-size: 13px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.search input:focus { outline: none; border-color: var(--c1); background: var(--surface); }
.search input::placeholder { color: var(--muted); }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); pointer-events: none;
}
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: var(--r-xs); padding: 1px 5px;
  background: var(--surface);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.term-chip {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-2);
  padding: 5px 10px; border: 1px solid var(--hairline); border-radius: var(--r-full);
}

/* Who is signed in — the portal should never be ambiguous about that. */
.user-chip {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  padding: 5px 10px; border-radius: var(--r-full); background: var(--surface-3);
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 15px; height: 15px; }

.page { flex: 1; padding: 30px var(--gutter) 72px; max-width: 1440px; width: 100%; }

/* =========================================================================
   Page furniture
   ========================================================================= */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 26px;
}
.eyebrow {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--muted); margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.eyebrow::before {
  content: ''; width: 16px; height: 2px; border-radius: var(--r-full);
  background: var(--ribbon);
}
.page-title {
  font-size: clamp(24px, 2.6vw, 32px); font-weight: 500;
  letter-spacing: -0.03em; line-height: 1.1;
}
.page-sub { color: var(--muted); margin-top: 6px; max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- buttons --- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-full);
  border: 1px solid var(--hairline); background: var(--surface);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease),
              background 0.18s var(--ease), opacity 0.18s var(--ease);
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 14px; height: 14px; }
.btn--primary { background: var(--ink); color: var(--canvas); border-color: var(--ink); }
.btn--primary:hover { opacity: 0.86; }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 34%, transparent); }
.btn--danger:hover { background: var(--bad-tint); border-color: var(--bad); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn--sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* --- cards --- */

.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 20px;
}
.card--flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-note { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--sidebar { grid-template-columns: 1.6fr 1fr; align-items: start; }
.stack { display: grid; gap: 16px; }

/* --- stat tiles: the headline number is the mark, no chart needed --- */

.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 18px;
}
.stat::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--ribbon); opacity: 0; transition: opacity 0.3s var(--ease);
}
.stat:hover::after { opacity: 1; }
.stat-label {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted);
}
.stat-value {
  font-family: var(--mono); font-size: 30px; font-weight: 500;
  letter-spacing: -0.03em; line-height: 1.1; margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.stat-value sup { font-size: 15px; margin-left: 1px; color: var(--muted); }
.stat-foot { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono); font-size: 11px; }
.stat-delta.is-up { color: var(--ok); }
.stat-delta.is-down { color: var(--bad); }

/* --- hero panel (dark, abstract) --- */

.hero {
  position: relative; overflow: hidden;
  background: var(--canvas-dark); color: var(--on-dark);
  border-radius: var(--r-md); padding: 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.hero::before {
  content: ''; position: absolute; inset: -60% -20% auto auto; width: 60%; height: 200%;
  background: var(--ribbon); filter: blur(70px); opacity: 0.42;
  border-radius: var(--r-full); pointer-events: none;
}
.hero-copy { position: relative; max-width: 46ch; }
.hero h2 { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; margin-bottom: 8px; }
.hero p { color: var(--on-dark-body); font-size: 13px; }
.hero-figure { position: relative; flex: none; }

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
/* Sticky to the top of .table-wrap, NOT the viewport. Because .table-wrap sets
   overflow-x, it is itself a scroll container, so a viewport offset here (e.g.
   the 60px topbar) would push the header down *inside* the box and float it
   over the first row instead of holding it to the top of the page. */
thead th {
  position: sticky; top: 0; z-index: 5;
  text-align: left; font-family: var(--mono); font-weight: 400;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--muted); padding: 11px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
thead th.is-sortable { cursor: pointer; user-select: none; }
thead th.is-sortable:hover { color: var(--ink); }
thead th .sort-caret { opacity: 0.4; margin-left: 4px; }
thead th[aria-sort] .sort-caret { opacity: 1; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: var(--r-full); flex: none;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  color: #fff; background: var(--ribbon); letter-spacing: 0.02em;
}
.who-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* --- chips --- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
}
.chip svg { width: 11px; height: 11px; }
.chip--ok { background: var(--ok-tint); color: var(--ok); }
.chip--warn { background: var(--warn-tint); color: var(--warn); }
.chip--bad { background: var(--bad-tint); color: var(--bad); }
.chip--info { background: var(--info-tint); color: var(--info); }
.chip--flat { background: var(--surface-3); color: var(--ink-2); }
.chip--outline { border-color: var(--hairline); color: var(--ink-2); }

/* the value bar inside a table cell */
.meter { display: flex; align-items: center; gap: 9px; justify-content: flex-end; }
.meter-track {
  width: 54px; height: 5px; border-radius: var(--r-full);
  background: var(--surface-3); overflow: hidden; flex: none;
}
.meter-fill {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--fill, var(--c1)); width: var(--w, 0%);
  transform-origin: left;
}

/* =========================================================================
   Charts
   ========================================================================= */

.chart { position: relative; }
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart--radar .chart-svg { max-width: 320px; margin: 0 auto; }
.chart-empty {
  color: var(--muted); font-size: 13px; text-align: center;
  padding: 34px 16px; border: 1px dashed var(--hairline); border-radius: var(--r-sm);
}
.c-grid { stroke: var(--hairline); stroke-width: 1; fill: none; }
.axis { font-family: var(--mono); font-size: 9px; fill: var(--muted); }
.crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hit { cursor: crosshair; }
.chart-line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); }

.chart-tip {
  position: fixed; top: 0; left: 0; z-index: 120; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 10px; border-radius: var(--r-sm);
  background: var(--canvas-dark); color: var(--on-dark);
  box-shadow: var(--shadow-md); opacity: 0;
  transition: opacity 0.14s var(--ease);
  white-space: nowrap;
}
.chart-tip.is-on { opacity: 1; }
.tip-k { font-size: 10px; color: var(--on-dark-body); font-family: var(--mono); }
.tip-v { font-size: 13px; font-weight: 500; font-family: var(--mono); }

/* --- bars --- */
.bars { display: grid; gap: 10px; }
.bar-row {
  display: grid; grid-template-columns: minmax(90px, 1fr) 2.2fr auto;
  align-items: center; gap: 12px; font-size: 12px;
}
.bar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: var(--r-sm); overflow: hidden; }
.bar-fill {
  display: block; height: 100%; width: var(--w); background: var(--fill);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.bar-value { color: var(--ink); font-size: 12px; min-width: 46px; text-align: right; }

/* --- gauge --- */
.gauge { position: relative; display: grid; place-items: center; }
.gauge-svg { width: 168px; height: 168px; }
.gauge-track { stroke: var(--surface-3); }
.gauge-inner {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; gap: 2px;
}
.gauge-value { font-family: var(--mono); font-size: 34px; font-weight: 500; letter-spacing: -0.03em; }
.gauge-label {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.13em; color: var(--muted);
}

/* --- heatmap --- */
.heat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(13px, 1fr));
  gap: 3px;
}
.heat-cell {
  aspect-ratio: 1; border-radius: 2px; background: var(--c);
  cursor: pointer; transition: transform 0.15s var(--ease);
}
.heat-cell:hover { transform: scale(1.25); }
.heat-cell.is-empty { background: var(--surface-3); }
.heat-legend {
  display: flex; align-items: center; gap: 3px; margin-top: 12px;
  justify-content: flex-end;
}
.heat-legend-label { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.heat-legend-label:first-child { margin-right: 4px; }
.heat-legend-label:last-child { margin-left: 4px; }
.heat-swatch { width: 11px; height: 11px; border-radius: 2px; background: var(--c); }

/* --- legend --- */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-2);
}
.legend-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--c); flex: none; }

/* =========================================================================
   Forms
   ========================================================================= */

.field { display: grid; gap: 6px; }
.field label, .label {
  font-family: var(--mono); font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.13em; color: var(--muted);
}
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  font-size: 13px; transition: border-color 0.18s var(--ease);
}
.input:focus { outline: none; border-color: var(--c1); box-shadow: 0 0 0 3px var(--info-tint); }
/* A control that cannot be used must look like it: the allotment table disables
   the role picker until a student is ticked. */
.input:disabled { opacity: 0.45; cursor: not-allowed; background: var(--surface-3); }
textarea.input { resize: vertical; min-height: 74px; }
input[type='checkbox'] { accent-color: var(--c1); width: 15px; height: 15px; cursor: pointer; }
.field-hint { font-size: 11px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* segmented status control */
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 4px 10px; border-radius: var(--r-xs);
  font-size: 11px; font-weight: 500; color: var(--muted);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
  display: inline-flex; align-items: center; gap: 5px;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button[aria-pressed='true'][data-status='present'] { color: var(--ok); }
.seg button[aria-pressed='true'][data-status='late'] { color: var(--warn); }
.seg button[aria-pressed='true'][data-status='absent'] { color: var(--bad); }
.seg button[aria-pressed='true'][data-status='excused'] { color: var(--info); }

/* 0–5 / 0–10 rating dots */
.rating { display: flex; align-items: center; gap: 4px; }
.rating button {
  width: 22px; height: 22px; border-radius: var(--r-xs); cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  transition: all 0.14s var(--ease);
}
.rating button:hover { border-color: var(--ink); color: var(--ink); }
.rating button.is-on { background: var(--c1); border-color: var(--c1); color: #fff; }
.rating-value { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 4px; }

/* =========================================================================
   Modal
   ========================================================================= */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(1, 1, 32, 0.42); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  opacity: 0; transition: opacity 0.22s var(--ease);
}
.modal-backdrop.is-in { opacity: 1; }
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); border: 1px solid var(--hairline);
  transform: translateY(12px) scale(0.99);
  transition: transform 0.28s var(--ease);
}
.modal--wide { width: min(880px, 100%); }
.modal-backdrop.is-in .modal { transform: none; }
.modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}
.modal-title { font-size: 16px; font-weight: 500; letter-spacing: -0.02em; }
.modal-body { padding: 22px; display: grid; gap: 16px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 22px; border-top: 1px solid var(--hairline);
  position: sticky; bottom: 0; background: var(--surface);
}

/* =========================================================================
   Toasts / empty / misc
   ========================================================================= */

#toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 150; display: grid; gap: 8px; justify-items: center;
}
.toast {
  padding: 9px 16px; border-radius: var(--r-full);
  background: var(--canvas-dark); color: var(--on-dark);
  font-size: 12px; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
  border-left: 2px solid var(--c2);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--bad { border-left-color: var(--orange); }
.toast--info { border-left-color: var(--periwinkle); }

.empty {
  display: grid; place-items: center; gap: 12px; text-align: center;
  padding: 56px 24px; border: 1px dashed var(--hairline); border-radius: var(--r-md);
  color: var(--muted);
}
.empty-mark {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--ribbon); opacity: 0.9;
}
.empty h3 { font-size: 15px; font-weight: 500; color: var(--ink); }
.empty p { max-width: 42ch; font-size: 13px; }

.divider { height: 1px; background: var(--hairline); border: 0; margin: 4px 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; align-self: center; }
.kv dd { margin: 0; }

.reveal { opacity: 0; }

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --gutter: 18px; }
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 260px;
    transform: translateX(-100%); transition: transform 0.32s var(--ease);
  }
  .rail.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .rail-scrim.is-on { opacity: 1; pointer-events: auto; }
  .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
  .grid--4 { grid-template-columns: 1fr; }
  .search kbd { display: none; }
  .term-chip, .user-chip { display: none; }
}

@media (min-width: 901px) { .rail-toggle { display: none; } }

/* =========================================================================
   Print — reports leave the building on paper
   ========================================================================= */

@media print {
  .rail, .topbar, .page-actions, .rail-scrim, .chart-tip, #toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .page { padding: 0; }
  .card, .stat { break-inside: avoid; border-color: #ddd; }
  body { background: #fff; }
  .hero { background: #fff; color: #000; border: 1px solid #ddd; }
  .hero::before { display: none; }
  .hero p { color: #555; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}
