
:root {
    --navy: #14213d;
    --navy-2: #1f315d;
    --blue: #2f6fed;
    --blue-dark: #2458bd;
    --cyan: #0ea5a8;
    --gold: #d7a52a;
    --rose: #9b2449;

    --background: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8faff;

    --text: #172033;
    --muted: #697386;
    --border: #dfe5ef;

    --success: #16865b;
    --danger: #c83d4b;
    --warning: #b7791f;

    --sidebar-width: 272px;
    --topbar-height: 86px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --shadow: 0 12px 30px rgba(20, 33, 61, 0.08);
    --shadow-lg: 0 24px 70px rgba(20, 33, 61, 0.14);
}

/* =========================================================
   RESET
   ========================================================= */

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

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family:
        Inter,
        "Segoe UI",
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
}

body.sidebar-open {
    overflow: hidden;
}

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

img {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* =========================================================
   MAIN ADMIN LAYOUT
   ========================================================= */

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

/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;

    position: sticky;
    top: 0;

    display: flex;
    flex-direction: column;

    padding: 20px 14px;

    background:
        radial-gradient(
            circle at top left,
            rgba(47, 111, 237, 0.18),
            transparent 32%
        ),
        linear-gradient(
            165deg,
            var(--navy) 0%,
            var(--navy-2) 100%
        );

    color: #ffffff;

    overflow: hidden;
    z-index: 100;
}

/* Logo block */

