/* ===== 中童学习平台 · 设计系统 ===== */
:root {
  --brand: #2f62f4;
  --brand-dark: #1e4bd8;
  --brand-50: #eef3ff;
  --brand-100: #dbe5ff;
  --accent: #ff7a45;
  --accent-50: #fff2ec;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e7ecf5;
  --line-2: #f0f3f9;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #12b76a;
  --ok-50: #e8f8f0;
  --warn: #f79009;
  --warn-50: #fef4e6;
  --danger: #f04438;
  --danger-50: #feeceb;
  --info: #2e90fa;
  --info-50: #eaf4ff;
  --r: 14px;
  --r-sm: 10px;
  --r-lg: 20px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .04);
  --sh-2: 0 10px 30px -14px rgba(16, 24, 40, .18);
  --sh-3: 0 24px 60px -24px rgba(16, 24, 40, .28);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d6dce8; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c2c9d8; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: .16s ease;
}
.btn:hover { border-color: #cfd8ea; background: #fbfcff; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 16px -8px rgba(47, 98, 244, .8);
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: var(--brand-50); border-color: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-100); }
.btn.danger { color: var(--danger); border-color: #f7d3d0; background: #fff; }
.btn.danger:hover { background: var(--danger-50); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.link { border: none; background: none; padding: 0; height: auto; color: var(--brand); font-weight: 500; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--line-2); color: var(--muted); white-space: nowrap;
}
.tag.ok { background: var(--ok-50); color: #0a8a52; }
.tag.warn { background: var(--warn-50); color: #b35c00; }
.tag.danger { background: var(--danger-50); color: #c02a1f; }
.tag.info { background: var(--info-50); color: #1266c9; }
.tag.brand { background: var(--brand-50); color: var(--brand); }
.tag.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-size: 13.5px; outline: none; transition: .15s;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
/* textarea 用 .input 时也要撑开，否则 rows 属性被 height:36px 压扁 */
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.65; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 98, 244, .12);
}
.select {
  appearance: none; cursor: pointer; padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }
.field .hint { color: var(--muted-2); font-size: 12px; margin-top: 5px; }

/* 表格 */
.table-wrap { width: 100%; overflow: auto; }
table.tb { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.tb th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 500; color: var(--muted);
  background: #fafbfe; padding: 11px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-size: 12.5px;
}
table.tb td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
/* 单元格统一左右居中：表格是数据网格，居中最容易看出列与列的边界；
   需要左对齐的单元格在 th/td 上加 class="tl"（树形分类、长文本描述用） */
table.tb th, table.tb td { text-align: center; }
table.tb td .uname, table.tb td .cell-actions { justify-content: center; }
/* 头像 + 姓名两行的那种（姓名 / 部门），组内左对齐才不会一行一个居中 */
table.tb td .uname > div:last-child { text-align: left; }
/* 主列（第一列：姓名 / 课程名 / 考试名）左对齐——标题长短不一，居中会左右都参差 */
table.tb th:first-child, table.tb td:first-child { text-align: left; }
table.tb td:first-child .uname, table.tb td:first-child .cell-actions { justify-content: flex-start; }
table.tb th.tl, table.tb td.tl { text-align: left; }
table.tb td.tl .uname, table.tb td.tl .cell-actions, table.tb td.tl .row { justify-content: flex-start; }
table.tb tbody tr:hover { background: #fafcff; }
table.tb tbody tr:last-child td { border-bottom: none; }
table.tb .t-title { font-weight: 550; color: var(--ink); }
table.tb .t-sub { color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.cell-actions { display: flex; gap: 12px; white-space: nowrap; }
.cell-actions a { color: var(--brand); font-size: 13px; cursor: pointer; }
.cell-actions a.danger { color: var(--danger); }
.cell-actions a:hover { text-decoration: underline; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted-2); }
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: 10px; }

/* 进度条 */
.bar { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }

/* 弹层 */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .42);
  backdrop-filter: blur(2px); z-index: 90; opacity: 0; pointer-events: none; transition: .2s;
}
.mask.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; z-index: 96; left: 50%; top: 50%; transform: translate(-50%, -46%) scale(.98);
  width: 560px; max-width: calc(100vw - 32px); max-height: calc(100vh - 80px);
  background: #fff; border-radius: 18px; box-shadow: var(--sh-3);
  opacity: 0; pointer-events: none; transition: .22s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal.lg { width: 860px; }
.modal.md { width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 14px; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head .x { cursor: pointer; color: var(--muted-2); display: flex; }
.modal-head .x:hover { color: var(--ink); }
/* flex 子项要显式给 min-height:0，否则内容再高也不会收缩，overflow:auto 形同虚设（弹窗底部被裁掉） */
.modal-body { padding: 4px 22px 20px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--line-2);
  display: flex; justify-content: flex-end; gap: 10px; background: #fcfdff;
}

/* 抽屉 */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 620px; max-width: 100vw;
  background: #fff; z-index: 91; box-shadow: var(--sh-3);
  transform: translateX(102%); transition: .26s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer .modal-body { flex: 1; }

/* toast */
#toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #101828; color: #fff; padding: 9px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--sh-2); animation: tin .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: #0b7a49; }
.toast.err { background: #b42318; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

.skeleton { background: linear-gradient(90deg, #eef1f8 25%, #f7f9fd 37%, #eef1f8 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.fade-in { animation: fin .32s ease both; }
@keyframes fin { from { opacity: 0; transform: translateY(6px); } }

.grid { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
