:root {
    --primary: #0d6e4f;
    --primary-dark: #094d38;
    --primary-light: #e8f5f0;
    --accent: #f0a500;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a2332;
    --text-muted: #5c6b7a;
    --border: #dde3ea;
    --danger: #c0392b;
    --success: #1e8449;
    --warning: #b7791f;
    --info: #2b6cb0;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(26, 35, 50, 0.08);
    --font: 'DM Sans', system-ui, sans-serif;
}

[data-theme="dark"] {
    --primary: #2dd4a0;
    --primary-dark: #0d6e4f;
    --primary-light: #1a2e28;
    --bg: #0f1419;
    --surface: #1a2332;
    --text: #e8edf2;
    --text-muted: #94a3b8;
    --border: #2d3a4d;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* Portal themes — admin (navy) vs student (green) */
body.portal-admin {
    --primary: #1a4d8f;
    --primary-dark: #1e3a5f;
    --primary-light: #e8eef7;
    --accent: #f0a500;
    --sidebar-start: #1e3a5f;
    --sidebar-end: #0f2847;
    --topbar-accent: #1a4d8f;
}

body.portal-student {
    --primary: #0d6e4f;
    --primary-dark: #094d38;
    --primary-light: #e8f5f0;
    --accent: #f0a500;
    --sidebar-start: #094d38;
    --sidebar-end: #063828;
    --topbar-accent: #0d6e4f;
}

html[data-theme="dark"] body.portal-admin {
    --primary: #6ba3e0;
    --primary-dark: #1a4d8f;
    --primary-light: #1a2744;
    --sidebar-start: #0f2847;
    --sidebar-end: #0a1628;
    --topbar-accent: #6ba3e0;
}

html[data-theme="dark"] body.portal-student {
    --primary: #2dd4a0;
    --primary-dark: #0d6e4f;
    --primary-light: #1a2e28;
    --sidebar-start: #0d6e4f;
    --sidebar-end: #063828;
    --topbar-accent: #2dd4a0;
}

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

img,
video,
svg {
    max-width: 100%;
    height: auto;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: auto;
}
.toast-show { transform: translateX(0); opacity: 1; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info    { border-left: 4px solid var(--info); }

.theme-toggle {
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.theme-toggle:hover { background: var(--border); }

/* Legacy inline alerts (auth pages) */
.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
[data-theme="dark"] .alert-success { background: #1a3d2a; color: #86efac; border-color: #2d5a3d; }
[data-theme="dark"] .alert-error   { background: #3d1a1a; color: #fca5a5; border-color: #5a2d2d; }

/* Auth layout */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-brand {
    background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary) 60%, #12875f 100%);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
}

.auth-brand-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

.auth-brand h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.auth-brand p  { opacity: 0.9; font-size: 1.1rem; max-width: 360px; }
.auth-brand .badge {
    display: inline-block;
    margin-top: 2rem;
    padding: 0.4rem 0.9rem;
    background: rgba(255,255,255,0.15);
    border-radius: 999px;
    font-size: 0.85rem;
}

.auth-form-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--surface);
}

.auth-form-panel {
    width: 100%;
    max-width: 400px;
}

.auth-home-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    width: 100%;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.auth-home-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary-light);
}

.auth-home-link-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.85;
    transition: transform 0.2s ease;
}

.auth-home-link:hover .auth-home-link-mark {
    transform: translateX(-2px);
}

.auth-home-link--on-brand {
    margin-top: 0;
    margin-bottom: 0;
    flex-shrink: 0;
    padding-top: 2rem;
    padding-bottom: 0;
    width: auto;
    max-width: 360px;
    border-bottom: none;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.08em;
}

.auth-home-link--on-brand:hover {
    color: #fff;
    border-bottom-color: transparent;
}

.auth-form {
    width: 100%;
    max-width: 400px;
}

.auth-form h2 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.auth-form .subtitle { color: var(--text-muted); margin-bottom: 2rem; }
.auth-form .btn-primary { width: 100%; }

.auth-portal-badge {
    display: inline-block;
    margin-bottom: 0.75rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(13, 110, 79, 0.12);
    color: var(--primary);
}

.auth-page--admin .auth-brand {
    background: linear-gradient(145deg, #1e3a5f 0%, #1a4d8f 55%, #2563eb 100%);
}

.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.required-mark {
    color: var(--danger);
    font-weight: 600;
    margin-left: 0.12em;
}

.form-required-legend {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: -1.25rem 0 1.5rem;
}

.field-optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85em;
}
.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Password show/hide — toggle overlaid inside the input border box */
.password-field-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.password-field-wrap > input[type="password"],
.password-field-wrap > input[type="text"] {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding-right: 2.85rem;
}
.form-group .password-field-wrap > input[type="password"],
.form-group .password-field-wrap > input[type="text"] {
    width: 100%;
    padding: 0.75rem 2.85rem 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group .password-field-wrap > input[type="password"]:focus,
.form-group .password-field-wrap > input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.password-toggle-btn {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 2.75rem;
    height: auto;
    margin: 0;
    padding: 0;
    transform: none;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.password-toggle-btn:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .password-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}
.password-toggle-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}
.password-toggle-icon {
    display: block;
    pointer-events: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font: inherit;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

.form-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* App shell */
.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
    overflow-y: visible;
}

