:root {
    --sidebar-w: 268px;
    --topbar-h: 68px;

    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Archivo', 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'SFMono-Regular', monospace;

    /* ---------- Modern Light Mode (default) ---------- */
    --ink: #0f172a;
    --muted: #64748b;
    --faint: #94a3b8;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --card-bg: #ffffff;

    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-soft: #f0fdfa;
    --on-accent: #ffffff;

    --success: #10b981;
    --success-soft: #ecfdf5;
    --success-text: #067647;
    --danger: #f04438;
    --danger-soft: #fef3f2;
    --danger-text: #b3261e;
    --danger-hover-bg: #fde0de;
    --warning: #f79009;
    --warning-soft: #fffaeb;
    --warning-text: #b45309;

    /* Attendance states. Separate from --success/--danger/--warning because
       those are tuned for soft-background badges, not for solid fills with
       white text: white on --warning (#f79009) is about 2.3:1, well under
       the 4.5:1 needed to be readable. These three are darkened until white
       text passes on all of them. */
    --att-present: #0a8159;
    --att-absent: #d92d20;
    --att-leave: #b45309;
    --att-present-tint: #ecfdf5;
    --att-absent-tint: #fef3f2;
    --att-leave-tint: #fffaeb;

    --sidebar-bg: #ffffff;
    --sidebar-bg-2: #f8fafc;
    --sidebar-ink: #64748b;
    --sidebar-ink-strong: #0f172a;
    --sidebar-border: rgba(15, 23, 42, 0.08);
    --sidebar-hover-bg: rgba(15, 23, 42, 0.05);
    --sidebar-eyebrow: rgba(15, 23, 42, 0.45);

    --row-hover: rgba(15, 23, 42, 0.035);

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 2px 4px -1px rgba(16, 24, 40, .06), 0 6px 16px -4px rgba(16, 24, 40, .08);
}

/* ---------- Dusk Dark Mode: near-black pine, not generic slate ---------- */
:root[data-theme="dark"] {
    --ink: #f8fafc;
    --muted: #94a3b8;
    --faint: #64748b;
    --border: #334155;
    --bg: #0f172a;
    --card-bg: #1e293b;

    --accent-hover: #2dd4bf;
    --accent-soft: rgba(13, 148, 136, 0.18);

    --success-soft: rgba(16, 185, 129, 0.16);
    --success-text: #6ee7b7;
    --danger-soft: rgba(240, 68, 56, 0.16);
    --danger-text: #fca5a5;
    --danger-hover-bg: rgba(240, 68, 56, 0.24);
    --warning-soft: rgba(247, 144, 9, 0.16);
    --warning-text: #fcd34d;

    /* Lifted on dark, where the light-theme values would read as muddy. */
    --att-present: #0e9f6e;
    --att-absent: #e5484d;
    --att-leave: #d97706;
    --att-present-tint: rgba(14, 159, 110, 0.14);
    --att-absent-tint: rgba(229, 72, 77, 0.14);
    --att-leave-tint: rgba(217, 119, 6, 0.14);

    --sidebar-bg: #0b1220;
    --sidebar-bg-2: #111827;
    --sidebar-ink: #94a3b8;
    --sidebar-ink-strong: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.07);
    --sidebar-eyebrow: rgba(248, 250, 252, 0.55);

    --row-hover: rgba(255, 255, 255, 0.035);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 2px 4px -1px rgba(0, 0, 0, .35), 0 6px 16px -4px rgba(0, 0, 0, .45);
}

.app-body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    transition: background 0.15s, color 0.15s;
}

.app-body * {
    box-sizing: border-box;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #0d9488, #115e59);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35);
}

.brand-logo svg {
    width: 22px;
    height: 22px;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 15.5px;
    font-weight: 600;
    color: var(--sidebar-ink-strong);
    line-height: 1.3;
}

.brand-sub {
    font-size: 11.5px;
    color: var(--sidebar-ink);
    opacity: 0.75;
    margin-top: 1px;
}

.nav {
    padding: 16px 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-eyebrow {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-eyebrow);
    padding: 14px 12px 6px;
}

.nav-eyebrow:first-child {
    padding-top: 2px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.85;
    transition: transform 0.15s, opacity 0.15s;
}

