:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --ok: #16a34a;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 560px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 14px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:disabled { background: #93c5fd; border-color: #93c5fd; cursor: not-allowed; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
  outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; min-height: 90px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px;
  background: #f1f5f9; color: #475569; border: 1px solid var(--line);
}
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.tag-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag-primary { background: var(--primary-soft); color: var(--primary); border-color: #bfdbfe; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ico { font-size: 34px; display: block; margin-bottom: 8px; opacity: .5; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfc; position: sticky; top: 0; }
table.tbl tbody tr:hover { background: #fafbfc; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-3 { grid-template-columns: repeat(1, 1fr); } }

/* ---------- 遮罩 / 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 60;
}
.mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
}
.modal-head {
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 96vw);
  background: #fff; box-shadow: -10px 0 40px rgba(15, 23, 42, .18);
  transform: translateX(100%); transition: .25s; z-index: 70; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer-body { padding: 18px; overflow: auto; flex: 1; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: .2s; z-index: 99; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner {
  width: 18px; height: 18px; border: 2px solid #cbd5e1; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 考生端 ---------- */
.exam-top {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.exam-top .inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.exam-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; color: var(--primary); }
.clock.danger { color: var(--danger); }

.q-card { margin-top: 16px; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.q-no { font-weight: 700; }
.q-stem { font-size: 16px; line-height: 1.7; white-space: pre-wrap; margin-bottom: 16px; }

.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: .12s; background: #fff;
}
.opt:hover { border-color: #c7d2fe; background: #fbfdff; }
.opt .k {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--muted);
}
.opt .k.square { border-radius: 7px; }
.opt.on { border-color: var(--primary); background: var(--primary-soft); }
.opt.on .k { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt .t { flex: 1; }

.exam-nav { display: flex; gap: 10px; margin-top: 16px; }
.exam-nav .btn { flex: 1; }
.mark-btn.on { background: var(--warn-soft); border-color: #fcd34d; color: var(--warn); }

.sheet .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 8px; }
.sheet .c {
  height: 42px; border: 1px solid var(--line); border-radius: 9px; display: flex;
  align-items: center; justify-content: center; cursor: pointer; font-size: 14px; background: #fff; position: relative;
}
.sheet .c.done { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary-dark); font-weight: 600; }
.sheet .c.flag::after { content: "⚑"; position: absolute; top: -6px; right: -4px; font-size: 11px; color: var(--warn); }
.sheet .c.cur { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }

.entry { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.entry .brand { text-align: center; margin-bottom: 22px; }
.entry .brand .logo {
  width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 10px;
}
.entry h1 { font-size: 19px; margin: 0; }
.entry .brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.dept-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.dept-pick .d {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px; text-align: center;
  cursor: pointer; font-size: 14px; background: #fff; transition: .12s;
}
.dept-pick .d:hover { border-color: #c7d2fe; }
.dept-pick .d.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }

/* 考试须知 */
.notice { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.notice h3 { margin: 0 0 9px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.notice dl { margin: 0; display: grid; grid-template-columns: 72px 1fr; gap: 8px 10px; font-size: 13px; line-height: 1.5; }
.notice dt { color: var(--muted); }
.notice dd { margin: 0; }
.notice .ty { display: flex; flex-wrap: wrap; gap: 6px; }
.notice .ty span { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.limit-tip { margin: -4px 0 12px; font-size: 13px; }

.result-hero { text-align: center; padding: 26px 18px; }
.result-hero .score { font-size: 46px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.result-hero .score.bad { color: var(--danger); }
.result-hero .score.good { color: var(--ok); }

.review { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.review.right { border-left: 4px solid var(--ok); }
.review.wrong { border-left: 4px solid var(--danger); }
.review.pending { border-left: 4px solid var(--warn); }
.review .q { font-weight: 600; margin-bottom: 8px; }
.review .ans { font-size: 14px; }
.review .ans b { color: var(--muted); font-weight: 500; }

/* ---------- 管理端 ---------- */
.admin-top {
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.admin-top .inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.admin-top .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.admin-top .logo .ic {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.tabs { display: flex; gap: 4px; }
.tabs .t { padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.tabs .t.on { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.stat .lb { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }

.exam-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; }
.exam-item + .exam-item { margin-top: 12px; }
.exam-item h4 { margin: 0 0 6px; font-size: 16px; }

.drop {
  border: 2px dashed #cbd5e1; border-radius: 12px; padding: 26px; text-align: center;
  cursor: pointer; background: #fbfdff; transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }

.q-list .q-row { display: flex; gap: 10px; align-items: flex-start; border-bottom: 1px solid var(--line); padding: 12px 0; }
.q-list .q-row:last-child { border-bottom: none; }
.q-list .q-row .txt { flex: 1; min-width: 0; }
.q-list .stem { line-height: 1.55; }
.q-list .opts { color: var(--muted); font-size: 13px; margin-top: 3px; }
.pick {
  width: 18px; height: 18px; border: 1.5px solid #cbd5e1; border-radius: 5px; cursor: pointer;
  flex: 0 0 18px; margin-top: 3px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
}
.pick.on { background: var(--primary); border-color: var(--primary); }

.bar { height: 8px; background: #f1f5f9; border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.bar.g > i { background: var(--ok); }
.bar.r > i { background: var(--danger); }
.bar.y > i { background: var(--warn); }

.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; image-rendering: pixelated; }
.code-pill {
  font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: 3px;
  background: var(--primary-soft); color: var(--primary-dark); padding: 8px 16px;
  border-radius: 10px; display: inline-block; font-weight: 700;
}
.link-line { display: flex; gap: 8px; align-items: center; }
.link-line input { font-size: 13px; }

@media (max-width: 640px) {
  .admin-top .inner { height: auto; padding: 10px 0; flex-wrap: wrap; }
  .tabs .t { padding: 6px 10px; font-size: 13px; }
  .grid-2 { grid-template-columns: 1fr; }
  .exam-title { font-size: 14px; }
  .container { padding: 0 12px; }
}
