/* WhatsBot — painel. Paleta do conceito aprovado (azul #2563eb), cantos 12px, sombras suaves. */
:root {
  --primary: #2563eb; --primary-hover: #1d4ed8; --primary-soft: #eff6ff;
  --success: #10b981; --success-soft: #ecfdf5; --warning: #f59e0b; --warning-soft: #fffbeb;
  --danger: #ef4444; --danger-soft: #fef2f2; --whats: #25d366;
  --dark: #0f172a; --g50: #f8fafc; --g100: #f1f5f9; --g200: #e2e8f0; --g300: #cbd5e1; --g400: #94a3b8; --g600: #475569; --g800: #1e293b;
  --radius: 12px; --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg: 0 20px 40px -12px rgba(15,23,42,.18); --t: all .2s cubic-bezier(.4,0,.2,1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: var(--g50); color: var(--dark); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
[x-cloak] { display: none !important; }
h1 { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: .95rem; font-weight: 650; }
small, .muted { color: var(--g600); }
.muted-2 { color: var(--g400); font-size: .85em; }
code { background: var(--g100); padding: 1px 6px; border-radius: 6px; font-size: .88em; }

/* Estrutura */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--dark); color: #cbd5e1; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30; transition: transform .25s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; color: #fff; font-weight: 800; font-size: 1.1rem; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #7c3aed); display: grid; place-items: center; font-size: 1rem; }
.brand small { display: block; color: #64748b; font-weight: 500; font-size: .72rem; margin-top: -2px; }
.nav { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: #cbd5e1; font-weight: 500; margin-bottom: 2px; transition: var(--t); }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.ativo { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(37,99,235,.7); }
.nav a .ic { width: 20px; text-align: center; font-size: 1rem; }
.nav a .pill { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; }
.side-user .nome { color: #fff; font-weight: 600; font-size: .88rem; line-height: 1.2; }
.side-user button { background: none; border: 0; color: #94a3b8; cursor: pointer; font-size: .8rem; padding: 0; }
.side-user button:hover { color: #fff; }
.main { flex: 1; margin-left: 240px; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: rgba(248,250,252,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--g200); }
.topbar .sub { color: var(--g600); font-size: .9rem; }
.topbar .acoes { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }
.so-mobile { display: none !important; }
.content { padding: 28px 32px 48px; max-width: 1240px; width: 100%; }
.content.wide { max-width: none; padding: 0; flex: 1; }
.banner { background: linear-gradient(90deg, #7c3aed, var(--primary)); color: #fff; padding: 8px 32px; display: flex; align-items: center; gap: 12px; font-size: .88rem; }
.banner.alerta { background: var(--warning); color: #451a03; }
.banner button { background: rgba(255,255,255,.2); color: inherit; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 3px 10px; cursor: pointer; font-weight: 600; }

/* Componentes */
.card { background: #fff; border: 1px solid var(--g200); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head .acoes { margin-left: auto; display: flex; gap: 8px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.stat { background: #fff; border: 1px solid var(--g200); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); transition: var(--t); position: relative; overflow: hidden; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat .rot { color: var(--g600); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .num { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; margin-top: 2px; }
.stat .det { color: var(--g400); font-size: .8rem; }
.stat .ic { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; background: var(--primary-soft); }
.stat.alerta .num { color: var(--danger); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; transition: var(--t); white-space: nowrap; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sec { background: #fff; color: var(--g800); border-color: var(--g200); }
.btn.sec:hover { background: var(--g50); border-color: var(--g300); }
.btn.ghost { background: transparent; color: var(--g600); }
.btn.ghost:hover { background: var(--g100); color: var(--dark); }
.btn.perigo { background: var(--danger-soft); color: #b91c1c; border-color: #fecaca; }
.btn.perigo:hover { background: #fee2e2; }
.btn.ok { background: var(--success); }
.btn.ok:hover { background: #059669; }
.btn.sm { padding: 5px 11px; font-size: .82rem; border-radius: 8px; }
.btn.lg { padding: 12px 22px; font-size: 1rem; }
.btn.bloco { width: 100%; }

label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 5px; color: var(--g800); }
.campo { margin-bottom: 14px; }
.campo .ajuda { color: var(--g400); font-size: .8rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--g200); border-radius: 9px; font: inherit; background: #fff; color: var(--dark); transition: var(--t); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: -3px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; margin: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; margin: 0; }
.switch input { position: absolute; opacity: 0; }
.switch .trilho { width: 40px; height: 22px; background: var(--g300); border-radius: 99px; position: relative; transition: var(--t); flex-shrink: 0; }
.switch .trilho::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: var(--t); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .trilho { background: var(--success); }
.switch input:checked + .trilho::after { left: 21px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 650; background: var(--g100); color: var(--g600); white-space: nowrap; }
.badge.verde { background: var(--success-soft); color: #047857; }
.badge.amarelo { background: var(--warning-soft); color: #b45309; }
.badge.vermelho { background: var(--danger-soft); color: #b91c1c; }
.badge.azul { background: var(--primary-soft); color: var(--primary-hover); }
.badge.roxo { background: #f5f3ff; color: #6d28d9; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--g300); display: inline-block; }
.dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.dot.ocupado { background: var(--warning); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; }
.alert.ok { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.alert.erro { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert.aviso { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }
.alert.info { background: var(--primary-soft); color: #1e40af; border-color: #bfdbfe; }

table.tab { width: 100%; border-collapse: collapse; }
.tab th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--g600); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--g200); background: var(--g50); }
.tab td { padding: 12px; border-bottom: 1px solid var(--g100); vertical-align: middle; }
.tab tr:hover td { background: var(--g50); }
.tab-wrap { overflow-x: auto; border: 1px solid var(--g200); border-radius: var(--radius); background: #fff; }
.tab-wrap .tab tr:last-child td { border-bottom: 0; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #dbeafe, #e0e7ff); color: var(--primary-hover); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: .72rem; }
.vazio { text-align: center; padding: 40px 20px; color: var(--g400); }
.vazio .ic { font-size: 2.2rem; margin-bottom: 8px; }

/* Passos de configuração */
.passos { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.passo { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--g300); color: var(--g800); font-weight: 600; font-size: .86rem; transition: var(--t); }
.passo:hover { border-color: var(--primary); background: var(--primary-soft); }
.passo .n { width: 24px; height: 24px; border-radius: 50%; background: var(--g100); display: grid; place-items: center; font-size: .75rem; flex-shrink: 0; }
.passo.feito { border-style: solid; border-color: #a7f3d0; background: var(--success-soft); color: #065f46; }
.passo.feito .n { background: var(--success); color: #fff; }

/* Gráfico de barras simples */
.barras { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.barras .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; position: relative; }
.barras .seg { width: 100%; max-width: 26px; border-radius: 4px 4px 0 0; transition: height .4s; min-height: 0; }
.barras .seg.r { background: var(--g300); }
.barras .seg.b { background: var(--primary); border-radius: 0; }
.barras .seg.h { background: var(--success); border-radius: 0; }
.barras .d { font-size: .66rem; color: var(--g400); margin-top: 4px; }
.barras .col:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; background: var(--dark); color: #fff; font-size: .72rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.legenda { display: flex; gap: 16px; font-size: .8rem; color: var(--g600); }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Prévia estilo WhatsApp */
.zap { background: #efeae2; background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px; border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.bolha { max-width: 82%; padding: 7px 11px 8px; border-radius: 10px; font-size: .9rem; line-height: 1.45; word-wrap: break-word; box-shadow: 0 1px .5px rgba(0,0,0,.13); position: relative; }
.bolha[x-html], .bolha [x-html] { white-space: pre-wrap; }
.bolha.in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.bolha.out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; }
.bolha.ia { background: #e0e7ff; }
.bolha.sistema { align-self: center; background: rgba(255,255,255,.85); color: var(--g600); font-size: .76rem; box-shadow: none; border-radius: 8px; padding: 4px 10px; max-width: 90%; text-align: center; }
.bolha .meta { display: block; font-size: .66rem; color: var(--g400); text-align: right; margin-top: 2px; }
.bolha .autor { display: block; font-size: .7rem; font-weight: 700; color: var(--primary-hover); margin-bottom: 1px; }
.bolha.ia .autor { color: #6d28d9; }
.bolha.erro { outline: 2px solid var(--danger); }

/* Caixa de atendimento */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 69px); background: #fff; }
.inbox-lista { border-right: 1px solid var(--g200); display: flex; flex-direction: column; min-height: 0; }
.abas { display: flex; gap: 0; padding: 8px 6px 0; scrollbar-width: none; border-bottom: 1px solid var(--g200); overflow-x: auto; }
.abas button { background: none; border: 0; padding: 9px 7px; font: inherit; font-size: .8rem; font-weight: 600; color: var(--g600); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.abas button.ativa { color: var(--primary); border-bottom-color: var(--primary); }
.abas .n { background: var(--g100); border-radius: 99px; padding: 0 6px; font-size: .72rem; }
.abas .n.quente { background: var(--danger); color: #fff; }
.busca { padding: 10px; }
.itens { overflow-y: auto; flex: 1; }
.item { display: flex; gap: 11px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--g100); transition: background .15s; }
.item:hover { background: var(--g50); }
.item.sel { background: var(--primary-soft); }
.item .info { min-width: 0; flex: 1; }
.item .l1 { display: flex; gap: 6px; align-items: center; }
.item .nome { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .hora { margin-left: auto; font-size: .72rem; color: var(--g400); flex-shrink: 0; }
.item .ult { font-size: .82rem; color: var(--g600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .nl { background: var(--whats); color: #fff; border-radius: 99px; font-size: .7rem; font-weight: 700; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; }
.chat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.chat-head { background: #fff; padding: 12px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--g200); flex-wrap: wrap; }
.chat-head .acoes { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px 6%; display: flex; flex-direction: column; gap: 5px; background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px; }
.chat-input { background: #f0f2f5; padding: 10px 14px; display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea { min-height: 42px; max-height: 140px; border-radius: 10px; border: 0; padding: 11px 14px; }
.chat-vazio { flex: 1; display: grid; place-items: center; color: var(--g600); text-align: center; background: var(--g50); }

/* Editor de menu */
.menu-layout { display: grid; grid-template-columns: 230px 1fr 340px; gap: 18px; align-items: start; }
.nos a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px; color: var(--g800); font-weight: 500; margin-bottom: 3px; }
.nos a:hover { background: var(--g100); }
.nos a.ativo { background: var(--primary-soft); color: var(--primary-hover); font-weight: 650; }
.opcao { border: 1px solid var(--g200); border-radius: 11px; padding: 14px; background: #fff; transition: var(--t); position: relative; }
.opcao:hover { border-color: var(--g300); box-shadow: var(--shadow); }
.opcao + .opcao { margin-top: 10px; }
.opcao .num { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.opcao .ordem { display: flex; flex-direction: column; gap: 2px; }
.opcao .ordem button { background: var(--g100); border: 0; border-radius: 5px; cursor: pointer; font-size: .65rem; padding: 1px 6px; color: var(--g600); }
.opcao .ordem button:hover { background: var(--g200); }
.sticky { position: sticky; top: 88px; }

/* Telefone (simulador e QR) */
.fone { max-width: 400px; margin: 0 auto; border-radius: 28px; border: 10px solid var(--dark); overflow: hidden; box-shadow: var(--shadow-lg); background: #efeae2; display: flex; flex-direction: column; height: 640px; }
.fone-top { background: #008069; color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.fone-top .avatar { background: rgba(255,255,255,.25); color: #fff; }
.fone-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 5px; background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px; }
.fone-input { display: flex; gap: 8px; padding: 8px; background: #f0f2f5; }
.fone-input input { border-radius: 99px; border: 0; padding: 10px 16px; }
.fone-input button { width: 42px; height: 42px; border-radius: 50%; background: #008069; color: #fff; border: 0; cursor: pointer; font-size: 1.05rem; flex-shrink: 0; }
.digitando { align-self: flex-start; background: #fff; border-radius: 10px; padding: 8px 14px; display: flex; gap: 4px; }
.digitando span { width: 6px; height: 6px; border-radius: 50%; background: var(--g400); animation: pula 1.2s infinite; }
.digitando span:nth-child(2) { animation-delay: .15s; } .digitando span:nth-child(3) { animation-delay: .3s; }
@keyframes pula { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.qr-box { width: 280px; height: 280px; border-radius: 16px; border: 1px solid var(--g200); display: grid; place-items: center; background: #fff; margin: 0 auto; overflow: hidden; }
.qr-box img { width: 100%; height: 100%; }
.status-grande { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 12px; background: var(--g50); }
.status-grande .ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; background: var(--g200); }
.status-grande.on .ic { background: var(--success-soft); }
.pulsar { animation: pulsar 1.6s infinite; }
@keyframes pulsar { 0% { box-shadow: 0 0 0 0 rgba(37,99,235,.35); } 70% { box-shadow: 0 0 0 12px rgba(37,99,235,0); } 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); } }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-arte { background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 60%, #7c3aed 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-arte::before { content: ''; position: absolute; width: 480px; height: 480px; border-radius: 50%; background: rgba(255,255,255,.08); right: -140px; top: -120px; filter: blur(10px); }
.auth-arte h1 { font-size: 2.4rem; line-height: 1.15; max-width: 440px; position: relative; }
.auth-arte p { opacity: .85; max-width: 420px; margin-top: 14px; font-size: 1.05rem; position: relative; }
.auth-arte .bolhas { position: relative; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.auth-arte .bolha { color: var(--dark); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form .caixa { width: 100%; max-width: 380px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 100; font-weight: 500; max-width: 380px; }
.toast.erro { background: #b91c1c; }
.modal-fundo { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
pre.prompt { background: var(--g800); color: #e2e8f0; padding: 16px; border-radius: 10px; font-size: .8rem; white-space: pre-wrap; max-height: 420px; overflow-y: auto; font-family: ui-monospace, Consolas, monospace; }
details summary { cursor: pointer; font-weight: 600; color: var(--primary); }

@media (max-width: 1100px) {
  .menu-layout { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .passos { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.aberta { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .so-mobile { display: inline-flex !important; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .banner { padding: 8px 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.com-chat .inbox-lista { display: none; }
  .inbox:not(.com-chat) .chat { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-arte { display: none; }
  .chat-msgs { padding: 14px; }
}
@media (max-width: 520px) { .g4, .passos { grid-template-columns: 1fr; } }
