@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Modern orange + warm white — matched to BitLearn app (#FF6B00) */
    --primary: #FF6B00;
    --primary-hover: #E85F00;
    --primary-deep: #D45200;
    --primary-soft: #FFF1E6;
    --primary-muted: #FFE0C2;
    --secondary: #0D9488;
    --background: #FFF8F3;
    --surface: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, 0.92);
    --text-main: #1C1917;
    --text-muted: #78716C;
    --border: #E7E5E4;
    --danger: #DC2626;
    --warning: #D97706;
    --font-main: 'Outfit', sans-serif;
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 78px;
    --content-pad: 2rem;
    --content-max: 1400px;
    --shadow-card: 0 10px 28px -14px rgba(28, 25, 23, 0.12);
    --shadow-primary: 0 8px 20px -6px rgba(255, 107, 0, 0.45);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}
body.admin-body {
    display: block;
    overflow-x: hidden;
}

/* Base gradients and dynamic backgrounds */
.bg-gradient-mesh {
    background:
        radial-gradient(at 0% 0%, rgba(255, 107, 0, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(13, 148, 136, 0.08) 0px, transparent 45%),
        radial-gradient(at 100% 100%, rgba(255, 107, 0, 0.09) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(255, 138, 61, 0.08) 0px, transparent 45%);
    background-color: var(--background);
    background-attachment: fixed;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-card);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 36px -16px rgba(249, 115, 22, 0.22);
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-brand {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #FF6B00, #FF8A3D);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.navbar-links a {
    color: var(--text-main);
    text-decoration: none;
    margin-left: 2rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.navbar-links a:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: var(--font-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 1rem;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -6px rgba(234, 88, 12, 0.5);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--primary-soft);
    border-color: #FDBA74;
    color: var(--primary-hover);
}

.btn-danger {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-block {
    width: 100%;
}

/* Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.2);
    background: #fff;
}

.form-control::placeholder {
    color: #A8A29E;
}

.text-muted { color: var(--text-muted); }

/* Layout Utilities */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--content-pad);
}

.main-content {
    flex: 1;
    padding: 2.5rem 0 3rem;
}

.app-main > .container.main-content {
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
}

/* Teacher dashboard */
.dash-home .page-header.dash-home-header {
    margin-bottom: 1.25rem;
}
.dash-home-sub {
    margin: 0.35rem 0 0;
    max-width: 40rem;
    line-height: 1.5;
}
.dash-stats {
    margin-bottom: 1.5rem;
}
.dash-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem !important;
    text-align: left;
}
.dash-stat:hover {
    transform: translateY(-2px);
}
.dash-stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    flex: 0 0 auto;
}
.dash-stat-icon.is-primary {
    background: var(--primary-muted);
    color: var(--primary-hover);
}
.dash-stat-icon.is-success {
    background: rgba(13, 148, 136, 0.12);
    color: var(--secondary);
}
.dash-stat-icon.is-warning {
    background: rgba(217, 119, 6, 0.12);
    color: var(--warning);
}
.dash-stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-main);
}
.dash-stat-label {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 0.15rem;
}
.dash-stat-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}
.dash-section {
    margin-bottom: 0.5rem;
}
.dash-section-title {
    margin: 0 0 0.9rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.dash-monitor-grid {
    gap: 1rem;
}
.dash-monitor {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.25rem !important;
    text-decoration: none;
    color: inherit;
    min-height: 0;
}
.dash-monitor:hover {
    transform: translateY(-2px);
}
.dash-monitor.is-danger {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, #fff 70%);
    border-color: rgba(220, 38, 38, 0.22);
}
.dash-monitor.is-success {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.1) 0%, #fff 70%);
    border-color: rgba(13, 148, 136, 0.22);
}
.dash-monitor-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.35rem;
}
.dash-monitor.is-danger .dash-monitor-value { color: var(--danger); }
.dash-monitor.is-success .dash-monitor-value { color: var(--secondary); }
.dash-monitor-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}
.dash-monitor-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0.3rem 0 0;
    line-height: 1.4;
}
.dash-monitor-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    flex: 0 0 auto;
}
.dash-monitor.is-danger .dash-monitor-icon {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger);
}
.dash-monitor.is-success .dash-monitor-icon {
    background: rgba(13, 148, 136, 0.12);
    color: var(--secondary);
}

