/* =============================================================================
   app.css — Quiz Portal
   =============================================================================
   Aesthetic: refined editorial. Serif display, neutral paper palette, single
   restrained accent. No framework. Modern CSS (custom properties, nesting,
   color-mix). Evergreen browsers.

   ARCHITECTURE NOTE (read before editing):
   There is ONE source of truth for tokens: the :root block below. Earlier the
   admin/center components referenced an undefined alias set (--surface, --fg,
   --border, --muted). Those are now formally defined as aliases of the core
   palette so every component renders intentionally instead of falling back to
   browser defaults. Do not reintroduce undefined variables.
   ============================================================================= */

@font-face {
    font-family: "InstrumentSerif";
    src: local("Instrument Serif"), local("InstrumentSerif");
    font-display: swap;
}

:root {
    color-scheme: light dark;

    /* ---- Core palette (warm-neutral paper, slate-blue ink) --------------- */
    --ink:        #1b2330;   /* primary text — deep slate, not pure black */
    --ink-soft:   #3d4757;   /* secondary text */
    --ink-muted:  #6b7585;   /* tertiary / labels */
    --paper:      #f6f5f2;   /* app background — warm off-white, not stark */
    --paper-2:    #edece7;   /* sunken surfaces, table head */
    --surface-1:  #fdfcfa;   /* raised cards / panels — warm white */
    --rule:       #e0ded7;   /* hairline borders */
    --rule-strong:#cfccc2;   /* emphasized borders */

    /* Primary accent = slate-blue (navy). Used for chrome, primary actions,
       links, focus, active nav. This is the new professional anchor. */
    --accent:     #2f4a6d;   /* slate / pastel-dark blue */
    --accent-ink: #233a57;   /* darker for hover/press */
    --accent-soft:#3f5f8a;   /* lighter slate for accents */
    --accent-tint:#e9eef5;   /* faint blue wash */

    /* Red is now reserved for danger/destructive only. */
    --success:    #2f6a3a;
    --warning:    #9a6112;
    --danger:     #b0322f;
    --danger-ink: #8c2522;

    /* ---- Semantic aliases (used by all admin/center components) ---------- */
    --fg:          var(--ink);
    --fg-soft:     var(--ink-soft);
    --muted:       var(--ink-muted);
    --bg:          var(--paper);
    --surface:     var(--surface-1);
    --surface-sunk:var(--paper-2);
    --border:      var(--rule);
    --border-strong: var(--rule-strong);

    /* ---- Elevation ------------------------------------------------------- */
    --shadow-xs: 0 1px 2px rgba(27,35,48,0.06);
    --shadow-sm: 0 1px 2px rgba(27,35,48,0.05), 0 2px 6px rgba(27,35,48,0.06);
    --shadow-md: 0 1px 2px rgba(27,35,48,0.05), 0 12px 30px rgba(27,35,48,0.10);
    --shadow-lg: 0 24px 60px rgba(27,35,48,0.22);
    --shadow: var(--shadow-sm);

    /* ---- Typography ------------------------------------------------------ */
    --font-display: "InstrumentSerif", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --font-body:    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    /* ---- Radius & spacing scale ----------------------------------------- */
    --radius-sm: 7px;
    --radius:    11px;
    --radius-lg: 16px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    --container-width: 1140px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink:        #e8ebf0;
        --ink-soft:   #c2c8d2;
        --ink-muted:  #8a93a3;
        --paper:      #11161e;   /* deep slate-navy ground */
        --paper-2:    #181f2a;
        --surface-1:  #1c2430;
        --rule:       #2b3340;
        --rule-strong:#3a4453;
        --accent:     #7da3d4;   /* light slate-blue for dark bg */
        --accent-ink: #9bbbe6;
        --accent-soft:#6f97cc;
        --accent-tint:#1a2738;
        --danger:     #e0726f;
        --danger-ink: #ec8a87;
        --shadow-xs: 0 1px 2px rgba(0,0,0,0.5);
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.4);
        --shadow-md: 0 1px 2px rgba(0,0,0,0.45), 0 12px 30px rgba(0,0,0,0.55);
        --shadow-lg: 0 24px 60px rgba(0,0,0,0.65);
    }
}

