:root{--bg:#eef2f9;--surface:#ffffff;--surface-2:#f7f9fc;--border:#e6ebf4;--text:#0f1b2d;--muted:#6b7a90;--faint:#9aa7ba;--brand:#4f46e5;--brand-2:#6366f1;--blue:#3b82f6;--green:#10b981;--teal:#14b8a6;--amber:#f59e0b;--red:#ef4444;--purple:#8b5cf6;--pink:#ec4899;--radius:16px;--radius-sm:10px;--shadow-sm:0 1px 2px rgba(16,27,45,0.04),0 1px 3px rgba(16,27,45,0.06);--shadow:0 4px 12px rgba(16,27,45,0.06),0 2px 4px rgba(16,27,45,0.04);--shadow-lg:0 12px 32px rgba(16,27,45,0.10);--sidebar-w:250px}*{box-sizing:border-box}body,html{margin:0;padding:0;background:var(--bg);color:var(--text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;font-size:14px;line-height:1.55;-webkit-font-smoothing:antialiased}a{color:inherit;text-decoration:none}.layout{display:flex;min-height:100vh}.sidebar{width:var(--sidebar-w);flex-shrink:0;background:linear-gradient(180deg,#1b2340,#141a33);color:#cdd5e6;padding:22px 16px;position:-webkit-sticky;position:sticky;top:0;height:100vh;display:flex;flex-direction:column;gap:4px}.brand{display:flex;align-items:center;gap:12px;padding:6px 10px 22px}.brand-logo{width:40px;height:40px;border-radius:11px;flex-shrink:0;background:linear-gradient(135deg,var(--brand-2),var(--pink));display:grid;place-items:center;color:#fff;box-shadow:0 6px 16px rgba(99,102,241,.45)}.brand-name{font-weight:700;font-size:15px;color:#fff;letter-spacing:-.01em}.brand-sub{font-size:11px;color:#8b97b4}.nav-label{font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:#6b769a;padding:14px 12px 6px}.nav a{display:flex;align-items:center;gap:11px;padding:10px 12px;border-radius:11px;color:#b6c0d8;font-weight:500;transition:background .15s,color .15s}.nav a svg{width:18px;height:18px;opacity:.85}.nav a:hover{background:rgba(255,255,255,.06);color:#fff}.nav a.active{background:linear-gradient(135deg,var(--brand),var(--brand-2));color:#fff;box-shadow:0 6px 16px rgba(79,70,229,.35)}.nav a.active svg{opacity:1}.sidebar-foot{margin-top:auto;padding:12px;font-size:11px;color:#6b769a}.main{flex:1 1;padding:26px 34px 60px;overflow-x:auto;max-width:100%}.topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:24px;gap:16px;flex-wrap:wrap}.page-title{font-size:22px;font-weight:750;margin:0;letter-spacing:-.02em}.page-sub{color:var(--muted);font-size:13px;margin-top:3px}.pill{display:inline-flex;align-items:center;gap:7px;background:var(--surface);border:1px solid var(--border);border-radius:999px;padding:7px 14px;font-size:12px;font-weight:600;box-shadow:var(--shadow-sm)}.dot{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 0 3px rgba(16,185,129,.18)}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));grid-gap:18px;gap:18px}.stat{position:relative;overflow:hidden;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px;box-shadow:var(--shadow)}.stat-top{display:flex;align-items:center;justify-content:space-between}.stat-ico{width:42px;height:42px;border-radius:12px;display:grid;place-items:center;color:#fff}.stat-ico svg{width:21px;height:21px}.ico-brand{background:linear-gradient(135deg,var(--brand),var(--brand-2))}.ico-green{background:linear-gradient(135deg,#10b981,#059669)}.ico-blue{background:linear-gradient(135deg,#3b82f6,#2563eb)}.ico-amber{background:linear-gradient(135deg,#f59e0b,#d97706)}.ico-purple{background:linear-gradient(135deg,#8b5cf6,#7c3aed)}.stat-label{color:var(--muted);font-size:12.5px;font-weight:600;margin-top:16px}.stat-value{font-size:30px;font-weight:780;margin-top:2px;letter-spacing:-.02em}.stat-sub{color:var(--faint);font-size:12px;margin-top:5px;display:flex;gap:8px;flex-wrap:wrap}.trend{font-weight:700;display:inline-flex;align-items:center;gap:3px}.trend.up{color:var(--green)}.trend.down{color:var(--red)}.grid{display:grid;grid-gap:18px;gap:18px;margin-top:18px}.grid-2{grid-template-columns:1.6fr 1fr}@media (max-width:1000px){.grid-2{grid-template-columns:1fr}}.panel{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);padding:20px 22px}.panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}.panel-title{font-size:15px;font-weight:700}.panel-sub{font-size:12px;color:var(--muted)}.bars{display:flex;align-items:flex-end;gap:10px;height:190px;padding-top:10px}.bar-col{flex:1 1;display:flex;flex-direction:column;align-items:center;gap:8px;height:100%;justify-content:flex-end}.bar{width:100%;max-width:34px;border-radius:7px 7px 3px 3px;background:linear-gradient(180deg,var(--brand-2),var(--brand));transition:height .3s;min-height:3px}.bar-x{font-size:10px;color:var(--faint)}.bar-v{font-size:11px;font-weight:700;color:var(--muted)}.donut-wrap{display:flex;align-items:center;gap:22px;flex-wrap:wrap}.legend{display:flex;flex-direction:column;gap:12px}.legend-row{display:flex;align-items:center;gap:10px;font-size:13px}.legend-dot{width:11px;height:11px;border-radius:4px}.legend-val{font-weight:700;margin-left:auto}.table-wrap{overflow-x:auto}table{width:100%;border-collapse:collapse}td,th{text-align:left;padding:12px 14px;font-size:13px;border-bottom:1px solid var(--border)}th{color:var(--muted);font-weight:600;text-transform:uppercase;font-size:10.5px;letter-spacing:.05em}tbody tr{transition:background .12s}tbody tr:last-child td{border-bottom:none}tbody tr:hover td{background:var(--surface-2)}.avatar{width:30px;height:30px;border-radius:9px;display:inline-grid;place-items:center;color:#fff;font-size:12px;font-weight:700;margin-right:10px;vertical-align:middle}.cell-name{display:flex}.badge,.cell-name{align-items:center}.badge{display:inline-flex;gap:5px;padding:3px 10px;border-radius:999px;font-size:11px;font-weight:650;border:1px solid transparent}.badge:before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}.badge.delivered,.badge.sent{color:#0f9d6b;background:#e7f8f1}.badge.failed{color:#d64545;background:#fdecec}.badge.queued,.badge.sending{color:#c1820b;background:#fdf5e3}.badge.muted{color:var(--faint);background:var(--surface-2)}.badge.muted:before{display:none}.badge.whatsapp{color:#0f9d6b;background:#e7f8f1}.badge.email{color:#2f6fed;background:#e9f0fe}.badge.telegram{color:#1d8fd1;background:#e6f4fb}.timeline{display:flex;flex-direction:column;gap:14px;position:relative}.tl-item{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 18px;box-shadow:var(--shadow-sm);position:relative}.tl-head{display:flex;gap:10px;align-items:center;margin-bottom:10px;flex-wrap:wrap}.tl-body{white-space:pre-wrap;color:var(--text);font-size:13px;background:var(--surface-2);padding:12px 14px;border-radius:var(--radius-sm);border:1px solid var(--border)}.tl-err{color:var(--red);font-size:12px;margin-top:8px}.filters{display:flex;gap:8px;margin-bottom:18px;flex-wrap:wrap}.filters a{padding:7px 14px;border:1px solid var(--border);border-radius:999px;color:var(--muted);font-size:12px;font-weight:600;background:var(--surface);box-shadow:var(--shadow-sm)}.filters a.active{background:var(--brand);color:#fff;border-color:var(--brand)}.muted{color:var(--muted)}.mono{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:12px}.empty{padding:48px;text-align:center}.back,.empty{color:var(--muted)}.back{font-size:13px;margin-bottom:16px;display:inline-flex;gap:6px}.auth-page,.back{align-items:center}.auth-page{min-height:100vh;display:flex;justify-content:center;padding:24px;background:#eef2fb}.auth-box{width:100%;max-width:420px}.auth-head{text-align:center;margin-bottom:26px}.auth-logo{width:68px;height:68px;margin:0 auto 18px;border-radius:18px;background:#2563eb;color:#fff;display:flex;align-items:center;justify-content:center}.auth-logo svg{width:34px;height:34px}.auth-head h1{margin:0 0 6px;font-size:27px;font-weight:700;color:#0f172a;letter-spacing:-.3px}.auth-head p{margin:0;color:#64748b;font-size:15px}.auth-card{background:#fff;border-radius:14px;padding:30px;box-shadow:0 1px 3px rgba(15,23,42,.08),0 12px 32px rgba(15,23,42,.06);gap:20px}.auth-card,.auth-field{display:flex;flex-direction:column}.auth-field{gap:7px}.auth-field label{font-size:14px;font-weight:600;color:#0f172a}.auth-label-row{display:flex;align-items:center;justify-content:space-between}.auth-link{font-size:13px;color:#2563eb;text-decoration:none;font-weight:500}.auth-link:hover{text-decoration:underline}.auth-field input{width:100%;background:#eef2f9;border:1px solid transparent;border-radius:8px;padding:12px 13px;font-size:15px;color:#0f172a;font-family:inherit}.auth-field input:focus{outline:none;background:#fff;border-color:#2563eb}.auth-error{background:#fef2f2;border:1px solid #fecaca;color:#b91c1c;border-radius:8px;padding:10px 12px;font-size:14px}.auth-submit{width:100%;background:#2563eb;color:#fff;border:none;border-radius:8px;padding:13px;font-size:15px;font-weight:600;cursor:pointer;font-family:inherit;display:block;text-align:center;text-decoration:none}.auth-submit:hover{background:#1d4ed8}.auth-submit:disabled{opacity:.65;cursor:default}.auth-submit-link{margin-top:4px}.auth-note{margin:0;font-size:14px;line-height:1.6;color:#475569}.logout-btn{display:flex;align-items:center;gap:11px;width:100%;margin-top:auto;background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.1);border-radius:11px;padding:10px 12px;color:#b6c0d8;font:inherit;font-size:13px;font-weight:600;cursor:pointer;transition:background .15s,color .15s,border-color .15s}.logout-btn:hover{background:rgba(239,68,68,.14);border-color:rgba(239,68,68,.45);color:#fca5a5}.logout-btn svg{width:17px;height:17px;flex:none;opacity:.9}.logout-btn:disabled{opacity:.55;cursor:default}.row-link:hover{background:var(--surface-2)}.tmpl-dot{display:inline-block;width:8px;height:8px;border-radius:999px;background:var(--accent,#16a34a);margin-right:9px}.tmpl-editor{gap:18px;max-width:720px}.tmpl-editor,.tmpl-editor .field{display:flex;flex-direction:column}.tmpl-editor .field{gap:6px}.tmpl-editor label{font-size:13px;font-weight:600;color:var(--text)}.tmpl-editor input,.tmpl-editor textarea{width:100%;background:var(--surface-2);border:1px solid var(--border);border-radius:9px;padding:9px 11px;color:var(--text);font:inherit;font-size:13px;resize:vertical}.tmpl-editor input:focus,.tmpl-editor textarea:focus{outline:none;border-color:var(--accent,#16a34a)}.tmpl-editor input:disabled{opacity:.5}.row-inline{display:flex;align-items:center;gap:8px}.btn-mini{background:var(--surface-2);border:1px solid var(--border);border-radius:8px;padding:5px 11px;font-size:12px;font-weight:600;color:var(--text);cursor:pointer}.btn-mini:hover{border-color:var(--accent,#16a34a)}.btn-mini.danger{color:#ef4444;padding:5px 9px}.opt-edit{display:flex;flex-direction:column;gap:6px;padding:10px;border:1px solid var(--border);border-radius:10px;margin-bottom:8px}.opt-edit-row{display:flex;align-items:center;gap:8px}.opt-num{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:999px;background:var(--surface-2);border:1px solid var(--border);font-size:12px;font-weight:700;flex:none}.opt-label{flex:1 1}.switch{display:inline-flex;align-items:center;gap:9px;cursor:pointer}.switch input{width:auto}.editor-actions{display:flex;align-items:center;gap:14px}.btn-primary{background:var(--accent,#16a34a);color:#fff;border:none;border-radius:9px;padding:10px 20px;font-size:14px;font-weight:600;cursor:pointer}.btn-primary:disabled{opacity:.6;cursor:default}.save-ok{color:#16a34a}.save-err,.save-ok{font-size:13px;font-weight:600}.save-err{color:#ef4444}.tl-tabs{display:flex;gap:6px;margin-bottom:14px;border-bottom:1px solid var(--border)}.tl-tab{display:inline-flex;align-items:center;gap:7px;cursor:pointer;background:transparent;border:none;border-bottom:2px solid transparent;color:var(--muted);font-size:13px;font-weight:600;padding:8px 14px;margin-bottom:-1px;transition:color .15s,border-color .15s}.tl-tab.active,.tl-tab:hover{color:var(--text)}.tl-tab.active{border-bottom-color:var(--accent,#16a34a)}.tl-tab svg{width:15px;height:15px}.tl-count{background:var(--surface-2);color:var(--muted);font-size:11px;font-weight:700;padding:1px 8px;border-radius:999px;border:1px solid var(--border)}.tl-tab.active .tl-count{background:var(--accent,#16a34a);color:#fff;border-color:transparent}.chat{display:flex;flex-direction:column;gap:14px;padding:6px 2px}.day-sep{display:flex;align-items:center;justify-content:center;margin:8px 0 2px}.day-sep span{background:var(--surface-2);color:var(--muted);font-size:11px;font-weight:700;padding:4px 14px;border-radius:999px;border:1px solid var(--border)}.msg{display:flex;gap:10px;max-width:76%}.msg.out{align-self:flex-end;flex-direction:row-reverse}.msg.in{align-self:flex-start}.msg-av{width:34px;height:34px;border-radius:10px;flex-shrink:0;display:grid;place-items:center;color:#fff;box-shadow:var(--shadow-sm)}.msg-av svg{width:17px;height:17px}.av-email{background:linear-gradient(135deg,#3b82f6,#2563eb)}.av-whatsapp{background:linear-gradient(135deg,#10b981,#059669)}.bubble{border:1px solid var(--border);border-radius:15px;padding:11px 14px;box-shadow:var(--shadow-sm);min-width:0}.msg.out .bubble{border-bottom-right-radius:4px}.msg.in .bubble{border-bottom-left-radius:4px}.bubble.email{background:#eff5ff;border-color:#dce8ff}.bubble.whatsapp{background:#eafaf1;border-color:#cdf0dc}.bubble.reply{background:var(--surface)}.bubble-meta{display:flex;align-items:center;gap:7px;margin-bottom:7px;flex-wrap:wrap}.bubble-subject{font-weight:700;font-size:13px;margin-bottom:3px}.bubble-body{white-space:pre-wrap;word-break:break-word;font-size:13px;line-height:1.5;color:var(--text)}.bubble-btns{display:flex;flex-direction:column;gap:4px;margin-top:8px}.bubble-btn{text-align:center;padding:7px 10px;border-radius:8px;background:rgba(255,255,255,.7);color:#027eb5;font-weight:600;font-size:12.5px;border:1px solid rgba(0,0,0,.06)}.bubble-foot{display:flex;align-items:center;gap:6px;margin-top:8px;font-size:11px;color:var(--muted)}.msg.out .bubble-foot{justify-content:flex-end}.bubble-err{color:var(--red);font-size:11.5px;margin-top:6px}.chip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:7px;font-weight:700;font-size:10.5px;letter-spacing:.01em}.chip svg{width:12px;height:12px}.chip.email{color:#2f6fed;background:#e3ecfd}.chip.whatsapp{color:#0f9d6b;background:#dff7ea}.chip.tmpl{color:var(--muted);background:var(--surface-2)}.chip.auto{color:#7c3aed;background:#efe8fd}.chip.followup{color:#b45309;background:#fdf0dc}.chip.reply{color:#0369a1;background:#e0f2fe}.ticks{display:inline-flex;align-items:center;gap:3px;font-weight:700}.ticks.sent{color:var(--muted)}.ticks.delivered{color:#0f9d6b}.ticks.read{color:var(--blue)}.ticks.failed{color:var(--red)}.ticks.pending{color:var(--amber)}.wa{display:flex;height:calc(100vh - 150px);min-height:500px;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;background:var(--surface);box-shadow:var(--shadow)}.wa-list{width:330px;flex-shrink:0;border-right:1px solid var(--border);display:flex;flex-direction:column}.wa-list-head{padding:15px 16px;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center}.wa-list-head b{font-size:15px}.wa-search{padding:10px 12px;border-bottom:1px solid var(--border)}.wa-search input{width:100%;padding:9px 12px;border:1px solid var(--border);border-radius:9px;background:var(--surface-2);font-size:13px;color:var(--text)}.wa-contacts{overflow-y:auto;flex:1 1}.wa-contact{display:flex;gap:11px;padding:12px 14px;cursor:pointer;border-bottom:1px solid var(--border);align-items:center}.wa-contact:hover{background:var(--surface-2)}.wa-contact.active{background:#eef4ff}.wa-contact-main{flex:1 1;min-width:0}.wa-contact-top{display:flex;justify-content:space-between;gap:8px;align-items:baseline}.wa-contact-name{font-weight:650;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wa-contact-time{font-size:10.5px;color:var(--faint);flex-shrink:0}.wa-contact-bottom{display:flex;justify-content:space-between;gap:8px;align-items:center;margin-top:2px}.wa-contact-last{font-size:12.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wa-badge{background:var(--green);color:#fff;border-radius:999px;font-size:11px;font-weight:700;padding:1px 7px;min-width:20px;text-align:center;flex-shrink:0}.wa-main{flex:1 1;display:flex;flex-direction:column;min-width:0;background:#eef1f7}.wa-main-head{padding:13px 18px;border-bottom:1px solid var(--border);background:var(--surface);display:flex;gap:12px;align-items:center}.wa-thread{flex:1 1;overflow-y:auto;padding:18px;display:flex;flex-direction:column;gap:8px}.wa-msg{max-width:70%;padding:9px 12px 7px;border-radius:12px;font-size:13px;line-height:1.45;box-shadow:var(--shadow-sm);white-space:pre-wrap;word-break:break-word}.wa-msg.in{align-self:flex-start;background:#ffffff;border:1px solid var(--border);border-bottom-left-radius:4px}.wa-msg.out{align-self:flex-end;background:#d9fdd3;border-bottom-right-radius:4px}.wa-msg-foot{display:flex;gap:5px;justify-content:flex-end;font-size:10px;color:#667;margin-top:3px;align-items:center}.wa-msg-text{white-space:pre-wrap}.wa-msg-btns{display:flex;flex-direction:column;gap:4px;margin-top:8px}.wa-msg-btn{text-align:center;padding:8px 10px;border-radius:8px;background:rgba(255,255,255,.8);color:#027eb5;font-weight:600;font-size:12.5px;border:1px solid rgba(0,0,0,.06)}.wa-composer{display:flex;gap:10px;padding:13px 16px;border-top:1px solid var(--border);background:var(--surface);align-items:flex-end}.wa-composer textarea{flex:1 1;padding:11px 15px;border:1px solid var(--border);border-radius:22px;background:var(--surface-2);font-size:14px;color:var(--text);font-family:inherit;line-height:1.4;resize:none;max-height:120px;overflow-y:auto}.wa-composer button{padding:0 22px;height:44px;border:0;border-radius:22px;background:var(--green);color:#fff;font-weight:700;cursor:pointer;font-size:13px}.wa-composer button:disabled{opacity:.5;cursor:not-allowed}.wa-empty-main{flex:1 1;display:grid;place-items:center;color:var(--muted);text-align:center;padding:20px}.wa-warn{background:#fff7ed;border:1px solid #fed7aa;color:#9a3412;padding:10px 14px;border-radius:10px;font-size:12.5px;margin-bottom:16px}@media (max-width:820px){.wa-list{width:100%}.wa.has-active .wa-list,.wa:not(.has-active) .wa-main{display:none}}