.nav-icon svg {
    width: 16px;
    height: 16px;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

/* Sliding accent bar on the leading edge - only "arrives" on hover/active,
   giving the sidebar a bit of tactile motion instead of a flat color swap. */
.nav-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    transform: scaleY(0);
    transition: transform 0.15s;
}

.nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-ink-strong);
    transform: translateX(2px);
}

.nav-link:hover .nav-icon {
    transform: scale(1.12);
    opacity: 1;
}

.nav-link:active {
    transform: translateX(2px) scale(0.98);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: var(--on-accent);
    font-weight: 600;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.nav-link.active::before {
    transform: scaleY(1);
    background: #fff;
}

.nav-link.active .nav-icon {
    opacity: 1;
}

.nav-group summary {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--sidebar-ink-strong);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s, transform 0.12s ease;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary .nav-caret {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.15s;
}

.nav-group[open] summary .nav-caret {
    transform: rotate(180deg);
}

.nav-group[open] summary .nav-icon {
    opacity: 1;
}

.nav-group summary:hover {
    background: var(--sidebar-hover-bg);
    transform: translateX(2px);
}

.nav-group summary:active {
    transform: translateX(2px) scale(0.98);
}

.nav-subitems {
    padding-left: 17px;
    margin: 3px 0 8px 15px;
    border-left: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-subitems .nav-link {
    font-size: 13px;
    font-weight: 400;
    padding: 7px 10px;
}

.nav-subitems .nav-group summary {
    font-size: 13px;
    font-weight: 500;
    padding: 7px 10px;
}

/* ---------- Main / topbar ---------- */

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

.topbar {
    height: var(--topbar-h);
    flex: 0 0 var(--topbar-h);
    background: var(--card-bg);
    box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 17px;
    cursor: pointer;
    color: var(--ink);
    box-shadow: 0 2px 0 var(--border);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.15s;
}

.sidebar-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--border);
}

.sidebar-toggle:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 var(--border);
}

.page-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    flex: 1;
    letter-spacing: -0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 0 var(--border);
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s ease, box-shadow 0.12s ease;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px) rotate(-12deg);
    box-shadow: 0 3px 0 var(--border);
}

.theme-toggle:active {
    transform: translateY(2px) rotate(0deg);
    box-shadow: 0 0 0 var(--border);
}

