:root {
  --bg: #eef1f5;
  --panel: #fff;
  --line: #e2e8f0;
  --text: #1e293b;
  --dim: #64748b;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --blue: #3b82f6;
  --blue-soft: #eff6ff;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: #1e293b; color: #fff;
}
.topbar h1 { margin: 0; font-size: 15px; }
.sub { margin: 2px 0 0; font-size: 11px; color: #94a3b8; }
.logo { font-size: 22px; }
.brand { display: flex; align-items: center; gap: 10px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.mode-label { font-size: 12px; color: #cbd5e1; display: flex; align-items: center; gap: 6px; }
.mode-sel {
  font-size: 12px; border-radius: 8px; padding: 5px 8px; border: 1px solid #475569;
  background: #0f172a; color: #e2e8f0; cursor: pointer; outline: none;
}
.badge { font-size: 11px; padding: 4px 10px; border-radius: 999px; background: #334155; color: #cbd5e1; }
.badge.ok { background: #14532d; color: #86efac; }
.ghost {
  border: 1px solid var(--line); background: #fff; color: var(--dim);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.ghost:hover { background: #f8fafc; }

/* ---------- 三栏主布局 ---------- */
.wb {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 430px;
  gap: 10px; padding: 10px;
}
.col {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.col-title {
  font-size: 13px; font-weight: 700; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.search {
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px;
  font-size: 12px; width: 130px; outline: none;
}
.dim { color: var(--dim); font-size: 12px; }
.hint { color: var(--dim); font-weight: 400; font-size: 11px; }

/* ---------- 左栏会话列表 ---------- */
.session-list { flex: 1; overflow-y: auto; padding: 6px; }
.s-item {
  border: 1px solid transparent; border-radius: 10px; padding: 8px 10px;
  cursor: pointer; margin-bottom: 4px;
}
.s-item:hover { background: #f8fafc; }
.s-item.active { background: var(--brand-soft); border-color: #c7d2fe; }
.s-top { display: flex; align-items: center; gap: 6px; }
.s-buyer { font-size: 13px; font-weight: 600; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.risk-dot.low { background: #bbf7d0; }
.risk-dot.mid { background: #fcd34d; }
.risk-dot.high { background: #f87171; }
.s-scene { font-size: 11px; color: var(--dim); margin-top: 2px; }
.s-text {
  font-size: 11px; color: var(--dim); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.s-time { margin-left: auto; font-size: 10px; color: #94a3b8; }

/* ---------- 中栏 ---------- */
.mid-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px 6px;
}
.buyer { font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; background: #f1f5f9; border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px; color: #475569;
}
.chip.scene { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }

/* 顶部商品卡 */
.goods-bar {
  display: flex; gap: 8px; padding: 0 14px 8px; overflow-x: auto; flex: 0 0 auto;
}
.goods-card {
  border: 1px solid #dbeafe; background: #f0f7ff; border-radius: 10px;
  padding: 8px 10px; min-width: 250px; flex: 1;
}
.goods-name { font-size: 12px; font-weight: 600; line-height: 1.4; }
.goods-sub { font-size: 11px; color: var(--dim); margin-top: 3px; line-height: 1.5; }
.goods-tag {
  display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 999px;
  background: #dbeafe; color: #1d4ed8; margin-top: 4px;
}
.goods-tag.paying { background: #fef3c7; color: #b45309; }
.goods-tag.warn { background: #fee2e2; color: #b91c1c; }

/* 聊天区 */
.chat { flex: 1; overflow-y: auto; padding: 8px 14px; background: #f8fafc; }
.msg-row { display: flex; margin: 8px 0; }
.msg-row.agent { justify-content: flex-end; }
.msg-bubble { max-width: 82%; }
.bubble {
  padding: 8px 11px; border-radius: 10px; font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; position: relative;
}
.msg-row.buyer .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg-row.agent .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 3px; }
.msg-time { font-size: 10px; color: #94a3b8; margin: 2px 6px 0; }
.msg-row.agent .msg-time { text-align: right; }
.msg-img { font-size: 11px; color: #64748b; margin-top: 3px; }
.emo-pill {
  display: inline-block; font-size: 10px; font-weight: 600; margin-top: 4px;
  padding: 1px 8px; border-radius: 999px; cursor: pointer; border: 1px solid transparent;
}
.emo-pill:hover { border-color: currentColor; }

/* 输入区 */
.input-row { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; font: inherit; font-size: 13px; outline: none;
}
.input-row textarea:focus { border-color: var(--blue); }
.input-btns { display: flex; flex-direction: column; gap: 6px; }
.primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 10px;
  padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.primary:hover { background: #2563eb; }

/* ---------- 右栏 ---------- */
.right-title { align-items: flex-start; flex-direction: column; gap: 6px; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; font-size: 12px; color: var(--dim);
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
}
.tab.active { background: var(--brand); color: #fff; font-weight: 600; }
.tab-body { flex: 1; overflow-y: auto; padding: 10px 12px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.empty { color: var(--dim); font-size: 12px; text-align: center; padding: 40px 12px; line-height: 1.8; }

/* 风险横幅 */
.risk-hint { font-size: 12px; padding: 8px 11px; border-radius: 9px; margin-bottom: 8px; line-height: 1.6; }
.risk-hint.low { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.risk-hint.mid { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.risk-hint.high { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }

/* 洞察 */
.insight-msg {
  background: #f8fafc; border-left: 3px solid var(--brand); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: #334155; margin-bottom: 8px; line-height: 1.6;
}
.emo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.emo-chip { font-size: 18px; font-weight: 700; padding: 5px 13px; border-radius: 9px; }
.metric { font-size: 12px; color: var(--dim); }
.metric b { color: var(--text); font-size: 14px; }
.mini-badges { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.mini-badge {
  font-size: 10px; font-weight: 600; border-radius: 999px; padding: 2px 8px;
  background: #fff1f2; color: #be123c;
}
.mini-badge.ghost-b { background: #ede9fe; color: #6d28d9; }
.bar { height: 7px; background: #eef1f6; border-radius: 999px; margin: 8px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #818cf8, var(--brand)); transition: width .4s; }
.level-row { margin: 8px 0 2px; display: flex; align-items: center; gap: 8px; }
.level-badge { font-size: 12px; font-weight: 700; padding: 3px 11px; border-radius: 999px; }
.ai-insight { background: #fffbeb; border: 1px solid #fde68a; border-radius: 9px; padding: 8px 10px; margin: 8px 0 2px; font-size: 12px; line-height: 1.7; color: #78350f; }
.ai-insight b { color: #b45309; }
.ai-insight .row { display: block; margin-bottom: 4px; }
.sec { font-size: 12px; color: var(--dim); margin: 12px 0 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 11px; background: var(--brand-soft); color: var(--brand); border-radius: 8px; padding: 3px 9px; font-weight: 600; }
.sug {
  border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 9px;
  padding: 8px 10px; margin-bottom: 8px; background: #fafbff;
}
.sug p { margin: 0 0 6px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.insert {
  font-size: 11px; border: 1px solid var(--blue); color: var(--blue); background: #fff;
  border-radius: 8px; padding: 3px 11px; cursor: pointer;
}
.insert.done { border-color: #16a34a; color: #16a34a; }
.meta { font-size: 11px; color: var(--dim); margin: 8px 0 4px; line-height: 1.7; word-break: break-all; }
.deep-btn { width: 100%; margin-top: 6px; }

/* 画像 */
.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.p-head { display: flex; flex-direction: column; gap: 8px; }
.p-stats { font-size: 12px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.p-stats b { color: var(--text); }
.goods-list { max-height: 340px; overflow-y: auto; }
.g-item {
  display: flex; justify-content: space-between; gap: 8px; font-size: 12px;
  border-bottom: 1px dashed var(--line); padding: 6px 2px;
}
.g-item .l { flex: 1; }
.g-item .st { color: var(--dim); font-size: 11px; }

/* 工单/轨迹 */
.wt-item {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px;
  border-left-width: 3px; font-size: 12px;
}
.wt-item.open { border-left-color: #f59e0b; background: #fffbeb; }
.wt-item.done { border-left-color: #16a34a; }
.wt-item.high { border-left-color: #ef4444; background: #fef2f2; }
.wt-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wt-type { font-weight: 700; }
.wt-status { font-size: 10px; padding: 1px 8px; border-radius: 999px; background: #f1f5f9; color: var(--dim); }
.wt-status.open { background: #fef3c7; color: #b45309; }
.wt-status.done { background: #dcfce7; color: #15803d; }
.wt-note { color: var(--dim); margin-top: 4px; line-height: 1.5; }
.wt-note b { color: #334155; }
.tl-list { position: relative; padding-left: 6px; }
.tl-item { display: flex; gap: 8px; font-size: 12px; margin-bottom: 8px; }
.tl-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px;
  background: var(--brand); }
.tl-item.chat .tl-dot { background: #94a3b8; }
.tl-item.wt .tl-dot { background: #f59e0b; }
.tl-body .tl-time { font-size: 10px; color: #94a3b8; }
.tl-body .tl-text { color: #334155; line-height: 1.5; }
