:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { font-size: 16px; color: #fff; font-weight: 600; letter-spacing: .5px; }
.brand p { font-size: 11px; color: #64748b; margin-top: 3px; letter-spacing: 1.5px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: 0; background: transparent; text-align: left;
  font-family: inherit; line-height: 1.6;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; color: #cbd5e1; margin-bottom: 2px;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 500; }
.nav-item .ico { width: 16px; text-align: center; opacity: .9; }

/* 导航分组：题目维护 / 试题导入 / 导入记录 挂在「题库管理」下面 */
.nav-group { margin-bottom: 2px; }
.nav-item.nav-parent.current { background: rgba(255,255,255,.07); color: #fff; }
.nav-sub { margin: 0 0 6px 17px; padding-left: 9px; border-left: 1px solid rgba(255,255,255,.1); }
.nav-item.sub { padding: 7px 10px; font-size: 13px; color: #9fadc2; }
.nav-item.sub .ico { width: 14px; font-size: 11px; opacity: .7; }
.nav-item.sub:hover { color: #fff; }
.nav-item.sub.active { background: rgba(37,99,235,.3); color: #fff; font-weight: 500; }

/* 侧栏底部：学员端入口 + 账号 + 操作，三层收在一起 */
.sidebar-foot { padding: 12px 14px 14px; border-top: 1px solid rgba(255,255,255,.07); }
.h5-link {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 0 0 12px; padding: 0; border-radius: 0;
  font-size: 12px; color: #8fa0b8; background: none;
}
.h5-link i { font-style: normal; font-size: 11px; opacity: .75; }
.h5-link:hover { color: #dbe4f5; background: none; }

.who { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; }
.who-avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; line-height: 1; color: #fff;
  background: linear-gradient(135deg, #4c6ef5, #7048e8);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.who-id { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.who-name {
  font-size: 12.5px; line-height: 1.35; color: #e2e8f4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-role { font-size: 10.5px; line-height: 1.3; color: #7d8ca3; }

.who-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.who-acts .btn.tiny {
  width: 100%; height: 27px; padding: 0; border-radius: 7px;
  font-size: 12px; color: #cdd7e6;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.11);
}
.who-acts .btn.tiny:hover { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.18); color: #fff; }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; font-weight: 600; }
.page-head p { color: var(--ink-3); font-size: 13px; margin-top: 2px; }

/* ---------- 卡片 / 通用 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; font-size: 13px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: var(--red-soft); }
.btn.danger:hover { background: #fee2e2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, .select {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.input::placeholder { color: #94a3b8; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* 行内操作收纳（R-30）：主操作只留 2 个，其余进「⋯」菜单，
   窄屏下不再换行错位。用原生 <details>，不引第三方菜单组件。 */
.more-menu { position: relative; display: inline-block; }
.more-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary::marker { content: ''; }
.more-menu[open] > summary { background: #eef2f8; }
.more-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 132px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  background: #fff; border: 1px solid #e6ebf3; border-radius: 10px;
  box-shadow: 0 10px 26px -12px rgba(20, 33, 66, .45);
}
.more-menu .menu .btn { width: 100%; justify-content: flex-start; text-align: left; }
/* 之前漏定义，导致 toolbar 里的 input/占位 span 撑不开 */
.grow { flex: 1 1 auto; min-width: 0; }


/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { font-size: 12.5px; color: var(--ink-3); }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -.5px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 2px; }
.stat::after {
  content: ''; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px;
  border-radius: 50%; background: var(--brand-soft);
}
.stat.green::after { background: var(--green-soft); }
.stat.amber::after { background: var(--amber-soft); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfd; }
.stem-cell { max-width: 520px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 500; white-space: nowrap;
}
.tag.gray { background: #f1f5f9; color: var(--ink-3); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }

.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.empty .big { font-size: 32px; margin-bottom: 8px; opacity: .35; }

/* ---------- 错误态（区别于空态） ---------- */
.error-state { padding: 36px 20px; text-align: center; font-size: 13.5px; color: var(--ink-2); }
.error-state .big { font-size: 30px; margin-bottom: 8px; color: var(--red); opacity: .9; }
.error-state .emsg { color: var(--ink-2); margin-bottom: 4px; word-break: break-word; }
.error-state .ehint { color: var(--ink-3); font-size: 12.5px; }

/* ---------- 筛选标记 ---------- */
.filter-badge { margin-left: 2px; white-space: nowrap; }

/* ---------- 导入 ---------- */
.dropzone {
  border: 2px dashed #cbd5e1; border-radius: 12px; padding: 38px 20px;
  text-align: center; background: #fbfcfe; cursor: pointer; transition: all .18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-ico { font-size: 34px; margin-bottom: 10px; }
.dropzone .dz-main { font-size: 14.5px; font-weight: 500; }
.dropzone .dz-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 6px; }

.summary-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-pill {
  flex: 1; min-width: 130px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff;
}
.summary-pill .n { font-size: 22px; font-weight: 650; }
.summary-pill .t { font-size: 12px; color: var(--ink-3); }
.summary-pill.ok { background: var(--green-soft); border-color: #bbf7d0; }
.summary-pill.ok .n { color: var(--green); }
.summary-pill.bad { background: var(--red-soft); border-color: #fecaca; }
.summary-pill.bad .n { color: var(--red); }

.notice { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }
.notice.info { background: var(--brand-soft); color: #1e40af; }
.notice.warn { background: var(--amber-soft); color: #92400e; }
.notice.ok { background: var(--green-soft); color: #166534; }
.notice.err { background: var(--red-soft); color: #991b1b; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 720px; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 60px -12px rgba(0,0,0,.35);
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { cursor: pointer; color: var(--ink-3); font-size: 20px; line-height: 1; padding: 4px; border: 0; background: transparent; font-family: inherit; }
.close-x:hover { color: var(--ink); }
.close-x:focus-visible, .nav-item:focus-visible, .pcell:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.field .input, .field .select, .field textarea { width: 100%; }
.field textarea {
  min-height: 76px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; outline: none;
}
.field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row .key { width: 26px; height: 26px; border-radius: 6px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.opt-row .input { flex: 1; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.pager .btns { display: flex; gap: 6px; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: all .25s; z-index: 200; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

.bar { height: 6px; background: #f1f5f9; border-radius: 999px; margin-top: 6px; position: relative; }
/* 60% 基准刻线（R-29）：没有刻度时 21.4% 和 58.3% 只是「短一点/长一点」，
   有了一条固定竖线，才能一眼看出「过半没过半」。overflow 不能 hidden，否则刻度会被裁掉 */
.bar::after {
  content: ''; position: absolute; left: 60%; top: -2px; bottom: -2px;
  width: 1px; background: rgba(15, 23, 42, .22); pointer-events: none;
}
body.dark .bar::after, html[data-theme="dark"] .bar::after { background: rgba(255, 255, 255, .28); }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.green > i { background: var(--green); }
.bar.red > i { background: var(--red); }

.muted { color: var(--ink-3); }

/* ---------- 学员端设置（策略开关） ---------- */
.pcell { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; border: 0; background: transparent; padding: 0; font-family: inherit; color: inherit; text-align: left; }
.pcell em { font-style: normal; font-size: 12.5px; color: var(--ink-3); }
.pswitch {
  position: relative; flex: none;
  width: 42px; height: 24px; border-radius: 12px;
  background: #dbe3ef; transition: background .18s;
}
.pswitch b {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .22);
  transition: transform .18s;
}
.pswitch.on { background: var(--brand); }
.pswitch.on b { transform: translateX(18px); }
.pcell:hover em { color: var(--ink-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav-item { white-space: nowrap; margin-bottom: 0; width: auto; flex: none; }
  /* 窄屏没有纵向空间做层级，摊平成一条横向滚动条 */
  .nav-group { display: flex; align-items: center; gap: 4px; margin-bottom: 0; }
  .nav-sub { display: flex; gap: 4px; margin: 0; padding: 0; border: 0; }
  .nav-item.sub { padding: 9px 12px; font-size: 13.5px; }
  .sidebar-foot { display: none; }
  .main { padding: 16px; }
}

/* ================= 登录页 ================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e8f0ff 0%, rgba(232, 240, 255, 0) 70%),
    var(--bg);
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px 22px;
  box-shadow: 0 12px 40px -18px rgba(15, 23, 42, .28);
}
.login-brand { display: flex; align-items: baseline; gap: 8px; margin-bottom: 20px; }
.login-brand b { font-size: 20px; color: var(--ink); letter-spacing: .5px; }
.login-brand span { font-size: 12px; color: var(--ink-3); }
.login-tabs {
  display: flex; gap: 6px; padding: 3px;
  background: var(--bg); border-radius: 9px; margin-bottom: 18px;
}
.ltab {
  flex: 1; padding: 8px 0; border: 0; background: transparent; border-radius: 7px;
  font-size: 13px; color: var(--ink-3); cursor: pointer; font-family: inherit;
}
.ltab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.lfield { display: block; margin-bottom: 14px; }
.lfield span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.lfield input {
  width: 100%; padding: 11px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.lfield input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.lerr { min-height: 18px; font-size: 12px; color: var(--red); margin-bottom: 6px; }
.lbtn { width: 100%; padding: 11px; font-size: 14px; }
.lbtn[disabled] { opacity: .65; cursor: default; }
.ltip { margin-top: 14px; font-size: 12px; line-height: 1.7; color: var(--ink-3); }

.btn.tiny { padding: 4px 9px; font-size: 12px; }

/* ---------- 表格内的操作按钮组：换行但不挤成竖条 ---------- */
.row-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.row-acts .btn { white-space: nowrap; }

/* ---------- 分组选择行（推送范围、加人） ---------- */
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fbfcfe; }
.pick-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  font-size: 13px; cursor: pointer; border: 1px solid transparent;
}
.pick-row:hover { background: #f4f7fc; }
.pick-row.on { background: #f6f9ff; border-color: #dbe6fb; cursor: default; }
.pick-row input { flex: none; }
.pick-row .pr-main { font-weight: 500; display: flex; align-items: center; gap: 6px; }
.pick-hint { font-size: 12px; color: var(--ink-3); margin: 10px 0 6px; }

/* ---------- 弹层分段 ---------- */
.modal-sec {
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em;
  margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.modal-sec .muted { font-weight: 400; font-size: 12px; }

/* ---------- 推送规则的每一行 ---------- */
.push-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; margin-bottom: 6px;
}
.push-row.log { background: #fbfcfe; border-style: dashed; }

/* ---------- 操作记录折叠块 ---------- */
.log-fold { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.log-fold > summary {
  cursor: pointer; font-size: 12.5px; color: var(--ink-3); list-style: none;
  padding: 6px 0; user-select: none;
}
.log-fold > summary::-webkit-details-marker { display: none; }
.log-fold > summary::before { content: '▸ '; color: var(--ink-3); }
.log-fold[open] > summary::before { content: '▾ '; }
.log-fold > summary:hover { color: var(--ink-2); }
.log-block { margin-top: 8px; }
.log-title { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }

/* 分页中间的页码 */
.pager-num { font-size: 12.5px; color: var(--ink-3); padding: 0 4px; min-width: 48px; text-align: center; }

/* ---------- 确认弹层正文 ---------- */
.dialog-desc { font-size: 13.5px; line-height: 1.75; color: var(--ink); }
.dialog-desc b { font-weight: 600; }
.dialog-tip {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: #f6f8fb; color: var(--ink-2); font-size: 12.5px; line-height: 1.75;
  border-left: 3px solid #dbe3ee;
}
.modal-mask .modal.narrow { max-width: 460px; }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-solid:hover { background: #b42318; border-color: #b42318; }