* { box-sizing: border-box; }

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

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.6 var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    transition: border-color 0.15s ease, color 0.15s ease;
}
a:hover { border-bottom-color: var(--accent); }

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--surface-sunk);
    padding: 0.12em 0.42em;
    border-radius: 5px;
    border: 1px solid var(--border);
}

:where(button, input, select, textarea):focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Auth shell
   ------------------------------------------------------------------------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%),
        var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.75rem 2.25rem;
    box-shadow: var(--shadow-md);
}
.auth-header { margin-bottom: 1.75rem; }
.auth-eyebrow, .eyebrow, .auth-subtitle ~ * .eyebrow {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
    font-weight: 600;
}
.auth-eyebrow { margin: 0 0 0.5rem; }
.auth-title {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: -0.015em;
    line-height: 1.08;
    margin: 0 0 0.5rem;
    color: var(--fg);
}
.auth-subtitle { color: var(--muted); margin: 0; font-size: 0.95rem; }
.auth-alert {
    background: color-mix(in srgb, var(--danger) 9%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
}
.auth-footer {
    margin-top: 1.5rem; padding-top: 1.25rem;
    border-top: 1px solid var(--border); text-align: center;
}
.auth-help { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* -------------------------------------------------------------------------
   Form primitives
   ------------------------------------------------------------------------- */
.auth-form, .form { display: flex; flex-direction: column; gap: 1.25rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--fg-soft);
    font-weight: 600;
}
.field input, .field select, .field textarea {
    width: 100%;
    font: inherit;
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.8rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.field-help, .field-error { font-size: 0.82rem; line-height: 1.4; }
.field-help { color: var(--muted); }
.field-error { color: var(--danger); }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45em;
    font: inherit;
    font-weight: 500;
    line-height: 1;
    padding: 0.62rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(0.5px); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn-outline {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--fg);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }

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

.btn-link, .btn-link-sm {
    background: transparent;
    border: none;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
}
.btn-link { color: var(--muted); padding: 0.62rem 0.6rem; }
.btn-link:hover { color: var(--fg); }
.btn-link-sm { font-size: 0.9rem; font-weight: 500; }
.btn-link-sm:hover { text-decoration: underline; }

.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }

.btn-success-flash {
    background: var(--success) !important;
    color: #fff !important;
    border-color: var(--success) !important;
}

.form-actions {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 0.6rem; margin-top: 0.5rem;
}

/* -------------------------------------------------------------------------
   Topbar
   ------------------------------------------------------------------------- */
