/* ============================================================
   CBT Pondok Pesantren Modern MBS Trenggalek
   Design system
   ============================================================ */
:root {
  --navy: #0d1b3e;
  --navy-2: #152e63;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --gold: #f5b301;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e3e9f2;
  --danger: #dc2626;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --shadow: 0 4px 20px rgba(15, 35, 80, .07);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Inter, system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
svg { display: inline-block; vertical-align: middle; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, .22), transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(22, 163, 74, .18), transparent 45%),
    linear-gradient(135deg, #0b1734 0%, #13306b 55%, #0f2552 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before, .login-page::after {
  content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.07);
}
.login-page::before { width: 520px; height: 520px; top: -200px; right: -140px; }
.login-page::after { width: 380px; height: 380px; bottom: -170px; left: -110px; }
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 430px;
  background: #fff; border-radius: 22px; padding: 34px 38px 30px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .35);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo {
  width: 108px; height: 108px; object-fit: contain; display: block; margin: 0 auto 12px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.12));
}
.login-brand h1 { font-size: 19px; color: var(--navy); line-height: 1.3; }
.login-brand p { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.login-subtitle { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 9px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}
.password-field { position: relative; }
.password-field input { padding-right: 46px !important; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted);
  border-radius: 8px; cursor: pointer; display: grid; place-items: center;
}
.password-toggle:hover { background: #f1f5f9; color: var(--blue); }
.login-show-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 20px; font-size: 13px; color: var(--muted); user-select: none; cursor: pointer; }
.login-show-row input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.login-foot { text-align: center; color: #94a3b8; font-size: 11.5px; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; flex: 0 0 252px; position: fixed; inset: 0 auto 0 0; z-index: 20;
  background: linear-gradient(180deg, #0d1b3e 0%, #142c5f 100%);
  color: #dbe6ff; display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-brand {
  padding: 22px 20px; display: flex; gap: 12px; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.sidebar-brand img { width: 44px; height: 44px; object-fit: contain; }
.sidebar-brand strong { color: #fff; font-size: 14px; display: block; line-height: 1.25; }
.sidebar-brand span { font-size: 10.5px; opacity: .7; letter-spacing: .08em; }
.sidebar-section { padding: 18px 12px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; opacity: .5; font-weight: 700; }
.nav { padding: 6px 12px 20px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 13px; border: 0; border-radius: 10px; background: transparent;
  color: #cbd8f2; cursor: pointer; text-align: left; font-weight: 500; transition: .15s;
}
.nav-item svg { flex: 0 0 18px; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, #2563eb, #3b82f6); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.35); }
.nav-item.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 16px 20px 22px; font-size: 11px; opacity: .55; border-top: 1px solid rgba(255,255,255,.08); }
.main-area { flex: 1; min-width: 0; margin-left: 252px; }
.topbar {
  height: 72px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 15;
}
.topbar-title { font-size: 17px; color: var(--navy); font-weight: 700; }
.topbar-title small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.user-area { display: flex; align-items: center; gap: 14px; }
.user-info { text-align: right; line-height: 1.25; }
.user-info strong { display: block; font-size: 13.5px; color: var(--navy); }
.user-info span { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #2563eb, #16a34a);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.content { padding: 24px 28px 40px; max-width: 1500px; margin: 0 auto; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs::-webkit-scrollbar { height: 4px; }
.tab {
  border: 0; background: transparent; cursor: pointer; padding: 12px 15px;
  color: var(--muted); font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 8px;
  border-bottom: 3px solid transparent; margin-bottom: -1px; transition: .15s;
}
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue-dark); border-bottom-color: var(--blue); }
.tab svg { width: 16px; height: 16px; }

/* ---------- Cards & stats ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { color: var(--navy); font-size: 16px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 46px; }
.stat-icon.blue { background: #e8f0ff; color: #2563eb; }
.stat-icon.green { background: #e7f8ee; color: #16a34a; }
.stat-icon.gold { background: #fff6dc; color: #d97706; }
.stat-icon.red { background: #feecec; color: #dc2626; }
.stat-icon.purple { background: #f1eafe; color: #7c3aed; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; cursor: pointer;
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 7px;
  transition: .15s; white-space: nowrap; justify-content: center;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(37,99,235,.22); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #12833a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; transition: .15s;
}
.icon-btn:hover { color: var(--blue); border-color: var(--blue); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn svg { width: 14px; height: 14px; }
.action-group { display: flex; gap: 5px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #475569; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #d7dfeb; border-radius: 9px; padding: 10px 12px;
  background: #fff; color: var(--text); outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field textarea { min-height: 90px; resize: vertical; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.field-hint code { background: #eef2f7; padding: 1px 4px; border-radius: 4px; font-size: 11px; }
.math-toolbar { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.math-chip {
  min-width: 32px; padding: 5px 8px; border: 1px solid #d7dfeb; border-radius: 7px;
  background: #f8fafc; color: #334155; font-size: 13px; line-height: 1.2; cursor: pointer;
}
.math-chip:hover { border-color: var(--blue); background: #eff6ff; }
.math-chip.latex { color: #1d4ed8; font-weight: 700; }
.katex { font-size: 1em; }
.katex-display { margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .field { margin: 0; min-width: 190px; flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--blue); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f8fafc; color: #475569; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; text-align: left; padding: 12px 14px; white-space: nowrap; border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbff; }
td .sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.soal-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.soal-table input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .45; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .35; display: block; margin: 0 auto 10px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 14px; }
.pager-info, .pager-controls span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pager-controls { display: flex; align-items: center; gap: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.blue { background: #e8f0ff; color: #1d4ed8; }
.badge.green { background: #e7f8ee; color: #15803d; }
.badge.gold { background: #fff5d6; color: #b45309; }
.badge.red { background: #feecec; color: #b91c1c; }
.badge.gray { background: #f1f5f9; color: #64748b; }
.badge.purple { background: #f3ebff; color: #7c3aed; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 18, 40, .55);
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.3);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { color: var(--navy); font-size: 16px; }
.modal-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; padding: 0 4px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 250px; max-width: 380px; background: #fff; border-left: 4px solid var(--blue);
  border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 12px 16px; font-size: 13px;
  animation: slide .2s ease-out; display: flex; gap: 10px; align-items: center;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--danger); }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Loading popup ---------- */
/* Overlay tetap berada di atas halaman yang sedang aktif, bukan menggantikannya. */
.page-loader {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(9, 21, 48, .42); backdrop-filter: blur(2px);
  color: var(--text); transition: opacity .24s ease, visibility .24s ease;
}
.page-loader[hidden] { display: none; }
.page-loader.is-hiding { opacity: 0; visibility: hidden; pointer-events: none; }
.page-loader-card {
  width: min(320px, calc(100vw - 40px));
  display: grid; justify-items: center; gap: 12px; padding: 28px 32px 26px;
  border-radius: 16px; background: #fff;
  border: 1px solid rgba(226, 232, 240, .9); box-shadow: 0 24px 70px rgba(8, 18, 40, .3);
  text-align: center; animation: loader-pop .22s cubic-bezier(.2, .9, .3, 1.15);
}
.page-loader-card strong { font-size: 16px; color: var(--navy); letter-spacing: .01em; }
.page-loader-card span { font-size: 12.5px; color: var(--muted); }
.loader-spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid #dbeafe; border-top-color: var(--blue);
  animation: loader-spin .75s linear infinite;
}
.loader-track { width: 180px; height: 4px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-top: 2px; }
.loader-track i { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--blue); animation: loader-slide 1.1s ease-in-out infinite; }
@keyframes loader-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes loader-spin { to { transform: rotate(360deg); } }
@keyframes loader-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---------- Chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 16px; height: 230px; padding: 12px 8px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 6px; }
.chart-count { font-weight: 800; font-size: 15px; color: var(--navy); }
.chart-track { width: 100%; max-width: 62px; flex: 1; display: flex; align-items: flex-end; background: #f1f5f9; border-radius: 8px 8px 4px 4px; overflow: hidden; }
.chart-bar { width: 100%; border-radius: 8px 8px 4px 4px; transition: height .5s ease; min-height: 2px; }
.chart-label { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.25; min-height: 28px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 12px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* ---------- Image preview & question ---------- */
.image-preview { margin-top: 10px; border: 1px dashed var(--border); border-radius: 10px; padding: 8px; display: inline-block; }
.image-preview img { max-width: 100%; max-height: 180px; display: block; border-radius: 6px; }
.question-img { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--border); margin: 10px 0; display: block; }

/* ---------- Exam ---------- */
.exam-top { background: var(--navy); color: #fff; padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.exam-heading h2 { font-size: 16px; margin: 0; }
.exam-heading p { margin: 3px 0 0; font-size: 12px; opacity: .75; }
.exam-tools { display: flex; align-items: center; gap: 12px; }
.exam-time-group { display: flex; align-items: center; gap: 12px; }
.exam-timer-wrap, .exam-violation-wrap { text-align: right; }
.exam-timer-wrap .label, .exam-violation-wrap .label { font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .1em; }
.exam-timer, .exam-violation { background: rgba(255,255,255,.12); border-radius: 10px; padding: 8px 16px; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; letter-spacing: .05em; }
.exam-timer.danger, .exam-violation.danger { background: #b91c1c; }
.exam-grid-toggle { display: none; }
.exam-backdrop { display: none; }
.exam-layout { display: grid; grid-template-columns: 1fr 230px; gap: 18px; padding: 20px 26px; align-items: start; }
.exam-question { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.q-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.q-number { color: var(--blue); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.q-subline { color: var(--muted); font-size: 12px; margin-top: 4px; }
.q-status { flex: 0 0 auto; background: #eef2f7; color: #64748b; border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 700; }
.q-status.answered { background: #dcfce7; color: #15803d; }
.q-status.ragu { background: #ffedd5; color: #c2410c; }
.q-text { font-size: 17px; line-height: 1.6; margin: 10px 0 18px; font-weight: 600; white-space: pre-line; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 13px 16px; cursor: pointer; transition: .15s; background: #fff;
}
.option:hover { border-color: #93b4f7; background: #f8fbff; }
.option.selected { border-color: var(--blue); background: #eef4ff; }
.option-key { width: 30px; height: 30px; border-radius: 8px; background: #f1f5f9; display: grid; place-items: center; font-weight: 700; color: var(--navy); flex: 0 0 30px; }
.option-img { display: block; max-width: 100%; max-height: 120px; margin-top: 6px; border-radius: 8px; border: 1px solid var(--border); object-fit: contain; }
.option.selected .option-key { background: var(--blue); color: #fff; }
.option-check { width: 22px; height: 22px; display: grid; place-items: center; color: var(--blue); flex: 0 0 22px; }
.exam-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; gap: 10px; }
.exam-actions .btn:disabled { opacity: .5; cursor: not-allowed; }
.exam-ragu { background: #fff; border-color: var(--border); color: var(--text); }
.exam-ragu.active { background: var(--warning); border-color: var(--warning); color: #fff; }
.exam-submit { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; }
.exam-nav { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; position: sticky; top: 92px; }
.exam-nav-head { display: flex; align-items: center; justify-content: space-between; }
.exam-nav h3 { font-size: 14px; color: var(--navy); margin: 0 0 12px; }
.exam-nav-close { display: none; }
.q-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.q-btn { aspect-ratio: 1; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12px; color: var(--muted); }
.q-btn.answered { background: #e7f8ee; border-color: #86efac; color: #15803d; }
.q-btn.current { background: var(--blue); border-color: var(--blue); color: #fff; }
.exam-nav-foot { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; display: grid; gap: 8px; }
.exam-nav-count { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.exam-alert { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 10px 14px; border-radius: 10px; font-size: 12.5px; margin: 0 26px 16px; display: flex; gap: 10px; align-items: center; }

/* Pratinjau ujian guru: memakai komponen ujian peserta di overlay penuh. */
.exam-preview { position: fixed; inset: 0; z-index: 90; overflow-y: auto; background: var(--bg); }
.exam-preview-actions { display: flex; align-items: center; gap: 8px; }
.exam-preview-close {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.32); background: rgba(255,255,255,.12);
  color: #fff; cursor: pointer;
}
.exam-preview-close:hover { background: rgba(255,255,255,.22); }

/* ---------- Misc ---------- */
.token-display { font-family: ui-monospace, Consolas, monospace; font-size: 18px; font-weight: 800; letter-spacing: .08em; color: var(--navy); background: #f1f5f9; padding: 8px 12px; border-radius: 8px; display: inline-block; }
.progress { height: 7px; background: #eef2f7; border-radius: 999px; overflow: hidden; width: 100%; min-width: 80px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #16a34a); border-radius: 999px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.info-strip { background: linear-gradient(100deg, #12306b, #1d4ed8); color: #fff; border-radius: var(--radius); padding: 20px 24px; margin-bottom: 18px; display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.info-strip .label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .7; }
.info-strip .value { font-size: 19px; font-weight: 700; margin-top: 4px; }
.loading { padding: 50px; text-align: center; color: var(--muted); }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; background: #eff6ff; color: #1d4ed8; border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 600; }

/* ---------- Form soal 4 format ---------- */
.option-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.option-row { display: flex; align-items: center; gap: 9px; }
.option-row input:not([type="file"]) { flex: 1; border: 1px solid #d7dfeb; border-radius: 8px; padding: 9px 11px; outline: none; }
.option-row input:not([type="file"]):focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.option-row .option-key { width: 30px; height: 30px; border-radius: 8px; background: #eef2f7; display: grid; place-items: center; font-weight: 700; color: var(--navy); flex: 0 0 30px; }
.option-fields { flex: 1; min-width: 0; }
.option-fields .option-text { width: 100%; }
.option-image-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.option-image-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px;
  border: 1px dashed var(--border); border-radius: 7px; color: var(--muted);
  cursor: pointer; font-size: 11.5px; background: #fff;
}
.option-image-btn:hover { border-color: var(--blue); color: var(--blue); }
.option-image-btn input { display: none; }
.option-image-preview { display: flex; align-items: center; gap: 6px; }
.option-image-preview img { max-width: 72px; max-height: 48px; border-radius: 6px; border: 1px solid var(--border); object-fit: contain; }
.key-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.key-chip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 36px;
  border: 1.5px solid var(--border); border-radius: 9px; padding: 0 11px; cursor: pointer;
  font-weight: 700; color: var(--navy); transition: .15s; background: #fff;
}
.key-chip.wide { min-width: 92px; }
.key-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.key-chip:has(input:checked) { background: var(--blue); border-color: var(--blue); color: #fff; }
.key-chip.disabled { opacity: .35; cursor: not-allowed; }

.statement-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.statement-row { display: flex; align-items: center; gap: 9px; }
.statement-no { width: 26px; height: 26px; border-radius: 7px; background: #eef2f7; display: grid; place-items: center; font-weight: 700; color: var(--navy); flex: 0 0 26px; }
.statement-text { flex: 1 1 auto; width: auto; min-width: 220px; border: 1px solid #d7dfeb; border-radius: 8px; padding: 9px 11px; outline: none; }
.statement-text:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.statement-key { flex: 0 0 110px; width: 110px; border: 1px solid #d7dfeb; border-radius: 8px; padding: 9px 10px; background: #fff; }
.statement-bobot { flex: 0 0 68px; width: 68px; border: 1px solid #d7dfeb; border-radius: 8px; padding: 9px 8px; }

.match-list { display: flex; flex-direction: column; gap: 9px; }
.match-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; }
.match-row select { border: 1px solid #d7dfeb; border-radius: 8px; padding: 8px 10px; min-width: 180px; background: #fff; }
.bs-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 4px; }
.bs-table th, .bs-table td { border: 1px solid var(--border); padding: 12px 14px; text-align: left; vertical-align: top; line-height: 1.5; }
.bs-table th { background: #f1f5f9; color: var(--navy); font-size: 12px; font-weight: 700; }
.bs-table td { font-size: 14px; }
.bs-table th.bs-choice, .bs-table td.bs-choice { width: 76px; text-align: center; vertical-align: middle; }
.bs-table input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); cursor: pointer; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d97706; }
.q-btn.ragu { background: #fff7ed; border-color: #fb923c; color: #c2410c; }
.q-btn.ragu.current { background: #f97316; border-color: #f97316; color: #fff; }
body.exam-mode .sidebar { display: none; }
body.exam-mode .topbar { display: none; }
body.exam-mode .main-area { margin-left: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .sidebar { width: 74px; flex-basis: 74px; }
  .sidebar-brand { padding: 16px 14px; justify-content: center; }
  .sidebar-brand div, .sidebar-section, .nav-item span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main-area { margin-left: 74px; }
  .exam-layout { grid-template-columns: 1fr; }
  .exam-nav { position: static; }
}
@media (max-width: 700px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-title small { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 15px; }
  .chart { gap: 6px; }
  .chart-label { font-size: 9.5px; }

  /* Ujian mode mobile: header putih, kartu soal abu, aksi bawah tetap. */
  body.exam-mode .content { padding: 0; }
  .exam-top {
    position: sticky; top: 0; z-index: 40; display: block;
    padding: 16px 16px 22px; background: #fff; color: var(--text);
    border-bottom: 1px solid var(--border); box-shadow: 0 2px 10px rgba(15,23,42,.04);
  }
  .exam-heading h2 { font-size: 15px; color: var(--text); }
  .exam-heading p { font-size: 11px; color: var(--muted); opacity: 1; }
  .exam-tools { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
  .exam-time-group { display: flex; align-items: center; gap: 10px; }
  .exam-timer-wrap, .exam-violation-wrap { text-align: left; }
  .exam-timer-wrap .label, .exam-violation-wrap .label { color: var(--muted); opacity: 1; }
  .exam-timer, .exam-violation { justify-self: start; background: #f1f5f9; color: var(--text); padding: 6px 12px; font-size: 16px; border-radius: 8px; }
  .exam-timer.danger, .exam-violation.danger { background: #fee2e2; color: #b91c1c; }
  .exam-grid-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 12px; border: 0; border-radius: 999px; background: #645cd4; color: #fff;
    font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer;
  }
  .exam-grid-toggle strong { font-weight: 800; }
  .exam-preview-close { background: #fff; border-color: var(--border); color: var(--text); }
  .exam-alert { margin: 12px 16px 0; }
  .exam-layout { display: block; padding: 0 16px 100px; }
  .exam-question { background: #f8fafc; border: 0; border-radius: 0; box-shadow: none; padding: 20px 2px 24px; }
  .q-number strong { font-size: 14px; }
  .q-subline { line-height: 1.4; }
  .q-text { font-size: 16px; margin: 18px 0; }
  .question-img { max-height: 200px; }
  .option { align-items: flex-start; padding: 12px; }
  .option-key { width: 28px; height: 28px; flex-basis: 28px; }
  .match-row { flex-wrap: wrap; }
  .match-row select { min-width: 0; flex: 1 1 130px; }
  .bs-table th, .bs-table td { padding: 10px 8px; font-size: 13px; }
  .bs-table th.bs-choice, .bs-table td.bs-choice { width: 56px; }
  .bs-table input[type="radio"] { width: 20px; height: 20px; }

  .exam-actions {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 8px; background: #fff; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(15,23,42,.06);
  }
  .exam-actions .btn { flex: 1; min-height: 44px; padding: 10px 8px; font-size: 12.5px; white-space: normal; }
  #prev-q { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
  .exam-ragu { background: #fffdf3; border-color: #fde68a; color: #b45309; }
  .exam-ragu.active { background: #f59e0b; border-color: #f59e0b; color: #fff; }
  #next-q { background: #4f46e5; border-color: #4f46e5; color: #fff; }
  .exam-submit { margin-top: 18px; }

  .exam-backdrop.show { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.45); }
  .exam-nav {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; top: auto;
    max-height: 76vh; overflow: auto; border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .22s ease;
    box-shadow: 0 -8px 32px rgba(15,23,42,.16);
  }
  .exam-nav.open { transform: translateY(0); }
  .exam-nav-head { margin-bottom: 14px; }
  .exam-nav h3 { margin: 0; font-size: 15px; }
  .exam-nav-close {
    display: inline-grid; place-items: center; width: 32px; height: 32px;
    border: 0; border-radius: 50%; background: #f1f5f9; color: var(--text); cursor: pointer;
  }
  .q-grid { gap: 8px; }
  .q-btn { aspect-ratio: auto; min-height: 42px; font-size: 13px; }
}

@media (max-width: 420px) {
  .exam-tools { gap: 8px; }
  .exam-time-group { gap: 6px; }
  .exam-timer, .exam-violation { padding: 5px 9px; font-size: 14px; }
  .exam-grid-toggle { padding: 7px 9px; font-size: 11px; }
}
