/* ==========================================================================
   个人 CRM — 界面样式
   极简瑞士风：专业蓝 + 草绿强调，密集仪表盘，亮/暗双主题
   ========================================================================== */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f5fd;
  --surface-3: #e8eefb;
  --border: #e4ecfc;
  --border-strong: #d3e0f7;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #5f6e84;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-weak: #eaf1fe;
  --on-primary: #ffffff;
  --accent: #047857;
  --accent-weak: #e5f6f0;
  --danger: #c81e1e;
  --danger-weak: #fdecec;
  --warn: #b45309;
  --warn-weak: #fdf1e2;
  --ring: #2563eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 16px -6px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 28px 64px -16px rgba(15, 23, 42, 0.3);
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --t: 160ms var(--ease);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* 暗色主题：显式切换 + 跟随系统 */
:root[data-theme="dark"] {
  --bg: #0a1120;
  --surface: #101a2c;
  --surface-2: #16213a;
  --surface-3: #1d2b47;
  --border: #1e2c46;
  --border-strong: #2a3b5c;
  --text: #e8eef8;
  --text-2: #a7b6ce;
  --text-3: #8a9bb5;
  --primary: #4d82ff;
  --primary-hover: #6b97ff;
  --primary-weak: #16294a;
  --on-primary: #ffffff;
  --accent: #2fd39b;
  --accent-weak: #102d26;
  --danger: #ff6b6b;
  --danger-weak: #341a21;
  --warn: #f0a75a;
  --warn-weak: #322415;
  --ring: #6b97ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 32px 70px -20px rgba(0, 0, 0, 0.75);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1120;
    --surface: #101a2c;
    --surface-2: #16213a;
    --surface-3: #1d2b47;
    --border: #1e2c46;
    --border-strong: #2a3b5c;
    --text: #e8eef8;
    --text-2: #a7b6ce;
    --text-3: #8a9bb5;
    --primary: #4d82ff;
    --primary-hover: #6b97ff;
    --primary-weak: #16294a;
    --on-primary: #ffffff;
    --accent: #2fd39b;
    --accent-weak: #102d26;
    --danger: #ff6b6b;
    --danger-weak: #341a21;
    --warn: #f0a75a;
    --warn-weak: #322415;
    --ring: #6b97ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 32px 70px -20px rgba(0, 0, 0, 0.75);
  }
}

* { box-sizing: border-box; }

/* hidden 属性优先于任何 display 规则 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon .dot { fill: currentColor; stroke: none; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

::selection { background: var(--primary); color: var(--on-primary); }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ 布局 */

.shell {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 12px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px -4px rgba(37, 99, 235, 0.7);
}
.brand-mark svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
}
.brand-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-2);
  transition: background var(--t), color var(--t);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 550;
}
.nav-item.active .icon { stroke-width: 1.9; }

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-parent {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  margin-top: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
}
.nav-group::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 42px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.nav-item.sub {
  height: 32px;
  padding: 0 10px 0 34px;
  font-size: 13px;
}

.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.foot-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.foot-btn:hover { background: var(--surface-2); color: var(--text); }
.foot-btn .icon { width: 14px; height: 14px; color: var(--text-3); }

.foot-note {
  margin: 8px 0 0;
  padding: 0 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-3);
  word-break: break-all;
}

.main {
  min-width: 0;
  padding: 26px 34px 72px;
  outline: none;
}
.main > * { max-width: 1080px; }

/* ------------------------------------------------------------------ 页头 */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 640;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.page-sub {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
}

.head-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  -webkit-user-select: none;
  user-select: none;
}
.btn .icon { width: 14.5px; height: 14.5px; }
.btn:active { transform: translateY(0.5px); }

.btn.primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}
.btn.primary:hover { background: var(--primary-hover); }

.btn.quiet {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
}
.btn.quiet:hover { background: var(--surface-2); color: var(--text); }

.btn.plain { color: var(--text-2); }
.btn.plain:hover { background: var(--surface-2); color: var(--text); }

.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-weak); }

.btn.tiny { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon-only { width: 30px; padding: 0; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------------------------------------------ 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

h2.card-title, h2.section-title { margin: 0; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.card-title .count {
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ 统计 */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.stat {
  position: relative;
  padding: 14px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
}
.stat-label .icon { width: 13px; height: 13px; }
.stat-value {
  margin-top: 6px;
  font-size: 25px;
  font-weight: 640;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-foot {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-3);
}
.stat.is-alert .stat-value { color: var(--danger); }

/* ------------------------------------------------------------------ 今日 */

.section + .section { margin-top: 18px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 2px 9px;
}
.section-title {
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text-2);
}
.section-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.section-hint {
  font-size: 11.5px;
  color: var(--text-3);
  margin-left: auto;
}
.section.is-overdue .section-count { background: var(--danger-weak); color: var(--danger); }
.section.is-overdue .section-title { color: var(--danger); }

.row-list { display: flex; flex-direction: column; }

.row-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t);
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--surface-2); }