/* Login Auth Page — 1 viewport, orange card */
body.auth-page {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.auth-page.bg-gradient-mesh {
    background:
        radial-gradient(ellipse 80% 55% at 10% 0%, rgba(255, 107, 0, 0.22) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 95% 15%, rgba(255, 138, 61, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse 60% 45% at 50% 100%, rgba(232, 95, 0, 0.14) 0%, transparent 55%),
        linear-gradient(165deg, #FFF8F3 0%, #FFE8D6 48%, #FFF4EB 100%);
    background-attachment: scroll;
}

.auth-wrapper {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 1.5vh, 1rem);
    padding: clamp(0.6rem, 2vh, 1.25rem) clamp(0.85rem, 3vw, 1.5rem);
    overflow: hidden;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100dvh - 4.5rem);
    overflow: auto;
    overscroll-behavior: contain;
    padding: clamp(1rem, 2.8vh, 1.75rem) clamp(1.1rem, 3.5vw, 1.75rem);
    border-radius: calc(var(--radius) + 4px);
    border: 1px solid rgba(255, 255, 255, 0.28);
    background:
        linear-gradient(155deg, #FF8A3D 0%, #FF6B00 42%, #E85F00 78%, #D45200 100%);
    box-shadow:
        0 22px 48px -18px rgba(212, 82, 0, 0.55),
        0 8px 20px -10px rgba(28, 25, 23, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
    color: #FFF8F3;
    isolation: isolate;
}
.auth-card.glass-card,
.glass-card.auth-card {
    background:
        linear-gradient(155deg, #FF8A3D 0%, #FF6B00 42%, #E85F00 78%, #D45200 100%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.auth-card:hover,
.glass-card.auth-card:hover {
    transform: none;
    box-shadow:
        0 22px 48px -18px rgba(212, 82, 0, 0.55),
        0 8px 20px -10px rgba(28, 25, 23, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.auth-card-decor {
    pointer-events: none;
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    overflow: hidden;
    background:
        radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.28) 0%, transparent 42%),
        radial-gradient(circle at 92% 18%, rgba(255, 236, 210, 0.22) 0%, transparent 38%),
        radial-gradient(circle at 80% 92%, rgba(0, 0, 0, 0.12) 0%, transparent 45%),
        repeating-linear-gradient(
            -28deg,
            transparent 0,
            transparent 11px,
            rgba(255, 255, 255, 0.035) 11px,
            rgba(255, 255, 255, 0.035) 12px
        );
}
.auth-card-decor::after {
    content: '';
    position: absolute;
    width: 9rem;
    height: 9rem;
    right: -2.2rem;
    bottom: -2.4rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.05);
}

.auth-card > *:not(.auth-card-decor) {
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: clamp(0.65rem, 1.8vh, 1.15rem);
}

.login-logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: clamp(0.35rem, 1.2vh, 0.75rem);
    padding: 0;
}

.login-logo {
    height: auto;
    width: clamp(132px, 28vh, 190px);
    max-width: 72%;
    filter: drop-shadow(0 6px 14px rgba(28, 25, 23, 0.28)) brightness(1.06) saturate(1.05);
}

.auth-header h1 {
    font-size: clamp(1.35rem, 1.1rem + 1.4vh, 1.85rem);
    margin-bottom: 0.2rem;
    color: #FFFFFF;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 0 rgba(212, 82, 0, 0.25);
    line-height: 1.2;
}

.auth-header p {
    color: rgba(255, 248, 243, 0.88);
    font-size: clamp(0.82rem, 0.75rem + 0.4vh, 0.95rem);
    margin: 0;
    line-height: 1.4;
}

.auth-form .form-group {
    margin-bottom: clamp(0.65rem, 1.6vh, 1rem);
}

.auth-form .form-label {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    font-size: 0.86rem;
    margin-bottom: 0.35rem;
}

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

.auth-input-wrap > .uil {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: #C2410C;
    font-size: 1.15rem;
    pointer-events: none;
    z-index: 1;
}

.auth-card .form-control {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.55);
    color: var(--text-main);
    padding-left: 2.85rem;
    box-shadow: 0 4px 12px -6px rgba(120, 53, 15, 0.28);
}
.auth-card .form-control.auth-input-password {
    padding-right: 2.85rem;
}
.auth-card .form-control::placeholder {
    color: #A8A29E;
}
.auth-card .form-control:focus {
    outline: none;
    border-color: #FFF7ED;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35), 0 4px 12px -6px rgba(120, 53, 15, 0.28);
}

.auth-eye {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #C2410C;
    padding: 0.3rem;
    display: flex;
    align-items: center;
    border-radius: 6px;
}
.auth-eye:hover {
    color: var(--primary-deep);
    background: rgba(255, 107, 0, 0.08);
}
.auth-eye .uil {
    font-size: 1.2rem;
}

.auth-submit {
    margin-top: clamp(0.35rem, 1vh, 0.75rem);
    background: #FFFFFF !important;
    color: #C2410C !important;
    border: none !important;
    font-weight: 700;
    box-shadow: 0 8px 18px -8px rgba(68, 24, 4, 0.45) !important;
}
.auth-submit:hover {
    background: #FFF7ED !important;
    color: #9A3412 !important;
    transform: translateY(-1px);
}

.auth-alert {
    margin-bottom: 0.85rem;
    padding: 0.7rem 0.85rem;
    font-size: 0.85rem;
}
.auth-card .alert-danger {
    background: rgba(254, 226, 226, 0.95);
    border: 1px solid rgba(252, 165, 165, 0.9);
    color: #B91C1C;
}
.auth-card .alert-success {
    background: rgba(204, 251, 241, 0.95);
    border: 1px solid rgba(94, 234, 212, 0.85);
    color: #0F766E;
}

.auth-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: clamp(0.72rem, 0.68rem + 0.3vh, 0.82rem);
    line-height: 1.35;
    flex-shrink: 0;
    max-width: 26rem;
}
.auth-footer p {
    margin: 0 0 0.15rem;
}
.auth-footer span,
.auth-footer b {
    color: var(--primary-hover);
    font-weight: 600;
}

/* Short viewports: keep everything on one screen */
@media (max-height: 720px) {
    .auth-card {
        max-height: calc(100dvh - 3.6rem);
        padding: 0.9rem 1.1rem;
    }
    .login-logo {
        width: clamp(110px, 22vh, 150px);
    }
    .auth-header h1 {
        font-size: 1.35rem;
    }
    .auth-form .form-group {
        margin-bottom: 0.55rem;
    }
    .auth-card .form-control {
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }
}

@media (max-height: 580px) {
    body.auth-page {
        overflow: auto;
        height: auto;
        min-height: 100dvh;
    }
    .auth-wrapper {
        overflow: visible;
        justify-content: flex-start;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    .auth-card {
        max-height: none;
        overflow: visible;
    }
    .login-logo {
        width: 100px;
    }
}

@media (max-width: 420px) {
    .auth-card {
        max-width: 100%;
        border-radius: 18px;
    }
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* Grid systems */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.course-layout-grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 1.15rem;
    align-items: start;
}

/* Course panel polish */
.page-header.course-hero {
    margin-bottom: 1.1rem;
    align-items: flex-start;
}
.course-hero h2 {
    margin: 0;
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.65rem);
    line-height: 1.3;
}
.course-hero .course-desc {
    color: var(--text-muted);
    margin: 0.4rem 0 0;
    max-width: 52rem;
    line-height: 1.55;
}
.course-meta-row {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    align-items: center;
}
.rombel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}
.rombel-chip {
    background: var(--primary-muted);
    color: var(--primary-hover);
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
}
.course-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}
.course-panel > .glass-card {
    margin-bottom: 0;
    padding: 1.25rem;
}
.course-panel > .glass-card:hover {
    transform: none;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.85rem;
    flex-wrap: wrap;
}
.section-head h3 {
    margin: 0;
    font-size: 1.05rem;
}
.empty-state-card {
    text-align: center;
    padding: 1.75rem 1.25rem;
    border: 1px dashed var(--border);
}
.empty-state-card:hover {
    transform: none;
}
.empty-state-card i {
    font-size: 2.25rem;
    color: var(--text-muted);
}
.empty-state-card h3 {
    margin: 0.65rem 0 0.3rem;
    font-size: 1.05rem;
}
.empty-state-card p {
    color: var(--text-muted);
    margin: 0 auto;
    font-size: 0.88rem;
    max-width: 28rem;
    line-height: 1.5;
}
.item-row {
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.65rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.item-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

/* Student progress sticky panel */
.progress-board {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 104px);
    display: flex;
    flex-direction: column;
    padding: 1.1rem !important;
    gap: 0.75rem;
}
.progress-board:hover {
    transform: none !important;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5) !important;
}
.progress-board-title {
    margin: 0;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.98rem;
}
.progress-search {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}
.progress-search .form-control {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
}
.progress-search .btn {
    flex: 0 0 auto;
    padding: 0.5rem 0.65rem;
}
.progress-add {
    margin: 0;
    padding: 0.7rem;
    background: rgba(13, 148, 136, 0.08);
    border: 1px solid rgba(13, 148, 136, 0.2);
    border-radius: var(--radius-sm);
}
.progress-add-row {
    display: flex;
    gap: 0.4rem;
}
.progress-add-row .form-control {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
}
.progress-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 0.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,0.4) rgba(255,255,255,0.04);
}
.progress-list::-webkit-scrollbar {
    width: 6px;
}
.progress-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
}
.progress-list::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.35);
    border-radius: 8px;
}
.progress-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148,163,184,0.55);
}
.student-progress-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--primary-soft);
    padding: 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
}
.student-progress-row:hover {
    background: var(--primary-muted);
    border-color: #FDBA74;
}
.student-row-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 0 0 auto;
}
.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
}