.theme-toggle svg {
    width: 17px;
    height: 17px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Attendance marking control ---------- */
/*
   A segmented three-way toggle per student (modules/attendance/
   mark_student.php) instead of three bare radio dots, which gave no colour
   cue and made a 130-student roster impossible to scan.

   Every rule here is written as `.att-toggle .att-opt` (two classes) rather
   than `.att-toggle label` (one class + one element). That is deliberate:
   `.panel label { display:block; margin:16px 0 6px }` further down this
   file has the SAME specificity as `.att-toggle label` and, being later in
   source order, won - so the first label in each group picked up
   `:first-of-type { margin-top:0 }` while the other two got a 16px top
   margin, tearing the pill apart vertically. Two classes outrank it
   regardless of order.

   The radios remain real radios (visually hidden, labels driving them), so
   keyboard use, focus, and the name="status[adm]" contract are unchanged.
*/
.att-toggle {
    display: inline-flex;
    align-items: stretch;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    white-space: nowrap;
    line-height: 0; /* kills the inline-gap under the labels */
}

.att-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.att-toggle .att-opt {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 76px;
    margin: 0;
    padding: 6px 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.01em;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

/* Hover previews the colour that clicking would apply. */
.att-toggle .att-opt.att-p:hover { background: var(--att-present-tint); color: var(--att-present); }
.att-toggle .att-opt.att-a:hover { background: var(--att-absent-tint);  color: var(--att-absent); }
.att-toggle .att-opt.att-l:hover { background: var(--att-leave-tint);   color: var(--att-leave); }

.att-toggle input:checked + .att-opt {
    color: #ffffff;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.att-toggle input:checked + .att-opt.att-p { background: var(--att-present); }
.att-toggle input:checked + .att-opt.att-a { background: var(--att-absent); }
.att-toggle input:checked + .att-opt.att-l { background: var(--att-leave); }

/* Keep the hover preview from washing out the already-selected segment. */
.att-toggle input:checked + .att-opt.att-p:hover { background: var(--att-present); color: #ffffff; }
.att-toggle input:checked + .att-opt.att-a:hover { background: var(--att-absent);  color: #ffffff; }
.att-toggle input:checked + .att-opt.att-l:hover { background: var(--att-leave);   color: #ffffff; }

.att-toggle input:focus-visible + .att-opt {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Attendance cell: keep the control off the row edge and stop the table
   from stretching the pill. */
.data-table td.att-cell {
    padding-top: 8px;
    padding-bottom: 8px;
    white-space: nowrap;
}

/* A coloured edge on rows that are not plain Present, so exceptions stand
   out down a long roster. Decorative: browsers without :has() just show an
   untinted row, and the toggle still carries the colour. */
.att-row td:first-child {
    border-left: 3px solid transparent;
}

.att-row:has(.att-a input:checked) td:first-child { border-left-color: var(--att-absent); }
.att-row:has(.att-l input:checked) td:first-child { border-left-color: var(--att-leave); }
.att-row:has(.att-a input:checked) { background: var(--att-absent-tint); }
.att-row:has(.att-l input:checked) { background: var(--att-leave-tint); }

/* Running tally beside the bulk buttons. */
.att-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.att-legend .att-count {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
}

.att-legend .att-count b {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.att-legend .att-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.att-dot-p { background: var(--att-present); }
.att-dot-a { background: var(--att-absent); }
.att-dot-l { background: var(--att-leave); }

.att-count-p { background: var(--att-present-tint); color: var(--att-present); border-color: var(--att-present-tint); }
.att-count-a { background: var(--att-absent-tint);  color: var(--att-absent);  border-color: var(--att-absent-tint); }
.att-count-l { background: var(--att-leave-tint);   color: var(--att-leave);   border-color: var(--att-leave-tint); }

/* Bulk "mark all" row. The generic .btn-secondary carries margin-top:20px
   and margin-left:8px, which is why these sat unevenly against the table;
   .att-bulk overrides the spacing and groups them as one toolbar. */
.att-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin: 16px 0 14px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.att-bulk-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.att-bulk-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 2px;
}

.att-toolbar .att-bulk {
    margin: 0;
    padding: 6px 14px;
    border-radius: 999px;
    /* font-family is not inherited by <button> - without this they render in
       the browser's UI font while everything around them is Archivo. */
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--muted);
    box-shadow: none;
    transform: none;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.att-toolbar .att-bulk:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.att-toolbar .att-bulk:hover {
    transform: none;
    box-shadow: none;
}

.att-toolbar .att-bulk-p:hover { background: var(--att-present-tint); color: var(--att-present); border-color: var(--att-present); }
.att-toolbar .att-bulk-a:hover { background: var(--att-absent-tint);  color: var(--att-absent);  border-color: var(--att-absent); }
.att-toolbar .att-bulk-l:hover { background: var(--att-leave-tint);   color: var(--att-leave);   border-color: var(--att-leave); }

@media (max-width: 720px) {
    .att-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .att-toggle .att-opt {
        min-width: 62px;
        padding: 6px 10px;
    }
}

/* Read-only status pill, for the screens that show attendance rather than
   set it (manual marking grid, attendance history). Same colour language as
   the toggle above so P/A/L mean the same thing everywhere. */
.att-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.att-badge-p { background: var(--att-present-tint); color: var(--att-present); }
.att-badge-a { background: var(--att-absent-tint);  color: var(--att-absent); }
.att-badge-l { background: var(--att-leave-tint);   color: var(--att-leave); }
.att-badge-o { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }

.topbar-clock {
    font-size: 13px;
    color: var(--muted);
    min-width: 165px;
    text-align: right;
    padding-right: 16px;
    border-right: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-meta {
    text-align: left;
    line-height: 1.3;
}

.user-name {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
}

.user-role {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
}

.logout-link:hover {
    background: var(--danger-hover-bg);
}

.content {
    padding: 28px;
    flex: 1;
}

.content-header {
    margin: -4px 0 22px;
}

.content-header h2 {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
    font-weight: 500;
}

/* ---------- Dashboard widgets ---------- */

/* One well-orchestrated load-in beats scattered micro-interactions: stat
   cards and panels rise/fade in with a short stagger (nth-child delay)
   the first time a page paints. `backwards` fills the pre-animation state
   so cards don't flash at full opacity before their delay kicks in. */
@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-grid > .stat-card,
.panel-grid > .panel,
.content > .panel {
    animation: rise-in .5s cubic-bezier(.16, 1, .3, 1) backwards;
}

.stat-grid > .stat-card:nth-child(1) { animation-delay: .03s; }
.stat-grid > .stat-card:nth-child(2) { animation-delay: .08s; }
.stat-grid > .stat-card:nth-child(3) { animation-delay: .13s; }
.stat-grid > .stat-card:nth-child(4) { animation-delay: .18s; }
.stat-grid > .stat-card:nth-child(n+5) { animation-delay: .22s; }

.panel-grid > .panel:nth-child(1),
.content > .panel:nth-child(1) { animation-delay: .1s; }
.panel-grid > .panel:nth-child(2),
.content > .panel:nth-child(2) { animation-delay: .16s; }
.panel-grid > .panel:nth-child(n+3) { animation-delay: .2s; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transform: perspective(700px);
    transition: box-shadow 0.15s, transform 0.15s;
    will-change: transform;
}

/* app.js drives a live rotateX/rotateY tilt toward the cursor while
   hovered (mouse-tracking, disabled under prefers-reduced-motion) - this
   just supplies the resting/lifted shadow either side of that. */
.stat-card:has(a):hover {
    box-shadow: 0 14px 24px -10px rgba(16, 24, 40, 0.25), var(--shadow-md);
}

.stat-card.tilt-active {
    transition: box-shadow 0.15s;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.tone-indigo { background: var(--accent-soft); }
.stat-icon.tone-green { background: var(--success-soft); }
.stat-icon.tone-amber { background: var(--warning-soft); }
.stat-icon.tone-red { background: var(--danger-soft); }

.stat-body {
    min-width: 0;
}

.stat-card .stat-label {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 600;
}

.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    margin-top: 2px;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.stat-card a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 18px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] .panel {
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel h3 {
    margin: 0 0 18px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

.attendance-row {
    display: flex;
    align-items: center;
    gap: 28px;
}

.donut-wrap {
    position: relative;
    width: 128px;
    height: 128px;
    flex-shrink: 0;
}

.donut {
    width: 128px;
    height: 128px;
    border-radius: 50%;
}

.donut-hole {
    position: absolute;
    inset: 20px;
    background: var(--card-bg);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-hole .donut-total {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}

.donut-hole .donut-caption {
    font-size: 10px;
    color: var(--muted);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 9px;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--ink);
}

.empty-note {
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Dashboard donut charts ---------- */
/* Every "comparison" widget on the dashboard is a renderDonut() call now
   (see dashboard.php) - they all reuse the same .attendance-row/.donut/
   .legend markup as the original attendance donuts, so this is just the
   chart-panel-specific bits (title spacing, the summary line under the
   Fee Collection Progress donut). */

.chart-panel h3 {
    margin-bottom: 14px;
}

.chart-caption {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chart-caption a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

/* ---------- Tabs (shared by modules) ---------- */

.tab-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-link {
    padding: 9px 16px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-link:hover {
    color: var(--ink);
    background: var(--bg);
}

.tab-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---------- Forms, tables, alerts (shared by modules) ---------- */

.alert {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger-text);
    border: 1px solid var(--danger-text);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success-text);
    border: 1px solid var(--success-text);
}

.search-bar {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--ink);
}

.data-table tbody tr:hover {
    background: var(--row-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Campus > Class > Student grouping rows used by the fee reports (see
   groupFeeRows() in modules/reports/fee.php). */
.data-table tr.group-row-campus td {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 9px 10px;
}

.data-table tr.group-row-class td {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 700;
    font-size: 12.5px;
    padding: 8px 10px;
}

.data-table tr.group-row-subtotal td {
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    border-bottom: 1px dashed var(--border);
    padding: 8px 10px;
}

.table-actions {
    text-align: right;
    white-space: nowrap;
}

.table-actions a {
    color: var(--accent);
    text-decoration: none;
    margin-right: 14px;
    font-size: 13px;
    font-weight: 600;
}

.link-danger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: none;
    border: none;
    color: var(--danger-text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, transform 0.12s;
}

.link-danger:hover {
    background: var(--danger-soft);
}

.link-danger:active {
    transform: scale(0.96);
}

/* The neutral twin of .link-danger, for a bare in-table action button
   that isn't destructive (Reset Password, Enable). Same geometry, so the
   two sit level next to each other in a table-actions cell. */
.link-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: none;
    border: none;
    color: var(--accent-hover);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, transform 0.12s;
}

.link-button:hover {
    background: var(--accent-soft);
}

.link-button:active {
    transform: scale(0.96);
}

.link-danger .btn-ico svg {
    width: 13px;
    height: 13px;
}

/* Same idea as .btn-sm, but for .link-danger's bare text-link look (no
   padding/border to shrink - .btn-sm's box padding would wrongly add one). */
.link-danger-sm {
    font-size: 11.5px;
}

.role-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.role-staff { background: var(--success-soft); color: var(--success-text); }
.role-accounts { background: var(--warning-soft); color: var(--warning-text); }

/*
 * Deliberately scoped to ".panel label" etc rather than ".panel form
 * label" - a plain descendant selector needs the DOM nesting order to
 * match exactly what it names, and several pages have a single <form>
 * wrapping more than one .panel (e.g. Change Class's transfer form
 * wraps both the roster panel and the destination panel so one submit
 * carries both), which is .panel *inside* form rather than form inside
 * .panel - ".panel form label" silently matched nothing there. Styling
 * every label/input/select/textarea found anywhere inside a .panel
 * works regardless of which element - .panel or form - is the outer
 * one.
 */
.panel label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin: 16px 0 6px;
    color: var(--ink);
}

.panel label:first-of-type {
    margin-top: 0;
}

.panel input[type="text"],
.panel input[type="password"],
.panel input[type="email"],
.panel input[type="date"],
.panel input[type="time"],
.panel input[type="month"],
.panel input[type="number"],
.panel input[type="tel"],
.panel input[type="search"],
.panel input[type="url"],
.panel input[type="file"],
.panel select,
.panel textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.panel textarea {
    resize: vertical;
    min-height: 64px;
}

.panel input:focus,
.panel select:focus,
.panel textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/*
 * 3D button treatment: a gradient fill plus a solid "edge" shadow standing
 * in for the button's own thickness (rather than a soft blur alone), so
 * the button reads as a raised, pressable object. Hover lifts it a touch
 * and deepens the edge; :active flattens it back down onto that edge to
 * sell the press. Icons injected by app.js land in .btn-ico.
 */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transform: translateY(0);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s;
}

.btn-primary {
    margin-top: 20px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--accent-hover), var(--accent));
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--accent-hover), 0 6px 14px -4px rgba(13, 148, 136, 0.5);
}

.btn-primary:hover {
    background: linear-gradient(180deg, var(--accent-hover), var(--accent-hover));
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--accent-hover), 0 10px 18px -4px rgba(13, 148, 136, 0.55);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--accent-hover), 0 3px 8px -2px rgba(13, 148, 136, 0.5);
}

.btn-secondary {
    margin-top: 20px;
    margin-left: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 0 var(--border), var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--accent-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 3px 0 var(--border), var(--shadow-md);
}

.btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 var(--border), var(--shadow-sm);
}

.btn-ico {
    display: inline-flex;
    flex-shrink: 0;
}

.btn-ico svg {
    width: 14px;
    height: 14px;
}

/* Click ripple - app.js drops a .btn-ripple span at the pointer position on
   mousedown; this animates it into an expanding, fading disc. */
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    transform: scale(0);
    pointer-events: none;
    animation: btn-ripple-out 0.5s ease-out forwards;
}

.btn-secondary .btn-ripple,
.link-danger .btn-ripple {
    background: rgba(13, 148, 136, 0.18);
}

@keyframes btn-ripple-out {
    to {
        transform: scale(2.6);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn-primary,
    .btn-secondary,
    .nav-link,
    .stat-card {
        transition: none !important;
    }
    .btn-ripple {
        animation: none !important;
        display: none;
    }
    .stat-grid > .stat-card,
    .panel-grid > .panel,
    .content > .panel {
        animation: none !important;
        opacity: 1;
        transform: none;
    }
}

/*
 * Size modifiers for .btn-primary/.btn-secondary/.link-danger - toolbar
 * buttons (Print, card-footer View/Edit, compact table-row actions) had
 * each picked their own one-off font-size/padding (11.5px, 12px, 12.5px
 * all doing the same job), so no two pages' "small button" matched. Use
 * .btn-sm for any button that needs to sit inline in a toolbar, table
 * row, or card footer instead of a bespoke inline style, and .btn-lg for
 * an oversized emphasis submit button.
 */
.btn-sm {
    margin: 0;
    padding: 5px 12px;
    font-size: 12.5px;
}

.btn-lg {
    margin-top: 20px;
    padding: 12px 28px;
    font-size: 14.5px;
}

/* ---------- Long multi-section forms (registration etc.) ---------- */

.form-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    margin-bottom: 18px;
    scroll-margin-top: 84px;
}

:root[data-theme="dark"] .form-section {
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.form-section h3 {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 17.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

.form-section .section-hint {
    margin: 0 0 18px;
    font-size: 12.5px;
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px 18px;
}

.field {
    display: flex;
    flex-direction: column;
}

.field-wide {
    grid-column: 1 / -1;
}

.field label {
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
}

.field .hint {
    font-size: 11px;
    color: var(--faint);
    margin-top: 4px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="date"],
.field input[type="time"],
.field input[type="month"],
.field input[type="number"],
.field input[type="tel"],
.field input[type="search"],
.field input[type="url"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field textarea {
    resize: vertical;
    min-height: 64px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input[readonly] {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
    border-color: transparent;
}

/*
 * Searchable select: app.js wraps every <select> in a .ss-wrap and adds a
 * filterable text input + listbox on top of it. The original <select>
 * stays in the DOM (kept visually hidden via the classic clip-rect
 * technique rather than display:none) so it still posts with the form
 * and still participates in native "required" validation - display:none
 * fields are silently excluded from constraint validation, which would
 * have made required dropdowns submit empty.
 */
.ss-wrap {
    position: relative;
    display: block;
}

.ss-wrap > select.ss-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ss-input {
    width: 100%;
    padding: 10px 30px 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.ss-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px var(--accent-soft);
    cursor: text;
}

.ss-input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.ss-wrap::after {
    content: "\25BE";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--faint);
    pointer-events: none;
}

.ss-list {
    position: absolute;
    z-index: 40;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 4px;
}

.ss-option {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-option:hover,
.ss-option.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.ss-empty {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--faint);
}

.field-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.field-checkbox input {
    width: auto;
}

.sticky-nav {
    position: sticky;
    top: calc(var(--topbar-h) + 12px);
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

.sticky-nav a {
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
}

.sticky-nav a:hover {
    background: var(--bg);
    color: var(--ink);
}

.photo-upload {
    display: flex;
    align-items: center;
    gap: 16px;
}

.photo-preview {
    width: 84px;
    height: 84px;
    border-radius: var(--radius-md);
    background: var(--bg);
    border: 1px solid var(--border);
    object-fit: cover;
    flex-shrink: 0;
}

.photo-preview-placeholder {
    width: 84px;
    height: 84px;
    border-radius: var(--radius-md);
    background: var(--bg);
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--faint);
    flex-shrink: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

/* ---------- Placeholder / forbidden ---------- */

.placeholder-panel {
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 70px 24px;
    text-align: center;
    color: var(--muted);
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
}

.placeholder-panel h2 {
    color: var(--ink);
    font-family: var(--font-display);
    margin: 0 0 8px;
    font-size: 19px;
}

.placeholder-panel p {
    max-width: 360px;
    margin: 0 auto;
    font-size: 13.5px;
    line-height: 1.6;
}

/* Mobile drawer close button, shown inside the sidebar itself - the
   sidebar sits above the topbar (z-index 20 vs 5) once open, so it
   physically covers the hamburger button that opened it. Without this,
   or the backdrop below, there was no way to close the drawer short of
   navigating to a new page. */
.sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: auto;
    flex-shrink: 0;
    border: none;
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-ink-strong);
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.2s;
        box-shadow: var(--shadow-md);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .sidebar-close {
        display: flex;
    }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 19;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }
    .sidebar-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
    .topbar-clock {
        display: none;
    }
    .content {
        padding: 18px;
    }
}

/*
 * Confirm modal - an in-page replacement for window.confirm() used where a
 * dialog needs its own message/buttons (e.g. an overpayment warning), styled
 * to match .panel/.btn-primary instead of the browser's native prompt.
 */
.confirm-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.45);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.confirm-modal-backdrop.open {
    display: flex;
}

.confirm-modal {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 22px;
    max-width: 420px;
    width: 100%;
}

.confirm-modal h4 {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}

.confirm-modal p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink);
    white-space: pre-line;
}

