:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #14171c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --brand: #2f6f6a;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  font-size: 14px; line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; }
.brand-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-dot { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.brand-title { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfbfc; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); background: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 12px; font-weight: 500; border-radius: 8px; }
.btn.ghost.danger { color: var(--danger); border-color: #f3c6c6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
.err { color: var(--danger); font-size: 13px; margin: 4px 0 10px; min-height: 18px; }

/* 布局 */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: #f4f5f7;
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 12px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: 0 0 auto; }
.who-name { font-weight: 600; font-size: 14px; }
.who-org { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn { border: 0; background: transparent; padding: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }

.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 104px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: .3px; }
.page-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.section-title h2 { font-size: 15px; margin: 0; font-weight: 700; }
.link { color: var(--brand); font-size: 12px; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 2px; letter-spacing: .4px; }
.kpi .foot { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi.pri .value { color: var(--brand); }
.kpi.danger .value { color: var(--danger); }
.kpi.ok .value { color: var(--ok); }

.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-strip > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-strip .label { font-size: 11px; color: var(--muted); }
.stat-strip .value { font-size: 17px; font-weight: 700; }

/* 列表 */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: block; }
.row:last-child { border-bottom: 0; }
.row:active { background: #fafafa; }
.row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-name { font-weight: 600; font-size: 15px; }
.row-meta { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.tag.on { outline: 2px solid var(--brand); outline-offset: -1px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef2f1; color: #33524f; border: 1px solid #dbe6e4; }
.tag.global { background: #eef1f6; color: #3c4a63; border-color: #dde3ee; }
.tag button { border: 0; background: transparent; color: #8a9aa0; margin-left: 2px; cursor: pointer; padding: 0 0 0 2px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.badge.pending { background: #fff4e5; color: var(--warn); }
.badge.submitted { background: #e8f0fe; color: #1d4ed8; }
.badge.approved { background: #e8f5ec; color: var(--ok); }
.badge.rejected { background: #fdeaea; color: var(--danger); }
.badge.void { background: #f3f4f6; color: var(--muted); }
.badge.overdue { background: #fdeaea; color: var(--danger); }
.badge.today { background: #e7f2f0; color: var(--brand); }
.badge.later { background: #f1f2f4; color: var(--muted); }

/* 表单/弹层 */
.sheet-mask { position: fixed; inset: 0; background: rgba(17,24,39,.42); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px 24px; }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .sub { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet-mask { align-items: center; }
  .sheet { border-radius: 18px; max-width: 520px; }
}

/* 详情 */
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-name { font-size: 18px; font-weight: 700; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { border-left: 2px solid #e8eaea; margin-left: 6px; padding-left: 14px; }
.timeline-item { position: relative; padding: 0 0 14px; }
.timeline-item::before { content: ""; position: absolute; left: -21px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline-item p { margin: 2px 0 0; font-size: 13px; }
.timeline-time { font-size: 11px; color: var(--muted); }

/* 表格（PC） */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: stretch;
  background: #fff; border-top: 1px solid #dfe3e8;
  box-shadow: 0 -3px 14px rgba(15,23,42,.08);
  padding: 5px 6px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; margin: 0 2px; padding: 6px 0 4px; border-radius: 12px;
  font-size: 12px; line-height: 1; color: #6b7280; text-decoration: none;
  -webkit-tap-highlight-color: transparent; transition: background .15s ease, color .15s ease;
}
.tabbar a svg { width: 22px; height: 22px; stroke: currentColor; }
.tabbar a + a::before {
  content: ""; position: absolute; left: -4px; top: 12px; bottom: 12px; width: 1px; background: #eceff3;
  border-radius: 1px;
}
.tabbar a:active { background: #f1f4f3; }
.tabbar a.active { color: var(--brand); font-weight: 700; background: #eaf2f0; }


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

/* 骨架 */
.loading { color: var(--muted); font-size: 13px; padding: 26px; text-align: center; }

@media (min-width: 900px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .main { padding: 24px 24px 40px; }
  .tabbar { display: none; }
}

/* 公海与筛选 */
.kpi.pool { grid-column: 1 / -1; border-color: #eadbc0; background: #fffaf0; }
.filterbar { margin-bottom: 12px; }
.searchline { display: flex; gap: 8px; align-items: center; }
.searchline input { flex: 1; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; }
.searchline select { min-height: 36px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.notice { margin-top: 12px; padding: 12px; border-radius: 10px; background: #fff7e6; border: 1px solid #f0dcb8; font-size: 13px; color: #7a5a18; }

/* 指标 */
.target-card { display: block; margin-top: 12px; }
.bar { height: 8px; border-radius: 999px; background: #eceff3; overflow: hidden; margin-top: 10px; }
.fill { height: 100%; background: linear-gradient(90deg, #2f6f6a, #5aa79f); border-radius: 999px; }
.sub-head { margin: 14px 0 6px; font-size: 12px; color: var(--muted); }
.warn-line { color: var(--warn); font-size: 12px; margin: 2px 0 0; }
.list.tight .row { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list.tight .row:last-child { border-bottom: 0; }
.kpi-inline { display: flex; align-items: baseline; gap: 10px; }
.kpi-inline .big { font-size: 26px; font-weight: 700; }
.block { margin-top: 18px; }
.block .section-title { margin-top: 0; }
.badge.pending { background: #fef3c7; color: #92400e; padding: 3px 8px; border-radius: 999px; font-size: 12px; }
.list.tight .row { padding: 10px 0; }
.list.tight { background: transparent; border: 0; border-radius: 0; }
.badge.cross { background: #ede9fe; color: #5b21b6; }

/* ---------- 经营看板 ---------- */
.board-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
.board-select{height:34px;border:1px solid #e3e5ea;background:#fff;border-radius:8px;padding:0 10px;font-size:13px;color:#333}
.board-kpis{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-bottom:14px}
.board-kpi{background:#fff;border:1px solid #e9ebef;border-radius:14px;padding:14px 16px}
.board-kpi .label{font-size:12px;color:#8a8f99}
.board-kpi .value{font-size:22px;font-weight:700;color:#141414;margin:4px 0 2px}
.board-kpi .foot{font-size:12px;color:#8a8f99}
.board-kpi .foot .up{color:#137a4b;font-weight:600}
.board-kpi .foot .down{color:#c0392b;font-weight:600}
.board-grid{display:grid;grid-template-columns:1fr;gap:12px}
.board-card{background:#fff;border:1px solid #e9ebef;border-radius:14px;padding:14px 16px}
.board-card-head{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px}
.board-card-head h3{font-size:14px;margin:0}
.trend{display:flex;align-items:flex-end;gap:10px;height:150px;padding-top:6px}
.trend-col{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%}
.trend-bar-wrap{flex:1;width:100%;display:flex;align-items:flex-end;justify-content:center}
.trend-bar{width:60%;max-width:34px;background:linear-gradient(180deg,#e0c98a,#c9ac64);border-radius:6px 6px 0 0;min-height:6px}
.trend-val{font-size:11px;color:#4b5563;margin-top:6px}
.trend-lab{font-size:11px;color:#9aa0aa}
.funnel-row{display:flex;align-items:center;gap:10px;margin-bottom:9px}
.funnel-name{width:74px;font-size:12px;color:#4b5563;flex-shrink:0}
.funnel-bar{flex:1;height:14px;background:#f2f3f6;border-radius:7px;overflow:hidden}
.funnel-bar>div{height:100%;background:#c9ac64;border-radius:7px}
.funnel-num{width:34px;text-align:right;font-size:12px;color:#333}
.table-wrap{overflow-x:auto}
.board-card table{width:100%;border-collapse:collapse;font-size:13px}
.board-card th,.board-card td{padding:8px 6px;border-bottom:1px solid #f1f2f5;text-align:left;white-space:nowrap}
.board-card th{font-size:12px;color:#8a8f99;font-weight:600}
.board-card td.num,.board-card th.num{text-align:right}
.tag-cloud{display:flex;flex-wrap:wrap;gap:8px}
.tag-chip{display:inline-flex;align-items:center;gap:6px;border:1px solid #e3e5ea;background:#fff;color:#333;border-radius:16px;padding:5px 10px;font-size:12px;cursor:pointer}
.tag-chip.global{border-color:#e6d7a8;background:#fdf9ec}
.tag-chip span{background:#f2f3f6;border-radius:9px;padding:1px 7px;font-size:11px;color:#666}
.tag-chip.global span{background:#f3e8c8;color:#8a6d1f}
@media (min-width:1024px){
  .board-kpis{grid-template-columns:repeat(4,1fr)}
  .board-grid{grid-template-columns:1.4fr 1fr}
}

/* ---------- POS 导入 ---------- */
.btn-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
#imp-text{width:100%;font-family:ui-monospace,Menlo,monospace;font-size:12px;border:1px solid #e3e5ea;border-radius:10px;padding:10px;resize:vertical}
.imp-sum{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;padding:12px;background:#fafafa;border-radius:10px;margin-bottom:10px}
.imp-sum>div{display:flex;flex-direction:column;gap:2px}
.imp-sum span{font-size:11px;color:#8a8f99}
.imp-sum b{font-size:15px}
.imp-row{display:flex;justify-content:space-between;gap:10px;align-items:flex-start;padding:10px 12px;border-top:1px solid #f1f2f5}
.imp-line{font-size:13px;font-weight:600}
.imp-msg{font-size:12px;color:#8a8f99;margin-top:2px}
.imp-batch-num{font-size:13px;font-weight:600;white-space:nowrap}
.badge.danger{background:#fdecec;color:#c0392b}

/* ---------- 历史迁移 ---------- */
#mig-text{width:100%;font-family:ui-monospace,Menlo,monospace;font-size:12px;border:1px solid #e3e5ea;border-radius:10px;padding:10px;resize:vertical}
.imp-sum{grid-template-columns:repeat(3,1fr)}

/* ---------- 回访建议 ---------- */
.advice-card{border-color:#ece2c8;background:#fffdf6}
.advice-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:8px}
.advice-tier{background:#f3e8c8;color:#8a6d1f;border-radius:10px;padding:2px 9px;font-size:12px;font-weight:600}
.advice-points{margin:0;padding-left:18px}
.advice-points li{font-size:13px;line-height:1.65;color:#333;margin-bottom:6px}
.advice-kv{margin:6px 0 0}

/* ---------- 大模型开关 ---------- */
.switch-row{display:flex;justify-content:space-between;align-items:center;gap:12px}
.switch{width:48px;height:26px;border-radius:13px;border:1px solid #e3e5ea;background:#eceef2;position:relative;cursor:pointer;flex-shrink:0}
.switch span{position:absolute;top:2px;left:2px;width:20px;height:20px;border-radius:10px;background:#fff;transition:.18s;box-shadow:0 1px 2px rgba(0,0,0,.15)}
.switch.on{background:#c9ac64;border-color:#c9ac64}
.switch.on span{left:24px}

/* ---------- 看板下钻与迁移体检 ---------- */
.board-kpi.clickable,tr.clickable{cursor:pointer}
.board-kpi.clickable:hover{border-color:#c9ac64}
.board-kpi.danger-kpi .value{color:#c0392b}
tr.clickable:hover td{background:#faf7ef}
.check-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-bottom:12px}
.check-card{border:1px solid #eceef2;border-radius:10px;padding:10px 12px;background:#fbfbfc}
.check-card.warn{border-color:#f0dfae;background:#fdfaf0}
.check-card.danger{border-color:#f3cfcb;background:#fdf4f3}
.check-top{display:flex;justify-content:space-between;align-items:center;gap:6px}
.check-title{font-size:13px;color:#555}
.check-num{font-size:26px;font-weight:600;margin:6px 0 2px;color:#222}
.card-head-row{display:flex;justify-content:space-between;align-items:center;gap:10px}
.card-head-row h3{margin:0}
