:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --line: #e3e8f0;
  --txt: #1f2937;
  --muted: #6b7280;
  --brand: #4f46e5;
  --brand-d: #4338ca;
  --brand-soft: #eef2ff;
  --green: #16a34a;
  --red: #e11d48;
  --orange: #f97316;
  --blue: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--txt); font-size: 14px; }

.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 220px; flex: 0 0 220px; background: #171e2e; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; letter-spacing: .5px; }
.brand-txt b { display: block; color: #f1f5f9; font-size: 16px; }
.brand-txt span { font-size: 12px; color: #94a3b8; }
.nav { padding: 12px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: #cbd5e1;
  font-size: 14px; padding: 10px 14px; border-radius: 8px; cursor: pointer; text-align: left; width: 100%;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }
.nav-item.active::before { opacity: 1; }
.side-foot { padding: 14px 18px; font-size: 12px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

/* 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; border-bottom: 1px solid var(--line);
}
.page-title { font-size: 19px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.filter-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

.content { padding: 20px 24px 40px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

/* 控件 */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--txt); padding: 7px 14px;
  border-radius: 8px; cursor: pointer; font-size: 13px; transition: all .15s; display: inline-flex;
  align-items: center; gap: 5px; line-height: 1.4; white-space: nowrap;
}
.btn:hover { border-color: #c7d0de; background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { opacity: .88; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 2px 6px; }
.btn.link:hover { text-decoration: underline; background: none; }

.select, .input, .textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px;
  background: #fff; color: var(--txt); outline: none; font-family: inherit;
}
.select:focus, .input:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.input.inline, .select.inline { max-width: 170px; }
.textarea { width: 100%; resize: vertical; line-height: 1.6; }
label.field-label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 13px; color: #374151; }
label.field-label:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.7; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

/* 面板/卡片 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-head { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 16px 18px; }
.empty { text-align: center; color: var(--muted); padding: 46px 16px; }
.empty .empty-title { font-size: 15px; color: #374151; margin: 8px 0 4px; }
.empty .empty-actions { margin-top: 16px; display: flex; gap: 10px; justify-content: center; }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.search-input { min-width: 200px; }

/* 统计卡片 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 30px; font-weight: 800; line-height: 1.2; }
.stat-card .lab { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat-card .sub { color: var(--muted); font-size: 12px; }
.stat-card.acc-red .num { color: var(--red); }
.stat-card.acc-green .num { color: var(--green); }
.stat-card.acc-brand .num { color: var(--brand); }

/* 进度条 */
.pbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #eef2f7; }
.pbar > i { display: block; height: 100%; min-width: 1px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; background: #f8fafc; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl .num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .check-cell { width: 30px; }

.badge { display: inline-block; color: #fff; font-size: 12px; line-height: 1; padding: 4px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.small { font-size: 11px; padding: 2px 6px; }
.chip-num { font-variant-numeric: tabular-nums; font-weight: 700; }
.dim { color: var(--muted); }
.tag { display: inline-block; background: var(--brand-soft); color: var(--brand-d); font-size: 12px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.tag.off { background: #f3f4f6; color: #9ca3af; }
.tag.fallback { background: #fef3c7; color: #b45309; }

/* 作业行 */
.hw-list { display: flex; flex-direction: column; gap: 10px; }
.hw-row { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); align-items: center; flex-wrap: wrap; }
.hw-row.hidden-hw { opacity: .66; }
.hw-main { flex: 1; min-width: 260px; }
.hw-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hw-title .t { font-weight: 700; font-size: 15px; }
.hw-meta { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hw-bar-area { margin-top: 8px; }
.hw-bar-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.hw-stats { display: flex; gap: 12px; font-size: 12px; align-items: center; flex-wrap: wrap; }
.hw-ops { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* 开关 */
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* 学生明细页 */
.detail-head { margin-bottom: 14px; }
.back-link { color: var(--brand); cursor: pointer; background: none; border: 0; font-size: 13px; padding: 0; }
.sec-title { font-size: 17px; font-weight: 700; margin: 8px 0 2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-filter { border: 1px solid var(--line); background: #fff; padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 12px; transition: all .15s; }
.chip-filter.active { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.chip-filter b { font-variant-numeric: tabular-nums; }
.chip-filter[data-key="not_submitted"].active { border-color: var(--red); color: var(--red); background: #fff1f2; }
.chip-filter[data-key="need_correction"].active { border-color: var(--orange); color: var(--orange); background: #fff7ed; }
.chip-filter[data-key="corrected"].active { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
.chip-filter[data-key="perfect"].active { border-color: var(--green); color: var(--green); background: #f0fdf4; }

.seg { display: inline-flex; gap: 4px; }
.seg button { border: 1px solid var(--line); background: #fff; color: #475569; padding: 4px 8px; font-size: 12px; cursor: pointer; border-radius: 6px; transition: all .12s; }
.seg button:hover { border-color: #94a3b8; }
.seg button.on { color: #fff; border-color: transparent; font-weight: 700; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .15s ease; }
.dlg { position: relative; background: #fff; border-radius: 14px; width: 460px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: popIn .16s ease; }
.dlg.wide { width: 640px; }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.dlg-title { padding: 16px 20px 0; font-size: 16px; font-weight: 700; }
.dlg-x { position: absolute; right: 14px; top: 12px; border: 0; background: none; font-size: 20px; color: #9ca3af; cursor: pointer; }
.dlg-body { padding: 14px 20px; overflow: auto; }
.dlg-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }
.dlg-text { line-height: 1.8; color: #374151; }

/* toast */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 9px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slideUp .2s ease; }
.toast.success { background: #15803d; }
.toast.error { background: #be123c; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

/* 多选框组（班级/类别） */
.check-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 6px; }
.check-group label { display: flex; gap: 8px; align-items: center; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 13px; }
.check-group label:hover { border-color: var(--brand); }
.check-group input { accent-color: var(--brand); }

/* 看板入口 */
.board-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.board-card { background: linear-gradient(145deg, #1e293b, #0f172a); border-radius: 14px; padding: 20px; color: #e2e8f0; }
.board-card h3 { margin: 0 0 4px; color: #fff; font-size: 18px; }
.board-card .sub { color: #94a3b8; font-size: 12px; margin-bottom: 14px; }
.board-card .btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* loading */
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid #dbe3ef; border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn.danger-ghost { color: var(--red); border-color: #fecdd3; }
.btn.danger-ghost:hover { background: #fff1f2; border-color: var(--red); }

/* 班级/类别表格 */
.list-panel { padding: 0; overflow: hidden; }

@media (max-width: 900px) {
  .sidebar { width: 62px; flex-basis: 62px; }
  .brand-txt, .side-foot, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item::before { font-size: 16px; }
}