.row-main { min-width: 0; flex: 1; }
.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.row-name {
  font-size: 13.5px;
  font-weight: 570;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta em {
  font-style: normal;
  color: var(--text-2);
}
.row-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.due {
  font-size: 11.5px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}
.due.is-late { color: var(--danger); }
.due.is-today { color: var(--warn); }

/* ------------------------------------------------------------------ 状态标签 */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}
.pill[data-status="未开发"] { color: #7c8798; background: #f4f6fa; border-color: #e8edf5; }
.pill[data-status="新线索"] { color: #4b5f7d; background: #eef2f9; border-color: #e2e9f4; }
.pill[data-status="跟进中"] { color: var(--primary); background: var(--primary-weak); }
.pill[data-status="已报价"] { color: var(--warn); background: var(--warn-weak); }
.pill[data-status="已成交"] { color: var(--accent); background: var(--accent-weak); }
.pill[data-status="已流失"] { color: var(--text-3); background: var(--surface-2); }

:root[data-theme="dark"] .pill[data-status="新线索"] { color: #9fb2cc; background: #1a263c; border-color: #24334e; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill[data-status="新线索"] { color: #9fb2cc; background: #1a263c; border-color: #24334e; }
}

/* 列表里的标签：全部展示，最多两行 */
table.grid th.col-tags { width: 240px; }

.tag-cell {
  display: block;
  max-height: 47px;
  overflow: hidden;
  line-height: 0;
}
.tag-cell .tag {
  margin: 0 4px 4px 0;
  vertical-align: top;
  line-height: 1.45;
}
.tag-cell .due {
  display: inline-block;
  line-height: 1.5;
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 工具栏 */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-3);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 31px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.search input::placeholder { color: var(--text-3); }
.search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}

.chips { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.chip {
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 570;
}
.chip .n {
  margin-left: 4px;
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.filter-select {
  width: 168px;
  flex: none;
}
.filter-select.region-pick { width: 132px; }
.filter-select.tag-pick { width: 152px; }
.filter-select select { height: 30px; font-size: 12.5px; }
.filter-select .icon { width: 12px; height: 12px; }

.spacer { flex: 1; }

/* ------------------------------------------------------------------ 表格 */

.table-wrap { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.03em;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.grid td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}

table.grid tbody tr {
  cursor: pointer;
  transition: background var(--t);
}
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }

.cell-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 570;
  color: var(--text);
  max-width: 300px;
}
.cell-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 1px;
}
.copyable {
  cursor: copy;
  border-radius: 3px;
  transition: color var(--t), background var(--t);
}
.copyable:hover {
  color: var(--primary);
  background: var(--primary-weak);
}

.cell-product {
  max-width: 216px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
}

.cell-contact {
  font-weight: 520;
  color: var(--text);
  white-space: nowrap;
}

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.pager-info b {
  color: var(--text-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pager-btns { display: flex; align-items: center; gap: 4px; }

.page-btn {
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.page-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.page-btn[aria-current="page"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-gap { padding: 0 2px; color: var(--text-3); }

.table-empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ------------------------------------------------------------------ 详情 */

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px 0 4px;
  margin-left: -4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.back-btn:hover { background: var(--surface-2); color: var(--text); }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-title {
  margin: 0;
  font-size: 23px;
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-3);
}
.detail-meta .sep { color: var(--border-strong); }

.detail-grid {
  display: grid;
  grid-template-columns: 328px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.col-stack { display: flex; flex-direction: column; gap: 14px; }

.info-list { padding: 4px 0 6px; }

.info-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 16px;
  font-size: 12.5px;
  align-items: start;
}
.info-key { color: var(--text-3); }
.info-val { color: var(--text); word-break: break-word; }
.info-val.muted { color: var(--text-3); }
.info-val a { color: var(--primary); }
.site-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-link .icon { width: 11px; height: 11px; flex: none; opacity: .7; }
.site-link:hover { text-decoration: underline; }
.info-val a:hover { text-decoration: underline; }

.info-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.notes-block {
  margin: 4px 16px 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.62;
  max-height: 190px;
  overflow: auto;
}

/* 联系人 */

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.contact-item:last-child { border-bottom: 0; }

.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.contact-body { min-width: 0; flex: 1; }
.contact-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 560;
  color: var(--text);
}
.contact-title { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.contact-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-2);
}
.contact-lines span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
}
.contact-lines span > a,
.contact-lines span > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-lines a:hover { color: var(--primary); }
.contact-lines .icon { width: 11px; height: 11px; color: var(--text-3); }