.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ---------- Certificates: rendered as an actual certificate document
   (ornamental border, centered title, narrative paragraph), not just a
   label:value table inside a plain .panel. ---------- */
.certificate {
    --cert-accent: #b7862c;
    position: relative;
    margin: 14px 0 4px;
    padding: 42px 48px 34px;
    background: var(--card-bg);
    border: 2px solid var(--cert-accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

:root[data-theme="dark"] .certificate {
    --cert-accent: #d4af6a;
}

.certificate::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid var(--cert-accent);
    opacity: 0.55;
    pointer-events: none;
}

.certificate-corner {
    position: absolute;
    z-index: 2;
    width: 22px;
    height: 22px;
    border: 2px solid var(--cert-accent);
    opacity: 0.9;
    pointer-events: none;
}

.certificate-corner.tl { top: 14px; left: 14px; border-right: 0; border-bottom: 0; }
.certificate-corner.tr { top: 14px; right: 14px; border-left: 0; border-bottom: 0; }
.certificate-corner.bl { bottom: 14px; left: 14px; border-right: 0; border-top: 0; }
.certificate-corner.br { bottom: 14px; right: 14px; border-left: 0; border-top: 0; }

/* School name, repeated large and faint on a diagonal behind the whole
   card - printed certificates use this to make a copy harder to pass off
   as issued by someone else. */
.certificate-watermark {
    position: absolute;
    z-index: 0;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

.certificate-watermark span {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(26px, 8vw, 58px);
    line-height: 1;
    color: var(--cert-accent);
    opacity: 0.09;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 2px;
    transform: rotate(-28deg);
}

.certificate-content {
    position: relative;
    z-index: 1;
}

.certificate-school {
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: 0.5px;
    color: var(--ink);
    margin-bottom: 2px;
}

.certificate-seal {
    position: absolute;
    z-index: 2;
    right: 40px;
    bottom: 34px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1.5px dashed var(--cert-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.certificate-seal::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid var(--cert-accent);
    border-radius: 50%;
}

.certificate-seal svg {
    width: 26px;
    height: 26px;
    color: var(--cert-accent);
}

.certificate-title {
    text-align: center;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 600;
    font-size: 40px;
    color: var(--ink);
    margin: 0;
}

.certificate-subtitle {
    text-align: center;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 4px;
}

.certificate-rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 18px auto 22px;
    max-width: 260px;
}

.certificate-rule span {
    flex: 1;
    height: 1px;
    background: var(--cert-accent);
    opacity: 0.6;
}

.certificate-rule i {
    width: 6px;
    height: 6px;
    background: var(--cert-accent);
    transform: rotate(45deg);
    display: block;
    flex-shrink: 0;
}

.certificate-lead {
    text-align: center;
    font-size: 13px;
    font-style: italic;
    color: var(--muted);
    margin: 0 0 8px;
}

.certificate-recipient {
    text-align: center;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 auto 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    max-width: 480px;
}

.certificate-body {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
    font-size: 14.5px;
    line-height: 1.85;
    color: var(--ink);
}

.certificate-body strong {
    font-weight: 700;
    color: var(--ink);
}

.certificate-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 22px;
    margin-top: 20px;
    font-size: 11.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.certificate-meta strong {
    color: var(--ink);
    text-transform: none;
    letter-spacing: normal;
    font-family: var(--font-mono);
}

.certificate-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-top: 46px;
}

.certificate-sign {
    text-align: center;
    min-width: 150px;
}

.certificate-sign strong {
    display: block;
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--ink);
}

