:root {
  --primary: #0ea5a4;
  --primary-dark: #0c8c8b;
  --primary-light: #e6f7f6;
  --accent: #3b82f6;
  --bg: #f4f7f9;
  --card: #ffffff;
  --text: #1f2d3d;
  --muted: #7b8a99;
  --border: #e6ebf0;
  --danger: #ef4444;
  --danger-light: #fde8e8;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(20, 50, 80, 0.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body { padding-bottom: calc(70px + var(--safe-b)); }

#app { min-height: 100vh; }

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ---------- 顶部栏 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 164, 0.25);
}
.hdr-btn {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.hdr-placeholder { background: transparent; visibility: hidden; }
.hdr-back { font-size: 26px; font-weight: 700; }
.hdr-title {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hdr-right { display: flex; align-items: center; gap: 6px; min-width: 36px; justify-content: flex-end; }
.hdr-avatar { font-size: 13px; opacity: 0.95; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-logout { font-size: 13px; background: rgba(255,255,255,0.18); padding: 6px 10px; border-radius: 10px; }

/* ---------- 容器 / 区块 ---------- */
.page { padding: 14px; }
.page-narrow { max-width: 720px; margin: 0 auto; }
.section { margin-bottom: 18px; }
.section-title { font-size: 14px; color: var(--muted); margin: 0 0 10px 4px; font-weight: 600; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; }
.card-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.card-row:last-child { border-bottom: none; }
.card-row .k { color: var(--muted); }
.card-row .v { font-weight: 500; text-align: right; word-break: break-all; }

/* ---------- 首页宫格 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s ease;
}
.grid-card:active { transform: scale(0.97); }
.grid-icon { font-size: 30px; }
.grid-label { font-size: 15px; font-weight: 600; }
.grid-sub { font-size: 12px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary-light);
  color: var(--primary-dark);
  min-height: 46px;
  width: 100%;
  transition: opacity 0.1s;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #eef2f6; color: var(--text); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.photo-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.btn-sm { min-height: 38px; padding: 8px 12px; font-size: 14px; width: auto; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); font-weight: 500; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 164, 0.12);
}
.field textarea { resize: vertical; min-height: 76px; }
.field-hint { font-size: 12px; color: var(--muted); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.check-row input { width: 20px; height: 20px; }
.input-money { position: relative; }
.input-money::before { content: '¥'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-money input { padding-left: 26px; }

/* ---------- 列表 ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: #fff;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: #f8fafb; }
.li-main { flex: 1; min-width: 0; }
.li-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.li-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.li-right { color: var(--muted); font-size: 20px; flex-shrink: 0; }
.li-member { display: inline-block; font-size: 11px; background: var(--primary-light); color: var(--primary-dark); padding: 1px 7px; border-radius: 8px; margin-left: 4px; font-weight: 600; }

/* ---------- 搜索框 ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; font-size: 15px; }
.search-bar input:focus { outline: none; border-color: var(--primary); }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 9px; font-weight: 600; }
.badge-stage-trial { background: #e0f2fe; color: #0369a1; }
.badge-stage-member { background: var(--primary-light); color: var(--primary-dark); }
.badge-stage-deal { background: #dcfce7; color: #15803d; }
.badge-stage-rep { background: #fef3c7; color: #b45309; }
.badge-stage-lost { background: #f1f5f9; color: #64748b; }
.badge-warn { background: var(--danger-light); color: var(--danger); }

/* ---------- 统计数字 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-align: center; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.rate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.rate-box { background: var(--primary-light); border-radius: 10px; padding: 12px 6px; text-align: center; }
.rate-num { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.rate-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- loading / 状态 ---------- */
.loading-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--muted); gap: 12px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--primary-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-box { text-align: center; padding: 60px 24px; }
.state-icon { font-size: 40px; margin-bottom: 10px; }
.state-text { color: var(--muted); margin-bottom: 18px; }
.empty-box { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 14px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 90vw; }
.toast { padding: 11px 18px; border-radius: 12px; background: rgba(31, 45, 61, 0.92); color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); opacity: 0; transform: translateY(-8px); transition: all 0.28s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: rgba(220, 38, 38, 0.95); }
.toast-success { background: rgba(16, 185, 129, 0.95); }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 30, 45, 0.5); display: flex; align-items: flex-end; justify-content: center; z-index: 500; opacity: 0; transition: opacity 0.25s ease; }
.modal-overlay.show { opacity: 1; }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 88vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; transform: translateY(20px); transition: transform 0.25s ease; overflow: hidden; }
.modal-overlay.show .modal { transform: translateY(0); }
.modal.full { max-width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--border); }
.modal-title { flex: 1; font-size: 17px; font-weight: 600; }
.modal-close { border: none; background: #eef2f6; width: 32px; height: 32px; border-radius: 50%; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }

/* ---------- 谈客助手 ---------- */
.talktree-fab {
  position: fixed; right: 16px; bottom: calc(20px + var(--safe-b)); z-index: 200;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; box-shadow: 0 6px 18px rgba(14, 120, 180, 0.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1; gap: 1px;
}
.talktree-fab span { font-size: 11px; font-weight: 600; }
.tt-node { display: flex; flex-direction: column; gap: 14px; }
.tt-question { font-size: 18px; font-weight: 700; line-height: 1.5; color: var(--text); }
.tt-observe { background: #f0f9ff; border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 8px; font-size: 14px; color: #075985; }
.tt-tip { background: #f1f5f9; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #64748b; font-style: normal; }
.tt-opts { display: flex; flex-direction: column; gap: 10px; }
.tt-opt { text-align: left; background: var(--primary-light); color: var(--primary-dark); border: 1px solid #cdeae9; border-radius: 12px; padding: 14px 16px; font-size: 16px; font-weight: 600; cursor: pointer; }
.tt-opt:active { transform: scale(0.98); }
.tt-actions { display: flex; gap: 10px; margin-top: 6px; }
.tt-actions .btn { flex: 1; }
.tt-end { text-align: center; padding: 40px 20px; }
.tt-end-icon { font-size: 46px; margin-bottom: 12px; }
.tt-end p { color: var(--muted); margin-bottom: 18px; }

/* ---------- 治疗卡 ---------- */
.qr-box { text-align: center; padding: 16px 0; }
.qr-box img { width: 220px; height: 220px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.qr-url { font-size: 12px; color: var(--muted); word-break: break-all; margin-top: 10px; }

/* ---------- 购买表单动态块 ---------- */
.pack-block { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fafcff; }
.pack-block.gift { background: #fff7ed; border-color: #fed7aa; }
.pack-block-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.pack-block.del { background: #fef2f2; }

/* ---------- 杂项 ---------- */
.muted { color: var(--muted); }
.text-warn { color: var(--danger); font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.summary-bar { background: var(--primary-light); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.summary-bar .big { font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.scroll-x { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border: 1px solid var(--border); padding: 8px; text-align: left; }
.table th { background: #f8fafb; color: var(--muted); font-weight: 600; }
.log-line { padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.log-line:last-child { border-bottom: none; }
.in-progress-tag { display: inline-block; background: var(--warning); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 8px; font-weight: 600; }
.center-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 16px; }
.brand { font-size: 26px; font-weight: 800; color: var(--primary-dark); letter-spacing: 1px; }
.brand-sub { color: var(--muted); font-size: 14px; }
.code-input { letter-spacing: 14px; font-size: 28px; text-align: center; font-weight: 700; }

/* ---------- 谈客助手：双 Tab / 进店率 / 内部话术 ---------- */
.tt-tabs { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border, #eee); }
.tt-tab { padding: 8px 14px; border: 1px solid var(--border, #eee); border-radius: 20px; background: #fff; font-size: 14px; cursor: pointer; color: var(--text); }
.tt-tab.active { background: var(--primary, #0ea5a4); color: #fff; border-color: var(--primary, #0ea5a4); }
.tt-stage { padding: 12px; }
.tt-prob { font-size: 12px; color: #e08000; background: #fff7e6; border: 1px solid #ffe2a8; border-radius: 6px; padding: 6px 8px; margin-bottom: 8px; }
.tt-tip.tt-internal { background: #fff1f0; border: 1px solid #ffccc7; color: #a8071a; }

/* ---------- 问诊结论卡：试探话术 / 推荐药包 / 收尾动作 ---------- */
.tt-probe { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; padding: 10px 12px; color: #3730a3; font-size: 14px; line-height: 1.6; }
.tt-pack { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 10px; padding: 10px 12px; font-size: 15px; color: #047857; }
.tt-pack b { font-size: 17px; }
.tt-pack-note { font-size: 12px; color: #059669; margin-top: 4px; line-height: 1.5; }
.tt-action { background: #fff7e6; border: 1px solid #ffe2a8; border-radius: 10px; padding: 10px 12px; color: #92400e; font-size: 14px; line-height: 1.6; }
.tt-node.tt-conclusion { gap: 10px; }
.tt-end-badge { text-align: center; color: #059669; font-size: 13px; font-weight: 600; }

/* ---------- AI 帮想话术 ---------- */
.tt-ai { border-top: 1px solid var(--border, #eee); padding: 10px 12px; }
.tt-ai-toggle { width: 100%; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border: none; border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; }
.tt-ai-toggle:active { opacity: 0.9; }
.tt-ai-panel { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.tt-ai-panel textarea { width: 100%; box-sizing: border-box; border: 1px solid #d4d8e0; border-radius: 10px; padding: 10px 12px; font-size: 15px; resize: vertical; min-height: 70px; font-family: inherit; }
.tt-ai-actions { display: flex; justify-content: flex-end; }
.tt-ai-loading { color: var(--muted); font-size: 13px; padding: 6px 0; }
.tt-ai-error { color: #a8071a; background: #fff1f0; border: 1px solid #ffccc7; border-radius: 10px; padding: 10px; font-size: 13px; }
.tt-ai-reply { background: #f4f4fb; border: 1px solid #e3e3f5; border-radius: 10px; padding: 12px; font-size: 14px; line-height: 1.7; color: #333; }
.tt-ai-reply b { color: #4338ca; }
.tt-ai-h { font-weight: 700; color: #3730a3; margin-top: 6px; }

/* ---------- 快捷 chips（客户痛点/目标点选） ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; }
.chip { border: 1px solid #cdeae9; background: #eefaf9; color: #0e7a77; border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer; }
.chip:active { transform: scale(0.96); }

/* ---------- AI 诊断卡片（点选症状后自动分析） ---------- */
.tt-dx { margin-top: 12px; border: 1px solid #c7d2fe; background: #eef2ff; border-radius: 12px; padding: 12px; font-size: 14px; }
.tt-dx-title { font-weight: 700; color: #3730a3; margin-bottom: 6px; }
.tt-dx-badge { display: inline-block; background: #6366f1; color: #fff; border-radius: 999px; font-size: 12px; padding: 2px 8px; margin-left: 6px; }
.tt-dx-extra { margin: 8px 0; color: #444; }
.tt-dx-talk { background: #fff; border: 1px dashed #a5b4fc; border-radius: 8px; padding: 8px 10px; color: #333; margin-top: 6px; }
.tt-dx-low { border-color: #fde68a; background: #fffbeb; }
.tt-dx-low .tt-dx-title { color: #92400e; }
.tt-dx-low .tt-dx-badge { background: #f59e0b; }
.tt-dx-loading { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ---------- 阶段性确诊暂存 ---------- */
.tt-drafts { border-top: 1px solid var(--border, #eee); padding: 10px 12px; }
.tt-drafts-toggle { width: 100%; background: #f0fdf4; color: #047857; border: 1px solid #a7f3d0; border-radius: 12px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; }
.tt-drafts-panel { margin-top: 10px; }
.tt-drafts-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.tt-draft-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 9px 11px; }
.tt-draft-name { font-size: 14px; font-weight: 600; color: #1e293b; }
.tt-draft-pack { display: inline-block; background: #ecfdf5; color: #059669; border-radius: 999px; font-size: 11px; padding: 1px 8px; margin-left: 6px; }
.tt-draft-probe { font-size: 12px; color: #64748b; margin-top: 3px; }
.tt-drafts-actions { display: flex; gap: 8px; justify-content: flex-end; }
#tt-dx-save { width: 100%; margin-top: 4px; }

/* ---------- 治疗页：药包→穴位联动信息卡 ---------- */
.acu-info { margin: 6px 0; }
.acu-info-card { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px; padding: 9px 11px; margin-bottom: 6px; font-size: 13px; }
.acu-info-name { font-weight: 700; color: #0369a1; margin-bottom: 3px; }
.acu-info-row { color: #475569; line-height: 1.6; }
.acu-combine-card { background: #f5f3ff; border: 1px dashed #c4b5fd; border-radius: 10px; padding: 10px 12px; color: #5b21b6; font-size: 13px; line-height: 1.6; margin-top: 4px; }
#t-acuBlock .field { margin-bottom: 6px; }

/* ---------- 治疗页：每药包独立卡片 ---------- */
.pack-card { background: #fafafa; border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.pack-card .check-row { margin-bottom: 6px; }
.pack-card .pack-acu-group { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e5e7eb; }
.pack-card .field { margin-bottom: 8px; }
.pack-card .acu-info-card { margin-bottom: 6px; }

/* ---------- 收款汇总：按收款方式（每方式应收/已收/待收三行） ---------- */
.method-block { padding: 8px 0; border-top: 1px solid var(--border, #eee); }
.method-block:first-child { border-top: none; }
.method-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }

/* ---------- 相机扫码（治疗卡） ---------- */
.modal.scan { max-width: 460px; }
.scan-wrap { padding: 4px 0; }
.scan-video { width: 100%; max-height: 56vh; object-fit: cover; background: #000; border-radius: 12px; display: block; }
.scan-divider { display: flex; align-items: center; gap: 12px; color: #99a; font-size: 12px; margin: 16px 0 10px; }
.scan-divider::before, .scan-divider::after { content: ''; flex: 1; height: 1px; background: #e5e7eb; }
#scanFileWrap .btn { display: inline-block; width: auto; }
