/* ============================================================================
   SCHOOL MANAGEMENT PLATFORM — DESIGN SYSTEM
   ----------------------------------------------------------------------------
   Layer order (do not reorder):
     1. Tokens          6. Tables
     2. Base/reset      7. Forms
     3. Typography      8. Modules (dashboard, auth, portal, score entry)
     4. App shell/nav   9. Report sheets + print   <- print-tuned, do not restyle
     5. Components     10. Responsive / motion

   ONE authoritative :root lives in layer 1. Never add a second :root block —
   the previous stylesheet had three competing ones and the cascade decided the
   design by accident. Add new tokens to layer 1 instead.

   The report-sheet layer (9) is calibrated for A4 output at 9–10px type and is
   carried over verbatim, including its Poppins metrics, so printed result cards
   keep their exact pagination and column widths.
   ========================================================================== */

/* Fonts. Kept as an @import (not only a <link>) because ~20 entry points —
   login, portal, checker, installer, system_check — build their own <head>
   and link this stylesheet directly. The authenticated shell in
   app/views/layout/header.php also preconnects and links this exact URL, so
   the browser fetches it once and that path gets the parallel load.

   v2 design pass: one typeface (Poppins) everywhere, one accent colour used
   sparingly, hairline borders instead of shadows/gradients/glow. The goal is
   restraint — a senior product designer's dashboard reads as quiet and
   well-aligned, not as a showcase of effects. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* ============================================================================
   1. TOKENS
   ========================================================================== */
:root {
    color-scheme: dark;

    /* Brand — one accent, the school's existing deep green, lifted a step
       lighter than the light-theme value so it still reads as a strong
       accent against a near-black page instead of disappearing into it. */
    --brand-50:  #0e231c;
    --brand-100: #163329;
    --brand-200: #1f4e3f;
    --brand-300: #25614d;
    --brand-400: #2f7a61;
    --brand-500: #3f8768;
    --brand-600: #63a486;
    --brand-700: #92c3ab;
    --brand-800: #bcdccb;
    --brand-900: #dcefe4;
    --brand-950: #f1f8f4;

    /* Neutrals — inverted from the light scale: 25 is the darkest page
       background, 900 is the brightest text. Keep the same step count so
       every existing --gray-N reference stays meaningful on dark. */
    --gray-25:  #05070a;
    --gray-50:  #0a0d12;
    --gray-100: #10141b;
    --gray-200: #1c212b;
    --gray-300: #313844;
    --gray-400: #4b5362;
    --gray-500: #6b7380;
    --gray-600: #9aa3af;
    --gray-700: #d4d9df;
    --gray-800: #e6e9ed;
    --gray-900: #f2f4f6;

    /* Surface + text aliases (used throughout; keep these names stable) */
    --bg: var(--gray-25);
    --panel: #0f1319;
    --panel-soft: #141922;
    --line: var(--gray-200);
    --line-strong: var(--gray-300);
    --text: var(--gray-700);
    --text-strong: #ffffff;
    --muted: var(--gray-600);
    --muted-2: var(--gray-500);
    --accent: var(--brand-600);
    --accent-2: var(--brand-500);
    --accent-soft: rgba(99, 164, 134, .14);

    /* Semantic — translucent dark fills with a brighter text colour, so the
       same icon/label/weight cue from the light theme still reads clearly
       against a black panel instead of a pale chip turning harsh. */
    --success: rgba(16, 185, 129, .12);
    --success-line: rgba(16, 185, 129, .35);
    --success-text: #4ade80;
    --warn: rgba(245, 158, 11, .12);
    --warn-line: rgba(245, 158, 11, .35);
    --warn-text: #fbbf24;
    --error: rgba(239, 68, 68, .12);
    --error-line: rgba(239, 68, 68, .35);
    --error-text: #f87171;
    --danger: #f87171;
    --danger-soft: var(--error);
    --info: rgba(59, 130, 246, .12);
    --info-line: rgba(59, 130, 246, .35);
    --info-text: #93c5fd;

    /* Spacing — 4px base */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Radii — restrained; pills only for status */
    --radius-sm: 7px;
    --radius: 9px;
    --radius-lg: 11px;
    --radius-xl: 14px;
    --radius-pill: 999px;

    /* Elevation — hairline borders do almost all of the work; shadows are
       barely-there, used only to lift a floating element (dropdown, modal)
       off the page, never to decorate a static card. */
    --shadow-xs: 0 1px 2px rgba(16, 20, 27, .04);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 1px rgba(0, 0, 0, .3);
    --shadow: var(--shadow-sm);
    --shadow-soft: var(--shadow-xs);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-modal: 0 16px 40px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-brand: none;
    --focus: 0 0 0 3px rgba(99, 164, 134, .35);

    /* Glass / vibrancy — Apple's material language, used only for the
       navigation chrome (sidebar, topbar, the small popovers) that floats
       above the page, never for content cards/tables where it would fight
       legibility. Always paired with a hairline border, same as macOS. */
    --glass-bg: rgba(10, 13, 18, .72);
    --glass-bg-strong: rgba(10, 13, 18, .88);
    --glass-border: rgba(255, 255, 255, .08);
    --glass-blur: blur(20px) saturate(180%);

    /* Type — one family, used at every weight it needs */
    --font-ui: "Poppins", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: var(--font-ui);
    --font-report: Poppins, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* Layout */
    --sidebar-w: 248px;
    --content-max: 1360px;
    --form-max: 920px;
    --form-max-wide: 1100px;

    /* Motion */
    --ease: cubic-bezier(.2, 0, .2, 1);
    --speed: 150ms;
    --speed-slow: 260ms;

    /* Z-index */
    --z-sticky: 18;
    --z-overlay: 35;
    --z-sidebar: 40;
    --z-skip: 100;
}

/* ============================================================================
   2. BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

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

html { overflow-x: hidden; }

html, body {
    margin: 0;
    padding: 0;
    /* Last-resort guard: a stray wide element should scroll inside its own
       container (.table-wrap, a code block, etc.), never force the whole
       page to pan sideways on a phone. This lives on html only (it clips at
       the viewport). With overflow-x: hidden on body as well, body becomes
       its own scroll container and the sticky sidebar stops sticking, so it
       scrolls away with the page and cuts off at a random height. */
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
}

/* A very soft, fixed wash behind the whole app — just enough texture for
   the glass sidebar/topbar to actually have something to blur. Stays
   nearly invisible on its own; it only reads once something translucent
   sits on top of it. */
body {
    background-image:
        radial-gradient(900px 480px at 14% -6%, rgba(37, 97, 77, .05), transparent 60%),
        radial-gradient(760px 420px at 100% 0%, rgba(37, 97, 77, .035), transparent 55%);
    background-attachment: fixed;
}

body { min-width: 320px; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

img { max-width: 100%; }

a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; font-family: inherit; }

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

::selection { background: var(--brand-100); color: var(--brand-900); }

.skip-link {
    position: fixed; left: 16px; top: 12px; z-index: var(--z-skip);
    transform: translateY(-160%);
    padding: 10px 16px; border-radius: var(--radius);
    background: var(--accent); color: #fff; font-weight: 600;
    transition: transform var(--speed) var(--ease);
}
.skip-link:focus { transform: translateY(0); color: #fff; }

[hidden] { display: none !important; }

/* ============================================================================
   3. TYPOGRAPHY
   ========================================================================== */
h1, h2, h3, h4 { margin: 0 0 var(--space-3); color: var(--text-strong); font-weight: 600; letter-spacing: -.012em; }
h1 { font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -.016em; }
h2 { font-size: 16px; line-height: 1.4; font-weight: 600; }
h3 { font-size: 14px; line-height: 1.4; font-weight: 600; }
h4 { font-size: 13px; line-height: 1.45; font-weight: 600; }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

strong, b { font-weight: 600; color: var(--text-strong); }

small, .tiny { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.hr { height: 1px; background: var(--line); margin: var(--space-5) 0; border: 0; }
.u-mt-2 { margin-top: var(--space-2); }
.u-mt-3 { margin-top: var(--space-3); }
.u-mt-4 { margin-top: var(--space-4); }
.u-mb-3 { margin-bottom: var(--space-3); }
.u-mb-4 { margin-bottom: var(--space-4); }
.note-box + .note-box { margin-top: var(--space-3); }
.form-inline { display: inline; }
.avatar-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }

/* Data label — the small uppercase caption above a value */
.eyebrow, .stat-label, .nav-section-label, .task-card-kicker, .preview-order,
.score-context-grid .label, .summary-caption, .report-title {
    font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.eyebrow { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--accent-2); }

/* Numeric data reads in tabular figures so columns align */
td, .stat .number, .score-context-grid .value, .summary-table td, .kv > div:nth-child(even) {
    font-variant-numeric: tabular-nums;
}

/* ============================================================================
   4. APP SHELL + NAVIGATION
   ----------------------------------------------------------------------------
   Light, flat, quiet — a single hairline border separates the sidebar from
   the page instead of a shadow or a colour change. One accent colour marks
   the active item; nothing glows, nothing has a gradient.
   ========================================================================== */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start; background: var(--bg); }

.sidebar {
    position: sticky; top: 0; z-index: 20;
    display: flex; flex-direction: column; gap: var(--space-5);
    height: 100vh; padding: var(--space-4) var(--space-3);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    overflow: hidden;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .sidebar { background: var(--panel); }
}

.brand { display: flex; gap: 10px; align-items: center; padding: var(--space-2) var(--space-2) var(--space-4); }
.brand strong { display: block; max-width: 168px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.brand span { display: block; font-size: 11.5px; color: var(--muted); }
.brand-mark { width: 30px; height: 30px; flex: 0 0 auto; border-radius: var(--radius-sm); background: var(--accent); }
.brand-logo { width: 30px; height: 30px; flex: 0 0 auto; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); }

.nav {
    display: grid; gap: var(--space-5); align-content: start;
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    padding-right: 4px; margin-right: -4px;
    scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-pill); }
.nav::-webkit-scrollbar-track { background: transparent; }

.nav-section { display: grid; gap: 1px; }

.nav-section-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; margin: 0; padding: 6px 10px 6px 12px;
    border: 0; border-radius: var(--radius-sm); background: transparent;
    cursor: pointer; appearance: none; font: inherit;
    transition: background var(--speed) var(--ease);
}
.nav-section-toggle:hover { background: var(--gray-100); }
.nav-section-toggle:hover .nav-section-label { color: var(--gray-600); }
.nav-section-label { padding: 0; color: var(--muted-2); transition: color var(--speed) var(--ease); }
.nav-section-chevron {
    flex: 0 0 auto; width: 12px; height: 12px; color: var(--muted-2);
    transform: rotate(-90deg); transition: transform var(--speed) var(--ease);
}
.nav-section-toggle[aria-expanded="true"] .nav-section-chevron { transform: rotate(0deg); }

.nav-links { display: grid; gap: 1px; padding-top: 2px; }

.nav a {
    position: relative;
    display: flex; align-items: center; gap: 9px; min-height: 33px;
    padding: 0 10px 0 12px; border-radius: var(--radius-sm);
    color: var(--gray-600); font-size: 13.25px; font-weight: 500;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.nav-icon { flex: 0 0 auto; width: 16px; height: 16px; color: var(--gray-400); }
.nav a:hover { background: var(--gray-100); color: var(--text-strong); }
.nav a:hover .nav-icon { color: var(--gray-600); }
.nav a.active, .nav a[aria-current="page"] {
    background: var(--accent-soft); color: var(--brand-800); font-weight: 600;
}
.nav a.active .nav-icon, .nav a[aria-current="page"] .nav-icon { color: var(--accent); }
.nav a.active::before, .nav a[aria-current="page"]::before {
    content: ''; position: absolute; left: 0; top: 7px; bottom: 7px;
    width: 2px; border-radius: var(--radius-pill); background: var(--accent);
}

/* Search/Notifications/Setup shortcuts, duplicated here for the phone nav
   tray. They stay hidden at every other width — the topbar's own icon
   toolbar already covers them there — and only appear once the 760px
   breakpoint below strips the topbar down to just the menu button and the
   user menu, so the two never show the same shortcuts at once. */
.sidebar-quick-links { display: none; flex-direction: column; gap: 1px; padding-bottom: var(--space-3); margin-bottom: var(--space-2); border-bottom: 1px solid var(--line); }
.sidebar-quick-link {
    position: relative;
    display: flex; align-items: center; gap: 9px; min-height: 33px;
    padding: 0 10px 0 12px; border-radius: var(--radius-sm);
    color: var(--gray-600); font-size: 13.25px; font-weight: 500;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.sidebar-quick-link:hover { background: var(--gray-100); color: var(--text-strong); }
.sidebar-quick-link .badge-dot { margin-left: auto; }

/* min-width: 0 overrides the grid item's default min-width: auto — without
   it, one wide descendant (an unwrapped table, a long admission number) sets
   the floor for this whole column and forces the page to scroll sideways on
   a phone instead of letting .table-wrap's own overflow:auto handle it. */
.main { width: 100%; min-width: 0; max-width: var(--content-max); margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-10); }

/* Every top-level block on a page gets consistent breathing room below it,
   full stop — not just the ones that happen to be .card. Relying on .card's
   own margin-bottom meant a plain layout section (e.g. a stats .grid with
   no card class of its own) had zero space below it and visually fused
   with whatever came next. This is the single rule that guarantees two
   top-level blocks never touch, regardless of what either one is. */
.main > * { margin-bottom: var(--space-5); }
.main > *:last-child { margin-bottom: 0; }

.topbar {
    position: sticky; top: 0; z-index: var(--z-sticky);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: var(--space-3) var(--space-4); row-gap: 10px;
    margin: calc(var(--space-6) * -1) calc(var(--space-8) * -1) var(--space-6);
    padding: var(--space-3) var(--space-8);
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .topbar { background: rgba(255, 255, 255, .97); }
}
/* Title keeps its natural width and never gets squeezed; if there isn't
   room for both on one line, .topbar-tools (not the title) is the one that
   wraps to its own row — see the flex-wrap above. Without this, a narrow
   viewport used to crush both into two tight columns that each wrapped
   their own contents, which read as broken rather than responsive. */
.topbar-title { flex: 0 1 auto; min-width: 0; }
.topbar h1 { margin-bottom: 2px; font-size: 18px; }
.topbar-title p { margin-bottom: 0; font-size: 12px; }
.topbar-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.topbar-tools .btn { white-space: nowrap; }
.topbar-divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }

/* Icon-only utility buttons — Search/Notifications/Setup. A professional
   topbar treats page navigation (text labels, in the sidebar) and topbar
   utilities (icon buttons, here) as two different things; keeping these as
   full text buttons was most of why the toolbar needed two rows at
   ordinary laptop widths in the first place. */
.icon-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex: 0 0 auto;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--panel); color: var(--gray-600); cursor: pointer;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.icon-btn:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--text-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .badge-dot {
    position: absolute; top: -5px; right: -5px;
    min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px;
    border: 1.5px solid var(--panel);
}

.menu-toggle {
    display: none; align-items: center; gap: 7px; min-height: 36px; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--panel); color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.menu-toggle:hover { background: var(--gray-50); border-color: var(--gray-400); }
.menu-toggle svg { width: 16px; height: 16px; flex: 0 0 auto; }
.sidebar-overlay, .sidebar-close { display: none; }

/* --- Top-right user menu --------------------------------------------------
   Replaces the old sidebar-footer profile block. A single trigger button
   (avatar + name + chevron) opens a small, borderless-feeling dropdown
   anchored to the top-right — the same pattern as Linear/Notion/Vercel. */
.user-menu { position: relative; }
.user-menu-trigger {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: var(--radius-pill);
    background: transparent; cursor: pointer;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.user-menu-trigger:hover, .user-menu[data-open="true"] .user-menu-trigger { background: var(--gray-100); border-color: var(--line); }
.user-menu-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-menu-name strong { font-size: 12.5px; font-weight: 600; color: var(--text-strong); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-name span { font-size: 11px; color: var(--muted); }
.user-menu-chevron { width: 14px; height: 14px; color: var(--muted); flex: 0 0 auto; transition: transform var(--speed) var(--ease); }
.user-menu[data-open="true"] .user-menu-chevron { transform: rotate(180deg); }
.avatar-chip {
    flex: 0 0 auto; width: 28px; height: 28px; border-radius: var(--radius-pill);
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--brand-800);
    font-weight: 600; font-size: 12px; letter-spacing: .01em;
}

.user-menu-panel {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
    min-width: 220px; padding: 6px;
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .user-menu-panel { background: var(--panel); }
}
.user-menu-panel[hidden] { display: none; }
.user-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-menu-head strong { display: block; font-size: 13px; color: var(--text-strong); }
.user-menu-head span { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.user-menu-item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font-size: 13px; font-weight: 500;
    text-align: left; cursor: pointer;
}
.user-menu-item svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; }
.user-menu-item:hover { background: var(--gray-100); color: var(--text-strong); }
.user-menu-item.danger { color: var(--danger); }
.user-menu-item.danger svg { color: var(--danger); }
.user-menu-item.danger:hover { background: var(--error); }
.user-menu form { margin: 0; }