.topbar {
    background: var(--accent);
    border-bottom: 1px solid color-mix(in srgb, #000 18%, var(--accent));
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.topbar-inner {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}
.topbar-brand {
    display: flex; align-items: center; gap: 0.55rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
    border-bottom: none;
}
.brand-mark {
    width: 11px; height: 11px;
    background: #fff;
    border-radius: 3px;
    display: inline-block;
    flex: none;
    opacity: 0.95;
}
.brand-name { color: #fff; }
.brand-suffix { color: color-mix(in srgb, #fff 72%, transparent); font-weight: 400; font-size: 0.8em; }

.topbar-nav { display: flex; align-items: center; gap: 0.15rem; }
.nav-link {
    font-size: 0.9rem;
    color: color-mix(in srgb, #fff 78%, transparent);
    padding: 0.42rem 0.85rem;
    border-radius: var(--radius-sm);
    border-bottom: none;
    transition: color 0.15s ease, background 0.15s ease;
}
.nav-link:hover { color: #fff; background: color-mix(in srgb, #fff 14%, transparent); }
.nav-link.is-active { color: #fff; background: color-mix(in srgb, #fff 18%, transparent); font-weight: 500; }
.nav-link-button { background: transparent; border: none; cursor: pointer; font: inherit; }
.logout-form { display: inline; margin: 0; padding: 0; }

/* -------------------------------------------------------------------------
   Page scaffold
   ------------------------------------------------------------------------- */
.page { padding: 3rem 1.5rem 5rem; }
.page-inner { max-width: var(--container-width); margin: 0 auto; }
.page-narrow { max-width: 720px; margin: 0 auto; }

.eyebrow {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--muted); margin: 0 0 0.45rem; font-weight: 600;
}
.display {
    font-family: var(--font-display);
    font-size: clamp(2rem, 1.1rem + 3.6vw, 3.1rem);
    font-weight: 400; line-height: 1.04; letter-spacing: -0.02em;
    margin: 0 0 0.4rem; color: var(--fg);
}
.subtitle { color: var(--muted); margin: 0 0 2.5rem; font-size: 1.02rem; }
.welcome { margin-bottom: 3rem; }

.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
    padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}
.page-header .subtitle { margin: 0.35rem 0 0; }
.page-actions { display: flex; gap: 0.6rem; }

.section-title {
    font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; margin: 0;
}

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.5rem 1.75rem;
    box-shadow: var(--shadow-xs);
}
.card-muted { background: var(--surface-sunk); box-shadow: none; }
.card-title {
    font-family: var(--font-display); font-size: 1.35rem; font-weight: 400;
    margin: 0 0 1rem; color: var(--fg);
}
.card-note { color: var(--muted); font-size: 0.88rem; margin: 1rem 0 0; }

/* -------------------------------------------------------------------------
   Metric cards
   ------------------------------------------------------------------------- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}
.metric-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.4rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.metric-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--accent); opacity: 0.0; transition: opacity 0.15s ease;
}
.metric-card:hover::before { opacity: 0.6; }
.metric-card-warn {
    border-color: color-mix(in srgb, var(--warning) 35%, var(--border));
    background: color-mix(in srgb, var(--warning) 5%, var(--surface));
}
.metric-card-warn::before { background: var(--warning); opacity: 0.6; }
.metric-label {
    margin: 0; color: var(--muted); font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600;
}
.metric-value {
    margin: 0; font-family: var(--font-display); font-size: 2.6rem;
    line-height: 1; color: var(--fg); letter-spacing: -0.01em;
}
.metric-link { color: var(--accent); font-size: 0.88rem; border-bottom: none; }
.metric-link:hover { text-decoration: underline; }
.metric-note { color: var(--muted); font-size: 0.85rem; }

/* -------------------------------------------------------------------------
   Quick actions
   ------------------------------------------------------------------------- */
.quick-actions { margin-top: 3rem; }
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem; margin-top: 1.25rem;
}
.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--fg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.action-card:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 3%, var(--surface));
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.action-card h3 {
    margin: 0 0 0.5rem; font-family: var(--font-display);
    font-weight: 500; font-size: 1.25rem;
}
.action-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* -------------------------------------------------------------------------
   Filter bar
   ------------------------------------------------------------------------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
}
.field-inline { margin: 0; flex: 1 1 200px; }
.field-inline input, .field-inline select { margin: 0; }
.checkbox-inline {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.9rem; color: var(--fg); white-space: nowrap; cursor: pointer;
}
.checkbox-inline input { accent-color: var(--accent); width: 1rem; height: 1rem; }

/* -------------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------------- */
.empty-state {
    text-align: center; padding: 4rem 2rem;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty-state p { color: var(--muted); margin: 0 0 1.5rem; }

/* -------------------------------------------------------------------------
   Data table
   ------------------------------------------------------------------------- */
.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.data-table th, .data-table td {
    text-align: left; padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border); vertical-align: middle;
}
.data-table thead th {
    background: var(--surface-sunk);
    font-weight: 600; font-size: 0.72rem;
    text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
    white-space: nowrap;
    position: sticky; top: 0;
}
.data-table tbody tr { transition: background 0.1s ease; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 3.5%, var(--surface)); }
.data-table .row-link { color: var(--fg); text-decoration: none; font-weight: 600; border-bottom: none; }
.data-table .row-link:hover { color: var(--accent); }
.data-table .muted { color: var(--muted); font-size: 0.85em; }
.data-table td code { background: var(--surface-sunk); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Zebra option (opt-in via .data-table-zebra) */
.data-table-zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--fg) 1.6%, var(--surface)); }
.data-table-zebra tbody tr:nth-child(even):hover { background: color-mix(in srgb, var(--accent) 3.5%, var(--surface)); }

