/* 学生考试成绩分析系统 Web 版 — 试卷工具风格 */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #26241f;
  --muted: #8a8577;
  --line: #e3ded2;
  --accent: #b03a2e;
  --accent-dark: #8c2d23;
  --accent-soft: #f9ecea;
  --green: #2e7d32;
  --green-bg: #e6f2e7;
  --red: #c62828;
  --red-bg: #fdeaea;
  --yellow: #9c6500;
  --yellow-bg: #fdf3d7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(38, 36, 31, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; height: 52px;
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; color: var(--ink); }
.brand em { color: var(--accent); font-style: normal; }
.nav {
  display: flex; gap: 2px; overflow-x: auto; flex: 1;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 10px; border-radius: 6px; color: var(--ink);
  white-space: nowrap; font-size: 13.5px;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.user-name { color: var(--muted); font-size: 13px; }
.cohort-box { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.cohort-box > span { font-size: 12px; color: var(--muted); }
.cohort-select { width: 150px; padding: 4px 24px 4px 7px; font-size: 12.5px; }

/* 布局 */
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.page-head .desc { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* 卡片 */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .hint { font-size: 12px; color: var(--muted); font-weight: 400; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13.5px;
  cursor: pointer; transition: background .15s, border-color .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--red); border-color: #ecc; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* 表单 */
.input, .select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; background: var(--surface); color: var(--ink);
}
.input:focus, .select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 140px; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fbfaf7; position: sticky; top: 0; }
.table tr:hover td { background: #fbfaf7; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* 徽章 / 标签 */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 1.7;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-gray { background: var(--bg); color: var(--muted); }

/* 得分率着色（与 Excel 一致） */
.rate-high { background: var(--green-bg); color: var(--green); }
.rate-low { background: var(--red-bg); color: var(--red); }
.rate-mid { background: var(--yellow-bg); color: var(--yellow); }
.rate-cell { padding: 1px 7px; border-radius: 4px; font-variant-numeric: tabular-nums; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 8px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 12.5px; }

/* 选项卡 */
.tabs { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 18px; border-radius: 6px;
  font: inherit; cursor: pointer; color: var(--muted);
}
.tabs button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* 上传区 */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.dropzone .big { font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.dropzone input[type=file] { display: none; }
.file-chosen { margin-top: 8px; font-size: 12.5px; color: var(--green); word-break: break-all; }

/* 进度/结果 */
.result-list { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.result-list li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.result-list li.ok::before { content: "✓ "; color: var(--green); font-weight: 700; }
.result-list li.fail::before { content: "✗ "; color: var(--red); font-weight: 700; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(38, 36, 31, .45);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 40px 12px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 640px; padding: 18px; box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.modal h3 { font-size: 15px; margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* 抽屉（学生详情） */
.drawer-mask { position: fixed; inset: 0; background: rgba(38,36,31,.45); display: none; z-index: 100; }
.drawer-mask.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 96vw);
  background: var(--surface); z-index: 101; overflow-y: auto;
  transform: translateX(100%); transition: transform .2s; padding: 20px;
  box-shadow: -4px 0 20px rgba(0,0,0,.15);
}
.drawer.show { transform: translateX(0); }
.drawer-close { position: sticky; top: 0; float: right; }

/* 提示条 */
.toast-box { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(480px, 92vw); }
.toast {
  padding: 10px 16px; border-radius: 8px; background: var(--ink); color: #fff;
  font-size: 13.5px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: toast-in .2s ease-out;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* 模块选择器 */
.mod-tree { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.mod-chapter { border-bottom: 1px solid var(--line); }
.mod-chapter > header {
  padding: 8px 12px; font-weight: 600; font-size: 13px; background: #fbfaf7;
  position: sticky; top: 0;
}
.mod-items { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
.mod-chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px;
  font-size: 12.5px; cursor: pointer; user-select: none; background: var(--surface);
}
.mod-chip:hover { border-color: var(--accent); }
.mod-chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.q-mod-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.q-mod-chips .chip {
  background: var(--accent-soft); color: var(--accent-dark);
  border-radius: 4px; padding: 0 6px; font-size: 12px;
}

/* 工具行 */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.sticky-bar {
  position: sticky; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--line); padding: 10px 0;
  display: flex; gap: 10px; align-items: center; z-index: 10; flex-wrap: wrap;
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.spin {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* 登录页 */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-card h1 { font-size: 19px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-err { color: var(--red); font-size: 13px; min-height: 20px; text-align: center; margin-bottom: 8px; }

@media (max-width: 640px) {
  /* 手机端将全部导航放到第二行，避免横向滚动时功能入口被遮住。 */
  .topbar-inner { height: auto; min-height: 52px; gap: 8px; padding: 7px 10px 0; flex-wrap: wrap; }
  .brand { font-size: 13.5px; }
  .user-name { display: none; }
  .cohort-box > span { display: none; }
  .cohort-select { width: 122px; }
  .nav { order: 3; flex: 0 0 100%; flex-wrap: wrap; overflow: visible; padding-bottom: 7px; }
  .nav a { padding: 4px 6px; font-size: 12px; }
  .container { padding: 14px 10px 60px; }
  .page-head h1 { font-size: 17px; }
  .table th, .table td { padding: 6px 8px; }
}
