:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d5d9e0;
  --text: #1c2029;
  --text-2: #5b6270;
  --text-3: #8b93a1;
  --brand: #1d4ed8;
  --brand-soft: #e8effd;
  --accent: #0f766e;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 14px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 226px;
  flex: 0 0 226px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--line); }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.brand .sub { margin-top: 4px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.tag { display: inline-block; padding: 0 6px; height: 18px; line-height: 18px; border-radius: 4px; font-size: 11px; background: var(--warn-soft); color: var(--warn); }

.nav { padding: 10px 10px; flex: 1; overflow: auto; }
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: #f6f7f9; color: var(--text); }
.nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .glyph { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.85; }
.nav .badge {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
}
.nav .badge.zero { display: none; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.7;
}
.status-line { display: flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 500; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }
.page-head .desc { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.page-head .right { display: flex; align-items: center; gap: 8px; }

/* ---------- 卡片 / 通用 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--text-3); }
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side { grid-template-columns: 1fr; }
}

.stat { padding: 15px 16px; }
.stat .label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; justify-content: space-between; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.4px; margin: 6px 0 2px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.stat .foot { font-size: 12px; color: var(--text-3); }
.stat.tone-warn .value { color: var(--warn); }
.stat.tone-ok .value { color: var(--ok); }
.stat.tone-brand .value { color: var(--brand); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: #b9c0cb; background: #fafbfc; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0d6a62; }
.btn.primary:disabled { background: #cfd8d6; border-color: #cfd8d6; opacity: 1; }
.btn.ghost { border-style: dashed; color: var(--text-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.warn { background: var(--warn-soft); border-color: #f0d5ab; color: var(--warn); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11.5px;
  background: #f1f3f6;
  color: var(--text-2);
  line-height: 19px;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.blue { background: #eaf0fd; color: #1d4ed8; }

.muted { color: var(--text-3); }
.mono { font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* ---------- 列表 ---------- */
.msg-list { display: flex; flex-direction: column; }
.msg { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.msg:last-child { border-bottom: 0; }
.msg-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-author { font-weight: 600; }
.msg-time { margin-left: auto; font-size: 12px; color: var(--text-3); }
.msg-content { margin: 7px 0 9px; color: #333944; }
.msg-context { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.draft {
  background: #f7f9fa;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13px;
  color: #39414f;
  white-space: pre-wrap;
}
.draft.sens { border-left-color: var(--warn); background: var(--warn-soft); color: #6b4a10; }
.msg-actions { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.msg-actions .spacer { flex: 1; }
.replied-text { font-size: 13px; color: var(--text-2); background: #fafbfc; border-radius: 7px; padding: 8px 11px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; background: #eceef2; border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch .track { width: 38px; height: 21px; border-radius: 11px; background: #cfd4dc; position: relative; transition: background .18s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .18s; }
.switch.on .track { background: var(--brand); }
.switch.on .thumb { transform: translateX(17px); }

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 12.8px;
  background: var(--warn-soft);
  color: #6b4a10;
  border: 1px solid #f2ddb8;
  line-height: 1.65;
}
.notice.info { background: #eef4ff; border-color: #d6e2fb; color: #23407c; }
.notice b { color: inherit; }

.todo { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.todo:last-child { border-bottom: 0; }
.todo .box { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; border-radius: 5px; border: 1.5px solid var(--line-strong); background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
.todo.done .box { background: var(--brand); border-color: var(--brand); }
.todo.done .todo-label { color: var(--text-3); text-decoration: line-through; }
.todo-label { font-weight: 500; }
.todo-hint { font-size: 12px; color: var(--text-3); }

.progress { height: 6px; border-radius: 3px; background: #eef0f3; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .25s; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px; padding: 9px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fcfcfd; }

.empty { padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(18, 22, 30, 0.38); display: none; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.modal-mask.show { display: flex; }
.modal { background: #fff; width: 520px; max-width: 100%; border-radius: 12px; box-shadow: 0 20px 60px rgba(16,24,40,.2); overflow: hidden; }
.modal h4 { margin: 0; padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.modal .body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal .foot { padding: 13px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfc; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"], input[type="time"], select, textarea {
  padding: 8px 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 var(--brand-soft); }
textarea { resize: vertical; min-height: 78px; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  background: #1f2937;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(16,24,40,.2);
  max-width: 70vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }


/* ---------- LeadHub 专属 ---------- */
.sidebar { background: #fbfcfe; }
.brand h1 { font-size: 17px; }
.brand .avatar { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; letter-spacing: 0; }
.brand .userline { margin-top: 8px; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.role-tag { padding: 0 6px; height: 17px; line-height: 17px; border-radius: 4px; font-size: 11px; background: var(--brand-soft); color: var(--brand); }
.logout { margin-left: auto; color: var(--text-3); cursor: pointer; background: none; border: 0; padding: 0; font-size: 12px; }
.logout:hover { color: var(--danger); }

.nav .badge { background: #e8effd; color: var(--brand); }

.kpi-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1200px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12.5px; color: var(--text-3); }
.kpi .k-value { font-size: 24px; font-weight: 650; letter-spacing: -0.3px; margin-top: 4px; }
.kpi .k-value small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.kpi.hl { border-color: #c9d9fb; background: linear-gradient(180deg, #f7faff, #fff); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 62px 1fr 42px; align-items: center; gap: 9px; font-size: 12.5px; }
.bar-track { height: 9px; border-radius: 5px; background: #eef1f6; overflow: hidden; }
.bar-track > i { display: block; height: 100%; border-radius: 5px; background: var(--brand); }
.bar-row .num { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

table.data tr.sel td { background: #f3f7ff; }
table.data td.tight { padding-top: 8px; padding-bottom: 8px; }
table.data td.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.row-check { width: 15px; height: 15px; }
.lead-nick { font-weight: 600; }
.lead-cmt { color: var(--text-2); font-size: 12.8px; max-width: 420px; }
.tag-intent { display: inline-block; padding: 0 6px; height: 18px; line-height: 18px; border-radius: 4px; font-size: 11px; }
.tag-intent.i-高 { background: var(--danger-soft); color: var(--danger); }
.tag-intent.i-中 { background: var(--warn-soft); color: var(--warn); }
.tag-intent.i-低 { background: #f1f3f6; color: var(--text-3); }
.status-dot { display: inline-flex; align-items: center; gap: 5px; }
.status-dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.status-dot.s-待分配 i { background: #94a3b8; }
.status-dot.s-待触达 i { background: var(--warn); }
.status-dot.s-已触达 i { background: var(--brand); }
.status-dot.s-已加微 i { background: var(--ok); }
.status-dot.s-无效 i { background: #c3c8d1; }

.touch-panel { position: sticky; top: 16px; }
.tpl-list { display: flex; flex-direction: column; gap: 7px; max-height: 220px; overflow: auto; }
.tpl { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; cursor: pointer; background: #fff; font-size: 12.8px; line-height: 1.6; }
.tpl:hover { border-color: #b9cbf3; }
.tpl.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl b { display: block; font-size: 13px; margin-bottom: 2px; }
.tpl span { color: var(--text-3); }

.quota { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.quota b { color: var(--text); font-variant-numeric: tabular-nums; }
.hit-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.code { background: #0f172a; color: #dbe4f0; border-radius: 8px; padding: 12px 14px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; line-height: 1.7; overflow: auto; white-space: pre; }
.code .k { color: #7dd3fc; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13px; }
.kv .k { color: var(--text-3); }