/* Page layout helpers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem 1.5rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}
.page-header > div:first-child {
    flex: 1 1 240px;
    min-width: 0;
}
.page-header .page-actions,
.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}
.action-row {
    width: 100%;
}
.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    width: 100%;
}
.filter-row .form-control {
    max-width: 320px;
    flex: 1 1 200px;
}
.list-row {
    background: var(--primary-soft);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.list-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    max-height: 280px;
    overflow-y: auto;
}

/* Tables */
.table-container,
.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sidebar Layout */
.app-wrapper {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    width: 100%;
    position: relative;
    align-items: start;
}
.app-wrapper.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}
.app-sidebar {
    width: 100%;
    max-width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    transition: max-width 0.25s ease;
    overflow: hidden;
    align-self: start;
}
.app-wrapper.sidebar-collapsed .app-sidebar {
    max-width: var(--sidebar-collapsed);
}
.sidebar-header {
    padding: 1.8rem 2rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-header img {
    height: auto;
    width: 160px;
    max-width: 100%;
}
.sidebar-nav {
    padding: 1.5rem 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    gap: 1rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}
.sidebar-link i {
    font-size: 1.25rem;
    flex: 0 0 auto;
}
.sidebar-link:hover, .sidebar-link.active {
    color: var(--primary-hover);
    background: var(--primary-soft);
    border-left-color: var(--primary);
}
.sidebar-footer {
    padding: 1.1rem 1.15rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--primary-soft);
}
.sidebar-footer .profile-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.sidebar-footer .profile-actions {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}
.sidebar-footer .profile-actions .btn {
    min-height: 2.35rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
}
.sidebar-footer .profile-actions .btn-profile {
    flex: 1;
}
.sidebar-footer .profile-actions .btn-logout {
    flex: 0 0 2.5rem;
    padding-left: 0;
    padding-right: 0;
}
.app-main {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.95rem var(--content-pad);
    background: var(--surface-glass);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.top-nav-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-left: auto;
}
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    font-size: 1.35rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.sidebar-toggle:hover {
    background: var(--border);
}
.top-nav-user {
    display: none;
    align-items: center;
    gap: 0.5rem;
}
.top-nav-user .btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
}