/* -------------------------------------------------------------------------
   Badges
   ------------------------------------------------------------------------- */
.badge {
    display: inline-block; padding: 0.18rem 0.55rem; border-radius: 9999px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; border: 1px solid; line-height: 1.4;
}
.badge-ok {
    background: color-mix(in srgb, var(--success) 9%, transparent);
    color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent);
}
.badge-warn {
    background: color-mix(in srgb, var(--warning) 11%, transparent);
    color: var(--warning); border-color: color-mix(in srgb, var(--warning) 32%, transparent);
}
.badge-danger {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}
.badge-neutral {
    background: var(--surface-sunk); color: var(--muted); border-color: var(--border-strong);
}




/* ---- Centre student list: bulk-pay bar (replaces inline styles) --------- */
.bulk-bar {
    margin: 0.75rem 0;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.bulk-bar-note { font-size: 0.85em; }
.data-table th.col-check { width: 24px; }



/* -------------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------------- */
.pager {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 1.5rem; gap: 1rem;
}
.pager-link {
    color: var(--accent); text-decoration: none; padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border-strong); font-size: 0.9rem;
    background: var(--surface);
}
.pager-link:hover { background: var(--accent-tint); border-color: var(--accent); }
.pager-link-disabled { color: var(--muted); cursor: not-allowed; border-color: var(--border); background: var(--surface); }
.pager-link-disabled:hover { background: var(--surface); border-color: var(--border); }
.pager-info { color: var(--muted); font-size: 0.9rem; }

/* -------------------------------------------------------------------------
   Alerts & notices
   ------------------------------------------------------------------------- */
.alert {
    padding: 0.85rem 1rem; border-radius: var(--radius-sm);
    margin-bottom: 1.5rem; font-size: 0.92rem; border: 1px solid transparent;
}
.alert-success {
    background: color-mix(in srgb, var(--success) 8%, transparent);
    border-color: color-mix(in srgb, var(--success) 26%, transparent);
    color: var(--success);
}
.notice {
    padding: 1rem 1.25rem; border-radius: var(--radius);
    margin-bottom: 2rem; font-size: 0.95rem; border: 1px solid;
}
.notice strong { display: block; margin-bottom: 0.25rem; }
.notice p { margin: 0; }
.notice-warning {
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    border-color: color-mix(in srgb, var(--warning) 30%, transparent);
    color: var(--warning);
}

/* -------------------------------------------------------------------------
   Key/value lists
   ------------------------------------------------------------------------- */
.kv {
    display: grid; grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem; margin: 0; font-size: 0.95rem;
}
.kv dt {
    color: var(--muted); font-weight: 500; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.06em; padding-top: 0.15em;
}
.kv dd { margin: 0; color: var(--fg); }
.kv-heading {
    font-family: var(--font-display); font-weight: 500; font-size: 1.05rem;
    margin: 1.5rem 0 0.5rem;
}

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.checklist li { padding-left: 1.5rem; position: relative; color: var(--fg-soft); }
.checklist li::before {
    content: ""; position: absolute; left: 0; top: 0.55em; width: 8px; height: 8px;
    border: 1.5px solid var(--muted); border-radius: 50%;
}

.card-divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* -------------------------------------------------------------------------
   Forms: sections & blocks
   ------------------------------------------------------------------------- */
.form-section {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem; margin-bottom: 1.5rem; background: var(--surface);
}
.form-section-title {
    font-family: var(--font-display); font-weight: 500; font-size: 1.1rem;
    padding: 0 0.5rem; color: var(--fg);
}
.form-stacked .field { margin-bottom: 1rem; }
.checkbox-block {
    display: flex; gap: 0.75rem; align-items: flex-start;
    margin: 1.5rem 0; padding: 1rem;
    background: var(--accent-tint);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
    border-radius: var(--radius); cursor: pointer;
}
.checkbox-block input { margin-top: 0.2rem; accent-color: var(--accent); }
.req { color: var(--accent); font-weight: 700; }

/* -------------------------------------------------------------------------
   Credentials slip
   ------------------------------------------------------------------------- */
