:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #667085;
  --line: #e4e8ef;
  --brand: #1a4d8f;
  --brand-2: #2563eb;
  --green: #18794e;
  --amber: #b54708;
  --red: #b42318;
  --blue: #175cd3;
  --purple: #7a3fb5;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.nav { display: flex; gap: 18px; font-size: 14px; }
.nav a { color: var(--ink); }
.nav a:hover { color: var(--brand-2); text-decoration: none; }
.link-home { color: var(--muted); font-size: 13px; }
.lang-select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: #fff; font-size: 13px; }

/* Layout */
.container { max-width: 1080px; margin: 0 auto; padding: 24px; }
.container-wide { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-desc { color: var(--muted); margin: 0 0 20px; }

/* Cards / panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 20px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 8px 14px; font-size: 14px; cursor: pointer; }
.btn:hover { border-color: #c9d2df; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #16407a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: #f2c4be; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge-default { background: #eef1f6; color: #475467; }
.badge-green { background: #e7f4ec; color: var(--green); }
.badge-amber { background: #fef3e6; color: var(--amber); }
.badge-red { background: #fdeceA; color: var(--red); }
.badge-blue { background: #e8f0fe; color: var(--blue); }
.badge-purple { background: #f3eafb; color: var(--purple); }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #fafbfc; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
table.data tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 16px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field select, .field input { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 13px; background: #fff; min-width: 130px; }

/* Exam */
.exam-shell { max-width: 820px; margin: 24px auto; padding: 0 16px; }
.exam-info dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 16px 0; }
.exam-info dt { color: var(--muted); }
.exam-info dd { margin: 0; font-weight: 500; }
.q-text { font-size: 16px; line-height: 1.7; margin: 8px 0 20px; white-space: pre-wrap; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; }
.option:hover { border-color: #c9d2df; background: #f8fafc; }
.option.selected { border-color: var(--brand); background: #f0f6ff; }
.option .key { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; background: #eef1f6; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.option.selected .key { background: var(--brand); color: #fff; }
.option.correct { border-color: var(--green); background: #e7f4ec; }
.option.wrong { border-color: var(--red); background: #fdecea; }

.exam-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0; }
.qnum { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; }
.qnum.answered { background: #e8f0fe; border-color: #bcd0fb; color: var(--blue); }
.qnum.marked { border-color: var(--amber); }
.qnum.current { outline: 2px solid var(--brand); }
.qnum.correct-mark { background: #e7f4ec; border-color: #9fd3b6; }
.qnum.wrong-mark { background: #fdecea; border-color: #f2b4ab; }

.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 20px; }
.timer.warn { color: var(--red); }
.exam-bar { position: sticky; top: 56px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 10; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.exam-actions { display: flex; gap: 12px; margin-top: 20px; }

/* Result */
.result-score { font-size: 48px; font-weight: 800; }
.score-ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; font-size: 32px; font-weight: 800; }

/* Modal / Drawer */
.modal-mask { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-mask.open { display: flex; }
.modal { background: #fff; border-radius: 10px; max-width: 720px; width: 100%; max-height: 86vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.textarea { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: inherit; resize: vertical; }

/* Admin login gate (admin-auth.js) */
.gw-input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; }
.gw-input:focus { outline: none; border-color: var(--brand); }
.gw-err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 4px; }

/* Misc */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 16px; }
.stat .num { font-size: 28px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.notice { background: #eef4ff; border: 1px solid #cfe0ff; color: #1a4d8f; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .nav { display: none; }
  .exam-info dl { grid-template-columns: 110px 1fr; }
  .exam-bar { top: 52px; flex-wrap: wrap; }
}
