/* ========== 芯图CRM（销售端） 全局样式 ========== */
:root {
  --primary: #4f6ef2;
  --primary-dark: #3b55d9;
  --primary-light: #eef1fe;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #1f2333;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --bg: #f5f6fa;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; color: var(--text); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ========== 登录页 ========== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #eef1fe 0%, #e0e7ff 40%, #dbeafe 100%); }
.login-wrap { width: 420px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; font-size: 30px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(79, 110, 242, .35); }
.login-brand h1 { font-size: 24px; margin-top: 14px; }
.login-slogan { color: var(--text-2); margin-top: 6px; font-size: 13px; }
.login-card { background: #fff; border-radius: 14px; padding: 30px 32px; box-shadow: 0 10px 40px rgba(16, 24, 40, .08); }
.login-card h2 { font-size: 18px; margin-bottom: 20px; }
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: border .2s; background: #fff; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 110, 242, .12); }
.login-tip { font-size: 12px; color: var(--text-3); background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; line-height: 1.7; }
.login-error { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; text-align: center; }

/* ========== 按钮 ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 13px; transition: all .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }

/* ========== 布局 ========== */
#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 216px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-group { font-size: 11px; color: var(--text-3); padding: 14px 18px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--text-2); font-size: 13px; cursor: pointer; border-left: 3px solid transparent; transition: all .12s; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-3); }
.btn-logout { margin-left: auto; border: none; background: transparent; color: var(--text-3); font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.btn-logout:hover { background: #fee2e2; color: var(--danger); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 54px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; flex-shrink: 0; }
.page-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-phone { font-size: 12px; color: var(--text-2); background: var(--bg); padding: 5px 10px; border-radius: 20px; }
.content { flex: 1; overflow-y: auto; padding: 20px; }
.loading { text-align: center; color: var(--text-3); padding: 60px 0; }

/* ========== 卡片 ========== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

/* ========== 统计卡片 ========== */
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden; }
.stat-card .stat-label { font-size: 12px; color: var(--text-2); }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.stat-card .stat-icon { position: absolute; right: 14px; top: 14px; font-size: 22px; opacity: .18; }
.stat-card.accent-blue { border-top: 3px solid var(--primary); }
.stat-card.accent-green { border-top: 3px solid var(--success); }
.stat-card.accent-orange { border-top: 3px solid var(--warning); }
.stat-card.accent-red { border-top: 3px solid var(--danger); }
.stat-card.accent-purple { border-top: 3px solid #8b5cf6; }

/* ========== 筛选栏 ========== */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #fff; min-width: 0; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }
.filter-bar .grow { flex: 1; min-width: 160px; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: #f9fafb; color: var(--text-2); font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tbody tr:hover { background: #fafbfe; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-green { background: #ecfdf5; color: var(--success); }
.tag-orange { background: #fffbeb; color: var(--warning); }
.tag-red { background: #fef2f2; color: var(--danger); }
.tag-purple { background: #f5f3ff; color: #7c3aed; }
.tag-gray { background: #f3f4f6; color: var(--text-2); }
.stage-tag { font-weight: 600; }
.empty { text-align: center; color: var(--text-3); padding: 50px 0; }
.empty .empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .4; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 0 0; font-size: 12px; color: var(--text-2); }
.pagination button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.pagination button:disabled { opacity: .4; }

/* ========== 图表容器 ========== */
.chart { width: 100%; height: 300px; }

/* ========== 弹窗 ========== */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 560px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal .close-x { float: right; border: none; background: none; font-size: 18px; color: var(--text-3); cursor: pointer; }
.dial-modal { width: 480px; }

/* ========== 详情页 ========== */
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.detail-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-item .k { font-size: 12px; color: var(--text-3); }
.detail-item .v { margin-top: 3px; font-size: 13px; }
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab-bar .tab { padding: 8px 14px; font-size: 13px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tab-bar .tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.stat-mini { text-align: center; padding: 10px 4px; background: var(--bg); border-radius: 8px; }
.stat-mini .v { font-size: 20px; font-weight: 700; }
.stat-mini .k { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.script-block { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.script-block .script-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.script-block pre { white-space: pre-wrap; font-family: inherit; font-size: 12.5px; line-height: 1.8; color: var(--text-2); }
.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 18px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline-item.ai::before { background: var(--success); }
.timeline-item .t-head { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-3); }
.timeline-item .t-body { margin-top: 6px; font-size: 13px; line-height: 1.7; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud .tcol { width: calc(50% - 4px); background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.tag-cloud .tcol .k { font-size: 11px; color: var(--text-3); }
.tag-cloud .tcol .v { font-size: 13px; margin-top: 2px; font-weight: 500; }

/* ========== 外呼弹窗 ========== */
.dial-head { text-align: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.dial-head .dial-name { font-size: 20px; font-weight: 700; }
.dial-head .dial-phone { color: var(--text-2); margin-top: 4px; }
.dial-timer { font-size: 40px; font-weight: 700; text-align: center; margin: 24px 0; font-variant-numeric: tabular-nums; color: var(--primary); }
.dial-btns { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }
.dial-hangup { width: 72px; height: 72px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 13px; border: none; box-shadow: 0 6px 20px rgba(239, 68, 68, .4); }
.dial-note { background: var(--bg); border-radius: 8px; padding: 10px; font-size: 12px; color: var(--text-2); line-height: 1.7; }

/* ========== 谈单助手 ========== */
.chat-input { display: flex; gap: 10px; margin-top: 14px; }
.chat-input textarea { flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 12px; resize: vertical; min-height: 72px; outline: none; }
.chat-input textarea:focus { border-color: var(--primary); }
.assistant-answer { background: var(--bg); border-radius: 10px; padding: 14px; line-height: 1.8; font-size: 13px; white-space: pre-wrap; }
.assistant-answer .ctx-line { color: var(--primary); font-size: 12px; margin-bottom: 8px; }
.chat-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.chat-item .q { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.chat-item .a { font-size: 12.5px; color: var(--text-2); line-height: 1.8; white-space: pre-wrap; }

/* ========== 知识库 ========== */
.kb-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; transition: box-shadow .15s; }
.kb-card:hover { box-shadow: 0 4px 16px rgba(16, 24, 40, .08); }
.kb-card.kb-open { cursor: pointer; }
.kb-card .kb-q { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kb-card .kb-a { margin-top: 8px; font-size: 13px; color: var(--text-2); line-height: 1.8; }
.kb-card .kb-meta { margin-top: 10px; font-size: 11px; color: var(--text-3); display: flex; gap: 10px; align-items: center; }

/* ========== 报告 ========== */
.metric-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.metric-box { background: var(--bg); border-radius: 10px; padding: 14px; text-align: center; }
.metric-box .v { font-size: 22px; font-weight: 700; color: var(--primary); }
.metric-box .k { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.issue-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13px; align-items: flex-start; }
.issue-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); margin-top: 6px; flex-shrink: 0; }

/* ========== 教程弹窗 ========== */
.tutorial h4 { margin: 14px 0 6px; font-size: 14px; }
.tutorial p, .tutorial li { font-size: 13px; color: var(--text-2); line-height: 1.8; }
.tutorial ol { padding-left: 20px; }
.tutorial code { background: var(--bg); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ========== 其他 ========== */
.text-2 { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mb-14 { margin-bottom: 14px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-100 { width: 100%; }
.w-140 { width: 140px; }
.w-180 { width: 180px; }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #1f2333; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 999; opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }

/* 响应式 */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2-1, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar-brand .brand-name, .sidebar-brand .brand-sub, .nav-group, .nav-item span:not(.nav-icon), .user-chip .user-name, .user-chip .user-role, .user-chip .btn-logout { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .sidebar-foot { padding: 10px 0; display: flex; justify-content: center; }
}
