:root {
  --canvas: #f2f4f0;
  --surface: #fff;
  --ink: #17241f;
  --ink-soft: #5f6b65;
  --line: #e1e6e1;
  --brand: #183d36;
  --accent: #2f7c69;
  --accent-soft: #e3f1eb;
  --warn: #a35d2c;
  --warn-soft: #fbeee3;
  --danger: #9d4b48;
  --danger-soft: #f9ebea;
  --blue: #2f5677;
  --blue-soft: #e2ecf5;
  --tabbar-h: 58px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
main { max-width: 640px; margin: 0 auto; padding: 0 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
.loading, .empty { padding: 40px 8px; color: var(--ink-soft); text-align: center; }

/* header */
.page-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; margin: 0 -14px; padding: 12px 14px 10px; background: var(--canvas); }
.page-head h1 { flex: 1; margin: 0; font-size: 21px; }
.back { width: 36px; height: 36px; margin-left: -6px; border: 0; border-radius: 50%; background: transparent; font-size: 24px; line-height: 1; }
.head-action { padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 14px; }

/* segmented + chips */
.segmented { display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; border-radius: 12px; background: #e3e8e3; }
.segmented button { flex: 1; padding: 8px 0; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); font-size: 15px; }
.segmented button.on { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px; scrollbar-width: none; }
.chips button { flex-shrink: 0; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 14px; }
.chips button.on { border-color: var(--brand); background: var(--brand); color: #fff; }

/* cards */
.card { margin: 0 0 12px; padding: 14px; border-radius: 16px; background: var(--surface); }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--ink-soft); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 12px; }
.quick button { padding: 12px 4px; border: 0; border-radius: 14px; background: var(--surface); font-size: 15px; font-weight: 600; }
.occupy-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; }
.occupy-list li { display: flex; gap: 10px; }
.occupy-list b { font-variant-numeric: tabular-nums; }