/* ============================================================================
   5. COMPONENTS
   ========================================================================== */

/* --- Surfaces ------------------------------------------------------------ */
.card, .form-card, .stat, .report-card, .auth-card, .public-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card, .form-card, .report-card { padding: var(--space-5); margin-bottom: var(--space-5); }
.card { transition: box-shadow var(--speed-slow) var(--ease), border-color var(--speed-slow) var(--ease); }

.page-hero, .hero-card {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--space-5); flex-wrap: wrap;
}
.hero-card {
    position: relative;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: var(--space-5); margin-bottom: var(--space-5); box-shadow: var(--shadow-sm);
}
.hero-copy { max-width: 720px; }
.hero-actions, .toolbar-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.section-head h2 { margin-bottom: 2px; }
.section-head p { margin-bottom: 0; }
.section-head-stack { align-items: flex-start; }
.section-anchor { position: relative; top: -16px; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: var(--space-2) var(--space-4); }
.kv > div:nth-child(odd) { color: var(--muted); }

/* --- Stats ------------------------------------------------------------- */
.stat {
    position: relative; display: grid; gap: 5px; align-content: start;
    padding: var(--space-4);
}
.stat-modern, .dashboard-summary-grid .stat { min-height: 88px; }
.stat-label { color: var(--muted); }
.stat .number { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -.015em; color: var(--text-strong); }
.compact-stats .stat { padding: var(--space-3) var(--space-4); }

/* --- Buttons -------------------------------------------------------------
   Flat fills, one accent colour, no gradients or motion beyond a quiet
   colour shift on hover — the primary action should look confident, not
   loud. */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 38px; padding: 8px 16px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: var(--accent); color: #fff;
    font-size: 13.5px; font-weight: 500; line-height: 1.2; cursor: pointer;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.btn:hover { background: var(--brand-800); color: #fff; }
.btn:active { background: var(--brand-900); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn-light { background: var(--panel); color: var(--gray-700); border-color: var(--line-strong); }
.btn-light:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--text-strong); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; color: #fff; }

.btn-gold { background: var(--warn-text); color: #fff; }
.btn-gold:hover { background: #8a3906; color: #fff; }

.btn-ghost { background: transparent; color: var(--accent-2); border-color: transparent; }
.btn-ghost:hover { background: var(--accent-soft); color: var(--brand-800); }

.btn-small { min-height: 30px; padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-sm); }

.actions, .row-actions, .bulk-toolbar, .module-toolbar {
    display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
}
.actions { margin-top: var(--space-3); }
.row-actions form, .actions form { margin: 0; }
.bulk-toolbar { margin: 0 0 var(--space-3); }
.bulk-toolbar select { width: auto; min-width: 180px; }
.module-toolbar { align-items: end; margin-bottom: var(--space-3); }

/* Submitting state — app.js sets data-submitting on enhanced forms */
[data-submitting="1"] { cursor: progress; }
[data-submitting="1"] .btn { pointer-events: none; opacity: .6; }

/* --- Status vocabulary ---------------------------------------------------- */
.badge, .pill, .status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    border: 1px solid var(--line); background: var(--gray-100); color: var(--gray-700);
    font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.status-badge { text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }

.pill-success, .status-badge.good { background: var(--success); border-color: var(--success-line); color: var(--success-text); }
.pill-warn, .status-badge.warn { background: var(--warn); border-color: var(--warn-line); color: var(--warn-text); }
.pill-danger, .status-badge.bad { background: var(--error); border-color: var(--error-line); color: var(--error-text); }
.pill-info { background: var(--info); border-color: var(--info-line); color: var(--info-text); }
.pill-gold { background: var(--warn); border-color: var(--warn-line); color: var(--warn-text); }
.pill-brand { background: var(--accent-soft); border-color: var(--brand-300); color: var(--brand-800); }

.badge-dot {
    min-width: 18px; height: 18px; padding: 0 5px;
    display: inline-grid; place-items: center; border-radius: var(--radius-pill);
    background: var(--danger); color: #fff; font-size: 11px; font-weight: 600;
}

/* --- Alerts -------------------------------------------------------------- */
.alert {
    display: flex; gap: var(--space-2);
    padding: 12px 14px; margin-bottom: var(--space-4);
    border: 1px solid transparent; border-radius: var(--radius);
    font-weight: 500;
}
.alert::before { font-weight: 700; }
.alert-success { background: var(--success); border-color: var(--success-line); color: var(--success-text); }
.alert-success::before { content: '\2713'; }
.alert-error { background: var(--error); border-color: var(--error-line); color: var(--error-text); }
.alert-error::before { content: '!'; }
.alert-warn { background: var(--warn); border-color: var(--warn-line); color: var(--warn-text); }
.alert-warn::before { content: '!'; }

/* --- Empty / note / guidance --------------------------------------------- */
.empty-state {
    display: block; padding: var(--space-5);
    border: 1px dashed var(--line-strong); border-radius: var(--radius);
    background: var(--panel-soft); color: var(--muted);
}
.empty-state-lg { padding: var(--space-8); text-align: center; }
.empty-state-lg strong { display: block; margin-bottom: var(--space-1); color: var(--text-strong); font-size: 16px; }

.note-box { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft); }
.minimal-list { margin: 0; padding-left: 18px; display: grid; gap: var(--space-2); }
.minimal-list li { margin: 0; }

.guide-box {
    display: flex; gap: var(--space-3); align-items: flex-start;
    margin: 0 0 var(--space-4); padding: var(--space-4);
    border: 1px solid var(--info-line); border-radius: var(--radius);
    background: var(--info); color: var(--info-text);
}
.guide-box strong { display: block; margin-bottom: var(--space-1); color: var(--info-text); font-size: 14px; }
.guide-box ol { margin: 0 0 0 18px; padding: 0; }
.guide-box li { margin: 3px 0; }
.guide-icon {
    flex: 0 0 26px; width: 26px; height: 26px; border-radius: var(--radius-pill);
    display: grid; place-items: center;
    background: var(--info-line); color: var(--info-text); font-weight: 700; font-size: 13px;
}

/* --- Progress / checklist / timeline -------------------------------------- */
.progress-track { height: 8px; border-radius: var(--radius-pill); background: var(--gray-200); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--radius-pill); background: var(--accent); }

.checklist { display: grid; gap: var(--space-2); }
.checklist-item {
    display: flex; align-items: flex-start; gap: var(--space-3);
    padding: var(--space-3) var(--space-4); border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--panel);
}
.check-dot {
    width: 20px; height: 20px; flex: 0 0 auto; border-radius: var(--radius-pill);
    display: grid; place-items: center;
    background: var(--gray-100); color: var(--muted); font-size: 11px; font-weight: 700;
}
.checklist-item.done .check-dot { background: var(--success); color: var(--success-text); }

.timeline { display: grid; gap: var(--space-2); }
.timeline-item {
    position: relative; padding: var(--space-3) var(--space-4) var(--space-3) 36px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.timeline-item::before {
    content: ''; position: absolute; left: 15px; top: 19px;
    width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--accent);
}

/* --- Task / quick action / feature cards ---------------------------------- */
.dashboard-quickstart { margin-bottom: var(--space-5); }
.dashboard-action-grid, .quick-action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }

.task-card, .quick-action, .feature-card {
    display: grid; gap: var(--space-2); padding: var(--space-4);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.task-card:hover, .quick-action:hover, .feature-card:hover { border-color: var(--line-strong); background: var(--gray-50); }
.task-card-kicker { display: inline-flex; color: var(--muted); font-weight: 600; }
.feature-card strong { font-size: 14.5px; }
.dashboard-pill-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Icon chip — small neutral square used ahead of a stat/task label so a
   metric reads with an at-a-glance cue instead of plain text alone. Flat
   grey by default; the one accent colour is reserved for the active/primary
   signal elsewhere, not spent decorating every chip. */
.icon-chip {
    display: inline-grid; place-items: center; flex: 0 0 auto;
    width: 32px; height: 32px; border-radius: var(--radius-sm); margin-bottom: 2px;
    background: var(--gray-100); color: var(--gray-600);
}
.icon-chip svg { width: 16px; height: 16px; }

/* --- Chips / selectable cards --------------------------------------------- */
.class-chip-scroll { display: flex; gap: var(--space-2); overflow-x: auto; padding: 2px 2px var(--space-3); margin-bottom: var(--space-4); scrollbar-width: thin; }
.class-chip {
    flex: 0 0 auto; min-width: 132px; display: grid; gap: 2px;
    padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
    box-shadow: var(--shadow-xs);
}
.class-chip span { font-weight: 600; color: var(--text-strong); }
.class-chip small { color: var(--muted); }
.class-chip:hover { border-color: var(--line-strong); background: var(--gray-50); }
.class-chip.active { border-color: var(--brand-300); background: var(--brand-50); color: var(--brand-800); box-shadow: var(--shadow-sm); }

.checkbox-list, .checkbox-card-list { display: grid; gap: var(--space-2); }
.checkbox-card, .subject-check-card {
    position: relative;
    display: flex; gap: var(--space-3); align-items: flex-start;
    padding: var(--space-3); border: 1.5px solid var(--line); border-radius: var(--radius);
    background: var(--panel); cursor: pointer;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.checkbox-card:hover, .subject-check-card:hover { border-color: var(--line-strong); background: var(--gray-50); }
.checkbox-card:has(input:checked), .subject-check-card:has(input:checked) {
    border-color: var(--brand-400); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand-400) inset;
}
.checkbox-card:has(input:checked)::after, .subject-check-card:has(input:checked)::after {
    content: '\2713'; position: absolute; top: 8px; right: 8px;
    width: 18px; height: 18px; border-radius: var(--radius-pill);
    background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center; line-height: 1;
}
.checkbox-card input, .subject-check-card input { margin-top: 3px; flex: 0 0 auto; }
.checkbox-card span, .subject-check-copy { display: grid; gap: 2px; min-width: 0; }
.checkbox-card small, .subject-check-copy small { color: var(--muted); }
.subject-check-copy strong { line-height: 1.3; }
.subject-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-2); }
.subject-category { display: grid; gap: var(--space-2); }
.subject-category-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-1); }
.subject-category-head h3 { margin: 0; font-size: 14.5px; }
.subject-manager { overflow: clip; }
.subject-picker-form { display: grid; gap: var(--space-4); }
.subject-toolbar { margin-bottom: 0; }
.subject-category[hidden], [data-filter-item][hidden], tr[hidden] { display: none !important; }
.copy-subjects-panel { margin-top: var(--space-4); padding: var(--space-4); border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-soft); }
.template-subject-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-2);
    max-height: 440px; overflow: auto; padding: 6px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}

/* --- Select toolbar ---------------------------------------------------------
   Reusable "search + select all/clear + live counter" bar for any long
   checkbox grid or table. Pair with data-filter-input / data-select-visible
   (already in app.js) and a [data-selection-count] element that app.js keeps
   in sync with however many checkboxes in scope are currently checked. */
.select-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
    margin-bottom: var(--space-3); padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft);
}
.select-toolbar .toolbar-search { flex: 1 1 220px; }
.select-toolbar-count {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--radius-pill);
    background: var(--accent-soft); color: var(--brand-800); font-size: 12.5px; font-weight: 700;
    white-space: nowrap;
}
.select-toolbar-count[data-selection-count="0"] { background: var(--gray-100); color: var(--muted); }

/* --- Marquee -------------------------------------------------------------
   A continuous horizontal strip for low-stakes, decorative content only
   (programme/feature highlights on the public landing page) — never for
   anything a visitor must actually read, since auto-scrolling text is a
   real accessibility problem for genuine announcements. Pauses on
   hover/focus so it's still inspectable, and pauses outright for
   prefers-reduced-motion. */
.marquee {
    overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--panel); box-shadow: var(--shadow-sm);
    padding: var(--space-3) 0;
    mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.marquee-track { display: flex; width: max-content; animation: marquee-scroll 26s linear infinite; }
.marquee:hover .marquee-track, .marquee:focus-within .marquee-track { animation-play-state: paused; }
@keyframes marquee-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.marquee-item {
    flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
    padding: 0 var(--space-6); white-space: nowrap;
    border-right: 1px solid var(--line); color: var(--gray-600); font-weight: 600; font-size: 13.5px;
}
.marquee-item .icon-chip { width: 26px; height: 26px; margin-bottom: 0; }
.marquee-item .icon-chip svg { width: 14px; height: 14px; }
@media (prefers-reduced-motion: reduce) {
    .marquee-track { animation: none; flex-wrap: wrap; width: 100%; }
    .marquee { overflow: visible; mask-image: none; }
}

/* --- Sticky action bar ---------------------------------------------------- */
/* A sticky bar does not reserve space — it just floats over whatever is
   still scrolled underneath it. Paired with a potentially long checkbox
   list (a school's full subject catalogue can easily be 30-40 rows), that
   meant the bar silently covered rows the user still needed to tick,
   leaving only a thin sliver of each row's top edge peeking out from
   behind it. The fix is for the list to scroll inside its own bounded box
   instead of the whole page scrolling past it — the sticky bar then always
   sits below that box, never over it. */
.subject-categories-scroll {
    max-height: 56vh; overflow-y: auto; padding-right: 6px; margin-right: -6px;
    scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent;
}
.subject-categories-scroll::-webkit-scrollbar { width: 8px; }
.subject-categories-scroll::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-pill); }

/* Deliberately NOT position:sticky. It looks appealing ("save button always
   visible while scrolling a long list") but the math for when a sticky
   element overlaps earlier content in a tall container is unreliable in
   practice — it can cover real, still-needed checkbox rows with no visual
   warning, which is worse than just asking the user to scroll a little
   further to reach Save. The checkbox list above this bar already scrolls
   inside its own bounded box (.subject-categories-scroll), so Save sits
   directly below it, always fully visible, never on top of anything. */
.sticky-action-bar {
    display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
    margin-top: var(--space-4); padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--panel-soft);
}
.sticky-action-bar small { display: block; }

/* --- Tabs / search results ------------------------------------------------ */
.settings-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0 var(--space-4); }
.settings-tabs .pill { background: var(--panel); border-color: var(--line-strong); }
.settings-tabs .pill:hover { background: var(--gray-50); color: var(--text-strong); }
.settings-tabs .pill.active { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-800); }

.search-results { display: grid; gap: var(--space-3); }
.result-group { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); overflow: hidden; }
.result-group h3 { margin: 0; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); background: var(--gray-50); font-size: 13px; }
.result-item { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.result-item:last-child { border-bottom: 0; }
.result-item:hover { background: var(--gray-25); }

.mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }

/* ============================================================================
   6. TABLES
   ========================================================================== */
.table-wrap {
    width: 100%; overflow: auto;
    border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--panel); box-shadow: var(--shadow-xs);
}
table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13.5px; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
    position: sticky; top: 0; z-index: 1;
    background: var(--gray-50); color: var(--muted);
    font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    white-space: nowrap; box-shadow: inset 0 -1px 0 var(--line-strong);
}
td { color: var(--gray-700); }
tbody tr { transition: background var(--speed) var(--ease); }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:has(input[type="checkbox"]:checked) { background: var(--brand-50); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap, th.wrap { white-space: normal; }
/* Cards that open with a heading get a quiet divider so title and body read as two parts. */
.card > .section-head { padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); }
.card .table-wrap, .form-card .table-wrap { margin-top: var(--space-3); }
td .row-actions { flex-wrap: nowrap; }
@media screen and (max-width: 760px) {
    th, td { padding: 10px 12px; }
}
.check-cell { width: 42px; text-align: center; }
.check-cell input { margin: 0; }
.score-cell { text-align: center; }

/* ============================================================================
   7. FORMS
   ========================================================================== */
label { display: block; margin: 0 0 6px; color: var(--gray-700); font-size: 13px; font-weight: 500; }

input, select, textarea {
    width: 100%; min-height: 38px; padding: 8px 11px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--gray-50); color: var(--text); font-size: 13.5px;
    outline: none;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--gray-400); }
