/* ============ 在线考试系统 · 共用样式（浅色主题） ============ */
:root {
  --bg: #f4f7fc;
  --card: #ffffff;
  --ink: #172033;
  --ink-2: #3d4a60;
  --muted: #7b8798;
  --line: #e4eaf3;
  --line-2: #eef2f8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fff5e6;
  --danger: #dc2626;
  --danger-soft: #feecec;
  --purple: #7c3aed;
  --purple-soft: #f2edff;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(24, 45, 88, .06);
  --shadow-lg: 0 12px 40px rgba(24, 45, 88, .16);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }

/* ---------- 通用 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; font-weight: 500;
  white-space: nowrap; transition: all .15s ease;
}
.btn:hover { border-color: #c8d5ea; background: #f8fbff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #f3c6c6; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #eeaaaa; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--primary-soft); }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.input:disabled, .select:disabled { background: #f5f7fa; color: var(--muted); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.field { margin-bottom: 14px; }
.field > label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); }

.tag { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.7; }
.tag-blue { background: var(--primary-soft); color: var(--primary-dark); }
.tag-green { background: var(--success-soft); color: #15803d; }
.tag-orange { background: var(--warn-soft); color: #b45309; }
.tag-red { background: var(--danger-soft); color: var(--danger); }
.tag-purple { background: var(--purple-soft); color: var(--purple); }
.tag-gray { background: #f1f4f8; color: var(--muted); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 11px 12px; background: #f8fafd; color: var(--muted);
  font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafcff; }
table.tbl td.actions { white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .ico { font-size: 34px; opacity: .45; margin-bottom: 8px; }

.alert { padding: 11px 14px; border-radius: 9px; font-size: 13px; line-height: 1.7; }
.alert-info { background: var(--primary-soft); color: #1e40af; border: 1px solid #cfdfff; }
.alert-warn { background: var(--warn-soft); color: #92400e; border: 1px solid #fde3b8; }
.alert-danger { background: var(--danger-soft); color: #b91c1c; border: 1px solid #f8cfcf; }

/* ---------- Toast / Modal ---------- */
#toastHost { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 420px; padding: 12px 16px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: slideIn .22s ease; border-left: 4px solid var(--primary);
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 28, 50, .45); z-index: 900;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 620px; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); animation: popIn .18s ease; margin: auto 0;
}
.modal.wide { max-width: 860px; }
@keyframes popIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn { border: none; background: transparent; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.icon-btn:hover { color: var(--ink); }

/* ---------- 学生端 ---------- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 60;
  box-shadow: 0 1px 6px rgba(20, 40, 80, .04);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: .3px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #2563eb, #4f8cff);
  color: #fff; display: grid; place-items: center; font-size: 17px; font-weight: 700;
}
.name-box {
  display: flex; align-items: center; gap: 9px; background: var(--primary-soft);
  border: 1px solid #d3e2ff; border-radius: 11px; padding: 6px 8px 6px 14px;
}
.name-box label { font-size: 13px; font-weight: 700; color: var(--primary-dark); white-space: nowrap; }
.name-box .input { width: 190px; border-color: #c9dcff; background: #fff; }
.name-box .locked { font-weight: 700; color: var(--primary-dark); min-width: 90px; }

.hero { padding: 34px 0 8px; }
.hero h1 { margin: 0 0 6px; font-size: 25px; font-weight: 800; }
.hero p { margin: 0; color: var(--muted); }
.exam-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin: 22px 0 40px; }
.exam-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; transition: transform .16s, box-shadow .16s; }
.exam-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(24, 45, 88, .1); }
.exam-card h3 { margin: 0; font-size: 17px; }
.exam-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.exam-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px dashed var(--line); padding-top: 12px; }
.exam-facts div { text-align: center; }
.exam-facts b { display: block; font-size: 17px; color: var(--ink); }
.exam-facts span { font-size: 12px; color: var(--muted); }

.exam-bar {
  position: sticky; top: 0; z-index: 55; background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 14px rgba(20, 40, 80, .07);
}
.exam-bar-inner { max-width: 1280px; margin: 0 auto; padding: 11px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.exam-bar .who { font-weight: 700; }
.timer { display: flex; align-items: baseline; gap: 6px; padding: 5px 14px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-dark); }
.timer b { font-size: 21px; font-variant-numeric: tabular-nums; letter-spacing: 1px; font-weight: 800; }
.timer.danger { background: var(--danger-soft); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .68; } }

.exam-layout { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; display: grid; grid-template-columns: 232px 1fr; gap: 20px; align-items: start; }
.sheet { position: sticky; top: 84px; padding: 16px; }
.sheet h4 { margin: 0 0 4px; font-size: 14px; }
.sheet-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 12px; }
.sheet-grid button {
  aspect-ratio: 1; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  cursor: pointer; font-size: 12.5px; color: var(--ink-2); font-weight: 600;
}
.sheet-grid button.done { background: var(--primary); border-color: var(--primary); color: #fff; }
.sheet-grid button.current { outline: 2px solid var(--primary); outline-offset: 1px; }
.sheet-grid button:hover { border-color: var(--primary); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

.q-card { padding: 20px 22px; margin-bottom: 14px; scroll-margin-top: 90px; }
.q-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.q-no {
  min-width: 30px; height: 30px; border-radius: 8px; background: var(--primary-soft);
  color: var(--primary-dark); display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.q-stem { font-size: 15px; font-weight: 600; line-height: 1.75; flex: 1; white-space: pre-wrap; }
.options { display: flex; flex-direction: column; gap: 9px; margin-left: 40px; }
.option {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; transition: all .14s; line-height: 1.6;
}
.option:hover { border-color: #b9d0ff; background: #f9fbff; }
.option.checked { border-color: var(--primary); background: var(--primary-soft); }
.option .letter {
  min-width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px; background: #fff; flex-shrink: 0;
}
.option.checked .letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.option input { display: none; }
.q-essay { margin-left: 40px; }
.save-hint { font-size: 12px; color: var(--muted); margin-left: 40px; margin-top: 10px; }
.done-panel { max-width: 620px; margin: 50px auto; text-align: center; padding: 40px 30px; }
.done-panel .big { font-size: 52px; color: var(--success); line-height: 1; }
.done-panel h2 { margin: 14px 0 8px; }

/* ---------- 管理端 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; padding: 30px; }
.login-card h1 { margin: 16px 0 4px; font-size: 21px; }
.admin-layout { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 4px 10px 20px; font-size: 15.5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  cursor: pointer; color: var(--ink-2); font-weight: 500; margin-bottom: 3px; border: none;
  background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: #f4f7fc; }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; }
.sidebar-foot { position: absolute; bottom: 18px; left: 12px; right: 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 14px; }
.admin-main { padding: 22px 26px 60px; min-width: 0; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 20px; font-weight: 800; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 17px 19px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 27px; font-weight: 800; margin-top: 4px; line-height: 1.25; }
.stat .sub { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.rule-row { display: grid; grid-template-columns: 1fr 110px 110px; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; background: #fbfcfe; }
.rule-row .rname { font-weight: 600; }
.rule-row .input { padding: 6px 9px; }
.stock-note { font-size: 12px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.paper-item { padding: 18px 20px; margin-bottom: 12px; }
.paper-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.paper-title h3 { margin: 0; font-size: 16px; }
.rule-chips { display: flex; gap: 7px; flex-wrap: wrap; margin: 12px 0; }
.grading-item { border: 1px solid var(--line); border-radius: 11px; padding: 16px; margin-bottom: 14px; }
.grading-item .stem { font-weight: 600; margin-bottom: 10px; }
.answer-box { background: #f7f9fc; border: 1px solid var(--line-2); border-radius: 8px; padding: 11px 13px; white-space: pre-wrap; line-height: 1.7; margin-bottom: 9px; }
.answer-box.ref { background: #f0fdf4; border-color: #cfeadb; }
.err-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; }
.err-list div { padding: 8px 12px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.err-list div:last-child { border-bottom: none; }
.doc h3 { margin: 22px 0 8px; font-size: 15px; }
.doc h3:first-child { margin-top: 0; }
.doc p, .doc li { color: var(--ink-2); line-height: 1.85; }
.doc code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: 12.5px; color: #b91c1c; }
.doc pre { background: #f7f9fc; border: 1px solid var(--line); padding: 13px; border-radius: 9px; overflow-x: auto; font-size: 12.5px; line-height: 1.7; }

@media (max-width: 900px) {
  .exam-layout { grid-template-columns: 1fr; }
  .sheet { position: static; }
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar .brand { width: 100%; }
  .sidebar-foot { display: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
