:root {
    --brand-navy: #0b1120;
    --brand-dark: #0f1b3d;
    --brand: #16224f;
    --brand-blue: #2563eb;
    --brand-blue-light: #60a5fa;
    --accent: #38bdf8;
    --gold: #c9962f;
    --gold-light: #e8b94d;
    --radius: 12px;
    --border: #e6e9f2;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --shadow-md: 0 6px 20px rgba(15,23,42,.08);
    --shadow-lg: 0 14px 34px rgba(15,23,42,.14);
    --ease: cubic-bezier(.16,1,.3,1);
}

body {
    background-color: #f1f4f9;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ---------- Sidebar (dark theme, restored) ---------- */
.sidebar {
    min-height: 100vh;
    background: var(--brand-dark);
    color: #fff;
    flex-shrink: 0;   /* fixed width: wide page content must never squeeze the menu */
}

/* ---------- Desktop and tablet: the menu stays in place while only the page scrolls ----------
   If the menu is taller than the window (the Headmaster's is), it scrolls inside itself, so every item
   can always be reached, however far down the page is. Phones use the slide-in drawer below. */
@media (min-width: 768px) {
    .sidebar {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,.25) transparent;
    }
    .sidebar::-webkit-scrollbar { width: 6px; }
    .sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 6px; }
}

