/* 智慧客户管理 CRM - 蓝白商务风 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f6fb;
  --card: #ffffff;
  --sidebar: #1e3a8a;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); }
.login-box { width: 400px; background: #fff; border-radius: 12px; padding: 40px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-box h1 { font-size: 24px; text-align: center; margin-bottom: 6px; color: var(--primary); }
.login-box .sub { text-align: center; color: var(--text-light); margin-bottom: 30px; }
.login-box .field { margin-bottom: 18px; }
.login-box label { display: block; margin-bottom: 6px; font-weight: 500; }
.login-box input { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 6px; padding: 0 12px; font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--primary); }
.login-demo { margin-top: 20px; padding: 12px; background: var(--primary-light); border-radius: 6px; font-size: 12px; color: var(--primary-dark); line-height: 1.7; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; position: fixed; height: 100vh; }
.logo { padding: 22px 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.logo .icon { width: 32px; height: 32px; background: #fff; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 18px; }
.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 12px 22px; color: rgba(255,255,255,.75); text-decoration: none; font-size: 14px; cursor: pointer; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #60a5fa; }
.nav .mi { width: 18px; text-align: center; font-size: 16px; }
.sidebar .user-bar { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.sidebar .user-bar b { display: block; margin-bottom: 8px; }
.sidebar .user-bar button { background: rgba(255,255,255,.12); border: 0; color: #fff; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; }

.main { flex: 1; margin-left: 220px; min-width: 0; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; }
.topbar h2 { font-size: 18px; }
.topbar .mode-badge { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--primary-light); color: var(--primary-dark); }
.topbar .mode-badge.api { background: #dcfce7; color: var(--success); }
.content { padding: 24px 28px; }

/* 卡片 */
.card { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h3 { font-size: 15px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card h3::before { content: ''; width: 3px; height: 16px; background: var(--primary); border-radius: 2px; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; cursor: pointer; transition: transform .15s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-card .si { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-card .sl { color: var(--text-light); font-size: 13px; margin-bottom: 4px; }
.stat-card .sv { font-size: 26px; font-weight: 700; }
.si.blue { background: var(--primary-light); color: var(--primary); }
.si.green { background: #dcfce7; color: var(--success); }
.si.orange { background: #fef3c7; color: var(--warning); }
.si.red { background: #fee2e2; color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* 表格 */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font-size: 14px; }
.toolbar input { min-width: 220px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f9fafb; color: var(--text-light); font-weight: 600; white-space: nowrap; }
tr:hover td { background: #f9fbfd; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; margin-right: 4px; }
.tag.blue { background: var(--primary-light); color: var(--primary-dark); }
.tag.green { background: #dcfce7; color: var(--success); }
.tag.orange { background: #fef3c7; color: #b45309; }
.tag.gray { background: #f3f4f6; color: var(--text-light); }
.tag.red { background: #fee2e2; color: var(--danger); }

/* 按钮 */
.btn { height: 36px; padding: 0 16px; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.link { background: none; color: var(--primary); padding: 0 6px; height: auto; }
.btn.link.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 分页 */
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; color: var(--text-light); font-size: 13px; }
.pagination button { height: 30px; min-width: 30px; border: 1px solid var(--border); background: #fff; border-radius: 4px; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 空状态 / 加载 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty .ei { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.loading { text-align: center; padding: 50px; color: var(--text-light); }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--primary-light); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 600; }
.modal-head .close { cursor: pointer; font-size: 22px; color: var(--text-light); line-height: 1; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item { display: flex; flex-direction: column; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 13px; margin-bottom: 5px; font-weight: 500; }
.form-item label .req { color: var(--danger); }
.form-item input, .form-item select, .form-item textarea { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 14px; font-family: inherit; }
.form-item input, .form-item select { height: 38px; }
.form-item textarea { resize: vertical; min-height: 70px; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { outline: none; border-color: var(--primary); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* 详情 */
.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 14px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.info-item label { color: var(--text-light); font-size: 12px; display: block; margin-bottom: 3px; }
.info-item div { font-size: 14px; }
.timeline { border-left: 2px solid var(--primary-light); padding-left: 16px; }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline-item .th { font-size: 13px; color: var(--text-light); margin-bottom: 4px; }
.timeline-item .tc { font-size: 14px; }

/* 明细行 */
.item-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row input { height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; }
.item-row .rm { cursor: pointer; color: var(--danger); text-align: center; font-size: 18px; }

/* Toast */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 18px; border-radius: 6px; color: #fff; box-shadow: var(--shadow); animation: slidein .2s; min-width: 200px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* 仪表盘图表 */
.chart-bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 10px; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-bar .bar { width: 100%; max-width: 40px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart-bar .bl { font-size: 11px; color: var(--text-light); margin-top: 6px; }
.chart-bar .bv { font-size: 11px; margin-bottom: 4px; }

/* 确认框 */
.confirm-text { font-size: 14px; line-height: 1.7; color: var(--text); }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ v2 标签+归属模型新增样式 ============ */
.login-logo { text-align: center; font-size: 46px; margin-bottom: 6px; }

/* 首页 hero 统计 */
.hero-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.hero-card { background: #fff; border-radius: 10px; padding: 18px 16px; box-shadow: var(--shadow); text-align: center; }
.hero-card .hv { font-size: 24px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.hero-card .hl { font-size: 12px; color: var(--text-light); }
.hero-card.accent { background: linear-gradient(135deg, #2563eb, #1e40af); }
.hero-card.accent .hv, .hero-card.accent .hl { color: #fff; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title h3 { margin: 0; }
.muted { color: var(--text-light); }
.sm { font-size: 12px; }

/* 需要跟进列表 */
.need-list { display: flex; flex-direction: column; }
.need-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.need-item:hover { background: #f9fbfd; }
.need-item .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.need-main { flex: 1; min-width: 0; }
.need-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.need-top b { font-size: 14px; }
.need-sub { color: var(--text-light); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.need-right { text-align: right; flex-shrink: 0; }
.need-date { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.tag-badge { font-weight: 600; }
.tag-badge.green { background: #dcfce7; color: #15803d; }
.tag-badge.blue { background: #dbeafe; color: #1d4ed8; }
.tag-badge.orange { background: #ffedd5; color: #c2410c; }
.tag-badge.gray { background: #f1f5f9; color: #475569; }
.tag-badge.red { background: #fee2e2; color: #b91c1c; }
.tag.overdue { font-weight: 600; }

/* 客户管理 */
.cust-card { padding-top: 8px; }
.scope-tabs { display: flex; gap: 8px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.scope-tab { padding: 12px 20px; border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.scope-tab.active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); }
.filter-line { display: flex; gap: 10px; margin-bottom: 12px; }
.search-input { flex: 1; max-width: 420px; height: 38px; border: 1px solid var(--border); border-radius: 6px; padding: 0 12px; font-size: 14px; }
.chip-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip-label { font-size: 12px; color: var(--text-light); width: 32px; flex-shrink: 0; }
.chip { padding: 5px 14px; border: 1px solid var(--border); border-radius: 16px; background: #fff; cursor: pointer; font-size: 13px; color: var(--text); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.batch-line { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.selected-tip { color: var(--text-light); font-size: 12px; margin-left: auto; }
.cust-table th, .cust-table td { vertical-align: middle; }
.cust-table .ck { width: 34px; text-align: center; }
.cust-table .ck input { width: 15px; height: 15px; cursor: pointer; }
.c-name { color: var(--primary); font-weight: 600; cursor: pointer; }
.cell-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.cust-table .op-cell { white-space: nowrap; }
.muted { color: #9ca3af; }

/* 数据分析 */
.dash-top { display: flex; align-items: center; gap: 40px; padding: 10px 0 18px; }
.dash-big { text-align: center; padding-right: 40px; border-right: 1px solid var(--border); }
.db-num { font-size: 44px; font-weight: 800; color: var(--text); }
.db-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.dash-split { display: flex; gap: 60px; }
.dash-split > div { text-align: center; }
.dash-split b { display: block; font-size: 28px; color: var(--primary); }
.dash-split span { font-size: 12px; color: var(--text-light); }
.dash-note { text-align: center; color: var(--text-light); font-size: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.proj-dyn { display: flex; }
.proj-dyn > div { flex: 1; text-align: center; padding: 16px; background: #f8fafc; border-radius: 8px; }
.proj-dyn > div:first-child { margin-right: 12px; }
.proj-dyn b { display: block; font-size: 26px; }
.proj-dyn span { font-size: 12px; color: var(--text-light); }
.recent-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.mini-stat { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px 8px; text-align: center; }
.mini-stat b { display: block; font-size: 22px; color: var(--primary); }
.mini-stat span { font-size: 11px; color: var(--text-light); }
.tag-dist { display: flex; flex-direction: column; gap: 14px; }
.td-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; }
.td-head b { font-weight: 600; }
.td-bar { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.td-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.green, .td-fill.green { background: #22c55e; }
.dot.blue, .td-fill.blue { background: #3b82f6; }
.dot.orange, .td-fill.orange { background: #f97316; }
.dot.gray, .td-fill.gray { background: #94a3b8; }
.dot.red, .td-fill.red { background: #ef4444; }

/* 项目工单子标签 */
.sub-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.sub-tab { padding: 8px 22px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; }
.sub-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.amount-tip { margin-top: 12px; font-weight: 700; color: var(--primary); }
.hint { font-size: 12px; color: var(--text-light); margin-top: 8px; }

/* 设置 */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.set-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.set-row span { color: var(--text-light); }
.set-big { font-size: 22px; font-weight: 700; margin: 6px 0; }
.tag-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.namecard { display: flex; justify-content: space-between; gap: 16px; }
.nc-name { font-size: 20px; font-weight: 700; }
.nc-company { color: var(--text-light); margin: 6px 0 12px; }
.nc-line { font-size: 13px; margin-bottom: 4px; }
.nc-qr { width: 90px; height: 90px; border: 2px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 12px; flex-shrink: 0; }

@media (max-width: 1100px) {
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .recent-grid { grid-template-columns: repeat(3, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .dash-top { flex-direction: column; gap: 20px; }
  .dash-big { border-right: 0; padding-right: 0; }
}

/* ============ v3 批量导入 + 关键字 + 合同到期 ============ */
.form-hint { font-size: 11px; color: #9ca3af; margin-top: 4px; line-height: 1.4; }
.import-wrap { min-height: 200px; }
.import-steps { background: #eff6ff; color: #1d4ed8; border-radius: 6px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.import-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.import-textarea { width: 100%; min-height: 120px; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font-size: 13px; font-family: Menlo, Consolas, monospace; resize: vertical; line-height: 1.5; margin-bottom: 12px; }
.import-summary { margin: 14px 0 8px; font-size: 13px; }
.import-summary b.ok { color: #15803d; } .import-summary b.bad { color: #b91c1c; }
.import-table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.import-table { font-size: 12px; }
.import-errors { margin-top: 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: 10px 14px; color: #b91c1c; font-size: 12px; line-height: 1.7; }
.import-errors > div { margin-top: 6px; color: #7f1d1d; }
