/* ============ 基础 ============ */
:root {
  --primary: #4f6ef7;
  --primary-dark: #3b5ae6;
  --primary-light: #eef1fe;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --green-bg: #e8f7ee;
  --red: #dc2626;
  --red-bg: #fdeaea;
  --amber: #d97706;
  --amber-bg: #fdf3e3;
  --teal: #0d9488;
  --teal-bg: #e6f5f3;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --bottom-nav-h: 62px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); font-size: 13px; }

/* ============ 布局骨架 ============ */
#app { display: flex; min-height: 100vh; }
#sidebar {
  display: none; width: 216px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  flex-direction: column; padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.brand-icon { width: 30px; height: 30px; }
#sideNav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--text); border: none; background: none; text-align: left; font-size: 14.5px;
}
.nav-item .ico { width: 22px; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--primary-light); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.side-foot { padding: 10px 12px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 26px; height: 26px; display: none; }
#pageTitle { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.sem-select-wrap { display: flex; align-items: center; gap: 6px; }
.sem-label { color: var(--muted); font-size: 12.5px; }
#semesterSelect {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: #fff; max-width: 40vw;
}
.icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px; width: 34px; height: 34px;
  font-size: 17px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--primary); }

#view { flex: 1; padding: 14px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ============ 底部导航（手机） ============ */
#bottomNav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#bottomNav .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 7px 2px 6px; border-radius: 0; font-size: 11px; }
#bottomNav .nav-item .ico { font-size: 19px; }
#bottomNav .nav-item.active { background: none; color: var(--primary); font-weight: 600; }
#view { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px); }

@media (min-width: 900px) {
  #sidebar { display: flex; }
  #bottomNav { display: none; }
  #view { padding-bottom: 40px; }
  .topbar-logo { display: block; }
}

/* ============ 通用组件 ============ */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.card h3 { font-size: 14.5px; margin-bottom: 10px; color: var(--text); }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.view-head h2 { font-size: 18px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border); background: #fff; border-radius: 9px; padding: 8px 14px; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 5px 13px; font-size: 13px; color: var(--text);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.search-input {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; width: 180px; background: #fff;
}
.search-input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }

/* 表格：桌面为表格式，手机为卡片行 */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 640px) {
  .tbl th.hide-m, .tbl td.hide-m { display: none; }
  .tbl td { padding: 9px 6px; }
}

