/* 长沙托管智能错题培优系统 - 设计系统 */
:root {
  --brand: #3b5bdb;
  --brand-dark: #2b3fa8;
  --brand-soft: #eef2ff;
  --accent: #e03131;
  --accent-soft: #fff0f0;
  --green: #12b886;
  --green-soft: #e6fcf5;
  --amber: #f59f00;
  --amber-soft: #fff4e0;
  --violet: #8b5cf6;
  --ink: #1f2733;
  --ink-2: #4b5563;
  --ink-3: #8a94a6;
  --line: #e6eaf2;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 32px rgba(16,24,40,.14);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --yali: #e8452c;
  --changjun: #2b6de6;
  --yizhong: #16a34a;
  --shida: #8b5cf6;
  --tongyong: #f59e0b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd2e0; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 通用 ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; } .gap20 { gap: 20px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb20 { margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.h1 { font-size: 22px; font-weight: 700; }
.h2 { font-size: 17px; font-weight: 700; }
.h3 { font-size: 15px; font-weight: 600; }
.text-center { text-align: center; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; transition: all .15s ease; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #c92a2a; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover:not(:disabled) { background: #dfe6ff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: #0ca678; }
.btn-danger { background: var(--accent); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c92a2a; }

/* 徽标 */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.badge-red { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: #b87300; }
.badge-blue { background: var(--brand-soft); color: var(--brand); }
.badge-violet { background: #f3f0ff; color: var(--violet); }
.badge-gray { background: #f1f3f7; color: var(--ink-3); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; background: #f1f3f7; color: var(--ink-2); }

/* 表单 */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); transition: border .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.textarea { min-height: 80px; resize: vertical; }

/* 筛选 chip */
.chip { padding: 5px 12px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 权限勾选框 */
.perm-check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); background: #fff; transition: all .15s; user-select: none; }
.perm-check:hover { border-color: var(--brand); }
.perm-check.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.perm-check input { accent-color: var(--brand); cursor: pointer; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #dfe8ff 0%, transparent 55%),
              radial-gradient(1000px 600px at 110% 110%, #ffe9e9 0%, transparent 55%), var(--bg); }
.login-box { width: 100%; max-width: 980px; display: grid; grid-template-columns: 1.05fr 1fr; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-lg); background: #fff; }
.login-hero { padding: 46px 40px; color: #fff; background: linear-gradient(150deg, #2b3fa8 0%, #3b5bdb 55%, #5a78f0 100%); position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; right: -80px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); }
.login-hero h1 { font-size: 26px; line-height: 1.35; margin-bottom: 14px; }
.login-hero .sub { color: rgba(255,255,255,.85); font-size: 14px; }
.sys-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.sys-pill { padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25); font-size: 13px; font-weight: 600; }
.login-form { padding: 46px 40px; }
.req { color: var(--accent); font-weight: 700; }
.pwd-wrap { position: relative; }
.pwd-wrap .input { padding-right: 40px; }
.pwd-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 6px; color: var(--ink-3); }
.pwd-toggle:hover { color: var(--brand); }

/* 应用布局 */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: linear-gradient(180deg, #1b2440 0%, #232f55 100%);
  color: #cdd6ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 22px 20px 18px; display: flex; align-items: center; gap: 10px; color: #fff; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #ff7a7a, #e03131); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; color: #fff; }
.sidebar .logo b { font-size: 15px; letter-spacing: .5px; }
.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-radius: 10px;
  color: #b7c1dd; cursor: pointer; font-size: 14px; margin-bottom: 3px; transition: all .15s; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.on { background: var(--brand); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; font-size: 16px; }
.sidebar .foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #8b97b5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-weight: 700; font-size: 16px; }
.term-switch { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; border: 1px solid var(--line); }
.term-switch button { padding: 5px 14px; border: none; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.term-switch button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.content { padding: 24px; flex: 1; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* 底部导航（手机端） */
.bottom-nav { display: none; position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bottom-nav .bn-item { flex: 0 0 auto; min-width: 66px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; font-size: 11px; color: var(--ink-3); cursor: pointer; }
.bottom-nav .bn-item.on { color: var(--brand); }
.bottom-nav .bn-item .ico { font-size: 19px; }

/* 移动端/平板响应式 */
body.term-phone .sidebar { display: none; }
body.term-phone .bottom-nav { display: flex; }
body.term-phone .content { padding: 14px; }
body.term-phone .grid-4 { grid-template-columns: repeat(2, 1fr); }
body.term-phone .grid-3 { grid-template-columns: 1fr; }
body.term-phone .grid-2 { grid-template-columns: 1fr; }
body.term-pad .grid-4 { grid-template-columns: repeat(2, 1fr); }
body.term-pad .grid-3 { grid-template-columns: repeat(2, 1fr); }

/* 统计卡片 */
.stat-card { padding: 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); position: relative; overflow: hidden; }
.stat-card .ico { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 12px; }
.stat-card .val { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-card .lbl { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.stat-card .delta { font-size: 12px; font-weight: 600; margin-top: 4px; }

/* 错题卡片 */
.mistake-card { padding: 16px 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); transition: all .15s; cursor: pointer; }
.mistake-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.mistake-card .q { font-size: 14px; font-weight: 600; margin: 8px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.err-bar { height: 4px; border-radius: 2px; margin-bottom: 10px; }

/* 系统主题色 */
.sys-yali { color: var(--yali); } .bg-yali { background: #fdecea; }
.sys-changjun { color: var(--changjun); } .bg-changjun { background: #eaf1ff; }
.sys-yizhong { color: var(--yizhong); } .bg-yizhong { background: #e6f7ee; }
.sys-shida { color: var(--shida); } .bg-shida { background: #f3efff; }
.sys-tongyong { color: var(--tongyong); } .bg-tongyong { background: #fef6e7; }
.sys-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 18px; max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }

/* 拍题 */
.scan-box { border: 2px dashed #c7d0e2; border-radius: 16px; padding: 40px 20px; text-align: center; cursor: pointer; transition: all .2s; background: #fafbfe; }
.scan-box:hover { border-color: var(--brand); background: var(--brand-soft); }
.scan-box .big-ico { font-size: 44px; }
.scan-anim { height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.scan-line { width: 80%; height: 3px; background: linear-gradient(90deg, transparent, var(--brand), transparent); animation: scan 1.4s ease-in-out infinite; border-radius: 2px; }
@keyframes scan { 0%,100% { transform: translateY(-40px); opacity: .3; } 50% { transform: translateY(40px); opacity: 1; } }

/* 图表面板 */
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

/* 题库/试卷 */
.q-item { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fff; }
.q-item .stem { font-weight: 600; margin: 6px 0; }
.opt { display: block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px; margin-top: 6px; cursor: pointer; transition: all .12s; }
.opt:hover { border-color: var(--brand); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.opt.correct { border-color: var(--green); background: var(--green-soft); color: #0b7c5a; }
.opt.wrong { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.opt.disabled { pointer-events: none; }

.system-tab { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; background: #fff; transition: all .15s; }
.system-tab:hover { box-shadow: var(--shadow); }
.system-tab.on { border-width: 2px; }
.system-tab .name { font-weight: 800; font-size: 16px; }
.system-tab .desc { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }

/* 进度条 */
.progress { height: 8px; background: #eef1f7; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 6px; transition: width .4s ease; }

/* 空状态 */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ico { font-size: 42px; margin-bottom: 10px; }

/* 打印 */
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  .main, .content { padding: 0; }
  body { background: #fff; }
}

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(59,91,219,.25); border-top-color: var(--brand); border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }
.fade-enter-active, .fade-leave-active { transition: opacity .18s ease; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* ==================== 拍题摄像头 + 错因分析 ==================== */
.camera-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #0b1220; min-height: 260px; }
.camera-video { width: 100%; max-height: 420px; object-fit: contain; display: block; background: #0b1220; }
.camera-guide { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px; font-size: 12px; color: #fff; text-align: center; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.scan-thumb { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #eef1f7; flex-shrink: 0; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--brand), var(--violet)); border-radius: 6px; transition: width .4s ease; }
.cause-box { flex: 1; min-width: 0; background: var(--accent-soft); border: 1px solid #ffd8d8; border-radius: 12px; padding: 14px 16px; }
.cause-title { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.cause-type { display: inline-block; margin-top: 6px; padding: 2px 12px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
@media (max-width: 640px) {
  .camera-wrap { min-height: 200px; }
  .scan-thumb { width: 84px; height: 84px; }
}

/* ==================== 学段 tab + 知识库体系 ==================== */
.stage-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); transition: all .15s; }
.stage-tab:hover { border-color: var(--brand); color: var(--brand); }
.stage-tab.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.stage-tab .mono { font-weight: 800; }
.stage-ps { color: var(--tongyong); }
.stage-jhs { color: var(--brand); }
.stage-shs { color: var(--shida); }
.stage-tab.stage-ps.on { background: var(--tongyong); border-color: var(--tongyong); color: #fff; }
.stage-tab.stage-jhs.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.stage-tab.stage-shs.on { background: var(--shida); border-color: var(--shida); color: #fff; }
.tag-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-3); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.kb-subject { margin-bottom: 16px; }
.kb-subject-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; margin-bottom: 8px; }
.kb-subject-title .muted { margin-left: 6px; }
.kb-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.kb-module { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafbfe; }
.kb-module-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.kb-points { display: flex; flex-direction: column; gap: 4px; }
.kb-point { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 12px; transition: background .12s; }
.kb-point:hover { background: var(--brand-soft); }
.kb-point-name { font-weight: 500; color: var(--ink-2); }

/* 存储服务状态卡片 */
.storage-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafbfe; }
.storage-card .on { color: #12b886; }

/* 语义检索相似度条 */
.score-bar { flex: 1; height: 6px; border-radius: 999px; background: #eef0f4; overflow: hidden; }
.score-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #3b5bdb, #12b886); transition: width .3s ease; }

@media (max-width: 640px) {
  .stage-tab { padding: 6px 12px; font-size: 12px; }
  .kb-modules { grid-template-columns: 1fr; }
}
