:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #16211f;
  --muted: #6b7c79;
  --line: #e4eae8;
  --primary: #0f766e;
  --primary-dark: #0b5d57;
  --primary-50: #e8f3f1;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --info: #0369a1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 40, 36, 0.04), 0 6px 18px rgba(16, 40, 36, 0.04);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.no-scroll {
  overflow: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

/* ---------------- 顶部栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: linear-gradient(135deg, #12867d, #0b5d57);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-text b {
  font-size: 15px;
  letter-spacing: 0.5px;
}

.brand-text small {
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.who {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 8px;
}

.who-name {
  font-size: 13px;
  font-weight: 600;
}

.who-role {
  font-size: 11px;
  color: var(--muted);
}

/* ---------------- 通用控件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn.block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-btn:hover {
  background: #eef3f2;
  color: var(--ink);
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #a6b3b1;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

input[type='color'] {
  padding: 4px;
  height: 42px;
}

/* ---------------- 布局 ---------------- */

.main {
  padding: 14px 16px calc(96px + env(safe-area-inset-bottom));
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}

.page-head h1,
.page-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.page-title {
  margin: 6px 0 12px;
}

.page-head .muted {
  font-size: 12.5px;
  margin-top: 3px;
}

.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.card.tight {
  padding: 2px 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.card.list {
  padding: 4px 14px;
}

.empty {
  padding: 26px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.tight {
  letter-spacing: 0;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

/* ---------------- 数据卡片 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.stat b {
  display: block;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat.ok b {
  color: var(--ok);
}

.stat.warn b {
  color: var(--danger);
}

.stat.info b {
  color: var(--primary);
  font-size: 19px;
}

.stat-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-grid.three .stat b {
  font-size: 20px;
}

/* ---------------- 课程行 ---------------- */

.lesson {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.card .lesson:last-child,
.card.tight .lesson:last-child {
  border-bottom: 0;
}

.ltime {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.ltime small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.lmain {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ltitle {
  font-size: 14.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lsub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef3f2;
  color: var(--muted);
  white-space: nowrap;
}

.pill.booked {
  background: #e0f2fe;
  color: var(--info);
}

.pill.done {
  background: #dcfce7;
  color: var(--ok);
}

.pill.cancelled {
  background: #f1f5f9;
  color: #94a3b8;
}

.tag {
  display: inline-block;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--primary-50);
  color: var(--primary);
  white-space: nowrap;
}

.tag.gray {
  background: #f1f5f9;
  color: #94a3b8;
}

/* ---------------- 列表行 ---------------- */

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.card .row:last-child,
.card.list .row:last-child {
  border-bottom: 0;
}

.rmain {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rtitle {
  font-size: 14.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rsub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rtime {
  flex: 0 0 44px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.rtime small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.rside {
  text-align: right;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}

.rside b {
  font-size: 15px;
}

.rside small {
  color: var(--muted);
  font-size: 11px;
}

.rside b.small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}

.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 22px;
}

.avatar.sm {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.avatar.warn {
  background: #fef3c7;
  color: var(--warn);
}

.avatar.muted {
  background: #f1f5f9;
  color: #94a3b8;
}

.balance {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}

.balance.low {
  color: var(--danger);
}

/* ---------------- 搜索 / 筛选 ---------------- */

.search {
  margin-bottom: 10px;
  background: #fff;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.chip.on {
  background: var(--primary-50);
  border-color: #bfe0db;
  color: var(--primary);
  font-weight: 600;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.filters select {
  font-size: 13.5px;
  padding: 9px 10px;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------------- 课表 ---------------- */

.day {
  margin-bottom: 12px;
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px;
  font-size: 13px;
  color: var(--muted);
}

.day-head b {
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 600;
}

.day.today .day-head b {
  color: var(--primary);
}

.day.today .day-head b::after {
  content: '今天';
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  vertical-align: 1px;
}

.day-empty {
  padding: 12px;
  text-align: center;
  color: #b9c4c2;
  font-size: 12px;
}

/* ---------------- 学员详情 ---------------- */

.hero-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-main h1 {
  font-size: 19px;
}

.hero-main p {
  font-size: 12.5px;
  margin-top: 3px;
}

.balance-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--primary-50);
  border-radius: 13px;
}

.balance-box b {
  font-size: 28px;
  color: var(--primary);
  line-height: 1;
}

.balance-box b.low {
  color: var(--danger);
}

.balance-box span {
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
}

.balance-box small {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--primary);
  font-size: 14px;
  text-decoration: none;
  font-weight: 600;
}

.note {
  margin-top: 10px;
  padding: 9px 11px;
  background: #f8fafc;
  border-radius: 10px;
  color: #475569;
  font-size: 13px;
}

/* ---------------- 管理菜单 ---------------- */

.menu {
  padding: 2px 14px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.menu-item:last-child {
  border-bottom: 0;
}

.mi-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary-50);
  color: var(--primary);
}

.mi-icon.sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.mi-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mi-main b {
  font-size: 14.5px;
}

.mi-main small {
  color: var(--muted);
  font-size: 12px;
}

.mi-icon + .mi-main + svg {
  color: #b9c4c2;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--primary);
}

/* ---------------- 详情表 ---------------- */

.detail {
  margin: 0;
  display: grid;
  gap: 9px;
}

.detail div {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.detail dt {
  flex: 0 0 42px;
  color: var(--muted);
  font-size: 13px;
  padding-top: 1px;
}

.detail dd {
  margin: 0;
  flex: 1;
  font-size: 14px;
}

/* ---------------- 表单 ---------------- */

.field {
  display: block;
  margin-bottom: 12px;
}

.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 26px;
  align-items: center;
}

.picked-item {
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 500;
}

/* ---------------- 选择学员 ---------------- */

.pick-list {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 10px;
  margin-top: 10px;
}

.pick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.pick:last-child {
  border-bottom: 0;
}

.pick input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.pick.on {
  background: #f7fbfa;
}

/* ---------------- 完成上课 ---------------- */

.complete-row {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}

.complete-row.absent {
  opacity: 0.55;
  background: #fafbfb;
}

.cr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cr-name {
  font-size: 15px;
  font-weight: 600;
}

.cr-balance {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.seg {
  display: inline-flex;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.seg button {
  border: 0;
  background: #fff;
  color: var(--muted);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.seg button + button {
  border-left: 1px solid var(--line);
}

.seg button.on {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ---------------- 弹层 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(13, 32, 29, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.16s ease;
}

.sheet {
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: slideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-overflow-scrolling: touch;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 700;
}

.sheet-text {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 14px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sheet-actions .btn {
  flex: 1;
}

.sheet-actions.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@keyframes slideUp {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------- 提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 80vw;
  padding: 10px 16px;
  border-radius: 11px;
  background: rgba(22, 33, 31, 0.92);
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: fadeIn 0.16s ease;
}

.toast.error {
  background: rgba(185, 28, 28, 0.95);
}

.toast[hidden] {
  display: none;
}

/* ---------------- 底部导航 / 悬浮按钮 ---------------- */

.nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: 100%;
  max-width: 760px;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(140%) blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 0;
  font-size: 11px;
  color: #8b9a97;
  text-decoration: none;
  border-radius: 10px;
}

.nav a svg {
  width: 22px;
  height: 22px;
}

.nav a.active {
  color: var(--primary);
  font-weight: 600;
}

.fab {
  position: fixed;
  right: max(16px, calc(50vw - 380px + 16px));
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 45;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.36);
  cursor: pointer;
}

.fab:active {
  transform: scale(0.96);
}

/* ---------------- 登录 ---------------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  text-align: center;
  gap: 4px;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: linear-gradient(135deg, #12867d, #0b5d57);
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.28);
  margin-bottom: 14px;
}

.login h1 {
  font-size: 22px;
  letter-spacing: 1px;
}

.login > p.muted {
  font-size: 13px;
  margin-top: 2px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  margin-top: 22px;
  text-align: left;
  padding: 18px 16px;
}

.login .small {
  margin-top: 16px;
  max-width: 300px;
}

/* ---------------- 宽屏 ---------------- */

@media (min-width: 640px) {
  .main {
    padding: 20px 20px calc(100px + env(safe-area-inset-bottom));
  }

  .overlay {
    align-items: center;
  }

  .sheet {
    max-width: 520px;
    border-radius: 20px;
    padding: 20px;
    max-height: 86vh;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fab {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}