.card-credentials { border: 2px solid var(--accent); padding: 2rem; }
.credentials-grid {
    display: grid; grid-template-columns: max-content 1fr;
    gap: 1rem 2rem; margin: 1.5rem 0; align-items: center;
}
.credentials-label {
    color: var(--muted); font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.credentials-value code {
    font-family: var(--font-mono); font-size: 1.5rem;
    background: var(--surface-sunk); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.5rem 1rem; display: inline-block; user-select: all;
}
.credentials-actions { display: flex; gap: 0.75rem; margin: 1.5rem 0; flex-wrap: wrap; }
.credentials-warning {
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
    border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: 1.5rem; color: var(--warning);
}
.credentials-warning strong { display: block; margin-bottom: 0.4rem; }
.credentials-warning p { margin: 0; font-size: 0.9rem; line-height: 1.5; }

/* -------------------------------------------------------------------------
   Dialog
   ------------------------------------------------------------------------- */
.dialog {
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 2rem; max-width: 480px; width: calc(100% - 2rem);
    background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
.dialog-title { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; margin: 0 0 0.5rem; }
.dialog-text { color: var(--muted); margin: 0 0 1.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

/* -------------------------------------------------------------------------
   Recent activity / audit
   ------------------------------------------------------------------------- */
.recent-activity { margin-top: 3rem; }
.recent-activity .data-table { font-size: 0.87rem; }
.recent-activity code { font-size: 0.8rem; word-break: break-word; }

/* -------------------------------------------------------------------------
   Material cards (student)
   ------------------------------------------------------------------------- */
.material-card { border-left: 3px solid var(--accent); }
.material-card .card-title { margin-bottom: 0.5rem; }
.material-card p { margin: 0.5rem 0; line-height: 1.5; }
.material-card .btn { margin-top: 0.5rem; }

/* Preview table errors */
.data-table-preview td .field-error { display: block; margin-top: 0.25rem; font-size: 0.8rem; }
.data-table-preview tr.row-error { background: color-mix(in srgb, var(--accent) 4%, transparent); }

/* -------------------------------------------------------------------------
   Theme variants
   ------------------------------------------------------------------------- */
/* Both portals use a solid colored topbar (set via --accent). They differ by
   hue so admin and center are instantly distinguishable:
   - admin:  navy slate-blue (default --accent)
   - center: deep teal-slate */
.theme-center {
    --accent:     #2c5a55;
    --accent-ink: #224740;
    --accent-tint:#e7f0ee;
    --accent-soft:#3c726b;
}
@media (prefers-color-scheme: dark) {
    .theme-center {
        --accent:     #6fb3aa;
        --accent-ink: #8accc2;
        --accent-tint:#15302c;
        --accent-soft:#5fa49b;
    }
}

/* -------------------------------------------------------------------------
   Utilities
   ------------------------------------------------------------------------- */
.stack-sm > * + * { margin-top: 0.5rem; }
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--muted); }
.count-pill {
    display: inline-block; min-width: 1.5rem; padding: 0.05rem 0.4rem;
    background: var(--surface-sunk); border: 1px solid var(--border);
    border-radius: 9999px; font-size: 0.8rem; color: var(--muted); text-align: center;
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 760px) {
    .topbar-inner { flex-direction: column; gap: 0.75rem; padding: 0.85rem 1rem; align-items: stretch; }
    .topbar-nav { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .page { padding: 2rem 1rem 3rem; }
    .page-header { align-items: flex-start; }
    .kv { grid-template-columns: 1fr; gap: 0.1rem 0; }
    .kv dt { padding-top: 0.75rem; }
    .pager { flex-direction: column; gap: 0.75rem; }
}

/* Part B utilities */
.cards-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .cards-2 { grid-template-columns: 1fr; } }
.mt-3 { margin-top: 0.75rem; }
.mt-5 { margin-top: 1.5rem; }
 

/* Part B utilities */
.cards-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .cards-2 { grid-template-columns: 1fr; } }
.mt-3 { margin-top: 0.75rem; }
.mt-5 { margin-top: 1.5rem; }

