:root {
    --ink: #172033;
    --muted: #647084;
    --line: #e4e8f0;
    --panel: #ffffff;
    --soft: #f6f8fb;
    --primary: #2356d8;
    --primary-dark: #173b9d;
    --accent: #0f9f8f;
    --danger: #d83250;
    --sidebar: #111827;
}

* {
    letter-spacing: 0;
}

body {
    background: var(--soft);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.admin-shell {
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.admin-sidebar,
.mobile-sidebar {
    background: var(--sidebar);
    color: #fff;
}

.admin-sidebar {
    width: 280px;
    height: 100vh;
    flex-direction: column;
    position: sticky;
    top: 0;
    flex: 0 0 280px;
    transition: width .22s ease, flex-basis .22s ease;
}

.mobile-sidebar {
    width: 280px;
}

.mobile-sidebar .offcanvas-body {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.mobile-sidebar .brand {
    padding-right: 60px;
}

.mobile-sidebar-close {
    position: absolute;
    top: 22px;
    right: 14px;
    z-index: 30;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background .18s ease, transform .22s ease;
    padding: 0;
}

.mobile-sidebar-close:hover {
    background: rgba(255, 255, 255, .18);
    transform: rotate(90deg);
}

.mobile-sidebar-close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .4);
    outline-offset: 2px;
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    padding: 26px 22px;
    min-height: 96px;
    position: relative;
}

.brand-mark {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 800;
}

.brand-logo {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    max-width: 44px;
    max-height: 44px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 5px;
    box-sizing: border-box;
}

.brand-copy {
    min-width: 0;
}

.brand-copy strong,
.brand-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-collapse-toggle {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    place-items: center;
    transition: background .18s ease;
}

.sidebar-collapse-toggle:hover {
    background: rgba(255, 255, 255, .16);
}

.brand strong,
.login-brand strong {
    display: block;
    font-size: 1.05rem;
}

.brand span,
.login-brand span {
    display: block;
    color: #aab4c4;
    font-size: .82rem;
}

.sidebar-nav {
    padding: 0 14px;
    display: grid;
    gap: 6px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    align-content: start;
}

.sidebar-nav a,
.sidebar-nav .disabled {
    min-height: 46px;
    border-radius: 8px;
    padding: 0 14px;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    white-space: nowrap;
    transition: background .18s ease, padding .22s ease, justify-content .22s ease;
}

.sidebar-nav i,
.sidebar-logout i {
    flex: 0 0 20px;
    text-align: center;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, .11);
    color: #fff;
}

.sidebar-nav .disabled {
    opacity: .48;
}

.sidebar-logout {
    margin-top: auto;
    padding: 22px;
    flex: 0 0 auto;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logout .btn {
    min-height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .1);
    color: #ef4444;
    white-space: nowrap;
    border-color: rgba(255, 255, 255, .12);
}

.sidebar-logout .btn i,
.sidebar-logout .btn span {
    color: #fff8f8;
}

.sidebar-logout .btn:hover,
.sidebar-logout .btn:focus,
.sidebar-logout .btn:active {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .18);
    color: #dc2626;
}

.sidebar-logout .btn:hover i,
.sidebar-logout .btn:hover span,
.sidebar-logout .btn:focus i,
.sidebar-logout .btn:focus span,
.sidebar-logout .btn:active i,
.sidebar-logout .btn:active span {
    color: #dc2626;
}

.sidebar-collapsed .admin-sidebar {
    width: 88px;
    flex-basis: 88px;
}

.sidebar-collapsed .admin-sidebar .brand {
    padding: 18px 14px 14px;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

.sidebar-collapsed .admin-sidebar .brand-copy,
.sidebar-collapsed .admin-sidebar .sidebar-nav span,
.sidebar-collapsed .admin-sidebar .sidebar-logout span {
    width: 0;
    opacity: 0;
    overflow: hidden;
    display: none;
}

.sidebar-collapsed .admin-sidebar .sidebar-collapse-toggle {
    position: static;
    margin: 0;
    width: 34px;
    height: 34px;
}

.sidebar-collapsed .admin-sidebar .sidebar-nav {
    padding: 0 12px;
}

.sidebar-collapsed .admin-sidebar .sidebar-nav a,
.sidebar-collapsed .admin-sidebar .sidebar-nav .disabled,
.sidebar-collapsed .admin-sidebar .sidebar-logout .btn {
    justify-content: center;
    padding: 0;
    width: 100%;
}

.sidebar-collapsed .admin-sidebar .sidebar-logout {
    padding: 18px 12px;
}

.admin-main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-topbar {
    min-height: 88px;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.page-kicker {
    color: var(--primary);
    font-weight: 700;
    font-size: .78rem;
    text-transform: uppercase;
}

.admin-topbar h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2vw, 1.9rem);
    font-weight: 800;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.admin-user-copy {
    min-width: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 0;
}

.current-branch-pill {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    font-weight: 800;
    text-decoration: none;
    max-width: 320px;
}

.current-branch-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.current-branch-pill i {
    color: var(--accent);
}

.metric-card-prompt {
    font-size: 0.95rem !important;
    color: var(--muted) !important;
    font-weight: 700 !important;
}

.admin-user span {
    display: block;
    color: var(--muted);
    font-size: .82rem;
}

.admin-user strong,
.admin-user span {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #e8f7f5;
    color: #087c70;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.admin-content {
    padding: 28px;
}

.dashboard-hero {
    border-radius: 8px;
    background: linear-gradient(135deg, #173b9d, #0f766e);
    color: #fff;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

.dashboard-hero span {
    text-transform: uppercase;
    font-size: .78rem;
    font-weight: 800;
    opacity: .8;
}

.dashboard-hero h2 {
    max-width: 680px;
    margin: 8px 0;
    font-size: clamp(1.55rem, 3vw, 2.25rem);
    font-weight: 800;
}

.dashboard-hero p {
    max-width: 640px;
    margin: 0;
    color: rgba(255, 255, 255, .82);
}

.metric-card,
.content-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(20, 32, 54, .06);
}

.metric-card {
    min-height: 150px;
    padding: 22px;
    display: grid;
    align-content: space-between;
}

.metric-card i {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #edf3ff;
    color: var(--primary);
}

.metric-card span {
    color: var(--muted);
}

.metric-card strong {
    font-size: 1.8rem;
}

.metric-card.muted strong {
    font-size: 1.1rem;
    color: var(--muted);
}

.dashboard-metric-row {
    align-items: stretch;
}

.dashboard-metric-row > [class*="col-"] {
    display: flex;
}

.dashboard-metric-card {
    position: relative;
    width: 100%;
    min-height: 118px;
    padding: 18px;
    grid-template-columns: 46px minmax(0, 1fr);
    align-items: center;
    align-content: center;
    gap: 14px;
    overflow: hidden;
    border-color: rgba(23, 32, 51, 0.08);
    box-shadow: 0 12px 28px rgba(20, 32, 54, 0.07);
}

.dashboard-metric-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: var(--metric-accent, var(--primary));
}

.dashboard-metric-card i {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    color: var(--metric-accent, var(--primary));
    background: var(--metric-soft, #eef4ff);
    font-size: 1.15rem;
}

.dashboard-metric-card div {
    min-width: 0;
}

.dashboard-metric-card span {
    display: block;
    margin-bottom: 5px;
    color: #6b7588;
    font-size: 0.76rem;
    font-weight: 850;
    line-height: 1.2;
    text-transform: uppercase;
}

.dashboard-metric-card strong {
    display: block;
    color: #172033;
    font-size: clamp(1.3rem, 2.2vw, 1.75rem);
    font-weight: 900;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.dashboard-metric-card.muted {
    background: linear-gradient(180deg, #ffffff, #fbfcfe);
}

.dashboard-metric-card.muted strong {
    color: #647084;
    font-size: 1.05rem;
}

.dashboard-metric-card.metric-primary {
    --metric-accent: #2356d8;
    --metric-soft: #eef4ff;
}

.dashboard-metric-card.metric-success {
    --metric-accent: #0f9f8f;
    --metric-soft: #e6f7f4;
}

.dashboard-metric-card.metric-accent {
    --metric-accent: #7c3aed;
    --metric-soft: #f5f3ff;
}

.content-panel {
    padding: 24px;
}

.narrow-panel {
    max-width: 760px;
}

.settings-panel {
    margin-bottom: 24px;
}

.settings-panel:last-of-type {
    margin-bottom: 0;
}

.settings-hero {
    border-radius: 8px;
    background: linear-gradient(135deg, #173b9d, #0f766e);
    color: #fff;
    padding: 28px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.settings-hero-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .16);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

.settings-hero span {
    text-transform: uppercase;
    font-size: .78rem;
    font-weight: 800;
    opacity: .8;
}

.settings-hero h2 {
    margin: 6px 0 4px;
    font-size: clamp(1.3rem, 3vw, 1.7rem);
    font-weight: 800;
}

.settings-hero p {
    margin: 0;
    color: rgba(255, 255, 255, .82);
}

.logo-upload-zone {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px;
    border: 2px dashed #c9d4e8;
    border-radius: 14px;
    background: #f8faff;
    flex-wrap: wrap;
    transition: border-color .18s ease, background .18s ease;
}

.logo-upload-zone:hover,
.logo-upload-zone:focus-within {
    border-color: var(--primary);
    background: #eef4ff;
}

.logo-upload-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    height: 90px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.logo-upload-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-align: center;
}

.logo-upload-placeholder i {
    font-size: 1.4rem;
}

.logo-upload-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 180px;
}

.logo-upload-actions .btn {
    align-self: flex-start;
}

.logo-upload-actions .form-text {
    margin: 0;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--muted);
}

/* Exam title + Question Category merged into one compact row */
.exam-summary-bar {
    padding: 8px 24px;
    margin-bottom: 14px;
}

.exam-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.exam-summary-title h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
}

.exam-summary-title p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.exam-summary-category {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.category-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 800;
    white-space: nowrap;
}

.category-status-pill.warning {
    background: #fffbeb;
    color: #b45309;
}

.category-status-pill.danger {
    background: #fff0f3;
    color: #9f1239;
}

.default-category-picker {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 14px;
    background: #f6f8fb;
    border: 1px solid var(--line);
    border-radius: 12px;
    min-width: 320px;
}

.default-category-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.default-category-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
}

.default-category-controls .form-select {
    flex: 1;
    min-width: 0;
    font-size: 0.86rem;
}

.default-category-controls .btn {
    font-size: 0.82rem;
    padding-top: 6px;
    padding-bottom: 6px;
}

.default-category-confirmed {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    color: #067647;
    line-height: 1.4;
}

@media (max-width: 575.98px) {
    .exam-summary-row {
        align-items: flex-start;
    }

    .exam-summary-category,
    .default-category-picker {
        width: 100%;
        min-width: 0;
    }
}

.admin-table {
    min-width: 720px;
}

.admin-table thead th {
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}

.admin-table td {
    border-color: var(--line);
}

.action-group {
    display: inline-flex;
    gap: 6px;
}

.action-group form {
    display: inline;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-bar.compact-filter-bar {
    grid-template-columns: 4fr 1fr;
}

.filter-bar.filter-bar-60-20-20 {
    grid-template-columns: 3fr 1fr 1fr;
}

.filter-bar.logs-filter-bar,
.filter-bar.filter-bar-oneline {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
}

.filter-bar.logs-filter-bar > *,
.filter-bar.filter-bar-oneline > * {
    flex: 1 1 0;
    min-width: 140px;
}

.filter-bar.logs-filter-bar .filter-bar-actions,
.filter-bar.filter-bar-oneline .filter-bar-actions {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
}

.filter-bar.logs-filter-bar .btn,
.filter-bar.filter-bar-oneline .btn {
    width: auto;
    white-space: nowrap;
    padding: 6px 22px;
    font-size: 1rem;
    font-weight: 800;
}

.filter-bar.filter-bar-60-20-20 .btn {
    width: 100%;
}

.filter-bar.compact-filter-bar .btn {
    width: 100%;
}

.btn {
    border-radius: 8px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-soft {
    background: #eef4ff;
    color: var(--primary);
}

.btn-danger-soft {
    background: #fff0f3;
    color: var(--danger);
}

.feedback-alert {
    border: 0;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 14px 16px;
    background: #fff0f3;
    color: #9f1239;
}

.feedback-alert.success {
    background: #ecfdf5;
    color: #047857;
}

.feedback-alert.info {
    background: #eef4ff;
    color: var(--primary);
}

.feedback-alert i {
    margin-top: 2px;
}

.required-mark {
    color: var(--danger);
    font-weight: 900;
}

/* Checkbox-as-card toggle: used for the Student Subjects grid, Exam
   randomization/negative-marking options, and the Academic Session
   "Active" checkbox — one shared style for every plain checkbox+label
   pair in the app's forms. */
.module-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 11px 14px;
    background: #f8fafc;
    border: 1px solid rgba(23, 32, 51, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    min-width: 0;
    height: 100%;
}

.module-check:hover {
    border-color: rgba(29, 111, 216, 0.4);
}

.module-check .form-check-input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

.module-check span {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    color: #344054;
    font-weight: 700;
    font-size: 0.92rem;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

/* Student Subjects: chips that hug their own text instead of stretching
   into equal-width grid columns, so a longer name like "Mathematics"
   sits on one line at its natural width instead of being squeezed into
   the same column width as "English" and forced to break mid-word. */
.subject-checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.subject-checkbox-grid .module-check {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    height: auto;
}

.module-check:has(.form-check-input:checked) {
    background: rgba(29, 111, 216, 0.08);
    border-color: #1d6fd8;
}

.module-check:has(.form-check-input:checked) span {
    color: #1d6fd8;
}

.module-check .form-check-input:checked ~ span {
    color: #1d6fd8;
}

/* Existing Guardian picker on the Student Create form: a search box with
   a live dropdown, plus a confirmation card once a Guardian is chosen. */
.guardian-search-box {
    position: relative;
}

.guardian-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.guardian-search-input {
    padding-left: 38px;
}

/* position: fixed (not absolute) and coordinates set inline by JS
   (positionGuardianDropdown() below) — the Student Create form most
   commonly opens inside the "Add Student" offcanvas drawer, and Bootstrap's
   .offcanvas-body is overflow-y: auto, which would otherwise clip an
   absolutely-positioned dropdown the moment the form is tall enough to
   scroll (exactly the case here: Guardian Type + this search box sit above
   Grade/Phone/Email/Subjects). Fixed positioning escapes that clipping
   since it's relative to the viewport; the z-index clears both Bootstrap's
   .offcanvas (1045) and its backdrop (1040) so results render above the
   open drawer. */
.guardian-search-dropdown {
    position: fixed;
    z-index: 1200;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(20, 32, 54, 0.12);
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
}

.guardian-dropdown-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    gap: 2px;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
}

.guardian-dropdown-item:hover,
.guardian-dropdown-item:focus-visible {
    background: #eef4ff;
    outline: none;
}

.guardian-dropdown-item strong {
    font-size: 0.9rem;
    color: var(--ink);
}

.guardian-dropdown-item span {
    font-size: 0.8rem;
    color: var(--muted);
}

.guardian-dropdown-empty {
    padding: 12px;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.guardian-selected-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 14px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 10px;
}

.guardian-selected-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #d1fae5;
    color: #067647;
    display: grid;
    place-items: center;
    font-size: 1rem;
}

.guardian-selected-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.guardian-selected-info strong {
    font-size: 0.92rem;
    color: var(--ink);
}

.guardian-selected-info span {
    font-size: 0.82rem;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.guardian-selected-card .btn {
    flex: 0 0 auto;
}

.admin-toast {
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(20, 32, 54, .18);
}

.admin-toast .toast-body {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.confirm-modal {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(20, 32, 54, .22);
}

.logout-modal .modal-body {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--muted);
}

.logout-confirm-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: #eef4ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    flex: 0 0 50px;
    font-size: 1.25rem;
}

.student-drawer {
    width: min(94vw, 560px) !important;
    border-left: 1px solid var(--line);
}

.exam-drawer {
    width: min(92vw, 760px) !important;
}

.student-drawer-header {
    min-height: 88px;
    border-bottom: 1px solid var(--line);
    padding: 18px 22px;
}

.student-drawer-header h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 850;
}