/* ---------- Mobile: sidebar becomes a slide-in drawer ---------- */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 250px;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform .25s ease;
        overflow-y: auto;
    }
    .sidebar.show { transform: translateX(0); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility 0s linear .25s;
    }
    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
        transition: opacity .25s ease, visibility 0s linear 0s;
    }
    main { width: 100%; }
}
.sidebar .brand {
    padding: 1.1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand img { flex: none; width: 42px; height: 42px; margin-right: .6rem; border-radius: 50%; object-fit: cover; }
.sidebar a.nav-link {
    color: rgba(226,232,255,.78);
    padding: .55rem .9rem;
    border-radius: 8px;
    margin: 2px 10px;
    font-size: .93rem;
    transition: background .15s ease, color .15s ease;
}
.sidebar a.nav-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.sidebar a.nav-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    font-weight: 600;
}
.sidebar .nav-section {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .08em;
    color: rgba(165,180,252,.6);
    padding: .9rem 1.1rem .25rem;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: .7rem 1.2rem;
}
.crumbs { display: flex; align-items: center; gap: .5rem; min-width: 0; font-size: .85rem; color: #64748b; }
.crumbs strong { color: #0f172a; font-weight: 600; white-space: nowrap; }
.crumbs-root { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.crumbs-sep { font-size: .65rem; opacity: .7; }
@media (max-width: 767.98px) { .crumbs-root, .crumbs-sep { display: none; } .crumbs strong { font-size: 1rem; } }
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--brand-blue);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
    letter-spacing: .02em;
    flex-shrink: 0;
}
.user-avatar-img {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.profile-photo-lg {
    width: 96px; height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 4px 14px rgba(15,23,42,.2);
}

.role-pill {
    display: inline-block;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: var(--gold);
    background: rgba(201,150,47,.12);
    border: 1px solid rgba(201,150,47,.3);
    padding: .1rem .5rem;
    border-radius: 20px;
}

.stat-tile {
    position: relative;
    height: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    transition: border-color .15s ease;
}
.stat-tile:hover { border-color: #c7d2e6; }
.stat-tile-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.stat-tile-label { font-size: .76rem; font-weight: 600; color: #64748b; letter-spacing: .02em; text-decoration: none; }
.stat-tile-ico {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
/* one soft tint per card, chosen by what the card counts (waiting = amber, approved = green, as on the status chips) */
.stat-tile-ico--blue   { background: #e8effd; color: #2563eb; }
.stat-tile-ico--purple { background: #eee9fa; color: #6d4bc4; }
.stat-tile-ico--navy   { background: #e7eaf3; color: #0f1b3d; }
.stat-tile-ico--teal   { background: #dff3f1; color: #0f766e; }
.stat-tile-ico--amber  { background: #fdf0e1; color: #b45309; }
.stat-tile-ico--green  { background: #e3f4e9; color: #15803d; }
.stat-tile-value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; color: #0f172a; margin: .5rem 0 .25rem; font-variant-numeric: tabular-nums; }
.stat-tile-sub { font-size: .78rem; color: #64748b; }
.stat-tile--attention .stat-tile-sub { color: #b45309; font-weight: 600; }

/* ---------- Recent Activities list ---------- */
.activity-list { display: flex; flex-direction: column; gap: .1rem; max-height: 360px; overflow-y: auto; }
.activity-row {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .2rem;
    border-bottom: 1px solid #f0f2f7;
}
.activity-row:last-child { border-bottom: none; }
.activity-icon {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem;
}
.icon-blue   { background: #e8effd; color: #2563eb; }
.icon-navy   { background: #e7eaf3; color: #0f1b3d; }
.icon-purple { background: #eee9fa; color: #6d4bc4; }
.icon-cyan   { background: #e1f3f8; color: #0b7a93; }
.icon-orange { background: #fdf0e1; color: #b45309; }
.icon-green  { background: #e3f4e9; color: #15803d; }
.icon-red    { background: #fde8e8; color: #b91c1c; }

/* ---------- Students-by-class legend ---------- */
.legend-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    margin-right: .45rem;
}

/* ---------- Quick Actions ---------- */
/* minmax(0, 1fr): a long label wraps inside its column instead of pushing the grid past the card */
.qa-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .75rem; }
.qa-list--single { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 575.98px) { .qa-list { grid-template-columns: minmax(0, 1fr); } }
.qa-row {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px;
    color: #1e293b; text-decoration: none; font-size: .9rem; font-weight: 500;
    transition: border-color .15s ease, background .15s ease;
}
.qa-row:hover { background: #f7f9fc; border-color: #c7d2e6; color: #0f172a; }
.qa-ico {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #eef2fa; color: var(--brand-blue); font-size: 1rem;
}
.qa-go { margin-left: auto; font-size: .75rem; color: #94a3b8; }

/* ---------- Toast notifications (replaces long-lived flash banners) ---------- */
.toast-stack {
    position: fixed;
    top: 78px;
    right: 18px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: 340px;
}
@media (max-width: 767.98px) {
    .toast-stack { top: auto; bottom: 18px; right: 12px; left: 12px; max-width: none; }
}
.app-toast {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand-blue);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: .7rem .9rem;
    font-size: .87rem;
    color: #1e293b;
    animation: toastIn .3s var(--ease) both;
}
.app-toast.toast-leaving { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(24px); } }
.app-toast i { font-size: 1.05rem; flex-shrink: 0; }
.app-toast span { flex-grow: 1; }
.app-toast-close {
    background: none; border: none; color: #94a3b8; font-size: 1.1rem; line-height: 1;
    padding: 0 0 0 .4rem; cursor: pointer;
}
.app-toast-success, .app-toast-info { border-left-color: #16a34a; }
.app-toast-success i, .app-toast-info i { color: #16a34a; }
.app-toast-danger { border-left-color: #dc2626; }
.app-toast-danger i { color: #dc2626; }
.app-toast-warning { border-left-color: #f97316; }
.app-toast-warning i { color: #f97316; }

/* ---------- App-styled confirmation modal (replaces native confirm()) ---------- */
.app-confirm-modal { border: none; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-lg); }
.app-confirm-modal .modal-header { border-bottom: 1px solid var(--border); }
.app-confirm-modal .modal-title i { color: #f97316; font-size: 1.1rem; }
.app-confirm-modal .modal-body { font-size: .92rem; color: #334155; }
.app-confirm-modal .modal-footer { border-top: 1px solid var(--border); }

/* ---------- Clean tables: Students, Users, Classes, Examinations, Review & Approval ---------- */
.tbl-clean thead th {
    background: #f8fafc; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: #94a3b8; padding: .65rem 1rem; border-width: 0 0 1px; border-bottom: 1px solid var(--border);
}
.tbl-clean tbody td { padding: .7rem 1rem; border-width: 1px 0 0; border-style: solid; border-color: #eef1f6; vertical-align: middle; color: #1e293b; }
.tbl-clean tbody tr:first-child td { border-top-width: 0; }
.tbl-clean tbody tr:hover { background: #fafbfd; }
.person { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.person-av {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: #e8effd; color: #2563eb; font-size: .72rem; font-weight: 700;
}
.person-av img { width: 100%; height: 100%; object-fit: cover; }
.person-name { font-weight: 600; color: #0f172a; line-height: 1.25; }
.person-sub { font-size: .76rem; color: #64748b; }
.cell-muted { color: #64748b; font-variant-numeric: tabular-nums; font-size: .88rem; }
/* row actions: quiet grey icons that take their colour when touched */
.acts { display: flex; justify-content: flex-end; align-items: center; gap: .15rem; }
.ibtn {
    width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent;
    display: inline-flex; align-items: center; justify-content: center;
    color: #64748b; font-size: 1rem; line-height: 1; text-decoration: none; cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.ibtn:hover, .ibtn:focus-visible { background: #eef2fa; color: #2563eb; }
.ibtn-danger:hover, .ibtn-danger:focus-visible { background: #fee2e2; color: #b91c1c; }
.ibtn-ok:hover, .ibtn-ok:focus-visible { background: #dcfce7; color: #15803d; }
.ibtn.is-disabled { opacity: .35; cursor: not-allowed; }
.ibtn.is-disabled:hover { background: transparent; color: #64748b; }
.chip {
    display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
    padding: .24rem .65rem; border-radius: 50rem; font-size: .74rem; font-weight: 600;
    background: #eef1f6; color: #475569;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip--ok   { background: #dcfce7; color: #166534; }
.chip--off  { background: #eef1f6; color: #64748b; }
.chip--warn { background: #fef3c7; color: #92400e; }
.role-tag { display: inline-block; padding: .24rem .6rem; border-radius: 6px; font-size: .74rem; font-weight: 600; }
.role-tag--head    { background: #e7eaf3; color: #0f1b3d; }
.role-tag--admin   { background: #eee9fa; color: #5b3fb0; }
.role-tag--teacher { background: #e8effd; color: #1d4ed8; }
.tbl-tools { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.tbl-search { position: relative; flex: 1 1 260px; max-width: 360px; }
.tbl-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.tbl-search .form-control { padding-left: 2.2rem; }

/* ---------- Page header (date, title, short description, actions) ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.4rem; }
.page-eyebrow { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: #64748b; margin-bottom: .3rem; }
.page-eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-blue); }
.page-title { font-size: 1.65rem; font-weight: 700; color: #0f172a; margin: 0; letter-spacing: -.01em; }
.page-sub { margin: .25rem 0 0; font-size: .88rem; color: #64748b; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-head-main { min-width: 0; }
.d-flex > .page-head { margin-bottom: 0; }
@media print { .page-eyebrow { display: none; } }

/* ---------- Panel cards (title row with a small label above) ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.panel-eyebrow { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #94a3b8; }
.panel-title { font-size: 1.02rem; font-weight: 600; color: #0f172a; margin: .15rem 0 0; }
.panel-note { font-size: .78rem; color: #94a3b8; margin: .2rem 0 0; }
.attn-list { display: flex; flex-direction: column; }
.attn-row { display: flex; align-items: center; gap: .9rem; padding: .75rem 0; border-top: 1px solid var(--border); }
.attn-row:first-child { border-top: 0; padding-top: 0; }
.attn-row:last-child { padding-bottom: 0; }
.attn-main { min-width: 0; flex: 1; }
.attn-title { font-size: .93rem; font-weight: 600; color: #0f172a; }
.attn-sub { font-size: .8rem; color: #64748b; }
@media (max-width: 575.98px) { .attn-row { flex-wrap: wrap; } .attn-main { flex-basis: 100%; } }

/* ---------- Empty-state icon (small inline SVG, no external image) ---------- */
.empty-state { text-align: center; padding: 2rem 1rem; color: #94a3b8; }
.empty-state svg { width: 56px; height: 56px; margin-bottom: .6rem; opacity: .55; }
.empty-state .msg { font-size: .87rem; }

/* ---------- Subject-Class assignment tick-box (styled toggle button, same single-click-save behaviour) ---------- */
.subject-toggle {
    width: 30px; height: 30px;
    border-radius: 7px;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    color: transparent;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .95rem;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s ease;
}
.subject-toggle:hover { border-color: var(--brand-blue); transform: translateY(-1px); }
.subject-toggle.checked {
    background: linear-gradient(135deg, #16a34a, #4ade80);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 8px rgba(22,163,74,.3);
}
.subject-toggle:active { transform: scale(.9); }

.card { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: none; }
.card-header {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    background: #fafbfd !important;
    border-bottom: 1px solid var(--border) !important;
    padding: .7rem 1.1rem;
}
.table thead th { background: #f4f6fb; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #4b5563; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background-color: #f4f6fb; }

/* Marks entry grid: fixed layout so every subject column (and its input
   box) is the same width, regardless of how short/long the subject name
   is (e.g. "Dini" vs "Science and Technology"). */
.marks-table { table-layout: fixed; width: 100%; }
.marks-table th, .marks-table td { overflow-wrap: break-word; }
.marks-table .score-input { width: 100%; min-width: 0; }

.btn { transition: background-color .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-success {
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-blue-light));
    background-size: 160% 100%;
    background-position: 0% 0%;
    border-color: var(--brand-blue);
    transition: background-position .35s ease, transform .12s ease, box-shadow .15s ease;
}
.btn-success:hover, .btn-success:focus {
    background-position: 100% 0%;
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37,99,235,.28);
}
.btn-outline-success {
    color: var(--brand-blue);
    border-color: var(--brand-blue);
}
.btn-outline-success:hover {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
}
a { color: var(--brand-blue); }
a:focus-visible, button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-blue-light);
    box-shadow: 0 0 0 .2rem rgba(37,99,235,.15);
}

/* ---------- Page-load motion: one quiet, consistent moment on every page,
   instead of scattered fade-ins on individual elements. ---------- */
@media (prefers-reduced-motion: no-preference) {
    /* 'backwards' (not 'both'): after the animation ends the page must NOT keep the final
       transform. A leftover transform traps every Bootstrap modal inside the page, under its
       own backdrop, so the dialog opens but nothing in it can be clicked or typed into. */
    .page-enter { animation: pageEnter .35s var(--ease) backwards; }
}
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Grade badges ---------- */
.grade-badge {    display: inline-block;
    min-width: 34px;
    padding: .25rem .5rem;
    border-radius: 6px;
    font-weight: 700;
    color: #fff;
    text-align: center;
}
.grade-A { background-color: #16a34a; }
.grade-B { background-color: #2563eb; }
.grade-C { background-color: #f59e0b; color: #333; }
.grade-D { background-color: #f97316; }
.grade-E { background-color: #dc2626; }
.grade-\- { background-color: #6c757d; }

.badge-gender-Male { background-color: #2563eb; }
.badge-gender-Female { background-color: #db2777; }
.badge-gender-Unknown { background-color: #6c757d; }

/* ---------- Class card mini gender-count chips (students.html) ---------- */
.class-gender-chip { font-weight: 600; font-size: .72rem; padding: .32rem .55rem; }
.class-gender-chip i { font-size: .5rem; vertical-align: 1px; }
.class-gender-chip--boys { background: #e6f0ff; color: #2563eb; }
.class-gender-chip--girls { background: #fde6f1; color: #db2777; }
html[data-theme="dark"] .class-gender-chip--boys { background: #16345e; color: #93c5fd; }
html[data-theme="dark"] .class-gender-chip--girls { background: #4a1030; color: #f4a6d0; }

/* Result status chips: soft tint with a small dot, the same on every page */
.badge[class*="status-badge-"] {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .7rem; border-radius: 50rem;
    font-size: .76rem; font-weight: 600; letter-spacing: 0;
    background: #eef1f6; color: #475569;
}
.badge[class*="status-badge-"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.status-badge-draft { background: #eef1f6; color: #475569; }
.badge.status-badge-submitted { background: #fef3c7; color: #92400e; }
.badge.status-badge-under_review { background: #dbeafe; color: #1e40af; }
.badge.status-badge-approved { background: #dcfce7; color: #166534; }
.badge.status-badge-returned { background: #fee2e2; color: #991b1b; }

/* ---------- Soft "chip" grade badges (light bg + colour text, like the
   boys/girls count chips on Class cards) - used on Performance Analytics
   where a full solid-fill badge is too heavy, e.g. the big "Average
   Grade" stat and inline grade labels. ---------- */
.grade-chip {
    display: inline-block;
    font-weight: 700;
    font-size: .8rem;
    padding: .32rem .7rem;
    border-radius: 50rem;
}
.grade-chip-A { background: #dcfce7; color: #16a34a; }
.grade-chip-B { background: #dbeafe; color: #2563eb; }
.grade-chip-C { background: #fef3c7; color: #b45309; }
.grade-chip-D { background: #ffedd5; color: #ea580c; }
.grade-chip-E { background: #fee2e2; color: #dc2626; }
.grade-chip-\- { background: #e2e8f0; color: #6c757d; }
html[data-theme="dark"] .grade-chip-A { background: #123524; color: #4ade80; }
html[data-theme="dark"] .grade-chip-B { background: #16345e; color: #93c5fd; }
html[data-theme="dark"] .grade-chip-C { background: #3a2e0c; color: #fbbf24; }
html[data-theme="dark"] .grade-chip-D { background: #3a1f0c; color: #fb923c; }
html[data-theme="dark"] .grade-chip-E { background: #3a1212; color: #f87171; }
html[data-theme="dark"] .grade-chip-\- { background: #1e293b; color: #94a3b8; }

/* Small circular "duara" counters for A/B/C/D/E counts in the Grade
   Distribution table - each grade keeps its own solid background colour. */
.grade-count-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 700;
    font-size: .9rem;
    color: #fff;
}
/* No students in this grade: keep the circle so the row stays aligned, but
   dim it so real counts stand out. */
.grade-count-circle.is-zero { opacity: .28; }
.grade-count-circle.grade-dot-A { background: #16a34a; }
.grade-count-circle.grade-dot-B { background: #2563eb; }
.grade-count-circle.grade-dot-C { background: #f59e0b; color: #33291a; }
.grade-count-circle.grade-dot-D { background: #f97316; }
.grade-count-circle.grade-dot-E { background: #dc2626; }

/* Small grey caption above a figure (Class Average / Average Grade / Top Subjects / Class Ranking).
   One quiet style for all of them; the --blue/--green/--amber/--purple names in the pages are kept
   but no longer change the colour, so these captions do not read as a rainbow of pills. */
.stat-label-chip {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: #64748b;
    margin-bottom: .35rem;
}
/* The few chips that set their own colour in the page (Highest / Lowest average, Subjects needing
   attention) keep the original pill shape, so only the colour-less ones turn into quiet captions. */
.stat-label-chip[style] {
    font-size: .72rem;
    letter-spacing: .02em;
    padding: .3rem .65rem;
    border-radius: 50rem;
    margin-bottom: .4rem;
}

/* Small circular position/rank badge for the class leaderboard. */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 .3rem;
    border-radius: 50%;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    font-size: .78rem;
}
.rank-badge--gold { background: #fef3c7; color: #b45309; }
html[data-theme="dark"] .rank-badge { background: #2e1f4d; color: #c4b5fd; }
html[data-theme="dark"] .rank-badge--gold { background: #3a2e0c; color: #fbbf24; }

/* ---------- Password show/hide toggle (login form etc.) ---------- */
.password-input-group { position: relative; }
.password-input-group input { padding-right: 2.4rem; }
.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: .55rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: .15rem;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
}
.password-toggle-btn:hover { color: #2563eb; }

/* ---------- Report / print ---------- */
.report-sheet {
    background: #fff;
    padding: 10mm;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-width: 210mm;
    margin: 0 auto;
}
.report-sheet .table-responsive { overflow-x: auto; }
.report-header { text-align: center; border-bottom: 3px solid var(--brand-blue); padding-bottom: 10px; margin-bottom: 20px; }
.report-header img { height: 70px; }
.report-header h2 { margin: .3rem 0 0; color: var(--brand-dark); font-weight: 800; letter-spacing: .03em; }
.report-header p { margin: 0; color: #555; }

.grade-text-A { color: #16a34a; font-weight: 700; }
.grade-text-B { color: #2563eb; font-weight: 700; }
.grade-text-C { color: #b45309; font-weight: 700; }
.grade-text-D { color: #ea580c; font-weight: 700; }
.grade-text-E { color: #dc2626; font-weight: 700; }
.grade-text-\- { color: #6c757d; font-weight: 700; }

/* ---------------------------------------------------------------------
   Official letterhead-style report card (matches the school's requested
   layout: logo + centered title + academic-year badge + info panel,
   navy header table, and a signed/stamped footer).
--------------------------------------------------------------------- */
:root {
    --report-navy: #1b2a4e;
}
.kps-sheet {
    background: #fff;
    border: 1.5px solid var(--report-navy);
    border-radius: 6px;
    padding: 8mm 9mm;
    max-width: 210mm;
    margin: 0 auto;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #1a1a1a;
    line-height: 1.45;
}
.kps-header-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.kps-header-top .logo-col img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.kps-header-top .center-col { flex: 1; text-align: center; padding-top: 4px; }
.kps-header-top .center-col h1 {
    font-size: 1.45rem; font-weight: 800; color: var(--report-navy);
    margin: 0; letter-spacing: .01em; line-height: 1.15;
}
.kps-header-top .center-col .subtitle {
    font-size: 1.05rem; font-weight: 700; color: var(--report-navy);
    margin: 4px 0 10px;
}
.kps-header-top .center-col .academic-badge {
    display: inline-block; background: var(--report-navy); color: #fff;
    padding: 5px 16px; border-radius: 5px; font-weight: 700;
    font-size: .8rem; letter-spacing: .03em;
}

.kps-info-wrap {
    display: flex;
    justify-content: flex-start;
    border-bottom: 2px solid var(--report-navy);
    padding-bottom: 12px;
    margin: 10px 0 16px;
}
.kps-info-box { min-width: 230px; font-size: .88rem; }
.kps-info-box .kps-info-row { display: flex; flex-wrap: nowrap; align-items: baseline; margin-bottom: 6px; }
.kps-info-box .kps-info-row .k { font-weight: 700; color: #222; }
.kps-info-box .kps-info-row .sep { margin: 0 5px; color: #222; }
.kps-info-box .kps-info-row .v { font-weight: 600; color: #000; }

.kps-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.kps-table th {
    background: var(--report-navy); color: #fff;
    padding: 10px 9px; font-size: .85rem; text-transform: uppercase;
    letter-spacing: .02em; text-align: left;
}
.kps-table td { padding: 9px; border: 1px solid #ccc; font-size: .95rem; }
.kps-table th.center, .kps-table td.center { text-align: center; }
.kps-table tbody tr:nth-child(even) { background: #f7f8fb; }

.kps-remarks { font-size: .9rem; margin-bottom: 14px; }
.kps-remarks .k { font-weight: 700; color: var(--report-navy); }
.kps-remarks .box { border: 1px solid #ccc; border-radius: 4px; padding: 8px 10px; margin-top: 4px; min-height: 55px; }

.kps-footer {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-top: 26px; border-top: 1px solid #ddd; padding-top: 18px;
}
.kps-footer .sign-col { width: 30%; text-align: center; }
.kps-footer .sign-line { border-top: 1px dotted #333; margin-top: 46px; padding-top: 5px; font-weight: 700; font-size: .82rem; color: var(--report-navy); }
.kps-footer .sign-date { font-size: .74rem; color: #666; margin-top: 3px; }
.kps-footer .stamp-col { width: 30%; text-align: center; }
.kps-footer .stamp-circle {
    width: 100px; height: 100px; border: 2px dashed #99a;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    margin: 0 auto 6px; color: #8891a8; font-size: .68rem; text-align: center; padding: 6px;
}

.report-footer {
    margin-top: 50px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.report-footer .sign-box { width: 30%; text-align: center; }
.report-footer .sign-line { border-top: 1px solid #333; margin-top: 45px; padding-top: 4px; font-size: .85rem; }
.report-footer .stamp-box {
    width: 30%;
    text-align: center;
    border: 2px dashed #999;
    border-radius: 50%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: .8rem;
    margin: 0 auto;
}

/* On-screen Class Result Sheet table (review_results.html etc.) - roomier
   than the print version below: headers stay on one line (no mid-word
   wrapping like "TOT AL" / "SU MI"), comfortable padding, and the
   surrounding .table-responsive handles horizontal scrolling on classes
   with many subjects instead of squeezing every column to fit. */
.report-table th {
    white-space: nowrap;
    font-size: .78rem;
    letter-spacing: .01em;
    padding: .65rem .7rem;
}
.report-table td {
    padding: .6rem .7rem;
    white-space: nowrap;
}
.report-table td:first-child { white-space: normal; min-width: 150px; }

@media print {
    @page { size: A4 portrait; margin: 10mm; }
    @page landscapeReport { size: A4 landscape; margin: 10mm; }
    .no-print { display: none !important; }
    .sidebar, .topbar { display: none !important; }
    .report-sheet, .kps-sheet { border: none; box-shadow: none; padding: 0; max-width: 100%; }
    .report-sheet .table-responsive { overflow: visible; }
    .class-report-wrap { page: landscapeReport; }
    .report-table, .report-table th, .report-table td {
        font-size: .78rem; padding: .3rem; white-space: normal; word-break: break-word;
    }
    body { background: #fff; }
    main { margin: 0 !important; width: 100% !important; }
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-navy), var(--brand-dark) 55%, var(--brand));
    position: relative;
    overflow: hidden;
}
.login-card {
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,.06);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 18px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
    color: #eef2ff;
}
.login-card .login-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 84px; height: 84px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    margin-bottom: .85rem;
}
.login-card .login-badge img { height: 56px; width: 56px; object-fit: contain; border-radius: 10px; }
.login-card h4 { color: #fff; }
.login-card small { color: rgba(226,232,255,.65); }
.login-card .form-label { color: rgba(226,232,255,.85); font-size: .88rem; }
.login-card .form-control {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    transition: background .2s, border-color .2s, box-shadow .2s;
}
.login-card .form-control::placeholder { color: rgba(226,232,255,.45); }
.login-card .form-control:focus {
    background: rgba(255,255,255,.12);
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(56,189,248,.25);
    color: #fff;
}
.login-card .btn-success {
    background: linear-gradient(90deg, var(--brand-blue), var(--accent));
    background-size: 160% 100%;
    background-position: 0% 0%;
    border: none;
    transition: background-position .35s ease, transform .15s ease, box-shadow .25s ease;
}
.login-card .btn-success:hover {
    background-position: 100% 0%;
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37,99,235,.35);
}
.login-card .btn-success:active { transform: translateY(0); }
.login-card a { color: var(--accent); }
.login-footnote { color: rgba(226,232,255,.5); }

/* ---------- Class tools (Classes menu) ---------- */
.tool { border: 1px solid var(--border); border-radius: 10px; background: #fff; margin-bottom: .6rem; overflow: hidden; }
.tool-radio { position: absolute; opacity: 0; pointer-events: none; }
.tool-head { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; margin: 0; cursor: pointer; font-weight: 600; font-size: .92rem; min-height: 44px; }
.tool-head::before { content: ""; flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #94a3b8; background: #fff; }
.tool-radio:checked + .tool-head { background: #f3f6fd; }
.tool-radio:checked + .tool-head::before { border-color: var(--brand-blue); background: radial-gradient(circle, var(--brand-blue) 45%, #fff 50%); }
.tool-radio:focus-visible + .tool-head { outline: 2px solid var(--brand-blue); outline-offset: -2px; }
.tool--danger .tool-radio:checked + .tool-head { background: #fef2f2; }
.tool--danger .tool-radio:checked + .tool-head::before { border-color: #dc2626; background: radial-gradient(circle, #dc2626 45%, #fff 50%); }
.tool-body { display: none; padding: .25rem 1rem 1rem; }
.tool-radio:checked ~ .tool-body { display: block; }
.tool-check { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; font-size: .9rem; min-width: 0; }
.tool-check span { min-width: 0; overflow-wrap: anywhere; }
.tool-check small { margin-left: auto; color: #64748b; white-space: nowrap; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.plan-list li:last-child { border-bottom: 0; }
.plan-list strong { font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }

/* ---------- Version line at the very bottom of every signed-in page ---------- */
.app-footer { margin-top: auto; padding: .85rem 1.5rem; border-top: 1px solid var(--border); text-align: center; font-size: .78rem; color: #94a3b8; }
@media print { .app-footer { display: none; } }

/* ---------- Login page (two panels: school welcome + sign-in) ----------
   Colours: Kisauni's own navy canvas, white sign-in card, blue and sky accents.
   Three clearly separated layers, so no rule can leak into a screen size it was not written for
   (this page had that bug twice before):
   1) component styling (colours, type, cards, inputs): no layout, applies everywhere;
   2) stacked layout  (<= 991.98px: phones, tablets, Android "Desktop site" ~980px);
   3) side-by-side layout (>= 992px).
   Stacked order: logo and school name, "RESULT MANAGEMENT SYSTEM", "What you can do", "Need quick help?",
   sign-in form, copyright, developer line. */
.lp {
    color: #e2e8ff;
    background:
        radial-gradient(circle 360px at 100% 0, rgba(56,189,248,.18), transparent 70%),
        linear-gradient(135deg, var(--brand-navy), var(--brand-dark) 55%, var(--brand));
}

.lp-logo { flex: none; display: inline-block; width: 56px; height: 56px; border-radius: 50%; box-shadow: 0 8px 22px rgba(0,0,0,.4); }
.lp-logo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.lp-school { font-weight: 800; font-size: 1.05rem; line-height: 1.2; color: #fff; text-transform: uppercase; letter-spacing: .02em; }

.lp-system { margin: 0; font-weight: 800; font-size: 1rem; text-transform: uppercase; letter-spacing: .2em; line-height: 1.5; color: #fff; }

.lp-glass {
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 20px;
    padding: 1.1rem; box-shadow: 0 18px 40px -18px rgba(2,6,23,.55);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.lp-glass-title { margin: .15rem .3rem .85rem; font-size: .74rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: rgba(238,242,255,.72); }
.lp-row {
    display: flex; align-items: flex-start; gap: .85rem; margin-bottom: .6rem; padding: .75rem .9rem;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09); border-radius: 14px;
}
.lp-row:last-child { margin-bottom: 0; }
.lp-row strong { display: block; font-size: .92rem; font-weight: 700; color: #fff; }
.lp-desc { display: block; margin-top: .1rem; font-size: .82rem; line-height: 1.4; color: rgba(238,242,255,.75); }
.lp-dot { flex: none; width: 14px; height: 14px; margin-top: .22rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.18); }
.lp-num {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 12px; font-size: .82rem; font-weight: 800;
    background: rgba(56,189,248,.15); border: 1px solid rgba(56,189,248,.25); color: var(--accent);
}
.lp-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.lp-link:hover { text-decoration: underline; }
.lp-footer { font-size: .8rem; color: rgba(226,232,255,.55); }
.lp-credit { font-size: .78rem; color: rgba(226,232,255,.65); }
.lp-credit a { display: inline-block; padding: .35rem .6rem; color: inherit; text-decoration: none; }
.lp-credit a:hover, .lp-credit a:focus-visible { color: #fff; text-decoration: underline; }

.lp-card { background: #fff; color: #0f172a; border-radius: 20px; padding: 1.5rem 1.25rem; box-shadow: 0 30px 60px -16px rgba(2,6,23,.45); }
.lp-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.lp-card-title { margin: 0 0 .25rem; font-size: 1.35rem; font-weight: 800; color: var(--brand-dark); }
.lp-pill { flex: none; padding: .45rem .95rem; border-radius: 999px; background: #e8eefc; color: #1e3a8a; font-size: .8rem; font-weight: 700; }
.lp-tabs { display: flex; gap: 4px; margin: 1.15rem 0 1.1rem; padding: 5px; background: #eef2fa; border: 1px solid #e0e6f3; border-radius: 999px; }
.lp-tab {
    flex: 1; padding: .7rem .5rem; text-align: center; border-radius: 999px;
    font-size: .9rem; font-weight: 700; color: #1e3a8a; text-decoration: none;
}
a.lp-tab:hover { background: rgba(37,99,235,.08); text-decoration: none; }
.lp-tab.is-active { color: #fff; background: linear-gradient(90deg, var(--brand-blue), var(--accent)); box-shadow: 0 6px 14px rgba(37,99,235,.28); }
.lp-field { margin-bottom: 1rem; }
.lp-input {
    display: block; width: 100%; height: 56px; padding: 0 1rem; font-size: 1rem; color: #0f172a;
    background: #fff; border: 1px solid #d5dcea; border-radius: 8px;
}
.lp-input::placeholder { color: #475569; }
.lp-input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.lp-pass { display: flex; }
.lp-pass .lp-input { flex: 1; min-width: 0; border-radius: 8px 0 0 8px; }
.lp-pass .password-toggle-btn {
    position: static; transform: none; flex: none; width: 56px; height: 56px; padding: 0;
    justify-content: center; font-size: 1.15rem; color: #0f172a;
    background: #eef1f6; border: 1px solid #d5dcea; border-left: 0; border-radius: 0 8px 8px 0;
}
.lp-pass .password-toggle-btn:hover { color: var(--brand-blue); }
.lp-forgot { margin: -.15rem 0 1rem; text-align: right; }
.lp-forgot a { font-size: .88rem; font-weight: 700; color: var(--brand-blue); text-decoration: none; }
.lp-forgot a:hover { text-decoration: underline; }
.lp-submit {
    display: flex; align-items: center; justify-content: center; width: 100%; height: 56px; padding: 0;
    overflow: hidden; cursor: pointer; border: 0; border-radius: 14px; color: #fff;
    font-size: 1rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    background: linear-gradient(90deg, var(--brand-blue), var(--accent)); box-shadow: 0 12px 24px -8px rgba(37,99,235,.5);
    transition: transform .15s ease, filter .2s ease, box-shadow .2s ease;
}
.lp-submit:hover { filter: brightness(1.07); transform: translateY(-1px); }
.lp-submit:active { transform: translateY(0); }
.lp-submit:disabled { opacity: .85; cursor: wait; }
.lp-submit-ico { align-self: stretch; flex: none; display: flex; align-items: center; justify-content: center; width: 52px; background: rgba(15,27,61,.22); }
.lp-submit-txt { flex: 1; padding-right: 52px; text-align: center; }
.lp-divider { position: relative; margin: 1.5rem 0 .25rem; text-align: center; }
.lp-divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid #e2e8f0; }
.lp-divider span { position: relative; display: inline-block; padding: 0 .9rem; background: #fff; font-size: .82rem; color: #64748b; }

/* 2) Stacked layout: phones, tablets, and Android "Desktop site" (~980px layout viewport) */
@media (max-width: 991.98px) {
    .lp {
        min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
        justify-content: center; padding: 1.25rem 1rem 1.5rem;
    }
    /* the welcome panel's pieces take part in the page order directly */
    .lp-brand, .lp-brand-inner, .lp-cards { display: contents; }
    .lp-top, .lp-hero, .lp-glass, .lp-formside, .lp-footer, .lp-credit { width: 100%; max-width: 520px; }
    .lp-top { order: 1; display: flex; align-items: center; gap: .8rem; margin-bottom: 1.1rem; }
    .lp-hero { order: 2; margin-bottom: 1.25rem; }
    .lp-glass-features { order: 3; margin-bottom: 1.25rem; }
    .lp-glass-help { order: 4; margin-bottom: 1.25rem; }
    .lp-formside { order: 5; margin-bottom: 1.25rem; }
    .lp-footer { order: 6; margin-top: 1.5rem; text-align: center; }
    .lp-credit { order: 7; margin-top: .6rem; text-align: center; }
    .lp-card-title { text-align: center; }
    .lp-card-head { justify-content: center; }
    .lp-pill { display: none; }
}

/* Touch screens with a ~700-991px layout viewport: tablets in portrait and phones using Chrome's "Desktop site"
   (layout viewport ~980px, shrunk to fit the phone, so everything sized for 360px looks tiny). Only the SIZE of
   existing elements is raised (about 1.3x); order, colours and content are untouched. A mouse on a narrow
   window, every viewport >= 992px, and a phone held sideways (short viewport) are not affected. */
@media screen and (pointer: coarse) and (min-width: 700px) and (max-width: 991.98px) and (min-height: 640px) {
    .lp { padding: 1.5rem 1.5rem 2rem; }
    .lp-top, .lp-hero, .lp-glass, .lp-formside, .lp-footer, .lp-credit { max-width: 680px; }
    .lp-logo { width: 76px; height: 76px; }
    .lp-school { font-size: 1.5rem; }
    .lp-system { font-size: 1.3rem; }
    .lp-glass { padding: 1.5rem; }
    .lp-glass-title { font-size: .95rem; }
    .lp-row { padding: 1rem 1.15rem; }
    .lp-row strong { font-size: 1.2rem; }
    .lp-desc { font-size: 1.05rem; }
    .lp-dot { width: 18px; height: 18px; margin-top: .3rem; }
    .lp-num { width: 52px; height: 52px; font-size: 1.05rem; }
    .lp-card { padding: 1.75rem 2rem 2rem; }
    .lp-card-title { font-size: 1.85rem; }
    .lp-tab { font-size: 1.15rem; padding: .95rem .5rem; }
    .lp-input { height: 72px; font-size: 1.25rem; }
    .lp-pass .password-toggle-btn { width: 72px; height: 72px; font-size: 1.4rem; }
    .lp-forgot a { font-size: 1.1rem; }
    .lp-submit { height: 72px; font-size: 1.3rem; }
    .lp-submit-ico { width: 72px; font-size: 1.4rem; }
    .lp-submit-txt { padding-right: 72px; }
    .lp-divider span { font-size: 1.05rem; }
    .lp-footer { font-size: 1rem; }
    .lp-credit { font-size: 1rem; }
}

/* 3) Side-by-side layout: computers (>= 992px) */
@media (min-width: 992px) {
    .lp {
        min-height: 100vh; min-height: 100dvh; display: grid;
        grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: 1fr auto;
        grid-template-areas: "brand form" "brand credit";
    }
    .lp-brand { grid-area: brand; display: flex; padding: 2.25rem 2.25rem 1.75rem; }
    .lp-brand-inner { display: flex; flex-direction: column; width: 100%; max-width: 860px; }
    .lp-top { display: flex; align-items: center; gap: 1.1rem; }
    .lp-logo { width: 84px; height: 84px; }
    .lp-school { font-size: 1.75rem; line-height: 1.15; max-width: 520px; }
    .lp-hero { margin-top: 3.25rem; }
    .lp-system { font-size: clamp(1.15rem, 1.9vw, 1.75rem); letter-spacing: .2em; }
    .lp-cards { display: grid; grid-template-columns: 1fr; gap: 1.1rem; margin-top: 1.75rem; }
    .lp-glass { padding: 1.35rem; }
    .lp-footer { margin-top: auto; padding-top: 1.75rem; }
    .lp-formside { grid-area: form; display: flex; align-items: center; justify-content: center; padding: 2rem 3rem; }
    .lp-card { width: 100%; max-width: 480px; padding: 2.5rem 2.25rem; }
    .lp-card-title { font-size: 1.5rem; }
    .lp-credit { grid-area: credit; padding: 1rem 1.5rem 1.4rem; text-align: center; }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
    .lp-pill { display: none; }
    .lp-formside { padding: 2rem 2rem; }
}
@media (min-width: 1200px) {
    .lp-cards { grid-template-columns: 1fr 1fr; }
}

/* Developer sign-in (side by side): it has less text than the school login, so its left
   panel is centred vertically to line up with the sign-in card, and its single info card
   uses the full width instead of half of a two-column grid. School login is unchanged. */
@media (min-width: 992px) {
    .lp--dev .lp-brand { align-items: center; }
    .lp--dev .lp-hero { margin-top: 2.25rem; }
    .lp--dev .lp-cards { grid-template-columns: 1fr; max-width: 560px; }
    .lp--dev .lp-footer { margin-top: 2rem; }
}

/* A brief, one-time shake on the login card when the page reloads after a
   failed sign-in - a quick, unmistakable "that didn't work" signal instead
   of a static red banner alone. */
@media (prefers-reduced-motion: no-preference) {
    .login-shake { animation: loginShake .4s cubic-bezier(.36,.07,.19,.97) both; }
}
@keyframes loginShake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

/* =======================================================================
   DARK MODE
   Applies to the app chrome (sidebar, topbar, cards, tables, forms) used
   across Dashboard/Students/Records/Marks/Users/Settings etc. Printed
   report sheets (.report-sheet, .kps-sheet) are intentionally left out -
   a printed/PDF result slip should always be paper-white regardless of
   the on-screen theme, and @media print forces this below either way.
========================================================================= */
html[data-theme="dark"] body { background-color: #0b1220; color: #dbe2ef; }
html[data-theme="dark"] .sidebar { background: #101828; border-right-color: #223049; }
html[data-theme="dark"] .sidebar .brand { border-bottom-color: #223049; }
html[data-theme="dark"] .sidebar a.nav-link { color: #94a3b8; }
html[data-theme="dark"] .sidebar a.nav-link:hover { background: #17223a; color: #93c5fd; }
html[data-theme="dark"] .sidebar a.nav-link.active { background: #16345e; color: #93c5fd; border-left-color: var(--brand-blue-light); }
html[data-theme="dark"] .sidebar .nav-section { color: #55637c; }

html[data-theme="dark"] .topbar { background: #101828; border-bottom-color: #223049; }
html[data-theme="dark"] .topbar .fw-semibold { color: #e5e9f3; }

html[data-theme="dark"] .card { background: #101828; border-color: #223049; color: #dbe2ef; }
html[data-theme="dark"] .card-header { background: #17223a !important; border-bottom-color: #223049 !important; color: #dbe2ef; }
html[data-theme="dark"] .stat-card .stat-value { color: #f1f5f9; }
/* Keep each stat-card's coloured top accent showing in dark mode too -
   otherwise the generic dark .card border-color rule above would flatten
   all six back to the same dark grey border. */
html[data-theme="dark"] .stat-card.stat-card--blue   { border-top-color: #2563eb; }
html[data-theme="dark"] .stat-card.stat-card--navy   { border-top-color: #5b7fd6; }
html[data-theme="dark"] .stat-card.stat-card--purple { border-top-color: #a78bfa; }
html[data-theme="dark"] .stat-card.stat-card--cyan   { border-top-color: #38bdf8; }
html[data-theme="dark"] .stat-card.stat-card--orange { border-top-color: #f97316; }
html[data-theme="dark"] .stat-card.stat-card--green  { border-top-color: #4ade80; }

html[data-theme="dark"] .table { color: #dbe2ef; }
html[data-theme="dark"] .table thead th { background: #17223a; color: #94a3b8; }
html[data-theme="dark"] .table tbody tr:hover { background-color: #17223a; }
html[data-theme="dark"] .activity-row { border-bottom-color: #223049; }

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background-color: #17223a;
    border-color: #2a3654;
    color: #e5e9f3;
}
html[data-theme="dark"] .form-control::placeholder { color: #64748b; }
html[data-theme="dark"] .form-control:focus, html[data-theme="dark"] .form-select:focus {
    background-color: #17223a;
    color: #e5e9f3;
}
html[data-theme="dark"] .text-muted { color: #8b96ab !important; }
html[data-theme="dark"] .quick-action-tile { color: #cbd5e1; }
html[data-theme="dark"] .quick-action-tile:hover { background: #17223a; color: #fff; }
html[data-theme="dark"] .btn-outline-secondary { color: #cbd5e1; border-color: #3a4763; }
html[data-theme="dark"] .btn-close { filter: invert(1); }
html[data-theme="dark"] a:not(.btn) { color: #7fb3ff; }
html[data-theme="dark"] .app-toast { background: #17223a; border-color: #2a3654; color: #e5e9f3; }
html[data-theme="dark"] .app-toast-close { color: #64748b; }
html[data-theme="dark"] .subject-toggle { background: #17223a; border-color: #3a4763; }
html[data-theme="dark"] .app-confirm-modal { background: #101828; color: #dbe2ef; }
html[data-theme="dark"] .app-confirm-modal .modal-header,
html[data-theme="dark"] .app-confirm-modal .modal-footer { border-color: #223049; }
html[data-theme="dark"] .app-confirm-modal .modal-body { color: #cbd5e1; }
html[data-theme="dark"] .modal-backdrop { opacity: .6; }

@media print {
    html[data-theme="dark"] body { background: #fff !important; color: #000 !important; }
    html[data-theme="dark"] .report-sheet,
    html[data-theme="dark"] .kps-sheet { background: #fff !important; color: #000 !important; }
}

/* ---------- Phone fit: never let a page become wider than the screen ----------
   When anything is wider than the phone, mobile Chrome shrinks the whole page and leaves
   an empty strip on the right. These rules keep the top bar, charts and the result
   report inside the screen width. They only apply on small screens (not print). */
@media screen and (max-width: 575.98px) {
    /* top bar: menu button on the left, user on the right, and the page title on its own full-width
       line below them, so long titles never get squeezed or split in the middle of a word */
    .topbar { flex-wrap: wrap; gap: .25rem .5rem; padding: .55rem .6rem; }
    .topbar > .fw-semibold { order: 3; flex: 1 0 100%; font-size: 1.05rem; line-height: 1.25; overflow-wrap: break-word; }
    .topbar > .d-flex { flex: 1 1 0; min-width: 0; justify-content: flex-end; }
    .topbar .text-end { min-width: 0; flex: 0 1 auto; }
    .topbar .text-end > .fw-semibold { font-size: .8rem; line-height: 1.15; overflow-wrap: break-word; }
    .topbar .role-pill { font-size: .62rem; padding: .08rem .4rem; }
    canvas { max-width: 100%; }
    .kps-sheet { padding: 12px 10px; }
    .kps-header-top { gap: 8px; }
    .kps-info-box { min-width: 0; }
    .kps-table th, .kps-table td { padding: 6px 3px; font-size: .76rem; }
    .kps-table th { font-size: .66rem; letter-spacing: 0; }
    .kps-table th[style*="width"] { width: auto !important; }
    /* page title + action buttons rows (Students, Users, Marks, ...): let buttons drop below the title */
    .d-flex.justify-content-between.align-items-center.mb-3 { flex-wrap: wrap; gap: .5rem; }
    .d-flex.justify-content-between.align-items-center.mb-3 > div:not(.page-head) { display: flex; flex-wrap: wrap; gap: .4rem; }
    .d-flex.justify-content-between.align-items-center.mb-3 > div:not(.page-head) > .btn { margin-right: 0 !important; }
}

/* ---------- Phone lists: show each row as a small card instead of a wide table ----------
   Wide tables (Users, Review & Approval, Students) were cut off on the right and users had
   to scroll sideways to see Status / Submitted / Actions. On phones every row is stacked
   with its column name, so nothing is hidden. Tablets and computers keep the normal table. */
@media screen and (max-width: 575.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr { display: block; width: 100%; }
    .table-stack tr { padding: .6rem .85rem; border-bottom: 1px solid #e5e7eb; }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td {
        display: flex; justify-content: space-between; align-items: center; gap: .75rem;
        width: 100%; padding: .22rem 0 !important; border: 0 !important;
        text-align: right !important; background: transparent !important; box-shadow: none !important;
    }
    .table-stack td::before {
        content: attr(data-label); flex: 0 0 38%; text-align: left;
        font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: #64748b;
    }
    .table-stack td.stack-head { display: block; text-align: left !important; font-size: 1rem; padding-bottom: .3rem !important; }
    .table-stack td.stack-head::before, .table-stack td.stack-actions::before { content: none; }
    /* "No results submitted yet." and similar one-cell rows: no side label, so centre the message */
    .table-stack td[colspan] { justify-content: center; text-align: center !important; }
    .table-stack td[colspan]::before { content: none; }
    /* page-header buttons (Student List, Users, Classes ...): small, several per line */
    .page-actions { width: 100%; gap: .4rem; }
    main .page-actions .btn, main .page-actions .btn-sm { font-size: .8rem; padding: .28rem .7rem; min-height: 32px; }
    .table-stack td.stack-actions { justify-content: flex-start; flex-wrap: wrap; gap: .5rem; padding-top: .45rem !important; }
    html[data-theme="dark"] .table-stack tr { border-bottom-color: #223049; }
    html[data-theme="dark"] .table-stack td::before { color: #94a3b8; }
}

/* ---------- Touch comfort (phones and small tablets): easy-to-tap controls ----------
   Small buttons, inputs and the two top-bar buttons were about 31px high; 40px is much easier
   with a thumb. Only sizes change; nothing is hidden. The logout link stays pinned at the bottom
   of the menu so it is always reachable without scrolling through the whole list. */
@media screen and (max-width: 767.98px) {
    /* Comfortable, not oversized: normal buttons ~36px and small/icon buttons ~34px (were 38px / 40px). Normal buttons
       are limited to the signed-in pages and pop-ups so the login page keeps its own sizing; the top-bar menu and
       theme buttons keep their 40px (rule below). */
    main .btn:not(.btn-sm), .modal .btn:not(.btn-sm) { font-size: .9rem; padding: .4rem .9rem; }
    .btn-sm { min-height: 34px; min-width: 34px; font-size: .85rem; padding: .25rem .55rem; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
    .form-control-sm, .form-select-sm { min-height: 40px; font-size: 1rem; }
    #sidebarToggle, #themeToggle { min-height: 40px; min-width: 40px; }
    .subject-toggle { width: 38px; height: 38px; }
    /* recent-activity lines on the dashboard: show the whole text (wrap) instead of cutting it with "..." */
    .activity-row .text-truncate { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
    .app-confirm-modal .btn-close { padding: .75rem; }
    /* Logout is a button inside a POST form: the form is what sticks to the bottom. */
    .sidebar #logoutForm { position: sticky; bottom: 0; z-index: 1; }
    .sidebar .nav-link.nav-logout {
        background: var(--brand-dark); border-top: 1px solid rgba(255, 255, 255, .12);
    }
}

/* Logout button looks exactly like the other sidebar links. */
.sidebar button.nav-link { background: none; font: inherit; cursor: pointer; }

/* ---------- Login / Forgot password: easy-to-tap links on phones ----------
   The "Forgot password?" / "Back to Login" links were about 15-22px high; they now get a 44px-high
   tap area on small screens and on any touch screen. A computer with a mouse keeps the current look. */
@media screen and (max-width: 767.98px), screen and (pointer: coarse) {
    .touch-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .5rem; }
}

/* ---------- Compact buttons: medium size on ALL screens (computer and phone) ----------
   Normal buttons were large (about 38px on a computer, 36px on a phone). Now about 31px, with
   slightly smaller text. Small and icon buttons (.btn-sm) and large buttons (.btn-lg) are not
   changed, and the login page is not affected (it has its own sizing and is outside <main>).
   To undo: delete this whole block. */
main .btn:not(.btn-sm):not(.btn-lg),
.modal .btn:not(.btn-sm):not(.btn-lg) {
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.4;
    padding: .3rem .8rem;
    border-radius: 8px;
}
main .btn:not(.btn-sm):not(.btn-lg) i,
.modal .btn:not(.btn-sm):not(.btn-lg) i {
    font-size: .95em;
}

/* ===== Subject Management (scoped: only .subj-* and .class-pick-* classes) ===== */
.subj-stat { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; }
.subj-stat-icon { width: 2.4rem; height: 2.4rem; border-radius: 8px; background: #eff6ff; color: #1d4ed8; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex: 0 0 auto; }
.subj-stat-label { font-size: .8rem; color: #64748b; }
.subj-stat-num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: #0f172a; }
.subj-count { display: inline-block; padding: .1rem .6rem; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-size: .8rem; font-weight: 600; }
.class-picker { border: 1px solid #e5e7eb; border-radius: 8px; padding: .5rem .75rem; max-height: 320px; overflow-y: auto; }
.class-pick-group + .class-pick-group { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed #e5e7eb; }
.class-pick-head { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #475569; margin-bottom: .35rem; }
.class-pick-items { display: flex; flex-wrap: wrap; gap: .4rem; }
.class-pick-item { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border: 1px solid #cbd5e1; border-radius: 999px; font-size: .85rem; cursor: pointer; user-select: none; }
.class-pick-item:has(input:checked) { background: #eff6ff; border-color: #2563eb; color: #1d4ed8; }
.class-pick-item.is-locked { opacity: .75; cursor: not-allowed; }
.class-pick-item[hidden] { display: none; }

/* Subjects: grey "Manage" button, icon and text on one line */
.btn-manage { display: inline-flex; align-items: center; white-space: nowrap; background: #e5e7eb; border: 1px solid #d1d5db; color: #1f2937; }
.btn-manage:hover, .btn-manage:focus { background: #d1d5db; border-color: #9ca3af; color: #111827; }

/* Register / Edit Student form (scoped) */
.student-form-card { max-width: 760px; }
.student-form-confirm { margin-top: 2.1rem; }
@media (max-width: 767.98px) { .student-form-confirm { margin-top: 0; } }

/* Dashboard: "Results are ready" notice for class teachers (scoped) */
.results-ready-card { border-left: 4px solid #16a34a; }
.results-ready-ico { width: 2.4rem; height: 2.4rem; border-radius: 8px; background: #ecfdf3; color: #15803d; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex: 0 0 auto; }

/* ---------- Class tools: correct marks table ---------- */
.marks-fix th { white-space: nowrap; font-size: .8rem; }
.marks-fix-name { position: sticky; left: 0; z-index: 1; background: #fff; min-width: 9.5rem; max-width: 13rem; overflow-wrap: anywhere; font-size: .88rem; }
.marks-fix thead .marks-fix-name { background: #f8fafc; }
.marks-fix-input { width: 4.6rem; min-width: 4.6rem; text-align: center; margin: 0 auto; }

/* ---------- Developer Control Center: expandable sidebar groups ---------- */
.sidebar .dev-group-toggle {
    display: flex; align-items: center;
    color: rgba(226,232,255,.85); background: none;
    padding: .55rem .9rem; margin: 2px 10px; width: calc(100% - 20px) !important;
    border-radius: 8px; font-size: .9rem; font-weight: 600;
    transition: background .15s ease, color .15s ease;
}
.sidebar .dev-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .dev-group-toggle:not(.collapsed) { color: #fff; }
.sidebar .dev-group-toggle .dev-chevron { margin-left: auto; font-size: .75rem; transition: transform .2s ease; }
.sidebar .dev-group-toggle:not(.collapsed) .dev-chevron { transform: rotate(180deg); }
.sidebar .dev-num {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 18px; height: 18px; margin-right: .45rem; border-radius: 50%;
    font-size: .62rem; background: rgba(255,255,255,.1); color: rgba(226,232,255,.8);
}
.sidebar .dev-submenu { margin-left: 18px; border-left: 1px solid rgba(255,255,255,.1); }
.sidebar .dev-submenu a.nav-link { font-size: .86rem; padding: .42rem .8rem; margin: 1px 8px; }
.sidebar .dev-submenu a.nav-link.active { background: rgba(96,165,250,.18); color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.dev-status { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; }
.dev-status-healthy { background: #d1fae5; color: #065f46; }
.dev-status-warning { background: #fef3c7; color: #92400e; }
.dev-status-critical { background: #fee2e2; color: #991b1b; }
.dev-status-unavailable, .dev-status-not_configured { background: #e5e7eb; color: #374151; }
.dev-log td { vertical-align: top; }
.dev-log .dev-time { white-space: nowrap; }
.dev-log .dev-msg { min-width: 240px; overflow-wrap: anywhere; }

/* Phones: Developer log tables become one small card per row (label: value),
   and check tables show the status under the check name (nothing cut off at the edge). */
@media (max-width: 575.98px) {
    .dev-log thead { display: none; }
    .dev-log, .dev-log tbody, .dev-log tr, .dev-log td { display: block; width: 100%; }
    .dev-log tr { padding: .65rem .85rem; border-bottom: 1px solid var(--border); }
    .dev-log tr:last-child { border-bottom: 0; }
    .dev-log td { border: 0 !important; padding: .1rem 0 !important; text-align: left !important; }
    .dev-log td[data-label]::before {
        content: attr(data-label); display: inline-block; min-width: 4.8rem; margin-right: .4rem;
        font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #64748b;
    }
    .dev-log .dev-msg { min-width: 0; }
    .dev-log td.dev-empty::before { content: none; }
    .dev-checks .dev-col-status { display: none; }
}
@media (min-width: 576px) {
    .dev-checks .dev-status-inline { display: none; }
}