.sidebar {
    width: 268px;
    background: linear-gradient(180deg, var(--sidebar-start, var(--primary-dark)) 0%, var(--sidebar-end, #063828) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 100vh;
}

.sidebar-logo {
    padding: 1.35rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo .site-brand {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-decoration: none;
    color: #fff;
}
.sidebar-logo strong { display: block; font-size: 1.15rem; line-height: 1.3; }
.sidebar-logo span   { font-size: 0.72rem; opacity: 0.75; display: block; margin-top: 0.2rem; }

/* Site logo — used in header, sidebar, auth, footer, hero */
.site-brand {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    max-width: 100%;
}
.site-brand--header {
    flex: 0 1 auto;
    max-width: min(420px, 55vw);
}
.site-brand--sidebar { width: 100%; }
.site-brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.site-brand-text strong {
    display: block;
    font-size: 1.1rem;
    line-height: 1.25;
    color: var(--primary);
}
.site-brand--sidebar .site-brand-text strong { color: #fff; }
.site-brand-text span,
.site-brand-text--sub-only span {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.25;
}
.site-brand--sidebar .site-brand-text span,
.site-brand--sidebar .site-brand-text--sub-only span {
    color: rgba(255,255,255,0.75);
}
.site-logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    background: transparent;
}
.site-logo--on-dark {
    background: #fff;
    border-radius: 10px;
    padding: 0.35rem 0.55rem;
    box-sizing: content-box;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.site-logo--header {
    width: min(240px, 100%);
    max-height: 96px;
    height: auto;
}
.site-logo--sidebar {
    width: 100%;
    max-width: 100%;
    max-height: 112px;
    height: auto;
}
.site-logo--auth {
    width: min(200px, 92%);
    max-height: 96px;
    height: auto;
    margin-bottom: 0.5rem;
}
.site-logo--footer { max-height: 64px; width: min(200px, 100%); }
.site-logo--verify { max-height: 80px; width: min(240px, 100%); }
.auth-brand .site-logo--auth {
    box-shadow: none;
    padding: 0.25rem 0.4rem;
    border-radius: 8px;
}
.auth-brand-main .site-logo--auth {
    align-self: flex-start;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0 1rem;
}

.sidebar-group { margin-bottom: 0.5rem; }
.sidebar-group-label {
    display: block;
    padding: 0.65rem 1.25rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.55;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem 0.55rem 1.15rem;
    margin: 0.1rem 0.65rem;
    color: rgba(255,255,255,0.88);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    text-decoration: none;
}
.sidebar-link.active {
    background: rgba(255,255,255,0.18);
    font-weight: 600;
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.9;
}
.sidebar-icon svg { width: 18px; height: 18px; display: block; }

.sidebar-footer {
    padding: 1rem 0.85rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.5rem 0.75rem;
}
.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.sidebar-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.35);
    flex-shrink: 0;
}

.profile-avatar-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.profile-avatar-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.student-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.student-list-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text);
}

.pagination-link.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination-meta {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-ellipsis {
    padding: 0 0.25rem;
    color: var(--text-muted);
}

.sidebar-user-meta strong { display: block; font-size: 0.85rem; line-height: 1.2; }
.sidebar-user-meta small { opacity: 0.7; font-size: 0.72rem; }
.sidebar-link-logout { opacity: 0.9; }

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-top: 3px solid var(--topbar-accent, var(--primary));
    border-radius: 0;
    box-shadow: none;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: visible;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
}

.page-body {
    position: relative;
    z-index: 1;
    padding: 2rem;
    flex: 1;
}

.topbar h1 { font-size: 1.35rem; font-weight: 600; }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    overflow: visible;
    position: relative;
}
.topbar-user .role-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.role-badge--admin {
    background: rgba(26, 77, 143, 0.12);
    color: var(--primary);
    border: 1px solid rgba(26, 77, 143, 0.25);
}
.role-badge--student {
    background: rgba(13, 110, 79, 0.12);
    color: var(--primary);
    border: 1px solid rgba(13, 110, 79, 0.25);
}
body.portal-admin .sidebar-link.active {
    background: rgba(240, 165, 0, 0.22);
    border-left: 3px solid var(--accent);
}
body.portal-student .sidebar-link.active {
    background: rgba(255, 255, 255, 0.18);
}


