:root{
  --bg:#f4f5fb;
  --sidebar:#0f1020;
  --sidebar-hover:#1b1d33;
  --primary:#6b4bff;
  --amo-red:#FF4757;
  --amo-red-d:#e23647;
  --amo-teal:#1fc7c7;
  --accent:#FF6B35;
  --green:#16c784;
  --yellow:#ffb020;
  --card:#ffffff;
  --line:#e7e9f4;
  --txt:#1d2030;
  --muted:#8a8fa3;
  --radius:16px;
  --shadow:0 4px 24px rgba(31,33,64,.06);
  font-synthesis:none;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Segoe UI',system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--txt);font-size:14px}
a{text-decoration:none;color:inherit}

.app{display:flex;min-height:100vh}
.sidebar{width:248px;background:var(--sidebar);color:#fff;display:flex;flex-direction:column;position:fixed;height:100vh;z-index:30}
.main{flex:1;margin-left:248px;display:flex;flex-direction:column;min-height:100vh}

.brand{display:flex;align-items:center;gap:10px;padding:22px 22px 14px}
.brand .mark{width:36px;height:36px;border-radius:10px;background:var(--amo-teal);display:grid;place-items:center;flex-shrink:0;box-shadow:0 0 0 3px rgba(31,199,199,.18)}
.brand .mark svg{width:20px;height:20px}
.brand b{font-size:18px;letter-spacing:.5px}
.brand b span{color:var(--amo-red);font-weight:800}
.suggest{margin:6px 18px 18px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);border-radius:12px;padding:11px 14px;display:flex;align-items:center;gap:9px;font-size:12.5px;cursor:pointer;color:#c4c8da}
.suggest:hover{background:rgba(255,255,255,.1)}
.nav-label{font-size:11px;letter-spacing:1.4px;color:#5c6078;padding:6px 24px;font-weight:600}
.nav a{display:flex;align-items:center;gap:13px;padding:11px 24px;color:#c4c8da;font-size:14.5px;cursor:pointer;border-left:3px solid transparent}
.nav a:hover{background:var(--sidebar-hover);color:#fff}
.nav a.active{background:linear-gradient(90deg,rgba(107,75,255,.22),transparent);color:#fff;border-left-color:var(--amo-red);font-weight:600}
.nav a svg{width:19px;height:19px;flex-shrink:0;opacity:.9}
.nav a .badge{margin-left:auto;background:var(--primary);font-size:9.5px;padding:2px 7px;border-radius:20px;font-weight:700;letter-spacing:.5px}
.nav .sep{height:1px;background:rgba(255,255,255,.06);margin:14px 22px}
.workspace{margin-top:auto;padding:16px 20px;border-top:1px solid rgba(255,255,255,.07);display:flex;align-items:center;gap:11px}
.workspace .av{width:34px;height:34px;border-radius:9px;background:var(--amo-red);display:grid;place-items:center;font-weight:700;font-size:13px;color:#fff}
.workspace small{display:block;color:#6b6f87;font-size:11px}

.topbar{height:60px;display:flex;align-items:center;justify-content:flex-end;gap:14px;padding:0 28px}
.pill-cta{background:var(--primary);color:#fff;padding:9px 16px;border-radius:30px;font-size:13px;font-weight:600;display:flex;align-items:center;gap:8px;cursor:pointer}
.pill-cta:hover{filter:brightness(1.08)}
.queue-pill{font-size:12px;color:var(--muted)}
.queue-pill.busy{color:var(--accent);font-weight:600}

.page{padding:6px 28px 40px;flex:1}
.page-head{display:flex;align-items:center;gap:12px;margin:6px 0 22px}
.page-head .ic{width:40px;height:40px;border-radius:12px;background:#eceaff;display:grid;place-items:center}
.page-head .ic svg{width:21px;height:21px;color:var(--primary)}
.page-head h1{font-size:23px;font-weight:700}
.hidden{display:none!important}
.muted{color:var(--muted)}
.muted-sm{color:var(--muted);font-size:12px;margin-left:auto}

.stat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:18px;margin-bottom:22px}
.stat{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:22px;text-align:center;position:relative}
.stat .ico{width:46px;height:46px;border-radius:14px;background:#f1efff;margin:0 auto 12px;display:grid;place-items:center}
.stat .ico svg{width:22px;height:22px;color:var(--primary)}
.stat .num{font-size:32px;font-weight:800;line-height:1}
.stat .lbl{color:var(--muted);margin-top:6px;font-size:13px}

.panel{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:22px 24px;margin-bottom:20px}
.panel h3{font-size:16px;margin-bottom:4px}
.panel .sub{color:var(--muted);font-size:12.5px;margin-bottom:16px}

.chart-wrap{height:320px;position:relative;padding-top:14px}
.legend{display:flex;gap:20px;justify-content:center;margin-bottom:8px;font-size:12px;color:#666}
.legend span{display:inline-flex;align-items:center;gap:6px}
.legend i{width:14px;height:3px;border-radius:3px;display:inline-block}

table{width:100%;border-collapse:collapse}
thead th{text-align:left;font-size:11.5px;letter-spacing:.6px;color:var(--muted);font-weight:600;padding:14px 16px;border-bottom:1px solid var(--line)}
tbody td{padding:15px 16px;border-bottom:1px solid var(--line);font-size:13.5px}
tbody tr:hover{background:#fafaff}
.plat{display:inline-flex;align-items:center;gap:8px;font-weight:600}
.plat .dot{width:22px;height:22px;border-radius:6px;display:grid;place-items:center;font-size:11px;color:#fff;font-weight:800}
.row-actions{display:flex;gap:8px;justify-content:flex-end;align-items:center}
.ic-btn{width:30px;height:30px;border-radius:8px;border:none;display:grid;place-items:center;cursor:pointer}
.ic-btn.edit{background:#fff4e6;color:var(--accent)}
.ic-btn.bell{background:#e9fff4;color:var(--green)}
.ic-btn.del{background:#ffecec;color:#ff4d4f}

.status-tag{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;font-weight:700;padding:3px 10px;border-radius:20px}
.st-sent{background:#e9fff4;color:var(--green)}
.st-queued{background:#eef0ff;color:var(--primary)}
.st-no_whatsapp{background:#fff7e6;color:#d99300}
.st-expired{background:#ffecec;color:#ff4d4f}
.st-failed{background:#ffecec;color:#ff4d4f}
.st-skipped{background:#f0f1f8;color:#999}

.integ-layout{display:grid;grid-template-columns:260px 1fr;gap:20px}
.integ-side{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px;max-height:560px;overflow:auto}
.search{display:flex;align-items:center;gap:9px;background:#f4f5fb;border-radius:30px;padding:10px 16px;margin-bottom:14px}
.search input{border:none;background:none;outline:none;width:100%;font-size:13px}
.plat-item{display:flex;align-items:center;gap:10px;padding:9px 8px;border-radius:9px;cursor:pointer;color:#555}
.plat-item:hover{background:#f4f5fb}
.plat-item .tag{width:18px;height:14px;border-radius:3px;background:#b9f3c8;flex-shrink:0}

.channel-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:20px}
.channel{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden;border:1px solid var(--line)}
.channel .body{padding:26px 22px;text-align:center}
.conn{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--green);background:#e9fff4;padding:4px 12px;border-radius:20px;margin-bottom:16px}
.conn .led{width:8px;height:8px;border-radius:50%;background:var(--green)}
.conn.off{color:#999;background:#f0f0f0}
.conn.off .led{background:#bbb}
.channel .pic{width:84px;height:84px;border-radius:50%;margin:0 auto 12px;display:grid;place-items:center;position:relative;background:var(--amo-teal)}
.channel .pic svg{width:42px;height:42px}
.channel .pic .qr{position:absolute;bottom:0;right:6px;width:22px;height:22px;border-radius:6px;background:var(--green);display:grid;place-items:center;border:2px solid #fff}
.channel .num{font-size:12.5px;color:var(--muted)}
.channel .name{font-size:16px;font-weight:700;margin-top:3px}
.engine-tag{display:inline-block;margin-top:8px;font-size:11px;font-weight:700;padding:3px 10px;border-radius:20px}
.engine-evo{background:#eef0ff;color:var(--primary)}
.engine-meta{background:#e7f6ff;color:#0a84d6}
.channel .foot{display:flex;gap:10px;padding:14px;background:#f8f8fc;border-top:1px solid var(--line)}
.btn{border:none;border-radius:10px;padding:10px 14px;font-size:13px;font-weight:600;cursor:pointer;flex:1;display:flex;align-items:center;justify-content:center;gap:7px}
.btn-orange{background:var(--accent);color:#fff}
.btn-red{background:var(--amo-red);color:#fff}
.btn-ghost{background:#fff;border:1px solid var(--line);color:#555;flex:none;padding:10px 16px}
.btn-add{border:2px dashed var(--line);background:transparent;color:var(--muted);min-height:230px;border-radius:var(--radius);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;cursor:pointer}
.btn-add:hover{border-color:var(--primary);color:var(--primary)}
.btn-add svg{width:34px;height:34px}

.check-list{display:flex;flex-direction:column;gap:11px;margin-bottom:8px}
.check-list .ci{display:flex;align-items:center;gap:11px;font-size:13.5px;color:#444}
.check-list .mk{width:22px;height:22px;border-radius:50%;display:grid;place-items:center;flex-shrink:0}
.mk.ok{background:#e9fff4;color:var(--green)}
.mk.warn{background:#fff7e6;color:var(--yellow)}
.webhook-box{display:flex;align-items:center;gap:10px;background:#f7f8fd;border:1px solid var(--line);border-radius:12px;padding:14px 16px;font-family:'Consolas',monospace;font-size:13px;color:#444}
.webhook-box span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.copy{width:34px;height:34px;border-radius:8px;border:1px solid var(--line);background:#fff;display:grid;place-items:center;cursor:pointer;color:#888}
.copy:hover{color:var(--primary);border-color:var(--primary)}

.tpl-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}
.tpl{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:18px;position:relative;display:flex;flex-direction:column;box-shadow:var(--shadow)}
.tpl .status{position:absolute;top:16px;right:16px;width:26px;height:26px;border-radius:50%;display:grid;place-items:center}
.tpl .status.ok{background:#e9fff4;color:var(--green)}
.tpl .status.warn{background:#fff7e6;color:var(--yellow)}
.tpl h4{font-size:14.5px;margin-bottom:6px;padding-right:30px}
.tpl p{color:var(--muted);font-size:12.5px;line-height:1.5;flex:1;margin-bottom:14px}
.tpl .tpl-btns{display:flex;flex-direction:column;gap:8px}
.tpl .tpl-btns button{font-size:12.5px;padding:9px}
.btn-cfg{background:var(--primary);color:#fff;border:none;border-radius:9px;font-weight:600;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px}
.btn-rem{background:#fff;border:1px solid var(--line);color:#888;border-radius:9px;font-weight:600;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px}

.tag-evo{font-size:11px;font-weight:700;color:var(--primary);background:#eef0ff;padding:2px 8px;border-radius:20px}
.tag-meta{font-size:11px;font-weight:700;color:#0a84d6;background:#e7f6ff;padding:2px 8px;border-radius:20px}

/* buttons */
.btn-sm{border:none;border-radius:9px;padding:9px 16px;font-size:13px;font-weight:600;cursor:pointer}
.btn-sm.primary{background:var(--primary);color:#fff}
.btn-sm.ghost{background:#fff;border:1px solid var(--line);color:#555}
.btn-sm:hover{filter:brightness(1.05)}

/* MODAL */
.modal-bg{position:fixed;inset:0;background:rgba(15,16,32,.5);display:grid;place-items:center;z-index:100;padding:20px}
.modal{background:#fff;border-radius:18px;width:100%;max-width:520px;max-height:90vh;overflow:auto;box-shadow:0 24px 60px rgba(0,0,0,.25)}
.modal-head{padding:22px 24px 0;display:flex;align-items:center;justify-content:space-between}
.modal-head h3{font-size:18px}
.modal-head .x{cursor:pointer;color:#aaa;font-size:22px;line-height:1;border:none;background:none}
.modal-body{padding:18px 24px 24px}
.field{margin-bottom:14px}
.field label{display:block;font-size:12.5px;font-weight:600;color:#555;margin-bottom:6px}
.field input,.field select,.field textarea{width:100%;border:1px solid var(--line);border-radius:10px;padding:11px 13px;font-size:13.5px;font-family:inherit;outline:none}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--primary)}
.field textarea{resize:vertical;min-height:110px}
.field .hint{font-size:11.5px;color:var(--muted);margin-top:5px}
.field-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.modal-foot{display:flex;gap:10px;justify-content:flex-end;margin-top:8px}
.engine-toggle{display:flex;gap:10px;margin-bottom:14px}
.engine-toggle .opt{flex:1;border:1px solid var(--line);border-radius:12px;padding:12px;cursor:pointer;text-align:center;font-size:13px;font-weight:600}
.engine-toggle .opt.sel{border-color:var(--primary);background:#f3f0ff;color:var(--primary)}
.engine-toggle .opt small{display:block;font-weight:400;color:var(--muted);font-size:11px;margin-top:3px}
.vartag{display:inline-block;background:#f0f1f8;color:#666;font-family:'Consolas',monospace;font-size:11px;padding:2px 7px;border-radius:6px;margin:2px 4px 2px 0;cursor:pointer}
.vartag:hover{background:var(--primary);color:#fff}

/* TOAST */
#toast-wrap{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;gap:10px;z-index:200}
.toast{background:#0f1020;color:#fff;padding:13px 18px;border-radius:12px;font-size:13.5px;box-shadow:0 10px 30px rgba(0,0,0,.25);display:flex;align-items:center;gap:10px;animation:slidein .25s ease}
.toast.ok{background:#0f3a2a}
.toast.err{background:#3a1414}
@keyframes slidein{from{transform:translateX(40px);opacity:0}to{transform:none;opacity:1}}

/* AUTH */
.auth-screen{position:fixed;inset:0;background:linear-gradient(135deg,#0f1020,#1b1d33);display:grid;place-items:center;z-index:300;padding:20px}
.auth-card{background:#fff;border-radius:20px;padding:34px 32px;width:100%;max-width:380px;box-shadow:0 24px 70px rgba(0,0,0,.4)}
.auth-logo{display:flex;align-items:center;gap:10px;justify-content:center;margin-bottom:22px}
.auth-logo .mark{width:38px;height:38px;border-radius:10px;background:var(--amo-teal);display:grid;place-items:center}
.auth-logo .mark svg{width:22px;height:22px}
.auth-logo b{font-size:20px}.auth-logo b span{color:var(--amo-red);font-weight:800}
.auth-card h2{font-size:21px;text-align:center}
.auth-sub{color:var(--muted);text-align:center;font-size:13px;margin:4px 0 20px}
.auth-err{color:#ff4d4f;font-size:12.5px;min-height:18px;margin-bottom:8px;text-align:center}
.logout-btn{background:rgba(255,255,255,.08);border:none;color:#c4c8da;width:34px;height:34px;border-radius:9px;cursor:pointer;display:grid;place-items:center;flex-shrink:0}
.logout-btn:hover{background:var(--amo-red);color:#fff}

/* TAGS / GRUPOS */
.tags-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:14px}
.tag-card{border:1px solid var(--line);border-radius:14px;padding:18px;display:flex;flex-direction:column;gap:4px}
.tag-card b{font-size:15px}.tag-card .cnt{font-size:26px;font-weight:800;color:var(--primary)}
.tag-card button{margin-top:8px;align-self:flex-start}

/* CRM */
.crm-board{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
.crm-col{background:#fff;border-radius:14px;box-shadow:var(--shadow);padding:14px;min-height:200px}
.crm-col h4{font-size:13px;display:flex;justify-content:space-between;margin-bottom:12px;color:var(--txt)}
.crm-col h4 span{background:#f0f1f8;border-radius:20px;padding:1px 9px;font-size:12px;color:var(--muted)}
.crm-card{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin-bottom:9px;font-size:13px}
.crm-card .nm{font-weight:600}
.crm-card .ph{color:var(--muted);font-size:11.5px}
.crm-card .mv{display:flex;gap:4px;margin-top:7px}
.crm-card .mv button{border:1px solid var(--line);background:#fafaff;border-radius:6px;font-size:10.5px;padding:3px 7px;cursor:pointer;color:#666}
.crm-card .mv button:hover{border-color:var(--primary);color:var(--primary)}

/* automacoes */
.auto-row{display:flex;align-items:center;gap:12px;padding:13px 0;border-bottom:1px solid var(--line)}
.auto-row:last-child{border:none}
.auto-row .ev{flex:1}
.auto-row .ev b{font-size:13.5px}.auto-row .ev small{display:block;color:var(--muted);font-size:11.5px}
.dot-on{width:9px;height:9px;border-radius:50%;background:var(--green);flex-shrink:0}
.dot-off{width:9px;height:9px;border-radius:50%;background:#ccc;flex-shrink:0}

/* ---------- QR CODE (conectar WhatsApp) ---------- */
.btn-qr{background:linear-gradient(135deg,#16c784,#0ea472);color:#fff}
.qr-wrap{background:#f7f8fd;border:1px solid var(--line);border-radius:16px;padding:18px;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:280px;margin-bottom:16px}
.qr-img{width:250px;height:250px;image-rendering:pixelated;border-radius:8px;background:#fff}
.qr-loading{text-align:center;color:var(--muted);font-size:13px}
.qr-loading p{margin-top:12px}
.spinner{width:34px;height:34px;border:3px solid var(--line);border-top-color:var(--primary);border-radius:50%;margin:0 auto;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.qr-error{text-align:center;color:#ff4d4f;font-size:13px;padding:10px}
.qr-error p{color:#666;margin:8px 0;font-size:12.5px;word-break:break-word}
.qr-error small{color:var(--muted);font-size:11.5px}
.qr-fallback{text-align:center;font-size:13px}
.qr-fallback code{display:block;background:#fff;border:1px solid var(--line);border-radius:8px;padding:10px;margin:10px 0;font-size:11px;word-break:break-all;max-height:90px;overflow:auto}
.qr-fallback small{color:var(--muted);font-size:11.5px}
.qr-ok{text-align:center;color:var(--green)}
.qr-ok svg{width:64px;height:64px;margin-bottom:10px}
.qr-ok b{display:block;font-size:18px}
.pairing{margin-top:12px;font-size:12.5px;color:var(--muted)}
.qr-steps{margin:0 0 14px 18px;color:#555;font-size:13px;line-height:1.9}
.qr-status{display:flex;align-items:center;gap:9px;background:#f7f8fd;border-radius:10px;padding:11px 14px;font-size:13px;color:#555}
.dot-wait{width:9px;height:9px;border-radius:50%;background:var(--yellow);animation:pulse 1.2s ease-in-out infinite;flex-shrink:0}
.dot-ok{width:9px;height:9px;border-radius:50%;background:var(--green);flex-shrink:0}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.3}}

/* USUARIOS / EQUIPE */
.user-row{display:flex;align-items:center;gap:13px;padding:13px 0;border-bottom:1px solid var(--line)}
.user-row:last-child{border-bottom:none}
.user-av{width:38px;height:38px;border-radius:10px;background:var(--primary);color:#fff;display:grid;place-items:center;font-weight:700;font-size:13px;flex-shrink:0}
.user-info{flex:1;min-width:0}
.user-info b{font-size:14px;display:block}
.user-info small{color:var(--muted);font-size:12px}
.user-acts{display:flex;gap:8px;align-items:center;flex-shrink:0}

/* retry */
.retry-btn{border:1px solid var(--line);background:#fff;color:var(--primary);border-radius:7px;width:24px;height:24px;cursor:pointer;font-size:13px;margin-left:7px;vertical-align:middle}
.retry-btn:hover{background:var(--primary);color:#fff}

/* mini switch (automacoes) */
.mini-switch{width:42px;height:24px;-webkit-appearance:none;appearance:none;background:#ccd;border-radius:20px;position:relative;cursor:pointer;flex-shrink:0;transition:.2s}
.mini-switch:checked{background:var(--green)}
.mini-switch::after{content:"";position:absolute;width:18px;height:18px;border-radius:50%;background:#fff;top:3px;left:3px;transition:.2s}
.mini-switch:checked::after{left:21px}

/* switch row */
.switch-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 0;cursor:pointer}
.switch-row span{display:flex;flex-direction:column}
.switch-row small{color:var(--muted);font-size:12px;font-weight:400}
.switch-row input{width:46px;height:26px;-webkit-appearance:none;appearance:none;background:#ccd;border-radius:20px;position:relative;cursor:pointer;flex-shrink:0;transition:.2s}
.switch-row input:checked{background:var(--green)}
.switch-row input::after{content:"";position:absolute;width:20px;height:20px;border-radius:50%;background:#fff;top:3px;left:3px;transition:.2s}
.switch-row input:checked::after{left:23px}

@media(max-width:980px){
  .crm-board{grid-template-columns:1fr 1fr}
  .stat-grid{grid-template-columns:repeat(2,1fr)}
  .tpl-grid{grid-template-columns:1fr}
  .integ-layout{grid-template-columns:1fr}
  .sidebar{width:70px}
  .brand b,.suggest,.nav a span:not(.badge),.nav-label,.workspace div:last-child,.nav a{font-size:0}
  .main{margin-left:70px}
}
