* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'Segoe UI', sans-serif; background: #f5f7fa; color: #1a1a2e; }

/* 顶部 */
.header { background: #fff; border-bottom: 1px solid #e8ecf0; padding: 0 32px; display: flex; align-items: center; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.brand-name { font-size: 16px; font-weight: 700; }
.brand-tag { font-size: 11px; background: #e8f5e9; color: #2e7d32; padding: 2px 10px; border-radius: 10px; font-weight: 600; }

/* 模块导航 */
.mod-nav { background: #fff; border-bottom: 1px solid #e8ecf0; padding: 16px 32px; display: flex; align-items: stretch; gap: 6px; overflow-x: auto; }
.mod-item { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 10px 18px; border-radius: 10px; transition: all .15s; white-space: nowrap; }
.mod-item:hover { background: #f0f3f7; }
.mod-item.active { background: #1a1a2e; }
.mod-icon { font-size: 22px; }
.mod-text { display: flex; flex-direction: column; }
.mod-title { font-size: 14px; font-weight: 700; color: #1a1a2e; }
.mod-item.active .mod-title { color: #fff; }
.mod-desc { font-size: 11px; color: #8a94a6; margin-top: 2px; }
.mod-item.active .mod-desc { color: rgba(255,255,255,.6); }
.mod-arrow { color: #c0c8d4; font-size: 16px; display: flex; align-items: center; }

/* 主体 */
.main { max-width: 1400px; margin: 0 auto; padding: 32px 24px; }
.mod-view { display: none; }
.mod-view.active { display: block; }
/* 首帧模块记忆：head 脚本设置 html[data-mod]，属性选择器优先级高于 .active，刷新不闪默认模块 */
html[data-mod] .mod-view { display: none; }
html[data-mod="insight"] #mod-insight { display: block; }
html[data-mod="research"] #mod-research { display: block; }
html[data-mod="product"] #mod-product { display: block; }
html[data-mod="hunt"] #mod-hunt { display: block; }
html[data-mod="service"] #mod-service { display: block; }
.view-head { margin-bottom: 24px; }
.view-head h2 { font-size: 22px; font-weight: 700; }
.view-head p { font-size: 14px; color: #8a94a6; margin-top: 4px; }

/* KPI 行 */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: linear-gradient(135deg, #1a1a2e, #16213e); border-radius: 12px; padding: 18px; color: #fff; text-align: center; }
.kpi-val { font-size: 26px; font-weight: 800; }
.kpi-label { font-size: 12px; opacity: .7; margin-top: 4px; }

/* 卡片 */
.card { background: #fff; border-radius: 14px; padding: 24px; margin-bottom: 20px; border: 1px solid #e8ecf0; }
.card-title { font-size: 15px; font-weight: 700; color: #1a1a2e; margin-bottom: 6px; }
.card-desc { font-size: 13px; color: #8a94a6; margin-bottom: 16px; }
.muted { font-size: 13px; color: #8a94a6; margin: 8px 0; }

/* 核心判断（四维度纯文本段落） */
.core-judgment .cj-dim { margin: 0 0 14px; line-height: 1.8; }
.core-judgment .cj-dim b { color: #4f6ef7; }

/* 分析框 */
.analysis-box { margin-top: 16px; background: #f8f9fb; border-radius: 12px; padding: 20px; font-size: 14px; line-height: 1.8; color: #1a1a2e; border-left: 4px solid #1a1a2e; }
.analysis-box.loading { color: #8a94a6; font-style: italic; border-left-color: #c0c8d4; }

/* 模块两栏布局 + AI 对话面板 */
.mod-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.mod-main { min-width: 0; }
.mod-ai-panel { background: #fff; border-radius: 14px; border: 1px solid #e8ecf0; padding: 16px; position: sticky; top: 16px; display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 480px; }
.ai-panel-title { font-size: 15px; font-weight: 700; color: #1a1a2e; margin-bottom: 4px; }
.ai-panel-desc { font-size: 12px; color: #8a94a6; margin-bottom: 12px; line-height: 1.5; }
.ai-chat { flex: 1; overflow-y: auto; background: #f8f9fb; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.ai-msg { max-width: 92%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.ai-msg.user { align-self: flex-end; background: #1a1a2e; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: #fff; border: 1px solid #e8ecf0; border-bottom-left-radius: 4px; color: #1a1a2e; }
.ai-msg.welcome { align-self: flex-start; background: #eef6ff; border: 1px solid #d4e6ff; color: #1a4d8f; }
.ai-input-row { display: flex; gap: 8px; }
.ai-input-row input { flex: 1; padding: 9px 12px; border: 1px solid #e8ecf0; border-radius: 8px; font-size: 13px; outline: none; font-family: inherit; }
.ai-input-row input:focus { border-color: #1a1a2e; }
.ai-input-row button { white-space: nowrap; }
.ai-typing { color: #8a94a6; font-style: italic; font-size: 12px; padding: 4px 0; }

/* 市场调研核心判断容器：去掉左边框/背景/圆角/内边距（不需要大括号效果） */
#research-corejudgment.analysis-box { background: none; border-left: none; border-radius: 0; padding: 0; }

/* 市场调研报告容器（与 .diag-report 同风格，字体统一） */
#research-report { font-size: 14px; line-height: 1.8; color: #1a1a2e; }
#research-report h3 { margin: 16px 0 8px; color: #1a1a2e; font-size: 16px; font-weight: 700; }
#research-report h3:first-child { margin-top: 0; }
#research-report h4 { margin: 10px 0 6px; color: #4f6ef7; font-size: 14px; font-weight: 600; }
#research-report table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13px; }
#research-report li { margin: 4px 0; }
#research-report hr { border: none; border-top: 1px solid #e8ecf0; margin: 16px 0; }

#planner-report { font-size: 14px; line-height: 1.8; color: #1a1a2e; }
#planner-report h3 { margin: 16px 0 8px; color: #1a1a2e; font-size: 16px; font-weight: 700; }
#planner-report h3:first-child { margin-top: 0; }
#planner-report h4 { margin: 10px 0 6px; color: #4f6ef7; font-size: 14px; font-weight: 600; }
#planner-report table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13px; }
#planner-report li { margin: 4px 0; }
#planner-report hr { border: none; border-top: 1px solid #e8ecf0; margin: 16px 0; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #e8ecf0; }
th { background: #f8f9fb; color: #5a6270; font-weight: 600; font-size: 12px; }
tr:hover { background: #f8f9fb; }

/* 按钮 */
.btn { padding: 8px 20px; border-radius: 8px; border: 1px solid #e8ecf0; background: #fff; cursor: pointer; font-size: 13px; color: #5a6270; transition: all .15s; }
.btn:hover { background: #f0f3f7; }
.btn.primary { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.btn.primary:hover { background: #2a2a3e; }
.btn-gold { background: #fff8e1; border-color: #fdd835; color: #b8860b; }
.btn-gold:hover { background: #fff3cd; }
.btn.small { padding: 5px 12px; font-size: 12px; border-radius: 6px; }

select { padding: 8px 12px; border: 1px solid #e8ecf0; border-radius: 6px; font-size: 14px; background: #fff; cursor: pointer; }

/* 线索卡片 */
.lead-card { background: #f8f9fb; border-radius: 10px; padding: 14px 18px; margin: 8px 0; display: flex; align-items: center; gap: 16px; }
.lead-name { font-weight: 600; color: #1a1a2e; font-size: 14px; }
.lead-co { font-size: 12px; color: #8a94a6; }
.ai-lead { border-left: 4px solid #e67e22; background: #fff8f0; }

/* 主动获客 Tab 切换 */
.hunt-tabs { display: flex; gap: 8px; margin-bottom: 16px; padding: 0 0 8px; border-bottom: 1px solid #e8ecf0; }
.hunt-tab { padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: #8a94a6; background: #f8f9fb; transition: .2s; }
.hunt-tab.active { color: #4f6ef7; background: #eef2ff; }
.hunt-pane { display: none; }
.hunt-pane.active { display: block; }

/* 手动获客报告容器 */
#hunt-report { font-size: 14px; line-height: 1.8; color: #1a1a2e; }
#hunt-report h3 { margin: 16px 0 8px; color: #1a1a2e; font-size: 16px; font-weight: 700; }
#hunt-report h3:first-child { margin-top: 0; }
#hunt-report h4 { margin: 10px 0 6px; color: #4f6ef7; font-size: 14px; font-weight: 600; }
#hunt-report table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13px; }
#hunt-report li { margin: 4px 0; }
#hunt-report hr { border: none; border-top: 1px solid #e8ecf0; margin: 16px 0; }

/* 手动获客核心判断（条理化列表） */
#hunt-corejudgment.analysis-box { background: none; border-left: none; border-radius: 0; padding: 0; }
#hunt-corejudgment .cj-dim { margin: 0 0 14px; line-height: 1.8; }
#hunt-corejudgment .cj-dim b { color: #4f6ef7; }

/* 客服后台 */
.cs-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.cs-stats .cs-kpi { cursor: pointer; transition: all .15s; }
.cs-stats .cs-kpi:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.cs-stats .cs-kpi-active { outline: 3px solid #1a1a2e; outline-offset: 2px; transform: translateY(-2px); }
.cs-stats .cs-kpi.dark { background: linear-gradient(135deg, #1a1a2e, #16213e); }
.cs-stats .cs-kpi.green { background: linear-gradient(135deg, #2e7d32, #388e3c); }
.cs-stats .cs-kpi.orange { background: linear-gradient(135deg, #e65100, #ef6c00); }
.cs-stats .cs-kpi.red { background: linear-gradient(135deg, #c62828, #d32f2f); }
.cs-alert { background: #fff3e0; color: #e65100; border-radius: 10px; padding: 12px 18px; margin-bottom: 16px; font-size: 13px; border-left: 4px solid #e65100; }
.cs-layout { display: grid; grid-template-columns: 280px 1fr 260px; gap: 16px; }
.cs-list { display: flex; flex-direction: column; gap: 10px; }
.cs-item { background: #fff; border-radius: 12px; padding: 14px; border: 1px solid #e8ecf0; cursor: pointer; transition: all .15s; }
.cs-item:hover { border-color: #1a1a2e; }
.cs-item.active { border-color: #1a1a2e; background: #f8f9fb; }
.cs-item.cs-key { border-left: 4px solid #fdd835; }
.cs-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cs-item-name { font-size: 14px; font-weight: 700; color: #1a1a2e; }
.cs-item-co { font-size: 12px; color: #8a94a6; margin-bottom: 4px; }
.cs-item-intent { font-size: 12px; color: #1a1a2e; background: #f0f3f7; padding: 4px 10px; border-radius: 6px; display: inline-block; margin-bottom: 6px; }
.cs-item-last { font-size: 12px; color: #8a94a6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-status { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.cs-status.needs_human { background: #fee; color: #c62828; }
.cs-status.ai_replied { background: #e8f5e9; color: #2e7d32; }
.cs-status.human_taken { background: #e3f2fd; color: #1565c0; }

.cs-detail { background: #fff; border-radius: 14px; border: 1px solid #e8ecf0; overflow: hidden; display: flex; flex-direction: column; height: 560px; }
.cs-detail-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid #e8ecf0; background: #f8f9fb; }
.cs-detail-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.cs-chat { flex: 1; overflow-y: auto; padding: 18px; background: #f8f9fb; display: flex; flex-direction: column; gap: 12px; }
.cs-chat .chat-msg { display: flex; }
.cs-chat .chat-msg.customer { justify-content: flex-end; }
.cs-chat .chat-msg.ai { justify-content: flex-start; }
.cs-chat .bubble { max-width: 88%; padding: 10px 16px; border-radius: 14px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.cs-chat .chat-msg.customer .bubble { background: #1a1a2e; color: #fff; border-bottom-right-radius: 4px; }
.cs-chat .chat-msg.ai .bubble { background: #fff; color: #1a1a2e; border: 1px solid #e8ecf0; border-bottom-left-radius: 4px; }
.cs-actions { display: flex; gap: 10px; padding: 12px 20px; border-top: 1px solid #e8ecf0; background: #fff; }

/* 批量指令指挥台 */
.cs-command { background: #fff; border-radius: 14px; border: 1px solid #e8ecf0; padding: 16px; height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.cs-command-title { font-size: 15px; font-weight: 700; color: #1a1a2e; }
.cs-command-desc { font-size: 12px; color: #8a94a6; line-height: 1.5; }
.cs-cats { display: flex; flex-wrap: wrap; gap: 8px; }
.cs-cat { display: flex; align-items: center; gap: 8px; background: #f0f3f7; border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: all .15s; }
.cs-cat:hover { background: #e3ecf5; }
.cs-cat-name { font-size: 12px; color: #5a6270; font-weight: 600; }
.cs-cat-count { background: #1a1a2e; color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 8px; font-weight: 700; }
.cs-cmd-input { background: #f8f9fb; border-radius: 10px; padding: 12px; }
.cs-cmd-input textarea:focus { border-color: #1a1a2e; }
.cs-cmd-log { background: #f8f9fb; border-radius: 10px; padding: 12px; flex: 1; overflow-y: auto; }

@media (max-width: 1200px) {
  .cs-layout { grid-template-columns: 280px 1fr; }
  .cs-command { grid-column: 1 / -1; height: auto; max-height: 400px; }
}
@media (max-width: 900px) {
  .cs-layout { grid-template-columns: 1fr; }
  .cs-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .mod-nav { flex-wrap: wrap; }
  .mod-arrow { display: none; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .header { padding: 12px; }
  .main { padding: 16px; }
}

/* 我的诊断 */
.diag-form { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.diag-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.diag-field input { width: 100%; padding: 8px 12px; border: 1px solid #d0d5dd; border-radius: 6px; font-size: 14px; }
.diag-field input:focus { outline: none; border-color: #4f6ef7; box-shadow: 0 0 0 2px rgba(79,110,247,0.15); }
.diag-actions { display: flex; gap: 10px; align-items: center; }
.diag-report { display: none; margin-top: 16px; padding: 16px; background: #f8f9fc; border: 1px solid #e8ecf0; border-radius: 8px; max-height: 520px; overflow-y: auto; font-size: 14px; line-height: 1.7; }
.diag-report h3 { margin: 12px 0 8px; color: #1a1a2e; }
.diag-report h3:first-child { margin-top: 0; }
.diag-report h4 { margin: 8px 0 4px; color: #4f6ef7; font-size: 14px; font-weight: 600; }
.diag-report table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 13px; }
.diag-report th { background: #4f6ef7; color: #fff; padding: 6px 10px; text-align: left; }
.diag-report td { padding: 6px 10px; border-bottom: 1px solid #e8ecf0; }
.diag-report .go-yes { color: #16a34a; font-weight: 700; }
.diag-report .go-no  { color: #dc2626; font-weight: 700; }
.diag-report .go-warn { color: #d97706; font-weight: 700; }
.diag-report hr { border: none; border-top: 1px solid #e8ecf0; margin: 16px 0; }
.diag-report ul { padding-left: 20px; }
.diag-report li { margin: 4px 0; }

/* 核心判断（四维度条理化列表） */
.core-judgment { padding: 12px 16px; border-left: none; }
.cj-dim { margin: 0 0 14px; border: none; }
.cj-dim table { margin: 8px 0 16px; font-size: 12.5px; }
.cj-dim h3, .cj-dim h4 { margin: 10px 0 6px; font-size: 13.5px; }
.cj-dim ul { margin: 6px 0; padding-left: 20px; }
.cj-dim b { display: block; font-size: 15px; color: #1a1a2e; margin-bottom: 6px; }
.cj-dim b::before { content: '▍'; color: #4f6ef7; margin-right: 4px; }
.cj-list { list-style: none; padding-left: 2px; }
.cj-list li { position: relative; padding-left: 18px; margin: 5px 0; line-height: 1.6; font-size: 13.5px; color: #333; }
.cj-list li::before { content: '·'; position: absolute; left: 4px; color: #4f6ef7; font-weight: 700; }

/* 诊断记录（自动记录，标签形式） */
.diag-history { margin-top: 12px; padding: 12px 16px; background: #f0f4ff; border: 1px solid #d4dffb; border-radius: 8px; font-size: 13px; }
.diag-history-title { font-weight: 600; color: #1a1a2e; margin-bottom: 8px; }
.diag-history-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.diag-history-tag { padding: 5px 12px; background: #fff; border: 1px solid #bcc8f0; border-radius: 6px; color: #1a1a2e; cursor: pointer; transition: background .15s; white-space: nowrap; }
.diag-history-tag:hover { background: #e8eeff; border-color: #4f6ef7; }
.diag-history-clear { margin-top: 8px; background: none; border: none; color: #888; font-size: 12px; cursor: pointer; padding: 0; }
.diag-history-clear:hover { color: #dc2626; }

/* 齿轮设置按钮（标题栏最右侧） */
.btn-settings {
  margin-left: auto;
  background: none;
  border: 1px solid #e8ecf0;
  border-radius: 8px;
  width: 36px; height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.btn-settings:hover { background: #f0f4ff; border-color: #bcc8f0; }
.btn-company {
  margin-left: 0;
  background: none;
  border: 1px solid #e8ecf0;
  border-radius: 8px;
  width: 36px; height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.btn-company:hover { background: #fff8f0; border-color: #fdd835; }

/* 开发信展开区 */
[id^="email-expand-"], [id^="email-expand-fav-"] { animation: slideDown .2s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* 设置弹窗 */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8ecf0;
  font-size: 15px; font-weight: 700;
}
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer; color: #888; padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { background: #f0f4ff; color: #333; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid #e8ecf0;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #333; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid #d0d5dd; border-radius: 8px;
  font-size: 13px; outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: #4f6ef7; box-shadow: 0 0 0 3px rgba(79,110,247,0.12); }
textarea.form-input { font-family: inherit; line-height: 1.6; resize: vertical; }
.form-hint { font-size: 11px; color: #888; margin-top: 4px; line-height: 1.5; }
.form-hint a { color: #4f6ef7; }
.form-status { font-size: 12px; margin-top: 8px; min-height: 18px; }
.btn {
  padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; transition: background .15s;
}
.btn-primary { background: #4f6ef7; color: #fff; }
.btn-primary:hover { background: #3b5de7; }
.btn-secondary { background: #f0f4ff; color: #333; border: 1px solid #d0d5dd; }
.btn-secondary:hover { background: #e4eaff; }

/* 获客记录 */
#hunt-history-list .hist-item:hover { background: #f7f9fc; }
