:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #667085;
    --line: #d8dee8;
    --primary: #116149;
    --primary-dark: #0d4e3a;
    --danger: #b42318;
    --warning: #9a6700;
    --ok: #137333;
    --focus: #2563eb;
}

* {
    box-sizing: border-box;
}

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

html.anti-cheat-active,
html.anti-cheat-active body,
html.anti-cheat-active .exam-layout,
html.anti-cheat-active .question-card,
html.anti-cheat-active .option {
    -webkit-user-select: none;
    user-select: none;
}

body.print-blocked * {
    visibility: hidden !important;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0 0 16px;
    letter-spacing: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
    margin-top: 24px;
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

button:hover, .button:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

button.secondary, .button.secondary, button.ghost {
    background: #fff;
    color: var(--primary);
}

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

input, select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    padding: 8px 10px;
}

textarea {
    resize: vertical;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.25);
    border-color: var(--focus);
}

label {
    display: grid;
    gap: 6px;
    font-weight: 650;
}

label input[type="checkbox"] {
    width: auto;
    min-height: auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 60px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.nav a {
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 650;
}

.nav a.active, .nav a:hover {
    background: #e7f2ee;
    color: var(--primary);
    text-decoration: none;
}

.session-box {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.auth-panel, .work-area {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 8px 22px rgba(16, 24, 40, 0.05);
}

.auth-panel, .narrow {
    width: min(560px, 100%);
    margin: 0 auto;
}

.stack {
    display: grid;
    gap: 14px;
}

.grid {
    display: grid;
    gap: 14px;
}

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

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

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

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

.alert {
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #fff;
}

.alert.danger {
    border-color: #f3b7b1;
    background: #fff1f0;
    color: var(--danger);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(520px, calc(100% - 36px));
    padding: 12px 14px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    z-index: 100;
}

.toast.error {
    background: var(--danger);
}

.editor-panel {
    display: grid;
    gap: 14px;
    margin-bottom: 22px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 18px;
}

.checks, .actions, .filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.picker label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-weight: 500;
}

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

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

.card {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}

.card h3 {
    margin: 0;
    font-size: 17px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #344054;
    font-size: 13px;
    font-weight: 650;
}

.pill.ok {
    background: #e7f6ec;
    color: var(--ok);
}

.pill.bad {
    background: #fff1f0;
    color: var(--danger);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

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

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

th {
    background: #f8fafc;
    color: #344054;
    font-size: 13px;
}

tr:last-child td {
    border-bottom: 0;
}

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

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

.stat strong {
    display: block;
    font-size: 24px;
}

.exam-layout {
    display: grid;
    gap: 16px;
}

.proctor-overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(17, 24, 39, 0.64);
    backdrop-filter: blur(10px);
}

.proctor-overlay[hidden] {
    display: none;
}

.exam-layout.mobile-blur-active .exam-content {
    filter: blur(8px);
    pointer-events: none;
}

.proctor-warning {
    position: fixed;
    top: 76px;
    right: 18px;
    z-index: 80;
    width: min(420px, calc(100% - 36px));
    padding: 12px 14px;
    border: 1px solid #f2c94c;
    border-radius: 8px;
    background: #fff8db;
    color: #694d00;
    box-shadow: 0 12px 30px rgba(16, 24, 40, 0.16);
    font-weight: 650;
}

.proctor-warning[hidden] {
    display: none;
}

.proctor-dialog {
    width: min(520px, 100%);
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.proctor-dialog p {
    margin: 0 0 18px;
    color: var(--muted);
}

.proctor-dialog h1 {
    font-size: 24px;
}

@media print {
    body * {
        visibility: hidden !important;
    }
}

.exam-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.timer {
    min-width: 120px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    text-align: center;
    font-size: 24px;
    font-weight: 800;
}

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

.question-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.question-card img {
    max-width: 100%;
    max-height: 380px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfe;
    font-weight: 500;
}

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

.exam-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    padding: 12px 0;
    background: linear-gradient(180deg, transparent, var(--bg) 35%);
}

.result-box {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

@media (max-width: 800px) {
    .topbar, .split-head, .exam-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .session-box {
        flex-wrap: wrap;
    }

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

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