/* Account profile dropdown (public header + app topbar) */
.account-user-menu {
    position: relative;
    flex-shrink: 0;
    z-index: 120;
}

.account-user-menu.is-open {
    z-index: 300;
}

.account-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.account-user-trigger:hover,
.account-user-menu.is-open .account-user-trigger {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(26, 77, 143, 0.12);
}

.account-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--primary-dark), var(--primary));
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}

.account-user-avatar svg {
    width: 1.15rem;
    height: 1.15rem;
}

.account-user-avatar-img {
    object-fit: cover;
    background: var(--border);
}

.account-user-chevron {
    width: 0;
    height: 0;
    margin-right: 0.45rem;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    transition: transform 0.2s ease;
}

.account-user-menu.is-open .account-user-chevron {
    transform: rotate(180deg);
}

.account-user-dropdown {
    display: none;
    position: fixed;
    z-index: 10050;
    min-width: 220px;
    max-width: min(280px, calc(100vw - 1.5rem));
    padding: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.account-user-menu.is-open .account-user-dropdown {
    display: block;
}

.account-user-dropdown-head {
    padding: 0.55rem 0.65rem 0.45rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.account-user-dropdown-head strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
}

.account-user-dropdown-head small {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-word;
}

.account-user-dropdown a {
    display: block;
    padding: 0.55rem 0.65rem;
    border-radius: 0.45rem;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.account-user-dropdown a:hover {
    background: var(--bg);
    color: var(--primary);
}

.account-user-dropdown-primary {
    font-weight: 600;
    color: var(--primary) !important;
}

.account-user-dropdown-logout {
    color: #b42318;
}

.account-user-dropdown-logout:hover {
    color: #b42318 !important;
    background: #fef3f2;
}

[data-theme="dark"] .account-user-dropdown-logout:hover {
    background: rgba(180, 35, 24, 0.15);
}

.account-user-dropdown-divider {
    height: 1px;
    margin: 0.35rem 0;
    background: var(--border);
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.stat-card h3 { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-card p  { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }
.stat-card small { display: block; color: var(--text-muted); font-size: 0.75rem; margin-top: 0.2rem; opacity: 0.85; }
.stat-card-link {
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(26, 35, 50, 0.12);
    text-decoration: none;
}

/* Dashboard */
.dash-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
    padding: 1.5rem 1.75rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.dash-hero-admin {
    border-left: 4px solid var(--primary);
    background: linear-gradient(135deg, var(--surface) 0%, var(--primary-light) 100%);
}
.dash-hero-student {
    border-left: 4px solid var(--accent);
    background: linear-gradient(135deg, var(--surface) 0%, var(--primary-light) 100%);
}
.dash-hero-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin-bottom: 0.35rem;
}
.dash-hero h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.35rem; }
.dash-hero-meta { color: var(--text-muted); font-size: 0.9rem; }
.reg-pill {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
}
.dash-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.dash-section { margin-bottom: 1.5rem; }
.dash-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
    gap: 1rem;
}
.dash-section-head h2 { font-size: 1rem; font-weight: 600; }

.dash-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    align-items: stretch;
}
@media (min-width: 640px) {
    .dash-nav-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
    .dash-nav-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
    .dash-nav-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.dash-health .dash-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.dash-health-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}
@media (min-width: 768px) {
    .dash-health-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
    .dash-health-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.dash-health-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
}
.dash-health-item.is-ok { border-color: rgba(13, 110, 79, 0.25); }
.dash-health-item.is-warn { border-color: rgba(180, 83, 9, 0.35); background: rgba(180, 83, 9, 0.04); }
.dash-health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--primary);
}
.dash-health-item.is-warn .dash-health-dot { background: #b45309; }
.dash-health-label { flex: 1; min-width: 0; }
.dash-nav-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.7rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    min-height: 4.75rem;
    height: 100%;
}
.dash-nav-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 35, 50, 0.1);
    border-color: var(--primary-light);
    text-decoration: none;
}
.dash-nav-card.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
}
.dash-nav-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.dash-nav-card-icon {
    flex-shrink: 0;
    width: 1.85rem;
    height: 1.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
}
.dash-nav-card-icon svg {
    width: 1rem;
    height: 1rem;
}
.dash-nav-card-title {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-nav-card-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    flex: 1;
}
.dash-nav-card-badge {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
    align-self: flex-start;
    margin-top: auto;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exam-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.exam-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
}
.exam-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.exam-card-head h3 { font-size: 1.05rem; font-weight: 600; line-height: 1.3; }
.exam-card-meta {
    list-style: none;
    margin-bottom: 1.1rem;
}
.exam-card-meta li {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}
.exam-card-meta li span { color: var(--text-muted); }
.text-muted { color: var(--text-muted); }