.brand {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    gap: 12px;

    min-height: 78px;
    padding: 4px 8px 18px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand img {
    flex: 0 0 56px;

    width: 56px;
    height: 56px;

    object-fit: contain;

    padding: 5px;

    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.brand div {
    min-width: 0;
}

.brand strong {
    display: block;

    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.25;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand span {
    display: block;
    margin-top: 3px;

    color: #cfd8ec;
    font-size: 0.78rem;
    line-height: 1.3;
}

/* Scrollable menu */

.nav {
    flex: 1 1 auto;
    min-height: 0;

    display: flex;
    flex-direction: column;
    gap: 4px;

    margin-top: 12px;
    padding: 0 5px 18px 0;

    overflow-x: hidden;
    overflow-y: auto;

    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.nav::-webkit-scrollbar {
    width: 6px;
}

.nav::-webkit-scrollbar-track {
    background: transparent;
}

.nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
}

.nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Menu category headings */

.nav-group {
    flex: 0 0 auto;

    margin-top: 8px;
    padding: 11px 12px 5px;

    color: #9fb0d1;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.11em;
}

/* Menu links */

.nav a {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    gap: 10px;

    width: 100%;
    min-height: 42px;

    padding: 10px 12px;

    color: #edf2ff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;

    border-radius: 9px;

    white-space: normal;
    overflow-wrap: anywhere;

    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.nav a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
}

.nav a.active {
    color: #ffffff;
    background: linear-gradient(
        90deg,
        rgba(47, 111, 237, 0.98),
        rgba(47, 111, 237, 0.7)
    );
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

/* Fixed bottom account section */

.sidebar-footer {
    flex: 0 0 auto;

    display: grid;
    gap: 5px;

    padding-top: 12px;

    border-top: 1px solid rgba(255, 255, 255, 0.14);

    background: linear-gradient(
        180deg,
        rgba(31, 49, 93, 0),
        rgba(31, 49, 93, 0.95) 22%
    );
}

.sidebar-footer a {
    display: flex;
    align-items: center;

    width: 100%;
    min-height: 42px;

    padding: 10px 12px;

    color: #edf2ff;
    font-size: 0.9rem;
    font-weight: 600;

    border-radius: 9px;

    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.sidebar-footer a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer .danger-link {
    color: #ffd9dd;
    background: rgba(200, 61, 75, 0.12);
}

.sidebar-footer .danger-link:hover {
    color: #ffffff;
    background: var(--danger);
}

/* Mobile overlay */

.sidebar-overlay {
    display: none;
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */

.main {
    min-width: 0;
    width: 100%;
}

.topbar {
    min-height: var(--topbar-height);

    position: sticky;
    top: 0;
    z-index: 40;

    display: flex;
    align-items: center;
    gap: 15px;

    padding: 16px 28px;

    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);

    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0;

    color: var(--navy);
    font-size: 1.32rem;
    line-height: 1.25;
}

.topbar p {
    margin: 4px 0 0;

    color: var(--muted);
    font-size: 0.88rem;
}

.role-badge {
    margin-left: auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 8px 12px;

    color: #274690;
    background: #e7edff;

    border: 1px solid #d1dcff;
    border-radius: 999px;

    font-size: 0.78rem;
    font-weight: 800;
}

.menu-button {
    display: none;

    width: 42px;
    height: 42px;

    align-items: center;
    justify-content: center;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: #ffffff;
    color: var(--navy);

    font-size: 1.35rem;
    cursor: pointer;
}

.content {
    width: 100%;
    padding: 28px;
}

/* =========================================================
   DASHBOARD CARDS
   ========================================================= */

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

.card {
    position: relative;

    padding: 20px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 17px;

    box-shadow: var(--shadow);
}

.stat-card {
    min-height: 125px;
    overflow: hidden;
}

.stat-card::after {
    content: "";

    position: absolute;
    top: -22px;
    right: -22px;

    width: 82px;
    height: 82px;

    border-radius: 50%;
    background: rgba(47, 111, 237, 0.08);
}

.stat-card span {
    color: var(--muted);
    font-size: 0.88rem;
}

.stat-card strong {
    display: block;
    margin-top: 8px;

    color: var(--navy);
    font-size: 2rem;
    line-height: 1.2;
}

/* =========================================================
   SECTION HEADINGS
   ========================================================= */

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    margin: 25px 0 13px;
}

.section-title h2 {
    margin: 0;

    color: var(--navy);
    font-size: 1.08rem;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    min-height: 40px;

    padding: 10px 15px;

    border: 0;
    border-radius: 10px;

    background: #e7ebf2;
    color: var(--text);

    font-weight: 750;
    line-height: 1;

    cursor: pointer;

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background-color 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(20, 33, 61, 0.12);
}

.btn-primary {
    color: #ffffff;
    background: var(--blue);
}

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

.btn-secondary {
    color: #ffffff;
    background: var(--navy);
}

.btn-success {
    color: #ffffff;
    background: var(--success);
}

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

.btn-warning {
    color: #342600;
    background: #f2c14e;
}

.btn-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.8rem;
}

/* =========================================================
   TABLES
   ========================================================= */

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 13px;

    text-align: left;
    vertical-align: middle;

    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    background: #fafbfe;

    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;

    white-space: nowrap;
}

tbody tr:hover {
    background: #fafcff;
}

/* =========================================================
   BADGES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 5px 9px;

    border-radius: 999px;

    font-size: 0.75rem;
    font-weight: 800;
}

.badge-success {
    color: #126442;
    background: #daf7ea;
}

.badge-danger {
    color: #9f2633;
    background: #ffe2e5;
}

.badge-warning {
    color: #8b5c00;
    background: #fff2cf;
}

.badge-info {
    color: #2351a2;
    background: #e2ecff;
}

/* =========================================================
   FORMS
   ========================================================= */

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

.form-group {
    display: grid;
    gap: 7px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;

    padding: 11px 12px;

    color: var(--text);
    background: #ffffff;

    border: 1px solid #ccd5e4;
    border-radius: 10px;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(47, 111, 237, 0.12);
    border-color: var(--blue);
}

input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    background: #f1f4f8;
    color: #8a94a6;
}

/* =========================================================
   ALERTS
   ========================================================= */

.alert {
    padding: 13px 15px;
    margin-bottom: 17px;

    border: 1px solid transparent;
    border-radius: 11px;
}

.alert-success {
    color: #11613f;
    background: #ecfbf4;
    border-color: #bfead5;
}

.alert-danger {
    color: #9e2631;
    background: #fff0f2;
    border-color: #ffcbd1;
}

.alert-warning {
    color: #815600;
    background: #fff8e4;
    border-color: #f7dda0;
}

.alert-info {
    color: #234f99;
    background: #edf4ff;
    border-color: #c7d9fa;
}

/* =========================================================
   UTILITIES
   ========================================================= */

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

.note {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.55;
}

.filters {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.filters .form-group {
    min-width: 170px;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */

.login-page {
    min-height: 100vh;

    display: grid;
    place-items: center;

    padding: 20px;

    background:
        radial-gradient(
            circle at top right,
            rgba(47, 111, 237, 0.35),
            transparent 35%
        ),
        linear-gradient(
            145deg,
            #0d1831,
            #243d74
        );
}

.login-card {
    width: min(430px, 100%);

    padding: 30px;

    background: rgba(255, 255, 255, 0.98);

    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
}

.login-brand {
    margin-bottom: 23px;
    text-align: center;
}

.login-brand img {
    width: 86px;
    height: 86px;

    object-fit: contain;

    padding: 6px;

    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 20px;
}

.login-brand h1 {
    margin: 12px 0 3px;
    color: var(--navy);
}

.login-brand p {
    margin: 0;
    color: var(--muted);
}

/* =========================================================
   QUIZ PAGE
   ========================================================= */

.quiz-body {
    background: #edf2f8;
}

.quiz-header {
    position: sticky;
    top: 0;
    z-index: 60;

    padding: 18px 24px;

    color: #ffffff;

    background:
        linear-gradient(
            120deg,
            var(--navy),
            var(--blue)
        );

    box-shadow: 0 8px 24px rgba(20, 33, 61, 0.16);
}

.quiz-header-inner {
    width: 100%;
    max-width: 1180px;

    display: flex;
    align-items: center;
    gap: 16px;

    margin: auto;
}

.quiz-header img {
    width: 48px;
    height: 48px;

    object-fit: contain;

    padding: 4px;

    background: #ffffff;
    border-radius: 12px;
}

.quiz-header .timer {
    margin-left: auto;

    padding: 10px 15px;

    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;

    font-weight: 900;
    letter-spacing: 0.04em;
}

.quiz-wrap {
    width: 100%;
    max-width: 1180px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 20px;

    margin: 24px auto;
    padding: 0 18px;
}

.question-card {
    padding: 24px;

    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 18px;

    box-shadow: var(--shadow);
}

.question-card h2 {
    color: var(--navy);
    line-height: 1.55;
}

.question-media {
    display: block;

    max-width: 100%;
    max-height: 330px;

    margin: 14px auto;

    object-fit: contain;
    border-radius: 12px;
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 12px;

    padding: 14px;
    margin: 11px 0;

    background: #ffffff;

    border: 1px solid var(--border);
    border-radius: 13px;

    cursor: pointer;

    transition:
        border-color 0.18s ease,
        background-color 0.18s ease,
        transform 0.18s ease;
}

.option:hover {
    background: #f7faff;
    border-color: var(--blue);
    transform: translateX(2px);
}

.option input {
    width: auto;
    margin-top: 4px;
}

.option img {
    max-width: 150px;
    max-height: 110px;

    object-fit: contain;
    border-radius: 8px;
}

.palette {
    height: max-content;

    position: sticky;
    top: 102px;

    padding: 18px;

    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 18px;

    box-shadow: var(--shadow);
}

.palette h3 {
    margin-top: 0;
    color: var(--navy);
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.palette a {
    display: grid;
    place-items: center;

    aspect-ratio: 1;

    color: var(--text);
    background: #e8edf5;

    border-radius: 8px;

    font-size: 0.8rem;
    font-weight: 750;
}

.palette a:hover {
    color: #ffffff;
    background: var(--blue);
}

.palette a.answered {
    color: #ffffff;
    background: var(--success);
}

.palette a.current {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* =========================================================
   RESPONSIVE TABLET
   ========================================================= */

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

    .quiz-wrap {
        grid-template-columns: 1fr;
    }

    .palette {
        position: static;
    }
}

/* =========================================================
   RESPONSIVE MOBILE
   ========================================================= */

@media (max-width: 760px) {
    .app-shell {
        display: block;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: calc(-1 * var(--sidebar-width) - 20px);

        width: var(--sidebar-width);
        height: 100vh;

        transition: left 0.25s ease;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 18px 0 45px rgba(0, 0, 0, 0.28);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 90;

        display: none;

        background: rgba(15, 23, 42, 0.48);
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .menu-button {
        display: inline-flex;
        flex: 0 0 auto;
    }

    .main {
        width: 100%;
        min-width: 0;
    }

    .topbar {
        min-height: 72px;
        padding: 12px 15px;
    }

    .topbar h1 {
        font-size: 1.08rem;
    }

    .topbar p {
        font-size: 0.78rem;
    }

    .role-badge {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-title .actions {
        width: 100%;
    }

    .section-title .actions .btn {
        flex: 1;
    }

    .filters {
        align-items: stretch;
        flex-direction: column;
    }

    .filters .form-group {
        width: 100%;
        min-width: 0;
    }

    .card {
        padding: 16px;
        border-radius: 14px;
    }

    th,
    td {
        padding: 10px;
    }

    .quiz-header {
        padding: 13px 15px;
    }

    .quiz-header-inner {
        align-items: flex-start;
    }

    .quiz-header img {
        width: 42px;
        height: 42px;
    }

    .quiz-header .timer {
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .quiz-wrap {
        margin: 16px auto;
        padding: 0 12px;
    }

    .question-card {
        padding: 17px;
    }

    .palette-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 420px) {
    .sidebar {
        width: 86vw;
        left: calc(-86vw - 20px);
    }

    .topbar {
        gap: 10px;
    }

    .topbar h1 {
        font-size: 1rem;
    }

    .topbar p {
        display: none;
    }

    .actions .btn {
        width: 100%;
    }

    .palette-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