input:focus, select:focus, textarea:focus { background: var(--panel); border-color: var(--accent-2); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--gray-100); color: var(--muted); cursor: not-allowed; }
input[readonly], textarea[readonly] { background: var(--gray-50); }
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
select[multiple] { min-height: 160px; padding: var(--space-2); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent-2); }
input:invalid:not(:placeholder-shown), select:invalid, textarea:invalid:not(:placeholder-shown) { border-color: var(--error-line); }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.form-row-1 { grid-template-columns: minmax(0, 1fr); }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.form-row-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.form-grid-tight { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.field-hint { margin-top: 5px; font-size: 12px; color: var(--muted); }
.field-error { margin-top: 5px; font-size: 12px; color: var(--error-text); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error-line); }

.inline-check, .toggle-row { display: inline-flex; gap: var(--space-2); align-items: center; font-weight: 500; color: var(--gray-700); }
.toggle-row { min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-soft); }
/* Sits inline inside a toolbar; goes full width only when the toolbar stacks. */
.toolbar-search { flex: 0 1 240px; width: auto; min-width: 0; }

/* Plain wrapper divs inside forms (label + control) get consistent rhythm. */
.form-card form > div:not([class]), .card form > div:not([class]), .field { margin-bottom: var(--space-4); }
.form-card h2 + .muted, .card h2 + .muted { margin-top: 2px; margin-bottom: var(--space-4); }

/* --- File inputs (every upload in the app) -------------------------------
   Native inputs keep working and stay accessible; only the look changes. */
input[type="file"] {
    padding: 6px; background: var(--panel); cursor: pointer;
    border: 1px dashed var(--line-strong); color: var(--muted);
}
input[type="file"]:hover { border-color: var(--accent-2); background: var(--accent-soft); }
input[type="file"]::file-selector-button {
    margin-right: var(--space-3); padding: 6px 14px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--gray-50); color: var(--gray-700);
    font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
    transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--gray-100); border-color: var(--gray-400); }

/* --- Drop zone ------------------------------------------------------------ */
.dropzone {
    position: relative; display: grid; justify-items: center; gap: var(--space-1);
    margin: 0; padding: var(--space-6) var(--space-4); text-align: center;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
    background: var(--panel-soft); cursor: pointer;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent-2); background: var(--accent-soft); }
.dropzone.is-dragover { box-shadow: var(--focus); }
.dropzone:focus-within { border-color: var(--accent-2); box-shadow: var(--focus); }
.dropzone.has-file { border-style: solid; border-color: var(--brand-300); background: var(--accent-soft); }
.dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.dropzone-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--space-1); border-radius: var(--radius-pill); background: var(--panel); border: 1px solid var(--line); color: var(--accent-2); }
.dropzone-icon svg { width: 20px; height: 20px; }
.dropzone-title { color: var(--text-strong); font-weight: 500; }
.dropzone-link { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.dropzone-hint { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.dropzone-compact { grid-template-columns: auto 1fr; justify-items: start; text-align: left; column-gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.dropzone-compact .dropzone-icon { grid-row: span 2; margin: 0; }

/* --- Import preview ------------------------------------------------------- */
.import-preview { display: grid; gap: var(--space-3); margin-bottom: var(--space-4); }
.import-preview[hidden] { display: none; }
.import-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.import-preview-table { max-height: 340px; }
tr.is-skipped td { background: var(--error); }
.import-note { margin-top: 4px; font-size: 12px; color: var(--muted); white-space: normal; }
tr.is-skipped .import-note { color: var(--error-text); }

/* ============================================================================
   8. MODULES
   ========================================================================== */

/* --- Auth ------------------------------------------------------------------
   A quiet frosted-glass card over the same soft wash as the rest of the
   app — the macOS sign-in-window treatment: translucent, hairline edge,
   nothing else competing with the form. */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: var(--space-5);
    background: var(--bg);
}
.auth-brand-mark {
    margin: 0 auto var(--space-4); width: 40px; height: 40px;
    border-radius: var(--radius); display: grid; place-items: center;
    background: var(--accent);
}
.auth-brand-mark img { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius); }
.auth-card {
    width: 100%; max-width: 400px; padding: var(--space-6);
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-modal); border: 1px solid var(--glass-border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .auth-card { background: var(--panel); }
}
.auth-header-simple { display: grid; gap: var(--space-1); margin-bottom: var(--space-5); text-align: center; }
.auth-header-simple h2 { font-size: 17px; }
.auth-helper-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.auth-helper-links a, .tiny-link { color: var(--muted); font-size: 13px; }
.auth-helper-links a:hover, .tiny-link:hover { color: var(--accent); }
.compact-links { margin-top: 0; padding-top: 0; border-top: 0; }

/* Auth field icons + password show/hide toggle. The icon is purely
   functional (identifies the field type at a glance in a dense form);
   the toggle button is injected by app.js onto every password field
   inside [data-enhanced-form] so no page has to wire it up by hand. */
.field-icon-input { position: relative; display: block; width: 100%; }
.field-icon-input > svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--muted-2); pointer-events: none;
}
.field-icon-input > input { padding-left: 40px; }
.field-icon-input > .password-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px; display: grid; place-items: center;
    border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-sm);
    cursor: pointer;
}
.field-icon-input > .password-toggle:hover { color: var(--accent); background: var(--panel-soft); }
.field-icon-input > .password-toggle svg { width: 18px; height: 18px; }
.field-icon-input:has(.password-toggle) > input { padding-right: 38px; }
.otp-input { font-size: 20px; letter-spacing: 6px; font-weight: 600; text-align: center; }

/* Auth multi-step wizard (admission application). Progressive enhancement:
   every step renders visible by default so the form still works with JS
   off; app.js hides all but the active step and drives Next/Back. */
.wizard-steps { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: 0 0 var(--space-6); padding: 0; }
.wizard-steps li {
    display: flex; align-items: center; gap: var(--space-2);
    font-size: 13px; font-weight: 500; color: var(--muted);
}
.wizard-steps .wizard-step-num {
    width: 24px; height: 24px; border-radius: var(--radius-pill); display: grid; place-items: center;
    border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; color: var(--muted);
    background: var(--panel);
}
.wizard-steps li[data-state="active"] { color: var(--text-strong); }
.wizard-steps li[data-state="active"] .wizard-step-num { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wizard-steps li[data-state="done"] .wizard-step-num { border-color: var(--accent); color: #fff; background: var(--accent); }
.wizard-steps li[data-clickable="true"] { cursor: pointer; }
.wizard-steps-connector { flex: 1; min-width: 16px; height: 1px; background: var(--line); align-self: center; }
.wizard-step[hidden] { display: none; }
.wizard-controls { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-5); }
.wizard-controls .wizard-spacer { flex: 1; }

/* --- Public pages -------------------------------------------------------- */
.public-shell { min-height: 100vh; max-width: 1120px; margin: 0 auto; padding: var(--space-8) var(--space-5) var(--space-12); background: var(--bg); }
.public-hero { display: grid; gap: var(--space-4); margin-bottom: var(--space-6); }
.public-brand { display: flex; align-items: center; gap: var(--space-3); }
.public-brand-logo { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.public-brand-mark { width: 52px; height: 52px; border-radius: var(--radius); background: var(--accent); }
.public-hero-copy { max-width: 720px; }
.public-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.public-card { padding: var(--space-5); }
.public-card h3 { margin-bottom: 6px; }
.public-card-icon {
    width: 40px; height: 40px; margin-bottom: var(--space-3);
    display: inline-grid; place-items: center; border-radius: var(--radius);
    background: var(--brand-50); color: var(--accent); font-weight: 700;
}
.public-support-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }

/* --- Parent/student portal ------------------------------------------------ */
.portal-shell { max-width: 1320px; }
.portal-hero-card { padding: var(--space-5); }
.portal-hero-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.portal-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.portal-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.portal-summary-grid span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.portal-summary-grid strong { display: block; font-size: 15px; }
.portal-app-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.portal-form-card { position: sticky; top: 18px; }
.portal-empty-card { min-height: 420px; display: grid; align-content: start; gap: var(--space-3); }
.portal-placeholder-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.portal-shell.portal-view-compact .public-card { padding: var(--space-4); }
.portal-shell.portal-view-compact .portal-summary-grid { gap: var(--space-2); }

/* --- Score entry ---------------------------------------------------------- */
.score-context-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.score-context-grid .public-card { padding: var(--space-3) var(--space-4); }
.score-context-grid .label { color: var(--muted); }
.score-context-grid .value { margin-top: 3px; font-size: 15px; font-weight: 600; color: var(--text-strong); }
.score-template-details summary { cursor: pointer; font-weight: 600; color: var(--text-strong); }
.score-sheet-table-simple th, .score-sheet-table-simple td { vertical-align: middle; }
.score-sheet-table-simple th { white-space: nowrap; }
.score-sheet-table-simple input.score-input { min-width: 92px; text-align: center; }
.score-sheet-table-simple input.score-total { min-width: 88px; background: var(--gray-50); font-weight: 600; text-align: center; }
.score-sheet-table-wrap { max-height: none; }

/* --- Print centre / ID cards ---------------------------------------------- */
.print-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.id-card { min-height: 160px; padding: var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); }
.id-card .school { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 12px; }
.id-card .name { margin-top: var(--space-2); font-size: 18px; font-weight: 600; }
.id-card .qr-placeholder { margin-top: var(--space-3); padding: var(--space-2); border: 1px dashed var(--gray-400); border-radius: var(--radius-sm); text-align: center; font-size: 12px; color: var(--muted); }
.receipt-box { padding: var(--space-4); border: 1px dashed var(--gray-400); border-radius: var(--radius); background: var(--panel); }
.help-index { columns: 2 280px; }
.help-index .note-box { break-inside: avoid; margin: 0 0 var(--space-3); }

/* --- Report builder preview ----------------------------------------------- */
.report-builder-preview {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3);
    min-height: 220px; padding: var(--space-3);
    border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-soft);
}
.preview-block { display: flex; flex-direction: column; gap: 6px; min-height: 86px; padding: var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); }
.preview-block.preview-wide, .preview-block.preview-full { grid-column: 1 / -1; }
.preview-block.preview-hidden { opacity: .45; background: repeating-linear-gradient(135deg, var(--gray-50), var(--gray-50) 10px, var(--gray-100) 10px, var(--gray-100) 20px); }
.preview-order { color: var(--muted); }
.layout-compact .report-meta-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ============================================================================
   9. REPORT SHEETS + PRINT
   ----------------------------------------------------------------------------
   Calibrated for A4 result cards. Carried over unchanged, and pinned to the
   original Poppins metrics so column widths and pagination do not shift when
   the rest of the app moved to Source Sans 3.
   ========================================================================== */
.result-sheet, .midterm-report, .exam-term-report,
.result-sheet input, .result-sheet select, .result-sheet textarea { font-family: var(--font-report); }

/* This sheet is printed on white paper and stays light-on-dark-text no
   matter what theme the rest of the app is using (see .result-sheet's own
   background: #fff below) — but base rules like "strong, b { color:
   var(--text-strong) }" still win over an ancestor's inherited color, since
   a direct declaration on the element always beats inheritance. Pin every
   bold/label/value color used inside the sheet back to the same dark,
   print-safe tones the rest of this section already hardcodes, so labels
   never go invisible again if the app theme changes. */
