:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f97316;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-sub: #64748b;
  --success: #16a34a;
  --sidebar-bg: #0f2540;
  --sidebar-text: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 37, 64, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }

/* ---------- 登录注册 ---------- */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f2540 0%, #1e4d8c 100%);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border-radius: 16px;
  padding: 36px 36px 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.brand-mark {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 26px; font-weight: 700;
  border-radius: 14px;
}
.brand-mark.small { width: 38px; height: 38px; font-size: 19px; margin: 0; border-radius: 10px; }
.auth-brand h1 { font-size: 23px; margin: 0 0 8px; }
.auth-brand p { margin: 0; color: var(--text-sub); font-size: 14px; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 22px; background: var(--bg); border-radius: 10px; padding: 4px; }
.auth-tab {
  flex: 1; border: 0; background: transparent;
  padding: 10px; font-size: 16px; cursor: pointer;
  border-radius: 8px; color: var(--text-sub);
}
.auth-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 7px; font-size: 14px; color: var(--text-sub); }
.auth-form input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--primary); }

.btn-primary {
  margin-top: 6px;
  padding: 13px;
  background: var(--primary);
  color: #fff; border: 0;
  font-size: 17px; font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.auth-message { min-height: 20px; color: #dc2626; font-size: 14px; text-align: center; margin: 12px 0 0; }

/* ---------- 工作台布局 ---------- */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px;
  color: #fff; font-size: 18px; font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  color: var(--sidebar-text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ico { font-size: 18px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; }
.user-meta strong { color: #fff; font-size: 15px; }
.user-meta span { color: var(--text-sub); font-size: 13px; }
.btn-logout {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--sidebar-text);
  border-radius: 9px;
  font-size: 15px;
  cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
}
.topbar h2 { margin: 0; font-size: 20px; }
.topbar-org {
  background: var(--bg); color: var(--text-sub);
  padding: 6px 14px; border-radius: 20px; font-size: 14px;
}
.content { padding: 26px 28px; flex: 1; }

/* 统计卡片：等宽等高、对齐 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
  min-height: 120px;
}
.stat-label { color: var(--text-sub); font-size: 14px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.ok { color: var(--success); font-size: 24px; }

.welcome-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.welcome-card h3 { margin: 0 0 12px; font-size: 19px; }
.welcome-card p { margin: 0; color: var(--text-sub); line-height: 1.7; }

/* 占位卡片 */
.placeholder-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
  box-shadow: var(--shadow);
}
.ph-ico { font-size: 46px; color: var(--primary); }
.placeholder-card h3 { margin: 16px 0 10px; font-size: 21px; }
.placeholder-card p { color: var(--text-sub); max-width: 560px; margin: 0 auto 20px; line-height: 1.7; }
.ph-tag {
  display: inline-block;
  background: #fff7ed; color: var(--accent);
  padding: 7px 16px; border-radius: 20px; font-size: 14px; font-weight: 600;
}

/* 响应式：窄屏统计卡片两列 */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { width: 72px; }
  .sidebar-brand span, .nav-item span:not(.nav-ico), .user-meta, .btn-logout { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
}

/* ---------- 文案营销 ---------- */
.copy-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 1.3fr;
  gap: 18px;
  margin-bottom: 22px;
  align-items: stretch;
}
.copy-form-card, .copy-result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.copy-form-card h3, .copy-result-card h3, .copy-history h3 { margin: 0 0 18px; font-size: 18px; }
.copy-form-card label { display: flex; flex-direction: column; gap: 7px; font-size: 14px; color: var(--text-sub); margin-bottom: 16px; }
.copy-form-card input, .copy-form-card select, .copy-form-card textarea {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
}
.copy-form-card input:focus, .copy-form-card select:focus, .copy-form-card textarea:focus {
  outline: none; border-color: var(--primary);
}
.copy-form-card .btn-primary { width: 100%; margin-top: 4px; }
.form-status { min-height: 20px; margin: 12px 0 0; font-size: 14px; color: var(--text-sub); }
.form-status.error { color: #dc2626; }

.result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  min-height: 320px;
  font-size: 15px;
  line-height: 1.75;
}
.result-box .result-empty { color: var(--text-sub); }
.result-content { white-space: pre-wrap; word-break: break-word; }
.result-meta { margin-top: 14px; font-size: 13px; color: var(--text-sub); }

