:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e4e8f0;
  --text: #1b2331;
  --text-2: #5c6878;
  --text-3: #8b96a8;
  --primary: #0a84ff;
  --primary-dark: #0069d9;
  --primary-soft: #e8f2ff;
  --danger: #e5484d;
  --warn: #f5a623;
  --success: #17a673;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* ===== 顶栏 ===== */
.top {
  height: 60px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 50;
}
.logo {
  width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #0a84ff, #6fb6ff);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.top h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.top .sub { color: var(--text-3); font-size: 12px; margin-left: 2px; }
.top .grow { flex: 1; }
.chip {
  background: var(--primary-soft); color: var(--primary-dark); border-radius: 999px;
  padding: 4px 12px; font-size: 12.5px; font-weight: 600;
}
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 9px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { border-color: #c9d3e3; background: #fafcff; }
.btn.p { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.p:hover { background: var(--primary-dark); }
.btn.d { color: var(--danger); border-color: #f2c9c9; }
.btn.d:hover { background: #fff5f5; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ===== 布局 ===== */
.layout { display: flex; min-height: calc(100vh - 60px); }
.side {
  width: 190px; flex: 0 0 190px; background: #fff; border-right: 1px solid var(--line); padding: 14px 10px;
}
.side .nav-i {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 9px;
  color: var(--text-2); cursor: pointer; font-size: 13.5px; margin-bottom: 3px; user-select: none;
}
.side .nav-i:hover { background: #f5f8fd; color: var(--text); }
.side .nav-i.on { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.side .nav-i .em { font-size: 15px; width: 18px; text-align: center; }
.side .nav-i .cnt {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; border-radius: 999px;
  padding: 0 6px; min-width: 18px; text-align: center; line-height: 17px;
}
.side .nav-title { font-size: 11.5px; color: var(--text-3); padding: 12px 12px 6px; letter-spacing: .5px; }
.main { flex: 1; padding: 18px 22px 40px; min-width: 0; }

/* ===== 卡片 ===== */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-b { padding: 16px; }
.muted { color: var(--text-3); font-size: 12.5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.col { flex: 1; min-width: 160px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12.5px; color: var(--text-3); }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.25; margin-top: 2px; letter-spacing: -.5px; }
.kpi .v small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.kpi .d { font-size: 12px; color: var(--text-3); }
.kpi.warn .v { color: var(--danger); }
.kpi.ok .v { color: var(--success); }
.kpi.pri .v { color: var(--primary); }

/* 图表 */
.chart { width: 100%; height: 150px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 6px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 26px; background: linear-gradient(180deg, #6fb6ff, #0a84ff); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b span { font-size: 10.5px; color: var(--text-3); white-space: nowrap; transform: scale(.92); }
.bars .b em { font-size: 10.5px; color: var(--text-2); font-style: normal; }

/* 漏斗 */
.funnel { display: flex; flex-direction: column; gap: 7px; }
.fn-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.fn-row .n { width: 62px; color: var(--text-2); flex: 0 0 62px; }
.fn-row .bar { flex: 1; height: 22px; background: #f1f4f9; border-radius: 6px; overflow: hidden; }
.fn-row .bar i { display: block; height: 100%; border-radius: 6px; transition: width .4s; }
.fn-row .num { width: 46px; text-align: right; font-weight: 600; flex: 0 0 46px; }
.fn-row .pct { width: 48px; text-align: right; color: var(--text-3); font-size: 12px; flex: 0 0 48px; }

/* 表格 */
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px;
  padding: 10px 10px; border-bottom: 1px solid var(--line); background: #fbfcfe; white-space: nowrap;
}
table.tb td { padding: 10px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
table.tb tr:hover td { background: #fafcff; }
table.tb .nm { font-weight: 600; }
table.tb .sub { color: var(--text-3); font-size: 11.5px; }
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #fff; white-space: nowrap;
}
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; background: #f1f4f9; color: var(--text-2);
  font-size: 11.5px; margin: 2px 4px 2px 0;
}
.score { font-weight: 700; }
.score.hi { color: var(--success); }
.score.mid { color: var(--warn); }
.score.lo { color: var(--text-3); }
.ops { display: flex; gap: 6px; white-space: nowrap; }
.link { color: var(--primary); cursor: pointer; font-size: 12.5px; }
.link.d { color: var(--danger); }
.link:hover { text-decoration: underline; }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.input, select.input, textarea.input {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-size: 13px;
  background: #fff; outline: none; font-family: inherit; color: var(--text);
}
.input:focus { border-color: #9ccaff; box-shadow: 0 0 0 3px rgba(10, 132, 255, .1); }
.grow { flex: 1; }

/* 空状态 */
.empty { text-align: center; padding: 42px 10px; color: var(--text-3); font-size: 13px; }
.empty .em { font-size: 30px; display: block; margin-bottom: 8px; opacity: .7; }

/* 弹窗 */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 620px; max-height: 88vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .22);
}
.modal.wide { max-width: 860px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 15.5px; }
.modal-h .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.field .input { width: 100%; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* toast */
.toast-wrap { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1f2937; color: #fff; padding: 9px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25); animation: tin .2s ease;
}
.toast.ok { background: #12805c; }
.toast.err { background: #b93a3f; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 详情抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 100; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw; background: #fff; z-index: 101;
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15, 23, 42, .18);
}
.drawer-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.drawer-h h3 { margin: 0; font-size: 16px; word-break: break-all; }
.drawer-h .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 22px; line-height: 1; }
.drawer-b { flex: 1; overflow: auto; padding: 16px 20px 30px; }
.drawer-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }

/* 阶段流程 */
.flow { display: flex; gap: 4px; margin: 10px 0 16px; flex-wrap: wrap; }
.flow .st {
  flex: 1; min-width: 56px; text-align: center; font-size: 11.5px; padding: 6px 2px; border-radius: 7px;
  background: #f1f4f9; color: var(--text-3); cursor: pointer; border: 1px solid transparent;
}
.flow .st:hover { border-color: #cfe3ff; }
.flow .st.on { color: #fff; font-weight: 700; }
.flow .st.done { background: #eaf4ff; color: var(--primary-dark); }

/* 时间线 */
.tl { position: relative; padding-left: 18px; }
.tl:before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: #eef2f8; }
.tl .it { position: relative; margin-bottom: 14px; }
.tl .it:before {
  content: ''; position: absolute; left: -17px; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: #c7d3e5; border: 2px solid #fff; box-shadow: 0 0 0 1px #dde5f1;
}
.tl .it.on:before { background: var(--primary); }
.tl .it .h { font-size: 12.5px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.tl .it .c { font-size: 13px; white-space: pre-wrap; word-break: break-word; margin-top: 3px; }

/* 话术卡片 */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tpl { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.tpl .t { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.tpl .bd { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; max-height: 130px; overflow: hidden; line-height: 1.6; }
.tpl .ft { display: flex; gap: 6px; margin-top: auto; }

/* 外呼 */
.call-box { display: grid; grid-template-columns: 1fr 300px; gap: 14px; }
.call-main { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.call-main .nm { font-size: 22px; font-weight: 700; }
.call-main .tel { font-size: 30px; font-weight: 700; color: var(--primary); letter-spacing: 1px; margin: 10px 0; }
.call-main .meta { color: var(--text-3); font-size: 13px; }
.call-res { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.call-res .btn { padding: 10px; }
.call-side { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); max-height: 560px; overflow: auto; }
.call-side .it { padding: 8px 6px; border-bottom: 1px solid #f2f5fa; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.call-side .it.on { background: var(--primary-soft); border-radius: 6px; }
.call-side .it .i { color: var(--text-3); width: 18px; flex: 0 0 18px; }

/* 路线 */
.route-list .it {
  display: flex; gap: 12px; padding: 10px 6px; border-bottom: 1px solid #f2f5fa; align-items: flex-start;
}
.route-list .no {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 24px;
}

/* 响应式 */
@media (max-width: 860px) {
  .side { width: 64px; flex: 0 0 64px; padding: 10px 6px; }
  .side .nav-i { justify-content: center; padding: 11px 0; }
  .side .nav-i span.tx { display: none; }
  .side .nav-i .cnt { position: absolute; margin: 0; transform: translate(14px, -12px); }
  .side .nav-title { display: none; }
  .main { padding: 12px; }
  .call-box { grid-template-columns: 1fr; }
  .f2, .f3 { grid-template-columns: 1fr; }
  .top h1 { font-size: 14px; }
  .top .sub { display: none; }
  table.tb th:nth-child(5), table.tb td:nth-child(5),
  table.tb th:nth-child(7), table.tb td:nth-child(7) { display: none; }
}
