/* ============================================================================
   Yoosee 拓客后台 · 视觉体系
   与落地页 business.yoosee.com 同血缘：深墨 #000814 顶栏 + 品牌蓝强调。

   三条设计决策（有依据，别随手改回去）：
   1. 品牌蓝用 #2563eb 而不是落地页的 #3b82f6 —— 后者配白字只有 3.68:1，做按钮底色
      不过 WCAG AA。#3b82f6 降级为图表填充色（那里不承载文字）。
   2. 模数比 1.25（13/16/20/25/31），不是落地页的 1.333 —— 数据密集界面用小比例，
      层级才不会跳脱。所有字号取自这个比例，不手挑数字。
   3. 状态永不只靠颜色：chip/badge 一律「色点 + 文字」，色盲用户与黑白打印都能读。

   间距一律取自 4·8·12·16·24·32·48 这一档，卡片内 24 / 卡片间 16 / 区块间 32。
   ========================================================================== */

:root {
  /* —— 中性阶：承载信息密度，占版面 90% —— */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --line: #e5e9ef;
  --line-strong: #d3d9e2;
  --text: #141a24;       /* off-black，不用纯黑 */
  --text-2: #5a6472;
  --text-3: #8b95a5;

  /* —— 品牌：10% 配额，只花在主操作与当前态 —— */
  --ink: #000814;        /* 顶栏，与落地页同一深墨 */
  --brand: #2563eb;      /* 白字 5.17:1 ✓ */
  --brand-dark: #1d4ed8;
  --brand-soft: #eff4ff;
  --chart: #3b82f6;      /* 仅用于图表填充，不承载文字 */

  /* —— 语义色：状态用，均已按 4.5:1 校过 —— */
  --ok: #0f7a52;
  --ok-soft: #e8f5f0;
  --warn: #b45309;
  --warn-soft: #fdf4e7;
  --danger: #b42318;
  --danger-soft: #fdf0ef;
  --info: #2563eb;
  --info-soft: #eff4ff;

  /* —— 字号：模数比 1.25 —— */
  --fs-kicker: 11px;
  --fs-xs: 13px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 20px;
  --fs-xl: 25px;
  --fs-2xl: 31px;

  --radius: 10px;
  --radius-sm: 6px;
  /* 发丝线优先于阴影：意式做法是靠线与留白分层，不是靠投影堆叠 */
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06);

  /* —— 动效：进 ease-out、出 ease-in，且只动 transform/opacity/颜色 —— */
  --ease-out: cubic-bezier(0, 0, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --t-fast: .14s;
  --t-base: .18s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', system-ui, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* 数据界面的栅格纪律：数字等宽，列才对得齐 */
.stat-value, .bar-num, .funnel-num, .table td, .chip b { font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }

button, input { font: inherit; color: inherit; }

/* 键盘可达：每个可聚焦元素都要有可见焦点环 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   登录
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  /* 深墨到画布的极缓过渡：落地页首屏也是这个调子 */
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(37, 99, 235, .07), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 40px; height: 40px;
  flex: none;
  display: grid; place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-lg);
  font-weight: 700;
  border-radius: var(--radius);
  letter-spacing: -.02em;
}

.brand-name { font-size: var(--fs-base); font-weight: 700; letter-spacing: -.01em; }
.brand-sub  { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }

