:root {
    --ink: #19211f;
    --muted: #64716d;
    --line: #dfe8e3;
    --brand: #12876f;
    --brand-dark: #0b5f52;
    --success: #2d8a57;
    --danger: #c14b3d;
    --surface: #ffffff;
    --soft: #f4f8f5;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--soft);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { text-decoration: none; }
h1, h2, h3 { letter-spacing: 0; }

.landing {
    min-height: 100vh;
    color: #fff;
    background: linear-gradient(135deg, rgba(20, 45, 41, .94), rgba(18, 135, 111, .82)), url('../images/exam-bg.svg') center/cover;
}
.home-auth {
    min-height: 100vh;
    display: grid;
    place-items: start end;
    padding: 15vh 13.8vw 24px 24px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .08), rgba(213, 238, 223, .26)),
        url('../images/login-bg.jpg') center/cover no-repeat;
}
.home-auth-card {
    width: min(100%, 560px);
    padding: 28px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 22px 55px rgba(32, 58, 50, .14);
    backdrop-filter: blur(6px);
    color: #0b5f52;
}
.home-logo {
    width: 92px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 12px;
}
.home-auth-card h1 {
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.05;
    font-weight: 850;
}
.home-auth-card p { color: #5d6b67; font-size: 1.05rem; }
.home-auth-card small { display: block; margin-top: 14px; color: #64716d; }
.home-auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}
.home-auth-actions .btn {
    min-width: 160px;
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 800;
}
.home-auth-actions .btn-primary {
    border: 0;
    background: #0b5f52;
}
.home-auth-actions .btn-primary:hover { background: #084a40; }
.home-auth-actions .btn-light {
    color: #0b5f52;
    border: 1px solid #d8e4de;
    background: #fff;
}
.home-auth-actions .btn-outline-light {
    color: #0b5f52;
    border-color: #c8d8d0;
}
.hero { padding: 70px 12px 90px; }
.hero h1 { max-width: 760px; font-size: clamp(2.2rem, 6vw, 4.6rem); line-height: 1.02; font-weight: 800; }
.hero .lead { color: rgba(255, 255, 255, .82); max-width: 720px; }
.hero-panel, .auth-card, .panel, .subject-card, .test-question, .review-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(30, 54, 47, .08);
}
.hero-panel { color: var(--ink); padding: 24px; }
.question-card { background: #f7fbf8; border-radius: 8px; padding: 18px; }
.option { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
.option.active { border-color: var(--brand); background: #e5f6ef; }
.eyebrow { text-transform: uppercase; font-size: .75rem; font-weight: 800; letter-spacing: .08em; }

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top left, #d9f2e7, transparent 34%), #f7fbf8;
}
.auth-card { width: min(100%, 430px); padding: 30px; }
.auth-card h1 { font-size: 2rem; font-weight: 800; }
.auth-card p { color: var(--muted); }
.branded-auth {
    min-height: 100vh;
    place-items: start end;
    padding: 15vh 13.8vw 24px 24px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .08), rgba(213, 238, 223, .26)),
        url('../images/login-bg.jpg') center/cover no-repeat;
}
.branded-auth .auth-card {
    width: min(100%, 455px);
    padding: 46px 44px 40px;
    border: 0;
    border-radius: 18px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 22px 55px rgba(32, 58, 50, .14);
    backdrop-filter: blur(6px);
}
.branded-auth .auth-card h1 {
    margin-bottom: 6px;
    text-align: center;
    color: #10443d;
    font-size: 2.1rem;
}
.branded-auth .auth-card p {
    margin-bottom: 28px;
    text-align: center;
}
.auth-field {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 0 18px;
    border: 1px solid #d8e4de;
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
}
.auth-field span {
    width: 24px;
    color: #5c6b66;
    font-size: 1.3rem;
    line-height: 1;
    text-align: center;
}
.auth-field .form-control {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 1.03rem;
}
.branded-auth .btn-primary {
    min-height: 64px;
    border: 0;
    border-radius: 8px;
    background: #0b5f52;
    font-size: 1.05rem;
    font-weight: 800;
}
.branded-auth .btn-primary:hover { background: #084a40; }
.branded-auth a { color: #0b5f52; font-weight: 700; }
.auth-logo {
    display: block;
    width: 92px;
    height: 72px;
    object-fit: contain;
    margin: 0 auto 12px;
}
.admin-corner-link,
.teacher-corner-link {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 5;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #0b5f52;
    background: rgba(255,255,255,.9);
    border: 1px solid #d8e4de;
    box-shadow: 0 14px 30px rgba(32, 58, 50, .16);
}
.teacher-corner-link {
    right: 72px;
}
.admin-corner-link:hover,
.teacher-corner-link:hover { color: #084a40; background: #fff; }
.question-image {
    display: block;
    max-width: min(100%, 680px);
    max-height: 360px;
    object-fit: contain;
    margin: 12px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.subject-check-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.subject-check-list label {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
}
.pwa-install-prompt {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2500;
    width: min(92vw, 390px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(22, 40, 35, .22);
}
.pwa-install-prompt[hidden] {
    display: none;
}
.pwa-install-prompt strong,
.pwa-install-prompt span {
    display: block;
}
.pwa-install-prompt span {
    color: var(--muted);
    font-size: .9rem;
}
.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 18px;
    font-size: .95rem;
}
.local-reset-link {
    margin-top: 18px;
    padding: 12px;
    border: 1px dashed #95aa9f;
    border-radius: 8px;
    background: rgba(255, 255, 255, .75);
    word-break: break-all;
}
.local-reset-link a { display: block; margin-top: 6px; font-size: .85rem; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    position: sticky;
    top: 0;
    width: 255px;
    min-height: 100vh;
    padding: 22px;
    background: #17201e;
    color: #fff;
}
.sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1200;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: #14211e;
    font-size: 1.25rem;
    line-height: 1;
}
body.sidebar-collapsed .site-sidebar {
    display: none;
}
body.sidebar-collapsed .admin-shell,
body.sidebar-collapsed .student-shell {
    display: block;
}
body.sidebar-collapsed .admin-main,
body.sidebar-collapsed .student-main {
    padding-left: 72px;
}
.admin-sidebar .nav {
    padding-top: 2px;
}
.admin-sidebar .brand { display: block; color: #fff; font-size: 1.3rem; font-weight: 800; margin-bottom: 22px; }
.admin-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, .75);
    border-radius: 8px;
    padding: 11px 13px;
}
.admin-sidebar .nav-link.active, .admin-sidebar .nav-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.admin-main { flex: 1; padding: 28px; min-width: 0; }
.topbar, .dashboard-head, .test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}
.topbar h1, .dashboard-head h1, .test-header h1 { margin: 0; font-weight: 800; }
.topbar p, .dashboard-head p, .test-header p, .subject-card p { color: var(--muted); margin-bottom: 0; }
.panel { padding: 20px; }
.panel h2, .subject-card h2, .test-question h2, .review-card h2 { font-size: 1.15rem; font-weight: 750; }
.stat-card {
    padding: 20px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}
.stat-card span { color: var(--muted); display: block; }
.stat-card strong { display: block; font-size: 2rem; line-height: 1.1; }
.question-preview { max-width: 380px; }
.table td, .table th { vertical-align: middle; }
.course-row-title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.course-row-title img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #fff;
}
.course-row-vertical {
    display: grid;
    justify-items: center;
    text-align: center;
}
.course-row-vertical img {
    width: 74px;
    height: 74px;
}
.compact-course-card {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 10px;
}
.course-check-list {
    max-height: 170px;
    overflow: auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.user-nav { background: #17433c; }
.user-nav .navbar-brand, .user-nav .nav-link { color: #fff; }
.student-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
    background: #f2f8f4;
}
.student-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    color: #fff;
    background: linear-gradient(180deg, #0f2f2a, #12584d);
}
.student-brand {
    display: block;
    padding: 12px 14px 18px;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 850;
}
.student-nav {
    display: grid;
    gap: 6px;
}
.student-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.82);
    font-weight: 700;
}
.student-nav-link span {
    width: 22px;
    text-align: center;
}
.nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    min-width: 24px;
    padding: 2px 7px;
    border-radius: 999px;
    color: #fff;
    background: #c14b3d;
    font-size: .78rem;
    text-align: center;
}
.student-nav-link:hover,
.student-nav-link.active {
    color: #fff;
    background: #12876f;
}
.logout-link {
    margin-top: auto;
}
.student-main {
    min-width: 0;
    padding: 24px 30px;
}
.student-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.student-topbar h1 {
    margin: 0;
    font-weight: 850;
}
.student-topbar p {
    color: var(--muted);
    margin-bottom: 0;
}
.student-panel {
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(30, 54, 47, .06);
}
.student-panel h2 {
    font-size: 1.2rem;
    font-weight: 850;
}
.student-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.student-stat-card {
    padding: 18px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.student-stat-card span {
    display: block;
    color: var(--muted);
}
.student-stat-card strong {
    display: block;
    margin-top: 6px;
    font-size: 2rem;
    line-height: 1;
}
.student-course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.student-course-tile {
    min-height: 150px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 10px;
    padding: 18px;
    color: var(--ink);
    text-align: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(30, 54, 47, .06);
}
.student-course-tile:hover {
    color: var(--ink);
    border-color: #b9cbc3;
}
.student-course-tile img {
    width: 78px;
    height: 78px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.student-course-tile strong {
    font-weight: 850;
}
.student-course-tile small {
    color: var(--muted);
}
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.narrow-panel {
    max-width: 520px;
}
.doubt-list {
    display: grid;
    gap: 14px;
}
.doubt-thread {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fbf8;
}
.doubt-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.doubt-head small {
    display: block;
    color: var(--muted);
}
.doubt-message {
    padding: 12px;
    margin-top: 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}
.doubt-message.admin-reply {
    background: #e8f7f0;
    border-color: #cce9dc;
}
.doubt-message p {
    margin: 6px 0;
}
.inbox-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 16px;
}
.inbox-list-panel {
    padding: 12px;
    max-height: calc(100vh - 220px);
    overflow: auto;
}
.inbox-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.inbox-thread-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}
.inbox-thread-list li {
    display: block;
    width: 100%;
}
.inbox-list {
    max-height: calc(100vh - 220px);
    overflow: auto;
}
.inbox-thread {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px;
    border-radius: 8px;
    color: var(--ink);
    border: 1px solid var(--line);
    background: #fff;
}
.inbox-thread-head {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.inbox-thread-head strong {
    min-width: 0;
}
.inbox-thread:hover,
.inbox-thread.active {
    color: var(--ink);
    border-color: #b9cbc3;
    background: #f6fbf8;
}
.inbox-thread small {
    color: var(--muted);
}
.subject-card { min-height: auto; padding: 18px; }
.section-title {
    margin: 0 0 14px;
    font-size: 1.35rem;
    font-weight: 800;
}
.course-card {
    min-height: 0;
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 18px 14px;
    text-align: center;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(30, 54, 47, .08);
}
.course-card:hover { color: var(--ink); border-color: #b9cbc3; transform: translateY(-1px); }
.course-card img {
    width: 74px;
    height: 74px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.course-card h3 { font-size: 1.05rem; font-weight: 850; margin: 0; }
.course-card p, .course-card small { color: var(--muted); margin: 0; }
.course-card.compact-course p, .course-card.compact-course small { display: none; }
.empty-state { color: var(--muted); }
.course-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 26px;
    margin-bottom: 20px;
    color: #fff;
    background: linear-gradient(135deg, #0f4f45, #12876f);
    border-radius: 8px;
}
.course-hero img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 8px;
    background: #fff;
}
.course-hero h1 { margin: 0; font-weight: 850; }
.course-hero p { margin-bottom: 0; color: rgba(255,255,255,.82); }
.subject-section { margin-bottom: 18px; }
.subject-section-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}
.collapse-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}
.collapse-toggle h2,
.collapse-toggle h3 { margin-bottom: 4px; }
.collapse-toggle span {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--brand);
    background: #e5f6ef;
    transition: transform .18s ease;
}
.collapse-toggle[aria-expanded="true"] > span { transform: rotate(180deg); }
.subject-toggle { margin-bottom: 0; }
.subject-toggle[aria-expanded="true"] { margin-bottom: 12px; }
.subject-section h2 { font-weight: 800; margin-bottom: 4px; }
.subject-section p, .class-row p { color: var(--muted); margin-bottom: 0; }
.class-list { display: grid; gap: 10px; }
.chapter-block {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-top: 12px;
}
.chapter-block h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 850;
}
.chapter-block > p, .chapter-toggle p { color: var(--muted); margin-bottom: 0; }
.chapter-toggle[aria-expanded="true"] { margin-bottom: 12px; }
.class-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fbf8;
}
.class-row h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 800; }
.class-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.video-panel { padding: 16px; }
.video-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: #081512;
}
.video-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
}
.phone-watermark {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    padding: 7px 10px;
    border-radius: 8px;
    color: rgba(255,255,255,.78);
    background: rgba(12,36,31,.46);
    font-weight: 800;
    transition: opacity .3s ease;
}
.phone-watermark.visible { opacity: 1; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.test-grid .btn { display: flex; justify-content: space-between; align-items: center; }
.test-grid small { color: inherit; opacity: .75; }
.test-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.test-series-icon {
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #0f4f45, #12876f);
    font-size: 2rem;
    font-weight: 850;
}

.timer-pill {
    color: #fff;
    background: #14211e;
    border: 1px solid rgba(22, 40, 35, .12);
    border-radius: 999px;
    padding: 9px 16px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(22, 40, 35, .12);
}
.timer-pill.timer-warning {
    background: #b13a32;
}
.progress-box { min-width: 190px; }
.test-question { padding: 22px; margin-bottom: 18px; }
.question-meta {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 10px;
}
.answer-option {
    display: flex;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 10px;
    cursor: pointer;
}
.answer-option:has(input:checked) { border-color: var(--brand); background: #e5f6ef; }
.sticky-submit {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: end;
    padding: 14px 0;
    background: linear-gradient(transparent, var(--soft) 28%);
}
.result-hero {
    padding: 26px;
    color: #fff;
    background: linear-gradient(135deg, #0f4f45, #12876f);
    border-radius: 8px;
    margin-bottom: 20px;
}
.result-summary-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(12, 36, 31, .62);
}
.result-summary-box {
    width: min(100%, 420px);
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(22, 40, 35, .25);
}
.result-summary-box h2 {
    margin-bottom: 18px;
    font-size: 1.35rem;
}
.result-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.result-summary-stats div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
}
.result-summary-stats span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
}
.result-summary-stats strong {
    display: block;
    margin-top: 4px;
    font-size: 1.15rem;
}
.question-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(12, 36, 31, .62);
}
.question-modal-box {
    width: min(100%, 980px);
    max-height: 88vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 22px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(22, 40, 35, .25);
}
.question-modal-list {
    overflow-y: auto;
    padding-right: 8px;
}
.review-card { padding: 22px; margin-bottom: 16px; border-left: 5px solid var(--line); }
.review-card.correct { border-left-color: var(--success); }
.review-card.wrong { border-left-color: var(--danger); }
.review-option { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.review-option.right { border-color: var(--success); background: #e7f7ed; }
.review-option.picked-wrong { border-color: var(--danger); background: #fff0ed; }
.answer-line { margin-top: 14px; font-size: .95rem; }
.answer-line span { margin-left: 14px; }
.explanation { color: var(--muted); margin: 10px 0 0; }
.exam-shell {
    min-height: 100vh;
    background: #eef6f1;
}
.exam-form {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}
.exam-topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.exam-topbar strong {
    display: inline-block;
    padding: 7px 14px;
    color: #fff;
    background: #12876f;
    text-transform: uppercase;
}
.exam-topbar span {
    margin-left: 8px;
    font-weight: 700;
}
.exam-instruction {
    display: grid;
    gap: 2px;
    padding: 4px 10px;
    border: 1px solid #9fd4c0;
    font-size: .78rem;
}
.exam-instruction span {
    margin: 0;
    color: #33413d;
    font-weight: 700;
}
.exam-body {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
}
.exam-question-area {
    min-width: 0;
    padding: 16px;
    background: #fff;
    border-right: 1px solid var(--line);
}
.exam-question {
    display: none;
    min-height: 58vh;
    box-shadow: none;
}
.exam-question.active {
    display: block;
}
.exam-actions {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-top: 20px;
}
.exam-actions .btn {
    min-width: 112px;
    color: #fff;
    background: #12876f;
    border-color: #12876f;
    font-weight: 800;
}
.exam-palette {
    padding: 12px;
    background: #f7fbf8;
    overflow: auto;
}
.exam-palette h2 {
    font-size: 1rem;
    font-weight: 800;
}
.palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}
.palette-btn {
    min-height: 34px;
    border: 1px solid #b8c9c1;
    border-radius: 4px;
    background: #fff;
    font-weight: 700;
}
.palette-btn.active {
    outline: 2px solid #168f7a;
}
.palette-btn.answered, .legend-dot.answered { background: #4fc16f; }
.palette-btn.marked, .legend-dot.marked { background: #6f63d9; color: #fff; }
.palette-btn.skipped, .legend-dot.skipped { background: #c14b3d; color: #fff; }
.palette-btn.not-attended, .legend-dot.not-attended { background: #fff; }
.palette-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
    font-size: .78rem;
}
.legend-dot {
    width: 22px;
    height: 22px;
    display: inline-block;
    margin-right: 6px;
    border: 1px solid #b8c9c1;
    vertical-align: middle;
}

tr[draggable="true"] { cursor: move; }
tr.dragging { opacity: 0.55; }

/* Modern polish layer */
:root {
    --accent: #d98c39;
    --accent-soft: #fff1df;
    --brand-soft: #e5f6ef;
    --brand-quiet: #f0faf5;
    --surface-2: #fbfdfb;
    --shadow-sm: 0 8px 24px rgba(24, 49, 41, .07);
    --shadow-md: 0 16px 44px rgba(24, 49, 41, .11);
    --shadow-lg: 0 24px 70px rgba(18, 44, 37, .16);
}

body {
    background:
        linear-gradient(180deg, rgba(229, 246, 239, .72), transparent 280px),
        var(--soft);
}

.btn {
    --bs-btn-border-radius: 8px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 750;
    letter-spacing: 0;
    box-shadow: none;
}
.btn-sm { min-height: 34px; }
.btn-primary,
.btn-success {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
}
.btn-outline-primary,
.btn-outline-success {
    --bs-btn-color: var(--brand-dark);
    --bs-btn-border-color: #a8cec1;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    background: rgba(255,255,255,.62);
}
.btn-danger,
.btn-outline-danger:hover {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #a93e32;
    --bs-btn-hover-border-color: #a93e32;
}
.btn-outline-secondary {
    --bs-btn-color: #46534f;
    --bs-btn-border-color: #c7d6cf;
    --bs-btn-hover-bg: #eef6f1;
    --bs-btn-hover-border-color: #b8c9c1;
    --bs-btn-hover-color: var(--ink);
}

.alert,
.toast {
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}
.toast-container { z-index: 2800; }
.text-bg-success { background-color: var(--brand) !important; }
.text-bg-danger { background-color: var(--danger) !important; }
.text-primary { color: var(--brand) !important; }
.badge.text-bg-warning {
    color: #5b3b05 !important;
    background: #ffe5ad !important;
}

.form-control,
.form-select {
    min-height: 42px;
    border-color: #ccd9d3;
    border-radius: 8px;
}
.form-control:focus,
.form-select:focus {
    border-color: #70b7a4;
    box-shadow: 0 0 0 .22rem rgba(18, 135, 111, .14);
}

.home-auth,
.branded-auth {
    min-height: 100svh;
    place-items: center end;
    padding: clamp(24px, 7vw, 72px) clamp(22px, 10vw, 132px);
    background:
        linear-gradient(90deg, rgba(9, 36, 31, .05), rgba(240, 250, 245, .76)),
        url('../images/login-bg.jpg') center/cover no-repeat;
}
.home-auth-card,
.branded-auth .auth-card {
    width: min(100%, 500px);
    border: 1px solid rgba(255,255,255,.68);
    border-radius: 8px;
    background: rgba(255,255,255,.82);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}
.home-auth-card h1,
.branded-auth .auth-card h1 {
    color: var(--brand-dark);
    font-weight: 900;
}
.home-auth-card p,
.branded-auth .auth-card p {
    color: #53645f;
}
.auth-field {
    min-height: 58px;
    border-color: #cadad3;
    background: rgba(255,255,255,.84);
}
.home-auth-actions .btn,
.branded-auth .btn-primary {
    min-height: 50px;
}
.admin-corner-link,
.teacher-corner-link {
    color: var(--brand-dark);
    border-color: rgba(255,255,255,.72);
    box-shadow: var(--shadow-sm);
}

.admin-shell,
.student-shell {
    background:
        linear-gradient(180deg, rgba(229,246,239,.8), transparent 320px),
        var(--soft);
}
.admin-sidebar,
.student-sidebar {
    background: linear-gradient(180deg, #0e352f, #143f38 54%, #102b27);
    box-shadow: inset -1px 0 0 rgba(255,255,255,.08);
}
.admin-sidebar .nav-link,
.student-nav-link {
    min-height: 42px;
    color: rgba(255,255,255,.76);
    border: 1px solid transparent;
}
.admin-sidebar .nav-link.active,
.admin-sidebar .nav-link:hover,
.student-nav-link.active,
.student-nav-link:hover {
    color: #fff;
    border-color: rgba(255,255,255,.12);
    background: rgba(255,255,255,.13);
}
.student-brand,
.admin-sidebar .brand {
    color: #fff;
    letter-spacing: 0;
}
.sidebar-toggle {
    box-shadow: var(--shadow-sm);
    background: var(--brand-dark);
}
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(8, 21, 18, .5);
    backdrop-filter: blur(2px);
}
.sidebar-backdrop[hidden] { display: none; }

.admin-main,
.student-main {
    padding: clamp(18px, 3vw, 34px);
}
.topbar,
.dashboard-head,
.student-topbar,
.test-header {
    padding: 4px 0 8px;
    align-items: flex-start;
}
.topbar h1,
.dashboard-head h1,
.student-topbar h1,
.test-header h1 {
    color: #152520;
    font-size: clamp(1.55rem, 2.6vw, 2.25rem);
    line-height: 1.05;
}
.eyebrow {
    color: var(--brand) !important;
    letter-spacing: .08em;
}

.panel,
.student-panel,
.hero-panel,
.auth-card,
.subject-card,
.test-question,
.review-card,
.stat-card,
.student-stat-card,
.student-course-tile,
.course-card,
.chapter-block,
.doubt-thread,
.inbox-thread {
    border-color: rgba(192, 211, 202, .92);
    background: rgba(255,255,255,.88);
    box-shadow: var(--shadow-sm);
}
.panel,
.student-panel {
    padding: clamp(16px, 2.2vw, 24px);
}
.panel h2,
.student-panel h2,
.subject-card h2,
.test-question h2,
.review-card h2 {
    color: #1b2a26;
    font-weight: 850;
}

.stat-card,
.student-stat-card {
    position: relative;
    overflow: hidden;
    min-height: 118px;
    padding: 20px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card::after,
.student-stat-card::after {
    content: "";
    position: absolute;
    right: -34px;
    top: -34px;
    width: 92px;
    height: 92px;
    border-radius: 999px;
    background: rgba(18,135,111,.11);
}
.stat-card:hover,
.student-stat-card:hover,
.student-course-tile:hover,
.course-card:hover {
    transform: translateY(-2px);
    border-color: #9dc8ba;
    box-shadow: var(--shadow-md);
}
.stat-card span,
.student-stat-card span {
    color: #687872;
    font-size: .84rem;
    font-weight: 750;
    text-transform: uppercase;
}
.stat-card strong,
.student-stat-card strong {
    margin-top: 12px;
    color: var(--brand-dark);
    font-size: clamp(2rem, 4vw, 2.65rem);
    font-weight: 900;
}
.student-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.quick-actions {
    padding-top: 4px;
}

.student-course-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.student-course-tile,
.course-card {
    align-content: start;
    justify-items: start;
    min-height: 176px;
    padding: 18px;
    text-align: left;
}
.student-course-tile img,
.course-card img {
    width: 84px;
    height: 84px;
    border-radius: 8px;
    border-color: #d9e6df;
}
.student-course-tile strong,
.course-card h3 {
    color: #152520;
    line-height: 1.2;
}
.course-card p,
.course-card small,
.student-course-tile small {
    line-height: 1.4;
}
.course-hero,
.result-hero,
.test-series-icon {
    background: linear-gradient(135deg, #0f4f45, #12876f 72%, #d98c39);
    box-shadow: var(--shadow-md);
}
.subject-section {
    padding: 18px;
    border: 1px solid rgba(192,211,202,.9);
    border-radius: 8px;
    background: rgba(255,255,255,.72);
}
.chapter-block {
    padding: 16px;
}
.class-row {
    align-items: flex-start;
    background: linear-gradient(180deg, #fff, #f7fbf8);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.class-row:hover {
    border-color: #9dc8ba;
    box-shadow: var(--shadow-sm);
}
.class-row h3 {
    color: #162722;
    font-size: 1.05rem;
}
.class-actions .btn {
    min-width: 76px;
}

.table-responsive {
    border-radius: 8px;
}
.table {
    margin-bottom: 0;
}
.table thead th {
    color: #52615d;
    font-size: .78rem;
    font-weight: 850;
    text-transform: uppercase;
    background: #f2f8f4;
    border-bottom: 1px solid var(--line);
}
.table tbody td {
    border-color: #edf3ef;
}
.table tbody tr:hover {
    background: #f9fcfa;
}

.exam-shell {
    background: #eef6f1;
}
.exam-topbar {
    min-height: 58px;
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
}
.exam-topbar strong {
    border-radius: 8px;
    background: var(--brand);
}
.exam-instruction {
    border-color: #b9d8cc;
    border-radius: 8px;
    background: #f7fbf8;
}
.exam-question-area {
    padding: clamp(14px, 2.5vw, 26px);
}
.exam-question {
    min-height: 54vh;
    border: 1px solid #dfe8e3;
    box-shadow: var(--shadow-sm);
}
.answer-option {
    background: #fff;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.answer-option:hover {
    border-color: #9dc8ba;
    background: #fbfdfb;
}
.answer-option:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
}
.exam-actions {
    gap: 10px;
    flex-wrap: wrap;
}
.exam-palette {
    background: #f7fbf8;
    border-left: 1px solid var(--line);
}
.palette-grid {
    gap: 8px;
}
.palette-btn {
    min-height: 38px;
    border-radius: 8px;
}
.palette-btn.active {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.timer-pill {
    background: #14352f;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 900px) {
    .sidebar-toggle {
        top: 12px;
        left: 12px;
        z-index: 1120;
    }
    .admin-shell,
    .student-shell {
        display: block;
    }
    .admin-sidebar,
    .student-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1110;
        width: min(86vw, 320px);
        min-height: 100svh;
        overflow-y: auto;
        transform: translateX(-102%);
        transition: transform .22s ease;
        padding-top: 64px;
    }
    body.sidebar-open .site-sidebar {
        transform: translateX(0);
    }
    body.sidebar-collapsed .site-sidebar {
        display: flex;
    }
    body.sidebar-collapsed .admin-main,
    body.sidebar-collapsed .student-main {
        padding-left: clamp(18px, 3vw, 34px);
    }
    .admin-sidebar .nav,
    .student-nav {
        display: grid !important;
        grid-template-columns: 1fr;
        overflow: visible;
    }
    .admin-main,
    .student-main {
        padding-top: 66px;
    }
    .student-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .class-row {
        display: grid;
        grid-template-columns: 1fr;
    }
    .class-actions {
        justify-content: flex-start;
    }
    .exam-body {
        grid-template-columns: 1fr;
    }
    .exam-palette {
        order: -1;
        border-left: 0;
        border-bottom: 1px solid var(--line);
    }
    .palette-grid {
        grid-template-columns: repeat(8, minmax(34px, 1fr));
    }
}

@media (max-width: 720px) {
    .home-auth,
    .branded-auth {
        place-items: center;
        padding: 20px;
        background-position: 42% center;
    }
    .home-auth-card,
    .branded-auth .auth-card {
        padding: 26px 20px;
    }
    .student-stats,
    .student-course-grid,
    .test-grid,
    .test-grid-wide {
        grid-template-columns: 1fr;
    }
    .topbar,
    .dashboard-head,
    .student-topbar,
    .test-header,
    .subject-section-head,
    .doubt-head {
        display: grid;
        grid-template-columns: 1fr;
    }
    .quick-actions .btn,
    .home-auth-actions .btn {
        width: 100%;
    }
    .responsive-table thead {
        display: none;
    }
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }
    .responsive-table tr {
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        box-shadow: var(--shadow-sm);
    }
    .responsive-table td {
        display: grid;
        grid-template-columns: minmax(110px, 38%) minmax(0, 1fr);
        gap: 10px;
        padding: 8px 0;
        border: 0;
        word-break: break-word;
    }
    .responsive-table td::before {
        content: attr(data-label);
        color: #687872;
        font-size: .76rem;
        font-weight: 850;
        text-transform: uppercase;
    }
    .responsive-table td:empty {
        display: none;
    }
    .exam-topbar {
        grid-template-columns: 1fr;
    }
    .palette-grid {
        grid-template-columns: repeat(5, minmax(34px, 1fr));
    }
    .result-summary-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .admin-shell { display: block; }
    .admin-sidebar { position: relative; width: 100%; min-height: auto; }
    .admin-sidebar .nav { flex-direction: row !important; overflow-x: auto; }
    .admin-main { padding: 18px; }
    .student-shell { display: block; }
    .student-sidebar {
        position: relative;
        min-height: auto;
    }
    .student-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .logout-link { margin-top: 8px; }
    .student-main { padding: 18px; }
    .student-stats { grid-template-columns: 1fr; }
    .inbox-layout { grid-template-columns: 1fr; }
    .student-course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-responsive { overflow-x: auto; }
    .exam-body { grid-template-columns: 1fr; }
    .exam-palette { order: -1; }
    .exam-topbar { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    body { font-size: 15px; }
    .topbar, .dashboard-head, .test-header { display: block; }
    .topbar .btn, .dashboard-head .btn { margin-top: 12px; }
    .hero { padding-top: 42px; }
    .auth-card, .panel, .subject-card, .test-question, .review-card { padding: 16px; }
    .branded-auth {
        place-items: center;
        padding: 24px;
        background-position: 42% center;
    }
    .branded-auth .auth-card {
        padding: 30px 22px;
        border-radius: 14px;
    }
    .home-auth {
        place-items: center;
        padding: 24px;
        background-position: 42% center;
    }
    .home-auth-actions {
        flex-direction: column;
    }
    .home-auth-card { width: min(100%, 380px); padding: 22px; }
    .home-auth-actions .btn { width: 100%; }
    .course-hero, .class-row { display: block; }
    .course-card img, .course-hero img { margin-bottom: 12px; }
    .class-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        justify-content: stretch;
        margin-top: 12px;
    }
    .class-actions .btn, .class-actions form, .class-actions form .btn { width: 100%; }
    .student-course-grid { grid-template-columns: 1fr; }
    .student-nav { grid-template-columns: 1fr; }
    .student-nav-link, .admin-sidebar .nav-link { min-height: 44px; }
    .admin-sidebar .nav { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-sidebar .nav-link { white-space: normal; }
    .course-hero img { width: 84px; height: 84px; }
    .course-hero h1, .student-topbar h1, .dashboard-head h1, .topbar h1 { font-size: 1.55rem; }
    .d-flex.gap-2, form.d-flex { flex-wrap: wrap; }
    form.d-flex .form-select, form.d-flex .form-control { min-width: 180px; }
    .test-grid { grid-template-columns: 1fr; }
    .answer-line span { display: block; margin-left: 0; margin-top: 4px; }
    .sticky-submit .btn { width: 100%; }
    .exam-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
    .palette-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 430px) {
    .admin-main, .student-main { padding: 12px; }
    .panel, .student-panel { padding: 14px; }
    .admin-sidebar, .student-sidebar { padding: 14px; }
    .admin-sidebar .nav { grid-template-columns: 1fr; }
    .class-actions { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar-toggle {
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1120;
    }
    .admin-sidebar,
    .student-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1110;
        width: min(86vw, 320px);
        min-height: 100svh;
        padding: 64px 14px 18px;
        overflow-y: auto;
        transform: translateX(-102%);
        transition: transform .22s ease;
    }
    body.sidebar-open .site-sidebar {
        transform: translateX(0);
    }
    body.sidebar-collapsed .site-sidebar {
        display: flex;
    }
    .admin-sidebar .nav,
    .student-nav {
        display: grid !important;
        grid-template-columns: 1fr;
        overflow: visible;
    }
    .admin-main,
    .student-main,
    body.sidebar-collapsed .admin-main,
    body.sidebar-collapsed .student-main {
        padding: 66px 18px 18px;
    }
    .table-responsive {
        overflow: visible;
    }
}

@media (max-width: 430px) {
    .admin-main,
    .student-main,
    body.sidebar-collapsed .admin-main,
    body.sidebar-collapsed .student-main {
        padding: 66px 12px 12px;
    }
    .admin-sidebar,
    .student-sidebar {
        width: min(90vw, 315px);
        padding-top: 64px;
    }
}