.student-drawer .offcanvas-body {
    padding: 22px;
}

.exam-drawer .offcanvas-body {
    padding: 24px 28px 0;
    background: #f7f9fc;
}

.student-drawer .admin-form {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.student-drawer .admin-form > .d-flex:last-child {
    margin-top: auto !important;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    background: #fff;
    position: sticky;
    bottom: -22px;
    padding-bottom: 8px;
}

.exam-drawer .admin-form > .d-flex:last-child {
    margin-left: -28px;
    margin-right: -28px;
    padding: 16px 28px 18px;
    bottom: 0;
    box-shadow: 0 -14px 30px rgba(20, 32, 54, .08);
}

.exam-form-sections {
    display: grid;
    gap: 16px;
    padding-bottom: 22px;
}

.exam-form-section {
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(20, 32, 54, .06);
}

.exam-form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef1f6;
}

.exam-form-section-title span {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    color: var(--primary);
    font-size: .8rem;
    font-weight: 900;
    background: #eef4ff;
    border-radius: 8px;
}

.exam-form-section-title h3 {
    margin: 0;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 850;
}

.question-form {
    display: grid;
    gap: 18px;
}

.question-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(20, 32, 54, .06);
}

.question-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid #eef1f6;
    background: linear-gradient(180deg, #fafbfe, #f6f8fb);
    /* .question-card no longer clips overflow (removed so the math-tools
       popover isn't cut off at the card edge), so the header rounds its own
       top corners instead of relying on the parent's overflow:hidden. */
    border-radius: 11px 11px 0 0;
}

.question-card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 850;
    color: var(--ink);
}

.question-card-header p {
    margin: 3px 0 0;
    font-size: .84rem;
    color: var(--muted);
}

.question-card-icon {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #eef4ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.05rem;
}

.question-card-icon.accent {
    background: #e6f7f4;
    color: var(--accent);
}

.question-card-icon.success {
    background: #ecfdf5;
    color: #067647;
}

.question-card-body {
    padding: 16px 20px;
}

.question-textarea {
    min-height: 90px;
    font-size: .95rem;
    line-height: 1.5;
    background: #fbfcfe;
}

/* Compact question form fields */
.question-field-group {
    margin-bottom: 12px;
}

.question-field-group .form-label,
.question-meta-row .form-label,
.option-builder > .form-label,
.question-explanation-field .form-label {
    margin-bottom: 4px;
    font-size: .82rem;
}

.question-meta-row {
    margin-bottom: 12px;
}

.question-meta-row .form-control,
.question-meta-row .form-select {
    min-height: 38px;
    font-size: .88rem;
}

.option-builder {
    margin-bottom: 12px;
}

.option-builder > .form-label {
    margin-bottom: 6px;
}

.option-row {
    padding: 6px 8px;
    margin-bottom: 6px;
    gap: 8px;
}

.option-badge {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    font-size: .82rem;
    margin-top: 3px;
}

.option-input-wrap textarea {
    min-height: 32px;
    font-size: .85rem;
    padding-top: 4px;
    padding-bottom: 4px;
}

.correct-answer-label {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    margin-top: 2px;
}

.correct-answer-mark {
    width: 26px;
    height: 26px;
    font-size: .75rem;
}

.btn-icon-remove {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    min-height: 30px;
    margin-top: 2px;
    font-size: .85rem;
}

.btn-add-option {
    min-height: 34px;
    margin-top: 4px;
    font-size: .82rem;
}

.question-explanation-field {
    margin-top: 12px;
}

.question-explanation-field textarea {
    min-height: 32px;
    font-size: .85rem;
}

.question-card-header {
    padding: 12px 16px;
    gap: 10px;
}

.question-card-header h3 {
    font-size: .95rem;
}

.question-card-header p {
    margin: 2px 0 0;
    font-size: .78rem;
}

.question-card-icon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    font-size: .95rem;
}

.question-form-actions {
    gap: 8px;
    padding-top: 2px;
}

.question-form-actions .btn {
    min-height: 40px;
    padding: 0 16px;
    font-size: .88rem;
}

.btn-add-question {
    min-height: 40px;
    font-size: .88rem;
}

.question-card-body .form-label {
    font-weight: 700;
    font-size: .88rem;
    color: var(--ink);
}

.question-card-body .form-control,
.question-card-body .form-select {
    min-height: 38px;
    border-radius: 8px;
    border-color: var(--line);
}

.question-card-body .form-control:focus,
.question-card-body .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(35, 86, 216, .1);
}

/* Option rows */
.option-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcfe;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.option-row:hover {
    border-color: #c9d4e8;
    box-shadow: 0 4px 14px rgba(20, 32, 54, .05);
}

.option-row:has(.correct-radio:checked) {
    border-color: #4ade80;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, .15);
}

.option-badge {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #e8eefb;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: .82rem;
    margin-top: 3px;
    user-select: none;
}

.option-input-wrap {
    flex: 1;
    min-width: 0;
}

.option-input-wrap textarea {
    min-height: 32px;
    font-size: .85rem;
    padding-top: 4px;
    padding-bottom: 4px;
    line-height: 1.4;
    background: #fff;
    resize: vertical;
}

.correct-answer-label {
    position: relative;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    margin-top: 2px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.correct-answer-label input.correct-radio {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.correct-answer-mark {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 2px solid #cbd5e1;
    background: #fff;
    color: transparent;
    display: grid;
    place-items: center;
    font-size: .75rem;
    transition: all .18s ease;
}

.correct-answer-label:hover .correct-answer-mark {
    border-color: var(--accent);
    color: var(--accent);
}

.correct-answer-label input.correct-radio:checked + .correct-answer-mark {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 159, 143, .35);
}

.btn-icon-remove {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    margin-top: 2px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    font-size: .85rem;
}

.btn-icon-remove:hover {
    color: var(--danger);
    background: #fff0f3;
    border-color: #fecdd3;
}

.btn-add-option {
    width: 100%;
    min-height: 34px;
    margin-top: 4px;
    border: 1px dashed #c9d4e8;
    border-radius: 8px;
    background: #f8fafc;
    color: var(--primary);
    font-weight: 700;
    font-size: .82rem;
    transition: all .18s ease;
}

.btn-add-option:hover {
    background: #eef4ff;
    border-color: var(--primary);
}

.btn-add-question {
    width: 100%;
    min-height: 40px;
    border: 2px dashed var(--primary);
    border-radius: 10px;
    background: #f8faff;
    color: var(--primary);
    font-weight: 800;
    font-size: .88rem;
    transition: all .18s ease;
}

.btn-add-question:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(35, 86, 216, .2);
}

.multi-question-block {
    scroll-margin-top: 120px;
    margin-bottom: 16px;
}

.multi-question-block:last-child {
    margin-bottom: 0;
}

[data-multi-question-list] .multi-question-block {
    margin-bottom: 16px;
}

[data-multi-question-list] .multi-question-block:last-child {
    margin-bottom: 0;
}

.add-item-panel {
    scroll-margin-top: 100px;
    padding-top: 12px;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.add-item-panel .panel-header {
    margin-bottom: 10px;
}

.add-item-panel .panel-header h2 {
    font-size: 1.05rem;
}

.add-item-panel .panel-header p {
    font-size: 0.82rem;
}

.add-item-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.add-item-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    padding: 12px 14px;
    border: 2px dashed var(--line);
    border-radius: 14px;
    background: var(--soft);
    transition: all .18s ease;
    width: 100%;
}

.add-item-tile:hover {
    border-color: var(--primary);
    background: #f8faff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(35, 86, 216, .12);
}

.add-item-tile-accent:hover {
    border-color: var(--accent);
    background: #f2fbfa;
    box-shadow: 0 10px 24px rgba(15, 159, 143, .14);
}

.add-item-tile-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    background: #eef4ff;
    color: var(--primary);
}

.add-item-tile-accent .add-item-tile-icon {
    background: #e6f7f5;
    color: var(--accent);
}

.add-item-tile-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.add-item-tile-body strong {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--ink);
}

.add-item-tile-body small {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.78rem;
    line-height: 1.35;
}

.add-item-inline-form {
    border-top: 1px solid var(--line);
    padding-top: 20px;
}

.passage-add-question-form {
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 24px;
}

.submit-panel {
    text-align: center;
    background: linear-gradient(135deg, #f8faff 0%, #eef4ff 100%);
    border: 1px solid var(--line);
}

.submit-panel .btn {
    min-width: 220px;
    min-height: 52px;
    font-size: 1rem;
    box-shadow: 0 10px 24px rgba(16, 185, 129, .22);
}

.submit-panel p {
    color: var(--muted);
    margin: 10px 0 0;
}

#beginExamButton {
    font-size: 1rem;
}

@media (max-width: 767.98px) {
    .add-item-tiles {
        grid-template-columns: 1fr;
    }
}

.question-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 2px;
}

.question-form-actions .btn {
    min-height: 40px;
    padding: 0 16px;
    font-size: .88rem;
}

@media (max-width: 575.98px) {
    .question-card-body {
        padding: 16px;
    }

    .option-row {
        flex-wrap: wrap;
        padding: 8px;
        gap: 8px;
    }

    .option-input-wrap {
        flex: 1 1 calc(100% - 46px);
    }

    .option-badge {
        flex: 0 0 30px;
        width: 30px;
        height: 30px;
        font-size: .82rem;
        margin-top: 5px;
    }

    .correct-answer-label {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        margin-top: 6px;
    }

    .correct-answer-mark {
        width: 28px;
        height: 28px;
    }

    .btn-icon-remove {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        margin-top: 6px;
    }

    .question-form-actions .btn {
        flex: 1 1 100%;
    }
}

.offcanvas-backdrop.show {
    opacity: .34;
    backdrop-filter: blur(3px);
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
}

.empty-state i {
    font-size: 2rem;
    color: var(--primary);
}

.logout-modal #confirmLogoutButton {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.logout-modal #confirmLogoutButton:hover,
.logout-modal #confirmLogoutButton:focus,
.logout-modal #confirmLogoutButton:active {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.empty-state h3 {
    margin-top: 14px;
    font-size: 1.15rem;
    font-weight: 800;
}

.empty-state p {
    color: var(--muted);
    margin-bottom: 0;
}

.admin-form .form-control,
.login-form .form-control,
.password-change-form .form-control {
    min-height: 48px;
    border-radius: 8px;
    border-color: var(--line);
}

.change-password-card {
    background: #fbfcfe;
}

.change-password-card .exam-form-section-title span {
    color: #b45309;
    background: #fffbeb;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 50px;
}

.password-toggle {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: grid;
    place-items: center;
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 4;
}

.password-toggle:hover,
.password-toggle:focus {
    color: var(--primary);
    background: #eef4ff;
    outline: none;
}

.password-field .is-invalid {
    background-position: right 3rem center;
}

.detail-list {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.detail-list div {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.detail-list dt {
    color: var(--muted);
    font-size: .82rem;
}

.detail-list dd {
    margin: 4px 0 0;
    font-weight: 800;
}

.login-body {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(35, 86, 216, .08), rgba(15, 159, 143, .12)),
        #f2f5fa;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(100%, 460px);
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 24px 70px rgba(20, 32, 54, .15);
    padding: 34px;
}

.unified-login-wrap {
    padding: 28px;
}

.unified-login-shell {
    display: flex;
    align-items: stretch;
    width: min(100%, 880px);
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(20, 32, 54, .16);
    border: 1px solid var(--line);
}

.login-hero {
    position: relative;
    flex: 0 0 420px;
    padding: 38px 40px;
    background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 55%, var(--accent) 130%);
    color: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.login-hero-glow {
    position: absolute;
    top: -35%;
    right: -20%;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 70%);
    pointer-events: none;
}

.login-hero-inner {
    position: relative;
    z-index: 1;
    width: 100%;
}

.login-hero .login-brand {
    margin-bottom: 26px;
}

.login-hero .brand-mark {
    background: rgba(255, 255, 255, .16);
    color: #fff;
}

.login-hero .login-brand strong {
    color: #fff;
}

.login-hero .login-brand span {
    color: rgba(255, 255, 255, .72);
}

.login-hero-title {
    font-size: 1.36rem;
    font-weight: 850;
    line-height: 1.28;
    margin: 0 0 8px;
}

.login-hero-subtitle {
    color: rgba(255, 255, 255, .78);
    font-size: .86rem;
    line-height: 1.5;
    margin: 0 0 22px;
}

.login-hero-role-select {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-hero-role-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    padding: 9px 10px;
    text-align: left;
    color: #fff;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.login-hero-role-btn:hover {
    background: rgba(255, 255, 255, .08);
}

.login-hero-role-btn.active {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .28);
    box-shadow: 0 10px 24px rgba(9, 20, 45, .18);
}

.login-hero-role-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .14);
    display: grid;
    place-items: center;
    font-size: .98rem;
    transition: background .16s ease;
}

.login-hero-role-btn.active .login-hero-role-icon {
    background: rgba(255, 255, 255, .24);
}

.login-hero-role-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.login-hero-role-copy strong {
    font-size: .9rem;
    font-weight: 800;
}

.login-hero-role-copy span {
    font-size: .78rem;
    color: rgba(255, 255, 255, .7);
}

.login-hero-role-arrow {
    flex: 0 0 auto;
    font-size: .85rem;
    color: rgba(255, 255, 255, .55);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .16s ease, transform .16s ease;
}

.login-hero-role-btn.active .login-hero-role-arrow,
.login-hero-role-btn:hover .login-hero-role-arrow {
    opacity: 1;
    transform: translateX(0);
}

