:root{font-family:Inter,"Microsoft YaHei",Arial,sans-serif;color:#172033;background:#f5f7fb}*{box-sizing:border-box}body{margin:0}header{height:82px;padding:14px 24px;background:#fff;border-bottom:1px solid #e5e9f2;display:flex;align-items:center;justify-content:space-between}h1{font-size:22px;margin:0 0 4px}header p{margin:0;color:#718096;font-size:13px}.badge{padding:8px 12px;border-radius:999px;background:#edf2f7;font-size:13px}.badge.ok{background:#e8f7ef;color:#177245}.badge.warn{background:#fff6df;color:#9a6700}.card{background:#fff;border:1px solid #e6eaf0;border-radius:12px;box-shadow:0 3px 14px rgba(21,32,51,.04)}main{padding:16px}.topbar{min-height:60px;padding:12px 16px;display:flex;gap:24px;align-items:center}button{border:0;border-radius:8px;background:#1f6feb;color:white;padding:10px 15px;cursor:pointer;font-weight:600}button.secondary{background:#eef2f7;color:#26364a}.switchrow{margin-left:auto;display:flex;gap:8px;align-items:center}.workspace{display:grid;grid-template-columns:300px minmax(480px,1fr) 320px;gap:14px;margin-top:14px;height:calc(100vh - 190px)}.sidebar,.events{overflow:auto}.section-title,.chat-head{padding:14px 16px;border-bottom:1px solid #eef1f5;font-weight:700}.conversation{padding:12px 14px;border-bottom:1px solid #f0f2f6;cursor:pointer}.conversation:hover,.conversation.active{background:#f4f8ff}.conversation .peer{font-weight:700;font-size:14px}.conversation .preview{font-size:12px;color:#718096;margin-top:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat{display:flex;flex-direction:column;min-width:0}.messages{flex:1;overflow:auto;padding:18px;background:#f9fbfd}.bubble-row{display:flex;margin:8px 0}.bubble-row.out{justify-content:flex-end}.bubble{max-width:74%;padding:10px 12px;border-radius:12px;background:#fff;border:1px solid #e5eaf1;white-space:pre-wrap;word-break:break-word}.out .bubble{background:#dff1ff;border-color:#cae4f7}.meta{font-size:10px;color:#9aa5b1;margin-top:5px}.composer{padding:12px;display:flex;gap:10px;border-top:1px solid #eef1f5}.composer textarea{flex:1;resize:none;height:64px;border:1px solid #d9e0ea;border-radius:8px;padding:10px;font:inherit}.composer button{width:90px}.events #events{padding:8px 12px}.event{padding:9px 2px;border-bottom:1px solid #f0f2f6;font-size:12px}.event .time{color:#98a2b3}.event.error{color:#b42318}.event.warning{color:#9a6700}.empty{color:#98a2b3;text-align:center;margin-top:60px}.modal{position:fixed;inset:0;background:rgba(8,15,28,.45);display:flex;align-items:center;justify-content:center}.hidden{display:none!important}.modal-card{background:#fff;border-radius:14px;width:420px;padding:24px;text-align:center;position:relative}.close{position:absolute;right:10px;top:8px;background:transparent;color:#667085;font-size:24px}.qr{width:260px;height:260px;image-rendering:pixelated}.note{font-size:12px;color:#7c8798;line-height:1.6}.mock-box{margin-top:14px;padding:12px;display:flex;gap:10px;align-items:center}.mock-box input{padding:9px;border:1px solid #d9e0ea;border-radius:8px;min-width:220px}@media(max-width:1100px){.workspace{grid-template-columns:260px 1fr}.events{display:none}}@media(max-width:760px){.workspace{display:block;height:auto}.sidebar{height:260px;margin-bottom:12px}.chat{height:620px}.topbar{flex-wrap:wrap}.switchrow{margin-left:0}}
.alert{margin:10px 0 0;padding:12px 16px;border-radius:10px;background:#fdecea;color:#b3261e;font-weight:700;border:1px solid #f5c6c2}.status-meta{font-size:12px;color:#718096}.status-meta b{color:#26364a}
/* --- P1: 会话标签 / 转人工 / 知识库 --- */
.tag{display:inline-block;padding:1px 6px;border-radius:6px;font-size:11px;margin-left:4px;white-space:nowrap;vertical-align:middle}
.tag-human{background:#fdecea;color:#b3261e;font-weight:700}
.tag-type{background:#e8f0fe;color:#1a56db}
.tag-intent{background:#eef2f7;color:#52627a}
.tag-product{background:#e8f7ef;color:#177245}
.peer-row{display:flex;align-items:center;justify-content:space-between;gap:6px}
.tags{display:flex;flex-wrap:wrap;justify-content:flex-end}
.clear-human{background:#fff;border:1px solid #f1b7b1;color:#b3261e;font-size:11px;padding:2px 8px;border-radius:6px;margin-top:6px;font-weight:600}
.clear-human:hover{background:#fdecea}
.clear-human-btn{font-size:12px;padding:4px 10px;margin-left:10px}
.bubble-tags{margin-top:5px}
.bubble-tags .tag{margin-left:0;margin-right:4px}
.knowledge-card{width:min(760px,92vw)}
#knowledgeText{width:100%;height:52vh;font-family:Consolas,"Microsoft YaHei",monospace;font-size:13px;line-height:1.5;padding:10px;border:1px solid #dbe1ea;border-radius:8px;resize:vertical;background:#fbfcfe}
.knowledge-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:10px}
/* --- 多账号：账号 chips / 账号面板 / 移除按钮 --- */
.topbar{flex-wrap:wrap;gap:12px}
.account-chips{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.chip{display:inline-flex;align-items:center;gap:6px;background:#eef2f7;color:#26364a;border-radius:999px;padding:7px 14px;font-size:13px;font-weight:600}
.chip.active{background:#1f6feb;color:#fff}
.chip-dot{width:9px;height:9px;border-radius:50%;display:inline-block}
.dot-ok{background:#22a45d}.dot-off{background:#c2c9d6}.dot-err{background:#e5484d}
.chip.active .dot-ok{background:#7ee2a8}.chip.active .dot-off{background:#e3e8f0}.chip.active .dot-err{background:#ffb3b5}
button.danger{background:#fdecea;color:#b3261e;border:1px solid #f5c6c2}
button.danger:hover{background:#fbd9d5}
.tag-account{background:#f3e8ff;color:#6941c6}
#accountPanel{margin-top:10px}
/* --- 接口连续失败的内联警告（黄色，区别于掉线红色横幅） --- */
.warn-banner{margin:10px 0 0;padding:12px 16px;border-radius:10px;background:#fff6df;color:#9a6700;font-weight:600;border:1px solid #f2e2b3}
.abnormal-hint{color:#718096;font-size:12px;margin-left:4px}
/* --- AI 设置弹窗 --- */
.ai-card{width:min(560px,92vw)}
.ai-form{display:flex;flex-direction:column;gap:12px;margin-top:12px}
.ai-form label{display:flex;flex-direction:column;gap:5px;font-size:13px;font-weight:600;color:#26364a}
.ai-form input,.ai-form textarea{font-size:13px;padding:9px 11px;border:1px solid #dbe1ea;border-radius:8px;background:#fbfcfe;font-family:inherit}
.ai-form textarea{height:110px;resize:vertical;line-height:1.5;font-family:Consolas,"Microsoft YaHei",monospace}
.ai-test-result{margin-top:12px;padding:10px 12px;border-radius:8px;background:#e8f7ef;color:#177245;font-size:13px;border:1px solid #bfe8cd;word-break:break-all}
.ai-test-result.error{background:#fdecea;color:#b3261e;border-color:#f5c6c2}
/* --- 客户线索池 --- */
.tag-lead{background:#fff0e6;color:#b25900;font-weight:700;cursor:pointer}
.leads-card{width:min(980px,94vw);max-height:88vh;display:flex;flex-direction:column}
.leads-stats{display:flex;gap:12px;margin:12px 0}
.lead-stat{flex:1;background:#f4f8ff;border:1px solid #e1ebfa;border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;align-items:center}
.lead-stat b{font-size:22px;color:#1f6feb}
.lead-stat span{font-size:12px;color:#52627a;margin-top:2px}
.leads-toolbar{display:flex;gap:10px;align-items:center;margin-bottom:10px;flex-wrap:wrap}
.leads-toolbar select{padding:8px 10px;border:1px solid #dbe1ea;border-radius:8px;background:#fbfcfe;font-size:13px}
.leads-list{overflow:auto;flex:1;border:1px solid #eef1f5;border-radius:10px}
.lead-row{display:flex;justify-content:space-between;gap:12px;padding:12px 14px;border-bottom:1px solid #f0f2f6;cursor:pointer}
.lead-row:hover{background:#f8fbff}
.lead-main{min-width:0;flex:1}
.lead-line1{display:flex;align-items:center;gap:6px}
.lead-peer{font-weight:700;font-size:14px}
.lead-line2{margin-top:6px}
.lead-line3{margin-top:5px;color:#52627a;font-size:12px}
.lead-contact{color:#1a56db;font-weight:600}
.lead-contact small{color:#8a95a5;font-weight:400}
.lead-contact.copied::after{content:' 已复制';color:#22a45d;font-size:11px}
.lead-contact.empty{color:#9aa5b1;font-weight:400}
.lead-time{color:#9aa5b1;font-size:12px;white-space:nowrap}
.lead-detail{background:#fbfcfe;border-bottom:1px solid #eef1f5;padding:14px 16px}
.lead-fields{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:10px}
.lead-field{background:#fff;border:1px solid #e6eaf0;border-radius:8px;padding:6px 9px;display:flex;flex-direction:column}
.lf-label{font-size:11px;color:#8a95a5}
.lf-value{font-size:13px;color:#26364a;font-weight:600;word-break:break-all}
.lead-summary{font-size:13px;color:#26364a;margin:8px 0;line-height:1.5}
.lead-actions{display:flex;gap:12px;align-items:center;margin:10px 0;flex-wrap:wrap}
.lead-actions select{padding:6px 9px;border:1px solid #dbe1ea;border-radius:8px;background:#fff}
.lead-note-label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:#52627a;margin-bottom:10px}
.lead-note{padding:8px 10px;border:1px solid #dbe1ea;border-radius:8px;font-size:13px;background:#fff}
.lead-raw pre{white-space:pre-wrap;word-break:break-word;background:#fff;border:1px solid #e6eaf0;border-radius:8px;padding:10px;font-size:12px;line-height:1.5;max-height:220px;overflow:auto;margin:6px 0 0;font-family:Consolas,"Microsoft YaHei",monospace}
.lead-new{background:#e8f0fe;color:#1a56db}
.lead-following{background:#fff6df;color:#9a6700}
.lead-quoted{background:#f3e8ff;color:#6941c6}
.lead-won{background:#e8f7ef;color:#177245}
.lead-lost{background:#eef2f7;color:#52627a}
.lead-invalid{background:#f1f2f4;color:#8a95a5}
/* --- 登录页 --- */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:16px}
.login-card{width:min(400px,100%);background:#fff;border:1px solid #e6eaf0;border-radius:12px;box-shadow:0 3px 14px rgba(21,32,51,.08);padding:28px 26px}
.login-card h1{font-size:20px;margin:0 0 6px;text-align:center}
.login-sub{margin:0 0 18px;color:#718096;font-size:13px;text-align:center}
.login-form{display:flex;flex-direction:column;gap:12px}
.login-form label{display:flex;flex-direction:column;gap:5px;font-size:13px;font-weight:600;color:#26364a}
.login-form input{font-size:14px;padding:10px 12px;border:1px solid #dbe1ea;border-radius:8px;background:#fbfcfe;font-family:inherit}
.login-form input:disabled{color:#8a95a5;background:#f1f3f7}
.login-error{background:#fdecea;color:#b3261e;border:1px solid #f5c6c2;border-radius:8px;padding:9px 11px;font-size:13px}
.login-note{margin:0;color:#9a6700;font-size:13px;background:#fff6df;border:1px solid #f2e2b3;border-radius:8px;padding:9px 11px;font-weight:600}
/* --- 顶栏用户区 / 角色徽标 --- */
.header-right{display:flex;align-items:center;gap:10px}
.user-name{font-size:13px;color:#26364a;font-weight:600;white-space:nowrap}
.role-badge{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;white-space:nowrap}
.role-badge.role-admin{background:#e8f0fe;color:#1a56db}
.role-badge.role-member{background:#e8f7ef;color:#177245}
/* --- 人员总览（复用 lead-row / chip 样式，只补少量容器样式） --- */
.staff-card{width:min(760px,94vw);max-height:88vh;display:flex;flex-direction:column}
.staff-list{overflow:auto;flex:1;border:1px solid #eef1f5;border-radius:10px}
.staff-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
.staff-row{cursor:default}
.staff-row:hover{background:#fff}
.staff-row-actions{display:flex;flex-direction:column;align-items:flex-end;gap:9px}
.staff-edit-btn{padding:6px 12px;font-size:12px}
.staff-disabled{background:#f1f2f4;color:#8a95a5}
.staff-edit-card{width:min(520px,94vw);text-align:left}
.staff-edit-card h2{text-align:center}
.staff-edit-form{display:flex;flex-direction:column;gap:11px}
.staff-edit-form label{display:flex;flex-direction:column;gap:5px;font-size:13px;font-weight:700;color:#52627a}
.staff-edit-form input,.staff-edit-form select{padding:10px 11px;border:1px solid #dbe1ea;border-radius:8px;background:#fbfcfe;font:inherit;color:#172033}
.staff-edit-form .note{margin:2px 0}
.staff-edit-actions{display:flex;justify-content:flex-end;gap:9px}
/* --- 新建业务员（admin-only 建号表单 + 一次性初始密码展示） --- */
.staff-create{display:flex;gap:8px;margin:10px 0 8px;flex-wrap:wrap}
.staff-create input{flex:1;min-width:160px}
.staff-create-result{border:1px dashed #b9c6d6;border-radius:10px;padding:10px 12px;margin:0 0 8px;font-size:13px;color:#26364a;background:#f7fafd}
.staff-create-result .pw-line{display:flex;align-items:center;gap:8px;margin-top:6px}
.staff-create-result code{font-size:15px;font-weight:700;letter-spacing:.5px;background:#eef3f9;border-radius:6px;padding:3px 8px}
.staff-create{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 12px;align-items:end}
.staff-create label{display:flex;flex-direction:column;gap:5px;min-width:0;text-align:left;font-size:12px;font-weight:700;color:#52627a}
.staff-create label input{min-width:0;width:100%;padding:10px 11px;border:1px solid #dbe1ea;border-radius:8px;background:#fbfcfe;font:inherit;color:#172033}
.staff-create-footer{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px}
.staff-create-footer span{font-size:12px;color:#718096}
.staff-create-footer button{white-space:nowrap}
@media(max-width:560px){.staff-create{grid-template-columns:1fr}.staff-create-footer{grid-column:1}}
.err-text{color:#c0392b}
/* --- 两栏模式：member 隐藏运行日志面板后，工作区不留空白第三栏 ---
   注意：必须放在下方 @media 之前，窄屏下单列规则（同特异性、后出现）才能覆盖它 */
.workspace.two-col{grid-template-columns:300px minmax(480px,1fr)}
/* --- 窄屏兜底：避免手机宽度下三栏工作区横向溢出 --- */
@media (max-width:860px){
  header{height:auto;flex-wrap:wrap;gap:10px;padding:12px 16px}
  .workspace{grid-template-columns:1fr;height:auto}
  .workspace.two-col{grid-template-columns:1fr}
  .sidebar,.events{max-height:320px}
  .chat{min-height:420px}
}

/* 人员 → 账号导航取代日志栏，账号从顶部横排移入树中。 */
.workspace{grid-template-columns:280px minmax(0,1fr) 300px;grid-template-areas:"conversations chat tree"}
.workspace .sidebar{grid-area:conversations}
.workspace .chat{grid-area:chat}
.account-tree-panel{grid-area:tree;display:flex;flex-direction:column;min-width:0;overflow:hidden}
.account-tree{padding:10px;overflow:auto;flex:1}
.tree-all,.tree-person-head,.tree-account{display:flex;align-items:center;width:100%;min-width:0;text-align:left;border-radius:8px;background:transparent;color:#26364a;font-size:13px}
.tree-all{justify-content:space-between;padding:10px 12px;margin-bottom:8px;font-weight:700}
.tree-all span,.tree-person-count{font-size:11px;color:#718096;background:#eef2f7;border-radius:999px;padding:2px 7px}
.tree-all:hover,.tree-person-head:hover,.tree-account:hover{background:#f4f8ff}
.tree-all.active,.tree-account.active{background:#e8f0fe;color:#1a56db}
.tree-person{border-top:1px solid #eef1f5;padding-top:6px;margin-top:6px}
.tree-person-head{gap:7px;padding:9px 7px;font-weight:700}
.tree-person-name,.tree-account-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
.tree-arrow{color:#8291a5;width:14px;text-align:center;flex:none}
.tree-children{margin:0 0 7px 14px;padding-left:9px;border-left:1px solid #e3e9f2}
.tree-account{gap:7px;padding:9px 8px;font-weight:500}
.tree-account .chip-dot{flex:none}
.tree-account-status{font-size:11px;color:#8794a7;white-space:nowrap}
.tree-account.active .tree-account-status{color:#3a6ec6}
.tree-empty{color:#98a2b3;font-size:12px;padding:8px 9px}
.tree-unassigned{cursor:default}
@media(max-width:1200px){.workspace{grid-template-columns:240px minmax(0,1fr) 260px}}
@media(max-width:960px){.workspace{grid-template-columns:240px minmax(0,1fr);grid-template-areas:"tree tree" "conversations chat";height:auto}.account-tree-panel{max-height:270px}.sidebar{min-height:420px}.chat{min-height:600px}}
@media(max-width:760px){.workspace{display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:"tree" "conversations" "chat"}.sidebar{min-height:0;height:260px}.chat{height:620px;min-height:0}}