/* ---- Material access chips (admin student list) ------------------------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
    display: inline-flex; align-items: center;
    font: inherit; font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.18rem 0.5rem; border-radius: 9999px;
    border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--muted);
    cursor: pointer; white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-on {
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 40%, transparent);
}
.chip-off { background: var(--surface); color: var(--muted); }
.chip-locked {
    cursor: default;
    background: color-mix(in srgb, var(--accent) 9%, var(--surface));
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.chip-locked:hover { border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }
.chip[disabled] { opacity: 0.5; cursor: progress; }

/* ---- Inline credentials popup ------------------------------------------- */
.creds-popup {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: rgba(16,18,21,0.45); backdrop-filter: blur(2px);
    padding: 1rem;
}
.creds-popup-card {
    background: var(--surface); color: var(--fg);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem; max-width: 420px; width: 100%;
}
.creds-popup .kv { margin: 1rem 0; }
.creds-popup code { font-size: 1.15rem; user-select: all; }



/* ---- Toggle switch (admin student list: single material toggle) --------- */
.switch {
    position: relative;
    display: inline-flex; align-items: center;
    width: 42px; height: 24px;
    border-radius: 9999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-sunk);
    cursor: pointer; padding: 0; vertical-align: middle;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.switch-knob {
    position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: var(--shadow-xs);
    transition: left 0.15s ease;
}
.switch-on {
    background: var(--success);
    border-color: color-mix(in srgb, var(--success) 60%, transparent);
}
.switch-on .switch-knob { left: 20px; }
.switch-warn { border-color: color-mix(in srgb, var(--warning) 55%, transparent); }
.switch-warn.switch-on { background: var(--warning); }
.switch[aria-disabled="true"] { opacity: 0.5; cursor: progress; }
.switch-hint { font-size: 0.72rem; margin-left: 0.35rem; vertical-align: middle; }

/* ---- Material access chips (admin student list) ------------------------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
    display: inline-flex; align-items: center;
    font: inherit; font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.18rem 0.5rem; border-radius: 9999px;
    border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--muted);
    cursor: pointer; white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-on {
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 40%, transparent);
}
.chip-off { background: var(--surface); color: var(--muted); }
.chip-locked {
    cursor: default;
    background: color-mix(in srgb, var(--accent) 9%, var(--surface));
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.chip-locked:hover { border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }
.chip[disabled] { opacity: 0.5; cursor: progress; }

/* ---- Inline credentials popup ------------------------------------------- */
.creds-popup {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: rgba(16,18,21,0.45); backdrop-filter: blur(2px);
    padding: 1rem;
}
.creds-popup-card {
    background: var(--surface); color: var(--fg);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem; max-width: 420px; width: 100%;
}
.creds-popup .kv { margin: 1rem 0; }
.creds-popup code { font-size: 1.15rem; user-select: all; }

/* Part B utilities */
.cards-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .cards-2 { grid-template-columns: 1fr; } }
.mt-3 { margin-top: 0.75rem; }
.mt-5 { margin-top: 1.5rem; }

/* ---- Embedded document manager (center edit form) ---------------------- */
.doc-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.85rem;
    background: var(--surface);
}
.doc-block-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; margin-bottom: 0.6rem;
}
.doc-block-title { font-weight: 600; font-size: 0.95rem; }
.doc-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.doc-list-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; padding: 0.4rem 0.6rem;
    background: var(--surface-sunk); border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.doc-del-form { margin: 0; }
.doc-upload-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.doc-upload-form input[type="file"] { flex: 1 1 auto; min-width: 0; font-size: 0.88rem; }


/* -------------------------------------------------------------------------
   Print
   ------------------------------------------------------------------------- */
@media print {
    .topbar, .credentials-actions, .form-actions, .credentials-warning, .filter-bar, .pager { display: none !important; }
    body { background: #fff; color: #000; }
    .card, .card-credentials { border-color: #ccc; box-shadow: none; }
}

/* -------------------------------------------------------------------------
   CSP-safe utilities (replace inline style="..." in views; strict CSP blocks
   inline styles, so anything that used a style attribute lives here instead)
   ------------------------------------------------------------------------- */
.ml-2 { margin-left: 0.4rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.badge-inline { margin-left: 0.4rem; vertical-align: middle; }

/* Hide options the batch-filter script narrows out (no inline style needed) */
.is-hidden { display: none !important; }