.certificate-sign span {
    display: block;
    padding-top: 6px;
    border-top: 1px solid var(--ink);
    margin-top: 22px;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

@media (max-width: 640px) {
    .certificate { padding: 30px 20px 26px; }
    .certificate-title { font-size: 30px; }
    .certificate-recipient { font-size: 22px; }
    .certificate-seal { display: none; }
    .certificate-footer { flex-direction: column; align-items: center; gap: 30px; }
}

/* ---------- Result Card: the on-screen counterpart to
   includes/result_card_pdf.php's A4 report card - a double-rule frame,
   identity block, ruled marks table, summary strip and signature footer,
   width-capped to roughly A4's proportions, instead of a bare
   .data-table. ---------- */
.result-card {
    position: relative;
    margin: 14px auto 4px;
    width: 100%;
    max-width: 720px;
    padding: 34px 38px 30px;
    background: var(--card-bg);
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-md);
}

.result-card::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1px solid var(--border);
    pointer-events: none;
}

.result-card-mast {
    text-align: center;
}

.result-card-school {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 21px;
    color: var(--ink);
}

.result-card-nick {
    font-size: 12px;
    font-style: italic;
    color: var(--muted);
    margin-top: 2px;
}

.result-card-contact {
    font-size: 11px;
    color: var(--faint);
    margin-top: 1px;
}

