:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #8a94a6;
  --line: #e6e9ef;
  --brand: #1f6feb;
  --brand-ink: #fff;
  --ok: #1aa971;
  --warn: #e0a106;
  --danger: #d8453b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---- 顶栏 ---- */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand { font-weight: 700; font-size: 16px; }
.brand .tag {
  font-size: 11px; color: var(--muted); font-weight: 400;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; margin-left: 6px;
}
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.userbox .who { color: var(--muted); }
.btn-link { color: var(--brand); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

/* ---- 布局 ---- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 224px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 12px 0; flex-shrink: 0;
}
.nav-group {
  padding: 14px 18px 5px; color: var(--muted); font-size: 11px;
  font-weight: 700; letter-spacing: .06em;
}
.nav-group:first-child { padding-top: 5px; }.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 18px; font-size: 14px; color: var(--ink); text-decoration: none;
}
.nav-link:hover { background: #f0f3f8; }
.nav-link.active { background: #eaf1ff; color: var(--brand); font-weight: 600;
  border-left: 3px solid var(--brand); padding-left: 15px; }
.nav-link.disabled { color: var(--muted); cursor: default; }
.nav-link.disabled:hover { background: transparent; }
.nav-link .phase {
  font-style: normal; font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 3px; padding: 0 5px;
}
.content { flex: 1; padding: 24px 28px; max-width: 1000px; }

/* ---- 文本 ---- */
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 26px 0 10px; color: #46506a; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- flash ---- */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.flash.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c2bd; }
.flash.success { background: #e8f7f0; color: var(--ok); border: 1px solid #b9e6d2; }

/* ---- 看板卡片 ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 18px;
}
.card .num { font-size: 26px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- 预算 ---- */
.budgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.budget { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.budget-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.budget .scope { font-weight: 600; }
.bar { height: 8px; background: #eef1f6; border-radius: 5px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--ok); }
.bar .fill.warn { background: var(--warn); }

/* ---- roadmap ---- */
.roadmap { list-style: none; padding: 0; margin: 0; }
.roadmap li {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  margin-bottom: 6px; background: var(--panel); font-size: 14px; color: #46506a;
}
.roadmap .done { font-weight: 700; color: var(--ink); }

/* ---- 登录 ---- */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 30px 32px; width: 320px; box-shadow: 0 8px 30px rgba(20,30,60,0.06);
}
.login-card h1 { font-size: 19px; }
.login-card form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { font-size: 13px; color: #46506a; display: flex; flex-direction: column; gap: 6px; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-card button {
  margin-top: 6px; padding: 11px; border: 0; border-radius: 6px;
  background: var(--brand); color: var(--brand-ink); font-size: 15px; cursor: pointer;
}
.login-card button:hover { background: #1a5fd0; }

/* ============================================================
   P1 新增：按钮、表格、状态徽章、筛选栏、表单、详情页
   ============================================================ */

/* ---- 按钮 ---- */
.btn {
  display: inline-block; padding: 7px 16px;
  background: var(--brand); color: var(--brand-ink);
  border: 1px solid var(--brand); border-radius: 6px;
  font-size: 13px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #1a5fd0; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #bd3a32; }
.btn-link.sm { font-size: 12px; border:0; background:none; cursor:pointer; padding:0; }

/* ---- 数据表格 ---- */
.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.data-table th {
  text-align: left; font-size: 12px; color: var(--muted);
  padding: 8px 10px; border-bottom: 2px solid var(--line); font-weight: 600;
}
.data-table td {
  padding: 10px 10px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.data-table tr:hover td { background: #f9fafb; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #f0f4fc; }

/* ---- 徽章 ---- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
  background: #eef1f6; color: #46506a;
}
.badge.ok { background: #e8f7f0; color: var(--ok); }
.badge.muted { background: #eef1f6; color: var(--muted); }
.badge.danger { background: #fdecea; color: var(--danger); }

/* ---- 状态徽章 ---- */
.status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 12px; font-weight: 600;
}
.status-badge.new { background: #eef1f6; color: #46506a; }
.status-badge.scored { background: #e8f0ff; color: #1f6feb; }
.status-badge.reviewing { background: #fff7e5; color: #c47f00; }
.status-badge.qualified { background: #e8f7f0; color: var(--ok); }
.status-badge.contacted { background: #f0e8ff; color: #6b3fc4; }
.status-badge.replied { background: #dff0f7; color: #2a7ca8; }
.status-badge.rejected { background: #fdecea; color: var(--danger); }

/* ---- 评分颜色 ---- */
.score { font-variant-numeric: tabular-nums; }
.score.high { color: var(--ok); }
.score.mid { color: var(--warn); }
.score.low { color: var(--muted); }

/* ---- 筛选栏 ---- */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 16px 0 8px;
}
.filter-bar select, .filter-bar input {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: var(--panel);
}
.filter-bar select:focus, .filter-bar input:focus {
  outline: none; border-color: var(--brand);
}

/* ---- 分页 ---- */
.pagination {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding: 10px 0;
}

/* ---- 编辑表单 ---- */
.edit-form { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.edit-form label { font-size: 13px; color: #46506a; display: flex; flex-direction: column; gap: 4px; }
.edit-form input, .edit-form select, .edit-form textarea {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; font-family: "Consolas", "Courier New", monospace;
}
.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus {
  outline: none; border-color: var(--brand);
}
.edit-form textarea { resize: vertical; line-height: 1.4; tab-size: 2; }
.form-actions { display: flex; gap: 12px; align-items: center; }
.help-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; background: var(--panel); }
.help-code { font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }

/* ---- 详情页 ---- */
.detail-grid { margin: 16px 0; }
.detail-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.detail-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table td { padding: 5px 0; font-size: 14px; vertical-align: top; }
.kv-table .kv-k { color: var(--muted); width: 100px; font-size: 13px; }
.status-actions { margin: 16px 0; }
.raw-data { font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
  background: #f8f9fb; padding: 12px; border-radius: 6px; max-height: 300px; overflow-y: auto; }

/* ---- 空状态 ---- */
.empty-state {
  padding: 40px 0; text-align: center; color: var(--muted);
  border: 2px dashed var(--line); border-radius: 10px; margin-top: 16px;
}
/* ---- 简化业务线与系统设置 ---- */
.advanced-options { margin-top: 4px; }
.advanced-options summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.advanced-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.settings-form { max-width: 720px; }
.setting-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.setting-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.setting-head h2 { margin: 0 0 4px; }
.setting-head p { margin: 0; }
.inline-check { flex-direction: row !important; align-items: center; margin-top: 10px; }
.inline-check input { width: auto; }
.settings-note { margin-top: 20px; max-width: 720px; }
.settings-note p { margin-bottom: 0; }
/* ---- 搜索计划与深度网站调研 ---- */
.engine-create-grid { align-items: start; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestion-chip { border: 1px solid #cbd8ee; background: #f5f8ff; color: #245aab; border-radius: 14px; padding: 4px 9px; font-size: 12px; cursor: pointer; }
.suggestion-chip:hover { background: #eaf1ff; }
.workflow-note { padding: 12px; border-radius: 7px; background: #f5f8ff; border: 1px solid #dce7f8; }
.table-scroll { overflow-x: auto; }
.research-report { margin: 16px 0; }
.fit-badge { padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.fit-badge.high { background: #e8f7f0; color: var(--ok); }
.fit-badge.medium { background: #fff7e5; color: #b57600; }
.fit-badge.low { background: #fdecea; color: var(--danger); }
.report-grid { display: grid; grid-template-columns: 140px 140px 1fr; gap: 12px; margin: 14px 0; }
.report-grid > div { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: #f8f9fb; border-radius: 6px; }
@media (max-width: 760px) { .report-grid { grid-template-columns: 1fr; } }

/* ---- DeepSeek 公司调研报告 ---- */
.ai-report { border-top: 4px solid var(--primary); }
.ai-overview { margin: 12px 0 18px; font-size: 16px; line-height: 1.75; color: var(--text); }
.ai-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.ai-meta-grid > div { display: flex; flex-direction: column; gap: 5px; padding: 12px; background: #f5f8ff; border-radius: 8px; }
.ai-report-section { padding: 14px 0; border-top: 1px solid var(--line); }
.ai-report-section h3 { margin: 0 0 8px; font-size: 15px; }
.ai-report-section p { margin: 0; line-height: 1.7; }
.ai-report-section.emphasized { margin: 6px 0; padding: 14px; border: 1px solid #d7e4f8; border-radius: 8px; background: #f6f9ff; }
.ai-report-section.warning { margin: 6px 0; padding: 14px; border: 1px solid #f1d9a8; border-radius: 8px; background: #fffaf0; }
.ai-list, .ai-evidence { margin: 0; padding-left: 20px; }
.ai-list li, .ai-evidence li { margin: 6px 0; line-height: 1.6; }
.ai-warning { border-left: 4px solid #d99a22; }
.rule-report-details { margin: 0 0 16px; }
@media (max-width: 760px) { .ai-meta-grid { grid-template-columns: 1fr; } .ai-report { padding: 18px; } }