:root {
  --primary: #0176bb;
  --primary-dark: #015f96;
  --primary-soft: #e6f2f9;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #1c2833;
  --muted: #6b7c8f;
  --border: #dfe6ee;
  --danger: #d64545;
  --warn: #c47f17;
  --ok: #1f9d6b;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 50, 80, .06), 0 12px 32px rgba(20, 50, 80, .05);
  --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.section-title { margin: 22px 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* ---------------- buttons & forms ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  background: #eef2f6; color: var(--text);
  padding: 9px 16px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: .16s ease; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.loading { pointer-events: none; opacity: .7; }
.file-btn { position: relative; }
.icon-btn {
  border: 0; background: transparent; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: #f1f4f8; }

input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; background: #fff; width: 100%; 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(1, 118, 187, .12);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
label { display: block; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { margin-top: 5px; color: var(--text); }
.select.sm { padding: 6px 10px; font-size: 13px; margin: 10px 14px 0; width: calc(100% - 28px); }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------------- auth ---------------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, #dcecf8 0%, transparent 60%),
    radial-gradient(700px 420px at 90% 90%, #e4f1fa 0%, transparent 60%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 380px; background: var(--card); border-radius: 16px;
  box-shadow: var(--shadow); padding: 32px 30px 26px;
}
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.auth-brand h1 { font-size: 22px; letter-spacing: .5px; }
.auth-brand p { color: var(--muted); font-size: 12px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { margin-top: 6px; padding: 11px; }
.auth-card .hint { margin-top: 14px; }
.student-link { display: block; text-align: center; margin-top: 18px; font-size: 13px; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: linear-gradient(145deg, #0b8fd4, var(--primary));
  color: #fff; font-weight: 700; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(1, 118, 187, .3);
}
.logo-mark.sm { width: 26px; height: 26px; font-size: 14px; border-radius: 7px; }

/* ---------------- admin shell ---------------- */
.admin-body { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: none; display: flex; align-items: center; gap: 26px;
  padding: 0 22px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: #123; }
.brand-sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button {
  border: 0; background: transparent; font-family: inherit; font-size: 14px;
  color: var(--muted); padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.tabs button:hover { background: #f2f6fa; color: var(--text); }
.tabs button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.userbar { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

.admin-main { flex: 1; padding: 20px 22px 30px; min-height: 0; }
.tab-panel { display: none; height: 100%; }
.tab-panel.active { display: block; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.panel.grow { min-width: 0; }
.panel.narrow { max-width: 720px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.panel-head h2 { color: #16324a; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-tip { color: var(--muted); font-size: 12px; margin: 2px 0 12px; }
.list-panel { position: sticky; top: 80px; }
.list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 190px); overflow: auto; padding: 2px; }
.list-item {
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px;
  cursor: pointer; background: #fbfcfe; transition: .14s;
}
.list-item:hover { border-color: #b9d7ea; background: #f5faff; }
.list-item.active { border-color: var(--primary); background: var(--primary-soft); }
.list-item .li-title { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.list-item .li-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.empty { color: var(--muted); font-size: 13px; padding: 26px 10px; text-align: center; }

/* ---------------- tables ---------------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
thead th {
  text-align: left; font-weight: 600; color: #3d556b; background: #f7f9fc;
  padding: 9px 11px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 8px 11px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfe; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; background: #eef2f6; color: var(--muted);
}
.tag.ok { background: #e5f6ee; color: var(--ok); }
.tag.warn { background: #fdf3e2; color: var(--warn); }
.tag.bad { background: #fdeaea; color: var(--danger); }
.tag.info { background: var(--primary-soft); color: var(--primary); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- checkin tab ---------------- */
.checkin-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.qr-box {
  border: 1px dashed var(--border); border-radius: 10px; min-height: 240px;
  display: flex; align-items: center; justify-content: center; padding: 12px; background: #fcfdff;
}
.qr-box img { width: 100%; max-width: 260px; display: block; border-radius: 6px; }
.qr-meta { margin: 10px 0; font-size: 12px; color: var(--muted); }
.qr-meta strong { color: var(--text); font-size: 14px; }
.stat-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 78px; background: #f7fafc; border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px;
}
.stat strong { display: block; font-size: 20px; color: #16324a; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.ok strong { color: var(--ok); }
.stat.warn strong { color: var(--warn); }
.stat.bad strong { color: var(--danger); }

/* ---------------- meta ---------------- */
.meta-line { color: var(--muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; margin: 2px 0 12px; }
.meta-line strong { color: var(--text); }

/* ---------------- forms in settings ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }
.form-grid p { grid-column: 1 / -1; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0 18px; }

/* ---------------- modal ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 36, 54, .42);
  display: none; align-items: center; justify-content: center; padding: 24px; z-index: 90;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(760px, 100%); max-height: 88vh; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 70px rgba(10, 30, 50, .3); display: flex; flex-direction: column;
  animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 18px 20px 22px; overflow: auto; }
.modal-body form { display: grid; gap: 12px; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: #16324a; color: #fff; padding: 10px 20px; border-radius: 24px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 120;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ---------------- mobile shells ---------------- */
.mobile-body { background: #eef3f8; }
.mobile-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 0 16px 28px; }
.mobile-shell.wide { max-width: 720px; }
.mobile-head {
  background: linear-gradient(150deg, #0b83c4, var(--primary));
  color: #fff; margin: 0 -16px 16px; padding: 18px 20px 20px;
  border-radius: 0 0 18px 18px;
}
.mobile-head.student, .mobile-head.homework {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.mobile-head.homework h1 { margin-top: 10px; font-size: 19px; }
.mobile-head.homework .btn { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); }
.mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.mobile-session { margin: 12px 0 10px; }
.mobile-session strong { font-size: 18px; display: block; }
.mobile-session span { font-size: 12px; opacity: .82; }
.qr-timer { font-size: 12px; background: rgba(255,255,255,.16); display: inline-block; padding: 3px 10px; border-radius: 20px; }
.qr-timer.expired { background: #ffd9d9; color: #9b1c1c; }

.step-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px; margin-bottom: 14px;
}
.step-card h2 { margin-bottom: 8px; color: #16324a; }
.step-card label { margin-bottom: 12px; display: block; }
.step-card input { margin-top: 6px; }
.mobile-foot { text-align: center; color: var(--muted); font-size: 11px; padding: 6px 0 10px; }

/* checkin verify */
.verify-grid { display: grid; gap: 12px; margin: 14px 0 16px; }
.geo-box {
  display: flex; gap: 12px; align-items: center;
  background: #f7fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
.geo-box > div:nth-child(2) { flex: 1; }
.geo-box p { font-size: 12px; }
.geo-icon { font-size: 24px; color: var(--primary); }
.camera-box {
  position: relative; background: #0d1a24; border-radius: 12px; overflow: hidden;
  aspect-ratio: 4 / 3;
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #cfe2f0; font-size: 13px; pointer-events: none; text-align: center; padding: 20px;
}
.liveness-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); background: #f7fafc;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.liveness-box .sep { flex-basis: 100%; height: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3ceda; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(31,157,107,.16); }
.dot.bad { background: var(--danger); }
.result-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff;
  font-size: 32px; display: flex; align-items: center; justify-content: center; margin: 6px auto 14px;
}
.result-icon.bad { background: var(--danger); }
.result-icon.warn { background: var(--warn); }
#stepResult { text-align: center; }
.result-flags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 12px 0 18px; }

/* student center */
.student-summary {
  background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.student-summary strong { font-size: 17px; }
.homework-cards { display: grid; gap: 12px; }
.hw-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: flex; justify-content: space-between;
  gap: 14px; align-items: center;
}
.hw-card h3 { font-size: 15px; margin-bottom: 4px; }
.hw-card .muted { font-size: 12px; }
.hw-card .score { font-size: 20px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.hw-card .score small { font-size: 11px; color: var(--muted); font-weight: 400; }

/* homework page */
.hw-desc { color: #3d556b; white-space: pre-wrap; }
.question-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px; border: 1px solid transparent;
}
.question-card.correct { border-color: #bfe8d5; }
.question-card.wrong { border-color: #f3c9c9; }
.q-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.q-index { color: var(--primary); font-weight: 700; margin-right: 6px; }
.q-type { font-size: 12px; color: var(--muted); white-space: nowrap; }
.q-stem { font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.options { display: grid; gap: 8px; margin-top: 12px; }
.option {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px; cursor: pointer; background: #fbfcfe; transition: .14s;
}
.option:hover { border-color: #b9d7ea; }
.option input { width: auto; margin: 4px 0 0; accent-color: var(--primary); }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option .opt-key { font-weight: 700; color: #3d556b; }
.q-answer-area { margin-top: 12px; }
.q-feedback { margin-top: 10px; font-size: 13px; }
.q-feedback.ok { color: var(--ok); }
.q-feedback.bad { color: var(--danger); }
.q-feedback .correct-answer { color: var(--text); background: #f2f7fb; border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
.point-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.point-list li { font-size: 12.5px; background: #f7fafc; border-radius: 7px; padding: 7px 10px; }
.point-list li.hit { background: #eef9f3; }
.point-list li.miss { background: #fdf1f1; }
.point-list .pv { float: right; font-weight: 600; }
.submit-bar {
  position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px 16px; margin: 18px 0;
}
.score-headline {
  background: var(--primary-soft); border-radius: 10px; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px;
}
.score-headline strong { font-size: 26px; color: var(--primary); }
.result-list { display: grid; gap: 10px; }
.result-item { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; }
.result-item .ri-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.result-item .ri-body { color: var(--muted); font-size: 12.5px; margin-top: 6px; white-space: pre-wrap; }

/* board */
.board-body { background: #0b1a26; color: #eaf4fb; min-height: 100vh; }
.board { min-height: 100vh; display: flex; flex-direction: column; padding: 26px 34px; }
.board-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.board-eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: 12px; color: #6fb6dd; }
.board-head h1 { font-size: 30px; margin: 6px 0 4px; }
.board-sub { color: #8fa9bc; font-size: 13px; }
.board-stats { display: flex; gap: 26px; }
.board-stats div { text-align: center; }
.board-stats strong { display: block; font-size: 34px; color: #7fd3ff; }
.board-stats span { font-size: 12px; color: #8fa9bc; }
.board-main { flex: 1; display: grid; grid-template-columns: 1fr 340px; gap: 30px; margin-top: 26px; align-items: start; }
.board-qr {
  background: #fff; border-radius: 20px; padding: 26px; text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.board-qr img { width: min(440px, 100%); aspect-ratio: 1; }
.board-progress { width: 100%; height: 6px; background: #e7eef5; border-radius: 4px; margin: 18px 0 10px; overflow: hidden; }
.board-progress span { display: block; height: 100%; width: 100%; background: var(--primary); transition: width .9s linear; }
.board-tip { color: #7b8fa0; font-size: 12px; }
.board-side h2 { font-size: 14px; color: #8fa9bc; margin-bottom: 12px; letter-spacing: .08em; }
.board-feed { display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow: auto; margin-bottom: 18px; }
.feed-item {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px; padding: 9px 12px; font-size: 13px;
  display: flex; justify-content: space-between; gap: 10px;
}
.feed-item span { color: #8fa9bc; font-size: 12px; }
.feed-item.bad { border-color: rgba(214,69,69,.5); }

/* responsive */
@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
  .list-panel { position: static; }
  .checkin-layout { grid-template-columns: 1fr; }
  .board-main { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; overflow: auto; }
  .brand-sub { display: none; }
  .admin-main { padding: 14px; }
  .board { padding: 16px; }
  .board-head { flex-direction: column; }
}