.unified-login-panel {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 34px 44px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand-wide {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.login-type-option {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    white-space: nowrap;
}

.login-type-option.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 24px rgba(35, 86, 216, .22);
}

.login-type-selector-mobile {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    margin: 0 0 18px;
    padding: 4px;
    border-radius: 12px;
    background: #eef3f8;
    border: 1px solid var(--line);
    scrollbar-width: none;
}

.login-type-selector-mobile::-webkit-scrollbar {
    display: none;
}

.login-type-selector-mobile .login-type-option {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 92px;
    min-height: 42px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.72rem;
    line-height: 1.1;
    white-space: normal;
    text-align: center;
}

.login-type-selector-mobile .login-type-option i {
    font-size: 0.95rem;
    line-height: 1;
}

.login-heading {
    margin-bottom: 16px;
}

.login-heading span {
    color: var(--accent);
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.login-brand {
    margin-bottom: 28px;
}

.login-brand span {
    color: var(--muted);
}

.login-panel h1 {
    font-size: 1.55rem;
    font-weight: 850;
    margin: 0 0 6px;
}

.login-panel p {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 18px;
}

.auth-link {
    display: block;
    margin-top: 16px;
    text-align: center;
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.auth-inline-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.auth-inline-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.login-input-wrap {
    position: relative;
}

.login-input-wrap > i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    z-index: 5;
}

.login-input-wrap .form-control {
    padding-left: 44px;
}

.login-input-wrap.password-field .form-control {
    padding-right: 50px;
}

.login-form-row {
    margin: 2px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.login-submit {
    min-height: 46px;
}

.login-form .mb-3 {
    margin-bottom: 14px;
}

.auth-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Unified login page: below the lg breakpoint the hero panel (hidden via
   d-none d-lg-flex in the markup) collapses out entirely, so the shell
   becomes a single centered card sized for a comfortable one-column form. */
@media (max-width: 991.98px) {
    .unified-login-wrap {
        padding: 20px 16px;
    }

    .unified-login-shell {
        width: 100%;
        max-width: 440px;
        margin: 0 auto;
    }

    .unified-login-panel {
        max-width: none;
        margin: 0;
        padding: 28px 26px;
    }
}

@media (max-width: 991.98px) {
    .admin-sidebar {
        transition: none;
    }

    .sidebar-collapsed .admin-sidebar {
        width: 280px;
        flex-basis: 280px;
    }

    .sidebar-collapsed .admin-sidebar .brand-copy,
    .sidebar-collapsed .admin-sidebar .sidebar-nav span,
    .sidebar-collapsed .admin-sidebar .sidebar-logout span {
        width: auto;
        opacity: 1;
        overflow: visible;
        display: inline;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-nav a,
    .sidebar-collapsed .admin-sidebar .sidebar-nav .disabled,
    .sidebar-collapsed .admin-sidebar .sidebar-logout .btn {
        justify-content: flex-start;
        padding: 0 14px;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-logout {
        padding: 22px;
    }

    .student-drawer {
        width: min(96vw, 520px) !important;
    }

    .exam-drawer {
        width: min(96vw, 680px) !important;
    }

    .admin-shell {
        min-height: 100vh;
        height: auto;
        overflow: visible;
    }

    .admin-main {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .admin-topbar {
        min-height: 76px;
        padding: 14px 18px;
    }

    .admin-content {
        padding: 18px;
    }

    .student-content {
        padding: 18px;
    }

    .dashboard-hero,
    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-hero .btn,
    .panel-header .btn {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    body {
        overflow-x: hidden;
    }

    body.login-body {
        min-height: 100dvh;
        overflow-x: hidden;
        background:
            linear-gradient(180deg, rgba(35, 86, 216, 0.12), rgba(15, 159, 143, 0.08)),
            #f6f8fb;
    }

    .mobile-sidebar {
        width: min(86vw, 320px) !important;
        max-width: 86vw;
    }

    .mobile-sidebar .brand {
        padding-right: 52px;
    }

    .mobile-sidebar-close {
        top: 20px;
        right: 12px;
        width: 36px;
        height: 36px;
    }

    .student-drawer {
        width: 96vw !important;
    }

    .exam-drawer {
        width: 96vw !important;
    }

    .student-drawer .offcanvas-body {
        padding: 18px;
    }

    .exam-drawer .offcanvas-body {
        padding: 18px 18px 0;
    }

    .exam-drawer .admin-form > .d-flex:last-child {
        margin-left: -18px;
        margin-right: -18px;
        padding-left: 18px;
        padding-right: 18px;
    }

    .student-drawer-header {
        padding: 16px 18px;
    }

    .login-wrap {
        min-height: 100dvh;
        place-items: start center;
        padding: 12px;
    }

    .login-panel {
        width: 100%;
        max-width: 400px;
        border-radius: 14px;
        padding: 18px;
        box-shadow: 0 16px 40px rgba(20, 32, 54, 0.12);
    }

    .unified-login-wrap {
        padding: 12px;
    }

    .unified-login-shell {
        max-width: 400px;
    }

    .unified-login-panel {
        padding: 22px 20px;
    }

    .login-brand {
        margin-bottom: 16px;
        gap: 10px;
    }

    .login-brand-wide {
        padding-bottom: 12px;
    }

    .login-brand .brand-mark {
        flex: 0 0 38px;
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .login-brand .brand-logo {
        flex: 0 0 38px;
        max-width: 38px;
        max-height: 38px;
    }

    .login-brand strong {
        font-size: 0.98rem;
    }

    .login-brand span {
        font-size: 0.76rem;
    }

    .login-heading {
        margin-bottom: 16px;
    }

    .login-heading span {
        font-size: 0.7rem;
    }

    .login-panel h1 {
        margin-bottom: 5px;
        font-size: 1.45rem;
        line-height: 1.2;
    }

    .login-panel p {
        margin-bottom: 0;
        font-size: 0.86rem;
        line-height: 1.45;
    }

    .login-form .mb-3 {
        margin-bottom: 12px !important;
    }

    .login-form .form-label {
        margin-bottom: 5px;
        font-size: 0.82rem;
        font-weight: 800;
    }

    .login-input-wrap > i {
        left: 14px;
        font-size: 0.95rem;
    }

    .login-form .form-control {
        min-height: 48px;
        border-radius: 10px;
        font-size: 0.95rem;
    }

    .login-input-wrap .form-control {
        padding-left: 42px;
    }

    .login-input-wrap.password-field .form-control,
    .password-field .form-control {
        padding-right: 52px;
    }

    .password-toggle {
        top: 50%;
        right: 6px;
        width: 40px;
        height: 40px;
        transform: translateY(-50%);
        border-radius: 10px;
    }

    .password-field .is-invalid {
        background-position: right 3.1rem center;
    }

    .feedback-alert {
        padding: 11px 12px;
        border-radius: 10px;
        font-size: 0.84rem;
    }

    .login-form-row {
        margin: 0 0 16px;
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .login-form-row .form-check {
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 7px;
        margin: 0;
    }

    .login-form-row .form-check-input {
        flex: 0 0 18px;
        width: 18px;
        height: 18px;
        margin: 0;
    }

    .login-form-row .form-check-label,
    .auth-inline-link {
        font-size: 0.82rem;
    }

    .auth-inline-link {
        margin-left: auto;
        padding: 4px 0;
        white-space: nowrap;
    }

    .login-submit,
    #studentContinueButton,
    #sendOtpButton,
    #verifyOtpButton,
    #createPasswordButton {
        min-height: 50px;
        border-radius: 10px;
        font-size: 0.95rem;
    }

    .invalid-feedback {
        font-size: 0.78rem;
    }

    .admin-user {
        display: none;
    }

    .topbar-actions {
        max-width: 52%;
    }

    .current-branch-pill {
        max-width: 100%;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .filter-bar.compact-filter-bar {
        grid-template-columns: 1fr;
    }

    .filter-bar.logs-filter-bar,
    .filter-bar.filter-bar-oneline {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar.logs-filter-bar > *,
    .filter-bar.filter-bar-oneline > * {
        min-width: 0;
    }

    .content-panel,
    .dashboard-hero {
        padding: 18px;
    }
}

@media (max-width: 359.98px) {
    .login-panel,
    .unified-login-panel {
        padding: 14px;
    }

    .auth-inline-link {
        margin-left: 0;
    }
}

/* Student portal */
.student-portal-body {
    min-height: 100vh;
    color: #172033;
    background:
        radial-gradient(circle at top left, rgba(29, 111, 216, 0.12), transparent 34rem),
        linear-gradient(135deg, #f7fafc 0%, #eef4f8 48%, #f9fbf7 100%);
}

.student-shell {
    background:
        radial-gradient(circle at top left, rgba(29, 111, 216, 0.12), transparent 34rem),
        linear-gradient(135deg, #f7fafc 0%, #eef4f8 48%, #f9fbf7 100%);
}

.student-sidebar,
.student-mobile-sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #173b6d 58%, #0b5d58 100%);
}

.student-panel-topbar {
    background: rgba(255, 255, 255, 0.9);
}

.student-content {
    width: auto;
    margin: 0;
    padding: 28px;
}

.student-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 74px;
    padding: 14px clamp(18px, 4vw, 56px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(23, 32, 51, 0.08);
    box-shadow: 0 10px 30px rgba(23, 32, 51, 0.06);
    backdrop-filter: blur(14px);
}

.student-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #172033;
    text-decoration: none;
}

.student-brand .brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, #1d6fd8, #18a999);
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(29, 111, 216, 0.22);
}

.student-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.student-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
    color: #596477;
    font-weight: 700;
    text-decoration: none;
    border-radius: 10px;
}

.student-nav a.active,
.student-nav a:hover {
    color: #0e5fc5;
    background: rgba(29, 111, 216, 0.1);
}

.student-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 48px;
}

.student-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: clamp(24px, 4vw, 42px);
    color: #fff;
    background:
        linear-gradient(135deg, rgba(15, 56, 113, 0.94), rgba(24, 169, 153, 0.9)),
        url("https://images.unsplash.com/photo-1522202176988-66273c2fd55f?auto=format&fit=crop&w=1600&q=80") center/cover;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(23, 32, 51, 0.18);
    overflow: hidden;
}

.student-hero span,
.student-section-header span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.8;
}

.student-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.4rem);
    font-weight: 850;
    letter-spacing: 0;
}

.student-hero p {
    margin: 10px 0 0;
    max-width: 700px;
    color: rgba(255, 255, 255, 0.84);
    font-size: 1.02rem;
}

.student-hero-avatar {
    display: none;
}

.student-hero-copy {
    min-width: 0;
}

.student-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.student-stat {
    min-height: 104px;
    padding: 18px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(23, 32, 51, 0.07);
}

.student-stat span {
    display: block;
    color: #6b7588;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.student-stat strong {
    display: block;
    margin-top: 10px;
    color: #172033;
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1.1;
}

.student-section {
    margin-top: 24px;
    padding: clamp(20px, 3vw, 28px);
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

.student-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.student-section-header h2 {
    margin: 0;
    color: #172033;
    font-size: clamp(1.35rem, 2vw, 1.8rem);
    font-weight: 850;
    letter-spacing: 0;
}

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

.exam-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 20px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 14px;
    box-shadow: 0 14px 32px rgba(23, 32, 51, 0.08);
}

.exam-card h3 {
    margin: 14px 0 8px;
    color: #172033;
    font-size: 1.2rem;
    font-weight: 850;
}

.exam-card p {
    color: #667085;
}

.exam-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 18px;
}

.exam-card dt {
    color: #7a8496;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.exam-card dd {
    margin: 2px 0 0;
    color: #172033;
    font-weight: 800;
}

.exam-card .btn {
    margin-top: auto;
}

.result-list {
    display: grid;
    gap: 10px;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    color: inherit;
    text-decoration: none;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 12px;
}

.result-row:hover {
    border-color: rgba(29, 111, 216, 0.28);
    box-shadow: 0 10px 24px rgba(29, 111, 216, 0.1);
}

.result-row span:not(.status-badge) {
    display: block;
    color: #7a8496;
    font-size: 0.88rem;
}

.result-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.result-card {
    position: relative;
    min-height: 86px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(23, 32, 51, 0.06);
    overflow: hidden;
}

.result-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--result-accent, #1d6fd8);
}

.result-card-left {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-card-icon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--result-accent, #1d6fd8);
    background: var(--result-soft, #eff6ff);
    border-radius: 9px;
    font-size: 0.95rem;
}

.result-card span {
    min-width: 0;
    margin: 0;
    color: #667085;
    font-size: 0.76rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
}

.result-card strong {
    color: #172033;
    font-size: clamp(1.05rem, 1.7vw, 1.35rem);
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
}

.result-card strong small {
    margin-left: 1px;
    color: #7a8496;
    font-size: 0.78rem;
    font-weight: 800;
}

.result-card.color-blue {
    --result-accent: #1d6fd8;
    --result-soft: #eff6ff;
}

.result-card.color-green {
    --result-accent: #10b981;
    --result-soft: #ecfdf5;
}

.result-card.color-orange {
    --result-accent: #f59e0b;
    --result-soft: #fffbeb;
}

.result-card.color-purple {
    --result-accent: #7c3aed;
    --result-soft: #f5f3ff;
}

.result-card.color-red {
    --result-accent: #ef4444;
    --result-soft: #fef2f2;
}

.result-card.color-teal {
    --result-accent: #14b8a6;
    --result-soft: #f0fdfa;
}

.exam-history-list,
.performance-list {
    display: grid;
    gap: 12px;
}

.exam-history-item,
.performance-item {
    display: grid;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(23, 32, 51, 0.055);
}

.exam-history-item {
    grid-template-columns: 42px minmax(180px, 1fr) minmax(120px, auto) auto auto;
    border-left: 4px solid #1d6fd8;
}

.exam-history-icon,
.performance-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 1.05rem;
}

.exam-history-icon {
    color: #1d6fd8;
    background: #eef4ff;
}

.exam-history-info,
.performance-info {
    min-width: 0;
}

.exam-history-info h4,
.performance-info h4 {
    margin: 0;
    color: #172033;
    font-size: 0.98rem;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.exam-history-date,
.performance-date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    color: #7a8496;
    font-size: 0.82rem;
    font-weight: 700;
}

.exam-history-score,
.performance-metric {
    min-width: 0;
}

.exam-history-score span,
.performance-metric span {
    display: block;
    color: #7a8496;
    font-size: 0.72rem;
    font-weight: 850;
    text-transform: uppercase;
}

.exam-history-score strong,
.performance-metric strong {
    display: block;
    margin-top: 3px;
    color: #172033;
    font-size: 0.98rem;
    font-weight: 900;
    white-space: nowrap;
}

.exam-history-status,
.performance-status {
    justify-self: end;
}

.exam-history-action,
.performance-action {
    justify-self: end;
    white-space: nowrap;
}

.performance-item {
    grid-template-columns: minmax(220px, 1.1fr) minmax(250px, 1fr) auto auto;
    border-left: 4px solid #0f9f8f;
}

.performance-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.performance-icon {
    flex: 0 0 42px;
    color: #0f766e;
    background: #e6f7f4;
}

.performance-icon.failed {
    color: #d83250;
    background: #fff0f3;
}

.performance-date.passed {
    color: #067647;
}

.performance-date.failed {
    color: #b42318;
}

.performance-metrics {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(92px, 1fr));
    gap: 8px 14px;
    align-items: end;
}

.performance-meter {
    grid-column: 1 / -1;
    height: 8px;
    overflow: hidden;
    background: #eef2f6;
    border-radius: 999px;
}

.performance-meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #1d6fd8, #18a999);
    border-radius: inherit;
}

.exam-instructions > p {
    color: #667085;
    font-size: 1rem;
}

.exam-runner-shell {
    min-height: calc(100vh - 150px);
}

.exam-loading {
    display: grid;
    place-items: center;
    min-height: 360px;
    color: #667085;
    font-weight: 800;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

.exam-runner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 20px 22px;
    color: #fff;
    background: linear-gradient(135deg, #173b6d, #168f83);
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(23, 32, 51, 0.16);
}

.exam-runner-header span {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    opacity: 0.78;
}

.exam-runner-header h1 {
    margin: 4px 0 0;
    font-size: clamp(1.35rem, 3vw, 2.2rem);
    font-weight: 850;
}

.exam-timer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 112px;
    justify-content: center;
    padding: 10px 14px;
    color: #173b6d;
    font-weight: 900;
    background: #fff;
    border-radius: 12px;
}

.exam-timer.danger {
    color: #b42318;
    background: #fff1f0;
}

.exam-progress {
    height: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    background: rgba(23, 32, 51, 0.1);
    border-radius: 999px;
}

.exam-progress div {
    height: 100%;
    background: linear-gradient(90deg, #1d6fd8, #18a999);
    transition: width 0.25s ease;
}

.exam-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 26px rgba(23, 32, 51, 0.06);
}

.exam-nav-wrap {
    flex: 1 1 320px;
    min-width: 0;
}

.exam-nav-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #667085;
}

.exam-nav-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.exam-nav-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #596477;
    font-weight: 800;
    background: #f3f6fa;
    border: 1px solid rgba(23, 32, 51, 0.1);
    border-radius: 10px;
}

.exam-nav-btn.answered {
    color: #067647;
    background: #ecfdf3;
    border-color: #75e0a7;
}

.exam-nav-btn.skipped {
    color: #b42318;
    background: #fef3f2;
    border-color: #f97066;
}

.exam-nav-btn.active {
    color: #fff;
    background: #1d6fd8;
    border-color: #1d6fd8;
}

