/* AI客服云 · 商家 Web 工作台 */
:root{
  --navy:#0d1f30; --navy2:#16324a; --text:#16222f; --sub:#66778a; --muted:#93a2b3;
  --accent:#2fb6ae; --accent-dark:#1b8c86; --soft:#e8f7f5; --line:#e6edf3;
  --bg:#f4f7fa; --danger:#d25757; --warn:#d98a3d; --warn-soft:#fdf3e7;
  --violet:#6c7be0; --radius:12px;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:"Noto Sans CJK SC","PingFang SC","Microsoft YaHei",system-ui,sans-serif;
     color:var(--text);font-size:14px;background:var(--bg);-webkit-font-smoothing:antialiased}
button{font:inherit;cursor:pointer;border:none;border-radius:8px;background:none;color:inherit}
input,textarea,select{font:inherit;color:var(--text);outline:none}
a{color:inherit}
.hidden{display:none!important}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#d6e1ea;border-radius:5px}
::-webkit-scrollbar-track{background:transparent}

/* ---------- 登录 ---------- */
#login{height:100%;display:flex;align-items:center;justify-content:center;
       background:radial-gradient(1000px 560px at 18% 0%,#12324a 0%,#0d1f30 55%,#08131d 100%)}
.login-card{width:400px;background:#fff;border-radius:16px;padding:34px 32px 26px;
            box-shadow:0 30px 80px rgba(0,0,0,.35)}
.logo{width:46px;height:46px;border-radius:12px;background:linear-gradient(135deg,#3fcabf,#219a93);
      color:#fff;display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:700;letter-spacing:.5px;margin-bottom:18px}
.login-card h1{font-size:20px;margin-bottom:6px}
.login-card .sub{color:var(--muted);font-size:12px;margin-bottom:22px}
.field{margin-bottom:14px}
.field label{display:block;font-size:12px;color:var(--sub);margin-bottom:6px}
.field input{width:100%;padding:10px 12px;border:1px solid #e1e9f1;border-radius:9px;background:#fff}
.field input:focus{border-color:#7fd3cd;box-shadow:0 0 0 3px rgba(47,182,174,.12)}
.btn-primary{background:var(--accent);color:#fff;font-weight:600;padding:10px 16px}
.btn-primary:hover{background:#28a79f}
.btn-primary:disabled{background:#bfe4e1;cursor:not-allowed}
.login-card .btn-primary{width:100%;padding:11px}
.err{color:var(--danger);font-size:12px;min-height:18px;margin-top:10px}
.login-foot{margin-top:16px;padding-top:14px;border-top:1px solid var(--line);
            display:flex;justify-content:space-between;color:var(--muted);font-size:11.5px}
.login-foot a{color:var(--accent-dark)}

/* ---------- 顶栏 ---------- */
header.top{height:56px;background:var(--navy);display:flex;align-items:center;gap:12px;
           padding:0 18px;color:#fff;flex-shrink:0}
.mark{width:28px;height:28px;border-radius:8px;background:var(--accent);display:flex;
      align-items:center;justify-content:center;font-weight:700;font-size:11px;letter-spacing:.5px}
.brand{font-weight:600;font-size:14.5px}
.tenant{background:#16324a;color:#9fc0d4;font-size:11.5px;border-radius:20px;padding:3px 10px}
.sp{flex:1}
.top .who{color:#a9bccd;font-size:12px}
.top .logout{background:transparent;border:1px solid #24405a;color:#a9bccd;padding:5px 11px;font-size:12px}
.top .logout:hover{color:#fff;border-color:#3a5e7c}

/* ---------- 布局 ---------- */
#app{height:100%;display:flex;flex-direction:column}
.shell{flex:1;display:flex;min-height:0}
.side{width:200px;background:var(--navy);padding:14px 10px;display:flex;flex-direction:column;gap:4px;flex-shrink:0}
.nav-item{display:flex;align-items:center;gap:10px;width:100%;text-align:left;
          padding:10px 12px;border-radius:9px;color:#a9bccd;font-size:13px}
.nav-item:hover{background:var(--navy2);color:#e8f2fa}
.nav-item.on{background:#173b45;color:#fff}
.nav-item .ico{width:18px;text-align:center;font-size:14px;opacity:.9}
.nav-badge{margin-left:auto;background:#f0685f;color:#fff;border-radius:9px;font-size:10px;
           font-weight:600;padding:1px 6px}
.side-foot{margin-top:auto;padding:10px 12px;color:#6e8399;font-size:11px;line-height:1.7;
           border-top:1px solid #16324a}

.main{flex:1;min-width:0;display:flex;flex-direction:column;min-height:0}
.view{flex:1;min-height:0;overflow-y:auto;padding:22px 24px 28px}
.view.chat-view{padding:0;overflow:hidden}

.page-head{display:flex;align-items:flex-end;gap:12px;margin-bottom:16px}
.page-head h1{font-size:19px}
.page-head .s{color:var(--muted);font-size:12px;margin-top:3px}
.page-head .sp{flex:1}

/* ---------- 卡片 / KPI ---------- */
.card{background:#fff;border:1px solid #e9eff5;border-radius:var(--radius);padding:16px}
.card h2{font-size:14px;font-weight:600;margin-bottom:2px}
.card .hint{color:var(--muted);font-size:11.5px}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:14px}
.kpi{background:#fff;border:1px solid #e9eff5;border-radius:var(--radius);padding:15px 16px}
.kpi .k{color:#7c8ca0;font-size:12px;display:flex;align-items:center;gap:6px}
.kpi .v{font-size:26px;font-weight:700;margin-top:6px;letter-spacing:-.5px}
.kpi .d{font-size:11.5px;margin-top:3px;color:var(--accent-dark)}
.kpi .d.warn{color:var(--warn)}

.grid2{display:grid;grid-template-columns:1.55fr 1fr;gap:14px}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px}

/* ---------- 表格 ---------- */
table{width:100%;border-collapse:collapse}
th{text-align:left;font-size:12px;color:#8091a3;font-weight:600;padding:9px 12px;
   background:#fafcfd;border-bottom:1px solid #edf3f8;white-space:nowrap}
td{padding:11px 12px;border-bottom:1px solid #f4f7fa;font-size:12.5px;vertical-align:middle}
tr:last-child td{border-bottom:none}
tbody tr:hover td{background:#fbfdfe}
.table-wrap{background:#fff;border:1px solid #e9eff5;border-radius:var(--radius);overflow:hidden}
.table-wrap .cap{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid #f0f4f8}
.table-wrap .cap h2{font-size:14px;font-weight:600}
.table-wrap .cap .sp{flex:1}

/* ---------- 表单 ---------- */
.btn-ghost{background:#fff;border:1px solid #dce6ef;color:#44576b;font-size:12.5px;padding:7px 13px;border-radius:8px}
.btn-ghost:hover{background:#f4f9fb}
.btn-soft{background:var(--soft);color:var(--accent-dark);font-weight:600;font-size:12.5px;padding:8px 14px;border-radius:8px}
.btn-soft:hover{background:#d9f1ef}
.btn-danger{background:#fceded;color:#c24b4b;font-size:12.5px;padding:7px 13px;border-radius:8px}
.btn-danger:hover{background:#f9dfdf}
.btn-sm{padding:5px 10px;font-size:12px;border-radius:6px}
.input{width:100%;padding:9px 12px;border:1px solid #e1e9f1;border-radius:9px;background:#fff;font-size:13px}
.input:focus{border-color:#7fd3cd;box-shadow:0 0 0 3px rgba(47,182,174,.12)}
textarea.input{resize:vertical;line-height:1.6}
select.input{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#93a2b3 50%),linear-gradient(135deg,#93a2b3 50%,transparent 50%);
  background-position:calc(100% - 18px) 18px,calc(100% - 13px) 18px;background-size:5px 5px;background-repeat:no-repeat}
.form-row{margin-bottom:14px}
.form-row label{display:block;font-size:12px;color:var(--sub);margin-bottom:6px}
.form-row .tip{color:var(--muted);font-size:11px;margin-top:4px}
.inline{display:flex;align-items:center;gap:10px}
.badge{font-size:10.5px;border-radius:6px;padding:2px 7px;background:#f1f5f9;color:#5a6c7f;white-space:nowrap}
.badge.teal{background:var(--soft);color:var(--accent-dark)}
.badge.warn{background:var(--warn-soft);color:#b9762e}
.badge.red{background:#fceded;color:#c24b4b}
.badge.gray{background:#f1f5f9;color:#5a6c7f}

.toggle{position:relative;width:38px;height:21px;background:#d5dfe8;border-radius:11px;transition:.2s;flex-shrink:0;cursor:pointer}
.toggle.on{background:var(--accent)}
.toggle:after{content:"";position:absolute;top:2px;left:2px;width:17px;height:17px;background:#fff;border-radius:50%;transition:.2s}
.toggle.on:after{left:19px}
.toggle.disabled{opacity:.45;cursor:not-allowed}

input[type=range]{-webkit-appearance:none;width:100%;height:4px;border-radius:2px;background:#e4edf4;outline:none}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;
  background:#fff;border:2px solid var(--accent);cursor:pointer}

/* ---------- 会话三栏 ---------- */
.chat-shell{height:100%;display:grid;grid-template-columns:276px 1fr 288px;overflow:hidden}
.convs{background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;min-width:0}
.side-head{padding:14px 14px 8px;display:flex;align-items:center;gap:8px}
.side-head h2{font-size:15px}
.side-head .count{color:var(--muted);font-size:12px}
.search{margin:0 12px 8px;padding:7px 11px;border:1px solid #e1e9f1;border-radius:8px;font-size:12.5px;width:calc(100% - 24px)}
.chips{display:flex;gap:6px;padding:0 12px 10px}
.chip{background:#f4f8fb;color:#67788b;border-radius:13px;padding:5px 12px;font-size:12px}
.chip.on{background:var(--soft);color:var(--accent-dark);font-weight:600}
.conv-list{flex:1;overflow-y:auto;padding:0 10px 12px}
.conv{border:1px solid #eef3f8;border-radius:10px;padding:10px 11px;margin-bottom:7px;cursor:pointer;background:#fff}
.conv:hover{background:#f7fcfc;border-color:#d8efed}
.conv.on{background:#f0faf9;border-color:#8ed9d4}
.conv .r1{display:flex;align-items:center;gap:6px;margin-bottom:4px}
.conv .r1 .name{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conv .r1 .time{margin-left:auto;color:#a3b1bf;font-size:11px;flex-shrink:0}
.conv .preview{color:#8a99aa;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px}
.conv .r2{display:flex;gap:5px;align-items:center}
.unread{margin-left:auto;background:#f0685f;color:#fff;border-radius:9px;font-size:10px;font-weight:600;padding:1px 6px}

.chat{display:flex;flex-direction:column;min-width:0;background:var(--bg)}
.chat-head{height:64px;background:#fff;border-bottom:1px solid #eef3f8;display:flex;align-items:center;
           gap:10px;padding:0 18px;flex-shrink:0}
.avatar{width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;
        color:#fff;font-weight:600;font-size:14px;flex-shrink:0}
.chat-head .c{flex:1;min-width:0}
.chat-head .n{font-size:14px;font-weight:700;display:flex;align-items:center;gap:7px}
.chat-head .meta{color:var(--muted);font-size:11.5px;margin-top:2px}

.msgs{flex:1;overflow-y:auto;padding:20px 22px 10px;display:flex;flex-direction:column;gap:14px}
.msgs .msg:first-child{margin-top:auto}
.msg{display:flex;gap:9px;align-items:flex-start}
.msg.me{flex-direction:row-reverse}
.msg .col{display:flex;flex-direction:column;gap:4px;max-width:min(560px,72%)}
.msg.me .col{align-items:flex-end}
.bubble{padding:10px 13px;border-radius:12px;font-size:13.5px;line-height:1.65;white-space:pre-wrap;word-break:break-word}
.bubble.buyer{background:#fff;border:1px solid #e9eff5;border-top-left-radius:3px}
.bubble.ai{background:#e9f8f6;border:1px solid #cbede9;border-top-right-radius:3px}
.bubble.agent{background:#1b2a3a;color:#f2f7fb;border-top-right-radius:3px}
.bubble.sys{align-self:center;color:#8a99aa;font-size:11.5px}
.msg .meta{color:#a3b1bf;font-size:11px}
.product{width:240px;background:#fff;border:1px solid #e4edf4;border-radius:10px;padding:9px 11px;display:flex;gap:9px;align-items:center;margin-top:6px}
.product .t{font-size:12px;font-weight:600}
.product .p{color:#d25757;font-size:14px;font-weight:700}

.sugg{margin:0 20px 6px;background:#f0faf9;border:1px solid #cbede9;border-radius:10px;padding:12px 14px}
.sugg .h{display:flex;align-items:center;gap:8px;margin-bottom:7px}
.sugg .h b{color:var(--accent-dark);font-size:12px}
.sugg .body{font-size:13px;line-height:1.65;white-space:pre-wrap}
.sugg .meta{color:var(--muted);font-size:11px;margin-top:6px}
.sugg .acts{display:flex;justify-content:flex-end;gap:8px;margin-top:9px}

.composer{background:#fff;border-top:1px solid var(--line);padding:10px 20px 12px;flex-shrink:0}
.composer textarea{width:100%;height:64px;padding:9px 11px;border:1px solid #e1e9f1;border-radius:9px;resize:none;font-size:13px}
.composer textarea:focus{border-color:#7fd3cd}
.composer .bar{display:flex;align-items:center;gap:8px;margin-top:8px}
.composer .hint{color:var(--muted);font-size:11.5px}
.composer .bar .sp{flex:1}
.send{background:var(--accent);color:#fff;font-weight:600;padding:8px 24px;border-radius:8px}
.send:hover{background:#28a79f}

.info{background:#fafcfd;border-left:1px solid var(--line);padding:16px;overflow-y:auto}
.info .buyer{text-align:center;margin-bottom:14px}
.info .buyer .name{font-size:14px;font-weight:700;margin-top:7px}
.info .tags{display:flex;justify-content:center;gap:5px;margin-top:6px;flex-wrap:wrap}
.box{background:#fff;border:1px solid #edf3f8;border-radius:10px;padding:11px 12px;margin-bottom:12px}
.box .row{display:flex;justify-content:space-between;gap:8px;font-size:12px;padding:3px 0}
.box .row .k{color:var(--muted)}
.box .row .v{font-weight:500;text-align:right;word-break:break-all}
.box h3{font-size:12px;font-weight:600;margin-bottom:8px}
.hit{background:#fff;border:1px solid #edf3f8;border-radius:8px;padding:8px 9px;margin-bottom:7px}
.hit .t{display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:600}
.hit .t .s{margin-left:auto;font-size:10px;color:var(--accent-dark);background:var(--soft);border-radius:5px;padding:1px 5px}
.hit .bar{height:3px;background:#eff4f8;border-radius:2px;margin-top:6px;overflow:hidden}
.hit .bar i{display:block;height:100%;background:var(--accent)}
.empty{color:#a9b6c4;text-align:center;padding:40px 10px;font-size:13px}

/* ---------- 知识库 / 商品 / 设置 ---------- */
.split{display:grid;grid-template-columns:1fr 360px;gap:14px;align-items:start}
.filters{display:flex;gap:8px;align-items:center;margin-bottom:12px}
.filters .input{max-width:320px}
.kb-table td.title{font-weight:500}
.actions{display:flex;gap:6px;justify-content:flex-end}
.icon-btn{width:26px;height:26px;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;
          color:#7c8ca0;font-size:13px}
.icon-btn:hover{background:#f1f5f9;color:var(--accent-dark)}
.tester{background:#fff;border:1px solid #e9eff5;border-radius:var(--radius);padding:16px}
.tester h2{font-size:14px;margin-bottom:4px}
.tester .hint{margin-bottom:12px}
.result{background:#fafcfd;border:1px solid #edf3f8;border-radius:8px;padding:10px;margin-top:8px}
.result .t{display:flex;gap:6px;align-items:center;font-size:12px;font-weight:600}
.result .t .s{margin-left:auto;font-size:10.5px;color:var(--accent-dark);background:var(--soft);border-radius:5px;padding:1px 6px}
.result .c{color:var(--sub);font-size:11.5px;margin-top:4px;line-height:1.6}
.result .bar{height:3px;background:#eff4f8;border-radius:2px;margin-top:7px;overflow:hidden}
.result .bar i{display:block;height:100%;background:var(--accent)}

.progress{height:6px;background:#eff4f8;border-radius:3px;overflow:hidden;margin:10px 0 6px}
.progress i{display:block;height:100%;width:0;background:var(--accent);transition:width .2s}
.sync-tip{color:var(--accent-dark);font-size:12px}

.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.settings-card{background:#fff;border:1px solid #e9eff5;border-radius:var(--radius);padding:18px}
.settings-card h2{font-size:14px;margin-bottom:14px}
.note{background:var(--warn-soft);border:1px solid #f6e0c8;border-radius:9px;padding:10px 13px;
      color:#9a6a2c;font-size:12px;line-height:1.6;margin-bottom:14px}

/* ---------- 弹窗 / 提示 ---------- */
.mask{position:fixed;inset:0;background:rgba(13,31,48,.45);display:flex;align-items:center;
      justify-content:center;z-index:40}
.modal{width:520px;max-height:86vh;overflow:auto;background:#fff;border-radius:14px;padding:24px 24px 18px;
       box-shadow:0 24px 60px rgba(0,0,0,.28)}
.modal h3{font-size:16px;margin-bottom:4px}
.modal .desc{color:var(--muted);font-size:12px;margin-bottom:16px}
.modal .foot{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}

#toast{position:fixed;left:50%;top:70px;transform:translateX(-50%);background:rgba(27,42,58,.95);
       color:#fff;padding:8px 16px;border-radius:9px;font-size:12.5px;opacity:0;transition:.2s;
       pointer-events:none;z-index:50}
#toast.show{opacity:1}
#toast.bad{background:rgba(180,60,60,.96)}

@media (max-width:1180px){
  .kpis{grid-template-columns:repeat(2,1fr)}
  .grid2,.split{grid-template-columns:1fr}
  .chat-shell{grid-template-columns:250px 1fr}
  .info{display:none}
}
@media (max-width:820px){
  .side{width:64px}
  .nav-item span.txt{display:none}
  .side-foot{display:none}
  .chat-shell{grid-template-columns:1fr}
  .convs{display:none}
}

#addMemberBox{flex-wrap:wrap;gap:8px}
#addMemberBox .btn-soft{white-space:nowrap;flex-shrink:0}
.actions .btn-ghost{padding:3px 8px;font-size:11.5px}
