/* ─────────────────────────────────────────────────────────────
   Lead System — Design Tokens (Attio-inspired)
   ───────────────────────────────────────────────────────────── */

:root {
  /* Type */
  --font-sans: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-display: "Inter", "Noto Sans SC", sans-serif;

  /* ── Core neutrals (warm, near-white) ── */
  --canvas: #fafaf8;          /* page background */
  --surface: #ffffff;         /* cards */
  --surface-2: #f6f5f1;       /* nested / inset */
  --surface-3: #efeee9;       /* hover wash on light */
  --line: #ecebe5;            /* hairline borders */
  --line-2: #e3e1d9;          /* stronger divider */
  --line-strong: #d4d2c8;

  /* ── Ink (text) ── */
  --ink-1: #1a1916;           /* primary text */
  --ink-2: #45433d;           /* secondary text */
  --ink-3: #6b6960;           /* tertiary / labels */
  --ink-4: #94918a;           /* muted */
  --ink-5: #b8b5ac;           /* placeholder */

  /* ── Brand: muted indigo (Attio-ish) ── */
  --brand-50:  #f1f1fb;
  --brand-100: #e3e2f5;
  --brand-200: #c8c5ea;
  --brand-300: #9c97d8;
  --brand-400: #6e67c1;
  --brand-500: #4f47a8;
  --brand-600: #3e3792;
  --brand-700: #312c75;
  --brand-800: #25215a;

  /* ── Semantic ── */
  --success-50:  #eef6ee;
  --success-100: #d8ebd9;
  --success-500: #3d8b50;
  --success-600: #2f7042;
  --success-700: #245733;

  --warn-50:  #fbf3e0;
  --warn-100: #f5e6bd;
  --warn-500: #b27a16;
  --warn-600: #8d5f0e;
  --warn-700: #6b4709;

  --danger-50:  #fbeae5;
  --danger-100: #f5cbc0;
  --danger-500: #b53d24;
  --danger-600: #94301c;
  --danger-700: #722414;

  --info-50:  #eaf2fb;
  --info-100: #cfdef4;
  --info-500: #2c64aa;
  --info-600: #234f87;

  --violet-50: #f3edf9;
  --violet-500: #6e3ea3;

  --teal-50: #e6f3f1;
  --teal-500: #2f7d72;

  --amber-50: #fbf0d6;
  --amber-500: #a36a0c;

  /* ── Funnel colors (calibrated to feel like progress) ── */
  --stage-pending:  #94918a;   /* 待分配 — neutral */
  --stage-assigned: #3a7bbf;   /* 已分配 — info blue */
  --stage-contacted:#5b8ab5;   /* 已联络 — softer blue */
  --stage-joined:   #6e67c1;   /* 已进群 — indigo */
  --stage-opened:   #3d8b50;   /* 已开户 — green */
  --stage-lost:     #b53d24;   /* 失联 — danger */

  /* ── Radius ── */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* ── Shadows ── */
  --shadow-xs: 0 1px 0 rgba(20,18,12,.04);
  --shadow-sm: 0 1px 2px rgba(20,18,12,.05), 0 0 0 1px rgba(20,18,12,.04);
  --shadow-md: 0 4px 14px -4px rgba(20,18,12,.10), 0 1px 3px rgba(20,18,12,.05);
  --shadow-lg: 0 16px 40px -16px rgba(20,18,12,.18), 0 4px 12px -4px rgba(20,18,12,.06);
  --shadow-pop: 0 24px 60px -20px rgba(20,18,12,.28), 0 6px 18px -6px rgba(20,18,12,.08);

  /* ── Spacing scale (4 base) ── */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  /* ── Density (tweakable) ── */
  --row-h: 36px;
  --row-h-sm: 30px;
  --pad-x: 14px;
  --pad-y: 10px;

  /* ── Misc ── */
  --focus-ring: 0 0 0 3px rgba(79, 71, 168, .22);
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ── Dark mode ── */
[data-theme="dark"] {
  --canvas: #0e0d0c;
  --surface: #181715;
  --surface-2: #1f1e1b;
  --surface-3: #262521;
  --line: #2a2925;
  --line-2: #34322d;
  --line-strong: #45433d;

  --ink-1: #f1eee6;
  --ink-2: #c9c5b9;
  --ink-3: #95918a;
  --ink-4: #6f6c64;
  --ink-5: #535048;

  --brand-50:  #1d1c33;
  --brand-100: #232246;
  --brand-200: #2e2c5e;
  --brand-300: #4f47a8;
  --brand-400: #7d76d4;
  --brand-500: #9c97d8;
  --brand-600: #c8c5ea;

  --success-50:  #122218;
  --success-100: #18301f;
  --success-500: #5fa973;

  --warn-50:  #2a1f0a;
  --warn-100: #3a2c0e;
  --warn-500: #d09a3b;

  --danger-50:  #2a140d;
  --danger-100: #3a1c12;
  --danger-500: #d96b50;

  --info-50:  #0e1d2e;
  --info-100: #14273e;
  --info-500: #6396d0;

  --shadow-xs: 0 1px 0 rgba(0,0,0,.4);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.04);
  --shadow-md: 0 4px 14px -4px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 16px 40px -16px rgba(0,0,0,.7), 0 4px 12px -4px rgba(0,0,0,.4);
}

/* ── Reset / base ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html, body {
  font-family: var(--font-sans);
  background: var(--canvas);
  color: var(--ink-1);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  font-variant-numeric: tabular-nums;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: separate; border-spacing: 0; }

/* ── Utility primitives used across screens ── */