.brand.compact .brand-mark { width: 30px; height: 30px; font-size: var(--fs-sm); border-radius: 8px; }
.brand.compact .brand-name { font-size: var(--fs-sm); color: #fff; }

.field { display: block; margin-top: 24px; }
.field span {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input::placeholder { color: var(--text-3); }

.form-error {
  margin-top: 12px;
  font-size: var(--fs-xs);
  color: var(--danger);
  min-height: 18px;
}

/* ==========================================================================
   按钮 —— 全站唯一的实心品牌色块，10% 配额就花在这里
   ========================================================================== */
.btn-primary {
  height: 42px;
  padding: 0 20px;
  background: var(--brand);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-block { display: block; width: 100%; margin-top: 20px; }

.btn-ghost {
  height: 32px;
  padding: 0 12px;
  background: transparent;
  color: rgba(255, 255, 255, .82);
  font-size: var(--fs-xs);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }

/* ==========================================================================
   顶栏 —— 深墨，与落地页 topbar 同一血缘
   ========================================================================== */
.topbar {
  height: 56px;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.today-label { font-size: var(--fs-xs); color: rgba(255, 255, 255, .55); }

/* ==========================================================================
   标签页
   ========================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 56px;
  z-index: 30;
}
.tab {
  height: 44px;
  padding: 0 4px;
  margin-right: 20px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.content { padding: 32px 24px 64px; max-width: 1320px; margin: 0 auto; }

/* ==========================================================================
   卡片
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card, .panel-grid + .card, .card + .panel-grid { margin-top: 16px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.card-title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; }
.card-head .card-title { margin: 0; }
.card > .card-title { display: block; margin-bottom: 20px; }
.card-hint { font-size: var(--fs-xs); color: var(--text-3); }

/* ==========================================================================
   统计卡 —— 四个并列指标，等权重
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
/* kicker：小字大写 + 字距，编辑排版里的「栏目名」，让数字有依托 */
.stat-label {
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin-top: 8px;
}

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ==========================================================================
   渠道分布条 —— 单色深浅，不用彩虹
   ========================================================================== */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 48px; align-items: center; gap: 12px; }
.bar-label { font-size: var(--fs-xs); color: var(--text-2); }
.bar-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: var(--chart);
  border-radius: 999px;
  transition: width .45s var(--ease-out);
}
/* 渠道用同一色相的明度差区分，而不是四种不同色相 —— 后者会让看板变调色板 */
.bar-fill.whatsapp       { background: #1d4ed8; }
.bar-fill.web_chat       { background: #3b82f6; }
.bar-fill.meta_lead_form { background: #60a5fa; }
.bar-fill.web_form       { background: #93c5fd; }
.bar-fill.landing_form   { background: #bfdbfe; }
.bar-num { font-size: var(--fs-xs); font-weight: 600; text-align: right; color: var(--text-2); }

/* ==========================================================================
   状态 chips —— 色点 + 文字，绝不只靠颜色
   ========================================================================== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.chip::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}
.chip b { font-weight: 700; color: var(--text); }
.chip.new::before       { background: var(--info); }
.chip.qualified::before { background: #7c3aed; }
.chip.quoted::before    { background: var(--warn); }
.chip.won::before       { background: var(--ok); }
.chip.lost::before      { background: var(--danger); }

/* ==========================================================================
   表格 —— 发丝线分层，不用斑马纹
   ========================================================================== */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left;
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--t-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
/* ⚠️ .cell-sub 同时用在 <td>（整列次要信息）和 <div>（姓名下的公司名）上。
   千万别给它 display:block —— <td> 变成 block 会脱离表格布局模型，行高与列对齐全乱。
   <div> 本身就是块级，间距单独给 div 即可。 */
.cell-sub { font-size: var(--fs-xs); color: var(--text-3); }
div.cell-sub { margin-top: 3px; }
/* 匿名聊天线索的 AI 摘要副行：一行截断，悬停 title 看全文 */
.cell-summary { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 匿名聊天访客占位身份：次级色，与真实姓名区分 */
.anon-name { color: var(--text-2); }
/* 时间列窄一点、不换行，把宽度让给姓名与联系方式 */
.table td:first-child { white-space: nowrap; width: 1%; }

/* ==========================================================================
   徽章 —— 同样是色 + 字
   ========================================================================== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.whatsapp       { background: var(--ok-soft);    border-color: #c6e6da; color: var(--ok); }
.badge.web_chat       { background: var(--info-soft);  border-color: #cddffd; color: var(--brand); }
.badge.web_form       { background: var(--surface-2);  border-color: var(--line-strong); color: var(--text-2); }
.badge.meta_lead_form { background: #f3eefe;           border-color: #ddd0fa; color: #6d28d9; }
.badge.landing_form   { background: var(--surface-2);  border-color: var(--line-strong); color: var(--text-2); }
/* AI 归纳的意图标签：虚线边框示意「机器判的，非人工录入」 */
.badge.intent         { background: var(--surface);    border-style: dashed; border-color: var(--line-strong); color: var(--text-2); }
.badge.pending        { background: var(--warn-soft);  border-color: #f0dcc0; color: var(--warn); }
.badge.sent,
.badge.done,
.badge.won            { background: var(--ok-soft);    border-color: #c6e6da; color: var(--ok); }
.badge.cancelled,
.badge.failed,
.badge.lost           { background: var(--danger-soft); border-color: #f5cdc9; color: var(--danger); }

.empty {
  padding: 40px 0;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ==========================================================================
   漏斗
   ========================================================================== */
.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel-row { display: grid; grid-template-columns: 84px 1fr 48px; align-items: center; gap: 12px; font-size: var(--fs-xs); }
.funnel-track { height: 26px; background: var(--bg); border-radius: var(--radius-sm); overflow: hidden; }
.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dark), var(--chart));
  border-radius: var(--radius-sm);
  transition: width .45s var(--ease-out);
}
.funnel-num { text-align: right; font-weight: 600; color: var(--text-2); }

/* ==========================================================================
   抽屉 —— 只动 transform，不动布局属性
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 24, .42);
  z-index: 50;
}
.drawer-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 51;
  display: flex;
  flex-direction: column;
  animation: drawer-in .22s var(--ease-out);
}
@keyframes drawer-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.drawer-head h3 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; }
.drawer-head .btn-ghost { color: var(--text-2); border-color: var(--line-strong); }
.drawer-head .btn-ghost:hover { background: var(--bg); color: var(--text); }
.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }

/* 键值对 */
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); font-size: var(--fs-xs); }
.kv dd { color: var(--text); word-break: break-word; }

.sub-title {
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 28px 0 12px;
}

/* ==========================================================================
   对话时间线
   ========================================================================== */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 4px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--line);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -20px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  border: 2px solid var(--surface);
}
.tl-item.outbound::before { background: var(--brand); }
.tl-meta { font-size: var(--fs-kicker); color: var(--text-3); margin-bottom: 4px; }
.tl-bubble {
  display: inline-block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  line-height: 1.55;
  max-width: 100%;
}
.tl-item.inbound .tl-bubble  { background: var(--surface-2); border: 1px solid var(--line); }
.tl-item.outbound .tl-bubble { background: var(--brand-soft); border: 1px solid #cddffd; }
.tl-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 10px;
  color: var(--text-3);
}

/* 跟进任务 */
.fu-list { display: flex; flex-direction: column; gap: 10px; }
.fu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.fu-item .fu-meta { font-size: var(--fs-xs); color: var(--text-3); }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  padding: 11px 20px;
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-sm);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: toast-in .2s var(--ease-out);
}
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ==========================================================================
   响应式 —— 断点按内容断裂处取，不按设备名
   ========================================================================== */
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
  .tabs { padding: 0 16px; }
  .tab { margin-right: 16px; }
  .card { padding: 20px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: var(--fs-xl); }
  .kv { grid-template-columns: 1fr; gap: 4px 0; }
  .kv dd { margin-bottom: 8px; }
  .drawer-panel { width: 100%; }
  .bar-row { grid-template-columns: 80px 1fr 40px; }
}

/* 尊重系统的减少动效设置：收敛为近乎瞬时，而不是彻底关掉 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