.result-sheet strong, .result-sheet b,
.midterm-report strong, .midterm-report b,
.exam-term-report strong, .exam-term-report b { color: #0f172a; }
.result-sheet, .midterm-report, .exam-term-report { color: #1f2937; }

.report-card { position: relative; overflow: hidden; }
.report-head { display: flex; gap: 20px; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.report-brand { display: flex; gap: 14px; align-items: flex-start; }
.report-logo, .logo-thumb { width: 74px; height: 74px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.signature-preview { width: 160px; height: 74px; object-fit: contain; }
.report-title { color: var(--muted); letter-spacing: .12em; }
.report-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.report-meta-item { background: var(--gray-50); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.report-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.report-stats .stat { box-shadow: none; }
.report-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 22px; }
.signature-box { min-height: 84px; padding-top: 10px; border-top: 1px solid var(--line); }
.signature-box img { max-width: 180px; max-height: 60px; object-fit: contain; display: block; margin-bottom: 8px; }

.result-sheet { background: #fff; }
.sheet-toolbar { display: flex; justify-content: flex-end; padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid #e5e7eb; }
.midterm-report { border-radius: 10px; border: 1px solid #bcbcbc; padding: 12px; font-size: 12px; color: #1f2937; }
.midterm-report * { box-sizing: border-box; }
.sheet-header-block { border-bottom: 1px solid #bdbdbd; padding-bottom: 8px; margin-bottom: 8px; }
/* Logo and (optional) passport reserve equal-width side columns so the
   school name/motto lockup lands on the true center of the header instead
   of drifting toward whichever side has content. */
.sheet-brand { display: grid; grid-template-columns: minmax(70px, 110px) 1fr minmax(70px, 110px); align-items: center; gap: 14px; }
.sheet-brand .sheet-school-logo { grid-column: 1; justify-self: start; }
.sheet-school-logo { width: 102px; height: 102px; object-fit: contain; border-radius: 6px; border: 1px solid #c8c8c8; background: #fff; padding: 4px; }
.sheet-school-logo.placeholder, .sheet-passport.placeholder { display: grid; place-items: center; font-size: 11px; color: #6b7280; background: #f8fafc; }
.sheet-school-copy { grid-column: 2; text-align: center; }
.sheet-brand .sheet-passport-wrap.top { grid-column: 3; justify-self: end; }
.sheet-school-name { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: .02em; color: #c2158f; text-transform: uppercase; }
.sheet-school-subtext { font-size: 11px; line-height: 1.35; color: #374151; }
.sheet-main-title { text-align: center; font-weight: 700; font-size: 13px; margin-top: 6px; text-transform: uppercase; }
.sheet-meta, .sheet-meta-grid { border-bottom: 1px solid #cfcfcf; padding: 6px 0; }
.sheet-meta-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.sheet-meta-grid.has-passport { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 14px; align-items: start; }
.sheet-meta-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
.sheet-passport-wrap { display: flex; justify-content: flex-end; }
.sheet-passport { width: 72px; height: 90px; object-fit: cover; border: 1px solid #c7c7c7; border-radius: 3px; background: #fff; }
.sheet-attendance-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.midterm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 12px; margin-top: 8px; }
.midterm-section-title { font-weight: 700; font-size: 12px; text-transform: uppercase; margin: 6px 0; }
.midterm-table, .scale-table, .summary-table { width: 100%; border-collapse: collapse; }
.midterm-table th, .midterm-table td, .scale-table th, .scale-table td, .summary-table td { border: 1px solid #5a5a5a; padding: 5px 6px; font-size: 11px; vertical-align: middle; }
.midterm-table th, .scale-table th { background: #dcdcdc; text-transform: none; letter-spacing: 0; color: #0f1720; position: static; }
.midterm-table td:nth-child(2), .midterm-table td:nth-child(3), .midterm-table td:nth-child(5), .midterm-table th:nth-child(2), .midterm-table th:nth-child(3), .midterm-table th:nth-child(5), .scale-table td:nth-child(2), .scale-table th:nth-child(2) { text-align: center; }
.midterm-table .accent-row td { background: #c017a2; color: #fff; font-weight: 700; }
.sheet-summary-wrap { display: grid; grid-template-columns: 180px 1fr 1fr; gap: 14px; align-items: end; margin: 10px 0 8px; }
.summary-box { border: 1px solid #c9c9c9; }
.summary-title { background: #efefef; border-bottom: 1px solid #c9c9c9; padding: 6px 8px; font-weight: 700; font-size: 11px; }
.summary-table td:first-child { width: 65%; background: #fafafa; }
.summary-highlight { text-align: center; }
.summary-caption { font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; margin-bottom: 6px; }
.summary-score-badge { display: inline-block; min-width: 112px; padding: 10px 16px; border-radius: 10px; background: linear-gradient(180deg, #2db449 0%, #16832d 100%); color: #fff; font-size: 20px; font-weight: 800; box-shadow: inset 0 2px 0 rgba(255,255,255,.18); }
.summary-final-result { text-align: center; }
.summary-grade { display: inline-block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.summary-remark { display: inline-block; font-size: 14px; font-weight: 600; color: #374151; }
.sheet-domain-ratings { margin: 10px 0; }
.sheet-domain-ratings .midterm-table { margin-bottom: 10px; }
.sheet-official-tag { text-align: center; font-weight: 700; margin: 6px 0 8px; letter-spacing: .08em; }
.sheet-comments-box { border: 1px solid #8f8f8f; padding: 10px; }
.comment-text { color: #1d4ed8; font-style: italic; }
.sheet-comments-box > div { margin-bottom: 8px; }
.sheet-signatures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: end; margin-top: 18px; }
.signature-slot { text-align: center; }
.signature-slot.align-right { text-align: right; }
.signature-image { max-width: 140px; max-height: 48px; object-fit: contain; display: inline-block; margin-bottom: 4px; background: transparent !important; mix-blend-mode: multiply; }
.signature-line { border-top: 1px solid #444; margin-top: 28px; }
.signature-name { font-size: 11px; margin-top: 6px; }
.signature-role { font-weight: 700; margin-top: 4px; }
.report-policy-footer { margin-top: 8px; text-align: right; }
.report-school-footer { margin-top: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.report-watermark {
    position: absolute; inset: 50% auto auto 50%;
    width: min(360px, 55%); max-height: 360px; object-fit: contain;
    opacity: .055; transform: translate(-50%, -50%); pointer-events: none; z-index: 0;
}
.result-sheet > *:not(.report-watermark) { position: relative; z-index: 1; }
.stamp-image { max-width: 72px; max-height: 54px; object-fit: contain; display: inline-block; margin: 0 0 4px 8px; vertical-align: bottom; }

.exam-term-report { border-radius: 10px; border: 1px solid #bcbcbc; padding: 10px 11px; font-size: 11px; color: #1f2937; }
.exam-term-report * { box-sizing: border-box; }
.exam-term-report .sheet-header-block.compact { margin-bottom: 6px; padding-bottom: 6px; }
.exam-term-report .sheet-school-logo { width: 78px; height: 78px; }
.exam-term-report .sheet-school-name { font-size: 24px; }
.exam-term-report .sheet-school-subtext { font-size: 10px; }
.exam-term-report .sheet-main-title { margin-top: 4px; font-size: 12px; }
.exam-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 18px; }
.exam-meta-grid > div { white-space: nowrap; }
.exam-attendance-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.next-term-chip { display: inline-block; padding: 2px 6px; border-radius: 999px; background: #14532d; color: #fff; font-weight: 700; font-size: 10px; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 10px; margin-top: 7px; align-items: start; }
.exam-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.exam-table th, .exam-table td { border: 1px solid #555; padding: 3px 5px; font-size: 10px; line-height: 1.15; vertical-align: middle; }
.exam-table th { background: #dcdcdc; color: #0f1720; text-transform: none; letter-spacing: 0; position: static; }
.exam-table td:first-child, .exam-table th:first-child { width: 24%; }
.single-term-report .exam-table td:first-child, .single-term-report .exam-table th:first-child { width: 28%; }
.exam-table td:last-child, .exam-table th:last-child { width: 10%; text-align: center; }
.exam-table td:nth-last-child(2), .exam-table th:nth-last-child(2) { width: 6%; }
.exam-table .score-cell { text-align: center; }
.exam-table .emphasis { background: #0b8a1f; color: #fff; font-weight: 700; }
.exam-table .accent-row td { background: #c017a2; color: #fff; font-weight: 700; }
.compact-scale-table th, .compact-scale-table td { padding: 4px 5px; font-size: 10px; }
.compact-side-note { margin-top: 8px; padding: 10px 11px; border-radius: var(--radius); }
.compact-side-note p { margin-top: 6px; font-size: 11px; }
.exam-summary-wrap { margin: 8px 0 6px; grid-template-columns: 1.15fr .9fr .95fr; gap: 10px; }
.exam-summary-wrap.multi { grid-template-columns: 1.3fr .85fr .85fr; }
.exam-summary-wrap .summary-title { padding: 5px 8px; }
.exam-summary-wrap .summary-table td { padding: 4px 6px; font-size: 10px; }
.compact-comments-box { padding: 8px 10px; }
.compact-comments-box > div { margin-bottom: 5px; font-size: 11px; }
.compact-signatures { margin-top: 12px; gap: 18px; }
.compact-signatures .signature-line { margin-top: 20px; }
.long-subject-list .exam-table th, .long-subject-list .exam-table td { padding: 2px 4px; font-size: 9.2px; }
.long-subject-list .sheet-school-name { font-size: 22px; }
.long-subject-list .summary-score-badge { min-width: 104px; padding: 8px 12px; font-size: 18px; }

.compact-meta-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 18px; }
.compact-attendance-row { margin-top: 8px; }
.print-side-summary { margin-top: 10px; }
.better-comments-box { margin-top: 8px; }
.refined-print-table td, .refined-print-table th { font-size: 9.6px; }
.refined-print-table td:first-child, .refined-print-table th:first-child { width: 26%; }
.single-term-report .refined-print-table td:first-child, .single-term-report .refined-print-table th:first-child,
.second-term-report .refined-print-table td:first-child, .second-term-report .refined-print-table th:first-child { width: 34%; }
.with-summary-side { grid-template-columns: minmax(0, 1fr) 220px; }

.uniform-result-report { border-radius: 10px; }
.uniform-result-report .sheet-main-title { letter-spacing: .02em; }
.uniform-result-report .sheet-comments-box { border-radius: 10px; }
.uniform-result-report .summary-box { border-radius: 10px; overflow: hidden; }
.uniform-result-report .sheet-attendance-row,
.uniform-result-report .exam-attendance-row { align-items: center; }
.uniform-result-report .midterm-layout.exam-layout { grid-template-columns: minmax(0, 1fr) 190px; }
.uniform-result-report .midterm-table td:first-child,
.uniform-result-report .midterm-table th:first-child { width: 38%; }
.uniform-result-report .midterm-table td:last-child,
.uniform-result-report .midterm-table th:last-child { width: 12%; }

/* ============================================================================
   9b. RESULT SHEET: paper colour system, structure, responsive layout
   ----------------------------------------------------------------------------
   Why: the app runs on a dark theme, and the base table/td/th rules paint
   near-white text on a near-black table panel. The result sheet is white
   paper, so tables showed up as dark slabs and labels (summary rows, remarks)
   as pale grey on grey. Re-pointing the theme tokens *inside* .result-sheet
   makes every inherited rule resolve to dark ink on paper, and the explicit
   fills below give each part (header, totals, max row, tiles) a tinted
   background with dark text, so it stays readable even when a browser drops
   background colours while printing.

   Print: colours and column widths apply to print too; sizes and chrome are
   inside @media screen so the A4 calibration (sections 9 and 10) is untouched.
   Responsive: the sheet is a size container, so it adapts to the space it is
   given (sidebar open, portal column, phone) rather than the viewport.
   ========================================================================== */
.result-sheet {
    color-scheme: light;
    --text: #1e293b; --text-strong: #0f172a; --muted: #475569; --muted-2: #64748b;
    --panel: #ffffff; --line: #cbd5e1; --line-strong: #94a3b8;
    --gray-25: #fcfdfe; --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
    --gray-300: #cbd5e1; --gray-700: #1e293b;
    --accent-soft: transparent;

    --rs-ink: #0f172a;
    --rs-ink-soft: #334155;
    --rs-line: #94a3b8;
    --rs-line-soft: #cbd5e1;
    --rs-head-bg: #d7e8de;
    --rs-head-ink: #0b2e1f;
    --rs-band: #f3f8f5;
    --rs-tile-bg: #f4f8f6;
    --rs-tile-line: #d3e2d9;
    --rs-total-bg: #d1fae5;
    --rs-total-ink: #064e3b;
    --rs-max-bg: #fde7f6;
    --rs-max-ink: #831843;
    --rs-comment-ink: #1e3a8a;
    --rs-brand: #14532d;

    background: #fff;
    color: var(--rs-ink);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Tables: ink on paper, tinted header, soft zebra, highlighted totals. */
.result-sheet table { background: #fff; }
.result-sheet th, .result-sheet td { color: var(--rs-ink); }
.result-sheet table th {
    position: static; white-space: normal; box-shadow: none;
    background: var(--rs-head-bg); color: var(--rs-head-ink);
    font-weight: 700; text-transform: none; letter-spacing: 0;
}
.result-sheet tbody tr:hover { background: transparent; }
:where(.result-sheet .rs-grid tbody tr:nth-child(even) td) { background: var(--rs-band); }
.result-sheet .rs-grid tr.accent-row td { background: var(--rs-max-bg); color: var(--rs-max-ink); font-weight: 700; }
.result-sheet .rs-grid td.emphasis { background: var(--rs-total-bg); color: var(--rs-total-ink); font-weight: 800; }
.result-sheet .summary-table td:first-child { background: var(--rs-tile-bg); font-weight: 600; }
.result-sheet .summary-title { background: var(--rs-head-bg); color: var(--rs-head-ink); }
.result-sheet .summary-caption { color: var(--rs-ink-soft); }
/* The old gradient started at #2db449, which is only 2.7:1 against the white percentage. */
.result-sheet .summary-score-badge { background: linear-gradient(180deg, #15803d 0%, #14532d 100%); color: #fff; }
.result-sheet .summary-remark { color: var(--rs-ink-soft); }
.result-sheet .sheet-school-subtext { color: var(--rs-ink-soft); }
.result-sheet .comment-text { color: var(--rs-comment-ink); }
.result-sheet .report-policy-footer { color: var(--rs-ink-soft); }

/* Column widths. The remark column gets real room (it was 6-12% before) and
   is left-aligned; grade stays narrow. Specificity matches the legacy
   ":first-child / :last-child" width rules above, and this block comes later. */
.result-sheet table.exam-table .col-subject { width: 27%; }
.result-sheet table.exam-table .col-grade { width: 8%; text-align: center; }
.result-sheet table.exam-table .col-remark { width: 17%; text-align: left; }
.result-sheet table.exam-table .col-teacher { width: 18%; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-sheet table.rs-table--term3 .col-subject { width: 19%; }
.result-sheet table.rs-table--term3 .col-grade { width: 6%; }
.result-sheet table.rs-table--term3 .col-remark { width: 14%; }
.result-sheet table.rs-table--term3 .col-teacher { width: 15%; }
.result-sheet table.rs-table--exam-only .col-subject { width: 31%; }
.result-sheet table.rs-table--exam-only .col-remark { width: 19%; }
.result-sheet table.rs-table--exam-only .col-teacher { width: 20%; }
.result-sheet table.rs-table--midterm .col-subject { width: 33%; }
.result-sheet table.rs-table--midterm .col-score { width: 14%; text-align: center; }
.result-sheet table.rs-table--midterm .col-grade { width: 8%; }
.result-sheet table.rs-table--midterm .col-remark { width: 23%; }
.result-sheet table.rs-table--midterm .col-teacher { width: 22%; }

/* Layout hooks that must also hold in print. */
.result-sheet .exam-layout.rs-academic.is-single { grid-template-columns: minmax(0, 1fr); }
.result-sheet .sheet-main-title { margin-bottom: 0; letter-spacing: 0; line-height: 1.3; }
.rs-field-label { font-weight: 700; }
.rs-field-label::after { content: ":"; }
.rs-field-value { margin-left: 4px; }
.rs-field--name .rs-field-value { font-weight: 900; }
.rs-comment-title { font-weight: 700; }
.rs-comment-title::after { content: ":"; }
.rs-comment-text { margin-left: 4px; }

/* Domain traits: name on top, descriptive word underneath (as on the paper report) */
.result-sheet .rs-traits { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 0; border: 1px solid var(--rs-line); border-radius: 10px; overflow: hidden; background: #fff; }
.result-sheet .rs-trait { display: grid; grid-template-rows: auto 1fr; border-right: 1px solid var(--rs-line-soft); border-bottom: 1px solid var(--rs-line-soft); margin: 0 -1px -1px 0; }
.result-sheet .rs-trait-label { padding: 6px 8px; background: var(--rs-head-bg); color: var(--rs-head-ink); font-size: 11px; font-weight: 800; text-align: center; line-height: 1.25; }
.result-sheet .rs-trait-value { padding: 8px 8px; background: #fff; color: var(--rs-ink); font-size: 13px; font-weight: 600; text-align: center; }

/* Keys to grading: one wrapping line of bands, highest first */
.result-sheet .rs-grading-key { margin: 14px 0 0; padding: 9px 12px; background: var(--rs-tile-bg); border: 1px solid var(--rs-tile-line); border-radius: 10px; color: var(--rs-ink); font-size: 12px; line-height: 1.6; }
.result-sheet .rs-key-title { margin-right: 8px; font-weight: 900; letter-spacing: .04em; color: var(--rs-head-ink); }
.result-sheet .rs-key-item { display: inline-block; margin-right: 10px; white-space: nowrap; }
.result-sheet .rs-key-item strong { color: var(--rs-brand); }

/* Third-term promotion line */
.result-sheet .rs-promotion { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 12px 0 0; padding: 10px 14px; border: 1px solid var(--rs-line); border-radius: 10px; font-weight: 700; }
.result-sheet .rs-promotion.is-promoted { background: var(--rs-total-bg); color: var(--rs-total-ink); border-color: #6ee7b7; }
.result-sheet .rs-promotion.is-held { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.result-sheet .rs-promotion-label { font-size: 11px; letter-spacing: .07em; }
.result-sheet .rs-promotion-value { font-size: 15px; }

@media screen, print {
    .result-sheet.report-card {
        container: rs / inline-size;
        max-width: 1040px; margin-inline: auto;
        padding: clamp(14px, 2.4vw, 28px);
        border: 1px solid #cbd5e1; border-radius: 16px;
        box-shadow: 0 12px 36px rgba(0, 0, 0, .35);
        font-size: 13px; line-height: 1.5;
    }
    .result-sheet .sheet-toolbar { border-bottom-color: #e2e8f0; }

    /* Header */
    .result-sheet .sheet-header-block {
        background: linear-gradient(180deg, #f3f9f5 0%, #e7f1eb 100%);
        border: 1px solid #c4d9cc; border-radius: 14px;
        padding: 16px 18px; margin-bottom: 16px;
    }
    .result-sheet .sheet-brand { display: grid; grid-template-columns: minmax(64px, 96px) minmax(0, 1fr) minmax(64px, 96px); gap: 18px; align-items: center; }
    .result-sheet .sheet-school-logo { width: 88px; height: 88px; padding: 6px; border-radius: 12px; border-color: #c4d9cc; }
    .result-sheet .sheet-passport { width: 80px; height: 100px; border-radius: 8px; border-color: #9fb8a9; }
    .result-sheet .sheet-school-name { font-size: clamp(18px, 3.2vw, 28px); line-height: 1.15; overflow-wrap: anywhere; }
    .result-sheet .sheet-school-subtext { font-size: 12px; margin-top: 2px; }
    .result-sheet .sheet-main-title {
        display: inline-block; max-width: 100%; margin-top: 10px; padding: 6px 16px;
        border-radius: 999px; background: var(--rs-brand); color: #fff;
        font-size: 12px; font-weight: 700; letter-spacing: .05em;
    }

    /* Pupil details + attendance tiles */
    .result-sheet .rs-meta, .result-sheet .rs-attendance {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px; margin: 0 0 14px; padding: 0; border: 0;
    }
    .result-sheet .rs-field {
        display: flex; flex-direction: column; gap: 2px; min-width: 0;
        padding: 9px 12px; background: var(--rs-tile-bg);
        border: 1px solid var(--rs-tile-line); border-radius: 10px;
    }
    .result-sheet .rs-field-label { font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--rs-ink-soft); }
    .result-sheet .rs-field-label::after { content: none; }
    .result-sheet .rs-field-value { margin: 0; font-size: 14px; font-weight: 600; color: var(--rs-ink); overflow-wrap: anywhere; }
    .result-sheet .rs-field--name { grid-column: 1 / -1; background: #e6f1ea; border-color: #b9d3c3; }
    .result-sheet .rs-field--name .rs-field-value { font-size: 17px; font-weight: 800; }
    .result-sheet .rs-field--stat .rs-field-value { font-size: 18px; font-weight: 800; }
    .result-sheet .next-term-chip { padding: 3px 10px; font-size: 12px; }

    /* Section titles */
    .result-sheet .midterm-section-title {
        display: flex; align-items: center; gap: 8px;
        margin: 4px 0 8px; font-size: 12px; letter-spacing: .06em; color: var(--rs-head-ink);
    }
    .result-sheet .midterm-section-title::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--rs-brand); }

    /* Academic block: table + side column */
    .result-sheet .exam-layout.rs-academic { grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; margin-top: 4px; align-items: start; }
    .result-sheet .exam-layout.rs-academic.is-single { grid-template-columns: minmax(0, 1fr); }
    .result-sheet .rs-side { display: grid; gap: 14px; align-content: start; align-items: start; }

    /* Tables */
    .result-sheet .rs-grid { border-collapse: separate; border-spacing: 0; border: 1px solid var(--rs-line); border-radius: 10px; overflow: hidden; table-layout: fixed; }
    .result-sheet .rs-grid th, .result-sheet .rs-grid td {
        padding: 9px 11px; font-size: 12.5px; line-height: 1.35;
        border: 0; border-right: 1px solid var(--rs-line-soft); border-bottom: 1px solid var(--rs-line-soft);
    }
    .result-sheet .rs-grid th:last-child, .result-sheet .rs-grid td:last-child { border-right: 0; }
    .result-sheet .rs-grid tbody tr:last-child td { border-bottom: 0; }
    .result-sheet .rs-grid th { padding-block: 10px; font-size: 12px; }
    .result-sheet .rs-grid td.col-subject { font-weight: 600; }
    .result-sheet .rs-grid td.col-grade { font-weight: 700; text-align: center; }
    .result-sheet .scale-table.rs-grid td:nth-child(2) { text-align: center; font-weight: 700; }
    .result-sheet .summary-table.rs-grid { border: 0; border-radius: 0; }
    .result-sheet .summary-table.rs-grid td:first-child { width: 58%; }
    .result-sheet .summary-table.rs-grid td:last-child { font-weight: 700; }
    .result-sheet .scale-table.rs-grid, .result-sheet .rs-domain-table { table-layout: auto; }
    .result-sheet .rs-domain-table td:nth-child(2), .result-sheet .rs-domain-table th:nth-child(2) { text-align: left; width: 45%; }

    .result-sheet .summary-box { border: 1px solid var(--rs-line); border-radius: 12px; overflow: hidden; background: #fff; }
    .result-sheet .summary-title { padding: 9px 12px; font-size: 12.5px; border-bottom: 1px solid var(--rs-line); }

    /* Mid-term summary strip */
    .result-sheet .sheet-summary-wrap { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; align-items: stretch; margin: 14px 0; }
    .result-sheet .summary-highlight, .result-sheet .summary-final-result {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: 14px; border: 1px solid var(--rs-tile-line); border-radius: 12px; background: var(--rs-tile-bg);
    }
    .result-sheet .summary-caption { margin-bottom: 8px; font-size: 11px; letter-spacing: .05em; }
    .result-sheet .summary-score-badge { font-size: 24px; }
    .result-sheet .summary-grade { font-size: 34px; line-height: 1.1; }

    /* Domain ratings sit side by side when there is room */
    .result-sheet .rs-domains { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 16px 0; }
    .result-sheet .rs-domain .midterm-section-title { margin-top: 0; }

    /* Comments: one roomy block each, full width */
    .result-sheet .sheet-official-tag { margin: 14px 0 8px; font-size: 11px; color: var(--rs-ink-soft); }
    .result-sheet .rs-comments { display: grid; gap: 12px; margin-top: 16px; padding: 0; border: 0; }
    .result-sheet .rs-comment { margin: 0; padding: 12px 16px 14px; border: 1px solid var(--rs-line-soft); border-left: 4px solid var(--rs-brand); border-radius: 10px; background: #fcfdfc; }
    .result-sheet .rs-comment-title { display: block; margin-bottom: 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--rs-head-ink); }
    .result-sheet .rs-comment-title::after { content: none; }
    .result-sheet .rs-comment-text { display: block; min-height: 3.6em; margin: 0; font-size: 14px; line-height: 1.65; }

    /* Signatures + footer */
    .result-sheet .sheet-signatures { gap: 32px; margin-top: 26px; }
    .result-sheet .signature-line { margin-top: 38px; border-top-width: 1.5px; border-top-color: var(--rs-ink-soft); }
    .result-sheet .signature-role { font-size: 12px; }
    .result-sheet .report-policy-footer { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--rs-line-soft); text-align: center; font-size: 11.5px; }
}

/* Container queries only apply on screen: the container is declared in the
   @media screen block above, so print never matches them. */
@container rs (max-width: 1000px) {
    .result-sheet .exam-layout.rs-academic.with-summary-side { grid-template-columns: minmax(0, 1fr); }
    .result-sheet .with-summary-side .rs-side { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
}
@container rs (max-width: 820px) {
    .result-sheet .exam-layout.rs-academic { grid-template-columns: minmax(0, 1fr); }
    .result-sheet .rs-side { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
}
@container rs (max-width: 640px) {
    .result-sheet .sheet-brand { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; gap: 12px; }
    .result-sheet .sheet-brand .sheet-school-logo,
    .result-sheet .sheet-brand .sheet-school-copy,
    .result-sheet .sheet-brand .sheet-passport-wrap.top { grid-column: 1; justify-self: center; }
    .result-sheet .sheet-header-block { padding: 14px 12px; }

    /* Subject tables become one card per subject. The !important flags win
       over the legacy per-column width/alignment rules, same pattern as the
       print overrides in section 10. */
    .result-sheet .rs-table { display: block; border: 0; border-radius: 0; overflow: visible; background: transparent; }
    .result-sheet .rs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .result-sheet .rs-table tbody { display: grid; gap: 10px; }
    .result-sheet .rs-table tbody tr {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
        border: 1px solid var(--rs-line); border-radius: 12px; overflow: hidden; background: #fff;
    }
    .result-sheet .rs-table td {
        display: flex; flex-direction: column; gap: 2px; min-width: 0;
        width: auto !important; padding: 8px 12px; font-size: 14px;
        border: 0; border-top: 1px solid var(--rs-line-soft);
        text-align: left !important;
    }
    .result-sheet .rs-table td::before {
        content: attr(data-label); font-size: 10.5px; font-weight: 700;
        letter-spacing: .06em; text-transform: uppercase; color: var(--rs-ink-soft);
    }
    .result-sheet .rs-table td.emphasis::before { color: var(--rs-total-ink); }
    .result-sheet .rs-table tr.accent-row td::before { color: var(--rs-max-ink); }
    .result-sheet .rs-table td.col-subject {
        grid-column: 1 / -1; border-top: 0; font-size: 15px; font-weight: 700;
        background: var(--rs-head-bg); color: var(--rs-head-ink);
    }
    .result-sheet .rs-table tr.accent-row td.col-subject { background: var(--rs-max-bg); color: var(--rs-max-ink); }
    .result-sheet .rs-table td.col-subject::before { content: none; }
    .result-sheet .rs-table td.col-remark { grid-column: 1 / -1; }
    .result-sheet .rs-table td.col-remark:empty, .result-sheet .rs-table td.col-grade:empty { display: none; }
    .result-sheet .rs-table td.col-remark { font-weight: 600; }
    .result-sheet .rs-field--name .rs-field-value { font-size: 16px; }
}
@container rs (max-width: 480px) {
    .result-sheet .sheet-signatures { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    .result-sheet .signature-slot.align-right { text-align: center; }
}

/* ============================================================================
   10. RESPONSIVE / MOTION / PRINT
   ========================================================================== */
@media screen and (max-width: 1200px) {
    .dashboard-action-grid, .quick-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* These two used to be separate breakpoints (1120px and 1024px). Between
   them, the grid had already collapsed to one column but the sidebar hadn't
   switched to its fixed/overlay mode yet, so it rendered as a full-width,
   full-height block and pushed the entire topbar and page content below the
   viewport — invisible without scrolling, on any ordinary laptop window in
   that ~100px range. Both changes now happen at the exact same breakpoint
   so there is no gap where that can happen again. */
@media screen and (max-width: 1024px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .main { max-width: none; }
    .portal-app-grid, .portal-grid { grid-template-columns: minmax(0, 1fr); }
    .portal-form-card { position: static; }

    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar);
        width: min(86vw, 300px); height: 100dvh;
        transform: translateX(-100%); transition: transform var(--speed) var(--ease);
        box-shadow: var(--shadow-modal);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .sidebar-overlay {
        position: fixed; inset: 0; z-index: var(--z-overlay);
        border: 0; padding: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px);
    }
    body.nav-open .sidebar-overlay { display: block; }
    .sidebar-close {
        display: inline-flex; align-self: flex-end;
        width: 34px; height: 34px; align-items: center; justify-content: center;
        border: 1px solid var(--line); border-radius: var(--radius-sm);
        background: var(--gray-50); color: var(--gray-700); font-size: 22px; line-height: 1; cursor: pointer;
    }
}

@media screen and (max-width: 980px) {
    .feature-grid, .template-subject-grid, .exam-layout, .exam-summary-wrap,
    .exam-meta-grid, .exam-attendance-row, .form-row-4, .score-context-grid, .compact-meta-top {
        grid-template-columns: minmax(0, 1fr);
    }
    .exam-term-report .sheet-school-name { font-size: 22px; }
    .page-hero, .section-head { flex-direction: column; }
}

@media screen and (max-width: 900px) {
    .public-grid { grid-template-columns: minmax(0, 1fr); }
    .public-support-card { flex-direction: column; align-items: flex-start; }
}

@media screen and (max-width: 820px) {
    .midterm-layout, .sheet-summary-wrap, .sheet-signatures, .sheet-meta-list, .sheet-attendance-row,
    .report-builder-preview { grid-template-columns: minmax(0, 1fr); }
    /* Several report-type modifier classes (.uniform-result-report
       .midterm-layout.exam-layout, .single-term-report .exam-layout, etc.)
       carry a higher-specificity two-class selector declared outside any
       media query, so the plain ".midterm-layout"/".exam-layout" rule above
       never wins against them — the academic table and grading scale stayed
       side by side instead of stacking on a phone. !important here matches
       the same pattern this stylesheet already uses for print overrides
       (see .sheet-attendance-row below) to guarantee the mobile collapse
       wins regardless of which report-type class combination is present. */
    .midterm-layout, .exam-layout { grid-template-columns: minmax(0, 1fr) !important; }
    .sheet-meta-top, .sheet-meta-grid.has-passport { grid-template-columns: minmax(0, 1fr); }
    .sheet-passport-wrap { justify-content: flex-start; }
    .sheet-school-name { font-size: 22px; }
    .sheet-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
    .sheet-brand .sheet-passport-wrap.top { justify-self: auto; margin-top: 8px; }
}

@media screen and (max-width: 760px) {
    .main { padding: var(--space-4) var(--space-4) var(--space-8); }
    .topbar { margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-4); padding: var(--space-3) var(--space-4); }
    /* The phone header keeps only the menu button and the user menu — the
       Search/Notifications/Setup icons move into the nav tray's quick-links
       block instead (see .sidebar-quick-links above), since a phone-width
       topbar doesn't have room for a full icon toolbar without crowding the
       page title next to it. Ordering puts the (now much smaller)
       menu-button + user-menu row first and gives the title its own
       full-width row below. */
    .topbar-tools > .icon-btn, .topbar-tools > .topbar-divider { display: none; }
    .sidebar-quick-links { display: flex; }
    .menu-toggle { order: 1; }
    .topbar-tools { order: 2; }
    .topbar-title { order: 3; flex: 1 1 100%; }
    .form-row, .form-row-3, .grid-2, .grid-3, .grid-4, .report-stats, .report-foot,
    .report-meta-grid, .dashboard-action-grid, .quick-action-grid, .form-grid-tight,
    .portal-summary-grid, .portal-placeholder-grid, .subject-check-grid, .mini-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .report-head, .portal-hero-head { flex-direction: column; align-items: flex-start; }
    .hero-card, .sticky-action-bar { flex-direction: column; align-items: stretch; }
    .hero-actions, .toolbar-actions { width: 100%; }
    .hero-actions .btn, .toolbar-actions .btn { flex: 1 1 auto; }
    .card, .form-card, .report-card { padding: var(--space-4); }
    .kv { grid-template-columns: minmax(0, 1fr); gap: 2px var(--space-3); }
    .kv > div:nth-child(odd) { margin-top: var(--space-2); }
    .toolbar-search { width: 100%; }
    .class-chip { min-width: 128px; }
    .result-item { flex-direction: column; }
    .help-index { columns: 1; }
    th, td { padding: 10px 12px; }

    /* The user menu's name/role text is the first thing to go on a narrow
       phone — the avatar alone is enough, and the full name is still the
       first line inside the dropdown once it's opened. */
    .user-menu-name { display: none; }
    .user-menu-trigger { padding: 4px; gap: 4px; }
}

/* Entrance for the page's top-level content — a quick, small fade with no
   blur and almost no movement. It should register as "the page settled in",
   not as a visible effect. */
@media (prefers-reduced-motion: no-preference) {
    @keyframes settle-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
    .main > section, .main > .card, .main > .hero-card {
        animation: settle-in 180ms var(--ease) both;
    }
}

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

@media print {
    /* Printed paper is always white regardless of the on-screen theme (see
       body { background: #fff } right below) — so every color token has to
       go back to its light-theme value here too, or dark-theme text (set to
       near-white for a black screen background) prints invisible on the
       white page. This is the belt-and-braces version of the same fix
       applied to .result-sheet/.midterm-report/.exam-term-report above,
       covering every other page a user might print (ID cards, broadsheet,
       timetable, etc.), not just the report card. */
    :root {
        color-scheme: light;
        --bg: #f9fafb; --panel: #ffffff; --panel-soft: #fcfcfd;
        --line: #e6e9ed; --line-strong: #d4d9df;
        --text: #313844; --text-strong: #10141b;
        --muted: #6b7380; --muted-2: #9aa3af;
        --gray-25: #fcfcfd; --gray-50: #f9fafb; --gray-100: #f2f4f6; --gray-200: #e6e9ed;
        --gray-300: #d4d9df; --gray-400: #9aa3af; --gray-500: #6b7380; --gray-600: #4b5362;
        --gray-700: #313844; --gray-800: #1c212b; --gray-900: #10141b;
    }
    .sidebar, .sidebar-overlay, .sidebar-close, .topbar, .menu-toggle, .actions,
    .alert, .no-print, .skip-link, .sticky-action-bar, .sheet-toolbar, .guide-box {
        display: none !important;
    }
    body { background: #fff; }
    .app-shell { display: block; }
    .main { max-width: none; padding: 0; }
    .report-card, .card { box-shadow: none; border: none; padding: 0; }
    .id-card { break-inside: avoid; }

    .midterm-report { border: 1px solid #a0a0a0; padding: 8px; font-size: 11px; }
    .result-sheet.report-card { padding: 0; }
    .midterm-table th, .midterm-table td, .scale-table th, .scale-table td, .summary-table td { padding: 4px 5px; font-size: 10px; }
    .sheet-school-name { font-size: 24px; }
    .summary-grade { font-size: 26px; }
    .sheet-attendance-row:not(.rs-attendance) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .exam-attendance-row:not(.rs-attendance) { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }

    .exam-term-report { border: 1px solid #aaa; padding: 6px 7px; font-size: 10px; }
    .exam-term-report .sheet-school-logo { width: 68px; height: 68px; }
    .exam-term-report .sheet-school-name { font-size: 22px; }
    .exam-term-report .sheet-main-title { font-size: 11px; margin-top: 3px; }
    .exam-meta-grid { gap: 4px 14px; }
    .exam-attendance-row { gap: 7px; }
    .exam-layout { gap: 8px; grid-template-columns: minmax(0, 1fr) 180px; }
    .exam-table th, .exam-table td { padding: 2px 4px; font-size: 9px; line-height: 1.05; }
    .compact-scale-table th, .compact-scale-table td,
    .exam-summary-wrap .summary-table td { padding: 3px 4px; font-size: 9px; }
    .summary-caption { font-size: 10px; margin-bottom: 4px; }
    .summary-score-badge { min-width: 96px; padding: 7px 11px; font-size: 18px; }
    .summary-grade { font-size: 24px; }
    .compact-comments-box { padding: 6px 8px; }
    .compact-comments-box > div { margin-bottom: 4px; font-size: 10px; }
    .compact-signatures { margin-top: 8px; gap: 14px; }
    .compact-signatures .signature-line { margin-top: 14px; }
    .report-policy-footer { margin-top: 4px; font-size: 10px; }
    .long-subject-list .exam-table th, .long-subject-list .exam-table td { padding: 1.5px 3px; font-size: 8.5px; }

    .compact-meta-top { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; }
    .refined-print-table td, .refined-print-table th { font-size: 8.7px; padding: 1.8px 3.2px; }
    .single-term-report .compact-exam-side, .second-term-report .compact-exam-side { width: 185px; }
    .single-term-report .exam-layout, .second-term-report .exam-layout { grid-template-columns: minmax(0, 1fr) 185px; }
    .single-term-report .sheet-header-block.compact, .second-term-report .sheet-header-block.compact { margin-bottom: 4px; padding-bottom: 4px; }
    .single-term-report .sheet-main-title, .second-term-report .sheet-main-title { font-size: 10.5px; }

    .uniform-result-report .midterm-layout.exam-layout { grid-template-columns: minmax(0, 1fr) 180px; }
    .uniform-result-report .sheet-school-logo { width: 68px; height: 68px; }
}

/* ==========================================================================
   11. BULK ACTIONS (driven by assets/bulk.js)
   Selection badge, sticky toolbar, selected-row highlight, grid fill buttons.
   ========================================================================== */
.bulk-toolbar {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft);
}
.bulk-toolbar.has-selection {
    position: sticky; top: 8px; z-index: 20;
    border-color: var(--accent-2); background: var(--accent-soft);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.bulk-count {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-pill);
    background: var(--gray-100); color: var(--muted); font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.bulk-toolbar.has-selection .bulk-count { background: var(--accent-2); color: #fff; }
.bulk-toolbar button[disabled] { opacity: .5; cursor: not-allowed; }
.bulk-search { width: 100%; max-width: 360px; margin: 0 0 var(--space-3); }
tr.is-selected > td { background: var(--accent-soft); }
tbody tr:has([data-row-check]) { cursor: pointer; }
.fill-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: 0 0 var(--space-3); }
.fill-toolbar .fill-label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.fill-note { font-size: 12.5px; color: var(--muted); }
@media screen and (max-width: 760px) {
    .bulk-toolbar select, .bulk-toolbar .btn { flex: 1 1 140px; }
    .bulk-toolbar.has-selection { top: 0; }
}
@media print { .bulk-toolbar, .bulk-search, .fill-toolbar { display: none !important; } }
@media print { .print-skip { display: none !important; } }

/* ==========================================================================
   12. REPORT CARD PAGE + GUIDE DISMISS
   ========================================================================== */
.guide-box > div:nth-child(2) { flex: 1 1 auto; }
.guide-dismiss {
    flex: 0 0 auto; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--info-text); font-size: 20px; line-height: 1; cursor: pointer;
}
.guide-dismiss:hover, .guide-dismiss:focus-visible { background: var(--info-line); }
.guide-restore {
    margin: 0 0 var(--space-3); padding: 4px 10px; border: 1px dashed var(--info-line); border-radius: var(--radius-pill);
    background: transparent; color: var(--info-text); font-size: 12.5px; cursor: pointer;
}
.guide-restore:hover { background: var(--info); }

.report-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.report-filter-grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.report-filter-student { grid-column: span 1; }
.report-nav { display: inline-flex; gap: var(--space-2); margin-left: auto; }
.report-nav .is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.report-filters .actions button[disabled] { opacity: .5; cursor: not-allowed; }

.report-context {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4);
    margin: var(--space-4) 0; padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft);
}
.report-context-main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.report-context-main strong { margin-right: var(--space-2); font-size: 15px; }
.report-context-links { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: 13px; }
.chip {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-pill);
    background: var(--gray-100); color: var(--gray-700); font-size: 12.5px; font-weight: 600;
}
.chip-good { background: #d1fae5; color: #064e3b; }
.chip-warn { background: #fef3c7; color: #78350f; }
.chip-bad { background: #fee2e2; color: #7f1d1d; }
.badge-warn { background: #fef3c7; color: #78350f; }

.report-batch > summary { cursor: pointer; padding: var(--space-1) 0; }
.report-batch .table-wrap { max-height: 420px; overflow: auto; }
.report-batch-sheet { margin: 0 0 var(--space-5); }

@media screen and (max-width: 1000px) {
    .report-filter-grid, .report-filter-grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 640px) {
    .report-filter-grid, .report-filter-grid:has(> :nth-child(3):last-child) { grid-template-columns: minmax(0, 1fr); }
    .report-nav { width: 100%; margin-left: 0; }
    .report-nav .btn { flex: 1 1 0; justify-content: center; }
    .report-context-links { width: 100%; }
}
@media print {
    .report-batch-sheet { break-after: page; page-break-after: always; margin: 0; }
    .report-batch-sheet:last-child { break-after: auto; page-break-after: auto; }
    .report-context, .report-batch, .report-batch-bar, .guide-restore { display: none !important; }
}

/* ==========================================================================
   13. APPEARANCE (light theme, text size), TOASTS, DIALOGS, PROGRESS, TABLE TOOLS
   Dark is the default; html[data-theme="light"] re-points the same tokens.
   ========================================================================== */
html[data-theme="light"] {
    color-scheme: light;
    --brand-50:  #eef7f2; --brand-100: #dcefe4; --brand-200: #bcdccb; --brand-300: #92c3ab;
    --brand-400: #63a486; --brand-500: #2f7a61; --brand-600: #25614d; --brand-700: #1f4e3f;
    --brand-800: #163329; --brand-900: #0e231c; --brand-950: #08150f;
    --gray-25: #f5f7fa; --gray-50: #eef1f5; --gray-100: #e6eaef; --gray-200: #d8dde4; --gray-300: #c0c7d1;
    --gray-400: #9aa3af; --gray-500: #6b7380; --gray-600: #4b5362; --gray-700: #2b323d; --gray-800: #1c212b; --gray-900: #10141b;
    --panel: #ffffff; --panel-soft: #f3f6f9;
    --text-strong: #0b1220;
    --accent-soft: rgba(47, 122, 97, .12);
    --success: rgba(22, 163, 74, .10); --success-line: rgba(22, 163, 74, .35); --success-text: #166534;
    --warn: rgba(217, 119, 6, .12); --warn-line: rgba(217, 119, 6, .38); --warn-text: #92400e;
    --error: rgba(220, 38, 38, .09); --error-line: rgba(220, 38, 38, .35); --error-text: #991b1b;
    --danger: #dc2626;
    --info: rgba(37, 99, 235, .09); --info-line: rgba(37, 99, 235, .3); --info-text: #1d4ed8;
    --shadow-sm: 0 1px 2px rgba(16, 20, 27, .08), 0 1px 1px rgba(16, 20, 27, .05);
    --shadow-md: 0 4px 10px rgba(16, 20, 27, .1), 0 1px 2px rgba(16, 20, 27, .06);
    --shadow-modal: 0 16px 40px rgba(16, 20, 27, .22), 0 2px 6px rgba(16, 20, 27, .1);
    --focus: 0 0 0 3px rgba(47, 122, 97, .35);
    --glass-bg: rgba(255, 255, 255, .8); --glass-bg-strong: rgba(255, 255, 255, .94);
    --glass-border: rgba(16, 20, 27, .1);
}
html[data-theme="light"] body { background-image: none; }
html[data-theme="light"] .bulk-toolbar.has-selection { box-shadow: 0 6px 18px rgba(16, 20, 27, .14); }
html[data-theme="light"] .bulk-toolbar.has-selection .bulk-count { color: #fff; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { color-scheme: light; }

/* Text size: scales the whole interface; the printed result sheet is unaffected */
html[data-text="large"] body { zoom: 1.12; }
html[data-text="xlarge"] body { zoom: 1.25; }
@media print { html[data-text] body { zoom: 1; } }

/* Strong keyboard focus everywhere */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Appearance controls inside the user menu */
.user-menu-appearance { display: grid; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.user-menu-appearance .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { padding: 4px 9px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-2); color: #fff; }

/* Toasts: flash messages float and fade; errors stay until closed */
.toast-region {
    position: fixed; top: 14px; right: 14px; z-index: 90; display: grid; gap: 8px;
    width: min(420px, calc(100vw - 28px)); pointer-events: none;
}
.toast-region .alert { margin: 0; padding-right: 38px; position: relative; pointer-events: auto; box-shadow: var(--shadow-md); animation: toast-in .22s var(--ease); }
.toast-region .alert.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
.toast-close { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.toast-close:hover { background: rgba(127, 127, 127, .2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast-region .alert { animation: none; } }
@media print { .toast-region { display: none !important; } }

/* Thin navigation progress bar */
.nav-progress { position: fixed; top: 0; left: 0; z-index: 95; height: 3px; width: 0; background: var(--accent-2); opacity: 0; transition: width .6s var(--ease), opacity .25s; pointer-events: none; }
.nav-progress.is-running { opacity: 1; width: 78%; }

/* Keyboard-shortcut dialog (and any future <dialog class="app-dialog">) */
dialog.app-dialog { width: min(560px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--panel); color: var(--text); box-shadow: var(--shadow-modal); }
dialog.app-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.app-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.app-dialog-head h2 { margin: 0; }
.app-dialog-body { padding: 14px 18px 18px; display: grid; gap: 6px; max-height: 70vh; overflow: auto; }
.kbd-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
kbd { display: inline-block; min-width: 22px; padding: 1px 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--panel-soft); color: var(--text-strong); font: 600 12px var(--font-mono); text-align: center; }

/* Draft restore banner */
.draft-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 var(--space-3); padding: 10px 14px; border: 1px solid var(--warn-line); border-radius: var(--radius); background: var(--warn); color: var(--warn-text); font-size: 13px; }
.draft-banner .btn { min-height: 28px; padding: 3px 10px; }
.draft-status { font-size: 12px; color: var(--muted); }

/* Sortable tables, column picker, saved views */
th[data-sortable] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sortable]::after { content: "\2195"; margin-left: 6px; font-size: 10px; opacity: .35; }
th[aria-sort="ascending"]::after { content: "\25B2"; opacity: .9; }
th[aria-sort="descending"]::after { content: "\25BC"; opacity: .9; }
.col-hidden { display: none !important; }
.table-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: flex-end; margin: 0 0 var(--space-2); }
.col-picker { position: relative; }
.col-picker-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 200px; max-height: 260px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-md); display: grid; gap: 4px; }
.col-picker-panel label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.saved-views { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 var(--space-2); }
.saved-view { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--panel-soft); font-size: 12.5px; cursor: pointer; }
.saved-view button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.saved-view button:hover { background: var(--line); }
@media print { .table-tools, .saved-views, .draft-banner, .nav-progress { display: none !important; } }

.alert-info { background: var(--info); border-color: var(--info-line); color: var(--info-text); }
.alert-info::before { content: 'i'; }

/* ==========================================================================
   14. DASHBOARD INSIGHTS: attention list, charts, birthdays
   ========================================================================== */
.attention-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.attention-item { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); background: var(--panel-soft); }
.attention-item.severity-bad { border-left-color: var(--error-text); }
.attention-item.severity-warn { border-left-color: var(--warn-text); }
.attention-item.severity-info { border-left-color: var(--info-text); }
.attention-tag { padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.severity-bad .attention-tag { background: var(--error); color: var(--error-text); }
.severity-warn .attention-tag { background: var(--warn); color: var(--warn-text); }
.severity-info .attention-tag { background: var(--info); color: var(--info-text); }
.attention-text { display: grid; gap: 1px; min-width: 0; }
.attention-text .muted { font-size: 12.5px; }
@media screen and (max-width: 640px) {
    .attention-item { grid-template-columns: minmax(0, 1fr) auto; }
    .attention-tag { grid-column: 1 / -1; justify-self: start; }
}

.hbars { display: grid; gap: 8px; margin-top: var(--space-3); }
.hbar { display: grid; grid-template-columns: minmax(80px, 28%) 1fr 54px; gap: var(--space-2); align-items: center; font-size: 12.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hbar-track { height: 12px; border-radius: var(--radius-pill); background: var(--gray-200); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--accent-2); }
.hbar-fill.tone-good { background: #16a34a; }
.hbar-fill.tone-ok { background: #d97706; }
.hbar-fill.tone-low { background: #dc2626; }
.hbar-value { text-align: right; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }

.chart { width: 100%; height: auto; display: block; margin-top: var(--space-3); }
.chart-grid-line, .chart .chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-axis { fill: var(--muted); font: 11px var(--font-ui); }
.chart-path { fill: none; stroke: var(--accent-2); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--panel); stroke: var(--accent-2); stroke-width: 2; }
.chart-series-0 { fill: var(--gray-400); }
.chart-series-1 { fill: var(--accent-2); }
@media print { .chart .chart-grid { stroke: #bbb; } .chart-axis { fill: #333; } .chart-path, .chart-dot { stroke: #14532d; } .chart-series-0 { fill: #888; } .chart-series-1 { fill: #14532d; } .hbar-track { background: #ddd; } }

.birthday-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.birthday-when { display: inline-block; min-width: 96px; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--gray-100); font-size: 12px; font-weight: 600; }
.birthday-when.is-today { background: var(--accent-2); color: #fff; }

/* ==========================================================================
   15. REPORT VERIFICATION (QR on the sheet, public verify page)
   ========================================================================== */
.result-sheet .rs-footer-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.result-sheet .rs-footer-text { flex: 1 1 auto; min-width: 0; }
.result-sheet .rs-verify { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; color: var(--rs-ink, #0f172a); }
.result-sheet .rs-verify .qr-code { width: 76px; height: 76px; border: 1px solid var(--rs-line-soft, #cbd5e1); border-radius: 4px; }
.result-sheet .rs-verify-text { display: grid; gap: 1px; font-size: 10px; line-height: 1.35; text-align: left; max-width: 150px; }
.result-sheet .rs-verify-text strong { font-size: 10.5px; }
@container rs (max-width: 480px) {
    .result-sheet .rs-footer-row { flex-direction: column; align-items: stretch; }
    .result-sheet .rs-verify { justify-content: center; }
}

.verify-card { max-width: 520px; }
.verify-result { display: grid; gap: 4px; margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.verify-result.is-valid { background: var(--success); border-color: var(--success-line); color: var(--success-text); }
.verify-result.is-warn { background: var(--warn); border-color: var(--warn-line); color: var(--warn-text); }
.verify-details { display: grid; gap: 6px; margin: 0 0 12px; }
.verify-details div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.verify-details dt { color: var(--muted); }
.verify-details dd { margin: 0; font-weight: 600; text-align: right; }

/* ==========================================================================
   16. MINIMAL REPORT CARD
   Plain white paper, black text, hairlines. No fills, tiles, pills, gradients or colour coding.
   Loaded last on purpose: it re-points the sheet's tokens and flattens every decorated part.
   Remove this section to return to the tinted design.
   ========================================================================== */
.result-sheet.report-card {
    --rs-ink: #111; --rs-ink-soft: #5b5b5b; --rs-line: #111; --rs-line-soft: #dcdcdc;
    --rs-head-bg: transparent; --rs-head-ink: #111; --rs-band: transparent;
    --rs-tile-bg: transparent; --rs-tile-line: #dcdcdc;
    --rs-total-bg: transparent; --rs-total-ink: #111; --rs-max-bg: transparent; --rs-max-ink: #5b5b5b;
    --rs-comment-ink: #111; --rs-brand: #111;
    background: #fff; color: #111;
}
.result-sheet.report-card .sheet-main-title,
.result-sheet.report-card .next-term-chip,
.result-sheet.report-card .summary-score-badge { background: none; color: #111; border-radius: 0; padding: 0; box-shadow: none; }

/* ---- header: centred, one rule underneath ---- */
.result-sheet.report-card .sheet-header-block { background: none; border: 0; border-bottom: 1px solid #111; border-radius: 0; padding: 0 0 14px; margin-bottom: 16px; }
.result-sheet.report-card .sheet-school-logo { border: 0; border-radius: 0; padding: 0; background: none; box-shadow: none; }
.result-sheet.report-card .sheet-passport { border: 1px solid #bbb; border-radius: 0; }
.result-sheet.report-card .sheet-school-name { color: #111; font-weight: 700; letter-spacing: .01em; }
.result-sheet.report-card .sheet-school-subtext { color: #5b5b5b; }
.result-sheet.report-card .sheet-main-title { display: block; margin-top: 8px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #111; }

/* ---- pupil details: plain label / value pairs ---- */
.result-sheet.report-card .rs-field,
.result-sheet.report-card .rs-field--name { background: none; border: 0; border-radius: 0; padding: 4px 0; }
.result-sheet.report-card .rs-field-label { font-size: 10px; letter-spacing: .08em; color: #5b5b5b; }
.result-sheet.report-card .rs-field-value { font-size: 13.5px; font-weight: 500; color: #111; }
.result-sheet.report-card .rs-field--name .rs-field-value { font-size: 16px; font-weight: 700; }
.result-sheet.report-card .rs-field--stat .rs-field-value { font-size: 14px; font-weight: 600; }
.result-sheet.report-card .rs-meta, .result-sheet.report-card .rs-attendance { gap: 2px 18px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #ececec; }

/* ---- section titles: small grey caps, no bar ---- */
.result-sheet.report-card .midterm-section-title { margin: 14px 0 6px; padding: 0; font-size: 10.5px; font-weight: 600; letter-spacing: .14em; color: #5b5b5b; text-transform: uppercase; }
.result-sheet.report-card .midterm-section-title::before { content: none; }

/* ---- tables: horizontal rules only ---- */
.result-sheet.report-card .rs-grid { border: 0; border-radius: 0; border-collapse: collapse; overflow: visible; background: none; }
.result-sheet.report-card .rs-grid th,
.result-sheet.report-card .rs-grid td { background: none; color: #111; border: 0; border-bottom: 1px solid #e4e4e4; padding: 7px 8px; }
.result-sheet.report-card .rs-grid th { border-bottom: 1px solid #111; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #111; }
.result-sheet.report-card .rs-grid tbody tr:last-child td { border-bottom: 1px solid #111; }
.result-sheet.report-card .rs-grid tbody tr:nth-child(even) td,
.result-sheet.report-card .rs-grid tr.accent-row td,
.result-sheet.report-card .rs-grid td.emphasis { background: none; }
.result-sheet.report-card .rs-grid tr.accent-row td { color: #5b5b5b; font-weight: 500; font-style: italic; }
.result-sheet.report-card .rs-grid td.emphasis { color: #111; font-weight: 700; }
.result-sheet.report-card .rs-grid td.col-subject { font-weight: 500; }
.result-sheet.report-card .rs-grid td.col-grade { font-weight: 700; }

/* ---- summary ---- */
.result-sheet.report-card .summary-box { border: 0; border-top: 1px solid #111; border-radius: 0; background: none; }
.result-sheet.report-card .summary-title { padding: 8px 0 4px; background: none; border: 0; font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #5b5b5b; }
.result-sheet.report-card .summary-table td:first-child { background: none; font-weight: 500; }
.result-sheet.report-card .summary-highlight,
.result-sheet.report-card .summary-final-result { background: none; border: 0; border-top: 1px solid #111; border-radius: 0; padding: 10px 0; align-items: flex-start; }
.result-sheet.report-card .summary-caption { color: #5b5b5b; }
.result-sheet.report-card .summary-score-badge { font-size: 22px; font-weight: 700; }
.result-sheet.report-card .summary-grade { font-size: 28px; font-weight: 700; color: #111; }

/* ---- grading key: just a line of text ---- */
.result-sheet.report-card .rs-grading-key { background: none; border: 0; border-radius: 0; padding: 8px 0 0; margin-top: 10px; font-size: 11.5px; color: #333; }
.result-sheet.report-card .rs-key-title { color: #111; font-weight: 600; letter-spacing: .1em; }
.result-sheet.report-card .rs-key-item strong { color: #111; }

/* ---- domains: hairline cells ---- */
.result-sheet.report-card .rs-traits { border: 0; border-top: 1px solid #111; border-radius: 0; background: none; }
.result-sheet.report-card .rs-trait { border: 0; border-bottom: 1px solid #e4e4e4; margin: 0; }
.result-sheet.report-card .rs-trait-label { background: none; color: #5b5b5b; font-size: 10px; font-weight: 500; letter-spacing: .04em; padding: 6px 6px 0; }
.result-sheet.report-card .rs-trait-value { background: none; color: #111; font-size: 13px; font-weight: 600; padding: 2px 6px 7px; }

/* ---- comments: label + text, no boxes ---- */
.result-sheet.report-card .rs-comments { gap: 0; margin-top: 12px; }
.result-sheet.report-card .rs-comment { border: 0; border-bottom: 1px solid #e4e4e4; border-radius: 0; background: none; padding: 10px 0 12px; }
.result-sheet.report-card .rs-comment-title { color: #5b5b5b; font-size: 10px; font-weight: 600; letter-spacing: .12em; }
.result-sheet.report-card .rs-comment-text { color: #111; font-style: normal; font-size: 13.5px; }
.result-sheet.report-card .comment-text { color: #111; }
.result-sheet.report-card .sheet-official-tag { color: #5b5b5b; letter-spacing: .1em; }

/* ---- promotion + verification ---- */
.result-sheet.report-card .rs-promotion,
.result-sheet.report-card .rs-promotion.is-promoted,
.result-sheet.report-card .rs-promotion.is-held { background: none; color: #111; border: 0; border-top: 1px solid #111; border-bottom: 1px solid #111; border-radius: 0; padding: 8px 0; margin-top: 12px; }
.result-sheet.report-card .rs-promotion-label { color: #5b5b5b; font-weight: 600; letter-spacing: .12em; }
.result-sheet.report-card .rs-promotion-value { font-weight: 700; }
.result-sheet.report-card .rs-verify .qr-code { border: 0; }

/* ---- signatures and footer ---- */
.result-sheet.report-card .signature-line { border-top: 1px solid #111; }
.result-sheet.report-card .report-policy-footer { border-top: 1px solid #e4e4e4; color: #5b5b5b; text-align: left; }

@media screen, print {
    .result-sheet.report-card { border: 1px solid #dcdcdc; border-radius: 2px; box-shadow: none; padding: clamp(16px, 3vw, 36px); }
}

/* ==========================================================================
   17. BROADSHEET HIGHLIGHTS
   ========================================================================== */
.bs-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 var(--space-3); }
.bs-chip { padding: 2px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.bs-top { background: #d1fae5; color: #064e3b; }
.bs-good { background: #e0f2fe; color: #0c4a6e; }
.bs-ok { background: #fef9c3; color: #713f12; }
.bs-fail { background: #fee2e2; color: #7f1d1d; }
.broadsheet-table td.bs-cell { text-align: center; font-variant-numeric: tabular-nums; }
.broadsheet-table td.bs-cell.bs-top { background: #d1fae5; color: #064e3b; }
.broadsheet-table td.bs-cell.bs-good { background: #e0f2fe; color: #0c4a6e; }
.broadsheet-table td.bs-cell.bs-ok { background: #fef9c3; color: #713f12; }
.broadsheet-table td.bs-cell.bs-fail { background: #fee2e2; color: #7f1d1d; font-weight: 700; }
.broadsheet-table td.bs-cell.bs-empty { color: var(--muted); }
.broadsheet-table td.bs-podium { font-weight: 800; }
.broadsheet-table th:nth-child(2), .broadsheet-table td:nth-child(2) { position: sticky; left: 0; background: var(--panel); z-index: 1; }
@media print {
    .broadsheet-table td.bs-cell { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .bs-legend { display: none; }
}

/* ==========================================================================
   18. CHILD SWITCHER, ACKNOWLEDGE, PROGRESS
   ========================================================================== */
.ward-switcher { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-4); }
.ward-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--panel); color: var(--text); font-weight: 600; }
.ward-pill small { color: var(--muted); font-weight: 500; }
.ward-pill:hover { border-color: var(--accent-2); color: var(--text-strong); }
.ward-pill.is-active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.ward-pill.is-active small { color: rgba(255, 255, 255, .85); }
.ward-initial { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); font-size: 12px; font-weight: 800; }
.ward-pill.is-active .ward-initial { background: rgba(255, 255, 255, .22); color: #fff; }
.report-progress, .report-acknowledge { margin-top: var(--space-4); }
@media print { .ward-switcher, .report-progress, .report-acknowledge { display: none !important; } }

/* Receipt */
.receipt-card { max-width: 560px; margin-inline: auto; }
.receipt-head { text-align: center; margin-bottom: var(--space-3); }
.receipt-head h2 { margin-bottom: 2px; }
@media print { .receipt-card { border: 0; box-shadow: none; max-width: none; } }

/* Audit, backups */
.audit-sensitive td { background: color-mix(in srgb, var(--warn) 55%, transparent); }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-top: var(--space-3); }
.code-block { margin: 0 0 var(--space-3); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel-soft); font: 12.5px var(--font-mono); overflow-x: auto; white-space: pre; }

/* 19. Command palette (Ctrl/Cmd+K) */
dialog.palette-dialog { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; }
.palette-box { display: grid; gap: 8px; padding: 12px; }
.palette-input { width: 100%; font-size: 1.05rem; padding: 12px 14px; }
.palette-results { display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; }
.palette-group { padding: 8px 10px 2px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.palette-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm, 8px); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.palette-row:hover, .palette-row.is-active { background: var(--panel-2, rgba(127, 127, 127, .16)); }
.palette-row small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.palette-empty, .palette-hint { margin: 4px 10px; }

/* 20. "View as" banner */
.viewas-bar { position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 10px 16px; margin-bottom: 12px; border-radius: var(--radius-sm, 8px); background: #b45309; color: #fff; }
.viewas-bar form { margin: 0; }
.viewas-bar .btn { background: #fff; color: #7c2d12; border-color: #fff; }

/* 21. Phone hardening: nothing may be wider than the screen, and everything must be easy to tap */
.grid > *, .form-row > *, .form-row-3 > *, .form-row-4 > *, .report-stats > *, .portal-summary-grid > *, .dashboard-action-grid > *, .quick-action-grid > * { min-width: 0; }
input, select, textarea { max-width: 100%; }
img, video, canvas, svg { max-width: 100%; height: auto; }
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
pre, code { overflow-wrap: anywhere; }
pre { max-width: 100%; overflow-x: auto; }
.card, .form-card, .alert { overflow-wrap: anywhere; }
table, .table-wrap td, .table-wrap th { overflow-wrap: normal; word-break: normal; }
@media screen and (pointer: coarse), screen and (max-width: 760px) {
    .btn, button.btn, a.btn { min-height: 44px; }
    .btn-small { min-height: 38px; padding-inline: 14px; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea { min-height: 44px; font-size: 16px; } /* 16px stops iOS zooming in on focus */
    .icon-btn, .menu-toggle, .sidebar-close { min-width: 44px; min-height: 44px; }
    .nav-section-toggle, .nav a, .sidebar-quick-link { min-height: 44px; }
    input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
    .row-actions { flex-wrap: wrap; gap: 8px; }
    .row-actions form { display: inline-flex; }
    .bulk-toolbar, .module-toolbar, .actions { flex-wrap: wrap; gap: 8px; }
    .bulk-toolbar select, .bulk-toolbar .btn, .module-toolbar .btn { flex: 1 1 140px; }
    dialog.app-dialog { width: calc(100vw - 16px); max-height: 92vh; }
    .palette-dialog { margin-top: 4vh; }
    .viewas-bar { position: static; }
    .toast-region { left: 8px; right: 8px; bottom: 8px; max-width: none; }
}
@media screen and (max-width: 760px) {
    th, td { white-space: normal; }
    .table-wrap table { min-width: 560px; }
    .table-wrap table.compact { min-width: 0; }
}
@media screen and (pointer: coarse), screen and (max-width: 760px) {
    a.pill, .pill { min-height: 38px; display: inline-flex; align-items: center; }
    .auth-card a, .auth-links a, .report-nav a, .muted a, p a { padding-block: 6px; display: inline-block; }
}
@media screen and (max-width: 760px) and (min-width: 340px) {
    .grid:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (pointer: coarse), screen and (max-width: 760px) {
    .report-context-links a, .kv a { display: inline-flex; align-items: center; min-height: 40px; padding-inline: 4px; }
}

/* ==========================================================================
   22. SINGLE-PAGE BALANCED REPORT CARD ARCHITECTURE
   Guaranteed single-page fit on any standard paper (A4, US Letter, Legal).
   Every section is cleanly proportioned, aligned, and optimized for print and screen.
   ========================================================================== */

/* Page Geometry */
@page {
    size: A4 portrait;
    margin: 6mm 8mm;
}

/* Screen container for report sheet */
.result-sheet.report-card {
    width: min(100%, 820px);
    margin: 0 auto 24px;
    padding: 16px 20px;
    background: #ffffff;
    border: 1.5px solid #0f172a;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
    font-family: var(--font-report, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif);
    color: #0f172a;
    position: relative;
}

/* 1. School Header Block */
.result-sheet.report-card .sheet-header-block {
    border-bottom: 2px solid #0f172a;
    padding-bottom: 7px;
    margin-bottom: 7px;
}
.result-sheet.report-card .sheet-brand {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr) 80px;
    align-items: center;
    gap: 12px;
}
.result-sheet.report-card .sheet-school-logo {
    width: 74px;
    height: 74px;
    object-fit: contain;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 2px;
    background: #ffffff;
}
.result-sheet.report-card .sheet-school-copy {
    text-align: center;
}
.result-sheet.report-card .sheet-school-name {
    font-size: 21px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: .02em;
    color: #0f172a;
    text-transform: uppercase;
}
.result-sheet.report-card .sheet-school-subtext {
    font-size: 9.5px;
    line-height: 1.35;
    color: #475569;
    margin-top: 1.5px;
}
.result-sheet.report-card .sheet-school-motto {
    font-size: 9.5px;
    font-weight: 700;
    font-style: italic;
    letter-spacing: .04em;
    color: #1e3a8a;
    text-transform: uppercase;
    margin-top: 1px;
}
.result-sheet.report-card .sheet-main-title {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    background: #0f172a;
    color: #ffffff;
    padding: 3px 18px;
    border-radius: 999px;
    margin-top: 3px;
}
.result-sheet.report-card .sheet-passport {
    width: 68px;
    height: 80px;
    object-fit: cover;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    background: #ffffff;
}
.result-sheet.report-card .sheet-passport.placeholder {
    display: grid;
    place-items: center;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: .05em;
    color: #94a3b8;
    background: #f8fafc;
}

/* 2. Unified Pupil Metadata & Attendance Ribbon */
.result-sheet.report-card .rs-meta-unified {
    border: 1px solid #0f172a;
    border-radius: 4px;
    margin-bottom: 7px;
    background: #f8fafc;
    overflow: hidden;
}
.result-sheet.report-card .rs-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 4px 10px;
    gap: 4px 14px;
}
.result-sheet.report-card .rs-meta-row-1 {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}
.result-sheet.report-card .rs-meta-row-2 {
    background: #f8fafc;
    font-size: 9.5px;
}
.result-sheet.report-card .rs-meta-col {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}
.result-sheet.report-card .rs-meta-col.col-name {
    flex: 1 1 200px;
}
.result-sheet.report-card .rs-meta-col.col-next-term {
    margin-left: auto;
}
.result-sheet.report-card .rs-meta-lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .05em;
    color: #64748b;
    text-transform: uppercase;
}
.result-sheet.report-card .rs-meta-val {
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
}
.result-sheet.report-card .rs-meta-val.rs-val-name {
    font-size: 12.5px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: .02em;
}
.result-sheet.report-card .next-term-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    background: #15803d;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
}

/* 3. Section Title */
.result-sheet.report-card .midterm-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #0f172a;
    margin: 6px 0 3px;
}
.result-sheet.report-card .midterm-section-title::before {
    content: "";
    width: 3px;
    height: 12px;
    background: #0f172a;
    border-radius: 1px;
}

/* 4. Academic Section & Full-Width Table */
.result-sheet.report-card .rs-academic-block {
    margin-bottom: 7px;
}
.result-sheet.report-card .rs-table-container {
    width: 100%;
}
.result-sheet.report-card .exam-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #ffffff;
}
.result-sheet.report-card .exam-table th,
.result-sheet.report-card .exam-table td {
    border: 1px solid #334155;
    padding: 5px 8px;
    font-size: 10.5px;
    line-height: 1.3;
    vertical-align: middle;
}
.result-sheet.report-card .exam-table th {
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 800;
    font-size: 10px;
    letter-spacing: .03em;
    text-align: center;
    text-transform: uppercase;
    padding: 5.5px 8px;
}
.result-sheet.report-card .exam-table th.col-subject {
    text-align: left;
    width: 34%;
}
.result-sheet.report-card .exam-table td.col-subject {
    text-align: left;
    font-weight: 600;
    color: #0f172a;
}
.result-sheet.report-card .exam-table th.col-score,
.result-sheet.report-card .exam-table td.col-score {
    text-align: center;
    width: 13%;
}
.result-sheet.report-card .exam-table td.score-cell.emphasis {
    font-weight: 800;
    background: #fafafa;
    color: #0f172a;
}
.result-sheet.report-card .exam-table th.col-grade,
.result-sheet.report-card .exam-table td.col-grade {
    text-align: center;
    font-weight: 800;
    width: 10%;
}
.result-sheet.report-card .exam-table th.col-remark,
.result-sheet.report-card .exam-table td.col-remark {
    text-align: left;
    padding-left: 10px;
    font-weight: 500;
    width: 20%;
}
.result-sheet.report-card table.rs-table--midterm th.col-subject,
.result-sheet.report-card table.rs-table--midterm td.col-subject {
    width: 33%;
}
.result-sheet.report-card table.rs-table--midterm th.col-score,
.result-sheet.report-card table.rs-table--midterm td.col-score {
    width: 14%;
}
.result-sheet.report-card table.rs-table--midterm th.col-grade,
.result-sheet.report-card table.rs-table--midterm td.col-grade {
    width: 8%;
}
.result-sheet.report-card table.rs-table--midterm th.col-remark,
.result-sheet.report-card table.rs-table--midterm td.col-remark {
    width: 23%;
}
.result-sheet.report-card table.rs-table--midterm th.col-teacher,
.result-sheet.report-card table.rs-table--midterm td.col-teacher {
    width: 22%;
}
.result-sheet.report-card table.rs-table--exam-only th.col-subject,
.result-sheet.report-card table.rs-table--exam-only td.col-subject { width: 31%; }
.result-sheet.report-card table.rs-table--exam-only th.col-score,
.result-sheet.report-card table.rs-table--exam-only td.col-score { width: 11%; }
.result-sheet.report-card table.rs-table--exam-only th.col-grade,
.result-sheet.report-card table.rs-table--exam-only td.col-grade { width: 8%; }
.result-sheet.report-card table.rs-table--exam-only th.col-remark,
.result-sheet.report-card table.rs-table--exam-only td.col-remark { width: 19%; }
.result-sheet.report-card table.rs-table--exam-only th.col-teacher,
.result-sheet.report-card table.rs-table--exam-only td.col-teacher { width: 20%; }
.result-sheet.report-card table.rs-table--term th.col-subject,
.result-sheet.report-card table.rs-table--term td.col-subject { width: 29%; }
.result-sheet.report-card table.rs-table--term th.col-score,
.result-sheet.report-card table.rs-table--term td.col-score { width: 10%; }
.result-sheet.report-card table.rs-table--term th.col-grade,
.result-sheet.report-card table.rs-table--term td.col-grade { width: 7%; }
.result-sheet.report-card table.rs-table--term th.col-remark,
.result-sheet.report-card table.rs-table--term td.col-remark { width: 16%; }
.result-sheet.report-card table.rs-table--term th.col-teacher,
.result-sheet.report-card table.rs-table--term td.col-teacher { width: 18%; }
.result-sheet.report-card table.rs-table--term3 th.col-subject,
.result-sheet.report-card table.rs-table--term3 td.col-subject { width: 20%; }
.result-sheet.report-card table.rs-table--term3 th.col-score,
.result-sheet.report-card table.rs-table--term3 td.col-score { width: 6.5%; }
.result-sheet.report-card table.rs-table--term3 th.col-grade,
.result-sheet.report-card table.rs-table--term3 td.col-grade { width: 6%; }
.result-sheet.report-card table.rs-table--term3 th.col-remark,
.result-sheet.report-card table.rs-table--term3 td.col-remark { width: 13.5%; }
.result-sheet.report-card table.rs-table--term3 th.col-teacher,
.result-sheet.report-card table.rs-table--term3 td.col-teacher { width: 15%; }
.result-sheet.report-card table.exam-table th.col-teacher,
.result-sheet.report-card table.exam-table td.col-teacher {
    text-align: left;
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-sheet.report-card table.exam-table tfoot tr.summary-foot-row td {
    background: #f1f5f9;
    font-weight: 800;
    color: #0f172a;
    border-top: 1.5px solid #475569;
    border-bottom: 1px solid #94a3b8;
    font-size: 9.5px;
    padding: 3.5px 5px;
}
.result-sheet.report-card .rs-chart-box {
    margin-top: 6px;
    padding: 4px 6px 2px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    break-inside: avoid;
}
.result-sheet.report-card .rs-chart-title {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-align: center;
    color: #1e293b;
    margin-bottom: 1px;
}
.result-sheet.report-card .rs-chart-svg {
    width: 100%;
    height: auto;
    max-height: 78px;
    display: block;
}
.result-sheet.report-card .rs-chart-val {
    font-size: 7.5px;
    font-weight: 700;
    fill: #0f172a;
}
.result-sheet.report-card .rs-chart-code {
    font-size: 6.5px;
    font-weight: 700;
    fill: #475569;
}
.result-sheet.report-card .exam-table tr.accent-row td {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-style: italic;
    font-size: 9px;
}
.result-sheet.report-card .exam-table tbody tr:nth-child(even):not(.accent-row) td {
    background: #fcfdfe;
}

/* Legacy layout compatibility if .exam-layout is used */
.result-sheet.report-card .exam-layout {
    display: block;
    width: 100%;
}
.result-sheet.report-card .exam-layout .exam-main {
    width: 100%;
}

/* 5. Performance Summary & KPI Metrics Block */
.result-sheet.report-card .rs-performance-row {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 7px;
}
.result-sheet.report-card .rs-summary-card {
    border: 1px solid #0f172a;
    border-radius: 4px;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.result-sheet.report-card .rs-summary-card .summary-title {
    background: #0f172a;
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: center;
    padding: 3.5px 6px;
    margin: 0;
    border: 0;
}
.result-sheet.report-card .rs-summary-card .summary-table {
    width: 100%;
    border-collapse: collapse;
    flex: 1 1 auto;
}
.result-sheet.report-card .rs-summary-card .summary-table td {
    padding: 3.5px 9px;
    font-size: 10.5px;
    line-height: 1.35;
    border-bottom: 1px solid #f1f5f9;
}
.result-sheet.report-card .rs-summary-card .summary-table td.rs-lbl {
    font-weight: 600;
    color: #475569;
}
.result-sheet.report-card .rs-summary-card .summary-table td.rs-val {
    font-weight: 800;
    text-align: right;
    color: #0f172a;
}
.result-sheet.report-card .rs-summary-card .summary-table tr.rs-final td {
    background: #f8fafc;
    border-top: 1px solid #0f172a;
    font-weight: 900;
}
.result-sheet.report-card .rs-summary-card .summary-table tr.rs-highlight td {
    background: #f8fafc;
    font-weight: 800;
}

/* KPI Metrics Dashboard (renders when domain ratings are empty) */
.result-sheet.report-card .rs-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    align-content: center;
}
.result-sheet.report-card .rs-kpi-tile {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    padding: 5px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.result-sheet.report-card .rs-kpi-lbl {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: .05em;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.result-sheet.report-card .rs-kpi-val {
    font-size: 14px;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.1;
}
.result-sheet.report-card .rs-kpi-val.rs-kpi-grd {
    font-size: 18px;
    color: #0f172a;
}
.result-sheet.report-card .rs-kpi-val.rs-kpi-pct {
    font-size: 16px;
    color: #0f172a;
}
.result-sheet.report-card .rs-kpi-val.rs-kpi-rmk {
    font-size: 12.5px;
    font-weight: 800;
    color: #0f172a;
}

/* Domain Ratings Strip & Box */
.result-sheet.report-card .rs-domain-side-wrap {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}
.result-sheet.report-card .rs-domains-strip {
    border: 1px solid #0f172a;
    border-radius: 4px;
    background: #ffffff;
    padding: 6px 10px;
    height: 100%;
    box-sizing: border-box;
}
.result-sheet.report-card .rs-domains-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.result-sheet.report-card .rs-domain-box {
    display: flex;
    flex-direction: column;
}
.result-sheet.report-card .rs-domain-heading {
    font-size: 8.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #374151;
    margin-bottom: 2px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 1px;
}
.result-sheet.report-card .rs-domain-items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 12px;
}
.result-sheet.report-card .rs-trait-pill {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    font-size: 8.5px;
    line-height: 1.3;
    padding: 1.5px 2px;
    border-bottom: 1px dotted #e2e8f0;
    min-width: 0;
}
.result-sheet.report-card .rs-trait-pill .pill-lbl {
    color: #4b5563;
    font-weight: 500;
}
.result-sheet.report-card .rs-trait-pill .pill-val {
    font-weight: 700;
    color: #111827;
    text-align: right;
}

/* Mid-term summary strip */
.result-sheet.report-card .rs-summary {
    display: grid;
    grid-template-columns: 225px minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    margin-bottom: 8px;
}
.result-sheet.report-card .rs-summary .summary-box {
    padding: 0;
    border: 1px solid #0f172a;
    border-radius: 4px;
    overflow: hidden;
}
.result-sheet.report-card .rs-summary .summary-title {
    background: #0f172a;
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 3.5px 6px;
    text-align: center;
    border: 0;
}
.result-sheet.report-card .rs-summary .summary-table td {
    padding: 3px 8px;
    font-size: 10px;
}
.result-sheet.report-card .rs-summary .summary-highlight,
.result-sheet.report-card .rs-summary .summary-final-result {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    padding: 8px 12px;
    text-align: center;
}
.result-sheet.report-card .rs-summary .summary-caption {
    font-size: 9px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 2px;
}
.result-sheet.report-card .rs-summary .summary-score-badge {
    font-size: 17px;
    font-weight: 900;
    color: #0f172a;
}
.result-sheet.report-card .rs-summary .summary-grade {
    font-size: 24px;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.1;
}
.result-sheet.report-card .rs-summary .summary-remark {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
}

/* 6. Keys to Grading Single-Line Strip */
.result-sheet.report-card .rs-grading-key {
    font-size: 9px;
    line-height: 1.35;
    padding: 3px 8px;
    margin-bottom: 7px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    text-align: center;
    color: #334155;
}
.result-sheet.report-card .rs-key-title {
    font-weight: 800;
    margin-right: 4px;
    color: #0f172a;
    letter-spacing: .04em;
}
.result-sheet.report-card .rs-key-item {
    display: inline-block;
    margin: 0 4px;
}
.result-sheet.report-card .rs-key-item strong {
    color: #0f172a;
}

/* Promotion Status Badge */
.result-sheet.report-card .rs-promotion {
    padding: 3px 10px;
    margin-bottom: 7px;
    border-radius: 4px;
    text-align: center;
    font-size: 9.5px;
    font-weight: 800;
}
.result-sheet.report-card .rs-promotion.is-promoted {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}
.result-sheet.report-card .rs-promotion.is-held {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

/* 7. Side-by-Side Official Endorsements (Comments + Signatures) */
.result-sheet.report-card .rs-endorsements {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 7px;
}
.result-sheet.report-card .endorsement-card {
    border: 1px solid #0f172a;
    border-radius: 4px;
    padding: 7px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #ffffff;
    min-height: 104px;
}
.result-sheet.report-card .endorsement-header {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 3px;
    margin-bottom: 4px;
}
.result-sheet.report-card .endorsement-title {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #0f172a;
}
.result-sheet.report-card .endorsement-comment {
    font-size: 11px;
    line-height: 1.4;
    color: #1e293b;
    flex: 1 1 auto;
    margin-bottom: 6px;
    min-height: 26px;
}
.result-sheet.report-card .endorsement-sign-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.result-sheet.report-card .endorsement-sign-block .sig-ink {
    min-height: 40px;
    height: 40px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
}
.result-sheet.report-card .endorsement-sign-block .signature-image {
    max-height: 40px;
    max-width: 160px;
    object-fit: contain;
    background: transparent !important;
    mix-blend-mode: multiply;
}
.result-sheet.report-card .endorsement-sign-block .stamp-image {
    max-height: 38px;
    max-width: 65px;
    object-fit: contain;
}
.result-sheet.report-card .endorsement-sign-block .sig-line {
    width: 80%;
    border-top: 1px solid #0f172a;
    margin: 2px auto;
}
.result-sheet.report-card .endorsement-sign-block .sig-details {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.result-sheet.report-card .endorsement-sign-block .sig-name {
    font-size: 10.5px;
    font-weight: 800;
    line-height: 1.2;
    color: #0f172a;
}
.result-sheet.report-card .endorsement-sign-block .sig-role {
    font-size: 8.5px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* 8. Policy Footer & Verification Bar */
.result-sheet.report-card .rs-footer-bar {
    border-top: 1px solid #cbd5e1;
    padding-top: 4px;
    margin-top: 5px;
}
.result-sheet.report-card .rs-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.result-sheet.report-card .rs-footer-text {
    flex: 1 1 auto;
    font-size: 8.5px;
    line-height: 1.3;
    color: #64748b;
}
.result-sheet.report-card .report-school-footer {
    font-weight: 700;
    color: #0f172a;
    margin-top: 1px;
}
.result-sheet.report-card .rs-verify {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.result-sheet.report-card .rs-verify .qr-box svg,
.result-sheet.report-card .rs-verify .qr-box img {
    width: 32px;
    height: 32px;
    display: block;
}
.result-sheet.report-card .rs-verify-text {
    font-size: 8px;
    line-height: 1.2;
    color: #475569;
}
.result-sheet.report-card .rs-verify-text strong {
    display: block;
    font-size: 8.5px;
    color: #0f172a;
}

/* Dense auto-scaling for long subject lists (16+ subjects) */
.result-sheet.report-card.long-subject-list .exam-table th,
.result-sheet.report-card.long-subject-list .exam-table td {
    padding: 2px 4px;
    font-size: 9px;
    line-height: 1.15;
}
.result-sheet.report-card.long-subject-list .sheet-header-block {
    padding-bottom: 4px;
    margin-bottom: 4px;
}
.result-sheet.report-card.long-subject-list .endorsement-card {
    min-height: 76px;
    padding: 4px 8px;
}
.result-sheet.report-card.long-subject-list .endorsement-sign-block .sig-ink {
    min-height: 30px;
    height: 30px;
}
.result-sheet.report-card.long-subject-list .endorsement-sign-block .signature-image {
    max-height: 30px;
}

/* 9. PRINT OVERRIDES: Guaranteed Single Page on Standard Paper */
@media print {
    html, body {
        width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .app-shell, .main {
        display: block !important;
        width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }
    .main > * {
        margin-bottom: 0 !important;
    }
    .sheet-toolbar, .no-print, .hr, .report-nav, .report-filter, .report-context,
    .topbar, .sidebar, header.topbar, nav, .alert, .skip-link, .sticky-action-bar, .guide-box,
    .ward-switcher, .report-progress, .report-acknowledge, .toast-region, dialog {
        display: none !important;
    }
    .result-sheet.report-card {
        width: 100% !important;
        max-width: 190mm !important;
        min-width: 0 !important;
        margin: 0 auto !important;
        padding: 4.5mm 6.5mm !important;
        border: 1.5px solid #0f172a !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        page-break-before: avoid !important;
        break-before: avoid !important;
        overflow: hidden !important;
        zoom: var(--rs-print-zoom, 1);
    }
    .report-batch-sheet {
        width: 100% !important;
        max-width: 192mm !important;
        margin: 0 auto !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: always !important;
        break-after: page !important;
    }
    .report-batch-sheet:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }
}

/* Excel score-grid helpers */
.score-input.is-invalid-score {
    border-color: var(--danger, #dc2626) !important;
    background: rgba(220, 38, 38, 0.08) !important;
    color: var(--danger, #dc2626) !important;
}
.score-total.is-over-max {
    color: var(--danger, #dc2626);
    font-weight: 700;
}
.grid-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: var(--radius);
    background: var(--panel-soft);
    border: 1px solid var(--line);
    font-size: 13px;
}
#score-grid-form .table-wrap table[data-paste-grid] th:nth-child(2),
#score-grid-form .table-wrap table[data-paste-grid] td:nth-child(2),
.score-sheet-table-simple[data-paste-grid] th:nth-child(3),
.score-sheet-table-simple[data-paste-grid] td:nth-child(3),
.score-sheet-table-simple:not([data-paste-grid]) th:nth-child(2),
.score-sheet-table-simple:not([data-paste-grid]) td:nth-child(2) {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
}
#score-grid-form .table-wrap table[data-paste-grid] th:nth-child(2),
.score-sheet-table-simple[data-paste-grid] th:nth-child(3),
.score-sheet-table-simple:not([data-paste-grid]) th:nth-child(2) {
    background: var(--panel-soft);
    z-index: 3;
}

/* ==========================================================================
   23. CARDS STACK: every card gets the full width of the page
   Cards used to sit two or three across, which squeezed their forms and tables. A grid that holds
   cards is now one column; small stat tiles (.stat) keep their compact multi-column grid.
   ========================================================================== */
.main .grid:has(> .card, > .form-card, > section, > details, > .note-box, > article) { grid-template-columns: minmax(0, 1fr); }
.main .grid:has(> .stat) { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.main .grid:has(> .card, > .form-card) > .card, .main .grid:has(> .card, > .form-card) > .form-card { width: 100%; }
/* two-column form rows inside a full-width card are fine; a long chart should not stretch to an enormous height */
.main .chart-cards .chart, .main .card .chart { max-height: 340px; }
