:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-soft: #eef5ff;
    --text: #10213f;
    --muted: #69758c;
    --line: #dbe4ef;
    --primary: #073c9e;
    --primary-strong: #052b73;
    --accent: #f5b400;
    --teal: #08aeb8;
    --danger: #c7374f;
    --success: #138a62;
    --shadow: 0 18px 50px rgba(15, 33, 63, 0.11);
    --radius: 18px;
}

[data-theme="dark"] {
    --bg: #101827;
    --surface: #172235;
    --surface-soft: #1d314d;
    --text: #f4f7fb;
    --muted: #aab6c9;
    --line: #2a3a55;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

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

.policy-page {
    min-height: 100vh;
    background: var(--bg);
}

.policy-shell {
    width: min(100% - 32px, 900px);
    margin: 0 auto;
    padding: 48px 0;
}

.policy-card {
    line-height: 1.7;
}

.policy-card h1 {
    margin: 0 0 18px;
    font-size: 34px;
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: url("../img/login-bg.jpg") center / cover no-repeat;
    position: relative;
}

.auth-page::before {
    content: none;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: min(100%, 440px);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 34px;
}

.auth-logo {
    width: 210px;
    max-width: 100%;
    display: block;
    margin-bottom: 26px;
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 30px;
}

.auth-card p {
    margin: 0 0 24px;
    color: var(--muted);
}

.form-group {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.form-group label {
    font-weight: 700;
    font-size: 14px;
}

.form-control {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 14px;
    color: var(--text);
    background: var(--surface);
    font: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    border: 0;
    border-radius: 999px;
    padding: 0 20px;
    background: linear-gradient(135deg, var(--primary), var(--teal));
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 14px 28px rgba(7, 60, 158, 0.22);
}

.button.full {
    width: 100%;
}

.secondary-button {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--line);
    box-shadow: none;
}

.google-button {
    background: #fff;
    color: #1f2937;
    border: 1px solid var(--line);
    box-shadow: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--muted);
    font-weight: 800;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-link,
.auth-note {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.auth-link a {
    color: var(--primary);
    font-weight: 800;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #071f4b;
    color: #fff;
    padding: 24px 16px;
    z-index: 30;
}

.brand {
    display: block;
    background: #fff;
    border-radius: 18px;
    padding: 12px;
    margin-bottom: 24px;
}

.brand img {
    width: 100%;
    display: block;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    border-radius: 14px;
    padding: 0 14px;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 700;
}

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

.main-area {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 28px;
    background: rgba(246, 248, 251, 0.88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

[data-theme="dark"] .topbar {
    background: rgba(16, 24, 39, 0.88);
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar h1 {
    margin: 0;
    font-size: 25px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-button {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
}

.user-chip span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--teal));
    color: #071f4b;
    font-weight: 900;
}

.content {
    padding: 28px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.metric {
    display: grid;
    gap: 10px;
}

.metric i {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--primary);
}

.metric strong {
    font-size: 30px;
}

.metric span {
    color: var(--muted);
    font-weight: 700;
}

.section-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 18px;
    margin-top: 18px;
}

.list {
    display: grid;
    gap: 12px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.list-item.stacked {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
}

.list-item small {
    color: var(--muted);
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    background: var(--surface-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

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

.section-heading h2,
.card h2 {
    margin: 0;
}

.filters {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 160px 150px auto;
    gap: 10px;
    margin-bottom: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

table.compact-table {
    min-width: 0;
}

.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 28px;
    background: #fff7ed;
    border-bottom: 1px solid #fed7aa;
    color: #7c2d12;
}

.impersonation-banner span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.impersonation-banner form {
    margin: 0;
}

.danger-button {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
}

.rich-editor-shell {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
}

.rich-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.rich-editor {
    min-height: 320px;
    padding: 18px 22px;
    line-height: 1.7;
    outline: none;
    overflow: auto;
}

.rich-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
}

.rich-editor img,
.lesson-content img {
    max-width: 100%;
    height: auto;
}

.rich-editor video,
.rich-editor audio,
.lesson-content video,
.lesson-content audio {
    max-width: 100%;
    margin: 12px 0;
}

.rich-editor figure,
.lesson-content figure {
    margin: 18px 0;
}

.rich-editor figcaption,
.lesson-content figcaption {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.rich-editor-shell.is-fullscreen {
    position: fixed;
    inset: 18px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
    overflow: auto;
}

.rich-editor-shell.is-fullscreen .rich-editor {
    min-height: 0;
    height: auto;
    flex: 1 0 auto;
    min-height: calc(100vh - 130px);
    font-size: 18px;
    padding: 32px;
    width: 100%;
    max-width: none;
    column-count: 1;
    white-space: normal;
    overflow: visible;
}

.rich-editor-shell.is-fullscreen .rich-editor table,
.rich-editor-shell.is-fullscreen .rich-editor thead,
.rich-editor-shell.is-fullscreen .rich-editor tbody,
.rich-editor-shell.is-fullscreen .rich-editor tr,
.rich-editor-shell.is-fullscreen .rich-editor th,
.rich-editor-shell.is-fullscreen .rich-editor td {
    display: block;
    width: 100% !important;
    max-width: none !important;
    border: 0;
    padding: 0;
}

.rich-editor-shell.is-fullscreen .rich-editor p,
.rich-editor-shell.is-fullscreen .rich-editor div,
.rich-editor-shell.is-fullscreen .rich-editor blockquote,
.rich-editor-shell.is-fullscreen .rich-editor li {
    width: auto !important;
    max-width: 1100px !important;
    margin-left: 0 !important;
    margin-right: auto !important;
    text-align: left;
}

.rich-editor-shell.is-fullscreen .rich-editor > div,
.rich-editor-shell.is-fullscreen .rich-editor > p,
.rich-editor-shell.is-fullscreen .rich-editor > blockquote,
.rich-editor-shell.is-fullscreen .rich-editor > ul,
.rich-editor-shell.is-fullscreen .rich-editor > ol,
.rich-editor-shell.is-fullscreen .rich-editor > h1,
.rich-editor-shell.is-fullscreen .rich-editor > h2,
.rich-editor-shell.is-fullscreen .rich-editor > h3,
.rich-editor-shell.is-fullscreen .rich-editor > h4,
.rich-editor-shell.is-fullscreen .rich-editor > figure {
    width: min(100%, 1100px) !important;
    max-width: 1100px !important;
}

body.rich-editor-open {
    overflow: hidden;
}

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

.certificate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.certificate-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fff;
}

.certificate-card h3 {
    margin: 6px 0 12px;
}

.certificate-preview {
    min-height: 520px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 8px double rgba(7, 60, 158, 0.22);
}

.certificate-preview h2 {
    font-size: 34px;
    margin: 8px 0 18px;
}

.certificate-preview strong {
    font-size: 30px;
    color: var(--primary);
}

.certificate-preview p {
    max-width: 720px;
    line-height: 1.8;
}

.certificate-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    margin-top: 18px;
}

.certificate-signature {
    margin-top: 48px;
    border-top: 1px solid var(--primary);
    padding-top: 10px;
    min-width: 240px;
}

.certificate-signature strong,
.certificate-signature span {
    display: block;
    font-size: 14px;
}

.certificate-verification img {
    width: 160px;
    margin-bottom: 18px;
}

th,
td {
    text-align: left;
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.actions form {
    margin: 0;
}

.icon-button.danger {
    color: var(--danger);
}

.admin-users-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 18px;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.full-span {
    grid-column: 1 / -1;
}

.textarea {
    min-height: 118px;
    padding-top: 12px;
    resize: vertical;
}

.textarea.tall {
    min-height: 180px;
}

.settings-panel {
    max-width: 960px;
}

.compact-grid {
    gap: 10px;
}

.course-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.course-hero p {
    color: var(--muted);
    margin-bottom: 0;
}

.builder-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
}

.builder-forms {
    display: grid;
    gap: 18px;
}

.module-list {
    display: grid;
    gap: 14px;
}

.module-block {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
}

.module-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    background: var(--surface-soft);
}

.module-title small,
td small {
    color: var(--muted);
    font-weight: 700;
}

.lesson-list {
    display: grid;
}

.lesson-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
}

.progress-mini {
    width: 92px;
    height: 9px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.progress-mini.wide {
    width: min(100%, 320px);
    margin-top: 12px;
}

.progress-mini span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--primary), var(--teal));
}

