:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2733;
  --muted: #6b7785;
  --primary: #3b6ef5;
  --primary-d: #2f59c7;
  --border: #e4e9f0;
  --math: #e8f0ff;
  --math-c: #2f59c7;
  --chinese: #fdeeee;
  --chinese-c: #d9534f;
  --english: #eafaf1;
  --english-c: #1f9d55;
  --shadow: 0 2px 10px rgba(31, 39, 51, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }

/* 顶部导航 */
.nav {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav .brand { font-weight: 700; font-size: 16px; margin-right: 18px; white-space: nowrap; flex-shrink: 0; }
.nav a {
  padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500;
  white-space: nowrap; flex-shrink: 0;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--math); color: var(--primary-d); }

.container { max-width: 1080px; margin: 22px auto; padding: 0 18px; }
.page-title { font-size: 20px; font-weight: 700; margin: 4px 0 16px; }
.sub { color: var(--muted); margin-bottom: 18px; }

/* 卡片与统计 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.card .num { font-size: 28px; font-weight: 700; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  background: var(--primary); color: #fff; transition: .15s;
}
.btn:hover { background: var(--primary-d); }
.btn.secondary { background: #eef2f8; color: var(--text); }
.btn.secondary:hover { background: #e2e8f2; }
.btn.danger { background: #fdecec; color: #d9534f; }
.btn.ghost { background: transparent; color: var(--primary); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1; min-width: 124px; }
/* 日期控件默认最小宽度较大，会挤得整行换行，这里允许收缩 */
input[type="date"] { min-width: 0; }
/* 表单右侧的提交类按钮：不参与拉伸，且换行时右对齐 */
.row .field.btn-field { flex: 0 0 auto; margin-left: auto; }

