:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --border: #d9e0ea;
    --text: #1f2937;
    --muted: #667085;
    --primary: #0f4c5c;
    --primary-dark: #0b3440;
    --primary-soft: #e8f4ed;
    --danger: #b42318;
    --warning: #b54708;
    --success: #067647;
}

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

.topbar {
    min-height: 64px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid #cdd8e5;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand {
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.brand::before {
    content: "S";
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: inline-grid;
    place-items: center;
}
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar nav a {
    color: var(--text);
    font-size: 14px;
    padding: 7px 9px;
    border-radius: 6px;
}
.topbar nav a:hover { background: #f1f5f9; }

.container { max-width: 1220px; margin: 30px auto; padding: 0 20px; }
.panel {
    background: var(--panel);
    border: 1px solid #d7e0eb;
    border-radius: 10px;
    padding: 26px;
    margin-bottom: 20px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .05);
}
.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;
}
.hero-head, .student-hero {
    background: linear-gradient(135deg, #0f4c5c 0%, #1b6b77 100%);
    color: #fff;
    border-radius: 14px;
    padding: 28px;
    margin-bottom: 22px;
    box-shadow: 0 18px 40px rgba(15, 76, 92, .22);
}
.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: #b9f3ff; }
.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: 10px 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 14px;
    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:hover { background: var(--primary-dark); }
.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: 14px;
    margin-bottom: 20px;
}
.stats-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat {
    background: #fff;
    border: 1px solid #d7e0eb;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .04);
}
.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: 13px; color: var(--muted); background: #f8fafc; }
.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;
}

.exam-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.exam-card {
    background: #fff;
    border: 1px solid #d7e0eb;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .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 #dbe5ee;
    background: #f8fbfd;
    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; }
.instruction-panel {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

.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 #d7e0eb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}
.setup-flow strong {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    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, .info-strip, .mini-grid, .exam-card-grid, .exam-meta, .toggle-grid, .setup-flow, .readiness-panel, .readiness-cards { grid-template-columns: 1fr; }
    .exam-side { position: static; }
    .page-head, .filter { align-items: stretch; flex-direction: column; }
}

@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; }
}