.star {
  color: var(--warn);
  display: inline-flex;
}
.star .icon { width: 11px; height: 11px; fill: currentColor; stroke: none; }

.mini-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--t); }
.contact-item:hover .mini-actions { opacity: 1; }

.mini-btn {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.mini-btn:hover { background: var(--surface-3); color: var(--text); }
.mini-btn.danger:hover { background: var(--danger-weak); color: var(--danger); }
.mini-btn .icon { width: 13px; height: 13px; }

/* ------------------------------------------------------------------ 记录框 */

.composer { padding: 14px 16px 16px; }

.contact-pick { width: 190px; flex: none; }
.contact-pick select { height: 28px; font-size: 12px; padding-left: 8px; }
.contact-pick .icon { width: 11px; height: 11px; right: 7px; }

.tl-contact {
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 550;
}

.channel-row { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }

.channel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t);
}
.channel .icon { width: 12.5px; height: 12.5px; }
.channel:hover { background: var(--surface-2); }
.channel[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 550;
}

textarea,
input:not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
input, select { height: 32px; padding: 0 9px; }
select { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer; }
textarea {
  padding: 9px 10px;
  line-height: 1.6;
  resize: vertical;
  min-height: 62px;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}
input[type="date"] { font-variant-numeric: tabular-nums; }

.select-wrap { position: relative; }
.select-wrap .icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--text-3);
  pointer-events: none;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 8px;
  margin-top: 9px;
  align-items: center;
}

.composer-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}
kbd {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  line-height: 1.4;
}

/* ------------------------------------------------------------------ 时间线 */

.timeline { padding: 16px 16px 4px; position: relative; }

.tl-item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 18px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: 55px;
  top: 20px;
  bottom: -2px;
  width: 1px;
  background: var(--border);
}
.tl-item:last-child { padding-bottom: 6px; }
.tl-item:last-child::before { display: none; }

.tl-date {
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding-top: 1px;
}
.tl-date b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.tl-body {
  position: relative;
  min-width: 0;
  padding-left: 14px;
}
.tl-body::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.6px solid var(--border-strong);
}
.tl-item:first-child .tl-body::before {
  border-color: var(--primary);
  background: var(--primary);
}

.tl-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}
.tl-channel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 550;
  color: var(--text-2);
}
.tl-channel .icon { width: 11.5px; height: 11.5px; color: var(--text-3); }

.tl-text {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.62;
}

.tl-next {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 6px;
  padding: 6px 9px;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 0 5px 5px 0;
  font-size: 12px;
  color: var(--text-2);
}
.tl-next .icon { width: 12px; height: 12px; margin-top: 3px; color: var(--accent); flex: none; }

.tl-del {
  position: absolute;
  right: 0;
  top: -2px;
  opacity: 0;
  transition: opacity var(--t);
}
.tl-item:hover .tl-del { opacity: 1; }

/* ------------------------------------------------------------------ 空状态 */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 54px 24px;
  color: var(--text-3);
}
.empty .icon {
  width: 26px;
  height: 26px;
  color: var(--border-strong);
  margin-bottom: 10px;
}
.empty h3 {
  margin: 0 0 5px;
  font-size: 14px;
  font-weight: 580;
  color: var(--text-2);
}
.empty p { margin: 0 0 14px; font-size: 12.5px; max-width: 380px; line-height: 1.65; }

/* ------------------------------------------------------------------ 弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 18px 18px;
  background: rgba(10, 17, 32, 0.44);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in 140ms var(--ease);
  overflow-y: auto;
}

.modal {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in 180ms var(--ease);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}
.modal-title { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.modal-body { padding: 16px 20px 4px; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ 表单 */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label {
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-2);
}
.field > label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 10.5px; color: var(--text-3); }

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  height: 32px;
}
.check input { width: auto; height: auto; accent-color: var(--primary); }

/* ------------------------------------------------------------------ Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  transform: translate(-50%, 12px);
  padding: 8px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
:root[data-theme="dark"] .toast { background: #e8eef8; color: #0a1120; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast { background: #e8eef8; color: #0a1120; }
}

/* ------------------------------------------------------------------ 杂项 */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.loading {
  padding: 60px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ------------------------------------------------------------------ 响应 */

@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main > * { max-width: none; }
}