/* Cards & tables */
.card, .stat-card, .auth-form {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-body-flush { padding: 0; }
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.data-table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active   { background: #d4edda; color: #155724; }
.badge-draft    { background: #fff3cd; color: #856404; }
.badge-closed   { background: #e2e3e5; color: #383d41; }
.badge-scheduled{ background: #cce5ff; color: #004085; }

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}
.empty-state-rich {
    padding: 3.5rem 2rem;
}
.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.85;
}
.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}
.empty-state-message {
    font-size: 0.9rem;
    max-width: 360px;
    margin: 0 auto 1.25rem;
    line-height: 1.5;
}
.empty-state-cta { margin-top: 0.25rem; }

.form-group input.input-invalid,
.form-group select.input-invalid,
.form-group textarea.input-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15);
}
.form-group input:invalid:not(:focus):not(:placeholder-shown),
.form-group select:invalid:not(:focus),
.form-group textarea:invalid:not(:focus):not(:placeholder-shown) {
    border-color: var(--danger);
}

/* Forms extended */
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
}
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}
.exam-card-muted {
    opacity: 0.92;
    border-style: dashed;
}
.exam-card-practice {
    border-color: var(--accent, #0d9488);
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.06), transparent);
}

.review-q-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.review-q-text {
    margin-bottom: 1rem;
    line-height: 1.6;
}
.review-options {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}
.review-opt {
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.review-opt-correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}
.review-opt-wrong {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}
.review-explanation {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: var(--bg-muted, #f4f6f8);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem;
    align-items: start;
}
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tabs a {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
}
.tabs a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}
.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 1rem;
    cursor: pointer;
}
.section-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.option-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.option-row input[type=text] { flex: 1; }
.option-block { margin: 1rem 0; }
.hint { color: var(--text-muted); font-size: 0.8rem; display: block; margin-top: 0.25rem; }

.filter-bar, .filter-inline {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.filter-bar select, .filter-inline select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
}

.actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.inline-form { display: inline; }
.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    padding: 0;
}
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }

.question-pick {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.question-pick p { font-size: 0.9rem; margin: 0; }
.question-pick small { color: var(--text-muted); }
.question-pick form { align-self: flex-start; }

code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.input-readonly {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

.reg-no-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: var(--primary-light);
    border: 1px dashed var(--primary);
    border-radius: var(--radius);
    font-size: 0.95rem;
}
.reg-no-preview strong {
    font-size: 1.1rem;
    color: var(--primary-dark);
    letter-spacing: 0.04em;
}

.allocate-banner {
    padding: 0.75rem 1.5rem;
    background: #fff8e6;
    border-bottom: 1px solid #ffe08a;
    font-size: 0.9rem;
}

.form-section-title {
    font-size: 0.95rem;
    color: var(--primary);
    margin: 1.25rem 0 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}
.form-section-title:first-of-type { margin-top: 0; }
.form-subtitle {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin: 1rem 0 0.5rem;
}

.rules-list {
    list-style: none;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.rules-list li {
    padding: 0.35rem 0;
    padding-left: 1.25rem;
    position: relative;
}
.rules-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary);
}

.import-report { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.import-report h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.error-list { font-size: 0.85rem; color: var(--danger); margin-top: 0.5rem; padding-left: 1.25rem; }
.text-success { color: var(--success); }

.badge-inactive, .badge-in_progress { background: #e2e3e5; color: #383d41; }
.badge-submitted { background: #d4edda; color: #155724; }
.badge-easy { background: #d4edda; color: #155724; }
.badge-medium { background: #fff3cd; color: #856404; }
.badge-hard { background: #f8d7da; color: #721c24; }
.badge-archived { background: #e2e3e5; color: #383d41; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.detail-grid .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* Maintenance banner */
.maintenance-banner {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}
.maintenance-banner strong {
    font-weight: 700;
}
.maintenance-banner a {
    margin-left: auto;
    font-weight: 600;
    white-space: nowrap;
}
[data-theme="dark"] .maintenance-banner {
    background: #3d3520;
    color: #fcd34d;
    border-color: #854d0e;
}
.public-site > .maintenance-banner {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

/* Mobile layout — see assets/css/mobile.css */

/* Password toggle — ensure icon stays inside bordered input (wins over .form-group input width) */
.form-group .password-field-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.form-group .password-field-wrap > input {
    width: 100% !important;
    max-width: 100%;
    padding-right: 2.85rem !important;
    box-sizing: border-box;
}
.form-group .password-field-wrap .password-toggle-btn {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    height: auto;
    width: 2.75rem;
    margin: 0;
    transform: none;
}