.copy-history {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.history-item:hover { border-color: var(--primary); background: var(--bg); }
.history-item strong { font-size: 15px; }
.history-item .h-meta { color: var(--text-sub); font-size: 13px; flex-shrink: 0; }
.history-empty { color: var(--text-sub); font-size: 14px; }

@media (max-width: 900px) {
  .copy-layout { grid-template-columns: 1fr; }
}

/* ---------- 通用卡片与栅格 ---------- */
.panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel-card h3 {
  margin: 0 0 16px; font-size: 17px;
  display: flex; align-items: center; justify-content: space-between;
}
.two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.two-col .panel-card { margin-bottom: 18px; }
.btn-small {
  padding: 6px 14px; font-size: 13px; border: 1px solid var(--primary);
  background: transparent; color: var(--primary); border-radius: 8px; cursor: pointer;
}
.btn-small:hover { background: var(--primary); color: #fff; }
.insight-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; font-size: 15px; line-height: 1.8; white-space: pre-wrap;
  color: var(--text-sub); min-height: 60px;
}
.insight-box.filled { color: var(--text); }

/* 总览统计卡片：自动排满、等高 */
#dash-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px;
}
#dash-stats .stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: center; gap: 8px; min-height: 110px;
}
#dash-stats .stat-label { color: var(--text-sub); font-size: 14px; }
#dash-stats .stat-value { font-size: 30px; font-weight: 700; }
#dash-stats .stat-value.ok { color: #16a34a; }

/* ---------- 表单 ---------- */
.panel-card form { display: flex; flex-direction: column; gap: 12px; }
.panel-card input, .panel-card select {
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 15px; font-family: inherit; color: var(--text); width: 100%;
}
.panel-card input:focus, .panel-card select:focus { outline: none; border-color: var(--primary); }

/* ---------- AI 销售 ---------- */
.sales-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 18px; height: calc(100vh - 170px); min-height: 480px;
}
.sales-sessions, .sales-chat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.sales-sessions { padding: 20px; }
.sales-sessions h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; font-size: 16px; }
.sales-session-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.sales-session-item {
  border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; cursor: pointer; font-size: 14px;
}
.sales-session-item.active, .sales-session-item:hover { border-color: var(--primary); background: var(--bg); }
.sales-session-item small { color: var(--text-sub); display: block; margin-top: 3px; }
.sales-chat { padding: 0; }
.sales-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 72%; padding: 11px 15px; border-radius: 14px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.sales-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }
.sales-input input { flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; }
.sales-input .btn-primary { white-space: nowrap; }

/* ---------- 列表条目 ---------- */
.lead-list, .customer-list, .supplier-list, .compare-list, .intel-list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 15px;
}
.list-item:hover { background: var(--bg); }
.list-item .li-main { display: flex; flex-direction: column; gap: 4px; }
.list-item .li-sub { color: var(--text-sub); font-size: 13px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.hot { background: #fee2e2; color: #dc2626; }
.badge.warm { background: #fef3c7; color: #d97706; }
.badge.cold { background: #e0e7ff; color: #4f46e5; }
.badge.verified { background: #dcfce7; color: #16a34a; }
.list-empty { color: var(--text-sub); font-size: 14px; padding: 8px 0; }
a.li-link { color: var(--primary); text-decoration: none; font-size: 14px; }

/* ---------- 图表（纯CSS条形） ---------- */
.chart { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 12px; font-size: 14px; }
.bar-track { background: var(--bg); border-radius: 8px; height: 26px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #6ea8fe); border-radius: 8px; }
.bar-num { text-align: right; font-weight: 600; }

/* ---------- 情报筛选 ---------- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-btn {
  padding: 8px 18px; border: 1px solid var(--border); background: var(--card);
  border-radius: 20px; cursor: pointer; font-size: 14px;
}
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.intel-meta { color: var(--text-sub); font-size: 13px; }

/* ---------- 设置 ---------- */
.setting-line { font-size: 15px; margin: 0 0 10px; }
.setting-note { color: var(--text-sub); font-size: 14px; line-height: 1.7; margin: 6px 0 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .two-col { grid-template-columns: 1fr; }
  #dash-stats { grid-template-columns: repeat(2, 1fr); }
  .sales-layout { grid-template-columns: 1fr; height: auto; }
}
@media (max-width: 640px) {
  #dash-stats { grid-template-columns: 1fr; }
}
