/* 仓选 · 闪电仓智能选品 Agent —— Demo UI（v2：Agent Loop / 回环修复 / 问人 / 双口径） */
:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #1a1d2e;
  --ink-2: #555b74;
  --ink-3: #8b90a8;
  --line: #e6e8f2;
  --accent: #5b5bd6;
  --accent-2: #7c5bd6;
  --accent-soft: #eeeefc;
  --ok: #12996b;
  --ok-soft: #e5f7ef;
  --warn: #c2410c;
  --warn-soft: #fef3e7;
  --danger: #d92d20;
  --danger-soft: #fee4e2;
  --role-traffic: #2e90fa;
  --role-profit: #12b76a;
  --role-test: #f79009;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 26, 43, .05), 0 8px 24px -12px rgba(23, 26, 43, .12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---------- 顶部 ---------- */
.topbar {
  background: linear-gradient(120deg, #3535a2 0%, #5b5bd6 55%, #7c5bd6 100%);
  color: #fff;
  padding: 26px 0 30px;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; backdrop-filter: blur(4px);
}
.brand h1 { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.brand p { font-size: 13px; opacity: .85; margin-top: 2px; }
.mode-chip {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3);
  padding: 6px 14px; border-radius: 999px; font-size: 12.5px; backdrop-filter: blur(4px);
}
.mode-chip.mock { background: #fdf6e3; color: #9a6700; border-color: #f0d48a; }
.mode-chip.real { background: #e5f7ef; color: #0b7a53; border-color: #9fe3c5; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 26px auto 60px; padding: 0 24px; display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.card-head h2 { font-size: 16.5px; font-weight: 700; }
.card-head h2::before { content: "▪"; color: var(--accent); margin-right: 8px; }

/* ---------- 表单 ---------- */
.quick-scenes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quick-label { font-size: 12.5px; color: var(--ink-3); }
.chip {
  border: 1px solid var(--line); background: #fafbff; color: var(--ink-2);
  padding: 5px 13px; border-radius: 999px; font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span2 { grid-column: span 2; }
.field.span4, .form-meta { grid-column: span 4; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.field label em { color: var(--danger); font-style: normal; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-size: 14px; color: var(--ink); background: #fff; outline: none;
  transition: border .15s, box-shadow .15s; font-family: inherit;
}
.field input:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,91,214,.12);
}
.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: 12px;
  padding: 12px 20px; font-size: 15px; font-weight: 700; cursor: pointer;
  letter-spacing: 1px; transition: transform .1s, box-shadow .15s, opacity .15s;
  box-shadow: 0 8px 20px -8px rgba(91,91,214,.55);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.form-meta { font-size: 12px; color: var(--ink-3); margin-top: -4px; }

/* ---------- 商圈识别确认面板 ---------- */
.district-hint { font-weight: 400; color: var(--ink-3); margin-left: 8px; font-size: 12px; }
.district-panel {
  display: flex; flex-direction: column; gap: 10px;
  border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fbfbff;
}
.district-panel.locked { border-style: solid; border-color: #9fe3c5; background: #f6fefb; }
.district-panel.stale { border-color: #f0d48a; background: #fffdf5; }
.detect-btn {
  align-self: flex-start; border: 1px solid var(--accent); color: var(--accent);
  background: #fff; border-radius: 10px; padding: 8px 16px; font-size: 13.5px;
  font-weight: 700; cursor: pointer; transition: all .15s;
}
.detect-btn:hover { background: var(--accent-soft); }
.detect-btn:disabled { opacity: .55; cursor: wait; }
.district-evidence { font-size: 13px; color: var(--ink-2); }
.district-evidence b { color: var(--accent); font-size: 15px; }
.district-locked { color: var(--ok); font-weight: 700; }
.district-stale-tip { color: #9a6700; font-size: 12px; }
.method-tag {
  font-size: 11px; border: 1px solid #ddd6fe; color: #6d28d9; background: #f5f3ff;
  border-radius: 6px; padding: 1px 7px; margin-left: 6px; font-weight: 600;
}
.district-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.district-pill {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 6px 18px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  font-weight: 600; transition: all .15s;
}
.district-pill:hover { border-color: var(--accent); color: var(--accent); }
.district-pill.on {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 4px 12px -4px rgba(91,91,214,.5);
}

/* ---------- 工作流步骤（含轮次分隔） ---------- */
.process-hint { font-size: 12.5px; color: var(--ink-3); }
.steps { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.round-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; color: var(--ink-3); margin: 10px 0 4px; font-weight: 700;
}
.round-divider::before, .round-divider::after {
  content: ""; height: 1px; background: var(--line); flex: 1;
}
.step {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px; border-radius: 10px; transition: background .2s;
}
.step.running { background: var(--accent-soft); }
.step.failed { background: var(--danger-soft); }
.step.skipped { opacity: .62; }
.step-icon {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; margin-top: 2px;
  background: var(--line); color: var(--ink-3);
}
.step.running .step-icon { background: #fff; color: var(--accent); }
.step.done .step-icon { background: var(--ok-soft); color: var(--ok); }
.step.failed .step-icon { background: #fff; color: var(--danger); }
.spinner {
  width: 14px; height: 14px; border: 2px solid #d5d5f5; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.step-body { flex: 1; min-width: 0; }
.step-name { font-size: 14px; font-weight: 600; }
.step.running .step-name { color: var(--accent); }
.step.failed .step-name { color: var(--danger); }
.step-detail { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; word-break: break-all; }
.step-ms { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; margin-left: 8px; }
.llm-usage { margin-top: 10px; font-size: 12px; color: var(--ink-3); border-top: 1px dashed var(--line); padding-top: 8px; }

/* ---------- 节点类型徽章（LLM / 代码，对应 PRD 系统流程图标注） ---------- */
.node-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  vertical-align: 1px; line-height: 1.5;
}
.node-badge.llm { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
.node-badge.llm.sim { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }
.node-badge.code { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }

/* ---------- 回环修复日志卡 ---------- */
.side-head { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.side-head .repair-sub { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 10px; }
.repair-card {
  margin-top: 14px; background: #fffaf2; border: 1px solid #f6d5b8;
  border-radius: 12px; padding: 12px 16px;
}
.repair-body { display: flex; flex-direction: column; gap: 8px; }
.repair-group { border-left: 3px solid #f0b36a; padding-left: 12px; }
.repair-round { font-size: 12px; font-weight: 700; color: #b45309; }
.repair-line { font-size: 12.5px; color: #7a3e10; margin: 1px 0; }

/* ---------- 问人卡（ask 状态） ---------- */
.ask-card {
  background: linear-gradient(135deg, #fff7ed, #fef3e7);
  border: 1px solid #f5c98a; border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow);
}
.ask-head { font-size: 16px; font-weight: 800; color: #92400e; margin-bottom: 8px; }
.ask-tag {
  font-size: 11.5px; font-weight: 600; color: #fff; background: #d97706;
  border-radius: 999px; padding: 2px 10px; margin-left: 8px; vertical-align: 2px;
}
.ask-msg { font-size: 14px; color: #7c3a0e; white-space: pre-wrap; }
.ask-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.ask-chip {
  background: #fff; border: 1.5px solid #f0b36a; color: #92400e;
  padding: 8px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: all .15s;
}
.ask-chip:hover { background: #92400e; color: #fff; border-color: #92400e; }
.ask-ref { margin-top: 14px; }
.ask-ref summary {
  cursor: pointer; font-size: 12.5px; color: #92400e; font-weight: 600;
  user-select: none;
}
.ask-ref-text {
  margin-top: 8px; font-size: 12.5px; color: #7c3a0e; line-height: 1.9;
  max-height: 130px; overflow-y: auto; background: rgba(255,255,255,.6);
  border-radius: 8px; padding: 8px 12px;
}

/* ---------- 横幅（调整识别 / 检索降级） ---------- */
.adjust-banner {
  background: linear-gradient(120deg, #fff8ed, #fdf3e7);
  border: 1px solid #f5d9ab; color: #92400e;
  border-radius: 12px; padding: 12px 18px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.adjust-icon {
  width: 26px; height: 26px; border-radius: 8px; background: #f5d9ab;
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: #92400e;
  flex: none;
}
.degrade-banner {
  background: var(--warn-soft); border: 1px solid #f6d5b8; color: #92400e;
  border-radius: 12px; padding: 12px 18px; font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.degrade-banner .adjust-icon { background: #f6d5b8; }

/* ---------- AI 来源标注 ---------- */
.ai-tag {
  font-size: 12px; color: #6d28d9; background: #f5f3ff;
  border: 1px solid #ddd6fe; border-radius: 999px; padding: 3px 10px;
}
.ai-tag-mini { font-size: 11px; color: #6d28d9; cursor: help; }

/* ---------- 策略 ---------- */
.strategy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.strategy-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: #fbfbff;
}
.strategy-card.span3 { grid-column: span 3; }
.strategy-label { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-bottom: 8px; letter-spacing: .5px; }
.strategy-label.secondary { margin-top: 14px; }
.strategy-value { font-size: 22px; font-weight: 800; color: var(--accent); }
.strategy-text { font-size: 13.5px; color: var(--ink-2); white-space: pre-wrap; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600;
}
.direction-list { display: flex; flex-direction: column; gap: 6px; }
.direction-item { display: flex; gap: 8px; font-size: 13px; align-items: baseline; flex-wrap: wrap; }
.direction-cat { font-weight: 700; min-width: 64px; }
.role-pill { font-size: 11.5px; border-radius: 999px; padding: 1px 9px; font-weight: 700; white-space: nowrap; }
.role-引流品 { background: #eaf3ff; color: var(--role-traffic); }
.role-利润品 { background: #e6f8ef; color: var(--role-profit); }
.role-测试品 { background: #fef4e6; color: var(--role-test); }
.direction-reason { color: var(--ink-3); font-size: 12.5px; }

/* 双口径金字塔条 */
.struct-bar-wrap { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.struct-bar { display: flex; height: 30px; border-radius: 9px; overflow: hidden; margin-top: 8px; }
.struct-bar.slim { height: 20px; opacity: .85; }
.struct-seg {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12.5px; font-weight: 700; min-width: 52px;
  transition: width .5s ease;
}
.struct-bar.slim .struct-seg { font-size: 11px; min-width: 40px; }
.seg-引流品 { background: var(--role-traffic); }
.seg-利润品 { background: var(--role-profit); }
.seg-测试品 { background: var(--role-test); }
.struct-legend { display: flex; gap: 18px; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.drift-ok { color: var(--ok); font-weight: 700; }
.drift-bad { color: var(--danger); font-weight: 700; }

/* ---------- 指标 ---------- */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: linear-gradient(180deg, #fbfbff, #fff);
}
.metric-label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.metric-value { font-size: 21px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.metric-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.metric.ok .metric-value { color: var(--ok); }
.metric.bad .metric-value { color: var(--danger); }
.main-tag {
  font-size: 10px; background: var(--accent); color: #fff;
  border-radius: 4px; padding: 0 5px; vertical-align: 2px; margin-left: 3px;
}
.ref-tag {
  display: inline-block; background: #fff7e6; border: 1px solid #ffe1a8;
  color: #92600a; font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 8px;
}
.disclaimer { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- Critique 检查卡 ---------- */
.critique-card {
  margin-top: 14px; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; background: #fbfcff;
}
.checks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.check {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  border-radius: 9px; padding: 8px 12px; background: #fff; border: 1px solid var(--line);
}
.check-icon {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.check.pass .check-icon { background: var(--ok-soft); color: var(--ok); }
.check.fail { background: var(--danger-soft); border-color: #f9b4ae; }
.check.fail .check-icon { background: #fff; color: var(--danger); }
.check-name { font-weight: 700; white-space: nowrap; }
.check-detail { color: var(--ink-3); font-size: 12px; }

/* ---------- SKU 表格 ---------- */
.sku-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.role-tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 9px; padding: 5px 14px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.export-btn {
  border: 1px solid var(--accent); color: #fff; background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-radius: 9px; padding: 6px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform .1s;
}
.export-btn:hover { transform: translateY(-1px); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.sku-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 980px; }
.sku-table th {
  background: #f7f8fd; color: var(--ink-2); font-weight: 700;
  padding: 10px 10px; text-align: left; white-space: nowrap; position: sticky; top: 0;
  border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.sku-table td { padding: 9px 10px; border-bottom: 1px solid #f0f1f8; vertical-align: top; }
.sku-table tr:last-child td { border-bottom: none; }
.sku-table tr:hover td { background: #fafbff; }
.sku-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sku-name { font-weight: 600; max-width: 210px; }
.sku-spec { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
.sku-cat { color: var(--ink-2); white-space: nowrap; }
.sku-reason { color: var(--ink-2); max-width: 260px; font-size: 12.5px; }
.frozen-mark { color: #2e90fa; margin-left: 4px; cursor: help; }
.table-note { margin-top: 10px; font-size: 12px; color: var(--ink-3); }

/* ---------- 对话调整 ---------- */
.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 320px; overflow-y: auto; }
.chat-msg { max-width: 80%; border-radius: 12px; padding: 9px 14px; font-size: 13.5px; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.agent { align-self: flex-start; background: #f2f3fa; color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.agent.intent { background: #f5f3ff; color: #6d28d9; font-size: 12.5px; }
.chat-examples { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chat-examples span { font-size: 12.5px; color: var(--ink-3); }
.chat-input-row { display: flex; gap: 10px; }
.chat-input-row input {
  flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px;
  font-size: 14px; outline: none; font-family: inherit;
}
.chat-input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,91,214,.12); }
.chat-input-row .btn-primary { padding: 11px 26px; }

/* ---------- 警告 ---------- */
.warnings { margin-left: 18px; }
.warnings li { font-size: 13px; color: var(--warn); margin: 4px 0; }

/* ---------- 评分弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23, 26, 43, .45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; padding: 26px 28px; width: min(420px, 92vw);
  box-shadow: 0 24px 60px -20px rgba(23,26,43,.4);
}
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.stars { display: flex; gap: 6px; margin-bottom: 14px; }
.star {
  border: none; background: none; font-size: 30px; color: #d9dbe9;
  cursor: pointer; transition: color .12s, transform .12s; line-height: 1;
}
.star:hover { transform: scale(1.15); }
.star.on { color: #f5a623; }
.modal textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-size: 13.5px; font-family: inherit; outline: none; resize: vertical; min-height: 70px;
}
.modal textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.btn-ghost {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 10px; padding: 9px 18px; font-size: 13.5px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--ink-3); }

/* ---------- 其他 ---------- */
.footer { text-align: center; padding: 26px 20px 40px; color: var(--ink-3); font-size: 12.5px; }
.footer p { margin: 3px 0; }
.footer .arch-line { color: var(--ink-2); }
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 99;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 880px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field.span2 { grid-column: span 2; }
  .field.span4, .form-meta { grid-column: span 2; }
  .strategy-grid { grid-template-columns: 1fr 1fr; }
  .strategy-card.span3 { grid-column: span 2; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .checks-grid { grid-template-columns: 1fr 1fr; }
  .brand h1 { font-size: 17px; }
}
@media (max-width: 560px) {
  .form-grid, .strategy-grid, .metrics-grid, .checks-grid { grid-template-columns: 1fr; }
  .field.span2, .field.span4, .form-meta, .strategy-card.span3 { grid-column: span 1; }
}
