:root{
  --bg:#f0f2f5;--panel:#fff;--line:#e4e6eb;--text:#050505;--muted:#65676b;--hover:#f2f2f2;--btn:#e4e6eb;
  --brand:#0866ff;--brand-soft:#e7f3ff;--bot:#7b4dff;--bot-soft:#f0ebff;
  --ok:#16a34a;--ok-soft:#e6f6ea;--warn:#d97706;--warn-soft:#fff4e0;--danger:#e41e3f;--danger-soft:#fdecee;
  --shadow:0 1px 2px rgba(0,0,0,.1),0 1px 1px rgba(0,0,0,.04);--radius:12px;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:"Segoe UI",Roboto,"Noto Sans","Helvetica Neue",Arial,sans-serif;background:var(--bg);color:var(--text);font-size:14.5px;overflow:hidden;-webkit-font-smoothing:antialiased}
button{font:inherit;cursor:pointer;border:none;background:none;color:inherit}
input,textarea,select{font:inherit;color:inherit}
.i{width:20px;height:20px;fill:currentColor;flex-shrink:0;vertical-align:-4px}
.h-ic{width:36px;height:36px;border-radius:50%;display:inline-grid;place-items:center;background:var(--brand-soft);color:var(--brand);flex-shrink:0}
.h-ic.purple{background:var(--bot-soft);color:var(--bot)}
.h-ic.tele{background:#e3f4fc;color:#229ed9}
.h-ic.green{background:var(--ok-soft);color:var(--ok)}
.h-ic.orange{background:#fff1e3;color:#ea580c}
.h-ic.pink{background:#fde7f1;color:#db2777}
.ttl{display:flex;align-items:center;gap:10px}
.muted{color:var(--muted)}
code{background:var(--bg);padding:1px 5px;border-radius:4px;font-size:12px}

.app{display:grid;grid-template-columns:76px 1fr;height:100vh;height:100dvh}
/* NAV */
.nav{background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;align-items:center;padding:14px 0;gap:4px;z-index:5}
.logo{width:44px;height:44px;border-radius:50%;background:linear-gradient(200deg,#00c6ff,#0866ff 55%,#a033ff);display:grid;place-items:center;color:#fff;margin-bottom:14px}
.logo .i{width:26px;height:26px}
.nav-btn{width:64px;padding:8px 0;border-radius:10px;color:var(--muted);display:flex;flex-direction:column;align-items:center;gap:3px;font-size:11px;font-weight:600;position:relative}
.nav-btn .i{width:24px;height:24px}
.nav-btn:hover{background:var(--hover)}
.nav-btn.active{background:var(--brand-soft);color:var(--brand)}
.nav-badge{position:absolute;top:2px;right:10px;background:var(--danger);border:2px solid #fff;color:#fff;font-size:10px;font-weight:700;border-radius:10px;padding:0 5px;line-height:15px}
.nav-spacer{flex:1}
.main{min-width:0;overflow:hidden}
.view{display:none;height:100%}
.view.active{display:block}

/* INBOX */
#v-inbox.active{display:grid;grid-template-columns:360px 1fr 320px}
.col{background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0;min-width:0}
.list-head{padding:14px 14px 6px}
.list-head h2{font-size:24px;font-weight:800;display:flex;align-items:center;justify-content:space-between}
.bot-master{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:700;color:var(--bot);background:var(--bot-soft);padding:5px 6px 5px 10px;border-radius:20px;cursor:pointer}
.bot-master.off{background:var(--btn);color:var(--muted)}
.bot-master .i{width:17px;height:17px}
.search-wrap{position:relative;margin-top:10px}
.search-wrap .i{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--muted);width:18px;height:18px}
.search{width:100%;padding:9px 12px 9px 38px;border:none;border-radius:20px;background:var(--bg);outline:none}
.chips{display:flex;gap:6px;overflow-x:auto;padding:10px 0 2px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{white-space:nowrap;padding:6px 12px;border-radius:18px;background:var(--btn);font-size:13px;font-weight:600}
.chip.active{background:var(--brand-soft);color:var(--brand)}
.chip .n{opacity:.6;margin-left:3px}
.page-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:5px;vertical-align:1px}
/* Thanh lọc gọn kiểu Pancake */
.list-head{position:relative}
.fbar{display:flex;gap:6px;align-items:center;margin-top:10px}
.pg-pick{display:flex;align-items:center;padding:3px 6px 3px 4px;border-radius:18px;background:var(--btn);flex-shrink:0;height:34px}
.pk-av{width:24px;height:24px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:9px;font-weight:800;border:2px solid #fff;margin-left:-8px}
.pk-av:first-child{margin-left:0}
.pk-av.big{width:34px;height:34px;font-size:11px;margin:0;border:none}
.caret{width:16px;height:16px;margin-left:2px;color:var(--muted)}
.fbtns{display:flex;gap:4px;overflow-x:auto;scrollbar-width:none;flex:1;min-width:0}
.fbtns::-webkit-scrollbar{display:none}
.fb{height:34px;min-width:34px;padding:0 8px;border-radius:17px;display:inline-flex;align-items:center;justify-content:center;gap:3px;color:var(--muted);font-size:13px;font-weight:600;position:relative;flex-shrink:0}
.fb .i{width:19px;height:19px}
.fb:hover{background:var(--hover)}
.fb.active{background:var(--brand-soft);color:var(--brand)}
.fc{font-size:10.5px;font-weight:700;background:var(--danger);color:#fff;border-radius:8px;padding:0 4px;line-height:15px;min-width:15px;text-align:center}
.fb:not(.active) .fc{background:#bcc0c4}
.fb[data-filter="need"] .fc,.fb[data-filter="unread"] .fc{background:var(--danger)}
.fsum{display:none;font-size:12.5px;color:var(--muted);margin-top:8px;align-items:center;gap:6px}
.fsum.show{display:flex}
.fsum b{color:var(--brand)}
.fsum button{margin-left:auto;color:var(--brand);font-weight:600;font-size:12.5px}
.dd{display:none;position:absolute;left:12px;right:12px;margin-top:6px;background:#fff;border-radius:12px;box-shadow:0 12px 28px rgba(0,0,0,.2),0 2px 4px rgba(0,0,0,.1);z-index:20;padding:8px;max-height:60vh;overflow-y:auto}
.dd.show{display:block}
.dd-title{font-weight:700;padding:6px 8px 8px;font-size:15px}
.dd-row{display:flex;align-items:center;gap:10px;padding:8px;border-radius:8px;cursor:pointer}
.dd-row:hover{background:var(--hover)}
.dd-row input{width:18px;height:18px;accent-color:var(--brand)}
.dd .tags-wrap{padding:4px 8px 8px}
.dd .tag{cursor:pointer;font-size:13px;padding:5px 11px}
.dd .tag.sel{outline:2px solid currentColor}

/* Cửa sổ kết nối Facebook */
.modal-bg{display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:90;align-items:center;justify-content:center;padding:16px}
.modal-bg.show{display:flex}
.modal{background:#fff;border-radius:14px;width:100%;max-width:460px;max-height:88vh;display:flex;flex-direction:column;box-shadow:0 12px 40px rgba(0,0,0,.3);overflow:hidden}
.modal-head{padding:16px 16px 12px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:10px}
.modal-head b{font-size:18px;flex:1}
.modal-body{padding:14px 16px;overflow-y:auto}
.modal-foot{padding:12px 16px;border-top:1px solid var(--line);display:flex;gap:8px;align-items:center}
.btn-fb{background:#1877f2;color:#fff;height:44px;font-size:15px;border-radius:8px}
.btn-fb .i{width:22px;height:22px}
.btn-fb:hover{background:#166fe5}
.fbpg{display:flex;align-items:center;gap:12px;padding:10px;border-radius:10px;cursor:pointer;border:1.5px solid transparent}
.fbpg:hover{background:var(--hover)}
.fbpg.sel{background:var(--brand-soft);border-color:#bcd6ff}
.fbpg.dis{opacity:.45;cursor:not-allowed}
.fbpg .nm{flex:1;min-width:0}
.fbpg .nm b{display:block}
.fbpg .nm span{font-size:12.5px;color:var(--muted)}
.ck{width:22px;height:22px;border-radius:50%;border:2px solid #bcc0c4;display:grid;place-items:center;flex-shrink:0;color:#fff}
.fbpg.sel .ck{background:var(--brand);border-color:var(--brand)}
.ck .i{width:14px;height:14px}
.step{display:flex;gap:10px;align-items:center;padding:8px 0;font-size:14px;color:var(--muted)}
.step.done{color:var(--text)}
.step .ck{width:22px;height:22px}
.step.done .ck{background:var(--ok);border-color:var(--ok)}
.step.run .ck{border-color:var(--brand);border-top-color:transparent;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
/* Lịch tháng */
.cal-bar{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:12px}
.cal-nav{display:flex;align-items:center;gap:6px}
.cal-nav b{font-size:17px}
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px;margin-bottom:14px}
.cal-h{font-size:12px;font-weight:700;color:var(--muted);text-align:center;padding:2px 0}
.cell{background:#fff;border-radius:10px;min-height:86px;padding:5px;box-shadow:var(--shadow);cursor:pointer;position:relative;overflow:hidden;min-width:0}
.cell:hover{background:var(--hover)}
.cell.other{background:transparent;box-shadow:none;opacity:.5}
.cell.past .dn{color:var(--muted)}
.cell .dn{width:26px;height:26px;border-radius:50%;display:grid;place-items:center;font-weight:700;font-size:13.5px;margin-bottom:2px}
.cell.today .dn{background:var(--brand);color:#fff}
.cell.sel{box-shadow:0 0 0 2px var(--brand)}
.cell .ev{font-size:11px;line-height:1.3;padding:2px 4px;margin-top:2px;border-left:3px solid;border-radius:3px;background:var(--bg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cell .more{font-size:11px;color:var(--muted);font-weight:700;padding:1px 4px}
.cell .cnt{display:none}
.grp-h{font-size:13px;font-weight:800;color:var(--brand);text-transform:uppercase;letter-spacing:.3px;margin:18px 0 6px}
.day-h{font-weight:700;margin:10px 0 8px;display:flex;justify-content:space-between;align-items:center}
.day-h span{font-size:12.5px;color:var(--muted);font-weight:600}

/* Thống kê */
.st-filters{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:14px}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:14px}
.kpi{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:14px 16px}
.kpi .lb{display:flex;align-items:center;gap:8px;font-size:13.5px;color:var(--muted);font-weight:600}
.kpi .lb .h-ic{width:30px;height:30px}
.kpi .lb .h-ic .i{width:17px;height:17px}
.kpi .vl{font-size:30px;font-weight:800;margin:8px 0 2px;letter-spacing:-.5px}
.kpi .sub{font-size:12.5px;color:var(--muted)}
.delta{font-size:12.5px;font-weight:700;margin-top:6px}
.delta.up{color:var(--ok)}.delta.down{color:var(--danger)}.delta.flat{color:var(--muted)}
.delta span{font-weight:400;color:var(--muted)}
.legend{display:flex;gap:14px;font-size:12.5px;color:var(--muted);margin:-4px 0 6px;flex-wrap:wrap}
.legend i{display:inline-block;width:14px;height:3px;border-radius:2px;vertical-align:middle;margin-right:5px}
.chart{position:relative;width:100%}
.chart svg{display:block;width:100%;height:auto;overflow:visible}
.chart .ax{font-size:11px;fill:var(--muted)}
.chart .grid{stroke:#e9ebee;stroke-width:1}
.chart .lbl{font-size:11.5px;font-weight:700;fill:var(--text)}
.tip{position:fixed;pointer-events:none;background:#fff;border-radius:8px;box-shadow:0 6px 20px rgba(0,0,0,.18);padding:8px 10px;font-size:12.5px;z-index:120;display:none;min-width:130px;line-height:1.5}
.tip b{display:block;margin-bottom:2px}
.tip .sw2{display:inline-block;width:9px;height:9px;border-radius:2px;margin-right:5px;vertical-align:0}
.fn-row{margin-bottom:12px}
.fn-top{display:flex;justify-content:space-between;font-size:13.5px;margin-bottom:4px}
.fn-top b{font-size:15px}
.fn-top span{color:var(--muted)}
.fn-bar{height:14px;background:var(--bg);border-radius:4px;overflow:hidden}
.fn-bar i{display:block;height:100%;background:#0866ff;border-radius:0 4px 4px 0;min-width:4px}
.who-row{margin-bottom:14px}
.who-row .fn-top{align-items:center}
.who-row .fn-top b{display:flex;align-items:center;gap:6px;font-size:14px}
.who-row .i{width:18px;height:18px}

/* Form sửa lịch / thẻ */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 10px}
.form-grid .full{grid-column:1/-1}
.swatches{display:flex;gap:8px;flex-wrap:wrap}
.swatch{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;cursor:pointer;border:2px solid transparent;font-weight:800;font-size:13px}
.swatch.sel{border-color:var(--text)}
.tag-row{display:flex;align-items:center;gap:10px;padding:9px 0;border-bottom:1px solid var(--line)}
.tag-row:last-child{border:none}
.tag-row .cnt{font-size:12.5px;color:var(--muted);flex:1}
.ap .icon-btn,.box .icon-btn{width:32px;height:32px}
.ap .icon-btn .i,.box .icon-btn .i{width:18px;height:18px}
.btn-danger{background:var(--danger);color:#fff}

/* Kết nối AI */
.aip{border:1.5px solid var(--line);border-radius:12px;padding:12px;margin-bottom:10px;transition:.15s}
.aip.on{border-color:#bcd6ff;background:#fafcff}
.aip-top{display:flex;align-items:center;gap:10px}
.aip-logo{width:38px;height:38px;border-radius:10px;display:grid;place-items:center;color:#fff;font-weight:800;font-size:15px;flex-shrink:0}
.aip-top .nm{flex:1;min-width:0}
.aip-top .nm b{display:block}
.aip-top .nm span{font-size:12.5px;color:var(--muted)}
.aip-body{margin-top:10px;display:none}
.aip.on .aip-body{display:block}
.aip-body label.dd-row{display:flex;margin:0}
.aip-body label{display:block;font-size:12.5px;font-weight:700;margin:8px 0 4px}
.role{font-size:11px;font-weight:700;padding:2px 8px;border-radius:10px;white-space:nowrap}
.role.main{background:var(--brand);color:#fff}
.role.bak{background:var(--btn);color:var(--muted)}
.mdl-note{font-size:12px;color:var(--muted);margin-top:4px;line-height:1.45}
.dep{font-size:12px;color:var(--muted);background:var(--bg);border-radius:10px;padding:9px 11px;margin-top:10px;line-height:1.55}
.dep s{color:#9aa0a6}
.big-ok{width:64px;height:64px;border-radius:50%;background:var(--ok-soft);color:var(--ok);display:grid;place-items:center;margin:6px auto 12px}
.big-ok .i{width:34px;height:34px}

.conv-list{flex:1;overflow-y:auto;padding:4px 6px}
.conv{display:flex;gap:11px;padding:10px;border-radius:10px;cursor:pointer;position:relative}
.conv:hover{background:var(--hover)}
.conv.active{background:var(--brand-soft)}
.conv.need{box-shadow:inset 3px 0 0 var(--danger)}
.av{width:56px;height:56px;border-radius:50%;display:grid;place-items:center;color:#fff;font-weight:700;flex-shrink:0;position:relative;font-size:18px}
.av .pg{position:absolute;right:-2px;bottom:-2px;width:22px;height:22px;border-radius:50%;border:2px solid #fff;display:grid;place-items:center;color:#fff}
.av .pg .i{width:12px;height:12px}
.pg.msg{background:linear-gradient(200deg,#00c6ff,#0866ff 55%,#a033ff)}
.pg.cmt{background:#f59e0b}
.conv-body{flex:1;min-width:0;padding-top:2px}
.conv-top{display:flex;justify-content:space-between;gap:8px}
.conv-name{font-weight:600;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conv.unread .conv-name{font-weight:800}
.conv-time{font-size:12px;color:var(--muted);flex-shrink:0}
.conv-last{color:var(--muted);font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.conv.unread .conv-last{color:var(--text);font-weight:700}
.conv-meta{display:flex;gap:4px;margin-top:5px;flex-wrap:wrap;align-items:center}
.tag{font-size:11.5px;font-weight:600;padding:2px 8px;border-radius:10px;white-space:nowrap}
.src{font-size:11.5px;font-weight:600;padding:2px 8px;border-radius:10px;background:var(--bg);color:var(--muted);display:inline-flex;align-items:center;gap:3px}
.src .i{width:12px;height:12px}
.src.camp{background:var(--brand-soft);color:var(--brand)}
.src.cmt{background:#fff1e3;color:#c2410c}
.bot-ic{color:var(--bot);display:inline-flex}
.bot-ic .i{width:15px;height:15px}
.conv-row{display:flex;align-items:center;gap:8px}
.conv-row>.conv-last,.conv-row>.conv-meta{flex:1;min-width:0}
.conv-meta:empty{display:none}
.conv-phone{color:#22c55e;display:inline-flex;flex-shrink:0;margin-top:5px}
.conv-phone .i{width:17px;height:17px}
.unread-dot{width:10px;height:10px;border-radius:50%;background:var(--brand);flex-shrink:0}

/* CHAT */
.chat{background:#fff;display:flex;flex-direction:column;min-height:0;min-width:0;border-right:1px solid var(--line)}
.chat-head{background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.08);padding:9px 12px;display:flex;align-items:center;gap:10px;z-index:2}
.chat-head .av{width:40px;height:40px;font-size:14px}
.chat-title{flex:1;min-width:0}
.chat-title b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:15px}
.chat-title span{font-size:12px;color:var(--muted)}
.timer{font-size:12px;font-weight:700;padding:5px 9px;border-radius:16px;background:var(--ok-soft);color:var(--ok);white-space:nowrap;display:inline-flex;align-items:center;gap:4px}
.timer .i{width:14px;height:14px}
.timer.warn{background:var(--warn-soft);color:var(--warn)}
.timer.dead{background:var(--danger-soft);color:var(--danger)}
.timer.in{display:none}
.icon-btn{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;color:var(--brand);flex-shrink:0}
.icon-btn .i{width:22px;height:22px}
.icon-btn:hover{background:var(--hover)}
.icon-btn.gray{color:var(--muted)}
.icon-btn.gray:hover{color:var(--danger)}
.back-btn{display:none}
.bot-toggle{display:flex;align-items:center;gap:6px;padding:4px 5px 4px 10px;border-radius:20px;background:var(--bot-soft);color:var(--bot);font-weight:700;font-size:12.5px}
.bot-toggle .i{width:17px;height:17px}
.bot-toggle.off{background:var(--btn);color:var(--muted)}
.sw{width:36px;height:21px;border-radius:21px;background:#ccd0d5;position:relative;transition:.2s;flex-shrink:0;cursor:pointer;display:inline-block}
.sw::after{content:"";position:absolute;width:17px;height:17px;border-radius:50%;background:#fff;top:2px;left:2px;transition:.2s;box-shadow:0 1px 2px rgba(0,0,0,.25)}
.sw.on{background:var(--brand)}
.sw.on.purple{background:var(--bot)}
.sw.on::after{left:17px}

.cbar{margin:8px 12px 0;padding:8px 12px;border-radius:12px;font-size:13px;display:flex;gap:10px;align-items:center;line-height:1.4}
.cbar .i{width:18px;height:18px;flex-shrink:0}
.cbar.camp{background:var(--bg)}
.cbar .thumb{width:40px;height:40px;border-radius:8px;flex-shrink:0;display:grid;place-items:center;font-size:20px;background:#fff;box-shadow:var(--shadow)}
.cbar .camp-lbl{display:inline-flex;align-items:center;gap:4px;color:var(--brand);font-weight:700}
.cbar .camp-lbl .i{width:14px;height:14px}
.cbar .crumb{color:var(--muted)}
.cbar b{color:var(--text)}
.cbar .lnk{margin-left:auto;font-weight:700;color:var(--brand);white-space:nowrap}
.cbar.cmt{background:#fff7ed;color:#9a3412}
.cbar.pause{background:var(--warn-soft);color:#92400e}
.cbar.need{background:var(--danger-soft);color:#9f1239}
.cbar.appt{background:var(--ok-soft);color:#14532d}

.msgs{flex:1;overflow-y:auto;padding:14px 14px 6px;display:flex;flex-direction:column;gap:3px}
.day{align-self:center;font-size:12px;color:var(--muted);margin:10px 0;font-weight:600}
.m{max-width:72%;display:flex;flex-direction:column}
.m .bub{padding:8px 12px;border-radius:18px;line-height:1.4;white-space:pre-wrap;word-wrap:break-word;font-size:15px}
.m .who{font-size:11.5px;color:var(--muted);margin:8px 8px 2px;display:inline-flex;align-items:center;gap:3px}
.m .who .i{width:13px;height:13px}
.m.in{align-self:flex-start;padding-left:36px;position:relative}
.m.in .bub{background:#f0f0f0}
.mav{position:absolute;left:0;bottom:16px;width:28px;height:28px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:11px;font-weight:700}
.m.out{align-self:flex-end;align-items:flex-end}
.m.out .bub{background:#0084ff;color:#fff}
.m.bot .bub{background:linear-gradient(135deg,#7b4dff,#a855f7);color:#fff}
.m.bot .who{color:var(--bot)}
.m.sys{align-self:center;max-width:90%}
.m.sys .bub{background:transparent;color:var(--muted);font-size:12.5px;padding:2px 8px;text-align:center}
.m .t{font-size:11px;color:var(--muted);margin:2px 8px 0}
.cmt-quote{font-size:12px;background:#fff7ed;border-radius:12px;padding:5px 10px;margin-bottom:3px;color:#9a3412;display:flex;gap:4px;align-items:center}
.cmt-quote .i{width:13px;height:13px}
.qr-chips{display:flex;gap:6px;margin-top:5px;justify-content:flex-end}
.qrc{border:1.5px solid var(--brand);color:var(--brand);background:#fff;border-radius:18px;padding:5px 12px;font-size:13px;font-weight:700;display:inline-flex;align-items:center;gap:5px}
.qrc .i{width:15px;height:15px}
.qr-note{font-size:11px;color:var(--muted);margin:3px 8px 0;text-align:right}
.qr-note a{color:var(--brand)}
.appt-card{margin-top:5px;background:#fff;border:1px solid var(--line);border-radius:14px;padding:9px 12px;font-size:13px;box-shadow:var(--shadow);min-width:220px}
.appt-card b{display:flex;align-items:center;gap:6px;color:var(--ok)}
.appt-card b .i{width:16px;height:16px}
.typing{align-self:flex-start;background:#f0f0f0;border-radius:18px;padding:11px 14px;display:none;gap:4px;margin:4px 0 4px 36px}
.typing.show{display:flex}
.typing i{width:7px;height:7px;border-radius:50%;background:#90949c;animation:bl 1s infinite}
.typing i:nth-child(2){animation-delay:.2s}.typing i:nth-child(3){animation-delay:.4s}
@keyframes bl{50%{opacity:.3}}

.composer{background:#fff;padding:6px 12px 10px}
.quick{display:flex;gap:6px;overflow-x:auto;padding-bottom:8px;scrollbar-width:none}
.quick::-webkit-scrollbar{display:none}
.qr{white-space:nowrap;font-size:12.5px;padding:5px 11px;border-radius:16px;background:var(--brand-soft);color:var(--brand);font-weight:600}
.compose-row{display:flex;gap:6px;align-items:flex-end}
.compose-row textarea{flex:1;resize:none;border:none;background:var(--bg);border-radius:20px;padding:10px 14px;min-height:40px;max-height:120px;outline:none;line-height:1.4}
.round{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;flex-shrink:0}
.round .i{width:22px;height:22px}
.name-edit{font:inherit;font-weight:700;font-size:17px;text-align:center;border:1px dashed transparent;border-radius:8px;background:none;color:inherit;width:100%;padding:3px 6px;margin-top:6px}
.name-edit:hover,.name-edit:focus{border-color:var(--line,#ccd0d5);outline:none;background:var(--bg)}
.md-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:8px}
.md-th{position:relative;display:block;aspect-ratio:1;border-radius:10px;overflow:hidden;background:var(--bg);cursor:pointer;border:3px solid transparent}
.md-th img{width:100%;height:100%;object-fit:cover;display:block}
.md-th.sel{border-color:var(--brand)}
.md-th.sel::after{content:'✓';position:absolute;top:4px;right:4px;width:22px;height:22px;border-radius:50%;background:var(--brand);color:#fff;display:grid;place-items:center;font-weight:700;font-size:13px}
.play{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:34px;height:34px;border-radius:50%;background:rgba(0,0,0,.55);color:#fff;display:grid;place-items:center;font-size:14px;pointer-events:none}
.md-cell{display:flex;flex-direction:column;gap:4px;min-width:0}
.md-meta{font-size:11.5px;color:var(--muted);line-height:1.35;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.md-acts{display:flex;gap:4px;align-items:center}
.md-acts select{flex:1;min-width:0;font-size:12px;padding:3px 4px;border-radius:6px;border:1px solid var(--line,#dadde1);background:var(--card,#fff);color:inherit}
.md-tabs{display:flex;gap:6px;overflow-x:auto;padding-bottom:8px;margin-bottom:6px}
.md-tabs button{white-space:nowrap;padding:6px 12px;border-radius:16px;background:var(--bg);font-size:13px;font-weight:600}
.md-tabs button.active{background:var(--brand-soft);color:var(--brand)}
.qa.on-off span{background:var(--danger-soft,#fee2e2)!important;color:var(--danger,#dc2626)!important}
.camp-st{font-size:11px;font-weight:700;padding:1px 7px;border-radius:9px;background:var(--bg);color:var(--muted);white-space:nowrap;vertical-align:1px}
.camp-st.on{background:#dcfce7;color:#15803d}
tr.camp-off td{opacity:.6}
.ap-br{font-size:13px;font-weight:600;color:#0f766e;margin-top:2px}
.ap-br.unk{color:#b45309;font-weight:500}
.att-sticker{width:64px;height:64px;object-fit:contain;display:block;margin-top:2px}
.att-media{position:relative;display:inline-block}
.round.att{color:var(--brand);cursor:pointer}
.round.att:hover{background:var(--brand-soft)}
.round.ai{color:var(--bot)}
.round.ai:hover{background:var(--bot-soft)}
.round.send{color:var(--brand)}
.round.send:hover{background:var(--brand-soft)}
.locked{padding:12px;text-align:center;color:var(--danger);font-size:13px;font-weight:600;background:var(--danger-soft);border-radius:12px}
.sim{display:flex;justify-content:center;padding:6px 0 0}
.sim button{font-size:12.5px;color:var(--muted);text-decoration:underline dotted}

/* INFO */
.info{background:#fff;overflow-y:auto;min-height:0}
.info-top{padding:22px 16px 14px;text-align:center;position:relative}
.info-top .av{width:80px;height:80px;font-size:26px;margin:0 auto 10px}
.info-top b{font-size:17px}
.info-top .sub{font-size:12.5px;color:var(--muted);margin-top:2px}
.info-close{display:none;position:absolute;top:10px;right:10px}
.grab{display:none}
.quick-acts{display:flex;justify-content:center;gap:18px;margin-top:12px}
.qa{display:flex;flex-direction:column;align-items:center;gap:4px;font-size:11.5px;color:var(--text)}
.qa span:first-child{width:36px;height:36px;border-radius:50%;background:var(--btn);display:grid;place-items:center}
.qa .i{width:18px;height:18px}
.sec{padding:12px 16px;border-top:1px solid var(--line)}
.sec h4{font-size:15px;font-weight:700;margin-bottom:9px;display:flex;justify-content:space-between;align-items:center}
.sec h4 button{color:var(--brand);font-size:13px;font-weight:600}
.kv{display:flex;gap:10px;font-size:14px;padding:5px 0;align-items:center}
.kv .i{color:var(--muted);width:18px;height:18px}
.kv input{flex:1;border:none;border-bottom:1px dashed var(--line);outline:none;padding:2px 0;min-width:0}
.tags-wrap{display:flex;flex-wrap:wrap;gap:5px}
.tags-wrap .tag{cursor:pointer;font-size:12.5px;padding:4px 10px}
.add-tag{font-size:12.5px;padding:4px 10px;border-radius:10px;border:1px dashed #bcc0c4;color:var(--muted)}
.tag-menu{display:none;flex-wrap:wrap;gap:5px;margin-top:8px;padding:8px;background:var(--bg);border-radius:10px}
.tag-menu.show{display:flex}
.tag-menu .tag{cursor:pointer}
.camp-card{background:var(--bg);border-radius:10px;padding:10px 12px;font-size:13px;line-height:1.7}
.camp-card .row{display:flex;gap:6px}
.camp-card .row span:first-child{color:var(--muted);width:74px;flex-shrink:0}
.box{border-radius:12px;padding:11px 12px;font-size:13.5px;line-height:1.6;background:var(--bg)}
.box.green{background:var(--ok-soft)}
.box .top{display:flex;justify-content:space-between;align-items:center;gap:6px}
.st{display:inline-block;font-size:11.5px;font-weight:700;padding:2px 8px;border-radius:10px;background:var(--warn-soft);color:var(--warn);white-space:nowrap}
.st.ok{background:var(--ok-soft);color:var(--ok)}
.st.done{background:var(--brand-soft);color:var(--brand)}
.st.cancel{background:var(--btn);color:var(--muted);text-decoration:line-through}
.acts{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
.progress{height:8px;border-radius:8px;background:#dfe3e8;overflow:hidden;margin-top:6px}
.progress i{display:block;height:100%;background:var(--ok)}
.note{width:100%;border:none;background:var(--bg);border-radius:10px;padding:9px 11px;min-height:64px;resize:vertical;outline:none;font-size:13.5px}
.log{font-size:12.5px;color:var(--muted);padding:3px 0;line-height:1.45}
.log b{color:var(--text);font-weight:600}

/* BUTTONS */
.btn{padding:0 14px;height:38px;border-radius:8px;font-weight:600;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap;font-size:14px}
.btn .i{width:18px;height:18px}
.btn-pri{background:var(--brand);color:#fff}
.btn-pri:hover{background:#0759e0}
.btn-ghost{background:var(--btn)}
.btn-ghost:hover{background:#d8dadf}
.btn-soft{background:var(--brand-soft);color:var(--brand)}
.btn-ok{background:var(--ok);color:#fff}
.btn-sm{height:32px;padding:0 11px;font-size:13px}

/* PAGES */
.page{height:100%;overflow-y:auto;padding:22px 26px 80px}
.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:16px;flex-wrap:wrap}
.page-head h1{font-size:24px;font-weight:800}
.page-head p{color:var(--muted);margin-top:4px;max-width:660px;line-height:1.5}
.card{background:#fff;border-radius:var(--radius);padding:16px;margin-bottom:14px;box-shadow:var(--shadow)}
.card>h3{font-size:16px;margin-bottom:12px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px;align-items:start}
.seg{display:inline-flex;background:var(--btn);border-radius:10px;padding:3px;gap:2px}
.seg button{padding:6px 12px;border-radius:8px;font-size:13px;font-weight:600;color:var(--muted);white-space:nowrap;display:inline-flex;align-items:center;gap:5px}
.seg button .i{width:16px;height:16px}
.seg button.active{background:#fff;color:var(--brand);box-shadow:var(--shadow)}
.tabs{display:flex;gap:4px;overflow-x:auto;scrollbar-width:none;border-bottom:1px solid var(--line);margin-bottom:14px}
.tabs::-webkit-scrollbar{display:none}
.tabs button{padding:10px 14px;font-weight:600;color:var(--muted);white-space:nowrap;border-bottom:3px solid transparent;display:inline-flex;align-items:center;gap:6px;border-radius:8px 8px 0 0}
.tabs button .i{width:18px;height:18px}
.tabs button:hover{background:var(--hover)}
.tabs button.active{color:var(--brand);border-bottom-color:var(--brand)}
.tabs .cnt{font-size:11px;background:var(--btn);color:var(--muted);border-radius:10px;padding:0 6px}
.field{margin-bottom:12px}
.field label{display:block;font-size:13px;font-weight:700;margin-bottom:5px}
.field textarea,.field input,.field select{width:100%;border:1px solid #ccd0d5;border-radius:8px;padding:9px 11px;outline:none;background:#fff}
.field textarea{min-height:70px;resize:vertical;line-height:1.5}
.field textarea:focus,.field input:focus,.field select:focus,.inp:focus{border-color:var(--brand);box-shadow:0 0 0 2px var(--brand-soft)}
.hint{font-size:12.5px;color:var(--muted);margin-top:4px;line-height:1.45}
.inp{border:1px solid #ccd0d5;border-radius:8px;padding:8px 10px;outline:none;background:#fff;width:100%;min-width:0}
.key-row{display:flex;gap:6px;align-items:center}
.key-row input{flex:1;min-width:0}
.set-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}
.set-row:last-child{border:none}
.set-row .tx{flex:1;min-width:0}
.set-row .tx b{display:block;font-weight:600}
.set-row .tx span{font-size:12.5px;color:var(--muted)}
.pg-av{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;color:#fff;font-weight:800;font-size:12px;flex-shrink:0}
.ok-pill{font-size:11.5px;font-weight:700;color:var(--ok);background:var(--ok-soft);padding:2px 9px;border-radius:10px;white-space:nowrap}

/* Dạy bot */
.bot-grid{display:grid;grid-template-columns:1fr 380px;gap:16px;align-items:start}
.bot-grid>*{min-width:0}
.sticky{position:sticky;top:0}
.item{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:12px 14px;margin-bottom:10px}
.item.off{opacity:.55}
.item-top{display:flex;gap:8px;align-items:center;margin-bottom:8px}
.no{width:26px;height:26px;border-radius:50%;background:var(--brand-soft);color:var(--brand);display:grid;place-items:center;font-weight:700;font-size:12px;flex-shrink:0}
.no.purple{background:var(--bot-soft);color:var(--bot)}
.item label{display:block;font-size:12px;font-weight:700;color:var(--muted);margin:8px 0 4px}
.item textarea{width:100%;border:1px solid #ccd0d5;border-radius:8px;padding:8px 10px;outline:none;min-height:60px;resize:vertical;line-height:1.5}
.item textarea:focus{border-color:var(--brand)}
.kw-chips{display:flex;flex-wrap:wrap;gap:4px;margin-top:5px}
.kw-chips span{font-size:11.5px;background:var(--warn-soft);color:#92400e;border-radius:8px;padding:1px 7px;font-weight:600}
.svc-row{display:grid;grid-template-columns:40px 1fr 110px 90px 36px;gap:8px;align-items:center;padding:8px 0;border-bottom:1px solid var(--line)}
.svc-row:last-child{border:none}
.svc-ic{width:40px;height:40px;border-radius:10px;background:var(--bg);display:grid;place-items:center;font-size:20px}
.svc-head{font-size:11.5px;font-weight:700;color:var(--muted);text-transform:uppercase;border:none;padding-bottom:0}
.as-box textarea{width:100%;border:1px solid var(--line,#dadde1);border-radius:10px;padding:10px 12px;font:inherit;resize:vertical;background:var(--card,#fff);color:inherit}
.as-row{display:flex;align-items:center;gap:8px;margin-top:10px;flex-wrap:wrap}
.as-row label.btn{cursor:pointer}
.as-imgs{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}
.as-img{position:relative;width:84px;height:84px;border-radius:10px;overflow:hidden;background:var(--bg)}
.as-img img{width:100%;height:100%;object-fit:cover}
.as-img button{position:absolute;top:3px;right:3px;width:22px;height:22px;border-radius:50%;background:rgba(0,0,0,.6);color:#fff;display:grid;place-items:center}
.as-img button .i{width:12px;height:12px}
.as-note{display:flex;gap:8px;align-items:flex-start;font-size:13.5px;line-height:1.5;padding-bottom:10px;border-bottom:1px solid var(--line,#e4e6eb);margin-bottom:6px}
.as-note>.i{color:var(--bot);flex-shrink:0;margin-top:2px}
.as-grp{font-size:12px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.3px;margin:12px 0 4px}
.as-item{display:flex;align-items:flex-start;gap:9px;padding:8px 4px;border-radius:8px;cursor:pointer}
.as-item.off{opacity:.45}
.as-item input{margin-top:3px;width:17px;height:17px;flex-shrink:0;accent-color:var(--brand)}
.as-ic{font-size:18px;line-height:1.2;flex-shrink:0}
.as-tx{flex:1;min-width:0;display:flex;flex-direction:column;font-size:13.5px}
.as-tx span{color:var(--muted);font-size:12.5px;white-space:pre-wrap}
.as-tag{font-size:11px;font-weight:700;padding:2px 8px;border-radius:10px;background:#dcfce7;color:#15803d;flex-shrink:0}
.as-tag.upd{background:#fef3c7;color:#b45309}
.spin.sm{width:14px;height:14px;border-width:2px;margin:0 4px 0 0;display:inline-block;vertical-align:-2px}
.add-line{width:100%;margin-top:6px;padding:10px;border:1.5px dashed #bcc0c4;border-radius:10px;color:var(--brand);font-weight:600;display:flex;align-items:center;justify-content:center;gap:6px}
.add-line .i{width:18px;height:18px}
.add-line:hover{background:var(--brand-soft);border-color:var(--brand)}
.prio{display:flex;gap:8px;align-items:center;font-size:12.5px;color:var(--muted);background:var(--bg);border-radius:10px;padding:9px 12px;margin-bottom:12px;line-height:1.5}
.prio b{color:var(--text)}
.test-box{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);display:flex;flex-direction:column;height:520px;overflow:hidden}
.test-head{padding:12px 14px;border-bottom:1px solid var(--line);font-weight:700;display:flex;align-items:center;gap:8px}
.test-box .msgs{padding:12px}
.src-lbl{font-size:10.5px;color:var(--bot);margin:2px 8px 0;font-weight:600}
.test-row{display:flex;gap:6px;padding:8px 10px;border-top:1px solid var(--line)}
.test-row input{flex:1;border:none;background:var(--bg);border-radius:20px;padding:9px 14px;outline:none}

/* Lịch hẹn */
.days{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;padding-bottom:4px;margin-bottom:14px}
.days::-webkit-scrollbar{display:none}
.dbtn{min-width:72px;padding:9px 6px;border-radius:12px;background:#fff;box-shadow:var(--shadow);text-align:center;flex-shrink:0}
.dbtn .dw{font-size:12px;color:var(--muted);font-weight:600}
.dbtn .dd{font-size:20px;font-weight:800;margin:1px 0}
.dbtn .dc{font-size:11px;font-weight:700;color:var(--brand)}
.dbtn.active{background:var(--brand);color:#fff}
.dbtn.active .dw,.dbtn.active .dc{color:#dbe7ff}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:14px}
.stat{background:#fff;border-radius:var(--radius);padding:12px 14px;box-shadow:var(--shadow)}
.stat .lb{font-size:12.5px;color:var(--muted)}
.stat .vl{font-size:24px;font-weight:800;margin-top:2px}
.stat .df{font-size:12px;color:var(--ok);font-weight:600}
.ap{display:flex;gap:14px;background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:12px 14px;margin-bottom:10px;align-items:center}
.ap.cancel{opacity:.5}
.ap-time{width:62px;text-align:center;flex-shrink:0}
.ap-time b{display:block;font-size:19px}
.ap-time span{font-size:11.5px;color:var(--muted)}
.ap-bar{width:4px;align-self:stretch;border-radius:4px;flex-shrink:0}
.ap-body{flex:1;min-width:0}
.ap-body .nm{font-weight:700;font-size:15px}
.ap-body .sv{font-size:13.5px;margin-top:1px}
.ap-body .mt{font-size:12.5px;color:var(--muted);margin-top:4px;display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.ap-body .mt .i{width:14px;height:14px}
.by{font-size:11px;font-weight:700;padding:1px 7px;border-radius:8px;display:inline-flex;align-items:center;gap:3px}
.by .i{width:12px;height:12px}
.by.bot{background:var(--bot-soft);color:var(--bot)}
.by.me{background:var(--brand-soft);color:var(--brand)}
.by.call{background:var(--bg);color:var(--muted)}
.ap-acts{display:flex;gap:6px;flex-shrink:0;align-items:center;flex-wrap:wrap;justify-content:flex-end}
.empty{padding:40px;text-align:center;color:var(--muted)}

/* Quảng cáo / luật */
.tbl-wrap{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:13.5px;min-width:820px}
th{text-align:left;font-size:12px;color:var(--muted);padding:11px 14px;border-bottom:1px solid var(--line);white-space:nowrap;font-weight:700}
td{padding:11px 14px;border-bottom:1px solid var(--line);white-space:nowrap}
td.num,th.num{text-align:right}
tr.camp td{background:#f7f8fa;font-weight:700}
tr.ad td:first-child{padding-left:30px}
.good{color:var(--ok);font-weight:700}.bad{color:var(--danger);font-weight:700}
.ad-cards{display:none}
.adc{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);margin-bottom:10px;overflow:hidden}
.adc-head{padding:12px 14px;font-weight:700;display:flex;justify-content:space-between;gap:8px;border-bottom:1px solid var(--line)}
.adc-row{padding:11px 14px;border-bottom:1px solid var(--line)}
.adc-row:last-child{border:none}
.adc-name{font-weight:600;margin-bottom:7px}
.adc-nums{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;text-align:center}
.adc-nums div{background:var(--bg);border-radius:8px;padding:6px 2px}
.adc-nums b{display:block;font-size:15px}
.adc-nums span{font-size:10.5px;color:var(--muted)}
.rule{display:flex;gap:12px;align-items:center;background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);padding:14px 16px;margin-bottom:10px}
.rule.off{opacity:.55}
.rule-body{flex:1;min-width:0}
.rule-title{font-weight:700;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.kind{font-size:11px;font-weight:700;padding:2px 8px;border-radius:10px;background:var(--btn);color:var(--muted)}
.kind.ai{background:var(--bot-soft);color:var(--bot)}
.rule-line{margin-top:7px;font-size:13.5px;display:flex;gap:6px;flex-wrap:wrap;align-items:center;line-height:1.7}
.kw{background:var(--warn-soft);color:#92400e;border-radius:6px;padding:1px 7px;font-weight:600;font-size:12.5px}
.lbl{font-size:11px;font-weight:800;color:var(--muted)}
.act{background:var(--ok-soft);color:#166534;border-radius:6px;padding:1px 7px;font-weight:600;font-size:12.5px}
.rule-hit{font-size:12px;color:var(--muted);text-align:right;flex-shrink:0}
.rule-hit b{display:block;font-size:17px;color:var(--text)}

.toast-box{position:fixed;right:18px;bottom:18px;display:flex;flex-direction:column;gap:8px;z-index:99}
.toast{background:#fff;color:var(--text);padding:11px 14px;border-radius:10px;font-size:13.5px;box-shadow:0 8px 28px rgba(0,0,0,.18);animation:tin .25s ease;max-width:360px;line-height:1.4;border-left:4px solid var(--brand)}
@keyframes tin{from{transform:translateY(10px);opacity:0}}
.overlay{display:none}

/* ==== Máy tính bảng ==== */
@media (max-width:1250px){
  #v-inbox.active{grid-template-columns:330px 1fr}
  .info{position:fixed;right:0;top:0;bottom:0;width:340px;z-index:50;box-shadow:-8px 0 30px rgba(0,0,0,.15);transform:translateX(100%);transition:.25s}
  body.show-info .info{transform:none}
  body.show-info .overlay{display:block;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:40}
  .info-close{display:grid}
  .bot-grid{grid-template-columns:1fr}
  .sticky{position:static}
}
@media (min-width:1251px){ .info-btn{display:none} }

/* ==== Điện thoại ==== */
@media (max-width:760px){
  body{font-size:15px}
  .app{grid-template-columns:1fr;grid-template-rows:minmax(0,1fr) auto}
  .main{order:1;min-height:0}
  .nav{order:2;flex-direction:row;justify-content:space-around;gap:0;padding:2px 0 calc(2px + env(safe-area-inset-bottom));border-right:none;border-top:1px solid var(--line)}
  .logo,.nav-spacer{display:none}
  .nav-btn{width:auto;flex:1;padding:7px 0 5px;font-size:10.5px;border-radius:0}
  .nav-btn:hover,.nav-btn.active{background:none}
  .nav-btn.active::after{content:"";position:absolute;left:25%;right:25%;top:0;height:3px;border-radius:0 0 3px 3px;background:var(--brand)}
  .nav-badge{right:calc(50% - 22px)}
  body.show-chat .nav{display:none}

  #v-inbox.active{grid-template-columns:1fr;height:100%}
  .list-head{padding:calc(4px + env(safe-area-inset-top)) 12px 2px}
  .list-head h2{font-size:21px;line-height:1.2}
  .list-head .bot-master{padding:3px 5px 3px 9px}
  .search-wrap{margin-top:6px}
  .fbar{margin-top:6px}
  .search{font-size:16px;padding:10px 12px 10px 38px}
  .chip{padding:7px 13px;font-size:13.5px}
  .conv{padding:9px 8px}
  .conv-name{font-size:16px}
  .conv-last{font-size:14px}
  .chat{display:none;border:none}
  body.show-chat #v-inbox .list{display:none}
  body.show-chat #v-inbox .chat{display:flex}
  .chat-head{gap:4px;padding:calc(6px + env(safe-area-inset-top)) 6px 6px}
  .back-btn{display:grid}
  .chat-head .av{width:38px;height:38px}
  .timer{font-size:11.5px;padding:4px 7px}
  .bot-toggle .lb{display:none}
  .bot-toggle{padding:4px 5px 4px 8px}
  .cbar{margin:6px 8px 0;padding:7px 10px;font-size:12.5px}
  .cbar .thumb{width:34px;height:34px;font-size:17px}
  .cbar>div{min-width:0;flex:1}
  .cbar .crumb,.cbar>div>div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  /* thanh trên gọn: tên khách đủ chữ (xuống 2 dòng nếu dài), đồng hồ 24h nằm ở dòng phụ, nút nhỏ lại */
  .chat-head{gap:2px;padding:calc(4px + env(safe-area-inset-top)) 4px 4px}
  .chat-head .av{width:34px;height:34px}
  .chat-head>.timer{display:none}
  .chat-title{margin-left:4px}
  .chat-title b{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:16px;line-height:1.25}
  .chat-title .sub{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:11.5px}
  .timer.in{display:inline-flex;padding:0 6px 0 0;background:none;font-size:11.5px;vertical-align:-2px}
  .timer.in .i{width:12px;height:12px}
  .chat-head .icon-btn{width:32px;height:32px}
  .chat-head .icon-btn .i{width:20px;height:20px}
  .bot-toggle{padding:3px;gap:3px;background:none}
  .bot-toggle>.i{display:none}
  .bot-toggle .sw{width:32px;height:19px}
  .bot-toggle .sw::after{width:15px;height:15px}
  .bot-toggle .sw.on::after{left:15px}
  .cbar.camp{padding:5px 10px;gap:8px}
  .cbar.camp .thumb{width:28px;height:28px}
  .cbar.camp>div{display:flex;gap:6px;align-items:center;white-space:nowrap;overflow:hidden}
  .cbar.camp .crumb{flex:1;min-width:0}
  .msgs{padding:10px 8px 6px}
  .m{max-width:84%}
  .m .bub{font-size:15.5px}
  .composer{padding:6px 8px calc(8px + env(safe-area-inset-bottom))}
  .qr{padding:7px 12px;font-size:13.5px}
  .compose-row textarea{font-size:16px}
  .round{width:42px;height:42px}
  .info{left:0;right:0;top:auto;width:100%;height:90%;border-radius:20px 20px 0 0;transform:translateY(100%);padding-bottom:env(safe-area-inset-bottom)}
  body.show-info .info{transform:none}
  .grab{display:block;width:42px;height:5px;border-radius:5px;background:#ccd0d5;margin:-12px auto 12px}
  .kv input,.note{font-size:16px}

  .page{padding:calc(14px + env(safe-area-inset-top)) 12px 24px}
  .page-head h1{font-size:22px}
  .page-head p{font-size:13.5px}
  .grid2{grid-template-columns:1fr}
  .stats{grid-template-columns:1fr 1fr;gap:8px}
  .kpis{grid-template-columns:1fr 1fr;gap:8px}
  .cal{gap:3px}
  .cell{min-height:52px;padding:3px;border-radius:8px;text-align:center}
  .cell .dn{margin:0 auto;width:26px;height:26px;font-size:13px}
  .cell .ev,.cell .more{display:none}
  .cell .cnt{display:inline-block;font-size:10.5px;font-weight:800;color:#fff;background:var(--ok);border-radius:8px;padding:0 5px;line-height:15px;margin-top:2px}
  .cell.today .cnt{background:var(--brand)}
  .cal-nav b{font-size:15px}
  .kpi{padding:12px}
  .kpi .vl{font-size:25px}
  .kpi .lb{font-size:12.5px}
  .form-grid{grid-template-columns:1fr}
  .modal-bg{align-items:flex-end;padding:0}
  .modal{max-width:none;border-radius:18px 18px 0 0;max-height:92vh}
  .stat .vl{font-size:21px}
  .tbl-wrap{display:none}
  .ad-cards{display:block}
  .rule{flex-wrap:wrap;position:relative;padding-right:62px}
  .rule>.sw{position:absolute;top:16px;right:14px}
  .rule>.rule-del{position:absolute;top:46px;right:12px}
  .rule-hit{text-align:left;width:100%}
  .rule-hit b{display:inline;font-size:13px;margin-right:4px}
  .ap{flex-wrap:wrap;gap:10px}
  .ap-time{width:auto;text-align:left;display:flex;gap:6px;align-items:baseline}
  .ap-bar{display:none}
  .ap-body{flex-basis:calc(100% - 90px)}
  .ap-acts{width:100%;justify-content:flex-start}
  .svc-row{grid-template-columns:40px 1fr 36px;grid-template-areas:"ic nm del" "ic pr del"}
  .svc-row .c-ic{grid-area:ic}.svc-row .c-nm{grid-area:nm}.svc-row .c-del{grid-area:del}
  .svc-row .c-pr{grid-area:pr;display:flex;gap:6px}
  .svc-head{display:none}
  .field input,.field textarea,.field select,.test-row input,.inp,.item textarea{font-size:16px}
  .set-row{flex-wrap:wrap}
  .test-box{height:460px}
  .toast-box{left:12px;right:12px;bottom:calc(72px + env(safe-area-inset-bottom))}
  body.show-chat .toast-box{bottom:calc(130px + env(safe-area-inset-bottom))}
  .toast{max-width:none}
}

/* ===== Bản thật: đăng nhập, ảnh đại diện thật, tiện ích ===== */
.login{position:fixed;inset:0;display:grid;place-items:center;background:var(--bg);padding:20px;z-index:200}
.login[hidden],.app[hidden]{display:none}
.login-box{background:#fff;border-radius:16px;box-shadow:var(--shadow);padding:28px 22px;width:100%;max-width:360px}
.login-box h1{text-align:center;font-size:22px}
.av img,.mav img{position:absolute;inset:0;width:100%;height:100%;border-radius:50%;object-fit:cover}
.av-def{width:100%;height:100%;display:block}
.att-img{max-width:220px;max-height:260px;border-radius:14px;display:block;margin-top:2px}
.empty-state{padding:40px 20px;text-align:center;color:var(--muted);line-height:1.6}
.empty-state .big-ok{background:var(--brand-soft);color:var(--brand)}
.spin{width:22px;height:22px;border:3px solid var(--btn);border-top-color:var(--brand);border-radius:50%;animation:spin .8s linear infinite;margin:30px auto}
.chat-empty{flex:1;display:grid;place-items:center;color:var(--muted);text-align:center;padding:20px}
.save-bar{position:sticky;bottom:0;background:linear-gradient(transparent,var(--bg) 30%);padding:14px 0 6px;display:flex;gap:8px;justify-content:flex-end}
.dirty{color:var(--warn);font-size:12.5px;font-weight:600;align-self:center;margin-right:auto}
.steps{counter-reset:s;margin:6px 0 0 0;padding:0;list-style:none}
.steps li{counter-increment:s;position:relative;padding:6px 0 6px 32px;line-height:1.5;font-size:13.5px}
.steps li::before{content:counter(s);position:absolute;left:0;top:6px;width:22px;height:22px;border-radius:50%;background:var(--brand-soft);color:var(--brand);font-weight:800;font-size:12px;display:grid;place-items:center}
.copy-row{display:flex;gap:6px;margin:4px 0}
.copy-row input{flex:1;min-width:0;font-family:Consolas,monospace;font-size:12.5px}
@media (max-width:760px){ .save-bar{bottom:0} }

/* ===== Ngăn kéo Bộ lọc kiểu Pancake ===== */
.fb.fbig{width:auto;padding:0 11px;gap:5px;background:var(--btn);color:var(--text);font-weight:700}
.fb.fbig.active{background:var(--brand-soft);color:var(--brand)}
.fbtns .chip{flex-shrink:0;padding:6px 11px}
.fdrawer{position:fixed;left:0;top:0;bottom:0;width:360px;max-width:86vw;background:#fff;z-index:95;box-shadow:8px 0 30px rgba(0,0,0,.18);transform:translateX(-105%);transition:transform .22s;display:flex;flex-direction:column}
body.show-fd .fdrawer{transform:none}
.fd-ov{display:none;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:94}
body.show-fd .fd-ov{display:block}
.fd-head{display:flex;align-items:center;justify-content:space-between;padding:calc(12px + env(safe-area-inset-top)) 14px 8px}
.fd-head b{font-size:22px}
.fd-body{flex:1;overflow-y:auto;padding:0 8px 10px}
.fd-sec{font-size:12.5px;color:var(--muted);font-weight:600;padding:14px 10px 4px}
.fd-row{display:flex;align-items:center;gap:12px;width:100%;padding:10px;border-radius:10px;text-align:left;font-size:15px}
.fd-row:hover{background:var(--hover)}
.fd-row .i{width:22px;height:22px;color:#606770;flex-shrink:0}
.fd-row span{flex:1}
.fd-row em{font-style:normal;font-size:12.5px;color:var(--muted);font-weight:600}
.fd-row.on{background:var(--brand-soft);color:var(--brand);font-weight:600}
.fd-row.on .i{color:var(--brand)}
.fd-row .i.ok{width:18px;height:18px}
.fd-chips{display:flex;flex-wrap:wrap;gap:6px;padding:2px 6px 6px}
.fd-foot{display:flex;gap:8px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line)}
.src.seen{background:#e7f3ff;color:#0866ff}
.m.out .t{text-align:right}

/* menu khi bấm vào tin nhắn: Sao chép / Cho bot học */
.m .bub{cursor:pointer}
.taught{font-size:11px;color:#b45309;font-weight:700;margin-top:2px}
.msg-menu{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:200;display:flex;align-items:flex-end;justify-content:center}
.mm-box{background:#fff;width:100%;max-width:440px;border-radius:18px 18px 0 0;padding:14px 14px calc(14px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:8px}
.mm-txt{font-size:13.5px;color:var(--muted);background:var(--bg);border-radius:12px;padding:10px 12px;line-height:1.45;white-space:pre-wrap}
.mm-box button{padding:13px;border-radius:12px;background:var(--btn);font-weight:700;font-size:15px;text-align:center}
.mm-box button.pri{background:#fef3c7;color:#92400e}
.mm-box button.cancel{background:none;color:var(--muted)}
@media(min-width:768px){.msg-menu{align-items:center}.mm-box{border-radius:18px}}
