/* 企微教练 H5 原型样式。品牌色与管理小程序 1.0 一致（#F88703 / #A95702 / #FFF7EE），企微相关元素用企微蓝。 */
:root {
  color-scheme: light;
  --accent: #f88703; --ink: #a95702; --tint: #ffead2; --pale: #fff7ee;
  --text: #2c353a; --muted: #7b878c; --faint: #a3aaa6; --line: #eef1f1; --card-line: #e9eeee;
  --wecom: #2f7be0; --wecom-bg: #ebf3fe; --late: #c4462b; --late-bg: #fdeeea; --ok: #2f8a57; --ok-bg: #e9f6ee; --warn: #9a6b00; --warn-bg: #fff4df;
  --bg: #f5f6f6; --page: #eceee9;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--text); font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 外框：桌面端显示手机框 + 控制台，手机上铺满 ---------- */
.frame-wrap { display: flex; justify-content: center; align-items: center; min-height: 100%; padding: 24px 24px 24px 344px; }
.phone { position: relative; display: flex; flex-direction: column; width: 390px; height: min(820px, calc(100vh - 48px)); overflow: hidden; border-radius: 34px; background: var(--bg); box-shadow: 0 0 0 10px #1f2427, 0 24px 60px #1f242740; }
@media (max-width: 899px) {
  .frame-wrap { display: block; padding: 0; min-height: 0; }
  .phone { width: 100%; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
}
html.in-wecom .frame-wrap { display: block; padding: 0; }
html.in-wecom .phone { width: 100%; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
html.in-wecom .nav { display: none; } /* 企微内用原生标题栏（document.title） */

/* 模拟企微原生标题栏 */
.nav { position: relative; flex: none; display: grid; place-items: center; height: 46px; padding-top: env(safe-area-inset-top); background: #fff; border-bottom: 1px solid #e8eaea; }
.nav h1 { margin: 0; font-size: 16px; font-weight: 600; }
.nav-back { position: absolute; left: 4px; bottom: 3px; width: 40px; height: 40px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--text); }

.view { position: relative; flex: 1; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 24px; -webkit-overflow-scrolling: touch; }
.view > * { flex: none; }
.view:has(> .bottom-bar) { padding-bottom: 0; }
.view > :has(+ .bottom-bar) { margin-bottom: 14px; }
.view:focus { outline: none; }
.loading { padding: 60px 0; color: var(--muted); text-align: center; font-size: 13px; }

.tabbar { flex: none; display: grid; grid-template-columns: 1fr 1fr; padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid #e8eaea; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; color: #8a8f8d; font-size: 11px; text-decoration: none; }
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="true"] { color: var(--accent); font-weight: 600; }

/* ---------- 通用组件 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; padding: 0 15px; border: 1px solid #dfe5e7; border-radius: 17px; background: #fff; color: #4f5b60; font-size: 13px; text-decoration: none; white-space: nowrap; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.btn.big { flex: 1; height: 44px; border-radius: 22px; font-size: 15px; }
.btn:disabled { border-color: #e6e9e9; background: #f1f3f3; color: var(--faint); cursor: not-allowed; }
.link { padding: 0; border: 0; background: none; color: var(--wecom); font-size: inherit; }
.muted { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 64px 16px; color: var(--muted); font-size: 12px; text-align: center; }
.empty strong { color: var(--text); font-size: 15px; }
.empty.small { gap: 4px; padding: 28px 12px; border: 1px dashed #dfe4e4; border-radius: 10px; background: #fff; }
.empty.small strong { font-size: 13px; }

.sec { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 2px 9px; font-size: 14px; font-weight: 700; }
.sec small { color: var(--faint); font-size: 11px; font-weight: 400; }
.foot { margin: 22px 4px 4px; color: var(--faint); font-size: 11px; text-align: center; }
.caption { margin: 10px 2px 8px; color: var(--muted); font-size: 11px; }

.tag { display: inline-flex; align-items: center; height: 21px; padding: 0 7px; border-radius: 4px; background: var(--pale); color: var(--ink); font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag.tone-bind { background: var(--wecom-bg); color: var(--wecom); }
.tag.tone-new { background: var(--tint); color: var(--ink); }
.tag.tone-service { background: #f1f4f2; color: #49605a; }
.tag.tone-sleep { background: #fff1e9; color: #ae5c2d; }
.stage { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px; background: var(--pale); color: var(--ink); font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.stage[data-stage="潜客"] { background: #f1f4f2; color: #5c6d66; }
.stage[data-stage="活跃客"] { background: var(--ok-bg); color: var(--ok); }
.stage[data-stage="沉睡客"] { background: #fff1e9; color: #ae5c2d; }
.stage[data-stage="流失客"] { background: #f3f0ef; color: #8b6b62; }
.chip { display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border-radius: 3px; font-size: 10px; white-space: nowrap; }
.chip.wecom { background: var(--wecom-bg); color: var(--wecom); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.muted { margin: 0; background: #f1f3f3; color: var(--muted); }

.avatar { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--tint); color: var(--ink); font-size: 15px; font-weight: 700; }
.avatar.wecom { background: var(--wecom-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f7be0' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8.5' r='3.6'/%3E%3Cpath d='M5 20c.7-3.9 3.4-6 7-6s6.3 2.1 7 6'/%3E%3C/svg%3E") 50% 50% / 58% no-repeat; color: transparent; }
.avatar.big { width: 48px; height: 48px; font-size: 19px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; }
.who > div { min-width: 0; flex: 1; }
.who strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who strong small { margin-left: 2px; color: var(--faint); font-size: 11px; font-weight: 400; }
.who strong i { color: #b9c0bd; font-style: normal; font-weight: 400; }
.who small { display: block; color: var(--muted); font-size: 12px; }
.who strong small { display: inline; }

/* ---------- 今日 ---------- */
.hero { padding: 15px 16px 14px; border: 1px solid #f6dfc4; border-radius: 12px; background: linear-gradient(160deg, #fff 0%, var(--pale) 100%); }
.hero h2 { margin: 0; font-size: 18px; }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 13px; }
.stats div { display: grid; gap: 1px; }
.stats div + div { padding-left: 12px; border-left: 1px solid #f3e2cd; }
.stats b { color: var(--ink); font-size: 22px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 11px; }
.stats .is-late b { color: var(--late); }

.card { display: block; margin-bottom: 10px; padding: 12px 13px; border: 1px solid var(--card-line); border-radius: 10px; background: #fff; color: inherit; text-decoration: none; box-shadow: 0 3px 12px #25313708; }
.card.bind { border-color: #cfe0f8; }
.card.late { border-left: 3px solid var(--late); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.due { color: var(--muted); font-size: 11.5px; }
.due.is-late { color: var(--late); font-weight: 600; }
.ctx, .match { margin: 9px 0 0; color: #4f5b60; font-size: 12.5px; line-height: 1.55; }
.conf { display: inline-flex; align-items: center; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 3px; font-size: 10px; font-weight: 600; vertical-align: 1px; }
.conf.high { background: var(--ok-bg); color: var(--ok); }
.conf.medium { background: var(--warn-bg); color: var(--warn); }
.conf.low { background: #f1f3f3; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.upcoming { margin: 0; padding: 4px 13px; border: 1px solid var(--card-line); border-radius: 10px; background: #fff; list-style: none; }
.upcoming li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; font-size: 13px; }
.upcoming li + li { border-top: 1px solid var(--line); }
.upcoming li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 客户列表 ---------- */
.search { display: block; }
.search input { width: 100%; height: 38px; padding: 0 14px 0 36px; border: 1px solid #e3e7e7; border-radius: 19px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3aaa6' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 13px 50% / 16px no-repeat; font-size: 14px; }
.search input:focus { border-color: var(--accent); outline: none; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 8px; border: 1px solid var(--card-line); border-radius: 10px; background: #fff; color: inherit; text-decoration: none; }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; font-size: 14.5px; }
.row-main small { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: grid; justify-items: end; gap: 4px; }

/* ---------- 客户卡 ---------- */
.profile { padding: 14px; border-radius: 12px; background: #fff; border: 1px solid var(--card-line); }
.who.big strong { font-size: 18px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.tags .t { display: inline-flex; align-items: center; height: 21px; padding: 0 7px; border-radius: 11px; background: #f3f5f5; color: #56636a; font-size: 11px; }
.tags .t.hv { background: var(--tint); color: var(--ink); font-weight: 600; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; }
.metrics div { display: grid; }
.metrics div + div { border-left: 1px solid var(--line); }
.metrics b { font-size: 16px; font-variant-numeric: tabular-nums; }
.metrics span { color: var(--muted); font-size: 11px; }
.task-box { margin-top: 10px; padding: 12px 13px; border: 1px solid #f6dfc4; border-radius: 10px; background: var(--pale); }
.task-box .card-head { margin-bottom: 6px; }
.task-box p { margin: 0; font-size: 13px; }
.task-box p.muted { margin-top: 4px; font-size: 11.5px; }
.note { margin-top: 10px; padding: 10px 13px; border-radius: 10px; background: #fff; border: 1px solid var(--card-line); font-size: 13px; }
.note b { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; font-weight: 400; }
.block { margin-top: 10px; padding: 12px 13px; border-radius: 10px; background: #fff; border: 1px solid var(--card-line); }
.block h3 { margin: 0 0 8px; font-size: 13.5px; }
.block dl { display: grid; grid-template-columns: 68px 1fr; gap: 7px 10px; margin: 0; font-size: 13px; }
.block dt { color: var(--muted); }
.block dd { margin: 0; min-width: 0; }
.block dd small { color: var(--muted); }
.orders, .timeline { margin: 0; padding: 0; list-style: none; }
.orders li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; }
.orders li + li { border-top: 1px solid var(--line); }
.orders b { display: block; font-size: 13px; font-weight: 600; }
.orders small { color: var(--muted); font-size: 11.5px; }
.orders span { font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline li { position: relative; padding: 0 0 12px 16px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 17px; bottom: 0; width: 1px; background: #ecdcc9; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.tl-head span { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; }
.timeline p { margin: 2px 0 0; font-size: 12.5px; }
.timeline p.muted { font-size: 11.5px; }
.bottom-bar { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; margin: auto -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fffffff2; border-top: 1px solid #e8eaea; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* ---------- 确认绑定 ---------- */
.friend { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid #cfe0f8; border-radius: 12px; background: #fff; }
.friend strong { display: block; font-size: 17px; }
.friend small { color: var(--muted); font-size: 12px; }
.cand { display: flex; gap: 10px; margin-bottom: 9px; padding: 12px 13px; border: 1.5px solid var(--card-line); border-radius: 10px; background: #fff; cursor: pointer; }
.cand:has(input:checked) { border-color: var(--accent); background: var(--pale); }
.cand input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.cand > div { flex: 1; min-width: 0; }
.cand-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.cand-top b { font-size: 14px; }
.cand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.cand p { margin: 5px 0 0; color: #4f5b60; font-size: 12.5px; }
.hint { margin: 6px 2px 0; padding: 9px 11px; border-radius: 8px; background: var(--wecom-bg); color: #3a5f8f; font-size: 12px; }

/* ---------- 弹层 ---------- */
.layer:empty { display: none; }
.mask { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; background: #1f242766; animation: fade .16s ease-out; }
.sheet { width: 100%; max-height: 88%; overflow-y: auto; padding: 6px 16px calc(14px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: #fff; animation: rise .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .mask, .sheet { animation: none; } }
.handle { width: 36px; height: 4px; margin: 2px auto 8px; border-radius: 2px; background: #dfe3e3; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 16px; }
.x { width: 36px; height: 36px; margin-right: -8px; border: 0; background: none; color: var(--muted); font-size: 24px; line-height: 1; }
.sub { margin: 2px 0 12px; color: var(--muted); font-size: 12px; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcomes button { display: grid; gap: 1px; padding: 9px 10px; border: 1.5px solid #e6eaea; border-radius: 9px; background: #fff; text-align: left; }
.outcomes button b { font-size: 13.5px; }
.outcomes button small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.outcomes button[aria-pressed="true"] { border-color: var(--accent); background: var(--pale); }
.outcomes button[aria-pressed="true"] b { color: var(--ink); }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span { color: var(--muted); font-size: 12px; }
.field input { height: 40px; padding: 0 12px; border: 1px solid #e3e7e7; border-radius: 8px; background: #fff; font-size: 14px; }
.field input:focus { border-color: var(--accent); outline: none; }
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.tagpick button { height: 30px; padding: 0 11px; border: 1px solid #e3e7e7; border-radius: 15px; background: #fff; font-size: 12px; color: #4f5b60; }
.tagpick button[aria-pressed="true"] { border-color: var(--accent); background: var(--pale); color: var(--ink); font-weight: 600; }
.next { margin: 14px 0 0; padding: 9px 11px; border-radius: 8px; background: #f5f7f7; color: #4f5b60; font-size: 12.5px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 14px; }
.sheet-actions .btn { height: 44px; border-radius: 22px; font-size: 15px; }
.sheet-actions.one { grid-template-columns: 1fr; }
.templates { display: grid; gap: 8px; }
.tpl { padding: 11px 12px; border: 1px solid #e3e7e7; border-radius: 10px; background: #fafbfb; font-size: 13.5px; line-height: 1.55; text-align: left; }
.tpl:active { border-color: var(--accent); background: var(--pale); }
.reasons { display: grid; gap: 2px; }
.reasons label { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.reasons input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ---------- 提示 ---------- */
.toast { position: absolute; left: 0; right: 0; bottom: 96px; z-index: 40; width: max-content; max-width: calc(100% - 48px); margin: 0 auto; padding: 9px 14px; border-radius: 8px; background: #1f2427e6; color: #fff; font-size: 13px; text-align: center; pointer-events: none; }
.push-banner { position: absolute; top: 52px; left: 10px; right: 10px; z-index: 30; display: grid; gap: 2px; padding: 10px 13px; border: 0; border-radius: 12px; background: #fffffff7; box-shadow: 0 8px 28px #1f24272e; text-align: left; font-size: 13px; animation: rise .2s ease-out; }
.push-banner b { color: var(--wecom); font-size: 11.5px; }

/* ---------- 演示控制台 ---------- */
.demo-panel { position: fixed; z-index: 50; top: 24px; left: 24px; width: 296px; max-height: calc(100vh - 48px); overflow-y: auto; border-radius: 14px; background: #fff; box-shadow: 0 10px 30px #1f24271a; font-size: 13px; }
.demo-panel summary { display: flex; align-items: baseline; gap: 8px; padding: 14px 16px; list-style: none; cursor: pointer; font-weight: 700; }
.demo-panel summary::-webkit-details-marker { display: none; }
.demo-panel summary small { color: var(--muted); font-weight: 400; font-size: 11px; }
.demo-panel summary .short { display: none; }
.demo-body { padding: 0 16px 16px; }
.demo-note { margin: 0 0 12px; color: var(--muted); font-size: 11.5px; }
.demo-panel fieldset { margin: 0 0 12px; padding: 0; border: 0; }
.demo-panel legend, .demo-field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11.5px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 9px; background: #f1f3f3; }
.seg button { height: 32px; border: 0; border-radius: 7px; background: none; font-size: 12.5px; color: #4f5b60; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px #1f242722; }
.demo-field { display: block; margin-bottom: 12px; }
.demo-field select { width: 100%; height: 34px; padding: 0 8px; border: 1px solid #e3e7e7; border-radius: 8px; background: #fff; font-size: 12.5px; }
.demo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demo-actions button, .demo-reset { height: 32px; border: 1px solid #e3e7e7; border-radius: 8px; background: #fff; font-size: 12px; color: #4f5b60; }
.demo-actions button:hover { border-color: var(--wecom); color: var(--wecom); }
.demo-reset { width: 100%; color: var(--late); }
.demo-steps { margin: 14px 0 0; padding: 12px 0 0 18px; border-top: 1px solid var(--line); color: #56636a; font-size: 12px; }
.demo-steps li + li { margin-top: 4px; }
@media (max-width: 899px) {
  .demo-panel { top: 6px; left: auto; right: 8px; width: auto; max-width: calc(100vw - 16px); background: transparent; box-shadow: none; }
  .demo-panel summary { padding: 7px 11px; border-radius: 15px; background: var(--text); color: #fff; font-size: 12px; float: right; }
  .demo-panel summary small, .demo-panel summary .full { display: none; }
  .demo-panel summary .short { display: inline; }
  .demo-panel[open] { width: min(320px, calc(100vw - 16px)); }
  .demo-panel[open] .demo-body { clear: both; margin-top: 6px; padding-top: 14px; border-radius: 14px; background: #fff; box-shadow: 0 10px 30px #1f242733; }
}
