/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
}
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.main { flex: 1; margin-left: var(--sidebar-w); padding: 24px; }

/* ===== 侧边栏 ===== */
.sidebar-logo { padding: 20px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary), #7c3aed); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; font-weight: bold; }
.sidebar-logo .logo-text { font-size: 16px; font-weight: 700; color: var(--text); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; cursor: pointer; color: var(--text-light); font-size: 14px; transition: all 0.15s; margin-bottom: 2px; text-decoration: none; }
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--danger); color: white; font-size: 11px; padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center; }
.nav-item.active .nav-badge { background: rgba(255,255,255,0.3); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-lighter); }

/* ===== 页面 ===== */
.page { display: none; }
.page.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-desc { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ===== 卡片 ===== */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: 16px; top: 16px; font-size: 32px; opacity: 0.15; }
.stat-card .stat-label { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-trend { font-size: 12px; margin-top: 4px; }
.stat-card .stat-trend.up { color: var(--success); }
.stat-card .stat-trend.down { color: var(--danger); }

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; font-size: 12px; color: var(--text-light); font-weight: 500; border-bottom: 2px solid var(--border); text-transform: uppercase; letter-spacing: 0.5px; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table tr:hover { background: #f8fafc; }
.table tr:last-child td { border-bottom: none; }

/* ===== 按钮 ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: none; font-size: 14px; cursor: pointer; transition: all 0.15s; font-family: inherit; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: #f8fafc; border-color: var(--text-lighter); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; background: transparent; border: none; cursor: pointer; font-size: 16px; color: var(--text-light); border-radius: 4px; }
.btn-icon:hover { background: #f1f5f9; color: var(--text); }

/* ===== 输入框 ===== */
.input, .textarea, .select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: white; transition: border-color 0.15s; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== 标签/徽章 ===== */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ===== 进度条 ===== */
.progress { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* ===== 意向分 ===== */
.score-circle { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; }
.score-high { background: var(--success); }
.score-mid { background: var(--warning); }
.score-low { background: var(--text-lighter); }

/* ===== 模态框 ===== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 200; justify-content: center; align-items: flex-start; padding-top: 60px; }
.modal-overlay.show { display: flex; }
.modal { background: white; border-radius: 12px; width: 90%; max-width: 560px; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: white; z-index: 1; border-radius: 12px 12px 0 0; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: white; border-radius: 0 0 12px 12px; }

/* ===== 智能问答区 ===== */
.qa-container { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.qa-input-area { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.qa-output-area { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.qa-answer { background: #f8fafc; border-radius: 8px; padding: 16px; margin-top: 12px; white-space: pre-wrap; line-height: 1.8; font-size: 15px; border: 1px solid var(--border); }
.qa-matched { margin-top: 12px; }
.qa-matched-item { display: inline-block; background: #ede9fe; color: #5b21b6; padding: 3px 10px; border-radius: 12px; font-size: 12px; margin-right: 6px; margin-bottom: 4px; }

/* ===== 漏斗 ===== */
.funnel { display: flex; flex-direction: column; gap: 4px; }
.funnel-stage { display: flex; align-items: center; padding: 12px 16px; border-radius: 8px; color: white; font-weight: 500; position: relative; }
.funnel-stage .stage-name { flex: 1; }
.funnel-stage .stage-count { font-size: 13px; opacity: 0.9; }

/* ===== 空状态 ===== */
.empty { text-align: center; padding: 40px 20px; color: var(--text-lighter); }
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty .empty-text { font-size: 14px; }

/* ===== Toast ===== */
.toast { position: fixed; top: 20px; right: 20px; background: #1e293b; color: white; padding: 12px 20px; border-radius: 8px; z-index: 300; font-size: 14px; box-shadow: var(--shadow-lg); animation: slideIn 0.2s; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== 搜索框 ===== */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-lighter); font-size: 14px; }

/* ===== 筛选栏 ===== */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar .input, .filter-bar .select { width: auto; min-width: 180px; }

/* ===== 时间线 ===== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); }
.timeline-time { font-size: 12px; color: var(--text-lighter); }
.timeline-content { font-size: 14px; margin-top: 2px; }

/* ===== 复制按钮 ===== */
.copy-btn { background: var(--primary); color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.copy-btn:hover { background: var(--primary-dark); }
.copy-btn.copied { background: var(--success); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.show { transform: translateX(0); }
  .main { margin-left: 0; padding: 16px; }
  .qa-container { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
