:root {
    --bg: #f4f4f2;
    --panel: #ffffff;
    --border: #dedede;
    --text: #232428;
    --muted: #6f7177;
    --primary: #f4c600;
    --primary-dark: #d7aa00;
    --primary-soft: #fff7c7;
    --charcoal: #2f3035;
    --charcoal-dark: #1e1f23;
    --grey: #77787d;
    --danger: #b42318;
    --warning: #a76b00;
    --success: #137a4b;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        linear-gradient(180deg, #eeeeec 0, #f7f7f5 300px, #f7f7f5 100%);
    line-height: 1.5;
}
a { color: #5d4a00; text-decoration: none; }
h1, h2 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }

.topbar {
    min-height: 76px;
    max-height: 86px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid #dddddd;
    box-shadow: 0 8px 22px rgba(35, 36, 40, .06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 38px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand {
    font-weight: 800;
    color: var(--charcoal);
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.brand img {
    display: block;
    width: 245px;
    height: 57px;
    max-width: 42vw;
    max-height: 57px;
    object-fit: contain;
}
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar nav a {
    color: var(--text);
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 6px;
}
.topbar nav a:hover { background: #fff7c7; }

.container { max-width: 1240px; margin: 32px auto; padding: 0 22px; }
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: 0 14px 34px rgba(35, 36, 40, .06);
}
.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.section-title h2 { margin-bottom: 4px; }
.action-panel {
    border-color: #e7d47a;
    background: linear-gradient(180deg, #ffffff 0%, #fffdf0 100%);
}
.hero-head, .student-hero {
    background: linear-gradient(135deg, #1f2024 0%, #3a3b40 62%, #f4c600 62%, #f4c600 100%);
    color: #fff;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 22px;
    box-shadow: 0 18px 40px rgba(35, 36, 40, .18);
}
.hero-head .muted, .student-hero p { color: rgba(255,255,255,.82); }
.student-hero h1 { margin-bottom: 8px; }
.eyebrow {
    display: inline-block;
    color: #5b6b7b;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 8px;
}
.hero-head .eyebrow, .student-hero .eyebrow { color: #ffe36a; }
.page-head p { margin: 4px 0 0; }

.form { display: grid; gap: 16px; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}
textarea { resize: vertical; }
.check {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 9px;
}
.check input { width: auto; }
.form-actions, .actions-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.button {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 10px 15px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary { color: #222; }
.button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #171717; }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.warning { background: #fff7ed; border-color: #fed7aa; color: var(--warning); }
.button.small { padding: 6px 9px; min-height: 32px; font-size: 13px; }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: #fff;
}
.alert.success { border-color: #abefc6; background: #ecfdf3; color: var(--success); }
.alert.error { border-color: #fecdca; background: #fef3f2; color: var(--danger); }
.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
}
.badge.pending { background: #eef2f6; color: #364152; }
.badge.warning { background: #fff7ed; color: var(--warning); }
.badge.success { background: #ecfdf3; color: var(--success); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.quick-card {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 12px 26px rgba(35, 36, 40, .06);
    color: var(--text);
}
.quick-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(35, 36, 40, .08);
}
.quick-card.primary {
    background: var(--charcoal);
    border-color: var(--charcoal);
    color: #fff;
}
.quick-card span {
    display: inline-flex;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
}
.quick-card.primary span,
.quick-card.primary small { color: rgba(255,255,255,.72); }
.quick-card strong {
    display: block;
    font-size: 20px;
    margin-bottom: 6px;
}
.quick-card small {
    display: block;
    color: var(--muted);
}
.stats-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 10px 22px rgba(35, 36, 40, .05);
}
.stat span { color: var(--muted); font-size: 13px; }
.stat strong {
    display: block;
    font-size: 24px;
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.filter { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter input[type="text"], .filter input:not([type]), .filter select { max-width: 280px; }
.filter input[type="file"] { max-width: 300px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--border); padding: 12px; text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); background: #f8fafc; text-transform: uppercase; letter-spacing: .04em; }
.retake-form {
    border: 1px solid #cfe5dd;
    background: #f3fbf7;
    border-radius: 8px;
    padding: 12px;
}
.table-wrap tbody tr:hover { background: #fbfdff; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions.stacked {
    align-items: stretch;
    flex-direction: column;
}
.row-actions form { margin: 0; }
.clean-list { margin: 0 0 20px; padding-left: 22px; }

.hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}
.toggle-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.toggle-grid .check {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px;
}

.info-strip, .exam-counts, .mini-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
}
.info-strip div, .exam-counts div, .mini-grid div {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px;
}
.info-strip span, .exam-counts span, .mini-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}
.info-strip strong, .exam-counts strong, .mini-grid strong {
    display: block;
    font-size: 18px;
    overflow-wrap: anywhere;
}
.mini-grid small { color: var(--muted); }
.result-summary {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 20px 0;
    padding: 16px;
    text-align: left;
}
.thankyou-panel {
    max-width: 760px;
    text-align: left;
}
.thankyou-panel h1 {
    font-size: 30px;
}
.thankyou-panel p {
    font-size: 17px;
}

.exam-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.exam-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 14px 32px rgba(35, 36, 40, .06);
}
.exam-card-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 12px;
}
.exam-card h3 {
    margin: 0;
    font-size: 22px;
}
.exam-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}
.exam-meta div, .result-tile {
    border: 1px solid var(--border);
    background: #fbfbfa;
    border-radius: 10px;
    padding: 12px;
}
.exam-meta span, .result-tile span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}
.exam-meta strong, .result-tile strong {
    display: block;
    font-size: 17px;
}
.result-tile {
    margin: 12px 0;
    border-color: #abefc6;
    background: #ecfdf3;
}
.result-tile small { color: #067647; }
.muted-tile {
    border-color: var(--border);
    background: #f8fafc;
}
.muted-tile small { color: var(--muted); }
.instruction-panel {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

.onsite-start {
    min-height: calc(100vh - 130px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 30px;
    align-items: center;
}
.start-copy {
    background:
        linear-gradient(135deg, rgba(15,76,92,.08), rgba(255,255,255,0) 45%),
        #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 38px;
    box-shadow: 0 18px 42px rgba(35, 36, 40, .07);
}
.start-copy h1 {
    font-size: 42px;
    margin-bottom: 10px;
}
.start-copy p {
    color: var(--muted);
    font-size: 18px;
    margin: 0 0 18px;
}
.start-form {
    margin-bottom: 0;
}
.exam-structure {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 22px 0;
}
.exam-structure div {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 6px;
    padding: 14px;
}
.exam-structure strong {
    display: block;
    font-size: 26px;
    color: var(--primary-dark);
}
.exam-structure span {
    color: var(--muted);
    font-size: 13px;
}
.start-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
}
.start-steps div {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 12px;
}
.start-steps span {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 8px;
}
.start-steps strong {
    display: block;
    font-size: 13px;
}

.setup-flow {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.setup-flow div {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(35, 36, 40, .05);
}
.setup-flow strong {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #222;
    margin-bottom: 10px;
}
.setup-flow span {
    display: block;
    font-weight: 800;
}
.setup-flow small {
    color: var(--muted);
}
.readiness-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.readiness-list span {
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
}
.readiness-list .ok { background: #ecfdf3; color: var(--success); }
.readiness-list .bad { background: #fff7ed; color: var(--warning); }
.readiness-panel {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 18px;
    align-items: start;
}
.readiness-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.readiness-cards div {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: #f8fafc;
}
.readiness-cards div.ok { border-color: #abefc6; background: #ecfdf3; }
.readiness-cards div.bad { border-color: #fed7aa; background: #fff7ed; }
.readiness-cards span,
.readiness-cards small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.readiness-cards strong {
    display: block;
    font-size: 22px;
    margin: 4px 0;
}
.small-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 800;
}

.exam-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    user-select: none;
}
.exam-side {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    align-self: start;
    position: sticky;
    top: 78px;
}
.exam-counts {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 0 0 14px;
}
.exam-counts div {
    padding: 10px 8px;
    text-align: center;
}
.exam-counts strong { font-size: 20px; }
.timer {
    background: #111827;
    color: #fff;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 14px;
}
.legend { display: grid; gap: 7px; font-size: 13px; margin-bottom: 14px; }
.dot { display: inline-block; width: 12px; height: 12px; background: #cbd5e1; margin-right: 7px; border-radius: 50%; }
.dot.answered { background: var(--success); }
.dot.skipped { background: #f79009; }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
.palette button {
    height: 38px;
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
}
.palette button.current { outline: 2px solid #111827; }
.palette button.answered { background: #dcfae6; border-color: #75e0a7; }
.palette button.skipped { background: #ffead5; border-color: #fdb022; }

.exam-main {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    min-height: 520px;
}
.question { display: none; }
.question.active { display: block; }
.question-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 18px;
}
.question-text { font-size: 18px; margin-bottom: 18px; }
.options { display: grid; gap: 12px; }
.option {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    grid-template-columns: auto 1fr;
    display: grid;
    align-items: start;
    font-weight: 400;
}
.option input { width: auto; margin-top: 4px; }
.question-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 24px;
}

@media (max-width: 760px) {
    .topbar { padding: 12px 16px; align-items: flex-start; gap: 10px; flex-direction: column; }
    .container { margin: 18px auto; padding: 0 14px; }
    .grid, .exam-shell, .stats-grid, .stats-grid.compact, .quick-grid, .info-strip, .mini-grid, .exam-card-grid, .exam-meta, .toggle-grid, .setup-flow, .readiness-panel, .readiness-cards, .onsite-start, .exam-structure, .start-steps { grid-template-columns: 1fr; }
    .exam-side { position: static; }
    .page-head, .filter, .section-title { align-items: stretch; flex-direction: column; }
    .start-copy h1 { font-size: 30px; }
    .brand img { width: 210px; height: 49px; max-height: 49px; }
}

@media print {
    .topbar, .page-head .button, .button, form { display: none !important; }
    body { background: #fff; }
    .container { max-width: none; margin: 0; }
    .panel, .stat { border-color: #999; break-inside: avoid; }
}
