/* ==========================================================================
   Exam System — UI stylesheet (admin + student panels)
   Hand-written plain CSS, no build step.

   1.  Design tokens            7.  Badges, alerts, empty states
   2.  Reset & typography       8.  Forms & filters
   3.  Helpers                  9.  Pagination
   4.  Admin shell & sidebar    10. Cards, paper views, modals
   5.  Buttons                  11. Student panel
   6.  Panels, stats, tables    12. Auth screen & responsive rules
                                13. Report sheet & print
   ========================================================================== */

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

:root {
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Courier New", monospace;

    --brand: #2563eb;
    --brand-600: #1d4ed8;
    --brand-700: #1e3fa8;
    --brand-soft: #eef4ff;
    --brand-line: #d3e0fb;
    --brand-ring: rgba(37, 99, 235, .22);

    --ink: #0f172a;
    --ink-soft: #64748b;
    --ink-faint: #94a3b8;

    --bg: #f4f6fb;
    --bg-tint: #eaeef7;
    --panel: #ffffff;
    --line: #e4e9f2;
    --line-soft: #f1f4fa;

    --ok: #0f9d63;
    --ok-bg: #e7f8f0;
    --ok-line: #bfe9d6;
    --warn: #b45309;
    --warn-bg: #fff5e6;
    --warn-line: #f6dfb6;
    --danger: #dc2626;
    --danger-bg: #fdecec;
    --danger-line: #f7cdcd;

    --nav-1: #0a152c;
    --nav-2: #14224a;

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

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 6px 18px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-lg: 0 26px 60px rgba(10, 21, 44, .26);

    --ease: cubic-bezier(.4, 0, .2, 1);
}

/* 2. Reset & typography --------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; font-weight: 500; transition: color .15s var(--ease); }
a:hover { color: var(--brand-600); }
a.link { text-decoration: underline; text-decoration-color: var(--brand-line); text-underline-offset: 3px; }

h1, h2, h3, h4 { margin: 0 0 .4rem; font-weight: 650; line-height: 1.25; letter-spacing: -.011em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .97rem; }
h4 { font-size: .9rem; }
p { margin: 0 0 .6rem; }
strong, b { font-weight: 650; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* 3. Helpers -------------------------------------------------------------- */

.muted { color: var(--ink-soft); }
.small { font-size: .82rem; }
.mono { font-family: var(--font-mono); font-size: .9em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }

/* 4. Admin shell & sidebar ------------------------------------------------ */

.layout-admin { background: var(--bg); }
.layout-admin .shell { display: flex; min-height: 100vh; }

