:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --primary: #4f46e5;
  --primary-soft: #eef0fe;
  --primary-d: #4338ca;
  --text: #1f2433;
  --muted: #6b7280;
  --line: #e6e9f0;
  --green: #16a34a;
  --green-soft: #e7f6ed;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 6px 24px rgba(16,24,40,.06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---- 布局 ---- */
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; display: grid; place-items: center; font-size: 16px; }
.topbar .spacer { flex: 1; }
.nav { display: flex; gap: 4px; margin-left: 26px; }
.nav a {
  padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 14px;
}
.nav a.active, .nav a:hover { background: var(--primary-soft); color: var(--primary-d); }
.userchip { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.userchip:hover { opacity: .92; }
.userchip img.avatar { object-fit: cover; padding: 0; }
.avatar-preview { width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 22px; overflow: hidden; flex: 0 0 auto; }
img.avatar-preview { object-fit: cover; padding: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; }
.btn.danger { color: #c0392b; border-color: #e6b0aa; }
.btn.danger:hover { background: #fdecea; }

.page { max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }
.page-narrow { max-width: 860px; }
.h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 22px; }

/* ---- 卡片/栅格 ---- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
/* 课程详情：左侧视频+课时考试，右侧课时列表 */
.layout-course { grid-template-columns: 1.6fr 1fr; }
/* 数据看板：左侧图表，右侧完成率环 */
.layout-dash { grid-template-columns: 1fr 300px; }
/* ---- 表格横向滚动容器 ---- */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- 手机端响应式 ---- */
@media (max-width: 860px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  /* 统计卡两列排列更紧凑；课程/看板双栏布局在手机上改为上下堆叠 */
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .layout-course, .layout-dash { grid-template-columns: 1fr; }
  /* 视频播放器在窄屏占满宽度 */
  .player { aspect-ratio: 16/10; }
  /* 课程详情里的课时考试卡片按钮、课时列表在堆叠后保持合适间距 */
  .lesson-actions { margin-top: 12px; }
  /* 顶栏允许换行：导航改为可横向滑动，不再隐藏，避免手机上无法切换栏目 */
  .topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .topbar .spacer { display: none; }
  .brand { font-size: 15px; }
  .nav { order: 3; flex-basis: 100%; margin-left: 0; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; gap: 2px; }
  .nav a { padding: 7px 12px; font-size: 13px; }
  .userchip .muted { display: none; }
  .userchip { gap: 8px; }
  /* 页面内边距收紧 */
  .page { padding: 16px 14px 54px; }
  .h1 { font-size: 19px; }
  .sub { margin-bottom: 16px; }
  .card, .stat, .chart-box { padding: 14px; }
  .stat .v { font-size: 24px; }
  /* 表格字号收紧，配合 .table-scroll 横向滚动 */
  th, td { padding: 9px 10px; font-size: 12.5px; }
  /* 表格在窄屏不再被压扁换行，改为保持最小宽度并横向滑动 */
  .table-scroll table { min-width: 560px; }
  .table-scroll th, .table-scroll td { white-space: nowrap; }
  /* 登录卡片自适应，避免窄屏溢出 */
  .login-card { width: auto; max-width: calc(100% - 32px); padding: 26px 20px; }
  /* 输入控件不小于 16px，避免 iOS 聚焦时缩放页面 */
  .input, select, textarea { font-size: 16px; padding: 12px 12px; }
  .btn { padding: 11px 16px; }
  .btn.sm { padding: 8px 12px; }
  /* 弹窗边距收紧 */
  .modal-mask { padding: 12px; }
  .modal .mh, .modal .mb, .modal .mf { padding-left: 16px; padding-right: 16px; }
  /* 题目与选项间距适配 */
  .q { padding: 14px; }
  .q .opt { padding: 11px 12px; }
  /* 课时列表适配 */
  .lesson-list li { gap: 10px; padding: 12px; }
  /* toast 贴近底部 */
  .toast { bottom: 16px; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.pad-lg { padding: 22px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.section-title { font-size: 16px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }

/* ---- 统计卡 ---- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 28px; font-weight: 800; margin-top: 4px; letter-spacing: .5px; }
.stat .v small { font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---- 课程卡 ---- */
.course {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: .18s;
}
.course:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(16,24,40,.1); }
.course .cover { height: 96px; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: grid; place-items: center; color: #fff; font-size: 30px; }
.course .body { padding: 15px 16px; flex: 1; display: flex; flex-direction: column; }
.course .title { font-weight: 700; font-size: 15.5px; margin-bottom: 6px; }
.course .desc { color: var(--muted); font-size: 13px; min-height: 38px; flex: 1; }
.meta { display: flex; gap: 12px; color: var(--muted); font-size: 12px; margin: 10px 0; }

/* ---- 进度条 ---- */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 99px; transition: width .4s; }

/* ---- 徽章 ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.blue { background: var(--primary-soft); color: var(--primary-d); }

/* ---- 按钮 ---- */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; transition: .15s; }
.btn:hover { border-color: #c9cef7; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.danger { color: var(--red); border-color: #f1c4c4; }
.btn.danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- 表单 ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 70px; }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th { color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: #fafbff; }

/* ---- 登录 ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #e9ecff, var(--bg)); }
.login-card { width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; }
.login-card .logo { width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card .tip { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-roles { display: flex; gap: 8px; margin-bottom: 16px; }
.login-roles .chip { flex: 1; text-align: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-roles .chip.active { background: var(--primary-soft); color: var(--primary-d); border-color: #c9cef7; }

/* ---- 视频/课时 ---- */
.player { background: #0b1020; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; cursor: pointer; transition: .15s; }
.lesson-list li:hover { border-color: #c9cef7; background: #fafbff; }
.lesson-list li.active { border-color: var(--primary); background: var(--primary-soft); }
.lesson-list .idx { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.lesson-list li.active .idx { background: var(--primary); color: #fff; }
.lesson-examctl { flex: none; display: flex; align-items: center; }
.lnk-dl { display: inline-block; margin-left: 8px; color: var(--primary); font-size: 12px; text-decoration: none; border: 1px solid var(--primary-soft); padding: 2px 8px; border-radius: 6px; }
.lnk-dl:hover { background: var(--primary-soft); }
.lesson-bank .q { background: #fafbff; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }

/* ---- 考试 ---- */
.q { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.q .qh { font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: baseline; }
.q .opt { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: .12s; }
.q .opt:hover { background: #fafbff; }
.q .opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.q .opt.correct { border-color: var(--green); background: var(--green-soft); }
.q .opt.wrong { border-color: var(--red); background: var(--red-soft); }
.q .opt input { accent-color: var(--primary); }
.q .res { font-size: 13px; margin-top: 6px; }

/* ---- 模态框 ---- */
.modal-mask { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 16px; width: 520px; max-width: 100%; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal .mh { padding: 18px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal .mb { padding: 20px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x { border: none; background: none; font-size: 20px; color: var(--muted); }

/* ---- toast ---- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1f2433; color: #fff; padding: 11px 20px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99; font-size: 13.5px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 杂项 ---- */
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.flex-wrap { flex-wrap: wrap; }
.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv .v { font-weight: 700; }

/* 考试历史成绩标签 */
.chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; margin: 2px 6px 2px 0; }
.chip.green { background: #e7f7ed; color: #1a8a4a; }
.chip.red { background: #fdeaea; color: #c0392b; }

/* 选项字母序号（A/B/C/D） */
.opt-key { display: inline-block; min-width: 16px; margin-right: 6px; color: var(--muted); font-weight: 700; }
.opt.correct .opt-key, .opt.wrong .opt-key { color: inherit; }

/* 视频断点续播提示条 */
.resume-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; margin-bottom: 10px; background: #fff7e6; color: #b35900; border: 1px solid #ffd591; border-radius: 10px; font-size: 13px; }
.resume-banner b { color: #d35400; font-weight: 700; }

/* 课时操作栏（下载视频） */
.lesson-actions { margin-top: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
