/* Шрифт подключается через <link> в HTML: так он грузится раньше и не мигает */
:root{--blue:#2F7BF5;--blue-d:#1F63D6;--blue-l:#DCE8FD;--ink:#111318;--muted:#4B5563;--soft:#F3F4F6;--side:#F2F3F6;--line:#EEF0F3;--warn:#B45309;--warn-l:#FEF3C7}
[hidden]{display:none!important}
*{box-sizing:border-box}
body{margin:0;font-family:Manrope,system-ui,sans-serif;color:var(--ink);background:#fff;font-weight:500;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility}
a{color:var(--blue);text-decoration:none}a:hover{color:var(--blue-d)}
button,input,select,textarea{font:inherit}
.logo{display:flex;align-items:center;gap:10px}
.logo .sq{width:40px;height:40px;border-radius:11px;background:var(--blue);display:flex;align-items:center;justify-content:center;flex:none}
.logo .word{font-weight:800;font-size:24px;letter-spacing:-.03em;color:#0E2A47}
.logo .word span{color:var(--blue);font-weight:700}
.btn{height:52px;padding:0 22px;border:0;border-radius:16px;background:var(--blue);color:#fff;font-weight:700;font-size:16px;cursor:pointer}
.btn:hover{background:var(--blue-d)}
.btn.light{background:#fff;color:var(--ink)}
.btn.light:hover{background:#E9EBEF}
.btn:disabled{background:#A9C6F8;cursor:default}
/* layout */
.shell{min-height:100vh;display:flex}
.side{width:260px;flex:none;background:var(--side);display:flex;flex-direction:column;position:sticky;top:0;height:100vh}
.side .logo{padding:28px 28px 32px}
.nav a{display:flex;align-items:center;gap:14px;padding:16px 28px;color:#1F2937;font-weight:700;font-size:16px}
.nav a.on{background:#E3E8F0;color:var(--blue)}
.nav .badge{margin-left:auto;font-size:13px;background:var(--blue);color:#fff;border-radius:999px;padding:2px 9px}
.nav .badge.warn{background:#D97706}
.me{margin-top:auto;padding:24px 28px;display:flex;align-items:center;gap:12px}
.ava{width:48px;height:48px;border-radius:50%;background:var(--blue);color:#fff;font-weight:700;font-size:18px;display:flex;align-items:center;justify-content:center;flex:none}
.me small{display:block;font-size:14px;color:#6B7280}
.me a{margin-left:auto;font-size:14px}
main{flex:1;min-width:0;padding:32px;display:flex;flex-direction:column;gap:22px}
h1{margin:0;font-size:40px;font-weight:800;letter-spacing:-.02em}
.head{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.count{width:48px;height:48px;border-radius:50%;background:var(--soft);color:var(--blue);font-weight:800;font-size:18px;display:flex;align-items:center;justify-content:center}
.seg{margin-left:auto;display:flex;gap:4px;background:var(--soft);border-radius:20px;padding:5px;flex-wrap:wrap}
.seg button{height:42px;padding:0 18px;border:0;border-radius:15px;background:transparent;color:var(--muted);font-weight:700;font-size:15px;cursor:pointer}
.seg button.on{background:#fff;color:var(--ink);box-shadow:0 1px 3px rgba(0,0,0,.08)}
/* dialogs */
.dlg{display:flex;gap:20px;align-items:stretch;min-height:calc(100vh - 150px)}
.list{width:360px;flex:none;display:flex;flex-direction:column;gap:10px;overflow:auto;max-height:calc(100vh - 150px)}
.row{display:flex;gap:12px;padding:14px 16px;border-radius:20px;background:var(--soft);cursor:pointer;border:2px solid transparent;text-align:left;width:100%;color:inherit}
.row:hover{background:#ECEEF2}
.row.on{background:var(--blue-l)}
.row.urgent{background:#FFF7E6;border-color:#F5C66B}
.row .ini{width:44px;height:44px;border-radius:50%;background:#fff;color:var(--blue);font-weight:800;display:flex;align-items:center;justify-content:center;flex:none}
.row .body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.row .top{display:flex;gap:8px;align-items:center}
.row .nm{font-weight:800;font-size:15px}
.row .tm{margin-left:auto;font-size:12px;color:var(--muted)}
.row .last{font-size:13px;color:#374151;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row .meta{display:flex;gap:6px;align-items:center;font-size:12px;font-weight:700;color:#374151}
.dot{width:9px;height:9px;border-radius:50%;flex:none}
.who{margin-left:auto;font-weight:800}
.who.ai{color:var(--blue)}.who.man{color:var(--warn)}
.chat{flex:1;min-width:0;background:var(--soft);border-radius:28px;display:flex;flex-direction:column;max-height:calc(100vh - 150px)}
.chat .bar{padding:18px 22px;display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.chat .bar b{font-size:20px;font-weight:800;display:block}
.chat .bar small{font-size:13px;color:var(--muted)}
.chat .bar .right{margin-left:auto;display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.state{font-size:14px;font-weight:700}
.state.ai{color:var(--blue)}.state.man{color:var(--warn)}
.msgs{flex:1;overflow:auto;padding:8px 22px 16px;display:flex;flex-direction:column;gap:10px}
.b{max-width:72%;border-radius:20px;padding:12px 16px;font-size:15px;line-height:1.5;white-space:pre-wrap;word-wrap:break-word}
.b.u{align-self:flex-start;background:#fff}
.b.a{align-self:flex-end;background:var(--blue-l)}
.b.m{align-self:flex-end;background:#FFF1DC}
.b .lbl{display:block;font-size:11px;font-weight:800;margin-bottom:2px}
.b.a .lbl{color:var(--blue-d)}.b.m .lbl{color:var(--warn)}
.b .t{display:block;font-size:11px;color:#6B7280;margin-top:4px;text-align:right}
.day{align-self:center;font-size:13px;font-weight:700;color:#374151;border:1px solid #D1D5DB;border-radius:999px;padding:4px 14px}
.compose{padding:14px 22px 22px;display:flex;gap:10px}
.compose textarea{flex:1;min-width:0;min-height:52px;max-height:160px;resize:vertical;border:0;border-radius:16px;padding:14px 18px;font-size:15px;background:#fff}
.compose textarea:disabled{background:#E9EBEF}
.info{width:300px;flex:none;display:flex;flex-direction:column;gap:14px}
.card{background:#fff;border:1px solid var(--line);border-radius:24px;padding:22px;display:flex;flex-direction:column;gap:14px}
.card h3{margin:0;font-size:17px;font-weight:700;color:#374151}
.kv{display:grid;grid-template-columns:1fr 1fr;gap:14px 10px}
.kv div{display:flex;flex-direction:column;gap:3px;font-size:14px}
.kv span{color:var(--muted)}
.kv b{color:var(--blue);font-weight:700;word-break:break-word}
.kv .wide{grid-column:1/-1}
.empty{margin:auto;color:var(--muted);font-size:15px;text-align:center;padding:40px}
/* orders */
.board{display:grid;grid-template-columns:repeat(4,minmax(220px,1fr));gap:14px;overflow-x:auto}
.col{background:var(--soft);border-radius:24px;padding:14px;display:flex;flex-direction:column;gap:10px;min-height:60vh}
.col .ch{display:flex;align-items:center;gap:8px;padding:6px 6px 4px;font-weight:800}
.col .ch .n{margin-left:auto;color:var(--blue)}
.oc{background:#fff;border-radius:18px;padding:14px;display:flex;flex-direction:column;gap:6px;font-size:14px}
.oc b{font-size:15px;font-weight:800}
.oc .sum{color:var(--blue);font-weight:800}
.oc .mv{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
.oc .mv button{height:34px;padding:0 10px;border:0;border-radius:11px;background:var(--soft);font-size:12px;font-weight:700;cursor:pointer;color:#1F2937}
.oc .mv button:hover{background:#E5E7EB}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:#111318;color:#fff;padding:12px 18px;border-radius:14px;font-size:14px;display:none;z-index:9}
.back{display:none}
/* phone */
@media (max-width:900px){
  .shell{flex-direction:column}
  .side{width:auto;height:auto;position:static;flex-direction:row;align-items:center;flex-wrap:wrap}
  .side .logo{padding:14px 16px}
  .nav{display:flex;margin-left:auto;flex-wrap:wrap}
  .nav a{padding:12px 14px;font-size:14px}
  .me{display:none}
  main{padding:16px;gap:14px}
  h1{font-size:28px}
  .seg{margin-left:0;width:100%}
  .seg button{flex:1;padding:0 6px;font-size:13px}
  .dlg{flex-direction:column;min-height:0}
  .list{width:auto;max-height:none}
  .chat{max-height:none;min-height:70vh}
  .info{width:auto}
  .dlg.open .list{display:none}
  .dlg:not(.open) .chat,.dlg:not(.open) .info{display:none}
  .back{display:flex;width:44px;height:44px;border-radius:50%;background:#fff;border:0;align-items:center;justify-content:center;cursor:pointer}
  .b{max-width:85%}
  .board{grid-template-columns:repeat(4,minmax(260px,1fr))}
}
/* analytics */
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px}
.stat{background:var(--soft);border-radius:24px;padding:22px;display:flex;flex-direction:column;gap:6px}
.stat span{font-size:15px;color:var(--muted)}
.stat b{font-size:30px;font-weight:800;color:var(--blue)}
.stat small{font-size:13px;color:var(--muted)}
.stats2{display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start}
.stats2>.card{flex:999 1 420px;min-width:0}
.side-cards{flex:1 1 300px;display:flex;flex-direction:column;gap:16px}
.bars{display:flex;align-items:flex-end;gap:6px;height:220px;padding-top:10px;overflow-x:auto}
.sbar{flex:1 0 18px;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end}
.sbar .pair{display:flex;align-items:flex-end;gap:3px;height:100%;width:100%;justify-content:center}
.sbar .pair i{display:block;width:45%;max-width:22px;border-radius:6px 6px 2px 2px;min-height:2px}
.sbar small{font-size:11px;color:var(--muted);white-space:nowrap}
.legend{display:flex;gap:16px;font-size:13px;color:var(--muted)}
.legend i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px}
.line{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px dashed #E5E7EB;font-size:14px}
.line:last-child{border-bottom:0}
.line .v{margin-left:auto;font-weight:800;color:var(--blue)}
.muted{color:var(--muted);font-size:14px}
/* channels */
.chgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px}
.chcard{background:var(--soft);border-radius:24px;padding:22px;display:flex;flex-direction:column;gap:14px}
.chcard .top{display:flex;align-items:center;gap:12px}
.chcard .ic{width:48px;height:48px;border-radius:14px;color:#fff;font-weight:800;display:flex;align-items:center;justify-content:center}
.chcard b{font-size:19px;font-weight:800;display:block}
.pill{align-self:flex-start;font-size:13px;font-weight:700;padding:6px 12px;border-radius:999px}
.pill.ok{background:#E3F5EA;color:#15703D}.pill.pause{background:var(--warn-l);color:#92400E}.pill.off{background:#E9EBEF;color:var(--muted)}
.swrow{display:flex;align-items:center;gap:12px;background:#fff;border-radius:16px;padding:12px 16px;font-size:15px}
.swrow+.swrow{margin-top:8px}
.sw{flex:none;margin-left:auto;width:52px;height:30px;border:0;border-radius:999px;padding:3px;cursor:pointer;display:flex;background:#D1D5DB;justify-content:flex-start}
.sw.on{background:var(--blue);justify-content:flex-end}
.sw::after{content:"";width:24px;height:24px;border-radius:50%;background:#fff}
.h2{margin:8px 0 0;font-size:28px;font-weight:800}
#notify-list .swrow{background:var(--soft)}
/* agent settings */
.note-bar{background:var(--warn-l);color:#78350F;border-radius:16px;padding:12px 16px;font-size:14px;line-height:1.5}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px;align-items:start}
.fld{display:flex;flex-direction:column;gap:6px;font-size:14px;color:var(--muted)}
.fld input,.fld textarea,.fld select,.prow input{height:48px;border:0;border-radius:14px;background:#fff;padding:0 14px;font-size:15px;font-weight:700;color:var(--ink);width:100%}
.fld textarea{height:auto;padding:12px 14px}
.box{background:var(--soft);border-radius:24px;padding:22px;display:flex;flex-direction:column;gap:12px}
.box h3{margin:0;font-size:18px;font-weight:800}
.box .hint{font-size:13px;color:var(--muted);line-height:1.5}
.prow{display:grid;grid-template-columns:1fr 140px 44px;gap:8px;align-items:center}
.prow.kv2{grid-template-columns:1fr 1fr 44px}
.prow .x{width:44px;height:44px;border:0;border-radius:12px;background:#fff;color:#6B7280;font-size:18px;cursor:pointer}
.prow .x:hover{background:#FDECEC;color:#B42318}
.add{height:44px;border:2px dashed #C9D3E3;border-radius:14px;background:transparent;font-weight:700;color:var(--blue-d);cursor:pointer}
.nums{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.editor{width:100%;min-height:60vh;border:0;border-radius:20px;background:var(--soft);padding:18px;font:500 14px/1.6 ui-monospace,Menlo,Consolas,monospace;color:var(--ink);resize:vertical}
.actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.tag{font-size:13px;font-weight:700;padding:6px 12px;border-radius:999px;background:#E3F5EA;color:#15703D}
.tag.code{background:#E9EBEF;color:var(--muted)}
.calc{display:grid;grid-template-columns:2fr 1fr 1fr auto;gap:8px;align-items:end}
.calc-out{background:#fff;border-radius:14px;padding:12px 14px;font-size:14px;line-height:1.6;white-space:pre-wrap}
@media (max-width:900px){.calc{grid-template-columns:1fr 1fr}.prow{grid-template-columns:1fr 110px 44px}}
