:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1b2434;
  --text-2: #4d5a70;
  --muted: #8b96a9;
  --line: #e9edf5;
  --primary: #3b6ef6;
  --primary-soft: #eaf0ff;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --orange: #f59e0b;
  --orange-soft: #fff4e0;
  --purple: #8b5cf6;
  --purple-soft: #f1ebff;
  --red: #ef4444;
  --red-soft: #feeceb;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(28, 45, 90, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: #e9edf5;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 13px; height: 13px; }

.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(30, 45, 80, 0.1);
  overflow: clip;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #4b7bff, #6f9bff);
  color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 10px rgba(59, 110, 246, 0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; }
.brand-text span { font-size: 11px; color: var(--muted); }
.icon-btn {
  position: relative; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text-2);
  background: #f5f7fb;
}
.icon-btn .dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; background: var(--red); border: 1.5px solid #fff; border-radius: 50%; }
.campus-btn {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 8px; border-radius: 9px; background: #f5f7fb;
  font-size: 12px; color: var(--text-2);
}

/* 页面容器 */
.content { padding: 16px 16px 96px; }
.page { display: none; animation: fade-up .24s ease both; }
.page.is-active { display: block; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 工作台 */
.greeting { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.greeting-date { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.greeting h1 { font-size: 21px; font-weight: 750; letter-spacing: -.3px; }
.greeting-tip { font-size: 12px; color: var(--muted); margin-top: 5px; }
.greeting-tip b { color: var(--primary); }
.greeting-badge {
  flex: 0 0 auto; margin-top: 4px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11px; font-weight: 700;
}
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.metric-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.metric-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.metric-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; }
.metric-icon .icon { width: 15px; height: 15px; }
.metric-icon.blue, .q-icon.blue, .menu-icon.blue { background: var(--primary-soft); color: var(--primary); }
.metric-icon.green, .q-icon.green, .menu-icon.green { background: var(--green-soft); color: var(--green); }
.metric-icon.orange, .q-icon.orange, .menu-icon.orange { background: var(--orange-soft); color: var(--orange); }
.metric-icon.purple, .q-icon.purple, .menu-icon.purple { background: var(--purple-soft); color: var(--purple); }
.metric-value { margin-top: 8px; font-size: 23px; font-weight: 750; letter-spacing: -.5px; }
.metric-foot { margin-top: 4px; font-size: 11px; color: var(--muted); }
.up { color: var(--green); font-weight: 700; }
.warn-text { color: var(--orange); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.text-btn { display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--primary); font-weight: 600; }
.rate-pill { padding: 4px 8px; border-radius: 20px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; }

.chart-wrap { width: 100%; height: 150px; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-legend { display: flex; justify-content: center; gap: 18px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.lg { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lg.blue { background: var(--primary); }
.lg.green { background: var(--green); }

.funnel-row { margin-bottom: 11px; }
.funnel-row:last-child { margin-bottom: 0; }
.funnel-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.funnel-label b { font-size: 12px; }
.funnel-label span { color: var(--muted); }
.funnel-track { height: 9px; background: #f0f3f9; border-radius: 20px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: 20px; transition: width .5s ease; }

.todo-list { display: flex; flex-direction: column; }
.todo-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.todo-item:last-child { border-bottom: 0; }
.todo-check { width: 19px; height: 19px; border-radius: 6px; border: 1.5px solid #cdd6e5; flex: 0 0 auto; display: grid; place-items: center; color: transparent; }
.todo-check.done { background: var(--green); border-color: var(--green); color: #fff; }
.todo-main { flex: 1; min-width: 0; }
.todo-main strong { display: block; font-size: 13px; font-weight: 600; }
.todo-main p { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo-time { font-size: 11px; color: var(--orange); white-space: nowrap; }
.todo-item.is-done .todo-main strong { text-decoration: line-through; color: var(--muted); }
.todo-item.is-done .todo-time { color: var(--muted); }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); }
.q-icon { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; }

/* 页面通用头部 */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 14px; }
.page-head h2 { font-size: 20px; font-weight: 750; }
.page-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.primary-btn { display: flex; align-items: center; gap: 4px; padding: 8px 13px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; box-shadow: 0 4px 10px rgba(59, 110, 246, .22); }
.search-bar { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 11px; background: #fff; color: var(--muted); box-shadow: var(--shadow); }
.search-bar .icon { width: 17px; height: 17px; }
.search-bar input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; }
.search-bar input::placeholder { color: #aab3c3; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; padding: 6px 12px; border-radius: 20px; background: #fff; color: var(--text-2); font-size: 12px; border: 1px solid var(--line); }
.tabs button.is-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.segment { display: flex; gap: 8px; margin: 12px 0; }
.segment button { flex: 1; padding: 8px 0; border-radius: 10px; background: #fff; color: var(--text-2); font-size: 12px; border: 1px solid var(--line); }
.segment button.is-active { background: var(--primary-soft); color: var(--primary); border-color: #cddaff; font-weight: 700; }

/* 线索列表 */
.lead-list, .student-list, .course-list { display: flex; flex-direction: column; gap: 10px; }
.lead-card, .student-card, .course-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.lead-top { display: flex; align-items: center; gap: 10px; }
.lead-avatar, .student-avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.lead-name, .student-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.lead-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge { padding: 2px 7px; border-radius: 6px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge.new { background: var(--primary-soft); color: var(--primary); }
.badge.following { background: var(--orange-soft); color: #d97706; }
.badge.won { background: var(--green-soft); color: var(--green); }
.badge.lost { background: #f0f2f6; color: var(--muted); }
.badge.hot { background: var(--red-soft); color: var(--red); }
.badge.warm { background: var(--orange-soft); color: #d97706; }
.badge.cool { background: #eef2f8; color: var(--text-2); }
.lead-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lead-tags span { padding: 3px 8px; border-radius: 6px; background: #f5f7fb; color: var(--text-2); font-size: 11px; }
.lead-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.lead-bottom .time { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.lead-bottom .time .icon { width: 13px; height: 13px; }
.lead-actions { display: flex; gap: 8px; }
.mini-btn { padding: 5px 10px; border-radius: 8px; font-size: 11px; font-weight: 600; background: #f5f7fb; color: var(--text-2); }
.mini-btn.primary { background: var(--primary-soft); color: var(--primary); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-icon { font-size: 30px; display: block; margin-bottom: 8px; opacity: .5; }

/* 学员 */
.student-card { display: flex; gap: 11px; align-items: center; }
.student-avatar { background: var(--primary-soft); color: var(--primary); }
.student-main { flex: 1; min-width: 0; }
.student-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.student-hours { text-align: right; flex: 0 0 auto; }
.student-hours strong { font-size: 16px; font-weight: 750; }
.student-hours.low strong { color: var(--red); }
.student-hours span { display: block; font-size: 10px; color: var(--muted); }

/* 课程 */
.week-strip { display: flex; gap: 6px; margin-bottom: 14px; }
.week-day { flex: 1; padding: 10px 0; text-align: center; border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.week-day span { display: block; font-size: 10px; color: var(--muted); }
.week-day b { display: block; font-size: 15px; margin-top: 3px; }
.week-day.is-active { background: var(--primary); color: #fff; }
.week-day.is-active span { color: rgba(255,255,255,.8); }
.week-day.has-class::after { content: ''; display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--orange); margin: 4px auto 0; }
.week-day.is-active::after { background: #fff; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 10px; }
.section-title span { font-size: 15px; font-weight: 700; }
.section-title small { font-size: 11px; color: var(--muted); }
.course-card { display: flex; gap: 12px; }
.course-time { width: 48px; flex: 0 0 auto; text-align: center; border-right: 1px solid var(--line); padding-right: 8px; }
.course-time b { display: block; font-size: 16px; font-weight: 750; }
.course-time span { font-size: 10px; color: var(--muted); }
.course-main { flex: 1; min-width: 0; }
.course-main h4 { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.course-main p { font-size: 11px; color: var(--muted); }
.course-progress { height: 6px; border-radius: 20px; background: #f0f3f9; margin-top: 9px; overflow: hidden; }
.course-progress i { display: block; height: 100%; background: var(--primary); border-radius: 20px; }
.rank-card { padding: 6px 15px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.rank-row:last-child { border-bottom: 0; }
.rank-no { width: 20px; height: 20px; border-radius: 6px; background: #f0f3f9; color: var(--text-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.rank-no.top { background: var(--orange-soft); color: var(--orange); }
.rank-row .rank-name { flex: 1; font-weight: 600; }
.rank-row .rank-val { color: var(--muted); }

/* 我的 */
.profile-card { display: flex; gap: 13px; align-items: center; background: linear-gradient(135deg, #4b7bff, #7ba3ff); border-radius: 18px; padding: 20px 16px; color: #fff; box-shadow: 0 8px 22px rgba(59,110,246,.22); }
.avatar-lg { width: 56px; height: 56px; border-radius: 17px; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 24px; font-weight: 700; }
.profile-info h2 { font-size: 18px; }
.profile-info p { font-size: 12px; opacity: .85; margin-top: 2px; }
.profile-tag { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 20px; background: rgba(255,255,255,.22); font-size: 10px; }
.profile-stats { display: flex; background: #fff; border-radius: var(--radius); padding: 14px 0; margin: 12px 0; box-shadow: var(--shadow); }
.profile-stats div { flex: 1; text-align: center; border-right: 1px solid var(--line); }
.profile-stats div:last-child { border-right: 0; }
.profile-stats strong { display: block; font-size: 16px; font-weight: 750; }
.profile-stats span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.menu-card { padding: 4px 15px; }
.menu-card button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 13px; text-align: left; }
.menu-card button:last-child { border-bottom: 0; }
.menu-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; }
.menu-icon .icon { width: 15px; height: 15px; }
.menu-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.menu-value { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu-arrow { color: #c5cddb; margin-left: auto; }
.version { text-align: center; font-size: 11px; color: var(--muted); line-height: 1.8; margin-top: 22px; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 20; width: 100%; max-width: 480px; height: 66px;
  display: flex; align-items: center;
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; }
.tabbar button.is-active { color: var(--primary); font-weight: 700; }
.tabbar .icon { width: 21px; height: 21px; }

/* 抽屉 */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(18,28,48,.4); opacity: 0; pointer-events: none; transition: opacity .25s; }
.overlay.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 31; bottom: 0; left: 50%; transform: translate(-50%, 105%);
  width: 100%; max-width: 480px; max-height: 86vh;
  background: #fff; border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  transition: transform .3s cubic-bezier(.22,.8,.3,1);
  box-shadow: 0 -10px 40px rgba(20,35,70,.15);
}
.sheet.is-open { transform: translate(-50%, 0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 4px; background: #dfe5ef; margin: 9px auto 2px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { font-size: 16px; font-weight: 700; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; }
.sheet-foot:empty { display: none; }
.sheet-foot button { flex: 1; padding: 11px 0; border-radius: 10px; font-size: 13px; font-weight: 600; background: #f1f4f9; color: var(--text-2); }
.sheet-foot button.primary { background: var(--primary); color: #fff; }
.sheet-foot button.success { background: var(--green); color: #fff; }
.sheet-foot button.danger { background: var(--red-soft); color: var(--red); }

.detail-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.detail-hero .lead-avatar { width: 52px; height: 52px; font-size: 19px; border-radius: 15px; }
.detail-hero h4 { font-size: 18px; margin: 0 0 4px; }
.detail-hero p { font-size: 12px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.detail-cell { background: #f7f9fc; border-radius: 11px; padding: 10px 12px; }
.detail-cell span { display: block; font-size: 11px; color: var(--muted); }
.detail-cell b { display: block; font-size: 13px; margin-top: 3px; }
.detail-section-title { font-size: 13px; font-weight: 700; margin: 16px 0 10px; display: flex; align-items: center; gap: 6px; }
.detail-section-title .icon { width: 15px; height: 15px; color: var(--primary); }
.timeline { border-left: 2px solid #e8edf7; margin-left: 6px; padding-left: 14px; }
.timeline-item { position: relative; padding-bottom: 14px; }
.timeline-item::before { content: ''; position: absolute; left: -21px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary-soft); }
.timeline-item strong { font-size: 12px; }
.timeline-item p { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.timeline-item time { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; z-index: 40; background: rgba(18,28,48,.4); display: none; align-items: flex-end; justify-content: center; }
.modal-mask.is-open { display: flex; }
.modal { width: 100%; max-width: 480px; background: #fff; border-radius: 20px 20px 0 0; padding: 6px 18px calc(20px + env(safe-area-inset-bottom)); animation: modal-in .25s ease both; }
@keyframes modal-in { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 14px; }
.modal-head h3 { font-size: 16px; }
.form-field { margin-bottom: 13px; }
.form-field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: #f9fafd; outline: 0; font-size: 13px;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); background: #fff; }
.form-field textarea { resize: none; min-height: 72px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-actions button { flex: 1; padding: 12px 0; border-radius: 10px; font-size: 13px; font-weight: 600; background: #f1f4f9; color: var(--text-2); }
.form-actions button.submit { background: var(--primary); color: #fff; }

/* 登录页 */
.login-mask {
  position: fixed; inset: 0; z-index: 70;
  background: linear-gradient(160deg, #4b7bff 0%, #6f9bff 45%, #8fb4ff 100%);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.login-mask.is-open { display: flex; }
.login-box {
  width: 100%; max-width: 380px; background: #fff; border-radius: 22px;
  padding: 34px 26px 26px; box-shadow: 0 20px 50px rgba(20, 50, 120, .25);
}
.login-logo {
  width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #4b7bff, #6f9bff); color: #fff;
  display: grid; place-items: center; font-size: 26px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(59,110,246,.28);
}
.login-box h1 { font-size: 21px; text-align: center; font-weight: 750; }
.login-sub { text-align: center; font-size: 12px; color: var(--muted); margin: 5px 0 26px; }
.login-error { min-height: 18px; font-size: 12px; color: var(--red); text-align: center; margin: -4px 0 8px; }
.login-server-btn {
  display: block; margin: 18px auto 0; font-size: 12px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
}

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 86px; transform: translate(-50%, 12px);
  padding: 9px 16px; border-radius: 10px; background: rgba(27,36,52,.92); color: #fff;
  font-size: 12px; opacity: 0; pointer-events: none; transition: all .25s;
  max-width: 80%; text-align: center;
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 520px) {
  body { padding: 20px 0; }
  .app { border-radius: 24px; min-height: calc(100vh - 40px); }
  .tabbar, .sheet, .modal { border-radius: 0; }
  .sheet { border-radius: 22px 22px 0 0; bottom: 20px; }
}