/* 徽标 */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge.math { background: var(--math); color: var(--math-c); }
.badge.chinese { background: var(--chinese); color: var(--chinese-c); }
.badge.english { background: var(--english); color: var(--english-c); }
.badge.gray { background: #eef2f8; color: var(--muted); }
.badge.ok { background: var(--english); color: var(--english-c); }
.badge.warn { background: #fff4e5; color: #c77700; }

/* 列表 */
.list { display: grid; gap: 16px; margin-top: 8px; }
.item {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; transition: .15s;
}
.item:hover { border-color: var(--primary); }
.item .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.item .q { margin: 8px 0 4px; font-weight: 600; }
.item .ans { font-size: 13px; }
.item .ans .wrong { color: var(--chinese-c); }
.item .ans .right { color: var(--english-c); }

/* 详情弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,28,40,.45); display: none;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; max-width: 560px; width: 100%; padding: 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.modal h3 { margin-top: 0; }
.modal .close { float: right; cursor: pointer; color: var(--muted); font-size: 20px; border: none; background: none; }

.empty { text-align: center; color: var(--muted); padding: 40px; }
/* 统一空状态（.empty 增强版：图标 + 标题 + 说明） */
.empty-icon { font-size: 34px; line-height: 1; margin-bottom: 12px; opacity: .75; }
.empty-title { font-size: 15px; font-weight: 600; color: #42506b; margin-bottom: 8px; }
.empty-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* 举一反三：结果区 */
.prac-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 10px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.prac-head b { color: #2a3550; }
.prac-count { font-size: 12.5px; color: var(--muted); }
.prac-item .q { margin: 6px 0 8px; }
.prac-opts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 8px; }
.prac-opt { font-size: 13.5px; color: #37405a; }

/* 错误提示卡（含重试入口） */
.alert-error {
  display: flex; gap: 14px; align-items: flex-start;
  background: #fff8f6; border: 1px solid #f5c9c0; border-left: 4px solid #e2574c;
  border-radius: var(--radius); padding: 16px 18px; margin: 6px 0 4px;
}
.alert-icon { font-size: 26px; line-height: 1; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 700; color: #b3392e; margin-bottom: 6px; }
.alert-detail { font-size: 13px; color: #6b4a45; line-height: 1.6; word-break: break-word; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* 统一学员筛选：各模块同一控件、同一文案 */
select.student-select {
  min-width: 148px; font-weight: 600; color: var(--primary-d);
  background-color: #fff; cursor: pointer;
}
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px;
}
.filter-bar > label { font-weight: 600; font-size: 13px; color: #42506b; margin: 0; }
/* 当前筛选范围/统计行：切换学员后同步刷新 */
.scope-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); margin-bottom: 14px;
}
.scope-line b { color: #2a3550; font-weight: 700; }
.scope-line .pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef2fb; color: var(--primary-d);
  border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.tabs { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.tabs label { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; white-space: nowrap; font-size: 13px; color: var(--muted); }
.tabs label input[type="checkbox"] { width: auto; margin: 0; }
.tab {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0;
  transition: .25s; z-index: 100; pointer-events: none;
}
.toast.show { opacity: 1; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.print-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
@media (max-width: 820px) {
  /* 窄屏：统计行与操作按钮分行左对齐，避免挤在一行里错位 */
  .print-tools { flex-direction: column; align-items: flex-start; gap: 10px; }
  .print-tools .actions { width: 100%; flex-wrap: wrap; }
  .scope-line { row-gap: 6px; }
}
@media (max-width: 600px) {
  .container { padding: 0 12px; }
  .row .field { min-width: 100%; }
  .row .field.btn-field { margin-left: 0; width: 100%; }
  .row .field.btn-field .btn { width: 100%; }
}

/* ============ 打印样式：错题卷 / 练习卷 ============ */
@media print {
  .nav, .print-tools, .no-print, .actions { display: none !important; }
  body { background: #fff; }
  .container { max-width: 100%; margin: 0; padding: 0 16px; }
  .item, .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .badge { border: 1px solid #999; }
  @page { margin: 14mm; }
}

/* ============ 家长端提交记录：缩略图 + 逐题批改 + 加错题 ============ */
/* 每条提交：白卡 + 状态左侧色条 + 头部/分隔线/底部，记录间留清晰间距 */
.sub-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .18s, transform .18s;
}
.sub-card.status-done { border-left-color: var(--english-c); }
.sub-card.status-error { border-left-color: var(--chinese-c); }
.sub-card.status-processing { border-left-color: #f0a020; }
.sub-card:hover { box-shadow: 0 6px 18px rgba(31,39,51,.10); transform: translateY(-1px); }

.sub-head { display: flex; align-items: center; gap: 12px; }
.sub-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--math); color: var(--primary-d);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.sub-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sub-date { font-weight: 700; color: var(--text); font-size: 14px; }
.sub-line2 { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sub-badges { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* 每条提交记录的删除按钮（右上角） */
.sub-del {
  border: none; background: transparent; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 8px;
  color: var(--muted); transition: background .15s, color .15s; flex-shrink: 0;
}
.sub-del:hover { background: #fdeaea; color: var(--chinese-c); }
.sub-card.deleting { opacity: .5; pointer-events: none; }

.sub-divider { height: 1px; background: var(--border); margin: 12px 0; }

/* 提交记录主体：左缩略图 + 右批改结果，强制同一行且等高对齐 */
.sub-body {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: nowrap;
}
.thumb-wrap {
  flex: 0 0 auto;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.thumb { width: 46px; height: 46px; border-radius: 11px; border: 1px solid var(--border); background: var(--math); color: var(--primary-d); font-size: 23px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .15s; flex-shrink: 0; }
.thumb:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(59,110,245,.18); transform: translateY(-1px); }
.thumb-empty { min-height: 46px; width: 46px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.thumb-cap { font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; }
/* 提交记录 / 错题本 通用筛选条 */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar label { font-weight: 600; }
.filter-bar select { width: auto; min-width: 150px; }
.filter-bar .sub { margin: 0; }
/* 批改结果缩略图（点击弹出完整逐题内容） */
.result-thumb {
  flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: #fafbfe;
  padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; gap: 4px;
  transition: .15s;
}
.result-thumb.clickable { cursor: pointer; }
.result-thumb.clickable:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(59,110,245,.18); background: #f3f7ff; }
.result-thumb.disabled { opacity: .65; cursor: default; }
.result-thumb .rt-icon { font-size: 19px; }
.result-thumb .rt-title { font-weight: 700; color: var(--text); font-size: 13px; }
.result-thumb .rt-sum { font-size: 12.5px; color: var(--text); }
.result-thumb .rt-sum .rt-ok { color: var(--english-c); font-weight: 600; }
.result-thumb .rt-sum .rt-bad { color: var(--chinese-c); font-weight: 600; }
.result-thumb .rt-hint { font-size: 11px; color: var(--primary); margin-top: 2px; }
/* 结果缩略图：标题行 + 学科分布彩标 */
.result-thumb .rt-top { display: flex; align-items: center; gap: 6px; }
.result-thumb .rt-subjs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.result-thumb .rt-subj { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11.5px; font-weight: 600; }
.result-thumb .rt-subj.math { background: var(--math); color: var(--math-c); }
.result-thumb .rt-subj.chinese { background: var(--chinese); color: var(--chinese-c); }
.result-thumb .rt-subj.english { background: var(--english); color: var(--english-c); }
.result-thumb .rt-subj.other { background: #eef2f8; color: var(--muted); }
.result-thumb .rt-nosubj { font-size: 11.5px; color: var(--muted); }
/* 窄屏适配：缩略图与批改结果保持同行，尺寸等比收窄避免溢出 */
@media (max-width: 520px) {
  .nav { padding: 0 10px; gap: 2px; }
  .nav .brand { font-size: 15px; margin-right: 8px; }
  .nav a { padding: 8px 8px; font-size: 13px; }
  .sub-body { gap: 10px; }
  .thumb-wrap { width: 58px; gap: 4px; }
  .thumb { width: 42px; height: 42px; font-size: 21px; border-radius: 10px; }
  .thumb-cap { font-size: 10px; }
  .result-thumb { padding: 8px 10px; gap: 3px; border-radius: 9px; }
  .result-thumb .rt-icon { font-size: 17px; }
  .result-thumb .rt-title { font-size: 12.5px; }
  .result-thumb .rt-sum { font-size: 12px; }
  .result-thumb .rt-hint { font-size: 10.5px; margin-top: 1px; }
}
@media (max-width: 380px) {
  .sub-body { gap: 8px; }
  .thumb-wrap { width: 52px; }
  .thumb { width: 38px; height: 38px; font-size: 19px; border-radius: 9px; }
  .thumb-cap { font-size: 9.5px; }
  .result-thumb { padding: 7px 9px; }
}
.wq-list { display: grid; gap: 10px; }
.wq-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fafbfe; }
.wq-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.wq-no { font-weight: 700; color: var(--text); }
.wq-kp { font-size: 12px; color: var(--muted); }
.wq-q { font-weight: 600; margin-bottom: 6px; line-height: 1.5; }
.wq-a { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.wq-a .lbl { display: inline-block; margin-right: 4px; }
.wq-a .val { margin-right: 16px; color: var(--text); }
.wq-a .val.right { color: var(--english-c); font-weight: 600; }
.wq-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wq-foot .mark.ok { color: var(--english-c); font-weight: 600; }
.wq-foot .mark.bad { color: var(--chinese-c); font-weight: 600; }
.wq-empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.mini-btn { border: 1px solid var(--primary); background: #fff; color: var(--primary); border-radius: 8px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.mini-btn:hover { background: var(--primary); color: #fff; }
.mini-btn.added, .mini-btn:disabled { background: #eef2f8; color: var(--muted); border-color: var(--border); cursor: default; }
/* 批改结果弹窗 */
.result-modal { max-width: 680px; width: 100%; }
.result-modal .rm-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
