/* ============================================================
 * 首推拓客 · 线索引擎（原型）样式
 * 零依赖、无外链字体，纯 CSS 变量设计
 * ============================================================ */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --r: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --mono: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
aside.side {
  width: 230px; flex: 0 0 230px; position: fixed; inset: 0 auto 0 0; z-index: 30;
  background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  color: #cbd5e1; display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
}
.brand b { color: #fff; font-size: 15px; display: block; line-height: 1.2; }
.brand small { color: #64748b; font-size: 11px; letter-spacing: .5px; }
nav.menu { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
nav.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; color: #cbd5e1; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; font-size: 14px; font-family: inherit;
}
nav.menu button .ic { width: 18px; text-align: center; }
nav.menu button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
nav.menu button.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #64748b; line-height: 1.7; }
.side-foot .tag { display:inline-block; background: rgba(16,185,129,.18); color:#6ee7b7; padding: 1px 8px; border-radius: 99px; font-size: 10px; margin-bottom:6px; }

main.main { flex: 1; margin-left: 230px; min-width: 0; padding: 20px 24px 60px; }

.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(241, 245, 249, .85);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 6px 0 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .sub { color: var(--ink-3); font-size: 12px; }
.topbar .sp { flex: 1; }
.topbar .compliance {
  font-size: 11px; color: #047857; background: #ecfdf5; border: 1px solid #a7f3d0;
  padding: 4px 10px; border-radius: 99px; white-space: nowrap;
}

/* ---------- 组件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); padding: 7px 13px; border-radius: 10px;
  cursor: pointer; font-size: 13px; font-family: inherit; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #c7d2fe; color: var(--brand); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; background: #f1f5f9; color: var(--ink-2);
  padding: 1px 9px; border-radius: 99px; font-size: 12px; border: 1px solid transparent;
}
.chip.blue { background: #eef2ff; color: #4338ca; }
.chip.green { background: #ecfdf5; color: #047857; }
.chip.orange { background: #fffbeb; color: #b45309; }
.chip.red { background: #fef2f2; color: #b91c1c; }
.chip.gray { background: #f1f5f9; color: #475569; }

.badge-score {
  min-width: 52px; text-align: center; display: inline-block; border-radius: 8px;
  padding: 2px 8px; font-weight: 700; font-family: var(--mono); color: #fff; font-size: 13px;
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card .card-h {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px 0;
  font-weight: 600; font-size: 14px;
}
.card .card-h .sp { flex: 1; }
.card .card-b { padding: 14px 16px 16px; }

.empty { text-align: center; color: var(--ink-3); padding: 40px 10px; }
.empty .big { font-size: 30px; margin-bottom: 8px; }

/* ---------- 仪表盘 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k { color: var(--ink-3); font-size: 12px; display: flex; justify-content: space-between; }
.kpi .k .ic { opacity: .7; }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.kpi .d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid2b { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 1080px) { .grid2, .grid2b { grid-template-columns: 1fr; } }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel .row { display: grid; grid-template-columns: 74px 1fr 52px; align-items: center; gap: 8px; font-size: 12px; }
.funnel .row .lb { color: var(--ink-2); white-space: nowrap; }
.funnel .track { height: 16px; background: #f1f5f9; border-radius: 99px; overflow: hidden; position: relative; }
.funnel .track i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; transition: width .4s; }
.funnel .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bars .row { display: grid; grid-template-columns: 92px 1fr 34px; gap: 8px; align-items: center; font-size: 12px; }
.bars .track { height: 14px; background: #f1f5f9; border-radius: 99px; overflow: hidden; }
.bars .track i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bars .n { text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.trend { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.trend .bar { width: 70%; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, var(--brand-2), var(--brand)); min-height: 2px; transition: height .3s; }
.trend .bar.hot { background: linear-gradient(180deg, #f59e0b, #f97316); }
.trend .lbl { font-size: 10px; color: var(--ink-3); transform: rotate(-30deg); white-space: nowrap; }
.trend-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.trend-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- 表格 / 线索池 ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { position: relative; }
.toolbar .search input {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 8px 30px;
  width: 240px; font-size: 13px; font-family: inherit; background: var(--card); outline: none;
}
.toolbar .search input:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.toolbar .search::before { content: '🔍'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .7; }
select.sel, input.inp, textarea.ta {
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 13px;
  font-family: inherit; background: var(--card); color: var(--ink); outline: none;
}
select.sel:focus, input.inp:focus, textarea.ta:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.tbl th {
  text-align: left; color: var(--ink-3); font-weight: 600; font-size: 12px;
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc;
}
.tbl td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tr:hover td { background: #f8fafc; }
.tbl tr.dim td { opacity: .62; }
.tbl .c-main { font-weight: 600; }
.tbl .c-sub { color: var(--ink-3); font-size: 12px; }
.tbl .intent { max-width: 320px; }
.tbl .intent p { margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cell-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.dot-s { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- 看板 ---------- */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(218px, 1fr)); gap: 12px; align-items: start; }
.kcol { background: #e9edf3; border-radius: 12px; padding: 8px; min-height: 200px; }
.kcol h3 { font-size: 12px; margin: 4px 4px 8px; display: flex; align-items: center; gap: 6px; }
.kcol h3 .n { background: #fff; border-radius: 99px; padding: 0 8px; font-size: 11px; color: var(--ink-2); }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
  margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: .15s;
}
.kcard:hover { border-color: #a5b4fc; box-shadow: var(--shadow); }
.kcard .top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.kcard .nm { font-weight: 600; font-size: 13px; }
.kcard .kw { font-size: 11px; color: var(--brand); }
.kcard .int { font-size: 12px; color: var(--ink-2); margin: 5px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard .meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 11px; color: var(--ink-3); }
.kcard .act { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- 抽屉 / 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 60;
  display: grid; place-items: center; padding: 24px;
}
.mask.drawer-mode { justify-items: end; padding: 0; }
.drawer {
  background: #fff; width: min(560px, 96vw); height: 100vh; overflow: auto;
  box-shadow: -12px 0 32px rgba(15,23,42,.18); display: flex; flex-direction: column;
}
.drawer .dr-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; }
.drawer .dr-h h2 { margin: 0; font-size: 17px; }
.drawer .dr-b { padding: 16px 20px 40px; flex: 1; }
.modal {
  background: #fff; border-radius: 16px; width: min(560px, 94vw); max-height: 88vh; overflow: auto;
  padding: 18px 20px 20px; box-shadow: 0 24px 60px rgba(15,23,42,.25);
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { color: var(--ink-3); font-size: 12px; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.field .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input.inp, textarea.ta, select.sel { width: 100%; }
textarea.ta { resize: vertical; min-height: 74px; }
.m-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.fieldline { display: grid; grid-template-columns: 104px 1fr; gap: 8px; font-size: 13px; padding: 7px 0; border-bottom: 1px dashed #eef2f7; }
.fieldline .lb { color: var(--ink-3); }
.reasons { font-size: 12px; color: var(--ink-2); background: #f8fafc; border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.events { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; }
.events li { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); margin-left: 6px; position: relative; }
.events li::before { content: ''; position: absolute; left: -5.5px; top: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.events .t { color: var(--ink-3); font-size: 11px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(15,23,42,.25); max-width: 340px; animation: pop .18s ease;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 设置 / 导入 ---------- */
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1080px) { .set-grid { grid-template-columns: 1fr; } }
.weight-row { display: grid; grid-template-columns: 160px 1fr 52px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.kg-list .row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed #eef2f7; }
.import-zone {
  border: 2px dashed #c7d2fe; border-radius: 14px; padding: 26px; text-align: center;
  color: var(--ink-2); cursor: pointer; transition: .15s; background: #fbfcff;
}
.import-zone:hover, .import-zone.drag { border-color: var(--brand); background: var(--brand-soft); }
.import-zone .big { font-size: 26px; }
code { background: #f1f5f9; border-radius: 6px; padding: 1px 6px; font-family: var(--mono); font-size: 12px; }
.demo-note {
  margin: 10px 0 16px; font-size: 12px; color: #92400e; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 10px; padding: 8px 12px;
}
.sig-editor textarea { font-family: var(--mono); font-size: 12px; min-height: 90px; }

/* ---------- 登录 / 权限 ---------- */
.admin-only { display: none; }
.user-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2);
  white-space: nowrap;
}
.user-chip b { font-weight: 600; color: var(--ink); }
.role-tag {
  font-size: 11px; padding: 1px 8px; border-radius: 99px; font-weight: 600;
}
.role-admin { background: #eef2ff; color: #4338ca; }
.role-sales { background: #ecfdf5; color: #047857; }
.role-viewer { background: #f1f5f9; color: #64748b; }
body.is-viewer #btnAddLead { display: none; }

.loading-cover {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--ink-3); font-size: 14px;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #e2e8f0; border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  aside.side { width: 62px; flex-basis: 62px; padding: 12px 8px; }
  aside.side .brand b, aside.side .brand small, aside.side nav.menu button span.txt, aside.side .side-foot { display: none; }
  nav.menu button { justify-content: center; padding: 10px; }
  main.main { margin-left: 62px; padding: 14px 12px 50px; }
  .topbar .compliance { display: none; }
}