/* Collapsed sidebar (desktop/laptop) */
.app-wrapper.sidebar-collapsed .sidebar-header {
    padding: 1.25rem 0.75rem;
    justify-content: center;
}
.app-wrapper.sidebar-collapsed .sidebar-header img {
    width: 42px;
}
.app-wrapper.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 1rem 0.75rem;
    gap: 0;
}
.app-wrapper.sidebar-collapsed .sidebar-link span,
.app-wrapper.sidebar-collapsed .sidebar-footer .user-meta,
.app-wrapper.sidebar-collapsed .sidebar-footer .btn-label {
    display: none;
}
.app-wrapper.sidebar-collapsed .sidebar-footer {
    padding: 1rem 0.65rem;
}
.app-wrapper.sidebar-collapsed .sidebar-footer .profile-row {
    justify-content: center;
    margin-bottom: 0.75rem;
}
.app-wrapper.sidebar-collapsed .sidebar-footer .profile-actions {
    flex-direction: column;
}

/* =========================
   Modal system (uniform + responsive)
   ========================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.48);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-overlay.active {
    display: flex;
}
body.modal-open {
    overflow: hidden;
}

.modal-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: min(92vh, 880px);
    margin: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 28px 60px -20px rgba(28, 25, 23, 0.35);
    transform: translateY(10px) scale(0.98);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.modal-box--sm { max-width: 420px; }
.modal-box--lg { max-width: 640px; }
.modal-box--xl { max-width: 760px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 auto;
    padding: 1.1rem 1.25rem;
    margin: 0 !important;
    border-bottom: 1px solid var(--border);
    background: var(--primary-soft);
}
.modal-header h3,
.modal-header .modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex: 1;
}
.modal-header h3 i,
.modal-header .modal-title i {
    color: var(--primary);
    flex: 0 0 auto;
}

/* Reset Bootstrap .btn-close inside our modals */
.modal-overlay .btn-close,
.modal-box .btn-close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    min-width: 2.25rem;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    background: #fff !important;
    background-image: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    color: var(--text-muted) !important;
    font-size: 1.25rem !important;
    line-height: 1 !important;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.modal-overlay .btn-close:hover,