@media (max-width: 760px) {
  /* 手机上跳出 grid，避免 sticky 顶栏把首行撑高 */
  .shell { display: block; min-height: 0; }
  .main { min-height: calc(100vh - 60px); }

  /* 顶栏：品牌 + 导航 + 头像 + 退出 */
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    z-index: 30;
    overflow-x: auto;
  }
  .brand { padding: 0; margin-right: 4px; }
  .brand-name { display: none; }
  .nav { flex-direction: row; gap: 2px; flex: none; }
  .nav-item { height: 40px; padding: 0 10px; font-size: 13.5px; white-space: nowrap; gap: 5px; }
  .nav-count { display: none; }
  .nav-badge { margin-left: 0; }

  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; gap: 0; }
  .foot-btn { display: none; }
  .foot-note, #data-note { display: none; }
  .user-box { border: 0; padding: 0; margin: 0; }
  .user-meta { display: none; }
  .user-row { padding: 0; }

  .main { padding: 14px 14px 72px; }
  .main > * { max-width: none; }

  /* 页面头 */
  .page-head { margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
  .page-title { font-size: 19px; }
  .page-sub { font-size: 12px; }
  .head-actions .btn { height: 34px; padding: 0 10px; font-size: 12.5px; }
  .head-actions .btn .icon { width: 13px; height: 13px; }

  /* 公海/我的 切换 */
  .scope-tabs { width: 100%; display: flex; }
  .scope-tab { flex: 1; height: 40px; font-size: 13px; }

  /* 工具栏：搜索独占一行，筛选两列 */
  .toolbar { gap: 8px; }
  .search { flex: 1 1 100%; max-width: none; }
  .search input { height: 44px; font-size: 14px; }
  .chips { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; gap: 6px; }
  .chip { flex: none; height: 40px; padding: 0 14px; font-size: 13.5px; }
  .filter-select { flex: 1 1 calc(50% - 4px); width: auto; }
  .filter-select select { height: 44px; font-size: 13.5px; }
  .filter-toggle { height: 44px; }

  /* 表格 → 卡片 */
  .table-wrap { overflow: visible; }
  table.grid thead { display: none; }
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid tbody tr {
    position: relative;
    padding: 10px 92px 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  table.grid tbody tr:last-child { border-bottom: 0; }
  table.grid td { border: 0; padding: 0; text-align: left; }
  table.grid td:nth-child(1) { font-size: 14.5px; font-weight: 600; }
  table.grid td:nth-child(1) .cell-sub { font-size: 11.5px; margin-top: 1px; }
  table.grid td:nth-child(2) { margin-top: 3px; }
  table.grid td:nth-child(2) .cell-contact { font-size: 13px; }
  table.grid td:nth-child(2) .cell-sub { font-size: 12px; color: var(--text-2); }
  table.grid td:nth-child(3) { margin-top: 5px; }
  table.grid td:nth-child(4),
  table.grid td:nth-child(5),
  table.grid td.col-optional { display: none; }
  table.grid td.col-act {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    text-align: right;
  }
  table.grid td.col-act .btn { height: 40px; padding: 0 14px; font-size: 13.5px; }

  .pager { padding: 10px 12px; }
  .page-btn { height: 38px; min-width: 38px; font-size: 13px; }

  /* 详情 */
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-title { font-size: 19px; }
  .card-head { flex-wrap: wrap; gap: 8px; }
  .contact-pick { width: 100%; }
  .composer-row { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .row-side .due { display: none; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ------------------------------------------------------------------ 登录 */

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 26px 26px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .01em;
}

.auth-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.auth-sub {
  margin: 6px 0 20px;
  font-size: 12.5px;
  color: var(--text-3);
}

.auth-field {
  display: block;
  margin-bottom: 13px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-2);
}

.auth-field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: 38px;
  padding: 0 11px;
  font-size: 14px;
}

.auth-submit {
  width: 100%;
  height: 38px;
  margin-top: 6px;
  font-size: 13.5px;
}

.auth-err {
  margin: 0 0 10px;
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
  opacity: 0;
  transition: opacity var(--t);
}
.auth-err.show { opacity: 1; }

/* 侧边栏用户 */

.user-box { padding: 0 4px 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
}

.avatar.sm {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
  flex: 1;
}
.user-meta b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-meta i {
  font-style: normal;
  font-size: 10.5px;
  color: var(--text-3);
}


/* ------------------------------------------------------------------ 公海 / 账号 */

.scope-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.scope-tab {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background var(--t), color var(--t), box-shadow var(--t);
}
.scope-tab:hover { color: var(--text); }
.scope-tab[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

table.grid th.col-act, table.grid td.col-act {
  text-align: right;
  white-space: nowrap;
  width: 92px;
}


/* ------------------------------------------------------------------ 可访问性修复 */

/* 跳到主要内容 */
.skip-link {
  position: fixed;
  top: -64px;
  left: 12px;
  z-index: 999;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--shadow-md);
  transition: top 150ms var(--ease);
}
.skip-link:focus {
  top: 12px;
  outline: 2px solid var(--on-primary);
  outline-offset: 2px;
}

/* 读屏用的列标签：桌面隐藏（表头已提供上下文），手机才暴露给辅助技术 */
.cell-label { display: none; }

/* 领取按钮：常态描边，hover 才实心，降低一屏 20 个主按钮的噪音 */
.claim-btn {
  border-color: var(--border-strong);
  color: var(--primary);
  background: var(--surface);
}
table.grid tbody tr:hover .claim-btn,
table.grid tbody tr:focus-within .claim-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* 手机筛选折叠 */
.filter-toggle { display: none; }

@media (max-width: 760px) {
  .filter-toggle {
    display: inline-flex;
    width: 100%;
    height: 36px;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
  }
  .filter-toggle .icon { width: 12px; height: 12px; transition: transform var(--t); }
  .filter-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }

  /* 默认收起，点「筛选」才展开 */
  .toolbar:not(.filters-open) .filter-item { display: none; }

  /* 手机上把标签文字暴露给读屏（表头已隐藏） */
  .cell-label {
    display: inline;
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ------------------------------------------------------------------ 手机触控尺寸（放最后，覆盖前面所有断点） */

@media (max-width: 760px) {
  .scope-tab { height: 40px; font-size: 13px; }
  .filter-toggle { height: 44px; }
  .head-actions .btn { height: 40px; padding: 0 12px; }
  .user-row .mini-btn { width: 40px; height: 40px; }
  .mini-btn { min-width: 34px; min-height: 34px; }
  .contact-item .mini-actions { opacity: 1; }
  .channel { height: 38px; padding: 0 12px; }
  .modal-foot .btn { height: 42px; }
  .auth-submit { height: 44px; }
}

/* 手机顶栏：4 个菜单 + 用户区，隐藏姓名/角色只留头像，避免溢出 */
@media (max-width: 760px) {
  .sidebar { gap: 2px; }
  .brand { margin-right: 2px; }
  .brand-name { display: none; }
  .nav-item { padding: 0 8px; gap: 4px; font-size: 13px; }
  .nav-item .icon { width: 15px; height: 15px; }
  .nav-count { display: none; }
  .user-box { margin: 0; padding: 0; border: 0; }
  .user-row { gap: 4px; }
  .user-meta { display: none; }
  .sidebar-foot { margin-left: auto; }
}


/* 手机：客户管理分组展开成一行，隐藏分组标题和引导线 */
@media (max-width: 760px) {
  .nav-group { flex-direction: row; gap: 2px; }
  .nav-parent { display: none; }
  .nav-group::before { display: none; }
  .nav-item.sub { height: 40px; padding: 0 8px; font-size: 13px; }
}

/* ------------------------------------------------------------ 待跟进 / 客户选择器 */

.section-act { margin-left: auto; }
.section-head.with-act .section-hint { margin-left: 0; }

.empty.compact { padding: 30px 20px; }
.empty.compact .icon { width: 26px; height: 26px; margin-bottom: 10px; }
.empty.compact h3 { font-size: 14px; margin-bottom: 5px; }
.empty.compact p { font-size: 12.5px; margin-bottom: 14px; }

.pick-list {
  margin-top: 10px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.pick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background var(--t);
}
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover { background: var(--surface-2); }
.pick-name {
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick-meta {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick-add {
  margin-left: auto;
  flex: none;
  font-size: 12px;
  font-weight: 560;
  color: var(--primary);
}
.pick-item.is-added { cursor: default; background: var(--surface-2); }
.pick-item.is-added .pick-add { color: var(--text-3); }
.pick-empty {
  padding: 26px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

/* 账号页：私海上限 */
.quota-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.quota-used { font-weight: 600; color: var(--text); }
.quota-slash { color: var(--text-3); }
.quota-input {
  width: 58px;
  height: 28px;
  padding: 0 6px;
  text-align: center;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
