/* ============================================================
   关澜ERP v2 · CRM 客户资源管理 专属样式（第 26 轮）

   基底色板完全沿用 style.css 的设计系统（#FAFAFA / #FFF / #3B82F6 …），
   本文件只承载 CRM 专属组件：资源池 / 客户360 / 商机看板 / 漏斗 / 时间线。
   ============================================================ */

/* ---------- 客户360：页头高亮区 ---------- */
.crm-highlight {
  background: linear-gradient(135deg, #F7F9FF 0%, #FFFFFF 60%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 18px; margin-bottom: 14px;
}
.crm-hl-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.crm-hl-item { min-width: 0; }
.crm-hl-label { font-size: 11px; color: var(--sub); margin-bottom: 4px; }
.crm-hl-value { font-size: 13.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 客户360：主体 + 侧栏 ---------- */
.crm-detail-grid { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 16px; align-items: start; }
.crm-side-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.crm-side-card + .crm-side-card { margin-top: 12px; }
.crm-side-head { padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.crm-side-body { padding: 13px 14px; }

/* 下一步待办（侧栏最上方） */
.crm-next-action { background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFF 100%);
  border: 1px solid #BFDBFE; border-radius: 7px; padding: 11px 12px; }
.crm-next-action.overdue { background: linear-gradient(135deg, #FEF2F2 0%, #FFF7F7 100%);
  border-color: #FECACA; }
.crm-next-label { font-size: 11px; color: var(--primary-d); font-weight: 700;
  margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.crm-next-action.overdue .crm-next-label { color: var(--danger); }
.crm-next-text { font-size: 12.5px; color: var(--text); line-height: 1.5; margin-bottom: 9px; }

/* ---------- 时间线 ---------- */
.crm-timeline { position: relative; padding-left: 22px; }
.crm-timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line); }
.crm-tl-item { position: relative; padding: 0 0 17px; }
.crm-tl-item:last-child { padding-bottom: 0; }
.crm-tl-dot { position: absolute; left: -20px; top: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.crm-tl-dot.ok { border-color: var(--ok); }
.crm-tl-dot.warn { border-color: var(--warn); }
.crm-tl-dot.gray { border-color: var(--line); }
.crm-tl-dot.invalid { border-color: var(--danger); }
.crm-tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-tl-who { font-size: 12.5px; font-weight: 600; }
.crm-tl-ch { font-size: 11px; background: #F4F4F5; color: var(--muted);
  border-radius: 9px; padding: 0 7px; }
.crm-tl-time { font-size: 11px; color: var(--sub); margin-left: auto;
  font-variant-numeric: tabular-nums; }
.crm-tl-body { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.crm-tl-next { font-size: 11.5px; color: var(--warn); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.crm-tl-invalid { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* ---------- 字段分组（详情 Tab） ---------- */
.crm-field-group { margin-bottom: 18px; }
.crm-field-group:last-child { margin-bottom: 0; }
.crm-field-title { font-size: 12px; font-weight: 700; color: var(--muted);
  margin-bottom: 9px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.crm-field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.crm-field-item { min-width: 0; }
.crm-field-label { font-size: 11px; color: var(--sub); margin-bottom: 3px; }
.crm-field-value { font-size: 12.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-field-value.muted { color: var(--sub); }

/* ---------- 公私海总览卡 ---------- */
.crm-pool-card { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; }
.crm-pool-card.public { border-left: 3px solid var(--warn); }
.crm-pool-card.private { border-left: 3px solid var(--primary); }
.crm-pool-card.protected { border-left: 3px solid var(--purple); }
.crm-pool-name { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.crm-pool-meta { display: flex; align-items: center; gap: 12px; margin-top: 8px;
  font-size: 11.5px; color: var(--sub); flex-wrap: wrap; }
.crm-pool-meta b { color: var(--text); font-weight: 600; }

/* ---------- 商机看板（Board） ---------- */
.crm-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.crm-board-col { width: 234px; min-width: 234px; background: #F4F4F5;
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 320px); }
.crm-board-col.drop-hint { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }
.crm-board-col-head { padding: 11px 13px 9px; border-bottom: 1px solid #E4E4E7; }
.crm-board-col-top { display: flex; align-items: center; gap: 7px; }
.crm-board-col-name { font-size: 12.5px; font-weight: 700; }
.crm-board-col-count { font-size: 11px; background: #fff; color: var(--muted);
  border-radius: 9px; padding: 0 7px; font-weight: 600; }
.crm-board-col-sum { font-size: 11.5px; color: var(--muted); margin-top: 5px;
  display: flex; justify-content: space-between; }
.crm-board-col-sum b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.crm-board-col-body { padding: 9px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }

.crm-opp-card { background: #fff; border: 1px solid var(--line); border-radius: 7px;
  padding: 10px 11px; cursor: grab; transition: box-shadow .15s, border-color .15s; }
.crm-opp-card:hover { box-shadow: 0 3px 12px rgba(10,10,11,.09); border-color: #D4D4D8; }
.crm-opp-card.dragging { opacity: .45; cursor: grabbing; }
.crm-opp-title { font-size: 12.5px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; }
.crm-opp-cust { font-size: 11.5px; color: var(--primary); margin-bottom: 7px;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-opp-amt { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.crm-opp-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px;
  padding-top: 8px; border-top: 1px dashed var(--line-soft); }
.crm-opp-owner { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.crm-opp-avatar { width: 17px; height: 17px; border-radius: 50%; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 600; }
.crm-opp-aging { margin-left: auto; font-size: 10.5px; }
.crm-opp-aging.warn { color: var(--warn); }
.crm-opp-aging.danger { color: var(--danger); font-weight: 600; }

/* ---------- 漏斗图 ---------- */
.crm-funnel { display: flex; flex-direction: column; gap: 3px; }
.crm-funnel-row { display: flex; align-items: center; gap: 12px; }
.crm-funnel-name { width: 76px; font-size: 12px; color: var(--muted);
  flex: none; text-align: right; }
.crm-funnel-bar-wrap { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.crm-funnel-bar { height: 30px; border-radius: 4px; display: flex; align-items: center;
  padding-left: 10px; color: #fff; font-size: 12.5px; font-weight: 600; min-width: 42px; }
.crm-funnel-meta { font-size: 11.5px; color: var(--sub); white-space: nowrap; }
.crm-funnel-meta b { color: var(--text); font-weight: 600; }
.crm-funnel-rate { width: 78px; text-align: right; font-size: 11.5px; flex: none; }
.crm-funnel-rate .up { color: var(--ok); font-weight: 600; }
.crm-funnel-rate .down { color: var(--danger); font-weight: 600; }

/* ---------- 渠道 ROI 卡 ---------- */
.crm-roi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.crm-roi-card { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px; }
.crm-roi-name { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.crm-roi-value { font-size: 21px; font-weight: 700; margin: 6px 0 3px; letter-spacing: -.4px; }
.crm-roi-sub { font-size: 11px; color: var(--sub); }
.crm-roi-bar { height: 5px; border-radius: 3px; background: #F4F4F5; margin-top: 9px; overflow: hidden; }
.crm-roi-bar > i { display: block; height: 100%; border-radius: 3px; }

/* ---------- 流转记录 ---------- */
.crm-flow-log { display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px dashed var(--line-soft); font-size: 12.5px; }
.crm-flow-log:last-child { border-bottom: none; }
.crm-flow-act { font-size: 11px; border-radius: 9px; padding: 1px 8px; font-weight: 600; flex: none; }
.crm-flow-act.claim { background: var(--primary-soft); color: var(--primary-d); }
.crm-flow-act.assign { background: var(--purple-soft); color: #6D28D9; }
.crm-flow-act.transfer { background: var(--purple-soft); color: #6D28D9; }
.crm-flow-act.return { background: var(--danger-soft); color: #B91C1C; }
.crm-flow-act.protect { background: var(--ok-soft); color: #047857; }
.crm-flow-act.unprotect { background: #F4F4F5; color: #52525B; }
.crm-flow-desc { flex: 1; color: var(--muted); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-flow-time { font-size: 11px; color: var(--sub); flex: none; font-variant-numeric: tabular-nums; }

/* ---------- 超期红榜 ---------- */
.crm-red-row { display: flex; align-items: center; gap: 9px; padding: 7px 0;
  border-bottom: 1px dashed var(--line-soft); font-size: 12.5px; }
.crm-red-row:last-child { border-bottom: none; }
.crm-red-name { color: var(--text); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.crm-red-name:hover { color: var(--primary); }
.crm-red-days { color: var(--danger); font-size: 11.5px; flex: none; font-weight: 600; }

/* ---------- 工作台：今日待办 ---------- */
.crm-todo { display: flex; align-items: center; gap: 9px; padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.crm-todo:last-child { border-bottom: none; }
.crm-todo-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.crm-todo-name { font-weight: 500; flex: none; cursor: pointer; }
.crm-todo-name:hover { color: var(--primary); }
.crm-todo-desc { color: var(--sub); font-size: 11.5px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 分布条（保有量 / 渠道） ---------- */
.crm-dist-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.crm-dist-label { width: 72px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.crm-dist-track { flex: 1; height: 10px; background: #F4F4F5; border-radius: 5px; overflow: hidden; }
/* 必须 display:block —— <i> 是 inline 元素，宽高不生效，条会完全不显示 */
.crm-dist-fill { display: block; height: 100%; border-radius: 5px; background: var(--primary); }
.crm-dist-fill.ok { background: var(--ok); }
.crm-dist-fill.warn { background: var(--warn); }
.crm-dist-fill.danger { background: var(--danger); }
.crm-dist-val { width: 46px; text-align: right; font-weight: 600; font-size: 12.5px;
  font-variant-numeric: tabular-nums; }

/* ---------- 空状态引导 ---------- */
.crm-empty { text-align: center; padding: 38px 20px; }
.crm-empty-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-soft);
  color: var(--primary); display: inline-flex; align-items: center; justify-content: center;
  font-size: 23px; margin-bottom: 12px; }
.crm-empty-title { font-size: 14px; font-weight: 700; margin-bottom: 5px; }
.crm-empty-desc { font-size: 12.5px; color: var(--muted); max-width: 380px;
  margin: 0 auto 14px; line-height: 1.6; }

/* ---------- 视图切换（列表/看板） ---------- */
.crm-view-switch { display: inline-flex; border: 1px solid var(--line);
  border-radius: var(--radius-btn); overflow: hidden; background: #fff; }
.crm-view-switch button { padding: 6px 13px; border: none; background: #fff; cursor: pointer;
  font-size: 12.5px; font-family: inherit; color: var(--muted); }
.crm-view-switch button.active { background: var(--primary); color: #fff; font-weight: 500; }

/* ---------- 公海行底色（区分归属） ---------- */
tr.crm-row-public td { background: #FFFBEB; }
tr.crm-row-public:hover td { background: #FEF3C7; }
tr.crm-row-protected td { background: #F5F3FF; }
tr.crm-row-protected:hover td { background: #EDE9FE; }

/* ---------- 拖拽提示条 ---------- */
.crm-drag-tip { font-size: 11.5px; color: var(--muted); background: var(--warn-soft);
  border: 1px solid #FDE68A; border-radius: var(--radius-btn); padding: 7px 11px;
  margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }

/* ---------- 看板/列 的移动端与窄屏 ---------- */
@media (max-width: 1200px) {
  .crm-hl-grid { grid-template-columns: repeat(3, 1fr); }
  .crm-roi-grid { grid-template-columns: repeat(3, 1fr); }
  .crm-field-grid { grid-template-columns: repeat(2, 1fr); }
  .crm-detail-grid { grid-template-columns: 1fr; }
}
