/* ================= M3 理论考试系统 ================= */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1b2436;
  --ink-2: #5a6478;
  --ink-3: #8b94a7;
  --line: #e3e8f0;
  --brand: #1f5fa9;
  --brand-2: #2f7fd1;
  --brand-soft: #e8f1fb;
  --ok: #1f9d6a;
  --ok-soft: #e6f6ef;
  --warn: #d9821c;
  --warn-soft: #fdf1e2;
  --bad: #d1443c;
  --bad-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 39, 75, .06), 0 8px 24px rgba(24, 39, 75, .07);
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  font-size: 14px; font-family: inherit; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger { background: transparent; border-color: #f0c2bf; color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }

/* ------------------------------ 表单 ------------------------------ */
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; font-weight: 500; }
.req { color: var(--bad); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; margin-top: 6px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 14px; font-family: inherit; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,127,209,.14);
}
textarea { min-height: 80px; resize: vertical; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ------------------------------ 登录页 ------------------------------ */
.auth-screen {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1100px 520px at 12% -10%, #dcebfb 0%, transparent 60%),
    radial-gradient(900px 480px at 100% 0%, #e4f0ea 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 430px; background: var(--panel);
  border-radius: 18px; box-shadow: var(--shadow); padding: 30px 28px 22px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 800; font-size: 19px; letter-spacing: .5px;
}
.auth-brand h1 { margin: 0; font-size: 19px; font-weight: 700; }
.auth-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.tabs { display: flex; gap: 4px; background: #f1f4f9; padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.tab {
  flex: 1; padding: 8px; border: 0; background: transparent; border-radius: 7px;
  font-size: 14px; font-family: inherit; color: var(--ink-2); cursor: pointer; font-weight: 500;
}
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(24,39,75,.10); font-weight: 600; }
.auth-form label { margin-bottom: 14px; }
.auth-msg { min-height: 20px; font-size: 13px; margin: -4px 0 10px; color: var(--bad); }
.auth-msg.ok { color: var(--ok); }
.auth-foot { margin: 18px 0 0; text-align: center; font-size: 12.5px; color: var(--ink-3); }

/* ------------------------------ 主布局 ------------------------------ */
.app-screen { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-weight: 800; font-size: 13px;
}
.brand-name { font-weight: 700; font-size: 15.5px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  font-size: 13px; color: var(--ink-2); background: #f1f4f9;
  padding: 5px 11px; border-radius: 20px;
}
.user-chip b { color: var(--ink); }

.layout { flex: 1; display: flex; align-items: stretch; }
.sidebar {
  width: 186px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 9px;
  color: var(--ink-2); font-size: 14px; cursor: pointer; user-select: none;
  border: 0; background: transparent; font-family: inherit; text-align: left; width: 100%;
}
.nav-item:hover { background: #f1f4f9; color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-sep { font-size: 11px; color: var(--ink-3); padding: 14px 12px 5px; letter-spacing: .6px; }

.content { flex: 1; padding: 22px 26px 60px; min-width: 0; }

/* ------------------------------ 通用块 ------------------------------ */
.page-head { margin-bottom: 18px; }
.page-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.page-head p { margin: 0; color: var(--ink-3); font-size: 13.5px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
.card-head .sub { font-size: 12.5px; color: var(--ink-3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12.5px; color: var(--ink-3); margin-bottom: 5px; }
.stat .v { font-size: 25px; font-weight: 700; line-height: 1.15; letter-spacing: -.5px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.stat .d { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.stat.good .v { color: var(--ok); }
.stat.bad .v { color: var(--bad); }
.stat.brand .v { color: var(--brand); }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px;
  background: #f1f4f9; color: var(--ink-2); margin: 2px 4px 2px 0; line-height: 1.7;
}
.tag-blue { background: var(--brand-soft); color: var(--brand); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }

.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .55; }
.empty p { margin: 0 0 4px; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--line); }
table.tbl th { background: #f7f9fc; color: var(--ink-2); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.tbl tbody tr:hover { background: #fafbfd; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.nowrap { white-space: nowrap; }

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { margin-top: 0; width: auto; min-width: 130px; }
.toolbar .grow { flex: 1; }

/* ------------------------------ 试卷卡片 ------------------------------ */
.paper-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.paper-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.paper-card h4 { margin: 0; font-size: 16px; font-weight: 650; }
.paper-card .desc { font-size: 12.5px; color: var(--ink-3); min-height: 19px; }
.paper-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.paper-meta b { color: var(--ink); font-weight: 600; }
.paper-actions { display: flex; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.paper-actions .btn { flex: 1; min-width: 88px; }

/* ------------------------------ 考试界面 ------------------------------ */
.exam-wrap { max-width: 1080px; margin: 0 auto; }
.exam-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 13px 16px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 66px; z-index: 20;
}
.exam-bar .title { font-weight: 650; font-size: 15.5px; }
.exam-bar .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.timer {
  font-family: var(--mono); font-size: 23px; font-weight: 700; letter-spacing: 1px;
  padding: 3px 14px; border-radius: 9px; background: var(--brand-soft); color: var(--brand);
}
.timer.warn { background: var(--warn-soft); color: var(--warn); }
.timer.danger { background: var(--bad-soft); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.progress-mini { font-size: 12.5px; color: var(--ink-2); }
.progress-mini b { color: var(--brand); }

.exam-grid { display: grid; grid-template-columns: 1fr 232px; gap: 14px; align-items: start; }
@media (max-width: 860px) { .exam-grid { grid-template-columns: 1fr; } }

.q-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.q-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
.q-no { font-weight: 700; font-size: 15px; color: var(--brand); }
.q-stem { font-size: 16px; line-height: 1.75; margin-bottom: 16px; word-break: break-word; }
.opt-list { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex; gap: 11px; align-items: flex-start; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  transition: border-color .12s, background .12s; background: #fff;
}
.opt:hover { border-color: var(--brand-2); background: #fafcff; }
.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt .mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--ink-3);
  background: #fff;
}
.opt.selected .mark { border-color: var(--brand); background: var(--brand); color: #fff; }
.opt.multi .mark { border-radius: 6px; }
.opt .text { font-size: 14.5px; line-height: 1.65; word-break: break-word; }

.exam-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.answer-sheet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px; }
.answer-sheet h4 { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.sheet-cell {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  display: grid; place-items: center; font-size: 12.5px; cursor: pointer; color: var(--ink-2);
  font-family: inherit; padding: 0;
}
.sheet-cell.done { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.sheet-cell.current { outline: 2px solid var(--warn); outline-offset: 1px; font-weight: 700; }
.sheet-cell.flag { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.legend { margin-top: 12px; font-size: 12px; color: var(--ink-3); line-height: 1.9; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ------------------------------ 成绩单 ------------------------------ */
.score-hero {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.score-hero .big { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -2px; }
.score-hero .big small { font-size: 20px; font-weight: 600; opacity: .8; }
.score-hero .meta { font-size: 13.5px; opacity: .92; line-height: 2; }
.score-hero .pass { font-size: 16px; font-weight: 700; padding: 4px 14px; border-radius: 20px; background: rgba(255,255,255,.2); }
.score-hero.fail .pass { background: rgba(255,255,255,.18); }

.review-item { border: 1px solid var(--line); border-radius: 10px; padding: 15px; margin-bottom: 12px; background: #fff; }
.review-item.correct { border-left: 3px solid var(--ok); }
.review-item.wrong { border-left: 3px solid var(--bad); }
.review-item .rh { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; flex-wrap: wrap; }
.review-item .stem { font-size: 14.5px; line-height: 1.7; margin-bottom: 11px; word-break: break-word; }
.review-item .opt { cursor: default; padding: 7px 12px; font-size: 13.5px; }
.review-item .opt.right { background: var(--ok-soft); border-color: #9ad9bd; }
.review-item .opt.wrong { background: var(--bad-soft); border-color: #f0b3ae; }
.review-item .opt .mark { width: 21px; height: 21px; font-size: 11.5px; }
.explain {
  margin-top: 11px; padding: 11px 13px; background: #f7f9fc; border-radius: 8px;
  font-size: 13px; line-height: 1.75; color: var(--ink-2); white-space: pre-wrap; word-break: break-word;
}

/* ------------------------------ 图表 ------------------------------ */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 62px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef1f6; border-radius: 20px; height: 17px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; background: var(--brand); transition: width .4s; }
.bar-fill.low { background: var(--bad); }
.bar-fill.mid { background: var(--warn); }
.bar-fill.high { background: var(--ok); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; }

/* ------------------------------ 弹窗 ------------------------------ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 28, 45, .48); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.22);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 9px;
}
.icon-btn {
  border: 0; background: transparent; font-size: 21px; cursor: pointer; color: var(--ink-3);
  line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.icon-btn:hover { background: #f1f4f9; color: var(--ink); }

/* 多选框组 */
.chip-group { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 20px; background: #fff;
  font-size: 13px; cursor: pointer; user-select: none; transition: all .12s;
}
.chip:hover { border-color: var(--brand-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .cnt { font-size: 11.5px; opacity: .72; }

.switch-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 13px; }
.switch-row input { width: auto; margin: 0; }

/* ------------------------------ 提示 ------------------------------ */
.toast-root { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px;
  font-size: 13.5px; box-shadow: 0 6px 22px rgba(0,0,0,.2); max-width: 340px;
  animation: slideIn .2s ease-out;
}
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes slideIn { from { transform: translateX(18px); opacity: 0; } }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 8px;
  }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-sep { display: none; }
  .content { padding: 16px 14px 48px; }
  .exam-bar { top: 56px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .score-hero .big { font-size: 42px; }
  .bar-row { grid-template-columns: 96px 1fr 54px; }
}

@media print {
  .sidebar, .topbar, .exam-bar, .paper-actions, .toolbar { display: none !important; }
  .content { padding: 0; }
}