.sidebar {
    flex: 0 0 264px;
    width: 264px;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: 1.15rem 1rem 1rem;
    background: linear-gradient(185deg, var(--nav-1) 0%, var(--nav-2) 60%, #16274f 100%);
    color: #cdd9f3;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }

.brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 650; color: #fff; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-role { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #93a9d3; }

.brand-mark {
    flex: none;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: linear-gradient(150deg, rgba(96, 165, 250, .34), rgba(37, 99, 235, .18));
    border: 1px solid rgba(147, 197, 253, .28);
    color: #dbeafe;
}
.brand-mark svg { width: 20px; height: 20px; }

/* Brand logo (public/img/logo.png). The artwork is drawn on a white
   background while the shells are dark, so the logo always sits on a white
   chip that keeps it crisp and readable. */
.brand-mark--logo {
    width: auto;
    min-width: 0;
    padding: .3rem .45rem;
    background: #fff;
    border-color: rgba(255, 255, 255, .5);
    box-shadow: 0 4px 14px rgba(3, 10, 24, .32);
}
.brand-logo { display: block; height: 22px; width: auto; }
.auth-aside .brand-mark--logo { padding: .4rem .55rem; border-radius: 14px; }
.auth-aside .brand-logo { height: 30px; }
.mobile-bar .brand-mark--logo { padding: .16rem .3rem; border-radius: 8px; box-shadow: none; }
.mobile-bar .brand-logo { height: 17px; }
.student-header .brand-logo { height: 20px; }

.guest-logo { display: block; height: 44px; width: auto; margin: 0 auto .7rem; }

.sidebar-close {
    display: none;
    border: 0; background: rgba(255, 255, 255, .08); color: #dbe6fb;
    width: 32px; height: 32px; border-radius: 9px; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.sidebar-close:hover { background: rgba(255, 255, 255, .16); }

.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav-group-title {
    margin: .9rem 0 .3rem;
    padding: 0 .55rem;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: #7c92bf;
}
.nav-group-title:first-child { margin-top: 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .6rem;
    border-radius: 10px;
    color: #c6d4ee;
    font-size: .9rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.is-active {
    background: linear-gradient(100deg, rgba(37, 99, 235, .95), rgba(59, 130, 246, .78));
    border-color: rgba(147, 197, 253, .35);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
}
.nav-icon { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-link.is-active .nav-icon { opacity: 1; }

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: .7rem;
    padding-top: .9rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-user { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.sidebar-user .who { font-weight: 600; color: #fff; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .muted { color: #93a9d3; }

/* The user chip is a link to the own profile page (name, e-mail, password). */
a.sidebar-user {
    padding: .35rem .4rem;
    border-radius: 10px;
    text-decoration: none;
    transition: background .16s var(--ease);
}
a.sidebar-user:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }

.avatar {
    flex: none;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: var(--radius-pill);
    background: linear-gradient(150deg, #3b82f6, #1e40af);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

/* A student who has a photo shows it instead of the initials. */
img.avatar { object-fit: cover; padding: 0; background: #dbe6fb; }

/* Name cell of the student list: the photo (or the initials) plus the e-mail. */
.student-cell { display: flex; align-items: center; gap: .55rem; }
.student-cell .avatar { width: 32px; height: 32px; font-size: .7rem; }
.student-cell .q-image-trigger { line-height: 0; }
.student-cell-text { min-width: 0; }

/* The photo already stored for a student, shown on the edit form. */
.photo-preview { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .55rem; }
img.photo-thumb {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.q-image-trigger:hover img.photo-thumb { border-color: var(--brand); }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.15rem 1.6rem;
    background: rgba(244, 246, 251, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; }
.topbar p { margin: .15rem 0 0; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.content-body { padding: 1.35rem 1.6rem 3rem; flex: 1; }

.mobile-bar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    gap: .7rem;
    padding: .55rem .9rem;
    background: linear-gradient(120deg, var(--nav-1), var(--nav-2));
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.mobile-bar .brand-name { font-size: .95rem; font-weight: 650; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #e5edfb;
    cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .16); }
.icon-btn svg { width: 18px; height: 18px; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(9, 18, 38, .5);
    backdrop-filter: blur(2px);
}
.sidebar-backdrop[hidden] { display: none; }

/* 5. Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #fff;
    padding: .5rem .85rem;
    border-radius: 10px;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.35;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease);
}
.btn:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

.btn-ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f6f8fd; border-color: #cfd8e8; color: var(--ink); }

.btn-secondary { background: var(--panel); color: var(--brand-600); border-color: var(--brand-line); }
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-700); }

.btn-success { background: var(--ok); border-color: var(--ok); }
.btn-success:hover { background: #0c8052; border-color: #0c8052; }

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

.btn-lg { padding: .65rem 1.2rem; font-size: .95rem; border-radius: 12px; }
.btn-small { padding: .3rem .6rem; font-size: .78rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-block + .btn-block { margin-top: .6rem; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.sidebar .btn-ghost { background: rgba(255, 255, 255, .07); color: #e3ecfd; border-color: rgba(255, 255, 255, .18); }
.sidebar .btn-ghost:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* 6. Panels, stats, tables ------------------------------------------------ */

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.15rem 1.25rem;
    margin-bottom: 1.1rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .85rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.card-actions form { display: inline; }
/* A single-purpose card (the student lobby dropdown) stays narrow and centred. */
.card--narrow { max-width: 640px; margin: 0 auto; }
.card--narrow .btn-block { margin-top: 1rem; }
.card--narrow > .hint:last-child { margin: .8rem 0 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
/* A grid that is directly followed by a card — the dashboard stat grid above
   "Recent exams" — needs the same room the cards already give each other. */
.grid + .card { margin-top: 1.1rem; }

.stat {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.05rem;
    position: relative;
    overflow: hidden;
    transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand), #60a5fa);
    opacity: .85;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; gap: .5rem; }
.stat-icon {
    width: 30px; height: 30px;
    flex: none;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--brand-soft);
    color: var(--brand-600);
    border: 1px solid var(--brand-line);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .74rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat-foot { font-size: .8rem; color: var(--ink-soft); }

.stat-row { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 1rem; }
.stat-row .stat { flex: 1 1 150px; }

table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: .62rem .7rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-soft);
    background: #f7f9fd;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: #f8fbff; }
tbody tr:last-child td { border-bottom: 0; }
tfoot th { background: #f7f9fd; border-top: 1px solid var(--line); border-bottom: 0; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}
.table-wrap table { min-width: 560px; }
.table-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
/* A right-aligned cell of row buttons (the report sheet's actions column) keeps
   its buttons against the edge the header above it is aligned to. */
.right .table-actions { justify-content: flex-end; }

/* Serial number column: it keeps counting across pages (page 2 starts at 16). */
th.sl, td.sl { width: 3.4rem; text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: .84rem; }

/* 7. Badges, alerts, empty states ----------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .18rem .55rem;
    border-radius: var(--radius-pill);
    font-size: .74rem;
    font-weight: 650;
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before { content: ""; width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; opacity: .75; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge-muted { background: #eef2f8; color: var(--ink-soft); border-color: var(--line); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.badge-brand { background: var(--brand-soft); color: var(--brand-600); border-color: var(--brand-line); }

.alert {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    border-radius: var(--radius);
    padding: .8rem .95rem .8rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid;
    border-left-width: 4px;
    font-size: .89rem;
    box-shadow: var(--shadow-xs);
}
.alert strong { font-weight: 650; }
.alert-success { background: var(--ok-bg); border-color: var(--ok-line); border-left-color: var(--ok); color: #0b6b46; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-line); border-left-color: var(--danger); color: #a12222; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); border-left-color: var(--warn); color: #8a4b06; }
.alert-list { margin: .2rem 0 0; padding-left: 1.15rem; }

.empty {
    padding: 2rem 1.2rem;
    text-align: center;
    color: var(--ink-soft);
    background: var(--panel);
    border: 1px dashed #cfd8e8;
    border-radius: var(--radius-lg);
    font-size: .9rem;
}

/* 8. Forms & filters ------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: .28rem; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.field-wide { grid-column: 1 / -1; }
.field .hint, .hint { font-size: .78rem; color: var(--ink-soft); }
.field .error, .error { font-size: .78rem; color: var(--danger); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="search"], input[type="date"], input[type="file"], select, textarea {
    width: 100%;
    font-family: inherit;
    font-size: .89rem;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid #d8e0ee;
    border-radius: 10px;
    padding: .5rem .65rem;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8195b4 50%), linear-gradient(135deg, #8195b4 50%, transparent 50%); background-position: calc(100% - 1.05rem) .95rem, calc(100% - .7rem) .95rem; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
textarea { min-height: 90px; resize: vertical; }
input[type="file"] { padding: .38rem .5rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:disabled, select:disabled { background: #f3f5fa; color: var(--ink-soft); cursor: not-allowed; }

.check { display: flex; align-items: center; gap: .5rem; font-size: .86rem; color: var(--ink-soft); cursor: pointer; font-weight: 500; }
.check input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--brand); flex: none; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .9rem 1rem; }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line-soft);
}
.form-actions .btn[data-busy] { min-width: 9.5rem; }

/* Form pages: the fields live in a wide column so a two-column grid always has
   room, while an optional column on the right carries help and context. */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.form-layout > .card { margin-bottom: 0; }
.form-layout .field .hint { line-height: 1.45; }
.form-side { display: grid; gap: .9rem; }
.form-side .card { margin-bottom: 0; }
.form-side h2 { font-size: .95rem; }
.form-intro { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: 1rem; }
.form-intro .form-intro-icon {
    flex: none;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--brand-soft);
    border: 1px solid var(--brand-line);
    color: var(--brand-600);
}
.form-intro .form-intro-icon svg { width: 18px; height: 18px; }
.form-intro p { margin: 0; font-size: .85rem; color: var(--ink-soft); }

.form-section { margin: 0 0 1.15rem; }
.form-section:last-of-type { margin-bottom: .2rem; }
.form-section-title {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 0 0 .7rem;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--brand-600);
}
.form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-section-title .form-section-step {
    width: 1.35rem; height: 1.35rem;
    flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--brand-soft);
    border: 1px solid var(--brand-line);
    font-size: .7rem;
    letter-spacing: 0;
}
.field .req { color: var(--danger); font-weight: 700; margin-left: .1rem; }

.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; font-size: .85rem; color: var(--ink-soft); }
.tips li { display: flex; gap: .5rem; align-items: flex-start; }
.tips li::before { content: "•"; color: var(--brand); font-weight: 700; line-height: 1.4; }

/* 8a-2. Staff permission picker ------------------------------------------- */

/* One card per grantable module and the whole card is the label, so a click
   anywhere on it toggles the module. The description states what is handed
   over, which is what an administrator needs to decide. */
.perm-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem 1rem;
    flex-wrap: wrap;
    margin-bottom: .7rem;
}
.perm-head > p { margin: 0; max-width: 62ch; line-height: 1.5; }
.perm-tools { display: flex; gap: .35rem; flex: none; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(248px, 1fr)); gap: .6rem; }

.perm {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .6rem .7rem;
    background: #fbfcff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.perm:hover { border-color: var(--brand-line); }
.perm.is-on {
    background: var(--brand-soft);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}
.perm input[type="checkbox"] { width: 1rem; height: 1rem; margin-top: .15rem; accent-color: var(--brand); flex: none; }
.perm-body { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.perm-label { font-size: .88rem; font-weight: 600; }
.perm-desc { font-size: .78rem; color: var(--ink-soft); line-height: 1.4; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.filters > div { display: flex; flex-direction: column; gap: .2rem; min-width: 150px; flex: 1 1 150px; }
.filters label { font-size: .73rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
.filters .btn { flex: none; }
.filters > .filters-actions {
    flex: 0 1 auto;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-end;
    gap: .5rem;
    min-width: 0;
}

/* 8b. Exam blueprint checklist -------------------------------------------- */

/* The blueprint lists every chapter of the chosen course, often 30+ rows, so the
   header stays pinned while the list scrolls. A ticked row tints itself and gets
   a brand rail, which makes a half-filled paper readable at a glance. */
.blueprint-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin: .2rem 0 .7rem;
}
.blueprint-status { margin: 0; font-size: .82rem; color: var(--ink-soft); }
.blueprint-status strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.blueprint-legend { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.blueprint-legend .badge { font-weight: 600; }

.blueprint-scroll { max-height: 34rem; overflow: auto; }
.blueprint-scroll thead th { position: sticky; top: 0; z-index: 2; }
#chapter-table { min-width: 720px; }
#chapter-table .use-col { width: 4rem; }

.chapter-row td { padding: .5rem .7rem; }
.chapter-row[hidden] { display: none !important; }
.chapter-row.is-selected { background: var(--brand-soft); }
.chapter-row.is-selected:hover { background: #e9f2fe; }
.chapter-row.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.chapter-row.is-selected .chapter-name { color: var(--brand-600); }
.chapter-row.is-empty .chapter-name { color: var(--ink-soft); }

.chapter-name { display: block; font-weight: 600; cursor: pointer; }
.chapter-sub { display: block; margin-top: .1rem; font-size: .76rem; color: var(--ink-soft); }

.chapter-check {
    display: block;
    width: 1.1rem;
    height: 1.1rem;
    margin: 0 auto;
    accent-color: var(--brand);
    cursor: pointer;
}
.chapter-check:disabled { cursor: not-allowed; opacity: .45; }

.chapter-avail { display: inline-flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.avail-meter { width: 3.6rem; height: 4px; border-radius: var(--radius-pill); background: #e7ecf6; overflow: hidden; }
.avail-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width .18s var(--ease); }
.avail-meter.is-over .avail-fill { background: var(--danger); }
.avail-meter.is-complete .avail-fill { background: var(--ok); }

/* The count input doubles as live feedback: a value over the available stock
   turns the field red (see :invalid), an untouched row keeps it quiet. The
   #chapter-table prefix is needed to out-rank the global input[type=number]
   rule, which also sets a width. */
#chapter-table .chapter-count {
    display: block;
    width: 5.5rem;
    margin-left: auto;
    text-align: center;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
#chapter-table .chapter-count:disabled { background: #f4f6fb; opacity: .55; cursor: not-allowed; }
#chapter-table .chapter-count:invalid { border-color: var(--danger-line); background: var(--danger-bg); }

/* 8c. Searchable select (Select2-style) ----------------------------------- */

/* public/js/app.js upgrades every `<select>` in the panels: the real element
   stays in the form (1px, clipped, still focusable so the browser keeps
   enforcing `required`), while the visible control is a button that opens a
   panel with a search box, a result counter and a scrollable option list.
   The panel lives in <body> and is positioned with `position: fixed`, so it
   can never be clipped by .table-wrap, .modal-panel or .blueprint-scroll. */

.s2 { position: relative; width: 100%; }

.s2-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    background-image: none !important;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.s2-trigger {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    min-height: 2.4rem;
    padding: .45rem .6rem;
    font-family: inherit;
    font-size: .89rem;
    line-height: 1.4;
    text-align: left;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid #d8e0ee;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.s2-trigger:hover { border-color: #c4d0e6; }
.s2-trigger:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.s2.is-open .s2-trigger { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.s2.is-invalid .s2-trigger { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .16); }
.s2.is-disabled .s2-trigger { background: #f3f5fa; color: var(--ink-soft); cursor: not-allowed; box-shadow: none; }

.s2-selection { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; }
.s2-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s2-placeholder { color: var(--ink-faint); }
.s2-caret { flex: none; width: 16px; height: 16px; color: #8195b4; transition: transform .18s var(--ease), color .18s var(--ease); }
.s2-caret svg { display: block; width: 100%; height: 100%; }
.s2.is-open .s2-caret { transform: rotate(180deg); color: var(--brand); }

.s2-clear {
    flex: none;
    width: 1.2rem;
    height: 1.2rem;
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    color: var(--ink-soft);
    background: #eef2f8;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.s2-clear[hidden] { display: none; }
.s2-clear:hover { background: var(--danger-bg); color: var(--danger); }
.s2-clear svg { width: 11px; height: 11px; }

/* Multiple selects show the picked values as chips inside the trigger. */
.s2-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .05rem .35rem .05rem .5rem;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-pill);
    background: var(--brand-soft);
    color: var(--brand-700);
    font-size: .8rem;
    font-weight: 600;
}
.s2-chip-x { display: grid; place-items: center; width: .95rem; height: .95rem; border-radius: var(--radius-pill); }
.s2-chip-x:hover { background: rgba(37, 99, 235, .18); }
.s2-chip-x svg { width: 9px; height: 9px; }

/* The panel is a child of <body>: an inline left/top/width keeps it glued to
   its field, everything else is styled here. */
.s2-panel {
    position: fixed;
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 18px 44px rgba(10, 21, 44, .18), 0 2px 6px rgba(10, 21, 44, .06);
    animation: s2-drop-in .15s var(--ease);
}
.s2-panel[hidden] { display: none; }
@keyframes s2-drop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.s2-panel.is-drop-up { animation-name: s2-drop-up; }
@keyframes s2-drop-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.s2-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .6rem;
    background: #f8fafd;
    border-bottom: 1px solid var(--line-soft);
}
.s2-search[hidden] { display: none; }
.s2-search-icon { flex: none; width: 15px; height: 15px; color: var(--ink-faint); }
.s2-search-icon svg { display: block; width: 100%; height: 100%; }

/* The two `.s2-search` prefixes are needed to out-rank the global
   `input[type="search"]` rule, which also sets a border, padding and radius. */
.s2-search .s2-search-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    padding: 0;
    font-size: .87rem;
    background: transparent;
    border: 0;
    border-radius: 0;
}
.s2-search .s2-search-input:focus { outline: none; border-color: transparent; box-shadow: none; }

.s2-count {
    flex: none;
    padding: .05rem .4rem;
    border-radius: var(--radius-pill);
    background: var(--bg-tint);
    color: var(--ink-soft);
    font-size: .7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.s2-count[hidden] { display: none; }

.s2-list {
    flex: 1 1 auto;
    margin: 0;
    padding: .3rem;
    list-style: none;
    overflow-y: auto;
    max-height: min(19rem, 45vh);
    overscroll-behavior: contain;
}

.s2-group {
    padding: .45rem .55rem .15rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.s2-option {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .55rem;
    border-radius: 9px;
    font-size: .87rem;
    line-height: 1.35;
    color: var(--ink);
    cursor: pointer;
}
.s2-option .s2-option-text { flex: 1 1 auto; min-width: 0; }
.s2-option mark { padding: 0 .1rem; border-radius: 4px; background: rgba(37, 99, 235, .16); color: var(--brand-700); font-weight: 650; }
.s2-option.is-selected { color: var(--brand-700); font-weight: 650; }
.s2-option.is-selected .s2-check { opacity: 1; }
.s2-option.is-active { background: var(--brand-soft); }
.s2-option.is-active.is-selected { background: #e2ecff; }
.s2-option.is-placeholder { color: var(--ink-soft); }
.s2-option.is-disabled { color: var(--ink-faint); background: #f7f9fd; cursor: not-allowed; }
.s2-option.is-disabled mark { background: transparent; color: inherit; }

.s2-check { flex: none; width: 15px; height: 15px; color: var(--brand); opacity: 0; }
.s2-check svg { display: block; width: 100%; height: 100%; }

.s2-empty { margin: 0; padding: 1rem .6rem; text-align: center; font-size: .84rem; color: var(--ink-soft); }
.s2-empty[hidden] { display: none; }

/* Below 640px the panel becomes a full-width bottom sheet, which is far easier
   to tap than a small dropdown floating next to the field. */
@media (max-width: 640px) {
    .s2-panel.is-sheet {
        left: .6rem !important;
        right: .6rem !important;
        bottom: .6rem !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        max-height: none !important;
    }
    .s2-panel.is-sheet .s2-list { max-height: min(24rem, 55vh); }
    .s2-trigger { min-height: 2.6rem; }
}

/* 9. Pagination ----------------------------------------------------------- */

/* The pagination bar renders itself only when the collection actually has more
   than one page, so lists never show an empty card. */
.pagination-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .7rem 1rem;
    padding: .7rem .9rem;
    margin-bottom: 1.1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.page-summary { font-size: .82rem; color: var(--ink-soft); margin: 0; }
.page-summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.pagination { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; justify-content: center; }
.page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    padding: .3rem .55rem;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    color: var(--ink);
    font-size: .82rem;
    font-weight: 600;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.page:hover { background: var(--brand-soft); border-color: var(--brand-line); text-decoration: none; }
.page.is-active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 650; }
.page.is-disabled { color: var(--ink-faint); background: #f6f8fc; cursor: not-allowed; }
.page.is-active:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.page-nav { gap: .35rem; padding: .3rem .7rem; }
.page-nav svg { width: 13px; height: 13px; flex: none; }
.page-ellipsis { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; color: var(--ink-faint); font-weight: 600; }

/* 10. Paper views, question images, modals -------------------------------- */

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; font-size: .88rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }

img.q-image { height: 300px; max-width: 320px; border: 1px solid var(--line); border-radius: 10px; display: block; margin-bottom: .6rem; }

/* The admin question list only has to show that a question has an image, so its
   thumbnail stays small. The full picture is one click away: every
   [data-image-preview] trigger below opens the image preview modal. */
img.q-image.q-image-thumb {
    height: auto;
    max-height: 64px;
    max-width: 104px;
    margin: .45rem 0 0;
    border-radius: 8px;
}

.q-image-trigger {
    display: inline-block;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    line-height: 0;
    cursor: zoom-in;
}
.q-image-trigger:hover img.q-image { border-color: var(--brand); }
.q-image-trigger:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

.paper-summary { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0 .4rem; }
.summary-item {
    flex: 1 1 155px;
    background: #f8fafd;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .65rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}
.summary-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-weight: 650; }
.summary-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.summary-item.is-filled { border-color: var(--brand-line); background: var(--brand-soft); }
.summary-item.is-filled .summary-value { color: var(--brand-600); }
.paper-note { margin: .6rem 0 0; font-size: .84rem; color: var(--ink-soft); }
.paper-note.is-live { color: var(--ok); }

.paper-question { padding-bottom: .9rem; }
.paper-question-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.paper-question-text { font-weight: 600; margin: .5rem 0 .65rem; white-space: pre-line; }

.paper-options { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.paper-option { display: flex; align-items: center; gap: .55rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; }
.paper-option .option-key { font-weight: 700; color: var(--brand-600); }
.paper-option .badge { margin-left: auto; }
.paper-option.option-correct { border-color: var(--ok-line); background: var(--ok-bg); }
.paper-option.option-selected { border-color: var(--brand-line); background: var(--brand-soft); }

body.modal-open { overflow: hidden; }

.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9, 18, 38, .55); backdrop-filter: blur(3px); }

.modal-panel {
    position: relative;
    background: var(--panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.25rem 1.35rem 1.35rem;
    width: 100%;
    max-width: 470px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in .18s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .8rem; }
.modal-head h2 { margin: 0; }

/* Image preview: the same .modal, drawn as a dark lightbox instead of a card.
   The exam sitting screen grows this same modal into a full-screen lightbox -
   see the override in public/css/exam.css. Opened by [data-image-preview]
   (see public/js/app.js). */
.image-preview .modal-panel {
    max-width: min(1080px, 96vw);
    padding: .5rem;
    background: #0b1220;
    border: 1px solid rgba(255, 255, 255, .16);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.image-preview-img {
    display: block;
    max-width: 100%;
    max-height: calc(90vh - 1.2rem);
    border-radius: 8px;
    background: #fff;
}
.image-preview-close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    z-index: 1;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 50%;
    background: rgba(9, 18, 38, .78);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.image-preview-close:hover { background: #fff; border-color: #fff; color: #0b1220; }

/* Image gallery (admin): the pictures that several questions share. */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.gallery-card {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.gallery-thumb {
    display: block;
    width: 100%;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    background: #f1f5fb;
}
.gallery-thumb-img { display: block; width: 100%; height: 148px; object-fit: cover; }
.gallery-thumb:hover .gallery-thumb-img { opacity: .88; }
.gallery-thumb:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.gallery-body { display: grid; gap: .5rem; padding: .8rem .85rem .95rem; }
.gallery-body form { margin: 0; }
.gallery-name { margin: 0; font-size: .82rem; font-weight: 650; overflow-wrap: anywhere; }
.gallery-meta {
    margin: 0;
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
    font-size: .76rem;
    color: var(--ink-soft);
}

/* The URL field and its copy button live in one row: the field is read-only
   (clicking it selects the whole URL) and the button copies it. */
.copy-row { display: flex; gap: .4rem; align-items: stretch; }
.copy-field {
    flex: 1 1 auto;
    min-width: 0;
    padding: .38rem .5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-tint);
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-size: .72rem;
    cursor: copy;
}
.copy-field:focus { outline: 2px solid var(--brand); outline-offset: 1px; background: var(--panel); color: var(--ink); }
.copy-row .btn { flex: none; }
[data-copy].is-copied { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
[data-copy].is-copy-failed { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }

/* 11. Student panel ------------------------------------------------------- */

.layout-student { background: linear-gradient(180deg, #eef2fa 0%, var(--bg) 320px); }

.student-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(120deg, var(--nav-1), var(--nav-2) 65%, #1b2f60);
    color: #d7e2f8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.4rem;
    flex-wrap: wrap;
    box-shadow: 0 10px 30px rgba(10, 21, 44, .18);
}
.student-header .brand-name { font-size: 1.02rem; }
.student-identity { display: flex; align-items: center; gap: 1rem; color: #d7e2f8; flex-wrap: wrap; }
.student-identity .who { display: flex; flex-direction: column; line-height: 1.3; }
.student-identity .who strong { color: #fff; font-size: .92rem; }
.student-identity .muted { color: #9fb4d8; }
.student-header .btn-ghost { background: rgba(255, 255, 255, .07); color: #e5edfb; border-color: rgba(255, 255, 255, .18); }
.student-header .btn-ghost:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.student-main { max-width: 1120px; width: 100%; margin: 0 auto; padding: 1.5rem 1.2rem 3.5rem; }

.hero {
    background: linear-gradient(130deg, #14224a 0%, #1d3a80 55%, #2563eb 100%);
    color: #e6eefc;
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.3rem;
    box-shadow: 0 18px 40px rgba(20, 34, 74, .22);
}
.hero h1 { color: #fff; margin-bottom: .25rem; }
.hero p { margin: 0; color: #c3d4f0; font-size: .9rem; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .85rem; }
.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    font-weight: 600;
    padding: .22rem .6rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #eaf1ff;
}

/* 11b. Student exam briefing (A4 paper) ----------------------------------- */

/* The lobby dropdown lives in a narrow card; the briefing below is the A4
   sheet a student reads before "Start exam" is pressed. */

/* Step 2 of the journey: "back to the lobby" plus the step hint. */
.paper-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* The sheet itself. 794px is the standard 96dpi width of an A4 page, so the
   briefing reads like a real question paper on a desktop screen. */
.paper {
    width: 100%;
    max-width: 794px;
    min-height: 1000px;
    margin: 0 auto;
    padding: 2.4rem 2.6rem 1.2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 26px 60px rgba(15, 23, 42, .14);
    display: flex;
    flex-direction: column;
}

.paper-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: .9rem;
    border-bottom: 1px solid var(--line);
}
.paper-brand { display: flex; align-items: center; gap: .65rem; }
.paper-brand > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.paper-brand .brand-mark--logo { box-shadow: none; }
.paper-ref { display: flex; flex-direction: column; line-height: 1.35; text-align: right; }

.paper-title { margin: 1.7rem 0 .6rem; font-size: 1.55rem; text-align: center; }
.paper-lead {
    max-width: 62ch;
    margin: 0 auto;
    text-align: center;
    font-size: .92rem;
    color: var(--ink-soft);
}

/* Instructions sit on a tinted block, so the marks / time facts below are
   impossible to miss - this is the "bg" area of the briefing. */
.paper-instructions {
    margin-top: 1.6rem;
    padding: 1.1rem 1.2rem 1.2rem;
    background: linear-gradient(135deg, #eef4ff 0%, #f7faff 60%, #fdfdff 100%);
    border: 1px solid var(--brand-line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
}
.paper-instructions h2, .paper-rules-block h2 {
    margin: 0;
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--brand-700);
}
.paper-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: .85rem 1.1rem;
    margin-top: .85rem;
}
.paper-fact { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.paper-fact span {
    font-size: .68rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-faint);
}
.paper-fact strong { font-size: .93rem; font-weight: 650; }

.paper-rules-block { margin-top: 1.6rem; }
.paper-rules-block h2 { color: var(--ink-soft); }
.paper-rules { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .55rem; font-size: .9rem; }
.paper-rules li { display: flex; align-items: flex-start; gap: .6rem; }
.paper-rules li::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-top: .45rem;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.paper-signoff {
    display: flex;
    justify-content: space-between;
    gap: .6rem 1rem;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 1.5rem;
    font-size: .78rem;
    color: var(--ink-soft);
}

/* The floating action bar: sticky inside the sheet, so the full-width "Start
   exam" button stays in view while the rules above are read. */
.paper-actions { position: sticky; bottom: .8rem; margin-top: .9rem; }
.paper-actions-inner {
    margin: 0;
    padding: .8rem .9rem .7rem;
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .14);
    backdrop-filter: blur(6px);
}
.paper-actions-inner .hint { margin: .5rem 0 0; }

@media (max-width: 720px) {
    .paper { min-height: 0; padding: 1.4rem 1.2rem 1rem; }
    .paper-ref { text-align: left; }
    .paper-title { font-size: 1.3rem; }
    .paper-lead { text-align: left; }
}

/* Thank-you page ---------------------------------------------------------- */

/* The confirmation is the whole page: one centred line of text. */
.thank-you-panel { text-align: center; padding: 2.6rem 1.4rem; }
.thank-you-panel h1 { font-size: 1.9rem; }

/* The only form on the page is the invisible real POST /logout. */
.logout-form[hidden] { display: none; }

/* 12. Auth screen & responsive rules -------------------------------------- */

.layout-guest { background: #eef2fa; }

.auth-shell { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }

.auth-aside {
    position: relative;
    overflow: hidden;
    padding: 3rem 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    color: #dbe6fb;
    background: radial-gradient(120% 120% at 0% 0%, #1b3a7d 0%, #0d1c3c 55%, #0a152c 100%);
}
.auth-aside::after {
    content: "";
    position: absolute;
    width: 420px; height: 420px;
    right: -140px; bottom: -160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, .38), transparent 70%);
}
.auth-aside .brand-mark { width: 44px; height: 44px; }
.auth-title { font-size: 1.95rem; color: #fff; max-width: 22ch; margin: .4rem 0 0; }
.auth-lead { color: #b9cbea; max-width: 40ch; font-size: .95rem; }
.auth-points { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .55rem; font-size: .88rem; }
.auth-points li { display: flex; align-items: flex-start; gap: .55rem; color: #cfdcf5; }
.auth-points li::before {
    content: "";
    flex: none;
    width: 18px; height: 18px;
    margin-top: .12rem;
    border-radius: 50%;
    background: rgba(96, 165, 250, .22);
    border: 1px solid rgba(147, 197, 253, .45);
}
.auth-foot { margin-top: auto; font-size: .78rem; color: #8ba4cd; position: relative; z-index: 1; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 2.2rem 1.4rem; }
.guest-card {
    width: 100%;
    max-width: 420px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 26px 60px rgba(15, 23, 42, .13);
    padding: 1.9rem 1.7rem 1.6rem;
}
.guest-brand { text-align: center; margin-bottom: 1.25rem; }
.guest-brand h1 { font-size: 1.25rem; margin-bottom: .25rem; }
.guest-note { margin: 1.1rem 0 0; font-size: .78rem; color: var(--ink-soft); text-align: center; }

.role-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .25rem;
    padding: .25rem;
    background: var(--bg-tint);
    border: 1px solid var(--line);
    border-radius: 13px;
    margin-bottom: 1.15rem;
}
.role-switch input { position: absolute; opacity: 0; pointer-events: none; }
.role-switch label {
    text-align: center;
    padding: .5rem .6rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 650;
    color: var(--ink-soft);
    transition: background .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease);
}
.role-switch label:hover { color: var(--ink); }
.role-switch input:checked + label { background: var(--panel); color: var(--brand-600); box-shadow: var(--shadow-sm); }
.role-switch input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (max-width: 1024px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

@media (max-width: 980px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        height: 100%;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }
    .sidebar-close { display: inline-grid; place-items: center; }
    .mobile-bar { display: flex; }
    .topbar { position: static; padding: .95rem 1rem; }
    .content-body { padding: 1.1rem 1rem 3rem; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .topbar { align-items: flex-start; }
    .topbar-actions { width: 100%; }
    .topbar-actions .btn { flex: 1 1 auto; }
    .content-body { padding: .95rem .8rem 3rem; }
    .card { padding: 1rem .9rem; border-radius: var(--radius); }
    .guest-card { padding: 1.5rem 1.2rem 1.4rem; border-radius: 16px; }
    .filters { padding: .75rem .8rem; }
    .student-main { padding: 1.1rem .85rem 3rem; }
    .hero { padding: 1.15rem 1.1rem; }
    .pagination-card { flex-direction: column; align-items: stretch; }
    .page-summary { text-align: center; }
    .filters > .filters-actions { justify-content: stretch; }
    .filters > .filters-actions .btn { flex: 1 1 auto; }
    .table-wrap { border-radius: var(--radius); }
    th.sl, td.sl { width: 2.4rem; }
    .blueprint-legend { display: none; }
    #chapter-table .chapter-count { width: 4.4rem; }
}

@media (min-width: 1080px) {
    .form-layout--side { grid-template-columns: minmax(0, 1fr) 320px; }
    .form-layout--wide { max-width: 1100px; }
}

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

/* 13. Report sheet & print ------------------------------------------------ */

/* The printed sheet carries its own head (title, caption of the filter, when the
   report was generated), because the browser tab header, the sidebar and the
   buttons are all gone on paper. On screen that block stays out of the way. */
.print-only { display: none; }

/* The on-screen counterpart of the printed head: what the sheet holds and when
   it was generated, on one calm line above the table. The sheet itself says it
   on paper, where this line is dropped. */
.report-slice {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .7rem;
    margin-bottom: .8rem;
    padding: .6rem .85rem;
    background: linear-gradient(90deg, var(--brand-soft), var(--panel));
    border: 1px solid var(--brand-line);
    border-radius: var(--radius);
}
.report-slice-tag {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--brand-600);
}
.report-slice strong { font-weight: 600; }
.report-slice .small { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Five counters, one row: they count one slice, so they read as one strip of
   figures rather than as five separate cards. */
.report-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.report-stats .stat-value { font-size: 1.45rem; }

/* The last row of the sheet adds the slice up - the whole filtered slice, not
   only the rows that fit on this page. */
.report-total td { background: var(--line-soft); font-weight: 600; }
.report-total .muted { font-weight: 400; }
.report-total .badge { margin-left: .25rem; }

@media print {
    /* Landscape, because the sheet is wide: ID, student, course, semester,
       batch, exam, date, score, percentage and result side by side. */
    @page { size: A4 landscape; margin: 10mm; }

    html, body { background: #fff; color: #000; }

    /* Only the sheet prints: navigation, the filter form, the top bar buttons,
       the pagination bar, the flash messages and per-row actions are dropped.
       An element that should stay off paper can also be marked .no-print. */
    .sidebar, .sidebar-backdrop, .mobile-bar, .topbar-actions,
    .filters, .pagination-card, .alert, .no-print { display: none !important; }

    .content { display: block; }
    .content-body { padding: 0 0 1rem; }

    .topbar {
        position: static;
        background: none;
        backdrop-filter: none;
        border-bottom: 0;
        padding: 0 0 .6rem;
    }

    .print-only { display: block; }

    /* The report page turns its screen title into a letterhead, so its top bar -
       a second title, a description and the buttons - would only repeat it. */
    .page-report .topbar { display: none !important; }

    /* The sheet is a letter, not a stack of blocks: it is as tall as the paper,
       so the pen lines and the foot of the sheet come to rest on the bottom edge
       of it instead of leaving a band of blank page under them. A4 landscape is
       210mm high and the page margins take 10mm top and bottom, so the sheet
       fills 186mm - 4mm short of the paper's edge, which keeps a short report
       from spilling onto a second, empty sheet. */
    body.page-report {
        display: flex;
        flex-direction: column;
        min-height: 186mm;
    }
    /* 100vh is the height of the window, not of the paper, on paper. */
    body.page-report .shell { flex: 1 1 auto; min-height: 0; }
    body.page-report .content,
    body.page-report .content-body {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        padding: 0;
    }

    /* Surfaces become plain paper: no cards, no shadows, no brand bars. */
    .card, .stat { background: none; border: 0; box-shadow: none; border-radius: 0; padding: 0; margin-bottom: .6rem; }
    .stat::after { display: none; }
    .stat { break-inside: avoid; }
    .stat-value { font-size: 1.15rem; }

    .table-wrap { overflow: visible; border: 0; border-radius: 0; background: none; }
    .table-wrap table { min-width: 0; font-size: .72rem; }
    table { width: 100%; }

    /* The column header repeats on every printed page, and no row is cut in
       half by a page break. */
    thead { display: table-header-group; }
    tr { break-inside: avoid; }

    th, td { border: 1px solid #9aa3b5; padding: .2rem .3rem; color: #000; }
    th { background: #eef1f7 !important; }

    /* Colours are unreliable on paper: a badge prints as plain bordered text. */
    .badge { background: none !important; border: 1px solid #6b7280; color: #000 !important; padding: 0 .25rem; }

    a { color: #000; text-decoration: none; }
    tbody tr:hover { background: none; }

    /* --- the letterhead --------------------------------------------------- */

    /* One head, not three: brand and document on the top line, the counters of
       the slice on the next with the caption beside them - the caption only
       when the slice is filtered - and the small print of who and when below it
       all, above a rule heavy enough to read as a letterhead. */
    .report-head {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: end;
        column-gap: 1rem;
        padding-bottom: .35rem;
        margin-bottom: .55rem;
        border-bottom: 2.5pt solid #111;
    }
    .report-head-brand { display: flex; align-items: center; }
    .report-head-brand .report-brand-logo { height: 2.1rem; width: auto; }
    .report-head-doc { text-align: right; }
    .report-head-doc .report-doc-title {
        display: block;
        font-size: .76rem;
        font-weight: 700;
        letter-spacing: .2em;
        text-transform: uppercase;
    }
    .report-head-tag {
        display: inline-block;
        margin-top: .1rem;
        padding: 0 .3rem;
        border: .5pt solid #8b93a1;
        font-size: .54rem;
        letter-spacing: .16em;
        text-transform: uppercase;
        color: #444;
    }
    .report-head-line {
        grid-column: 1 / -1;
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        margin-top: .3rem;
        padding-top: .28rem;
        border-top: .5pt solid #c8ced9;
        font-size: .78rem;
    }
    .report-head-counts { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .report-head .report-meta {
        grid-column: 1 / -1;
        margin: .12rem 0 0;
        font-size: .62rem;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: #666;
    }

    /* --- the counters, as one ruled strip --------------------------------- */

    /* Five counters, five columns, one strip: the label on top, the figure under
       it, the note in the smallest type. Rules only - no cards, no colour. */
    .report-stats {
        grid-template-columns: repeat(5, 1fr);
        gap: 0;
        margin: 0 0 .5rem;
        border-top: .5pt solid #111;
        border-bottom: .5pt solid #111;
        break-inside: avoid;
    }
    .report-stats .stat {
        border: 0;
        border-left: .5pt solid #c8ced9;
        border-radius: 0;
        padding: .3rem .45rem;
        margin: 0;
    }
    .report-stats .stat:first-child { border-left: 0; }
    .report-stats .stat-icon { display: none; }
    .report-stats .stat-value { font-size: 1.15rem; line-height: 1.25; }
    .report-stats .stat-label { font-size: .6rem; letter-spacing: .14em; color: #222; }
    .report-stats .stat-foot { font-size: .6rem; color: #555; }

    /* --- the sheet itself ------------------------------------------------- */

    /* A report table reads as ruled paper: one rule under the head, a hairline
       between the rows, a light band on every other row, a heavier rule closing
       the body. No box around it and no vertical grid. */
    .table-wrap.report-sheet {
        border: 0;
        background: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .report-sheet table { font-size: .7rem; }
    .report-sheet th, .report-sheet td {
        border: 0;
        border-bottom: .5pt solid #d7dce5;
        padding: .26rem .42rem;
        vertical-align: top;
    }
    .report-sheet thead th {
        border-bottom: 1.4pt solid #111;
        background: #eef1f7 !important;
        padding: .34rem .42rem;
        font-size: .6rem;
        letter-spacing: .1em;
        text-transform: uppercase;
        color: #222;
    }
    .report-sheet tbody tr:nth-child(even) td { background: #f6f8fb !important; }
    .report-sheet tbody tr:last-child td { border-bottom: 1.2pt solid #111; }
    .report-sheet .right { text-align: right; font-variant-numeric: tabular-nums; }
    .report-sheet .muted { color: #555; }
    .report-sheet .mono { font-size: .6rem; }

    /* Colours and pills are unreliable on paper: a result prints as a word. */
    .report-sheet .badge {
        background: none !important;
        border: 0 !important;
        padding: 0 !important;
        font-size: .58rem;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: #111 !important;
    }
    .report-sheet .badge::before { display: none; }

    /* The total band closes the sheet and repeats the counters in words. */
    .report-sheet tfoot td {
        background: #eef1f7 !important;
        border-top: 1.2pt double #111;
        border-bottom: 0;
        padding: .3rem .38rem;
        font-size: .58rem;
        font-weight: 700;
        letter-spacing: .1em;
        text-transform: uppercase;
    }
    .report-sheet tfoot .small { text-transform: none; letter-spacing: 0; font-weight: 400; }

    /* --- the sign-off ----------------------------------------------------- */

    /* Lines for the pen, then the foot of the sheet: who printed it, how much is
       in it and on which of how many pages. The auto top margin is what pushes
       the block to the bottom of the sheet - and the padding keeps a table that
       reaches the bottom of a full page from touching the pen lines. */
    .print-only.report-foot { padding-top: 1.1rem; margin-top: auto; break-inside: avoid; }
    .report-signoff { display: flex; gap: 2rem; }
    .report-signoff .signoff-line {
        flex: 1 1 0;
        border-top: 1px solid #111;
        padding-top: .22rem;
        font-size: .6rem;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: #333;
    }
    .report-foot-line {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        margin: .8rem 0 0;
        padding-top: .25rem;
        border-top: .5pt solid #c8ced9;
        font-size: .58rem;
        letter-spacing: .1em;
        text-transform: uppercase;
        color: #666;
    }
}
