/* ============================================
   GEO 获客系统 · 商务风格 UI
   参考：Zoho CRM NextGen / 纷享销客 / Salesforce
   布局：深蓝侧边栏 + 浅色内容区 + 卡片化
   ============================================ */
:root {
  --sidebar-bg: #1e2a4a;          /* 深蓝侧边栏 */
  --sidebar-text: #a8b6d4;
  --sidebar-active: #ffffff;
  --bg: #f3f5f9;                  /* 浅灰内容背景 */
  --bg2: #ffffff;                 /* 卡片背景 */
  --panel: #ffffff;
  --panel2: #f7f9fc;
  --border: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7a90;
  --accent: #2563eb;              /* 商务蓝 */
  --accent2: #0ea5e9;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --blue: #0284c7;
  --slate: #94a3b8;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c6cfdd; border-radius: 4px; }
a { color: var(--accent); text-decoration: none; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; background: var(--sidebar-bg); border-right: none;
  padding: 18px 12px; position: fixed; top: 0; bottom: 0; overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
.logo-icon {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, .4);
}
.logo-text b { font-size: 15px; display: block; color: #fff; letter-spacing: .3px; }
.logo-text span { font-size: 11px; color: var(--sidebar-text); }
.nav-section { color: #7181a8; font-size: 10px; font-weight: 700; letter-spacing: .9px; padding: 16px 12px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); cursor: pointer; margin-bottom: 2px; font-size: 13.5px;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .35), rgba(59, 130, 246, .12));
  color: var(--sidebar-active); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .25);
}
.nav-item .ico { width: 17px; text-align: center; }
.main { margin-left: 208px; flex: 1; padding: 20px 26px 60px; }
.sidebar .hint { color: #7c8db5; }
.sidebar .hint a { color: #93c5fd; }
.sidebar .hint a:hover { color: #bfdbfe; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

/* ---------- 今日工作 ---------- */
.welcome-panel { background: linear-gradient(115deg, #18325f 0%, #2459ac 62%, #1686b7 100%); border-radius: 16px; padding: 24px 26px; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; box-shadow: 0 10px 28px rgba(30, 70, 140, .2); }
.welcome-panel h2 { font-size: 21px; letter-spacing: .1px; margin: 2px 0 3px; }
.welcome-panel p { color: rgba(255,255,255,.78); font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: 1px; font-weight: 700; color: #a5ddf7; }
.welcome-actions { display: flex; gap: 9px; flex: none; }
.welcome-actions .btn { border-color: rgba(255,255,255,.42); background: rgba(255,255,255,.1); color: #fff; }
.welcome-actions .btn.primary { background: #fff; color: #1854a3; box-shadow: none; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; color: #334155; }
.card h3 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: #fff; color: #334155; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; font-size: 13px; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); border: none; color: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(37, 99, 235, .3); }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.success { background: rgba(22, 163, 74, .08); border-color: rgba(22, 163, 74, .35); color: var(--green); }
.btn.danger { background: rgba(220, 38, 38, .07); border-color: rgba(220, 38, 38, .35); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea {
  background: #fff; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font-size: 13px; outline: none; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
label.fld { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; font-weight: 500; }

/* ---------- 统计卡（KPI） ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); opacity: .7;
}
.stat .num { font-size: 26px; font-weight: 800; margin-top: 2px; color: #0f172a; }
.stat .lbl { color: var(--muted); font-size: 12px; }
.stat .num.c-accent { color: var(--accent); }
.stat .num.c-green { color: var(--green); }
.stat .num.c-amber { color: var(--amber); }
.stat .num.c-red { color: var(--red); }

/* ---------- 看板网格 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 12.5px; }
.bar-row .lbl { width: 90px; color: var(--muted); flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; height: 9px; background: #eef2f7; border-radius: 5px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 5px; transition: width .4s; }
.bar-row .val { width: 44px; text-align: right; color: #334155; flex: none; font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: #475569; font-weight: 600; font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--border); background: #f8fafc; white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid #edf1f7; vertical-align: middle; }
tr:hover td { background: #f6f9ff; }
td .company { font-weight: 600; color: #0f172a; }
td .muted { color: var(--muted); font-size: 12px; }
.snippet-cell { max-width: 300px; }
.snippet-cell p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }

/* ---------- 徽章（柔和底） ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.lv-S { background: #fee2e2; color: #b91c1c; }
.lv-A { background: #fef3c7; color: #b45309; }
.lv-B { background: #e0f2fe; color: #0369a1; }
.lv-C { background: #f1f5f9; color: #64748b; }
.st-new { background: #dbeafe; color: #1d4ed8; }
.st-contacted { background: #e0f2fe; color: #0369a1; }
.st-intent { background: #fef3c7; color: #b45309; }
.st-quoted { background: #f3e8ff; color: #7e22ce; }
.st-won { background: #dcfce7; color: #15803d; }
.st-lost { background: #f1f5f9; color: #64748b; }
.src-badge { color: #475569; font-size: 11.5px; background: #f1f5f9; padding: 2px 8px; border-radius: 6px; }

/* ---------- 筛选条 ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=text] { min-width: 220px; }
.filters select { min-width: 120px; }
.filters .spacer { flex: 1; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 12.5px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none;
  align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 640px; padding: 22px; position: relative; box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 860px; }
.modal h2 { font-size: 16px; margin-bottom: 16px; color: #0f172a; }
.modal .close {
  position: absolute; right: 14px; top: 12px; cursor: pointer; color: var(--muted);
  font-size: 20px; line-height: 1; padding: 4px; border-radius: 6px;
}
.modal .close:hover { color: #0f172a; background: #f1f5f9; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 跟进时间线 ---------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: #e2e8f0; }
.tl-item { position: relative; margin-bottom: 12px; }
.tl-item::before {
  content: ""; position: absolute; left: -18px; top: 7px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(37, 99, 235, .2);
}
.tl-item .time { font-size: 11px; color: var(--muted); }
.tl-item .txt { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; margin-top: 3px; }

/* ---------- 采集 ---------- */
.subtabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.subtab { padding: 8px 16px; cursor: pointer; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.kw-group { margin-bottom: 12px; }
.kw-group .g-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kw-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 4px 11px; border-radius: 20px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 12px; color: #475569; user-select: none; transition: all .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: rgba(37, 99, 235, .08); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.preview-info { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.checkbox { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 34px 0; }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.ok-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* ---------- 任务 ---------- */
.task-item { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid #edf1f7; }
.task-item.overdue-item { background: #fffaf8; margin: 0 -6px; padding: 9px 10px; border-radius: 8px; }
.task-item .due { color: var(--amber); font-size: 12px; white-space: nowrap; }
.task-item .due.over { color: var(--red); }
.task-item.done .txt { text-decoration: line-through; color: var(--muted); }
.task-item .who { color: var(--muted); font-size: 12px; }
.task-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.task-kpi { appearance: none; text-align: left; background: #fff; border: 1px solid var(--border); padding: 13px 15px; border-radius: 10px; cursor: pointer; box-shadow: var(--shadow); color: var(--muted); transition: .15s ease; }
.task-kpi:hover, .task-kpi.active { border-color: var(--accent); background: #f7faff; }
.task-kpi span { display: block; font-size: 12px; }
.task-kpi b { display: block; font-size: 21px; color: var(--text); line-height: 1.25; margin-top: 2px; }
.task-lead { appearance: none; border: 0; padding: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; }
.task-lead:hover { text-decoration: underline; }

/* ---------- 导出 ---------- */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tpl-link { display: block; padding: 10px 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.tpl-link:hover { border-color: var(--accent); }
.tpl-link b { display: block; font-size: 13px; }
.tpl-link span { font-size: 11.5px; color: var(--muted); }

/* ---------- 优化组件 ---------- */
.icon-btn {
  width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 6px;
  cursor: pointer; font-size: 14px; transition: all .12s; vertical-align: middle;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--red); border-color: #fecaca; background: #fef2f2; }
.icon-btn.success:hover { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.row-ops { display: inline-flex; gap: 3px; }
.row-ops .btn { padding: 3px 8px; font-size: 12px; }
.tel-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.tel-link:hover { text-decoration: underline; }
.cell-ellipsis { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-more { display: none; }
.filter-more.open { display: flex; }
.batch-float {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #fff; border: 1px solid var(--accent); border-radius: 12px;
  padding: 8px 14px; display: none; align-items: center; gap: 8px; z-index: 90;
  box-shadow: var(--shadow-lg); opacity: 0; transition: all .2s;
}
.batch-float.show { display: flex; opacity: 1; transform: translateX(-50%) translateY(0); }
.batch-float .count { color: #0f172a; font-weight: 700; margin-right: 6px; }
.quick-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 18px; }
.quick-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer;
  transition: all .15s; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow);
}
.quick-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lg); }
.quick-card .q-ico { font-size: 20px; }
.quick-card .q-num { font-size: 19px; font-weight: 800; color: #0f172a; }
.quick-card .q-lbl { font-size: 11.5px; color: var(--muted); }
.modal-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.modal-tab { padding: 7px 14px; cursor: pointer; color: var(--muted); font-size: 12.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.modal-pane { display: none; }
.modal-pane.active { display: block; }
.empty .guide-btn { margin-top: 10px; }

/* ========== 移动端适配 ========== */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .quick-row { grid-template-columns: repeat(3, 1fr); }
  .task-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .quick-row { grid-template-columns: repeat(2, 1fr); }
  .cell-ellipsis { max-width: 90px; }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0;
    width: 100%; height: 56px; border-right: none; border-top: 1px solid #33415e;
    background: var(--sidebar-bg); display: flex; align-items: stretch; z-index: 200;
    padding: 0; overflow: visible;
  }
  .logo { display: none; }
  .nav-section { display: none; }
  .sidebar > .hint { display: none; }
  .nav-item {
    flex: 1; flex-direction: column; justify-content: center; gap: 2px;
    padding: 4px 0; margin: 0; border-radius: 0; font-size: 10px; text-align: center;
  }
  .nav-item .ico { font-size: 17px; }
  .nav-item.active { background: rgba(59, 130, 246, .3); border-radius: 0; box-shadow: none; }
  .main { margin-left: 0; padding: 12px 10px 70px; }
  .topbar { margin-bottom: 12px; }
  .topbar h1 { font-size: 17px; }
  .topbar .sub { font-size: 11px; }
  .topbar-right .btn { padding: 5px 9px; font-size: 11.5px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
  .stat { padding: 10px 12px; }
  .stat .num { font-size: 20px; }
  .quick-row { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
  .quick-card { padding: 9px 10px; }
  .quick-card .q-num { font-size: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 12px; margin-bottom: 12px; }
  #view-dash .card .grid2 { grid-template-columns: repeat(2, 1fr) !important; }
  .table-wrap { margin: 0 -10px; padding: 0 10px; }
  table.compact th:nth-child(3), table.compact td:nth-child(3),
  table.compact th:nth-child(4), table.compact td:nth-child(4),
  table.compact th:nth-child(5), table.compact td:nth-child(5) { display: none; }
  table.compact td { padding: 6px 4px; font-size: 12px; }
  .company { font-size: 12.5px; }
  .badge { font-size: 10.5px; padding: 1px 6px; }
  .row-ops .btn { padding: 2px 6px; font-size: 11px; }
  .filters { gap: 6px; }
  .filters input[type=text] { min-width: 130px; font-size: 12.5px; padding: 6px 8px; }
  .filters select { min-width: 80px !important; font-size: 12px; padding: 6px 6px; }
  .filters .btn { padding: 6px 9px; font-size: 12px; }
  .filter-more { flex-wrap: wrap; }
  .modal-mask { padding: 0; }
  .modal, .modal.wide {
    width: 100%; max-width: 100%; min-height: 100vh; border-radius: 0;
    border-left: none; border-right: none; border-bottom: none; padding: 14px;
  }
  .modal .close { font-size: 24px; }
  .modal h2 { font-size: 15px; }
  #call-modal .modal { min-height: auto; }
  #call-qr { width: 140px !important; height: 140px !important; }
  #call-number { font-size: 19px !important; }
  .task-item { flex-wrap: wrap; gap: 6px; }
  .welcome-panel { padding: 18px; align-items: flex-start; flex-direction: column; }
  .timeline { padding-left: 14px; }
  .subtabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .subtab { white-space: nowrap; padding: 8px 10px; }
  .kw-chips .chip { font-size: 11px; padding: 3px 8px; }
  .pager { flex-wrap: wrap; font-size: 11.5px; }
}
@media (max-width: 420px) {
  .topbar { flex-wrap: wrap; }
  .filters input[type=text] { min-width: 100%; }
}
