:root{--bg:#f4f6f5;--card:#fff;--ink:#14332b;--muted:#6b7a75;--brand:#ee7138;--green:#1f8a5b;--line:#e3e8e6;--red:#c0392b}
*{box-sizing:border-box}body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:var(--bg);color:#1c2321;font-size:14px}
a{color:inherit}button{font:inherit;cursor:pointer;border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 12px}button.primary{background:var(--brand);color:#fff;border-color:var(--brand)}button.ghost{background:transparent;border-color:transparent}button:disabled{opacity:.5;cursor:default}
input,select,textarea{font:inherit;width:100%;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:#fff}label{display:block;font-size:12px;color:var(--muted);margin:8px 0 4px}
.login{min-height:100vh;display:grid;place-items:center;background:var(--ink)}.login form{background:#fff;padding:28px;border-radius:16px;width:min(380px,92vw)}.login h1{margin:0 0 4px;font-size:22px}
.shell{display:grid;grid-template-columns:230px 1fr;min-height:100vh}.side{background:var(--ink);color:#fff;padding:16px;position:sticky;top:0;height:100vh;overflow:auto}.side .brand{font-weight:800;font-size:18px;margin-bottom:18px}.side nav button{display:block;width:100%;text-align:left;background:transparent;color:#cfe0da;border:0;padding:9px 10px;border-radius:8px;margin:2px 0}.side nav button.active{background:rgba(255,255,255,.12);color:#fff}
.main{padding:18px 22px;max-width:1400px}.top{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;gap:10px}.top h1{margin:0;font-size:20px}
.grid{display:grid;gap:12px}.g4{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}.g2{grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:14px}.card h3{margin:0 0 10px;font-size:14px;color:var(--muted);font-weight:600}.kpi{font-size:26px;font-weight:800}.kpi small{font-size:12px;color:var(--muted);font-weight:400;display:block}
.badge{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px;background:#eef2f0;color:#33413c}.badge.ok{background:#dff4ea;color:var(--green)}.badge.warn{background:#fdecdc;color:#b3471a}.badge.bad{background:#fde3e0;color:var(--red)}
table{width:100%;border-collapse:collapse}th,td{text-align:left;padding:8px 6px;border-bottom:1px solid var(--line);vertical-align:top}th{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}tr.click{cursor:pointer}tr.click:hover{background:#f7faf8}
.chat{display:grid;grid-template-columns:320px 1fr;gap:12px;height:calc(100vh - 110px)}.list{overflow:auto;border:1px solid var(--line);border-radius:12px;background:#fff}.list .row{padding:10px 12px;border-bottom:1px solid var(--line);cursor:pointer}.list .row.active{background:#eef6f2}.list .row b{display:block}.list .row small{color:var(--muted)}
.thread{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:12px;background:#fff;overflow:hidden}.thread header{padding:10px 14px;border-bottom:1px solid var(--line);display:flex;gap:8px;align-items:center;flex-wrap:wrap}.msgs{flex:1;overflow:auto;padding:14px;background:#efeae2}.msg{max-width:72%;padding:8px 11px;border-radius:10px;margin:4px 0;white-space:pre-wrap;word-break:break-word;font-size:13.5px}.msg.in{background:#fff;margin-right:auto}.msg.out{background:#d9fdd3;margin-left:auto}.msg small{display:block;color:#667;font-size:10px;margin-top:3px}.compose{display:flex;gap:8px;padding:10px;border-top:1px solid var(--line)}.compose textarea{resize:none;height:44px}
.toast{position:fixed;bottom:18px;left:50%;transform:translateX(-50%);background:#1c2321;color:#fff;padding:10px 16px;border-radius:10px;display:none;z-index:99}
dialog{border:0;border-radius:14px;padding:20px;width:min(560px,94vw)}dialog::backdrop{background:rgba(0,0,0,.4)}
.muted{color:var(--muted)}.right{text-align:right}.mono{font-family:ui-monospace,monospace;font-size:12px}.row-actions{display:flex;gap:6px;flex-wrap:wrap}
.menu-btn{display:none}
@media(max-width:900px){.shell{grid-template-columns:1fr}.side{position:fixed;left:-260px;width:240px;transition:left .2s;z-index:50}.side.open{left:0}.menu-btn{display:inline-block}.chat{grid-template-columns:1fr;height:auto}.chat .list{max-height:40vh}.thread{height:70vh}.main{padding:12px}}

/* ===== Live chat PRO ===== */
.chat.pro{display:grid;grid-template-columns:340px 1fr 0;grid-template-rows:minmax(0,1fr);gap:0;height:calc(100vh - 92px);border:1px solid var(--line);border-radius:14px;overflow:hidden;background:#fff;transition:grid-template-columns .2s}
.chat.pro.side-open{grid-template-columns:340px 1fr 300px}
.chat-list-pane{display:flex;flex-direction:column;border-right:1px solid var(--line);min-width:0;min-height:0;overflow:hidden}
.chat-tools{display:flex;gap:6px;padding:10px 10px 6px}.chat-tools input{flex:1;border-radius:999px;padding:8px 14px;background:#f4f6f5}
.chat-filters{display:flex;gap:4px;padding:0 10px 8px;overflow-x:auto;scrollbar-width:none}.chat-filters::-webkit-scrollbar{display:none}.chat-filters button{white-space:nowrap;padding:5px 10px;font-size:12px;border-radius:999px}.chat-filters .cnt{background:rgba(0,0,0,.12);border-radius:999px;padding:0 6px;font-size:11px;margin-left:2px}.chat-filters button.primary .cnt{background:rgba(255,255,255,.3)}
.chat.pro .list{flex:1;min-height:0;overflow:auto;border:0;border-radius:0;border-top:1px solid var(--line)}
.chat.pro .row{display:flex;gap:10px;padding:10px 12px;align-items:flex-start}.chat.pro .row.unread{background:#fbfdfc}.chat.pro .row.unread .row-prev{font-weight:600;color:#1c2321}.chat.pro .row.active{background:#eef6f2}
.avatar{flex:none;width:40px;height:40px;border-radius:50%;color:#fff;display:grid;place-items:center;font-weight:700;font-size:14px}.side-avatar{width:64px;height:64px;border-radius:50%;color:#fff;display:grid;place-items:center;font-weight:800;font-size:22px;margin:0 auto}
.row-main{flex:1;min-width:0}.row-top{display:flex;justify-content:space-between;gap:6px}.row-top b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.row-top .time{font-size:11px;color:var(--muted);flex:none}
.row-prev{font-size:12.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:2px 0}
.row-tags{display:flex;gap:4px;flex-wrap:wrap;align-items:center;min-height:16px}.row-tags .badge{font-size:10px;padding:1px 6px}
.unread-dot{margin-left:auto;background:var(--green);color:#fff;border-radius:999px;font-size:11px;font-weight:700;min-width:20px;text-align:center;padding:1px 6px}
.chat.pro .thread{border:0;border-radius:0;min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column}.chat.pro .msgs{flex:1;min-height:0;overflow-y:auto}.thread-empty{flex:1;display:grid;place-items:center;text-align:center;background:#f7f8f7}
.thread-head{padding:8px 12px;display:flex;gap:10px;align-items:center;border-bottom:1px solid var(--line);background:#fff}.thread-head .head-main{flex:1;min-width:0}.thread-head .head-sub{font-size:11px;margin-top:2px;display:flex;gap:4px;flex-wrap:wrap;align-items:center}.thread-head .head-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}.thread-head .back{display:none;font-size:20px;padding:4px 8px}
button.icon{padding:6px 9px;font-size:16px;line-height:1}button.small{padding:4px 8px;font-size:12px}button.tiny{padding:0 4px;font-size:11px}
.cart-bar{padding:6px 14px;background:#fff7ef;font-size:12px;border-bottom:1px solid #f5e2cf;display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.chat.pro .msgs{background:#e5ddd5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Ccircle cx='30' cy='30' r='1.2' fill='%23d9cfc4'/%3E%3C/svg%3E")}
.chat.pro .msg{box-shadow:0 1px .5px rgba(0,0,0,.13);position:relative;max-width:min(78%,640px)}.chat.pro .msg.in{border-top-left-radius:2px}.chat.pro .msg.out{border-top-right-radius:2px}.chat.pro .msg.agent{background:#dbeafe}
.msg .who{display:block;color:#7a5a2b;font-size:10.5px;font-weight:700;margin:-2px 0 3px}.msg.agent .who{color:#1d4ed8}.msg .meta{display:flex;justify-content:flex-end;gap:4px;font-size:10px;color:#667;margin-top:3px;align-items:center}.tick{font-size:11px;letter-spacing:-2px}.tick.read{color:#34b7f1}.tick.bad{color:var(--red)}
.msg .btns{display:flex;gap:4px;flex-wrap:wrap;margin-top:6px}.msg .btns span{border:1px solid rgba(0,0,0,.15);border-radius:8px;padding:3px 10px;font-size:12px;background:rgba(255,255,255,.6);color:#0a7cff}
.msg audio{width:260px;max-width:100%;height:36px}.msg .transcript{font-size:12.5px;margin-top:4px;color:#333}.msg .thumb{max-width:260px;max-height:260px;border-radius:8px;display:block}.msg .tap{color:#0a7cff}
.day{font-size:11px;color:#556;background:#fff;display:table;margin:10px auto;padding:3px 10px;border-radius:8px;box-shadow:0 1px .5px rgba(0,0,0,.13)}
.sys{text-align:center;font-size:11px;color:#556;background:#fdf3c7;display:table;margin:8px auto;padding:3px 10px;border-radius:8px}
.typing{padding:4px 14px;font-size:12px;background:#fff;border-top:1px solid var(--line)}
.chat.pro .compose{align-items:flex-end;background:#f0f2f5}.chat.pro .compose textarea{height:42px;min-height:42px;max-height:140px;border-radius:20px;padding:10px 14px;line-height:20px;overflow:hidden}.chat.pro .compose textarea::placeholder{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.compose .send{border-radius:20px;padding:10px 18px}
.canned{border-top:1px solid var(--line);max-height:220px;overflow:auto;background:#fff}.canned-head{display:flex;gap:6px;align-items:center;padding:6px 10px;font-size:12px;border-bottom:1px solid var(--line)}.canned-row{padding:6px 10px;border-bottom:1px solid var(--line);cursor:pointer;font-size:13px}.canned-row.hit,.canned-row:hover{background:#eef6f2}.canned-row small{color:var(--muted)}
.chat-side{border-left:1px solid var(--line);overflow:auto;background:#fafbfa;min-width:0;min-height:0;display:none}.chat.pro.side-open .chat-side{display:block}
.side-sec{padding:12px;border-bottom:1px solid var(--line)}.side-sec h4{margin:0 0 6px;font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}.side-kpis{display:flex;justify-content:space-around;margin-top:10px}.side-kpis div{text-align:center}.side-kpis b{display:block;font-size:15px}.side-kpis small{color:var(--muted);font-size:11px}
.side-order{padding:6px 0;border-bottom:1px dashed var(--line)}.note{background:#fff8dc;border-radius:8px;padding:6px 8px;margin-top:6px;font-size:12.5px}.tagx{cursor:pointer}
@media(min-width:1200px){.chat.pro{grid-template-columns:340px 1fr 300px}.chat.pro .chat-side{display:block}}
@media(max-width:900px){
  .chat.pro,.chat.pro.side-open{grid-template-columns:1fr;height:calc(100dvh - 78px)}
  .chat.pro .chat-list-pane{height:100%}.chat.pro .list{min-height:0}
  .chat.pro .chat-list-pane{display:flex}.chat.pro .thread,.chat.pro .chat-side{display:none}
  .chat.pro.has-thread .chat-list-pane{display:none}.chat.pro.has-thread .thread{display:flex;height:100%}
  .chat.pro.has-thread.side-open .thread{display:none}.chat.pro.has-thread.side-open .chat-side{display:block}
  .thread-head .back{display:inline-block}.thread-head .head-actions button:not(.icon){font-size:12px;padding:5px 8px}
  .chat.pro .msg{max-width:88%}.main{padding:8px}.top{margin-bottom:8px}
}
@media(max-width:900px){
  .thread-head{padding:6px 8px;gap:6px;flex-wrap:nowrap}.thread-head .avatar{width:34px;height:34px;font-size:12px}
  .thread-head .head-main b{font-size:14px}.thread-head .head-sub{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;white-space:nowrap}.thread-head .head-sub::-webkit-scrollbar{display:none}.thread-head .head-sub .muted{display:none}
  .thread-head .head-actions{flex-wrap:nowrap;gap:4px}.thread-head .head-actions button[data-mode]{font-size:11px;padding:6px 8px}
  .cart-bar{font-size:11px;padding:5px 10px}
}