.result-card-rule {
    height: 3px;
    margin: 12px 0 14px;
    background:
        linear-gradient(var(--ink), var(--ink)) top / 100% 2px no-repeat,
        linear-gradient(var(--border), var(--border)) bottom / 100% 1px no-repeat;
}

.result-card-title {
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 3px;
    color: var(--ink);
}

.result-card-term {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
    margin-bottom: 14px;
}

.result-card-identity {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.result-card-identity div {
    display: flex;
    gap: 6px;
    font-size: 13px;
}

.result-card-identity span {
    color: var(--muted);
    min-width: 88px;
    flex-shrink: 0;
}

.result-card-identity strong {
    color: var(--ink);
    font-weight: 700;
}

.result-card-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin-bottom: 4px;
}

.result-card-table th {
    border-top: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    padding: 7px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink);
    text-align: center;
}

.result-card-table th:first-child {
    text-align: left;
}

.result-card-table td {
    border-bottom: 1px solid var(--border);
    padding: 6px;
    text-align: center;
    color: var(--ink);
}

.result-card-table td:first-child {
    text-align: left;
}

.result-card-table tr.result-card-total td {
    border-top: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    font-weight: 700;
}

.result-card-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin: 16px 0 8px;
}

.result-card-summary div {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 6px;
    text-align: center;
}

.result-card-summary span {
    display: block;
    font-size: 10.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-card-summary strong {
    display: block;
    font-size: 16px;
    color: var(--ink);
    margin-top: 2px;
}

.result-card-legend {
    text-align: center;
    font-size: 10.5px;
    font-style: italic;
    color: var(--muted);
    margin: 4px 0 18px;
}

.result-card-remarks {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px 16px;
    margin-bottom: 22px;
    background-image: repeating-linear-gradient(to bottom, transparent 0 21px, var(--border) 21px 22px);
}

.result-card-remarks span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.result-card-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.result-card-footer div {
    flex: 1;
    text-align: center;
}

.result-card-footer span {
    display: block;
    height: 26px;
    border-bottom: 1px solid var(--ink);
}

.result-card-footer label {
    display: block;
    margin-top: 5px;
    font-size: 10.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

@media (max-width: 640px) {
    .result-card { padding: 22px 18px 20px; }
    .result-card-identity { grid-template-columns: 1fr; }
    .result-card-footer { flex-direction: column; gap: 14px; }
}

.confirm-modal-actions .btn-primary,
.confirm-modal-actions .btn-secondary {
    margin-top: 0;
}