/* 汇总统计 */
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .statgrid { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.stat-num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat .accent { color: var(--primary); }
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.progress { background: var(--border); border-radius: 999px; height: 6px; min-width: 70px; overflow: hidden; }
.progress > div { background: var(--primary); height: 100%; border-radius: 999px; }
.progress.full > div { background: var(--green); }

/* 徽标 */
.badge { display: inline-flex; align-items: center; border-radius: 6px; font-size: 11.5px; padding: 1px 7px; font-weight: 600; white-space: nowrap; }
.badge.in { background: var(--teal-bg); color: var(--teal); }
.badge.out { background: var(--amber-bg); color: var(--amber); }
.badge.done { background: var(--green-bg); color: var(--green); }
.badge.todo { background: #eef0f4; color: var(--muted); }
.badge.status-在读 { background: var(--green-bg); color: var(--green); }
.badge.status-停课 { background: var(--amber-bg); color: var(--amber); }
.badge.status-结课 { background: #eef0f4; color: var(--muted); }

/* 课程行 */
.lesson-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 6px; border-bottom: 1px solid var(--border);
}
.lesson-row:last-child { border-bottom: none; }
.lesson-main { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.lesson-row.is-done .lesson-title { color: var(--muted); }
.lesson-actions { display: flex; gap: 6px; }
.lesson-done-check { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input[type="text"], .field input[type="number"], .field input[type="date"], .field input[type="time"],
.field input[type="password"], .field select, .field textarea,
.field:not(.no-field) > input {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; background: #fff;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.checkline { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14.5px; }
.checkline input { width: 18px; height: 18px; accent-color: var(--primary); }
.checkline.disabled { color: var(--muted); }

/* 模态框 */
.modal-wrap {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 640px) { .modal-wrap { align-items: center; padding: 20px; } }
.modal {
  background: #fff; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 16px; animation: slideUp .22s ease;
}
@media (min-width: 640px) { .modal { border-radius: 16px; animation: pop .18s ease; } }
.modal.wide { max-width: 720px; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.roster-list { list-style: none; }

/* Toast */
#toasts { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: 92vw; }
.toast {
  background: #1f2430; color: #fff; border-radius: 10px; padding: 10px 18px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 92vw; animation: pop .18s ease;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.toast.out { opacity: 0; transition: opacity .3s; }

/* AI 录入页 */
.entry-card textarea#aiInput {
  width: 100%; min-height: 120px; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  resize: vertical; font-size: 15px; line-height: 1.6;
}
.entry-card textarea#aiInput:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.entry-toolbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.entry-toolbar .spacer { flex: 1; }
.mic-btn { position: relative; }
.mic-btn.recording { background: var(--red-bg); border-color: var(--red); color: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.25); } 50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); } }
.file-btn input[type="file"] { display: none; }
.dropzone-hint { font-size: 12.5px; color: var(--muted); }
#view.dragover .entry-card { outline: 3px dashed var(--primary); outline-offset: -3px; border-radius: var(--radius); }
.file-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--primary-light); color: var(--primary-dark);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12.5px; max-width: 100%;
}
.file-chip .rm { border: none; background: rgba(59,90,230,.15); color: var(--primary-dark); width: 18px; height: 18px; border-radius: 50%; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.file-chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

/* AI 确认卡片 */
.confirm-card { border-left: 4px solid var(--primary); }
.confirm-card.applied { border-left-color: var(--green); opacity: .85; }
.cc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.kind-tag { background: var(--primary); color: #fff; border-radius: 6px; font-size: 12px; padding: 2px 8px; font-weight: 600; }
.cc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
@media (max-width: 560px) { .cc-fields { grid-template-columns: 1fr; } }
.cc-fields .span2 { grid-column: 1 / -1; }
.cc-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.cc-ok-note { color: var(--green); font-size: 13px; font-weight: 600; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.loading-inline { display: flex; width: 100%; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 学员行（手机） */
.stu-cell-main { min-width: 0; }
.stu-name { font-weight: 600; }
.stu-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 设置页 */
.set-section { margin-bottom: 18px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.preset-btn { border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 10px; text-align: left; }
.preset-btn .p-name { font-weight: 600; font-size: 14px; }
.preset-btn .p-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.preset-btn.active { border-color: var(--primary); background: var(--primary-light); }
.sem-list { display: flex; flex-direction: column; gap: 8px; }
.sem-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.sem-item.current { border-color: var(--primary); background: var(--primary-light); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }

.empty-tip { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
/* 手机上隐藏与相邻列重复的信息 */
@media (min-width: 641px) { .hide-d { display: none; } }

/* ---------- v2 迭代新增 ---------- */

/* 筛选统计与课时费页 */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.filter-bar .field { flex: 1; min-width: 130px; margin-bottom: 0; }
.fee-mode { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.fee-total { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--primary-light); font-size: 15px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fee-total b { font-size: 22px; color: var(--primary); }
.fee-input { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* 学员详情：沟通流水 */
.note-list { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.note-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.note-date { font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 2px; }
.note-text { flex: 1; font-size: 13.5px; line-height: 1.6; }

/* 点名下拉（到课状态） */
.roster-item select {
  padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; color: inherit;
}
.roster-item .checkline { display: flex; align-items: center; gap: 8px; width: 100%; }


/* ============ 教师名单 ============ */
.teacher-card { margin-bottom: 12px; }
.teacher-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.teacher-name { font-size: 17px; font-weight: 600; }
.teacher-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.teacher-classes { display: flex; flex-wrap: wrap; gap: 8px; }