.compact-select {
    min-height: 40px;
    min-width: 130px;
}

.course-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.course-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.course-thumb {
    aspect-ratio: 16 / 8;
    display: grid;
    place-items: center;
    background: var(--surface-soft);
    color: var(--primary);
    font-size: 42px;
}

.course-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-card-body {
    padding: 18px;
}

.course-card-body h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.course-card-body p {
    min-height: 44px;
    color: var(--muted);
}

.course-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.player-layout {
    display: grid;
    grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
    gap: 18px;
}

.player-sidebar {
    align-self: start;
    position: sticky;
    top: 104px;
}

.player-module {
    display: grid;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.player-lesson {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--muted);
}

.player-lesson.is-active,
.player-lesson:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.player-lesson small {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 11px;
}

.lesson-panel h2 {
    margin-top: 0;
    font-size: 30px;
}

.lesson-content {
    margin-top: 18px;
    line-height: 1.8;
    color: var(--text);
}

.video-shell {
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    margin: 18px 0;
}

.video-shell iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.player-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.player-actions form {
    margin: 0;
}

.assignment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.quiz-shell {
    max-width: 980px;
}

.timer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    min-height: 40px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--primary);
    font-weight: 900;
}

.question-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    margin: 18px 0;
}

.question-card h3 {
    margin: 0 0 14px;
}

.answer-builder {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}

.answer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    font-weight: 700;
}

.question-list {
    margin-top: 18px;
}

.alert {
    border-radius: 14px;
    padding: 13px 14px;
    margin-bottom: 16px;
    font-weight: 700;
}

.alert.error {
    background: rgba(199, 55, 79, 0.12);
    color: var(--danger);
}

.alert.success {
    background: rgba(19, 138, 98, 0.12);
    color: var(--success);
}

.mobile-only {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1080px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .section-grid {
        grid-template-columns: 1fr;
    }

    .admin-users-grid,
    .builder-grid,
    .player-layout,
    .filters,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .player-sidebar {
        position: static;
    }

    .course-hero,
    .module-title,
    .lesson-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .mobile-only {
        display: inline-grid;
    }

    .sidebar {
        position: fixed;
        transform: translateX(-105%);
        transition: transform 180ms ease;
        width: min(86vw, 300px);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(7, 31, 75, 0.42);
        z-index: 25;
    }

    .topbar {
        padding: 14px 16px;
    }

    .content {
        padding: 18px 16px 28px;
    }

    .user-chip strong {
        display: none;
    }
}

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

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

    .player-actions,
    .course-card-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .auth-card {
        padding: 24px;
    }
}