.modal-box .btn-close:hover {
    color: var(--danger) !important;
    border-color: rgba(220, 38, 38, 0.35) !important;
    background: rgba(220, 38, 38, 0.08) !important;
}
.modal-overlay .btn-close:focus,
.modal-box .btn-close:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.18) !important;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
    -webkit-overflow-scrolling: touch;
}
.modal-box > form,
.modal-box > .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
    -webkit-overflow-scrolling: touch;
}
.modal-box > .modal-header + form {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
}

.modal-footer {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: #fff;
}
.modal-footer .btn {
    margin: 0;
}
.modal-box .btn-block {
    width: 100%;
}
.modal-box .form-group:last-of-type {
    margin-bottom: 1rem;
}
.modal-box .form-control {
    background: #fff;
}
.modal-note {
    background: var(--primary-soft);
    border: 1px solid var(--primary-muted);
    color: var(--text-main);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}
.modal-panel {
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}
.modal-form-grid {
    gap: 1rem;
}
@media (max-width: 640px) {
    .modal-form-grid.grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal-box,
    .modal-box--sm,
    .modal-box--lg,
    .modal-box--xl {
        max-width: 100%;
        width: 100%;
        max-height: min(92vh, 100%);
        border-radius: 18px 18px 0 0;
        margin: 0;
    }
    .modal-header {
        padding: 1rem 1rem 0.9rem;
    }
    .modal-header h3,
    .modal-header .modal-title {
        font-size: 1.02rem;
    }
    .modal-box > .modal-header + form,
    .modal-body,
    .modal-box > form {
        padding: 1rem;
    }
    .modal-footer {
        padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
    }
    .modal-footer .btn {
        flex: 1 1 auto;
    }
}

