:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --danger: #b91c1c;
  --amber: #b45309;
  --green: #15803d;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea, select { -webkit-user-select: text; user-select: text; }

main { max-width: 900px; margin: 0 auto; padding: 24px 16px 48px; }

h1 { margin: 0 0 4px; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1.15rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 6%);
}

.sub { margin: 0; color: var(--muted); }
.meta { color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); font-size: .85rem; }
.note { margin-top: 20px; color: var(--muted); font-size: .85rem; }
.center { text-align: center; }

label { display: block; margin: 18px 0 6px; font-weight: 600; font-size: .9rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input:not([type]) {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}

textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; }

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: min(640px, 94vw);
  max-height: 90vh;
  overflow: auto;
}

dialog::backdrop { background: rgb(15 23 42 / 55%); }
.dialog-body { padding: 24px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.snippet { max-width: 460px; }
.answer-table { margin-top: 18px; font-size: .85rem; }
.answer-table th, .answer-table td { padding: 7px 6px; }
.text-ok { color: var(--green); font-weight: 600; }
.text-bad { color: var(--danger); font-weight: 600; }

input:focus-visible, button:focus-visible {
  outline: 3px solid rgb(15 118 110 / 30%);
  outline-offset: 2px;
}

button {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: #e2e8f0;
  color: var(--ink);
}

button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { background: var(--danger); color: #fff; }
button.ghost { background: #fff; border-color: var(--line); }
button.ghost:hover { background: #f8fafc; }
button.ghost.active { background: #fef3c7; border-color: #f59e0b; color: var(--amber); }

#btn-start { width: 100%; margin-top: 22px; padding: 14px; }

.logo {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 14px;
}

.logo-sm { width: 64px; height: 64px; margin: 0; }
.logo-header { width: 40px; height: 40px; margin: 0; }

.terms-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.terms-head h1 { margin: 0; }

.terms-box {
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px 16px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.terms-box p { margin: 0 0 12px; }
.terms-box h3 { margin: 18px 0 8px; font-size: 1rem; }
.terms-list { margin: 0 0 8px; padding-left: 22px; }
.terms-list li { margin-bottom: 8px; }

.terms-check { align-items: flex-start; }
.terms-check input { margin-top: 3px; flex: none; }
.terms-check input:disabled + span { opacity: .55; }

.terms-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.terms-actions button { flex: 1 1 0; }

.error { min-height: 1.3em; margin: 12px 0 0; color: var(--danger); font-size: .9rem; }

/* Exam */
.exam-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #0f172a;
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.timer { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low { color: #fca5a5; }
.head-stats { display: flex; gap: 16px; margin-left: auto; font-size: .9rem; color: #cbd5e1; }

.exam-body { display: grid; gap: 16px; }
.q-number { margin: 0 0 8px; color: var(--brand); font-weight: 700; font-size: .9rem; }
.q-text { margin: 0 0 18px; font-size: 1.1rem; line-height: 1.55; }

.options { display: grid; gap: 10px; }

.option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 400;
  transition: border-color .12s, background .12s;
}

.option:hover { border-color: #94a3b8; }
.option:has(input:checked) { border-color: var(--brand); background: #f0fdfa; }
.option input { margin-top: 3px; accent-color: var(--brand); }

.nav-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }

.navigator { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }

.navigator button {
  position: relative;
  padding: 9px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-variant-numeric: tabular-nums;
}

.navigator button.nav-answered { background: #dcfce7; border-color: #86efac; color: var(--green); }
.navigator button.nav-flagged { background: #fef3c7; border-color: #fbbf24; color: var(--amber); }
.navigator button.nav-current { box-shadow: inset 0 0 0 2px var(--ink); }
.navigator button.nav-flagged::after { content: "⚑"; position: absolute; top: -6px; right: -4px; font-size: .8rem; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; }
.dot-empty { background: #fff; }
.dot-answered { background: #dcfce7; border-color: #86efac; }
.dot-flagged { background: #fef3c7; border-color: #fbbf24; }
.dot-current { box-shadow: inset 0 0 0 2px var(--ink); }

.exam-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.exam-actions button { flex: 1 1 auto; }

/* Overlay & toast */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background: rgb(15 23 42 / 72%);
}

.overlay-card {
  width: min(420px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.overlay-card h2 { flex: none; }
.overlay-card #overlay-btn { flex: none; margin-top: 16px; }
#overlay-text { overflow-y: auto; }

.overlay-card.wide { width: min(760px, 100%); text-align: left; }
.overlay-card.wide #overlay-text { text-align: left; padding-right: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .9rem;
  z-index: 60;
}

/* Admin */
.admin-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-head h1 { margin: 0; font-size: 1.3rem; margin-right: auto; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  white-space: nowrap;
}
.tab:hover { background: #eef2f7; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.tab-panel { display: grid; gap: 16px; }

/* Hasil peserta */
.result { margin: 24px 0 8px; }
.result-score {
  margin: 0;
  font-size: 3.4rem;
  line-height: 1.1;
  font-weight: 800;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #f8fafc; }

.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-open { background: #dcfce7; color: var(--green); }
.badge-closed { background: #fee2e2; color: var(--danger); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { padding: 6px 10px; font-size: .82rem; }

form.settings label { margin-top: 12px; }
form.settings button { margin-top: 18px; }

.checkline { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 600; font-size: .9rem; }
.checkline input { width: 18px; height: 18px; accent-color: var(--brand); }

@media (max-width: 560px) {
  main { padding: 14px 10px 40px; }
  .card { padding: 18px; }
  .head-stats { margin-left: 0; width: 100%; order: 3; }
  .exam-actions { flex-direction: column; }
}
