:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e8eaee;
  --line-strong: #dcdfe6;
  --text: #1b1f27;
  --text-2: #5b6472;
  --text-3: #8b93a1;
  --brand: #2f5cf0;
  --brand-weak: #eef2ff;
  --high: #e0403f;
  --high-weak: #fdeeee;
  --mid: #d98510;
  --mid-weak: #fdf5e6;
  --none: #8b93a1;
  --none-weak: #f1f2f5;
  --ok: #12805c;
  --ok-weak: #e9f7f1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 26, 40, .05), 0 8px 24px -18px rgba(20, 26, 40, .25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #fbfbfc;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2f5cf0, #6a8bff);
  color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px -4px rgba(47, 92, 240, .7);
}
.brand-text strong { display: block; font-size: 13.5px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--text-3); }

.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--text-2); cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f0f1f4; color: var(--text); }
.nav-item.active {
  background: var(--brand-weak); color: var(--brand);
  font-weight: 600; border-color: #dfe6ff;
}
.nav-item svg { width: 15px; height: 15px; opacity: .9; }
.nav-badge {
  margin-left: auto; font-size: 10.5px; background: #eef0f4; color: var(--text-2);
  border-radius: 20px; padding: 1px 6px; font-weight: 600;
}
.nav-item.active .nav-badge { background: #dfe6ff; color: var(--brand); }

.sidebar-foot {
  margin-top: auto; padding: 12px 16px 16px;
  font-size: 11px; color: var(--text-3); line-height: 1.7;
  border-top: 1px solid var(--line);
}
.sidebar-foot b { color: var(--text-2); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.topbar .crumb { color: var(--text-3); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.content { padding: 20px 22px 40px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
.card-head .sub { color: var(--text-3); font-size: 11.5px; }
.card-body { padding: 16px; }

.btn {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; font-weight: 550; line-height: 1.5;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { background: #f7f8fa; border-color: #cdd2db; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #2849cc; border-color: #2849cc; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f0f1f4; color: var(--text); }
.btn-danger { color: var(--high); border-color: #f1d3d3; }
.btn-danger:hover { background: var(--high-weak); }
.btn-sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.field .hint { font-size: 11px; color: var(--text-3); font-weight: 400; line-height: 1.6; }
.input, .select, .textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 92, 240, .1);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.65; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-high { background: var(--high-weak); color: var(--high); }
.pill-mid { background: var(--mid-weak); color: var(--mid); }
.pill-none { background: var(--none-weak); color: var(--none); }
.pill-run { background: var(--brand-weak); color: var(--brand); }
.pill-ok { background: var(--ok-weak); color: var(--ok); }
.pill-gray { background: #f1f2f5; color: var(--text-2); }
.pill-warn { background: var(--mid-weak); color: var(--mid); }
.pill-err { background: var(--high-weak); color: var(--high); }

.muted { color: var(--text-3); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 62px; height: 62px; border-radius: 50%; background: #f4f6fb;
}
.kpi .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; margin-top: 6px; line-height: 1.1; }
.kpi .foot { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
.kpi.accent-high .value { color: var(--high); }
.kpi.accent-brand .value { color: var(--brand); }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; margin-top: 12px; }

/* ---------- 图表 ---------- */
.bar-row { display: grid; grid-template-columns: 76px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 11px; }
.bar-row .name { font-size: 12px; color: var(--text-2); }
.bar-track { height: 8px; background: #f0f1f5; border-radius: 6px; position: relative; overflow: hidden; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #c9d5f8; border-radius: 6px; transition: width .5s; }
.bar-fill.h { background: var(--high); z-index: 1; }
.bar-row .num { font-size: 12px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }

.trend { display: flex; align-items: flex-end; gap: 10px; height: 132px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.trend-bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #a9beff, #dbe4ff); border-radius: 4px 4px 2px 2px; position: relative; min-height: 3px; }
.trend-bar i { position: absolute; bottom: 0; left: 0; right: 0; background: var(--high); border-radius: 4px 4px 2px 2px; }
.trend-x { font-size: 10.5px; color: var(--text-3); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc;
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f2f3f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfcfe; }
.table .num { font-variant-numeric: tabular-nums; }

.progress { height: 5px; background: #eef0f4; border-radius: 4px; overflow: hidden; margin-top: 5px; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .4s; }

.empty {
  padding: 46px 16px; text-align: center; color: var(--text-3); font-size: 12.5px;
  line-height: 1.9;
}
.empty b { display: block; color: var(--text-2); font-size: 13px; margin-bottom: 2px; }

/* ---------- 线索 ---------- */
.filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fcfcfd;
}
.filters .input, .filters .select { width: auto; min-width: 120px; padding: 5px 9px; font-size: 12.5px; }
.filters .grow { flex: 1; min-width: 180px; }
.filters .spacer { margin-left: auto; }

.lead {
  display: grid; grid-template-columns: 3px 1fr; gap: 0;
  border-bottom: 1px solid #f1f3f6; position: relative;
}
.lead:last-child { border-bottom: none; }
.lead:hover { background: #fcfdff; }
.lead .stripe { background: var(--none); width: 4px; }
.lead.high .stripe { background: var(--high); }
.lead.mid .stripe { background: var(--mid); }
.lead-main { padding: 12px 16px 12px 14px; }
.lead-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
.lead-text { font-size: 13.5px; line-height: 1.65; color: var(--text); }
.lead-meta { display: flex; align-items: center; gap: 12px; margin-top: 7px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.lead-meta .link { color: var(--brand); }
.lead-reason {
  margin-top: 9px; font-size: 12px; color: var(--text-2); line-height: 1.7;
  background: #f8f9fc; border: 1px solid #eef0f5; border-radius: 7px; padding: 8px 10px;
}
.lead-script {
  margin-top: 8px; font-size: 12.5px; line-height: 1.75; color: #34405a;
  background: var(--brand-weak); border: 1px solid #e0e7ff; border-radius: 7px; padding: 9px 11px;
  position: relative; padding-right: 76px;
}
.lead-actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; align-items: center; }
.lead .copy {
  position: absolute; right: 8px; top: 8px;
}
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: #f3f4f7; color: var(--text-2); border: 1px solid #e9ebf0;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 20, 30, .38);
  display: none; place-items: center; z-index: 100; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-mask.open { display: grid; }
.modal {
  background: #fff; border-radius: 12px; width: 640px; max-width: 100%;
  max-height: calc(100vh - 60px); display: flex; flex-direction: column;
  box-shadow: 0 24px 60px -20px rgba(10, 16, 30, .45);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(6px) scale(.99); opacity: .6; } }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.modal-head .close { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; padding: 2px 4px; }
.modal-head .close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 20px;
  cursor: pointer; font-size: 12.5px; color: var(--text-2); background: #fff; transition: all .14s;
  user-select: none;
}
.chip:hover { border-color: #c3cad6; }
.chip.on { background: var(--brand-weak); border-color: #c9d6ff; color: var(--brand); font-weight: 600; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- 提示 ---------- */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #1b2230; color: #fff; padding: 9px 14px; border-radius: 8px;
  font-size: 12.5px; box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .4);
  animation: fadein .18s;
  max-width: 360px; line-height: 1.6;
}
.toast.err { background: #b7262b; }
.toast.ok { background: #10674a; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }

.notice {
  display: flex; gap: 9px; align-items: flex-start;
  background: #fbfdff; border: 1px solid #e3ecfb; border-radius: 9px;
  padding: 10px 13px; font-size: 12px; color: #43536e; line-height: 1.75;
}
.notice svg { flex: 0 0 auto; margin-top: 2px; color: var(--brand); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch i {
  width: 34px; height: 19px; border-radius: 20px; background: #d7dbe3; position: relative; transition: background .18s;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch.on i { background: var(--brand); }
.switch.on i::after { transform: translateX(15px); }

.section-title { font-size: 12px; font-weight: 700; color: var(--text-2); letter-spacing: .3px; margin: 2px 0 -2px; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 14px; }
}