/* A Summary step marks all of its child questions "active" at once, so the
   blue fill must not hide whether each one is answered: an answered question
   on the current step stays green, with a blue ring showing it's on screen.
   Clearing the answer drops it back to plain blue. */
.exam-nav-btn.active.answered {
    color: #067647;
    background: #ecfdf3;
    border-color: #1d6fd8;
    box-shadow: 0 0 0 2px rgba(29, 111, 216, .35);
}

/* Submit Exam modal: which questions were attempted vs skipped. */
.submit-summary {
    display: grid;
    gap: 14px;
}

.submit-summary-group {
    padding: 12px 14px;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background: #f9fafb;
}

.submit-summary-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 700;
}

.submit-summary-title strong {
    margin-left: auto;
}

.submit-summary-title.answered {
    color: #067647;
}

.submit-summary-title.skipped {
    color: #b42318;
}

.submit-summary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.submit-summary-empty,
.submit-summary-hint {
    margin: 0;
    font-size: 0.875rem;
    color: #667085;
}

.exam-font-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.exam-font-control-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #667085;
    white-space: nowrap;
}

.exam-font-control button {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f6fa;
    border: 1px solid rgba(23, 32, 51, 0.1);
    border-radius: 8px;
    color: #172033;
}

.exam-font-control button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.exam-question-panel {
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
    padding: clamp(20px, 3vw, 30px);
}

.question-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    color: #667085;
    font-weight: 800;
}

.exam-question-text {
    margin-bottom: 22px;
    color: #172033;
    font-size: calc(1.18rem * var(--exam-font-scale, 1));
    font-weight: 800;
    line-height: 1.55;
}

/* Question text renders as rich HTML (same CKEditor as Summaries) via
   .passage-preview for its paragraph/image/table styling, but .passage-preview
   also carries its own fixed padding and font-size (meant for a standalone
   boxed preview elsewhere). Both rules have equal (single-class) specificity,
   so without this compound override .passage-preview's fixed 0.94rem would
   win on source order alone and the Text Size control would silently stop
   affecting Questions (including Questions under a Summary, which use this
   same class combination) while still working on the Summary panel. */
.exam-question-text.passage-preview {
    padding: 0;
    font-size: calc(1.18rem * var(--exam-font-scale, 1));
    line-height: 1.55;
}

/* Anti-copy protection: applies to every element inside the exam runner
   (question text, passage/summary content, MCQ options, palette, etc.).
   Scoped to .exam-runner-shell, which only renders while a student is
   actively taking an exam, so no other page is affected. Buttons and
   click handlers are unaffected since user-select only blocks text
   selection, not pointer/click events. */
.exam-runner-shell,
.exam-runner-shell * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.exam-options {
    display: grid;
    gap: 12px;
}

.exam-option {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    width: 100%;
    min-height: 56px;
    padding: 14px;
    text-align: left;
    background: #f8fafc;
    border: 1px solid rgba(23, 32, 51, 0.1);
    border-radius: 12px;
}

.exam-option > span {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    border: 2px solid #98a2b3;
    border-radius: 999px;
}

.exam-option.selected {
    background: rgba(29, 111, 216, 0.08);
    border-color: #1d6fd8;
}

.exam-option.selected > span {
    border: 6px solid #1d6fd8;
}

.exam-controls {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.math-content {
    overflow-wrap: anywhere;
}

/* Passage/Summary question group — student exam runner.
   Flex (not grid) so the Summary panel's width can be driven imperatively
   by the resize-handle drag logic in student-exam.jsx: the panel gets an
   explicit inline pixel width (flex: 0 0 auto so it never grows/shrinks on
   its own), the handle is a fixed-width column, and the questions column
   fills whatever space is left (flex: 1 1 0%). */
.passage-step-grid {
    display: flex;
    align-items: flex-start;
}

.passage-panel {
    flex: 0 0 auto;
    width: 38%;
    /* .admin-topbar (min-height: 88px) is sticky within the same scroll
       container (.admin-main) that this panel scrolls inside, so "top" and
       "max-height" both need to clear it — otherwise this panel slides up
       underneath/behind the topbar instead of docking cleanly below it. */
    position: sticky;
    top: calc(88px + 16px);
    z-index: 5;
    align-self: start;
    min-width: 0;
    background: #ffffff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-top: 3px solid var(--accent, #0f9f8f);
    border-radius: 14px;
    padding: 20px 22px;
    max-height: calc(100vh - 88px - 32px);
    overflow-y: auto;
    box-shadow: 0 16px 36px rgba(23, 32, 51, 0.08);
}

.passage-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(23, 32, 51, 0.08);
}

.passage-panel-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent, #0f9f8f);
}

.passage-panel-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 850;
    color: #172033;
}

.passage-panel-image {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 14px;
}

.passage-panel-content {
    color: #344054;
    line-height: 1.7;
    font-size: calc(0.96rem * var(--exam-font-scale, 1));
}

.passage-panel-content > *:first-child {
    margin-top: 0;
}

.passage-panel-content > *:last-child {
    margin-bottom: 0;
}

.passage-panel-content p {
    margin: 0 0 14px;
}

.passage-panel-content ul,
.passage-panel-content ol {
    margin: 0 0 14px;
    padding-left: 22px;
}

.passage-panel-content li {
    margin-bottom: 6px;
}

.passage-panel-content blockquote {
    margin: 0 0 14px;
    padding: 10px 16px;
    border-left: 3px solid var(--accent, #0f9f8f);
    background: rgba(15, 159, 143, 0.06);
    border-radius: 0 8px 8px 0;
    color: #475467;
}

.passage-panel-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 6px 0 14px;
}

.passage-panel-content table {
    width: 100%;
    margin-bottom: 14px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.passage-panel-content td,
.passage-panel-content th {
    padding: 8px 10px;
    border: 1px solid rgba(23, 32, 51, 0.12);
}

.passage-questions-column {
    flex: 1 1 0%;
    min-width: 0;
    display: grid;
    gap: 26px;
}

.passage-question-block {
    padding-bottom: 22px;
    border-bottom: 1px dashed rgba(23, 32, 51, 0.14);
}

.passage-question-block:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.passage-collapse-toggle {
    display: none;
}

/* Draggable divider between the Summary and Question/Answer panels — same
   idea as a textarea's resize grip, but full-height and mouse/touch/keyboard
   operable. Width must match PASSAGE_DIVIDER_WIDTH in student-exam.jsx. */
.passage-resize-handle {
    flex: 0 0 20px;
    width: 20px;
    align-self: stretch;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    touch-action: none;
}

.passage-resize-handle::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: rgba(23, 32, 51, 0.12);
    border-radius: 2px;
    transition: background-color 0.15s ease, width 0.15s ease;
}