/* === RESPONSIVE LAYOUT UTILITIES === */
.flex-split {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.admin-sidebar-overlay.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Desktop Viewer Layout */
.viewer-container { display: flex; height: 100vh; overflow: hidden; }
.viewer-sidebar { width: 300px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; transition: transform 0.3s ease; }
.viewer-main { flex: 1; overflow-y: auto; background: var(--background); position: relative; padding: 2rem; min-width: 0; }
.btn-mobile-menu { display: none; }
.sidebar-overlay { display:none; }

/* Large desktop */
@media (min-width: 1400px) {
    :root { --content-pad: 2.25rem; --content-max: 1520px; }
}

/* Mid desktop / laptop: optional collapse */
@media (max-width: 1399px) and (min-width: 1100px) {
    :root { --content-pad: 1.5rem; --content-max: 100%; }
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Compact laptop / large tablet landscape */
@media (max-width: 1099px) and (min-width: 769px) {
    :root { --content-pad: 1.25rem; --content-max: 100%; --sidebar-width: 220px; }

    /* Keep sidebar in-flow (never overlay content) */
    .app-wrapper {
        grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    }
    .app-wrapper.sidebar-collapsed {
        grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
    }
    .app-sidebar {
        position: sticky;
        transform: none !important;
        left: auto;
        max-width: var(--sidebar-width);
    }
    .app-main { width: 100%; max-width: 100%; }
    .admin-sidebar-overlay { display: none !important; }
    .top-nav-user { display: none; }
    .stats-grid,
    .grid-cols-3,
    .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dash-monitor-grid { grid-template-columns: 1fr 1fr; }
    .course-layout-grid { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }
    .glass-card:hover { transform: translateY(-2px); }
    .page-header { align-items: stretch; }
}

@media (max-width: 900px) and (min-width: 769px) {
    .stats-grid,
    .grid-cols-2,
    .grid-cols-3 { grid-template-columns: 1fr; }
    .dash-stats { grid-template-columns: 1fr; }
    .dash-monitor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --content-pad: 1rem; --content-max: 100%; }

    .grid-cols-2,
    .grid-cols-3,
    .stats-grid,
    .course-layout-grid { grid-template-columns: 1fr; }
    .dash-stats,
    .dash-monitor-grid { grid-template-columns: 1fr; }
    .grid-auto { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }

    .navbar { padding: 1rem; flex-direction: column; align-items: stretch !important; transition: all 0.3s; }
    .navbar-header-mobile { display: flex; justify-content: space-between; align-items: center; width: 100%; }
    .student-menu-toggle { display: block !important; background: var(--surface); color: var(--text-main); border: 1px solid var(--border); padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); font-size: 1.3rem; cursor: pointer; }
    .navbar-links { display: none; flex-direction: column; width: 100%; background: rgba(0,0,0,0.15); padding: 1rem; border-radius: var(--radius); gap: 1rem; margin-top: 1rem; }
    .navbar-links.active { display: flex; }
    .navbar-links a, .navbar-links .btn { margin: 0 !important; width: 100%; justify-content: center; }

    .flex-split { flex-direction: column; align-items: stretch; gap: 1.25rem; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .page-actions { width: 100%; }
    .page-header .page-actions .btn { flex: 1 1 auto; }

    .container { padding: 0 var(--content-pad); }
    .glass-card { padding: 1.25rem; }
    .glass-card:hover { transform: none; }
    .auth-wrapper { padding: 1rem; min-height: 100dvh; align-items: center; }
    .login-logo-container { margin-bottom: 0.5rem !important; padding: 0 !important; }
    .login-logo { width: 170px !important; transform: scale(1) !important; }

    .form-control { font-size: 16px; }

    /* Teacher shell: horizontal nav on phone */
    .app-wrapper {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
    }
    .app-wrapper.sidebar-collapsed {
        grid-template-columns: none;
    }
    .app-sidebar {
        width: 100%;
        max-width: none;
        flex-basis: auto;
        height: auto;
        position: static;
        transform: none !important;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        box-shadow: none;
        overflow: visible;
    }
    .app-wrapper.sidebar-collapsed .app-sidebar {
        width: 100%;
        max-width: none;
        flex-basis: auto;
    }
    .app-sidebar .sidebar-nav {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding: 0.5rem;
        gap: 0.15rem;
    }
    .sidebar-link {
        padding: 0.8rem 1rem;
        flex: 0 0 auto;
        border-left: none;
        border-bottom: 2px solid transparent;
        justify-content: center;
    }
    .sidebar-link span { display: inline; }
    .sidebar-link.active {
        border-bottom-color: var(--primary);
        background: transparent;
    }
    .app-sidebar .sidebar-footer { display: none; }
    .app-main { width: 100%; }
    .top-nav { justify-content: space-between; }
    .sidebar-toggle { display: none; }
    .top-nav-user { display: inline-flex; }
    .admin-sidebar-overlay { display: none !important; }

    /* Viewer Off-Canvas Logic */
    .viewer-container { display: block; position: relative; }
    .viewer-sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000; transform: translateX(-100%); }
    .viewer-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
    .viewer-main { padding: 1rem; padding-top: 4rem; height: 100vh; }
    .btn-mobile-menu { display: inline-flex; position: fixed; top: 1rem; left: 1rem; z-index: 900; background: var(--surface); color: var(--text-main); border: 1px solid var(--border); padding: 0.5rem 0.8rem; border-radius: var(--radius-sm); font-size: 1.2rem; cursor: pointer; box-shadow:0 4px 6px rgba(0,0,0,0.3); }

    .sidebar-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); z-index: 999; display:none; opacity: 0; transition: opacity 0.3s ease; }
    .sidebar-overlay.open { display: block; opacity: 1; }

    .btn-block { width: 100%; }
    .navbar-links .btn { width: 100%; margin-bottom: 0.5rem; }
    .action-row .btn,
    .list-row-actions .btn { width: auto; }
    td, th { padding: 0.5rem; font-size: 0.85rem; }
    .filter-row .form-control { max-width: none; width: 100%; }
}