/* Pill (status, badges) */
.ls-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 540; letter-spacing: .1px;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.ls-pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .8; }
.ls-pill svg { width: 12px; height: 12px; }

.ls-pill--pending  { color: #6b6960; background: #f1f0eb; border-color: #e3e1d9; }
.ls-pill--assigned { color: #234f87; background: var(--info-50); border-color: var(--info-100); }
.ls-pill--contacted{ color: #2f7d72; background: var(--teal-50); border-color: #cae6e1; }
.ls-pill--joined   { color: #4f47a8; background: var(--brand-50); border-color: var(--brand-100); }
.ls-pill--opened   { color: #245733; background: var(--success-50); border-color: var(--success-100); }
.ls-pill--lost     { color: #94301c; background: var(--danger-50); border-color: var(--danger-100); }
.ls-pill--warn     { color: #8d5f0e; background: var(--warn-50);   border-color: var(--warn-100); }
.ls-pill--violet   { color: var(--violet-500); background: var(--violet-50); border-color: #e1d4ee; }

/* Card */
.ls-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

/* Buttons */
.ls-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 540;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-1);
  transition: background .12s var(--ease), border-color .12s var(--ease), box-shadow .12s var(--ease);
  white-space: nowrap;
}
.ls-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.ls-btn:active { background: var(--surface-3); }
.ls-btn--primary {
  background: var(--ink-1); color: var(--surface); border-color: var(--ink-1);
}
.ls-btn--primary:hover { background: #000; border-color: #000; }
.ls-btn--brand {
  background: var(--brand-500); color: #fff; border-color: var(--brand-500);
}
.ls-btn--brand:hover { background: var(--brand-600); border-color: var(--brand-600); }
.ls-btn--ghost {
  background: transparent; border-color: transparent; color: var(--ink-2);
}
.ls-btn--ghost:hover { background: var(--surface-2); }
.ls-btn--sm { height: 26px; padding: 0 9px; font-size: 12px; gap: 4px; }
.ls-btn--icon { width: 28px; padding: 0; justify-content: center; }
.ls-btn--icon.ls-btn--sm { width: 24px; height: 24px; }
.ls-btn--danger { color: var(--danger-600); }
.ls-btn--danger:hover { background: var(--danger-50); border-color: var(--danger-100); }

/* Inputs */
.ls-input, .ls-select {
  height: 30px; padding: 0 10px;
  background: var(--surface); color: var(--ink-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
  outline: none;
}
.ls-input:focus, .ls-select:focus {
  border-color: var(--brand-400);
  box-shadow: var(--focus-ring);
}
.ls-input::placeholder { color: var(--ink-5); }

/* Search input with icon prefix */
.ls-search {
  position: relative; display: inline-flex; align-items: center;
}
.ls-search svg { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--ink-4); pointer-events: none; }
.ls-search .ls-input { padding-left: 30px; }

/* Tables */
.ls-table { width: 100%; font-size: 13px; }
.ls-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  font-weight: 540;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-4);
  padding: 8px var(--pad-x);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ls-table tbody td {
  padding: 9px var(--pad-x);
  border-bottom: 1px solid var(--line);
  color: var(--ink-1);
  vertical-align: middle;
}
.ls-table tbody tr:hover { background: var(--surface-2); }
.ls-table tbody tr:last-child td { border-bottom: 0; }

/* Mono numerals */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; letter-spacing: -.2px; }
.tnum { font-variant-numeric: tabular-nums; }

/* Avatar */
.ls-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--brand-100); color: var(--brand-700);
  font-size: 10.5px; font-weight: 600;
  flex-shrink: 0;
}
.ls-avatar--md { width: 28px; height: 28px; font-size: 12px; }
.ls-avatar--lg { width: 36px; height: 36px; font-size: 13px; }

/* Kbd */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

/* Section header inside card */
.ls-section-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.ls-section-h h3 {
  font-size: 13px; font-weight: 600; color: var(--ink-1);
  display: flex; align-items: center; gap: 8px;
}
.ls-section-h h3 .count {
  font-weight: 500; color: var(--ink-4);
  background: var(--surface-2); padding: 1px 6px;
  border-radius: var(--r-xs); font-size: 11.5px;
}

/* Skeleton scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* Dividers */
.ls-divider { height: 1px; background: var(--line); }
.ls-divider--vert { width: 1px; height: 16px; background: var(--line); }

/* Subtle text accents */
.t-mute { color: var(--ink-3); }
.t-mute-2 { color: var(--ink-4); }
.t-strong { color: var(--ink-1); font-weight: 540; }

/* ── Round 15 · Skeleton placeholders ── */
.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
  vertical-align: middle;
}
.skel-line     { height: 12px; width: 100%; }
.skel-line.w-30 { width: 30%; }
.skel-line.w-40 { width: 40%; }
.skel-line.w-60 { width: 60%; }
.skel-line.w-80 { width: 80%; }
.skel-row td   { padding: 11px 12px; }
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Round 15 · Empty state (rich variant) ── */
.ls-empty-rich {
  padding: 48px 16px; text-align: center;
  color: var(--ink-3); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ls-empty-rich .icon { font-size: 36px; opacity: .6; }
.ls-empty-rich .title { color: var(--ink-2); font-weight: 540; font-size: 13.5px; }
.ls-empty-rich .hint { color: var(--ink-4); font-size: 12px; }