.appt { display: block; width: 100%; margin: 0 0 10px; padding: 14px; border: 0; border-left: 5px solid var(--blue); border-radius: 14px; background: var(--surface); text-align: left; }
.appt.s-in_service { border-left-color: var(--accent); }
.appt.s-pending { border-left-color: var(--warn); }
.appt.s-completed, .appt.s-evaluated, .appt.s-cancelled { border-left-color: #b8c0bb; opacity: .75; }
.appt .time { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.appt .who { margin-top: 2px; font-size: 17px; font-weight: 650; }
.appt .what { color: var(--ink-soft); font-size: 14px; }
.status { padding: 3px 9px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); font-size: 13px; white-space: nowrap; }
.status.s-in_service { background: var(--accent-soft); color: var(--accent); }
.status.s-pending { background: var(--warn-soft); color: var(--warn); }
.status.s-completed, .status.s-evaluated, .status.s-cancelled { background: #eceeec; color: var(--ink-soft); }
.appt-foot { display: flex; justify-content: flex-end; margin-top: 10px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-size: 16px; font-weight: 650; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 15px; }
.btn.ghost { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.bottom-bar { position: fixed; left: 0; right: 0; max-width: 640px; margin: 0 auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 10px; padding: 10px 14px; background: rgba(242,244,240,.96); border-top: 1px solid var(--line); }
.bottom-bar .btn { flex: 1; }
.with-bottom-bar { padding-bottom: 76px; }

/* detail */
.kv { display: grid; grid-template-columns: 5.5em 1fr; gap: 6px 10px; margin: 0; font-size: 15px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; word-break: break-all; }
.flow { margin: 0; padding: 0; list-style: none; }
.flow li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 5px; }
.flow li:last-child { border-left-color: transparent; padding-bottom: 0; }
.flow li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.flow .t { font-weight: 650; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.thumbs img { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; background: #eee; }

/* forms */
label.field { display: block; margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); }
label.field > input, label.field > textarea, label.field > select { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-size: 16px; }
textarea { min-height: 90px; resize: vertical; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.tags button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: #f6f8f5; font-size: 14px; }
.tags button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.uploader { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.uploader .shot { position: relative; }
.uploader .shot button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 22px; }
.uploader .add { display: grid; place-items: center; width: 76px; height: 76px; border: 1px dashed #aab4ae; border-radius: 10px; color: var(--ink-soft); font-size: 28px; }
.uploader .add input { display: none; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; z-index: 21; max-height: 88vh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--surface); }
.sheet h2 { margin: 0 0 14px; font-size: 18px; }
.sheet .close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eef1ee; font-size: 20px; }

/* tabbar：与正文同宽居中，企微电脑客户端布局宽度可能大于窗口 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; z-index: 10; display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: #fff; }
.tabbar a { flex: 1; display: grid; place-items: center; align-content: center; gap: 1px; color: var(--ink-soft); font-size: 12px; text-decoration: none; }
.tabbar a i { font-style: normal; font-size: 20px; line-height: 1.1; }
.tabbar a.on { color: var(--brand); font-weight: 650; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 90px); z-index: 30; max-width: 86vw; padding: 10px 16px; transform: translateX(-50%); border-radius: 12px; background: rgba(23,36,31,.92); color: #fff; font-size: 15px; text-align: center; }
.menu { margin: 0 0 12px; padding: 0; border-radius: 16px; background: var(--surface); list-style: none; overflow: hidden; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a, .menu button { display: flex; justify-content: space-between; width: 100%; padding: 14px; border: 0; background: none; color: var(--ink); font-size: 16px; text-align: left; text-decoration: none; }
.menu a::after, .menu button::after { content: "›"; color: #a5aea9; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
.stat-grid a { display: block; padding: 14px; border-radius: 16px; background: var(--brand); color: #fff; text-decoration: none; }
.stat-grid a + a { background: #245247; }
.stat-grid b { display: block; font-size: 24px; }
.stat-grid span { font-size: 13px; opacity: .85; }

/* 代客开卡（照搬小程序选择套卡弹层） */
.pkg { margin: 0 0 10px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.pkg.on { border-color: var(--accent); background: #f7fbf9; }
.pkg .price { color: #904d00; font-size: 17px; white-space: nowrap; }
.acts { display: grid; gap: 6px; margin-top: 8px; }
.acts button { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f6f8f5; font-size: 14px; text-align: left; }
.acts button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.open-fields { padding-top: 6px; border-top: 1px solid var(--line); }
.logs { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.logs li { padding: 8px 0; border-top: 1px solid var(--line); }

/* 经营概览 */
.date-in { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 15px; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 16px; background: var(--surface); }
.kpi:first-child { background: var(--brand); color: #fff; }
.kpi:first-child em, .kpi:first-child span { color: rgba(255,255,255,.8); }
.kpi span { color: var(--ink-soft); font-size: 13px; }
.kpi b { font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi b small { font-size: 14px; font-weight: 500; }
.kpi em { color: var(--ink-soft); font-size: 12px; font-style: normal; }
.kpi small.up, .kpi small.down { font-size: 12px; font-weight: 600; }
.kpi small.up { color: var(--accent); }
.kpi small.down { color: var(--danger); }
.kpi:first-child small.up, .kpi:first-child small.down { color: #bfe6d6; }
.rank { padding: 8px 0; border-top: 1px solid var(--line); }
.rank i { display: inline-block; width: 1.6em; color: var(--ink-soft); font-style: normal; }
.bar { height: 6px; margin: 6px 0 4px; border-radius: 3px; background: #eef1ee; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar.alt span { background: var(--blue); }
.trend { display: grid; grid-template-columns: 3.2em 1fr 6.5em; align-items: center; gap: 8px; font-size: 13px; }
.trend .bar { margin: 0; }
.trend b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 学习（learn.js） */
.lv-motto { margin: 0 4px 14px; color: var(--ink-soft); font-size: 14px; line-height: 1.8; }
.lv-motto span { display: block; text-align: right; font-size: 13px; }
.lv-group { margin: 16px 4px 8px; font-size: 15px; color: var(--ink-soft); }
.lv-card { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; padding: 14px; border-radius: 16px; background: var(--surface); }
.lv-play { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 15px; }
.lv-main { flex: 1; min-width: 0; }
.lv-main b { display: block; font-size: 16px; }
.lv-main small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 13px; }
.lv-tag { flex: none; padding: 3px 9px; border-radius: 99px; background: #eceeec; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.lv-tag.part { background: var(--warn-soft); color: var(--warn); }
.lv-tag.done { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.lv-player { margin: 0 -14px 12px; background: #000; }
.lv-progress { margin: 0; font-weight: 600; }
.lv-stage { position: relative; background: #000; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.lv-stage video { display: block; width: 100%; max-height: 70vh; background: #000; }
.lv-watermark { position: absolute; inset: 0 0 56px; display: grid; grid-template-columns: repeat(2, 1fr); align-content: space-evenly; justify-items: center; overflow: hidden; pointer-events: none; }
.lv-watermark span { transform: rotate(-24deg); color: rgba(255,255,255,.3); font-size: 12px; white-space: nowrap; text-shadow: 0 0 2px rgba(0,0,0,.35); }
.lv-full { position: absolute; top: 10px; right: 10px; padding: 6px 10px; border: 0; border-radius: 8px; background: rgba(0,0,0,.45); color: #fff; font-size: 13px; }
.lv-stage:fullscreen, .lv-stage.is-full { display: flex; align-items: center; justify-content: center; }
.lv-stage.is-full { position: fixed; inset: 0; z-index: 1000; }
.lv-stage:fullscreen video, .lv-stage.is-full video { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.lv-stage:fullscreen .lv-watermark span, .lv-stage.is-full .lv-watermark span { font-size: 16px; }
.lv-select { width: 100%; min-height: 42px; margin: 0 0 10px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.lv-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 10px; }
.lv-sum span { padding: 8px 10px; border-radius: 12px; background: var(--surface); color: var(--ink-soft); font-size: 12px; }
.lv-sum b { display: block; color: var(--ink); font-size: 20px; }
.lv-people { margin-top: 10px; padding: 4px 14px; }
.lv-person { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lv-person:last-child { border-bottom: 0; }
.lv-person small { display: block; color: var(--ink-soft); font-size: 12px; }
.lv-person-r { flex: none; text-align: right; }
.lv-person-r small { margin-top: 3px; }

/* 自测（exam.js） */
.ex-chips { margin: 0 0 10px; }
.ex-size { margin: 0 0 12px; }
.ex-list { padding: 4px 14px; }
.ex-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.ex-row:last-child { border-bottom: 0; }
.ex-row small { display: block; color: var(--ink-soft); font-size: 12px; }
.ex-score { flex: none; font-size: 20px; font-weight: 700; }
.ex-score small { display: inline; font-size: 13px; font-weight: 400; }
.ex-type { margin: 0 0 6px; color: var(--ink-soft); font-size: 13px; }
.ex-stem { margin: 0 0 12px; font-size: 16px; line-height: 1.6; font-weight: 600; }
.ex-opts { display: grid; gap: 8px; }
.ex-opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.5; text-align: left; }
.ex-opt i { flex: none; min-width: 1em; font-style: normal; font-weight: 700; color: var(--ink-soft); }
.ex-opt i:empty { display: none; }
.ex-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.ex-opt.on i { color: var(--accent); }
.ex-opt.right { border-color: var(--accent); background: var(--accent-soft); }
.ex-opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.ex-verdict { margin: 12px 0 0; font-size: 14px; }
.ex-mark { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.ex-mark.ok { background: var(--accent-soft); color: var(--accent); }
.ex-mark.half { background: var(--warn-soft); color: var(--warn); }
.ex-mark.bad { background: var(--danger-soft); color: var(--danger); }
.ex-analysis { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: #f3f5f1; color: var(--ink-soft); font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.ex-submit { position: sticky; bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -2px 12px; padding: 10px 14px; border-radius: 16px; background: var(--surface); box-shadow: 0 2px 12px rgba(0,0,0,.1); }
.ex-total { text-align: center; }
.ex-total b { font-size: 40px; }
.ex-total span { margin-left: 4px; color: var(--ink-soft); }
.ex-total small { display: block; margin-top: 4px; color: var(--ink-soft); }
/* 月考（exam.js） */
.ex-exam h2 { margin: 0 0 4px; }
.ex-topic { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #f3f5f1; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.ex-state { margin: 4px 0 0; }
.ex-exam .ex-row { padding: 6px 0 0; border: 0; }
.ex-note { margin: 0 4px 12px; }
.ex-essay { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; line-height: 1.6; }
.ex-hurry { color: var(--danger); }
