:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar .brand { font-weight: 700; font-size: 16px; margin-right: 16px; color: var(--primary); }
.navbar a.item {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
}
.navbar a.item:hover { background: var(--bg); text-decoration: none; }
.navbar a.item.active { color: var(--primary); background: #eff6ff; font-weight: 600; }
.navbar .spacer { flex: 1; }
.container { max-width: 1200px; margin: 20px auto; padding: 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }

/* ---------- 组件 ---------- */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 12px; }

input[type=text], input[type=password], input[type=number], textarea, select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
table.tbl tbody tr:hover { background: #f9fafb; }
table.tbl tbody tr.clickable { cursor: pointer; }

.muted { color: var(--muted); font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; white-space: pre-wrap; }
.ok-text { color: var(--ok); font-size: 13px; margin-top: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* 统计卡片 */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1; min-width: 150px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 18px;
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* 进度条 */
.progress-wrap { margin-top: 12px; }
.progress-bar { height: 12px; background: #e5e7eb; border-radius: 6px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }
.progress-text { margin-top: 8px; font-size: 13px; color: var(--muted); }
.error-list {
  margin-top: 10px; max-height: 160px; overflow: auto;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  padding: 8px 12px; font-size: 12px; color: var(--danger);
}

/* 关卡矩阵 */
.matrix td.cell {
  text-align: center;
  font-size: 10px;
  padding: 0;
  height: 30px; min-width: 30px;
  border: 1px solid #fff;
}
/* 星级配色：矩阵单元格 / 关卡条 / 图例共用 */
.c3 { background: #16a34a; color: #fff; }
.c2 { background: #84cc16; color: #fff; }
.c1 { background: #f59e0b; color: #fff; }
.c0 { background: #f1f5f9; color: #cbd5e1; }
.legend { display: flex; gap: 12px; margin: 10px 0; font-size: 12px; color: var(--muted); align-items: center; }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* 学生详情的关卡条 */
.level-strip { display: flex; gap: 3px; flex-wrap: wrap; }
.level-strip .lv {
  width: 24px; height: 24px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff;
}
.bar-wrap { background: #e5e7eb; border-radius: 4px; height: 8px; width: 100px; display: inline-block; vertical-align: middle; overflow: hidden; }
.bar-wrap > div { height: 100%; background: var(--ok); }

/* 登录页 */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.login-box h1 { font-size: 18px; margin: 0 0 18px; text-align: center; color: var(--primary); }

/* 同步卡片 / Cookie 弹窗 */
.sync-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sync-head h2 { margin: 0; }
.warn-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 10px;
}
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto;
  z-index: 100;
}
.modal { background: #fff; border-radius: 10px; padding: 20px 22px; width: 560px; max-width: 92vw; margin: 5vh auto; }
.modal h2 { margin: 0 0 12px; font-size: 16px; }

/* 首页同步进度弹窗：逐课程状态列表 */
.course-sync-list {
  margin-top: 12px;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.cs-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cs-row:last-child { border-bottom: none; }
.cs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-st { white-space: nowrap; color: var(--muted); }
.cs-st.st-running { color: var(--primary); font-weight: 600; }
.cs-st.st-done { color: var(--ok); font-weight: 600; }
.cs-st.st-failed { color: var(--danger); font-weight: 600; }

/* 作业详情表格：完整边框便于视觉区分 */
#hwDetailBody table.tbl { border: 1px solid var(--border); }
#hwDetailBody table.tbl th, #hwDetailBody table.tbl td { border: 1px solid var(--border); }

/* 发布作业确认表格：完整边框便于视觉区分 */
#hwPublishMask table.tbl { border: 1px solid var(--border); }
#hwPublishMask table.tbl th, #hwPublishMask table.tbl td { border: 1px solid var(--border); }

/* 首页学情总览：星级分色（满分绿 / 50-59橙 / 30-49浅红 / 1-29红 / 0灰 / 无数据） */
.sc { text-align: center; font-weight: 600; min-width: 48px; }
.sc-green { background: #16a34a; color: #fff; }
.sc-orange { background: #f59e0b; color: #fff; }
.sc-lred { background: #fca5a5; color: #7f1d1d; }
.sc-red { background: #dc2626; color: #fff; }
.sc-gray { background: #e5e7eb; color: #6b7280; }
.sc-none { background: #f8fafc; color: #cbd5e1; }

/* 首页总览表格：纵向随页面展开，学生多时才出现横向滚动条 */
.tbl-scroll { overflow-x: auto; }
.home-tbl th, .home-tbl td { white-space: nowrap; }
.home-tbl thead th { background: #f9fafb; }
.home-tbl td:first-child, .home-tbl th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
.home-tbl thead th:first-child { background: #f9fafb; }
.home-tbl td.sc { font-size: 13px; }

/* 首页作业勾选：点击单元格选中，蓝色描边 + 角标 */
#homeData td.sc { cursor: pointer; position: relative; user-select: none; }
#homeData td.sc:hover { box-shadow: inset 0 0 0 2px #93c5fd; }
#homeData td.sc.picked { box-shadow: inset 0 0 0 3px #1d4ed8; }
#homeData td.sc.picked::after {
  content: '✓';
  position: absolute;
  top: 0; right: 0;
  font-size: 10px; line-height: 13px;
  padding: 0 3px;
  background: #1d4ed8; color: #fff;
  border-radius: 0 0 0 5px;
}