.passage-resize-grip {
    position: relative;
    z-index: 1;
    width: 16px;
    height: 34px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid rgba(23, 32, 51, 0.14);
    box-shadow: 0 4px 10px rgba(23, 32, 51, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.passage-resize-grip::before,
.passage-resize-grip::after {
    content: '';
    width: 2px;
    height: 14px;
    border-radius: 2px;
    background: rgba(23, 32, 51, 0.28);
}

.passage-resize-handle:hover::before,
.passage-resize-handle:focus-visible::before,
.passage-step-grid.is-resizing .passage-resize-handle::before {
    background: var(--accent, #0f9f8f);
    width: 3px;
}

.passage-resize-handle:hover .passage-resize-grip,
.passage-resize-handle:focus-visible .passage-resize-grip,
.passage-step-grid.is-resizing .passage-resize-grip {
    border-color: var(--accent, #0f9f8f);
    box-shadow: 0 6px 14px rgba(15, 159, 143, 0.25);
    transform: scaleX(1.1);
}

.passage-resize-handle:focus-visible {
    outline: none;
}

/* While actively dragging, disable transitions/text-selection so the panel
   tracks the pointer immediately instead of easing/selecting text underneath
   fast mouse movement. */
.passage-step-grid.is-resizing .passage-panel,
.passage-step-grid.is-resizing .passage-questions-column {
    user-select: none;
}

body.is-resizing-panels {
    cursor: col-resize;
    user-select: none;
}

body.is-resizing-panels * {
    cursor: col-resize !important;
}

@media (max-width: 767.98px) {
    .passage-step-grid {
        flex-direction: column;
        gap: 16px;
    }

    /* The drag-resize divider is JS-disabled below this breakpoint
       (student-exam.jsx doesn't render it at all); this is a pure fallback
       in case it's ever present in the DOM anyway. */
    .passage-resize-handle {
        display: none;
    }

    .passage-panel {
        position: static;
        max-height: none;
        padding: 16px 18px;
        width: 100% !important;
        flex-basis: auto;
    }

    .passage-questions-column {
        flex-basis: auto;
    }

    /* Once the passage panel goes full-width (stacked above its questions
       instead of sitting in a narrow side column), an uncapped image can
       run very tall. Capping the height and using "contain" (never "cover")
       keeps it compact without cropping any exam content out of view. */
    .passage-panel-image,
    .passage-panel-content img {
        display: block;
        max-height: 260px;
        width: 100%;
        margin-left: auto;
        margin-right: auto;
        object-fit: contain;
        background: #f8fafc;
    }

    .passage-questions-column {
        gap: 20px;
    }

    /* A wide data table pasted into passage content would otherwise force
       the whole page to scroll horizontally; scope the scroll to the table
       itself instead. */
    .passage-panel-content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .passage-collapse-toggle {
        display: inline-flex;
    }

    .passage-panel.collapsed .passage-panel-body {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .student-topbar,
    .student-section-header,
    .exam-runner-header {
        align-items: stretch;
        flex-direction: column;
    }

    .student-nav {
        justify-content: flex-start;
    }

    .student-main {
        width: min(100% - 24px, 1180px);
        padding-top: 18px;
    }

    .student-hero,
    .student-section {
        border-radius: 14px;
    }

    .student-content .empty-state {
        padding: 34px 16px;
    }

    .student-content .empty-state i {
        font-size: 1.7rem;
    }

    .exam-card dl {
        grid-template-columns: 1fr;
    }

    .result-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .exam-history-item,
    .performance-item {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .exam-history-icon,
    .performance-icon {
        display: none;
    }

    .exam-history-status,
    .performance-status,
    .exam-history-action,
    .performance-action {
        justify-self: stretch;
    }

    .exam-history-action,
    .performance-action {
        width: 100%;
    }

    .exam-controls .btn {
        flex: 1 1 100%;
        justify-content: center;
    }
}

@media (max-width: 575.98px) {
    /* 8 stat tiles read as one long list in a single column — 2-up keeps
       every number visible without excessive scrolling, and the icon+value
       stack (below) gives each tile room to stay legible at half width. */
    .result-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .result-card {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 92px;
        padding: 12px 14px;
    }

    .result-card-left {
        gap: 8px;
    }

    .result-card strong {
        align-self: center;
        font-size: 1.25rem;
    }

    .performance-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Teacher Dashboard has only 3 stat cards (not the 7-8 tile results
       page the 2-up rule above is tuned for), so on phones they stack one
       per row instead of wrapping 2+1. Desktop/tablet keep the shared
       .result-card-grid behavior untouched. */
    .result-card-grid.teacher-dashboard-stats {
        grid-template-columns: 1fr;
    }

    /* At full row width the centered icon+label/value cluster from the
       2-up tile style above would float in the middle with large empty
       gaps on both sides — a plain left/right row reads better here. */
    .teacher-dashboard-stats .result-card {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        min-height: 56px;
        padding: 8px 14px;
    }

    .teacher-dashboard-stats .result-card strong {
        font-size: 1.15rem;
    }

    .teacher-dashboard-stats .result-card-icon {
        flex: 0 0 28px;
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
}

/* ============================================
   Exam Details Page (Admin / Branch)
   ============================================ */

/* Hero banner */
.exam-hero {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #173b9d 0%, #1d5fd8 45%, #0f9f8f 100%);
    box-shadow: 0 18px 45px rgba(23, 59, 157, 0.22);
}

.exam-hero-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 85% 20%, rgba(255, 255, 255, 0.14), transparent 22rem),
        radial-gradient(circle at 15% 90%, rgba(255, 255, 255, 0.08), transparent 18rem);
    pointer-events: none;
}

.exam-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    padding: 28px 30px;
    color: #fff;
}

.exam-hero-top {
    order: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.exam-hero-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.exam-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.exam-status-badge.status-published {
    background: rgba(16, 185, 129, 0.28);
    border-color: rgba(16, 185, 129, 0.45);
}

.exam-status-badge.status-draft {
    background: rgba(245, 158, 11, 0.28);
    border-color: rgba(245, 158, 11, 0.45);
}

.exam-status-badge.status-closed {
    background: rgba(239, 68, 68, 0.28);
    border-color: rgba(239, 68, 68, 0.45);
}

.exam-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.exam-meta-chip i {
    font-size: 0.9rem;
    opacity: 0.85;
}

.exam-hero-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-exam-action {
    min-height: 40px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.88rem;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-exam-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: #fff;
    color: #fff;
}

.exam-hero-title {
    order: 2;
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 850;
    letter-spacing: -0.01em;
    line-height: 1.2;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.exam-hero-desc {
    order: 3;
    margin: 10px 0 0;
    max-width: 720px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.98rem;
    line-height: 1.6;
}

/* Stats grid */
.exam-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.exam-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(20, 32, 54, 0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.exam-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(20, 32, 54, 0.1);
}

.exam-stat-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

.exam-stat-icon.primary {
    background: #eef4ff;
    color: var(--primary);
}

.exam-stat-icon.accent {
    background: #e6f7f4;
    color: var(--accent);
}

.exam-stat-icon.success {
    background: #ecfdf5;
    color: #067647;
}

.exam-stat-icon.warning {
    background: #fffaeb;
    color: #b54708;
}

.exam-stat-icon.info {
    background: #eff8ff;
    color: #175cd3;
}

.exam-stat-icon.danger {
    background: #fff0f3;
    color: var(--danger);
}

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

.exam-stat-body span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.exam-stat-body strong {
    display: block;
    margin-top: 4px;
    font-size: 1.5rem;
    font-weight: 850;
    line-height: 1.1;
    color: var(--ink);
}

.exam-stat-body strong small {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

/* Exam details panel */
.exam-details-panel {
    margin-bottom: 20px;
}

.exam-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.exam-detail-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fbfcfe;
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.exam-detail-item:hover {
    border-color: #c9d4e8;
    box-shadow: 0 4px 14px rgba(20, 32, 54, 0.05);
}

.exam-detail-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #eef4ff;
    color: var(--primary);
    font-size: 0.95rem;
}

.exam-detail-icon.success {
    background: #ecfdf5;
    color: #067647;
}

.exam-detail-icon.danger {
    background: #fff0f3;
    color: var(--danger);
}

.exam-detail-item dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.exam-detail-item dd {
    margin: 3px 0 0;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--ink);
}

/* Questions panel */
.questions-panel {
    margin-bottom: 20px;
}

.question-mgmt-panel {
    margin-bottom: 28px;
}

.questions-panel-header {
    padding: 16px 24px;
    margin-bottom: 28px;
}

.questions-panel-header .panel-header {
    margin-bottom: 0;
}

.questions-panel-header .panel-header h2 {
    font-size: 1.1rem;
}

.questions-panel-header .panel-header p {
    margin-top: 2px;
    font-size: 0.85rem;
}

.question-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #eef4ff;
    color: var(--primary);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 800;
    white-space: nowrap;
}

/* Existing questions panel (shown on add-question page) */
.existing-questions-panel {
    display: grid;
    gap: 18px;
}

.existing-question-card {
    background: #fbfcfe;
}

.existing-question-card .form-control,
.existing-question-card .form-select {
    background: #f3f5f9;
    color: var(--muted);
}

.badge-saved {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #067647;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Question list */
.question-list {
    display: grid;
    gap: 16px;
}

.question-mgmt-panel .question-list {
    gap: 20px;
}

.question-admin-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(20, 32, 54, 0.05);
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.question-admin-item:hover {
    border-color: #c9d4e8;
    box-shadow: 0 16px 40px rgba(20, 32, 54, 0.09);
}

/* Passage/Summary group card — distinct teal-tinted background so it's
   immediately clear which questions belong to a Summary vs. stand alone. */
.passage-group-item {
    background: #d9f0ec;
    border-color: #9cd6c9;
}

.passage-group-item > .question-item-header {
    background: linear-gradient(180deg, #cdeae3, #bfe3da);
    border-bottom-color: #a9d9cc;
}

.passage-group-item > .question-item-header .question-number-badge {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    font-size: 1.05rem;
}

.passage-preview {
    padding: 4px 20px 18px;
    color: var(--ink);
    font-size: 0.94rem;
    line-height: 1.7;
}

.passage-preview > *:first-child {
    margin-top: 0;
}

.passage-preview > *:last-child {
    margin-bottom: 0;
}

.passage-preview p {
    margin: 0 0 12px;
}

.passage-preview ul,
.passage-preview ol {
    margin: 0 0 12px;
    padding-left: 22px;
}

.passage-preview li {
    margin-bottom: 5px;
}

.passage-preview blockquote {
    margin: 0 0 12px;
    padding: 10px 16px;
    border-left: 3px solid var(--accent);
    background: rgba(15, 159, 143, 0.08);
    border-radius: 0 8px 8px 0;
    color: #475467;
}

/* Images inserted via the Summary/Question rich-text editor: keep their
   intrinsic aspect ratio, cap width to the card so they never overflow the
   result layout on any screen size, and give them a bit of visual weight. */
.passage-preview img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 8px 0 12px;
    box-shadow: 0 6px 18px rgba(20, 32, 54, 0.08);
}

.passage-preview table {
    width: 100%;
    margin-bottom: 12px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.passage-preview td,
.passage-preview th {
    padding: 8px 10px;
    border: 1px solid rgba(23, 32, 51, 0.12);
}

/* Student Result Details: Summary "Read More" / "Show Less". Collapsed
   state is toggled by JS only when the content actually overflows the
   preview window, so a short Summary never shows the button at all. Images
   stay fully responsive throughout — this only clips the container. */
.summary-collapsible {
    position: relative;
}

.summary-collapsible-body.is-collapsed {
    position: relative;
    max-height: 320px;
    overflow: hidden;
}

.summary-collapsible-body.is-collapsed::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: linear-gradient(180deg, rgba(217, 240, 236, 0) 0%, #d9f0ec 88%);
    pointer-events: none;
}

.summary-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 20px 16px;
}

.summary-toggle-icon {
    font-size: 0.8rem;
}

.passage-group-questions {
    display: grid;
    gap: 12px;
    padding: 0 16px 16px;
    background: #eef6f5;
}

.question-mgmt-panel .passage-group-questions {
    gap: 16px;
}

.passage-child-item {
    background: #f8fcfb;
    border-color: #dcece9;
    box-shadow: none;
}

.passage-child-item .question-item-header {
    background: linear-gradient(180deg, #f2f9f8, #edf6f4);
    border-bottom-color: #e2f0ed;
}

.passage-child-item .question-number-badge {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    box-shadow: none;
}

.question-item-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid #eef1f6;
    background: linear-gradient(180deg, #fafbfe, #f6f8fb);
}

.question-number-badge {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 0.95rem;
    box-shadow: 0 6px 16px rgba(35, 86, 216, 0.22);
}

.question-item-content {
    flex: 1;
    min-width: 0;
}

.question-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.question-marks-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: #fff0f3;
    color: var(--danger);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.question-item-text {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.5;
    color: var(--ink);
}

/* Question text now renders as rich HTML (same CKEditor as Summaries) via
   .passage-preview for its paragraph/image/table styling, but that class's
   own padding is meant for a standalone boxed preview — here it already
   sits inside .question-item-header's padding, so reset it to avoid a
   double-indent against the badges/marks row above it. */
.question-item-text.passage-preview {
    padding: 0;
}

/* Student Result Details only: this markup (.question-item-text etc.) is
   shared with the Admin/Branch result-review page via the same
   answer-item partial, so scope to .student-content — the Student Panel's
   own <main> — rather than touching the base rule above. Excludes
   .passage-group-item's own header, which reuses .question-item-text for
   the Summary's title ("Summary 1: Total = …"), not a question. */
.student-content .question-admin-item:not(.passage-group-item) .question-item-text {
    font-size: 0.94rem;
}

.question-item-actions {
    flex: 0 0 auto;
}

/* Option preview */
.option-preview {
    display: grid;
    gap: 8px;
    padding: 16px 20px;
    list-style: none;
    margin: 0;
}

.option-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.option-preview-item.correct {
    background: #f0fdf4;
    border-color: #86efac;
}

.option-letter {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #e8eefb;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 0.8rem;
}

.option-preview-item.correct .option-letter {
    background: #d1fae5;
    color: #067647;
}

.option-text {
    flex: 1;
    min-width: 0;
    font-size: 0.92rem;
    color: var(--ink);
}

/* Answer Review / Result Details, mobile only, ALL panels (Super Admin,
   Branch, Teacher, Student, Guardian): every one of these panels renders
   Questions/Student Answers/Correct Answers/Summary content through the
   same shared markup (.question-item-text, .option-text, .passage-preview,
   etc. — see results/partials/show.blade.php, results/partials/answer-item
   .blade.php, student/results/show.blade.php, guardian/students/
   result-details.blade.php), so one unscoped mobile rule set keeps the
   compact font sizing and responsive behavior consistent everywhere
   instead of duplicating it per panel. Desktop/tablet are untouched since
   this only fires below 575.98px. */
@media (max-width: 575.98px) {
    .question-item-text,
    /* Wins over the pre-existing, non-mobile-scoped Student Panel rule
       (.student-content ... .question-item-text { font-size: 0.94rem })
       so Student's mobile size matches every other panel. */
    .student-content .question-admin-item:not(.passage-group-item) .question-item-text {
        font-size: 0.92rem;
    }

    .option-text {
        font-size: 0.85rem;
    }

    /* Teacher's displayed remark text (the read-only box shown after a
       remark is saved — not the remark input, which is left alone). */
    .remark-display-text {
        font-size: 0.9rem;
    }

    /* Passage/Summary question header: the "Passage/Summary Question"
       badge plus the marks badge don't fit on one line at phone widths —
       let them wrap instead of overflowing the card. */
    .question-item-meta {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    /* Summary content is rich, arbitrary CKEditor HTML — a wide table, an
       image with an inline width= attribute (which beats a plain CSS
       max-width rule), or a long unbroken word/URL can all push wider than
       the screen. Rather than chase each cause individually, make the
       passage/summary box itself the thing that scrolls: anything inside
       that's too wide scrolls within its own card instead of stretching
       the page. Text also wraps instead of overflowing. */
    .passage-preview {
        padding-left: 14px;
        padding-right: 14px;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .passage-preview img {
        max-width: 100% !important;
        height: auto !important;
    }

    .passage-preview table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Belt-and-suspenders: the card and the question list around it never
       grow past the viewport even if something inside briefly measures
       wider before wrapping/scrolling kicks in. */
    .question-admin-item,
    .question-list {
        max-width: 100%;
        overflow-x: hidden;
    }
}

.correct-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #d1fae5;
    color: #067647;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

/* Question explanation */
.question-explanation {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 20px 18px;
    padding: 14px 16px;
    background: #fffaeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
}

.explanation-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #fef3c7;
    color: #b54708;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
}

.question-explanation strong {
    display: block;
    color: #92400e;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.question-explanation p {
    color: #78350f;
    font-size: 0.9rem;
    line-height: 1.55;
}

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.status-badge.status-published {
    background: #ecfdf5;
    color: #067647;
    border: 1px solid #a7f3d0;
}

form .status-badge.status-published {
    cursor: pointer;
    transition: all 0.18s ease;
}

form .status-badge.status-published:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    transform: translateY(-1px);
}

.status-badge.status-closed {
    background: #fff0f3;
    color: var(--danger);
    border: 1px solid #fecdd3;
}

/* Draft status button */
.status-draft-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    background: #fffaeb;
    color: #b54708;
    border: 1px solid #fde68a;
    cursor: pointer;
    transition: all 0.18s ease;
}

.status-draft-btn:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
    transform: translateY(-1px);
}

/* Upcoming status badge */
.status-badge.status-upcoming {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Publish lock hint */
.publish-lock-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f1f3f7;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Publish confirm icon */
.publish-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: #ecfdf5;
    color: #067647;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

/* Toggle confirm icon */
.toggle-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: #eef4ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

/* Exam published lock */
.exam-published-lock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.85rem;
    font-weight: 800;
    backdrop-filter: blur(6px);
}

/* Question marks badge variants */
.question-marks-badge.correct {
    background: #ecfdf5;
    color: #067647;
}

.question-marks-badge.wrong {
    background: #fff0f3;
    color: var(--danger);
}

.question-marks-badge.unanswered {
    background: #f1f3f7;
    color: var(--muted);
}

.question-marks-badge.group-total {
    background: #fff;
    color: var(--accent);
}

/* Empty state icon */
.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border-radius: 16px;
    background: #eef4ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.8rem;
}

/* ============================================
   Student Exam UI Updates
   ============================================ */

/* Available exams - 2 cards per row */
.student-exam-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

/* Info card grid - 3 cards per row */
.student-info-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.student-info-card-grid.compact {
    margin-top: 0;
}

.info-card {
    position: relative;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 12px;
    padding: 16px 18px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.05);
    overflow: hidden;
}

.info-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.info-card.color-blue::before { background: #1d6fd8; }
.info-card.color-green::before { background: #10b981; }
.info-card.color-orange::before { background: #f59e0b; }
.info-card.color-purple::before { background: #8b5cf6; }
.info-card.color-teal::before { background: #14b8a6; }
.info-card.color-red::before { background: #ef4444; }

.info-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1rem;
    margin-bottom: 10px;
}

.info-card.color-blue .info-card-icon { background: #eff6ff; color: #1d6fd8; }
.info-card.color-green .info-card-icon { background: #ecfdf5; color: #10b981; }
.info-card.color-orange .info-card-icon { background: #fffbeb; color: #f59e0b; }
.info-card.color-purple .info-card-icon { background: #f5f3ff; color: #8b5cf6; }
.info-card.color-teal .info-card-icon { background: #f0fdfa; color: #14b8a6; }
.info-card.color-red .info-card-icon { background: #fef2f2; color: #ef4444; }

.info-card span {
    display: block;
    color: #7a8496;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.info-card strong {
    display: block;
    color: #172033;
    font-size: 1.3rem;
    font-weight: 850;
    line-height: 1.2;
}

.info-card strong small {
    font-size: 0.8rem;
    font-weight: 700;
    color: #7a8496;
}

/* Begin exam confirmation icon */
.begin-exam-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: #eef4ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    .student-exam-grid-2 {
        grid-template-columns: 1fr;
    }

    .student-info-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .student-info-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .info-card {
        min-height: 88px;
        padding: 12px 14px;
    }

    .info-card-icon {
        width: 32px;
        height: 32px;
        margin-bottom: 8px;
    }

    .info-card span {
        font-size: 0.68rem;
    }

    .info-card strong {
        font-size: 1.15rem;
    }
}

/* ============================================
   Student Profile Summary
   ============================================ */
.student-profile-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(23, 32, 51, 0.06);
}

.student-profile-avatar-lg {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1d6fd8, #18a999);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(29, 111, 216, 0.25);
}

.student-profile-summary h3 {
    margin: 0;
    color: #172033;
    font-size: 1.2rem;
    font-weight: 800;
}

.student-profile-summary p {
    color: #7a8496;
    font-size: 0.9rem;
}

/* ============================================
   Student Dashboard Charts
   ============================================ */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.chart-card {
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(23, 32, 51, 0.07);
    padding: 20px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-card-header {
    margin-bottom: 16px;
}

.chart-card-header h3 {
    margin: 0;
    color: #172033;
    font-size: 1.05rem;
    font-weight: 800;
}

.chart-card-subtitle {
    display: block;
    margin-top: 4px;
    color: #7a8496;
    font-size: 0.82rem;
}

.chart-container {
    flex: 1;
    min-height: 240px;
    position: relative;
}

.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 240px;
    color: #7a8496;
    text-align: center;
}

.chart-empty i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: #cbd5e1;
}

.chart-empty p {
    margin: 0;
    font-size: 0.9rem;
}

/* ============================================
   Modern Pagination
   ============================================ */
.modern-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.pagination-info {
    color: var(--muted);
    font-size: 0.85rem;
}

.pagination-info strong {
    color: var(--ink);
    font-weight: 800;
}

.pagination-list {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.pagination-list .page-item {
    margin: 0;
}

.pagination-list .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.18s ease;
    gap: 6px;
}

.pagination-list .page-link:hover {
    background: #eef4ff;
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-list .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(35, 86, 216, 0.25);
}

.pagination-list .page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8fafc;
}

.pagination-list .page-link.dots {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: default;
}

/* ============================================
   Heading Size Reductions
   ============================================ */
.admin-topbar h1 {
    font-size: clamp(1.2rem, 1.8vw, 1.6rem);
}

.dashboard-hero h2 {
    font-size: clamp(1.35rem, 2.5vw, 1.9rem);
}

.student-hero h1 {
    font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.login-panel h1 {
    font-size: 1.55rem;
}

.exam-hero-title {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.student-profile-name {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.panel-header h2 {
    font-size: 1.15rem;
}

.student-section-header h2 {
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
}

/* ============================================
   Student Profile Page (Admin / Branch)
   ============================================ */

/* Profile hero */
.student-profile-hero {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #173b9d 0%, #1d5fd8 45%, #0f9f8f 100%);
    box-shadow: 0 18px 45px rgba(23, 59, 157, 0.22);
}

.student-profile-top-actions {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-student-back {
    min-height: 40px;
    padding: 0 16px;
    font-weight: 800;
}

.student-profile-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 85% 20%, rgba(255, 255, 255, 0.14), transparent 22rem),
        radial-gradient(circle at 15% 90%, rgba(255, 255, 255, 0.08), transparent 18rem);
    pointer-events: none;
}

.student-profile-content {
    position: relative;
    z-index: 1;
    padding: 28px 30px;
    color: #fff;
}

.student-profile-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.student-profile-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.student-profile-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.student-profile-chip i {
    font-size: 0.9rem;
    opacity: 0.85;
}

.student-profile-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-student-action {
    min-height: 40px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.88rem;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-student-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.student-profile-main {
    display: flex;
    align-items: center;
    gap: 20px;
}

.student-profile-avatar {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 2rem;
    font-weight: 900;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.student-profile-info {
    min-width: 0;
}

.student-profile-name {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 850;
    letter-spacing: -0.01em;
    line-height: 1.2;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.student-profile-subtitle {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Student stats grid */
.student-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.student-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(20, 32, 54, 0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.student-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(20, 32, 54, 0.1);
}

.student-stat-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

.student-stat-icon.primary {
    background: #eef4ff;
    color: var(--primary);
}

.student-stat-icon.accent {
    background: #e6f7f4;
    color: var(--accent);
}

.student-stat-icon.success {
    background: #ecfdf5;
    color: #067647;
}

.student-stat-icon.info {
    background: #eff8ff;
    color: #175cd3;
}

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

.student-stat-body span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.student-stat-body strong {
    display: block;
    margin-top: 4px;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Student details panel */
.student-details-panel {
    margin-bottom: 20px;
}

.student-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.student-detail-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fbfcfe;
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.student-detail-item:hover {
    border-color: #c9d4e8;
    box-shadow: 0 4px 14px rgba(20, 32, 54, 0.05);
}

.student-detail-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #eef4ff;
    color: var(--primary);
    font-size: 0.95rem;
}

.student-detail-item dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.student-detail-item dd {
    margin: 3px 0 0;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--ink);
}

.student-profile-footer {
    margin-top: 4px;
}

.mobile-table-toggle-cell,
.mobile-table-detail-row {
    display: none;
}

/* Responsive */
@media (max-width: 767.98px) {
    .student-profile-content {
        padding: 22px 20px;
    }

    .student-profile-top {
        flex-direction: column;
        align-items: stretch;
    }

    .student-profile-actions {
        width: 100%;
    }

    .btn-student-action {
        flex: 1 1 100%;
        justify-content: center;
    }

    .student-profile-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .student-profile-avatar {
        flex: 0 0 60px;
        width: 60px;
        height: 60px;
        font-size: 1.6rem;
        border-radius: 14px;
    }

    .student-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }

    .student-stat-card {
        padding: 14px;
        gap: 10px;
    }

    .student-stat-icon {
        flex: 0 0 38px;
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    /* Scoped to .student-content (the Student Panel's own <main>) so this
       never touches the Admin/Branch "view student" page, which reuses the
       same .student-details-grid/.student-detail-item markup. */
    .student-content .student-details-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

/* Responsive */
@media (max-width: 767.98px) {
    .exam-hero-content {
        padding: 22px 20px;
        gap: 12px;
    }

    .exam-hero-top {
        order: 2;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 0;
    }

    .exam-hero-title {
        order: 1;
        margin: 0;
    }

    .exam-hero-actions {
        width: 100%;
        justify-content: stretch;
    }

    .btn-exam-action {
        flex: 1 1 100%;
        justify-content: center;
    }

    .exam-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }

    .exam-stat-card {
        padding: 14px;
        gap: 10px;
    }

    .exam-stat-icon {
        flex: 0 0 38px;
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .exam-stat-body strong {
        font-size: 1.25rem;
    }

    .exam-details-grid {
        grid-template-columns: 1fr;
    }

    .question-item-header {
        flex-wrap: wrap;
        padding: 16px;
    }

    .question-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .option-preview {
        padding: 14px 16px;
    }

    .question-explanation {
        margin: 0 16px 16px;
        padding: 12px 14px;
    }
}

/* ============================================
   Phone-first polish across panels
   ============================================ */
@media (max-width: 575.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .mobile-hide {
        display: none !important;
    }

    .admin-shell {
        min-height: 100dvh;
        height: auto;
        overflow: visible;
    }

    .admin-main {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .admin-topbar {
        min-height: 64px;
        padding: 8px 10px;
        gap: 8px;
        align-items: center;
    }

    .admin-topbar > div:not(.topbar-actions) {
        min-width: 0;
    }

    body:not(.super-admin-panel) .admin-topbar > div:not(.topbar-actions):not(:first-child) {
        flex: 1 1 0;
        max-width: calc(100% - 168px);
    }

    .admin-topbar h1 {
        font-size: clamp(0.98rem, 5.2vw, 1.2rem);
        line-height: 1.15;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .page-kicker {
        font-size: 0.6rem;
        line-height: 1.1;
    }

    .btn-icon {
        flex: 0 0 34px;
        width: 34px;
        height: 34px;
        min-height: 34px;
        border-radius: 9px;
        font-size: 0.95rem;
    }

    .topbar-actions {
        max-width: 44%;
        gap: 8px;
    }

    body:not(.super-admin-panel) .topbar-actions {
        flex: 0 0 auto;
        max-width: 156px;
    }

    body:not(.super-admin-panel) .admin-user {
        gap: 6px;
        max-width: 156px;
    }

    body:not(.super-admin-panel) .admin-user .avatar {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        font-size: 0.86rem;
    }

    body:not(.super-admin-panel) .admin-user-copy {
        display: block;
        line-height: 1.1;
    }

    body:not(.super-admin-panel) .admin-user strong,
    body:not(.super-admin-panel) .admin-user span {
        max-width: 118px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body:not(.super-admin-panel) .admin-user strong {
        display: block;
        font-size: 0.74rem;
        line-height: 1.12;
    }

    body:not(.super-admin-panel) .admin-user span {
        font-size: 0.61rem;
        line-height: 1.12;
    }

    .current-branch-pill {
        min-height: 36px;
        max-width: 100%;
        padding: 0 9px;
        border-radius: 10px;
        font-size: 0.74rem;
    }

    .admin-content,
    .student-content {
        padding: 14px 12px 24px;
    }

    .dashboard-hero,
    .content-panel,
    .student-section,
    .chart-card,
    .student-profile-summary,
    .exam-details-panel,
    .student-details-panel {
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 10px 24px rgba(20, 32, 54, 0.07);
    }

    /* A flex item's default min-width is its content's intrinsic width,
       not 0 — so a long name or email in the untitled wrapper div next to
       the avatar could otherwise force this row wider than the screen and
       put the whole page into horizontal scroll. */
    .student-profile-summary {
        gap: 12px;
    }

    .student-profile-summary > div:last-child {
        min-width: 0;
        flex: 1 1 auto;
    }

    .student-profile-summary h3,
    .student-profile-summary p {
        overflow-wrap: anywhere;
    }

    .dashboard-hero {
        align-items: flex-start;
        margin-bottom: 14px;
        gap: 14px;
    }

    .dashboard-hero span,
    .student-hero span,
    .student-section-header span {
        font-size: 0.68rem;
    }

    .dashboard-hero h2,
    .student-hero h1,
    .exam-hero-title,
    .student-profile-name {
        font-size: clamp(1.25rem, 7vw, 1.65rem);
        line-height: 1.16;
    }

    .dashboard-hero p,
    .student-hero p,
    .exam-hero-desc,
    .panel-header p {
        font-size: 0.86rem;
        line-height: 1.45;
    }

    .metric-card {
        min-height: 92px;
        padding: 14px;
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        align-items: center;
        align-content: center;
        gap: 10px;
        border-radius: 12px;
    }

    .metric-card i {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.95rem;
    }

    .metric-card span {
        font-size: 0.76rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .metric-card strong {
        display: block;
        margin-top: 3px;
        font-size: 1.15rem;
        line-height: 1.1;
    }

    .metric-card.muted strong {
        font-size: 0.9rem;
    }

    .dashboard-metric-row {
        margin-bottom: 1rem !important;
    }

    .dashboard-metric-card {
        min-height: 82px;
        padding: 12px;
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 10px;
    }

    .dashboard-metric-card i {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        font-size: 1rem;
    }

    .dashboard-metric-card span {
        margin-bottom: 3px;
        font-size: 0.7rem;
    }

    .dashboard-metric-card strong {
        font-size: 1.18rem;
    }

    .dashboard-metric-card.muted strong {
        font-size: 0.88rem;
    }

    .row.g-3,
    .row.g-4 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }

    .panel-header,
    .student-section-header,
    .exam-hero-top,
    .student-profile-top {
        margin-bottom: 14px;
        gap: 10px;
    }

    .panel-header h2,
    .student-section-header h2,
    .chart-card-header h3,
    .student-profile-summary h3 {
        font-size: 1.05rem;
        line-height: 1.2;
    }

    .filter-bar,
    .filter-bar.compact-filter-bar {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 14px;
    }

    .filter-bar.logs-filter-bar,
    .filter-bar.filter-bar-oneline {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 14px;
    }

    .form-label {
        margin-bottom: 5px;
        font-size: 0.82rem;
        font-weight: 800;
    }

    .form-control,
    .form-select,
    .admin-form .form-control,
    .admin-form .form-select,
    .login-form .form-control {
        min-height: 44px;
        border-radius: 10px;
        font-size: 0.92rem;
    }

    textarea.form-control {
        min-height: 72px;
    }

    .admin-form .row {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }

    .btn {
        min-height: 40px;
        border-radius: 10px;
        padding: 0.45rem 0.75rem;
        font-size: 0.88rem;
    }

    .btn-sm {
        min-height: 34px;
        padding: 0.32rem 0.6rem;
        font-size: 0.8rem;
    }

    body.login-body .login-form .form-control {
        min-height: 48px;
    }

    body.login-body .login-submit,
    body.login-body #studentContinueButton,
    body.login-body #sendOtpButton,
    body.login-body #verifyOtpButton,
    body.login-body #createPasswordButton {
        min-height: 50px;
    }

    .action-group {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .feedback-alert,
    .alert {
        padding: 11px 12px;
        border-radius: 10px;
        font-size: 0.84rem;
    }

    .toast-container {
        inset: 8px 8px auto 8px !important;
        padding: 0 !important;
    }

    .admin-toast {
        width: 100%;
        border-radius: 12px;
    }

    .admin-toast .toast-body {
        align-items: flex-start;
        font-size: 0.86rem;
        line-height: 1.35;
    }

    .modal-dialog {
        width: calc(100% - 24px);
        margin: 12px auto;
    }

    .confirm-modal {
        border-radius: 14px;
    }

    .confirm-modal .modal-header,
    .confirm-modal .modal-body,
    .confirm-modal .modal-footer {
        padding: 14px 16px;
    }

    .confirm-modal .modal-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .confirm-modal .modal-footer > * {
        width: 100%;
        margin: 0;
    }

    .logout-modal .modal-body {
        gap: 12px;
    }

    .logout-confirm-icon,
    .publish-confirm-icon,
    .toggle-confirm-icon,
    .begin-exam-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 1.15rem;
    }

    .mobile-sidebar {
        width: min(82vw, 300px) !important;
        max-width: 82vw;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mobile-sidebar .brand {
        min-height: 78px;
        padding: 18px 52px 16px 16px;
    }

    .super-admin-panel .admin-topbar {
        min-height: 64px;
        padding: 8px 10px;
        gap: 8px;
    }

    .super-admin-panel .admin-topbar h1 {
        font-size: clamp(1rem, 5.4vw, 1.22rem);
        max-width: 100%;
    }

    .super-admin-panel .page-kicker {
        font-size: 0.62rem;
    }

    .super-admin-panel .btn-icon {
        flex-basis: 42px;
        width: 42px;
        height: 42px;
        min-height: 42px;
        font-size: 1.12rem;
    }

    .super-admin-panel .topbar-actions {
        max-width: 40%;
    }

    .super-admin-panel .current-branch-pill {
        min-height: 34px;
        padding: 0 8px;
        gap: 5px;
        font-size: 0.68rem;
    }

    .super-admin-panel .current-branch-pill i {
        flex: 0 0 auto;
        font-size: 0.84rem;
    }

    .super-admin-panel .mobile-sidebar {
        width: min(78vw, 280px) !important;
        max-width: 78vw;
    }

    .super-admin-panel .mobile-sidebar .brand {
        min-height: 70px;
        padding: 14px 48px 12px 14px;
        gap: 9px;
    }

    .super-admin-panel .mobile-sidebar .brand-mark {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.9rem;
    }

    .super-admin-panel .mobile-sidebar .brand-copy strong {
        font-size: 1.05rem;
    }

    .super-admin-panel .mobile-sidebar .brand-copy span {
        font-size: 0.82rem;
    }

    .super-admin-panel .mobile-sidebar-close {
        top: 15px;
        right: 10px;
        width: 32px;
        height: 32px;
        border-radius: 9px;
        font-size: 0.98rem;
    }

    .super-admin-panel .mobile-sidebar .sidebar-nav {
        padding: 0 9px 10px;
        gap: 3px;
    }

    .super-admin-panel .mobile-sidebar .sidebar-nav a,
    .super-admin-panel .mobile-sidebar .sidebar-nav .disabled {
        min-height: 46px;
        padding: 0 10px;
        gap: 10px;
        border-radius: 9px;
        font-size: 1.08rem;
        overflow: hidden;
    }

    .super-admin-panel .mobile-sidebar .sidebar-nav i,
    .super-admin-panel .mobile-sidebar .sidebar-logout i {
        flex: 0 0 23px;
        width: 23px;
        font-size: 1.18rem;
    }

    .super-admin-panel .mobile-sidebar .sidebar-nav span,
    .super-admin-panel .mobile-sidebar .sidebar-logout span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .super-admin-panel .mobile-sidebar .sidebar-logout {
        padding: 10px;
    }

    .super-admin-panel .mobile-sidebar .sidebar-logout .btn {
        min-height: 46px;
        gap: 10px;
        font-size: 1.08rem;
        border-radius: 9px;
    }

    .mobile-sidebar .brand-mark {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .mobile-sidebar-close {
        top: 18px;
        right: 12px;
        width: 36px;
        height: 36px;
    }

    .sidebar-nav {
        padding: 0 10px 12px;
        gap: 4px;
    }

    .sidebar-nav a,
    .sidebar-nav .disabled {
        min-height: 46px;
        padding: 0 12px;
        border-radius: 10px;
        font-size: 1.05rem;
        gap: 11px;
    }

    .mobile-sidebar .sidebar-nav i,
    .mobile-sidebar .sidebar-logout i {
        flex: 0 0 23px;
        width: 23px;
        font-size: 1.16rem;
    }

    .mobile-sidebar .sidebar-logout .btn {
        min-height: 46px;
        gap: 11px;
        font-size: 1.05rem;
    }

    .sidebar-logout {
        padding: 14px 12px;
    }

    .student-drawer,
    .exam-drawer {
        width: min(94vw, 420px) !important;
        max-width: 94vw;
        border-left: 1px solid var(--line);
    }

    .student-drawer-header {
        min-height: 68px;
        padding: 14px 16px;
    }

    .student-drawer-header h2 {
        font-size: 1.08rem;
    }

    .student-drawer .offcanvas-body,
    .exam-drawer .offcanvas-body {
        padding: 16px;
        overflow-y: auto;
    }

    .student-drawer .admin-form > .d-flex:last-child,
    .exam-drawer .admin-form > .d-flex:last-child {
        margin-left: -16px;
        margin-right: -16px;
        padding: 12px 16px 14px;
        gap: 8px;
    }

    .exam-form-sections {
        gap: 12px;
        padding-bottom: 16px;
    }

    .exam-form-section,
    .question-card {
        border-radius: 12px;
        padding: 14px;
    }

    .exam-form-section-title {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .question-card {
        padding: 0;
    }

    .question-card-header {
        padding: 12px 14px;
    }

    .question-card-body {
        padding: 14px;
    }

    .option-row {
        gap: 7px;
        padding: 8px;
    }

    .table-responsive {
        overflow: visible;
    }

    .admin-table.mobile-collapsible-table,
    .admin-table[data-mobile-enhanced="true"] {
        display: block;
        min-width: 0;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .admin-table[data-mobile-enhanced="true"] thead {
        display: none;
    }

    .admin-table[data-mobile-enhanced="true"] tbody {
        display: grid;
        gap: 0;
    }

    .admin-table[data-mobile-enhanced="true"] tbody tr:not(.mobile-table-detail-row) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "primary toggle"
            "secondary toggle";
        align-items: center;
        gap: 4px 10px;
        margin-top: 10px;
        padding: 12px;
        background: #fff;
        border: 1px solid rgba(23, 32, 51, 0.08);
        border-radius: 12px;
        box-shadow: 0 8px 20px rgba(20, 32, 54, 0.055);
    }

    .admin-table[data-mobile-enhanced="true"] td {
        display: none;
        padding: 0;
        border: 0;
    }

    .admin-table[data-mobile-enhanced="true"] .mobile-primary-cell {
        grid-area: primary;
        display: block;
        min-width: 0;
        font-weight: 850;
        color: var(--ink);
        overflow-wrap: anywhere;
    }

    .admin-table[data-mobile-enhanced="true"] .mobile-secondary-cell {
        grid-area: secondary;
        display: block;
        color: var(--muted);
        font-size: 0.82rem;
    }

    .admin-table[data-mobile-enhanced="true"] .mobile-table-toggle-cell {
        grid-area: toggle;
        display: block;
        justify-self: end;
    }

    .mobile-table-toggle {
        min-height: 34px;
        gap: 5px;
    }

    .mobile-table-detail-row {
        display: block;
        margin-top: -2px;
    }

    .mobile-table-detail-row > td {
        display: block !important;
        padding: 0 !important;
    }

    .mobile-table-detail-panel {
        max-height: 0;
        margin: 0 8px;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-4px);
        transition: max-height 0.24s ease, opacity 0.18s ease, transform 0.18s ease, padding 0.18s ease;
    }

    .mobile-table-detail-row.is-open .mobile-table-detail-panel {
        max-height: 1400px;
        padding: 10px 10px 12px;
        opacity: 1;
        transform: translateY(0);
        background: #f8fafc;
        border: 1px solid rgba(23, 32, 51, 0.08);
        border-top: 0;
        border-radius: 0 0 12px 12px;
    }

    .mobile-table-detail-item {
        min-height: 0;
        display: grid;
        gap: 3px;
        padding: 8px 0;
        border-bottom: 1px solid rgba(23, 32, 51, 0.07);
    }

    .mobile-table-detail-item:last-child {
        border-bottom: 0;
    }

    .mobile-table-detail-item > span {
        color: #7a8496;
        font-size: 0.68rem;
        font-weight: 850;
        text-transform: uppercase;
    }

    .mobile-table-detail-item > div {
        min-width: 0;
        color: var(--ink);
        font-size: 0.86rem;
        overflow-wrap: anywhere;
    }

    .mobile-table-actions > div {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        flex-wrap: wrap;
    }

    .student-main {
        width: min(100% - 20px, 1180px);
        padding: 14px 0 28px;
    }

    .student-hero {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        padding: 18px;
        border-radius: 14px;
    }

    .student-hero-avatar {
        flex: 0 0 52px;
        width: 52px;
        height: 52px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.18);
        border: 2px solid rgba(255, 255, 255, 0.35);
        color: #fff;
        font-size: 1.4rem;
        font-weight: 800;
        line-height: 1;
        text-transform: uppercase;
    }

    .student-hero-copy {
        flex: 1 1 auto;
        min-width: 0;
    }

    .student-hero-copy h1 {
        margin: 0;
        font-size: 1.1rem;
        line-height: 1.3;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .student-hero-copy p {
        margin: 5px 0 0;
        font-size: 0.78rem;
        line-height: 1.4;
        color: rgba(255, 255, 255, 0.84);
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .student-hero-copy span {
        margin-bottom: 2px;
        font-size: 0.62rem;
    }

    .student-hero > .d-flex {
        flex: 1 1 100%;
        justify-content: stretch;
        margin-top: 4px;
    }

    .student-hero > .d-flex .btn {
        width: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 42px;
        padding: 8px 14px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    .student-stat-grid,
    .student-stats-grid,
    .exam-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin: 14px 0;
    }

    .student-stat,
    .student-stat-card,
    .exam-stat-card,
    .info-card {
        min-height: 82px;
        padding: 12px;
        border-radius: 12px;
        box-shadow: 0 8px 20px rgba(23, 32, 51, 0.055);
    }

    .student-stat strong,
    .student-stat-body strong,
    .exam-stat-body strong,
    .info-card strong {
        font-size: 1.05rem;
    }

    .student-stat-icon,
    .exam-stat-icon,
    .info-card-icon {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.92rem;
    }

    .exam-card-grid,
    .student-exam-grid-2,
    .dashboard-charts-grid,
    .exam-details-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Compact icon+label+value tiles read better as a 2-up grid than one
       long column on phones — halves the scroll length of the Exam
       Instructions and Profile pages without cramping any of them. */
    .student-info-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    /* Scoped to .student-content — see the matching 767.98px rule above —
       so the Admin/Branch "view student" page (which reuses this same
       .student-details-grid/.student-detail-item markup) is unaffected. */
    .student-content .student-details-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .student-content .student-detail-item {
        gap: 9px;
        padding: 11px 12px;
        border-radius: 10px;
    }

    .student-content .student-detail-icon {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
        font-size: 0.84rem;
    }

    .student-content .student-detail-item dt {
        font-size: 0.66rem;
    }

    .student-content .student-detail-item dd {
        margin-top: 2px;
        font-size: 0.84rem;
        overflow-wrap: anywhere;
    }

    .exam-card {
        padding: 16px;
        border-radius: 12px;
    }

    .exam-card h3 {
        margin: 10px 0 6px;
        font-size: 1.05rem;
    }

    .exam-card p {
        font-size: 0.86rem;
        line-height: 1.45;
    }

    .exam-card dl {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 10px 0 14px;
    }

    .exam-card dd,
    .student-detail-item dd,
    .exam-detail-item dd {
        font-size: 0.88rem;
    }

    .exam-hero-content,
    .student-profile-content {
        padding: 18px;
    }

    .student-profile-top-actions + .exam-hero {
        margin-bottom: 10px;
    }

    .exam-hero {
        margin-bottom: 14px;
        overflow: hidden;
        border-radius: 14px;
        background: linear-gradient(135deg, #173b9d 0%, #1d5fd8 45%, #0f9f8f 100%);
        box-shadow: 0 12px 28px rgba(23, 59, 157, 0.18);
    }

    .exam-hero-overlay {
        display: block;
    }

    .student-profile-hero {
        border-radius: 14px;
        margin-bottom: 14px;
    }

    .exam-hero-actions,
    .student-profile-actions {
        width: 100%;
    }

    .exam-hero-content {
        gap: 13px;
        color: #fff;
    }

    .exam-hero-top {
        order: 2;
        gap: 12px;
        margin-bottom: 0;
    }

    .exam-hero-badges {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .exam-status-badge,
    .exam-meta-chip {
        width: 100%;
        justify-content: center;
        min-height: 42px;
        padding: 8px 9px;
        border-radius: 10px;
        font-size: 0.8rem;
        line-height: 1.2;
        text-transform: none;
        letter-spacing: 0;
        color: rgba(255, 255, 255, 0.94);
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(6px);
    }

    .exam-status-badge {
        grid-column: 1 / -1;
        justify-self: start;
        width: auto;
        min-height: 30px;
        padding: 6px 11px;
        border-radius: 999px;
        font-size: 0.74rem;
        font-weight: 850;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .exam-status-badge i,
    .exam-meta-chip i {
        flex: 0 0 auto;
        font-size: 0.92rem;
        color: rgba(255, 255, 255, 0.92);
        opacity: 1;
    }

    .exam-status-badge.status-draft {
        color: #fff7ed;
        background: rgba(245, 158, 11, 0.28);
        border-color: rgba(251, 191, 36, 0.45);
    }

    .exam-status-badge.status-published {
        color: #ecfdf5;
        background: rgba(16, 185, 129, 0.28);
        border-color: rgba(52, 211, 153, 0.45);
    }

    .exam-status-badge.status-closed {
        color: #fff1f2;
        background: rgba(239, 68, 68, 0.28);
        border-color: rgba(248, 113, 113, 0.45);
    }

    .exam-status-badge.status-draft i {
        color: #fde68a;
    }

    .exam-status-badge.status-published i {
        color: #a7f3d0;
    }

    .exam-status-badge.status-closed i {
        color: #fecaca;
    }

    .exam-hero-title {
        order: 1;
        margin: 0;
        color: #fff;
        font-size: clamp(1.28rem, 6.2vw, 1.55rem);
        line-height: 1.16;
        text-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
        overflow-wrap: anywhere;
    }

    .exam-hero-desc {
        order: 3;
        margin: -2px 0 0;
        color: rgba(255, 255, 255, 0.84);
    }

    .exam-hero-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .exam-hero-actions form {
        width: 100%;
    }

    .exam-hero-actions form .btn-exam-action,
    .exam-hero-actions > .btn-exam-action {
        width: 100%;
        justify-content: center;
    }

    .exam-hero-actions > .btn-exam-action:first-child {
        grid-column: 1 / -1;
    }

    .exam-hero-actions .btn-light,
    .exam-hero-actions .btn-outline-light {
        color: #173b9d;
        background: rgba(255, 255, 255, 0.94);
        border-color: rgba(255, 255, 255, 0.7);
    }

    .exam-hero-actions .btn-success {
        color: #fff;
        background: #059669;
        border-color: #059669;
    }

    .btn-exam-action,
    .btn-student-action {
        flex: 1 1 100%;
        min-height: 38px;
        padding: 0 12px;
        font-size: 0.82rem;
    }

    .student-profile-main {
        gap: 12px;
    }

    .branch-student-show .student-profile-hero {
        margin-bottom: 12px;
        background: linear-gradient(135deg, #173b6d 0%, #1d6fd8 54%, #0f9f8f 100%);
        box-shadow: 0 12px 28px rgba(23, 32, 51, 0.14);
    }

    .branch-student-show .student-profile-top-actions {
        margin-bottom: 10px;
    }

    .branch-student-show .btn-student-back {
        min-height: 38px;
        padding: 0 13px;
        font-size: 0.86rem;
    }

    .branch-student-show .student-profile-overlay {
        display: none;
    }

    .branch-student-show .student-profile-content {
        padding: 16px;
        display: flex;
        flex-direction: column;
    }

    .branch-student-show .student-profile-top {
        display: contents;
    }

    .branch-student-show .student-profile-badges {
        order: 2;
        gap: 6px;
        margin-top: 12px;
    }

    .branch-student-show .student-profile-chip {
        max-width: 100%;
        padding: 5px 9px;
        border-radius: 999px;
        font-size: 0.74rem;
    }

    .branch-student-show .student-profile-chip i {
        font-size: 0.82rem;
    }

    .branch-student-show .student-profile-main {
        order: 1;
        display: grid;
        grid-template-columns: 50px minmax(0, 1fr);
        align-items: center;
        gap: 11px;
    }

    .student-profile-avatar,
    .student-profile-avatar-lg {
        flex-basis: 52px;
        width: 52px;
        height: 52px;
        border-radius: 14px;
        font-size: 1.35rem;
    }

    .branch-student-show .student-profile-avatar {
        width: 50px;
        height: 50px;
        border-radius: 13px;
        font-size: 1.28rem;
    }

    .branch-student-show .student-profile-name {
        font-size: clamp(1.15rem, 6vw, 1.45rem);
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .branch-student-show .student-profile-subtitle {
        margin-top: 5px;
        font-size: 0.78rem;
    }

    .branch-student-show .student-profile-actions {
        order: 3;
        width: 100%;
        margin-top: 12px;
    }

    .branch-student-show .btn-student-action {
        width: 100%;
        min-height: 38px;
        justify-content: center;
        font-size: 0.86rem;
    }

    .branch-student-show .student-stats-grid {
        grid-template-columns: 1fr;
        gap: 9px;
        margin: 0 0 12px;
    }

    .branch-student-show .student-stat-card {
        min-height: 68px;
        padding: 11px 12px;
        gap: 10px;
        border-radius: 11px;
    }

    .branch-student-show .student-stat-icon {
        flex: 0 0 34px;
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.92rem;
    }

    .branch-student-show .student-stat-body span {
        font-size: 0.68rem;
    }

    .branch-student-show .student-stat-body strong {
        margin-top: 2px;
        font-size: 0.92rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .branch-student-show .student-details-panel {
        padding: 14px;
    }

    .branch-student-show .student-details-panel .panel-header {
        margin-bottom: 10px;
    }

    .branch-student-show .student-details-panel .panel-header p {
        display: none;
    }

    .branch-student-show .student-details-panel h2 {
        font-size: 1rem;
    }

    .branch-student-show .student-details-grid {
        gap: 8px;
    }

    .student-detail-item,
    .exam-detail-item {
        padding: 12px;
        border-radius: 10px;
    }

    .branch-student-show .student-detail-item {
        padding: 10px 11px;
        gap: 9px;
        align-items: center;
    }

    .branch-student-show .student-detail-icon {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        font-size: 0.86rem;
    }

    .branch-student-show .student-detail-item dt {
        font-size: 0.66rem;
    }

    .branch-student-show .student-detail-item dd {
        margin-top: 2px;
        font-size: 0.86rem;
        overflow-wrap: anywhere;
    }

    .branch-student-show .student-profile-footer {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px !important;
        margin-top: 12px;
    }

    .branch-student-show .student-profile-footer form,
    .branch-student-show .student-profile-footer .btn {
        width: 100%;
    }

    .result-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .result-card {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 88px;
        padding: 12px 14px;
        border-radius: 12px;
    }

    .result-card-left {
        gap: 8px;
    }

    .result-card strong {
        align-self: center;
    }

    .result-card-icon {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
    }

    .exam-history-item,
    .performance-item {
        padding: 12px;
        gap: 10px;
        border-radius: 12px;
    }

    .performance-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .chart-card {
        min-height: 250px;
    }

    .chart-container,
    .chart-empty {
        min-height: 190px;
    }

    .exam-runner-shell {
        min-height: calc(100dvh - 86px);
    }

    .exam-runner-header {
        padding: 14px;
        border-radius: 14px;
        gap: 10px;
    }

    .exam-runner-header h1 {
        font-size: 1.15rem;
    }

    .exam-timer {
        min-width: 0;
        width: 100%;
        min-height: 40px;
        padding: 8px 10px;
    }

    .exam-question-panel {
        border-radius: 14px;
        padding: 16px;
    }

    .exam-question-text {
        margin-bottom: 16px;
        font-size: calc(1rem * var(--exam-font-scale, 1));
        line-height: 1.45;
    }

    /* Same specificity fix as the desktop rule above — keeps this breakpoint's
       font-size winning over .passage-preview's fixed 0.94rem. */
    .exam-question-text.passage-preview {
        font-size: calc(1rem * var(--exam-font-scale, 1));
        line-height: 1.45;
    }

    .exam-toolbar {
        padding: 12px;
        gap: 12px;
    }

    .exam-nav-wrap {
        flex-basis: 100%;
    }

    .exam-nav-btn {
        width: 34px;
        height: 34px;
    }

    .exam-font-control {
        width: 100%;
        justify-content: flex-end;
    }

    .exam-options {
        gap: 10px;
    }

    .exam-option {
        min-height: 48px;
        padding: 12px;
        border-radius: 10px;
        font-size: 0.9rem;
    }

    .passage-panel {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .passage-panel-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .passage-panel-eyebrow {
        font-size: 0.68rem;
    }

    .passage-panel-title {
        font-size: 0.98rem;
    }

    .passage-panel-image,
    .passage-panel-content img {
        max-height: 200px;
    }

    .passage-panel-content {
        font-size: calc(0.9rem * var(--exam-font-scale, 1));
        line-height: 1.6;
    }

    .passage-questions-column {
        gap: 16px;
    }

    .passage-question-block {
        padding-bottom: 16px;
    }

    /* Result Details' "Answer Summary" review reuses .passage-preview (also
       shared by the Admin/Branch result-review pages), so this is scoped to
       .student-content — same reasoning as the exam runner's image cap
       above, just for the post-exam review instead of the live attempt. */
    .student-content .passage-preview img {
        max-height: 200px;
        width: auto;
        margin-left: auto;
        margin-right: auto;
    }

    .exam-controls {
        gap: 8px;
        margin-top: 16px;
    }

    .exam-controls .btn {
        flex: 1 1 100%;
    }
}

/* "My Profile"-style pages, mobile only: Teacher/Student/Guardian's own
   profile page and Guardian's per-student page (teacher/profile,
   student/profile, guardian/profile, guardian/students/show,
   guardian/students/result — all wrap this markup in <section
   class="student-section">). A centered, stacked header plus a
   single-column detail list reads far better on a phone than the
   compact 2-col icon grid: labels/values (email, branch name, subjects)
   no longer get squeezed into a half-width column, and there's no
   leftover half-empty tile when the field count is odd. Scoped to
   .student-section so the Admin/Branch "view student" page — which
   reuses the same .student-details-grid/.student-detail-item markup
   inside .student-details-panel, not .student-section, and needs to
   stay compact since it's someone else's record, not a short personal
   profile — keeps its existing 2-col layout untouched. Placed after
   every earlier .student-content-scoped rule for these same classes so
   it wins the equal-specificity cascade. */
@media (max-width: 767.98px) {
    .student-section .student-profile-summary {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 22px 16px;
    }

    .student-section .student-profile-summary > div:last-child {
        width: 100%;
    }

    .student-section .student-profile-summary .student-profile-avatar-lg {
        width: 68px;
        height: 68px;
        flex-basis: 68px;
        font-size: 1.7rem;
        border-radius: 18px;
    }

    .student-section .student-profile-summary h3 {
        font-size: 1.1rem;
    }

    .student-section .student-profile-summary p {
        font-size: 0.86rem;
    }

    .student-section .student-details-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .student-section .student-detail-item {
        padding: 12px 14px;
    }

    .student-section .student-detail-icon {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }

    .student-section .student-detail-item dt {
        font-size: 0.7rem;
    }

    .student-section .student-detail-item dd {
        font-size: 0.88rem;
        overflow-wrap: anywhere;
    }
}

/* Guardian picker on the Student Create form, mobile only: a comfortable
   tap target for each search result, and the selected-guardian card wraps
   its "Change" button onto its own row instead of squeezing the guardian's
   email into a sliver of space next to it. */
@media (max-width: 575.98px) {
    .guardian-dropdown-item {
        padding: 12px;
    }

    .guardian-dropdown-item strong {
        font-size: 0.88rem;
    }

    .guardian-dropdown-item span {
        font-size: 0.78rem;
    }

    .guardian-selected-card {
        flex-wrap: wrap;
    }

    .guardian-selected-info {
        min-width: 60%;
    }

    .guardian-selected-card .btn {
        margin-left: auto;
    }
}

@media (max-width: 359.98px) {
    body:not(.super-admin-panel) .admin-topbar {
        gap: 6px;
        padding-inline: 8px;
    }

    body:not(.super-admin-panel) .admin-topbar > div:not(.topbar-actions):not(:first-child) {
        max-width: calc(100% - 144px);
    }

    body:not(.super-admin-panel) .topbar-actions,
    body:not(.super-admin-panel) .admin-user {
        max-width: 136px;
    }

    body:not(.super-admin-panel) .admin-user .avatar {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    body:not(.super-admin-panel) .admin-user strong,
    body:not(.super-admin-panel) .admin-user span {
        max-width: 100px;
    }

    body:not(.super-admin-panel) .admin-user strong {
        font-size: 0.7rem;
    }

    body:not(.super-admin-panel) .admin-user span {
        font-size: 0.58rem;
    }

    .exam-hero-badges,
    .exam-hero-actions {
        grid-template-columns: 1fr;
    }

    .exam-hero-actions > .btn-exam-action:first-child {
        grid-column: auto;
    }

    .admin-content,
    .student-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .student-stat-grid,
    .student-stats-grid,
    .exam-stats-grid {
        grid-template-columns: 1fr;
    }

    .exam-card dl {
        grid-template-columns: 1fr;
    }

    .exam-nav-btn {
        width: 32px;
        height: 32px;
    }

    .confirm-modal .modal-footer {
        grid-template-columns: 1fr;
    }
}

/* ===== Math Input Toolbar ===== */
.math-input-wrap {
    position: relative;
    width: 100%;
}

.math-input-wrap .form-control {
    padding-right: 42px;
}

.math-toolbar-toggle {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all .18s ease;
    z-index: 2;
    padding: 0;
}

.math-toolbar-toggle:hover {
    color: var(--primary);
    background: #eef4ff;
    border-color: var(--primary);
}

.math-toolbar-popover {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 50;
    width: min(320px, calc(100vw - 24px));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(20, 32, 54, .16);
    overflow: hidden;
}

.math-toolbar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--soft);
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.math-toolbar-header .btn-close {
    font-size: 0.6rem;
}

.math-toolbar-hint {
    margin: 8px 12px 0;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--muted);
}

.math-toolbar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.math-tool-btn {
    min-height: 34px;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s ease;
    display: grid;
    place-items: center;
    white-space: nowrap;
}

.math-tool-btn:hover {
    background: #eef4ff;
    border-color: var(--primary);
    color: var(--primary);
}

/* Mobile responsive */
@media (max-width: 576px) {
    .math-toolbar-popover {
        width: min(280px, calc(100vw - 20px));
    }

    .math-toolbar-grid {
        grid-template-columns: repeat(5, 1fr);
        max-height: 200px;
    }

    .math-tool-btn {
        min-height: 32px;
        font-size: 0.78rem;
    }
}

/* ===== CKEditor Math Tool (Summary + Question Text) ===== */
.ckeditor-field-wrap {
    position: relative;
}

.ckeditor-math-wrap {
    position: relative;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.ckeditor-math-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s ease;
}

.ckeditor-math-toggle:hover {
    color: var(--primary);
    background: #eef4ff;
    border-color: var(--primary);
}

.ckeditor-math-staging {
    padding: 10px 10px 0;
}

.ckeditor-math-actions {
    display: flex;
    justify-content: flex-end;
    padding: 8px 10px 10px;
}

/* ===== Question Text: Normal Text / Math Equation mode switch ===== */
.ckeditor-math-wrap.has-mode-switch {
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.question-mode-switch {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--soft);
}

.question-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s ease;
}

.question-mode-btn:hover {
    color: var(--primary);
}

.question-mode-btn.is-active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(20, 32, 54, .12);
}

.math-mode-panel {
    position: relative;
}

/* The field is auto-focused on entering Math Equation mode — keep it calm:
   a plain primary border instead of the thick Bootstrap focus glow. */
.math-mode-panel .form-control:focus {
    border-color: var(--primary);
    box-shadow: none;
}

@media (max-width: 576px) {
    .question-mode-switch {
        width: 100%;
    }

    .question-mode-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ==========================================================================
   Guardian Panel — "My Students" dashboard cards + the multi-student switcher
   shown on a Student's profile/result pages. Built from the same tokens as
   the rest of the app (--primary/--accent/--ink, the shared card shadow) so
   it reads as one system alongside the Admin/Branch/Student panels.
   ========================================================================== */
.guardian-student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.guardian-student-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(23, 32, 51, 0.055);
    text-decoration: none;
    color: inherit;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.guardian-student-card:hover,
.guardian-student-card:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(23, 32, 51, 0.1);
    border-color: rgba(35, 86, 216, 0.3);
    color: inherit;
}

.guardian-student-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.guardian-student-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.guardian-student-card-arrow {
    color: var(--muted);
    font-size: 1.1rem;
    transition: transform 0.18s ease, color 0.18s ease;
}

.guardian-student-card:hover .guardian-student-card-arrow {
    transform: translateX(3px);
    color: var(--primary);
}

.guardian-student-card h3 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--ink);
}

.guardian-student-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.86rem;
    color: var(--muted);
}

.guardian-student-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.guardian-student-card-stats {
    display: flex;
    gap: 16px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px dashed rgba(23, 32, 51, 0.12);
}

.guardian-student-card-stats strong {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ink);
}

.guardian-student-card-stats span {
    font-size: 0.76rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.guardian-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(23, 32, 51, 0.055);
}

.guardian-switcher-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    flex: 0 0 auto;
}

.guardian-switcher-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.guardian-switcher-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 8px;
    border-radius: 999px;
    border: 1px solid rgba(23, 32, 51, 0.1);
    background: #fbfcfe;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.guardian-switcher-pill:hover,
.guardian-switcher-pill:focus-visible {
    border-color: rgba(35, 86, 216, 0.35);
    color: inherit;
}

.guardian-switcher-pill.active {
    background: linear-gradient(135deg, rgba(35, 86, 216, 0.1), rgba(15, 159, 143, 0.1));
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(35, 86, 216, 0.12);
}

.guardian-switcher-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.82rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    flex: 0 0 auto;
}

.guardian-switcher-pill strong {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.25;
}

.guardian-switcher-pill small {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.2;
}

@media (max-width: 576px) {
    .guardian-student-grid {
        grid-template-columns: 1fr;
    }

    .guardian-switcher {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Exam List: visibility scope of an exam — "All Branches" (Super Admin,
   global) vs "Branch Only" (created by one branch). */
.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}

.scope-badge.scope-global {
    background: rgba(29, 111, 216, 0.08);
    color: #1d6fd8;
    border-color: rgba(29, 111, 216, 0.3);
}

.scope-badge.scope-branch {
    background: #fff7ed;
    color: #b54708;
    border-color: #fed7aa;
}

.exam-grade-list {
    display: inline-block;
    max-width: 220px;
    white-space: normal;
    line-height: 1.35;
}

/* Super Admin Exam List filters: search, status, scope, button. */
.filter-bar.filter-bar-exams {
    grid-template-columns: 3fr 1fr 1fr 1fr;
}

@media (max-width: 767.98px) {
    .filter-bar.filter-bar-exams {
        grid-template-columns: 1fr;
    }

    .filter-bar.filter-bar-exams .btn {
        width: 100%;
    }
}

/* Exam form: compact Grade(s) multi-select — one field with chips that
   opens a searchable checklist, instead of a wall of checkbox tiles. */
.grade-ms {
    position: relative;
}

.grade-ms-field {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 6px 12px;
    text-align: left;
    background: #fff;
    cursor: pointer;
}

.grade-ms.is-open .grade-ms-field,
.grade-ms-field:focus-visible {
    border-color: #1d6fd8;
    box-shadow: 0 0 0 3px rgba(29, 111, 216, 0.15);
    outline: none;
}

.grade-ms.is-invalid .grade-ms-field {
    border-color: #dc3545;
}

.grade-ms-value {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.grade-ms-placeholder {
    color: #8a94a6;
}

.grade-ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: rgba(29, 111, 216, 0.1);
    color: #1d6fd8;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.grade-ms-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}

.grade-ms-chip-remove:hover {
    background: rgba(29, 111, 216, 0.2);
}

.grade-ms-more {
    font-size: 0.8rem;
    font-weight: 700;
    color: #5b6576;
}

.grade-ms-caret {
    flex: 0 0 auto;
    color: #5b6576;
    transition: transform 0.15s ease;
}

.grade-ms.is-open .grade-ms-caret {
    transform: rotate(180deg);
}

.grade-ms-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border: 1px solid var(--line, #e3e8ef);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
    overflow: hidden;
}

.grade-ms-menu[hidden] {
    display: none;
}

.grade-ms-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line, #e3e8ef);
    color: #8a94a6;
}

.grade-ms-search input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    font-size: 0.9rem;
    background: transparent;
}

.grade-ms-actions {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid var(--line, #e3e8ef);
}

.grade-ms-actions button {
    border: 0;
    background: none;
    padding: 2px 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: #1d6fd8;
}

.grade-ms-actions button:last-child {
    color: #5b6576;
}

.grade-ms-options {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.grade-ms-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
}

.grade-ms-option[hidden] {
    display: none;
}

.grade-ms-option:hover {
    background: #f4f7fb;
}

.grade-ms-option input {
    width: 16px;
    height: 16px;
    accent-color: #1d6fd8;
    cursor: pointer;
}

.grade-ms-option:has(input:checked) {
    color: #1d6fd8;
    font-weight: 600;
}

.grade-ms-empty {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #8a94a6;
}

@media (max-width: 767.98px) {
    .grade-ms-field {
        min-height: 44px;
    }
}

/* Student exam page: compact info cards — icon beside the label/value
   instead of stacked above it, so each card is roughly half as tall. */
.student-info-card-grid .info-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    align-content: center;
    min-height: 72px;
    padding: 12px 16px;
}

.student-info-card-grid .info-card-icon {
    grid-row: 1 / span 2;
    width: 38px;
    height: 38px;
    margin-bottom: 0;
}

.student-info-card-grid .info-card span {
    margin-bottom: 1px;
    font-size: 0.76rem;
}

.student-info-card-grid .info-card strong {
    font-size: 1.25rem;
    white-space: nowrap;
}

.student-info-card-grid .info-card-icon {
    font-size: 1.05rem;
}

.student-info-card-grid .info-card strong small {
    font-size: 0.85rem;
}

/* Up to five cards (with Negative Marking) share one row on wide screens
   instead of one card wrapping onto a row of its own. */
@media (min-width: 1200px) {
    .student-info-card-grid {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
    }
}

.scope-badge[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* Submit Exam modal: Total / Attempted / Unanswered counts. */
.submit-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.submit-summary-stat {
    padding: 10px 8px;
    text-align: center;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background: #fff;
}

.submit-summary-stat strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
    color: #172033;
}

.submit-summary-stat span {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #667085;
}

.submit-summary-stat.answered strong {
    color: #067647;
}

.submit-summary-stat.skipped {
    border-color: #fda29b;
    background: #fef3f2;
}

.submit-summary-stat.skipped strong,
.submit-summary-stat.skipped span {
    color: #b42318;
}

/* Multiple attempts: "2/3" chip, per-exam Attempt History, and the
   "result pending until all attempts are done" screen. */
.attempt-chip,
.student-section-header .attempt-chip,
.performance-info .attempt-chip,
.exam-history-info .attempt-chip {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(29, 111, 216, 0.1);
    color: #1d6fd8;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    vertical-align: middle;
}

.attempt-chip.attempt-chip-lg,
.student-section-header .attempt-chip.attempt-chip-lg {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.attempt-history {
    margin-top: 20px;
}

.attempt-history-table tr.is-current td {
    background: rgba(29, 111, 216, 0.06);
}

.result-pending {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
}

.result-pending-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: #fffaeb;
    color: #b54708;
    font-size: 1.6rem;
}

.result-pending h2 {
    margin: 12px 0 8px;
    font-size: 1.35rem;
    font-weight: 800;
}

.result-pending p {
    color: #596477;
}

.result-pending-progress {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0 22px;
}

.result-pending-progress span {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(23, 32, 51, 0.12);
    background: #f3f6fa;
    color: #596477;
    font-weight: 800;
}

.result-pending-progress span.done {
    background: #ecfdf3;
    border-color: #75e0a7;
    color: #067647;
}

.result-pending-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Attempt History: each attempt's Answer Review slides open under its row. */
.attempt-history-table tr.attempt-detail-row > td {
    padding: 0;
    border-bottom-width: 0;
    background: transparent;
    white-space: normal;
}

.attempt-history-table tr.attempt-detail-row:has(.collapse.show, .collapsing) > td {
    border-bottom-width: 1px;
}

.attempt-history .collapsing {
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.attempt-open-btn .attempt-close-icon,
.attempt-open-btn:not(.collapsed) .attempt-open-icon {
    display: none;
}

.attempt-open-btn:not(.collapsed) .attempt-close-icon {
    display: inline-block;
}

.attempt-open-btn:not(.collapsed) {
    background: #1d6fd8;
    color: #fff;
}

.attempt-detail {
    margin: 4px 0 16px;
    padding: 16px 18px;
    border: 1px solid rgba(29, 111, 216, 0.18);
    border-radius: 12px;
    background: #f8fbff;
}

.attempt-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

/* An attempt's own summary cards, above its Answer Review in the panel. */
.attempt-detail-summary {
    margin-bottom: 18px;
}

.attempt-detail-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #172033;
}

@media (prefers-reduced-motion: reduce) {
    .attempt-history .collapsing {
        transition: none;
    }
}
