/* ZapLeve — tema escuro estilo WhatsApp, responsivo (celular e computador) */
:root, [data-theme="dark"] {
  --bg: #0b141a; --panel: #111b21; --panel2: #202c33; --panel3: #2a3942; --line: #2a3942;
  --text: #e9edef; --muted: #8696a0; --green: #00a884; --green-dark: #005c4b; --blue: #53bdeb;
  --red: #f15c6d; --yellow: #f59e0b; --radius: 10px;
  --chat-bg: #0b141a; --chat-dot: %23182229; --bubble-in: #202c33; --bubble-out: #005c4b; --meta: #ffffff99;
  --quote-bg: #0003; --quote-text: #d1d7db; --day-bg: #182229; --sys-bg: #1d3a45; --sys-text: #cde3ea;
  --row-line: #1c272d; --chip-on: #0a332c; --shadow: #0008; --input: #202c33; --code-bg: #0a1014; --assume: #1c2a33;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eae6df; --panel: #ffffff; --panel2: #f0f2f5; --panel3: #e4e8eb; --line: #e1e4e7;
  --text: #111b21; --muted: #667781; --green: #00a884; --green-dark: #d9fdd3; --blue: #027eb5;
  --red: #e0245e; --yellow: #b45309;
  --chat-bg: #efeae2; --chat-dot: %23d9d2c5; --bubble-in: #ffffff; --bubble-out: #d9fdd3; --meta: #667781;
  --quote-bg: #0000000d; --quote-text: #3b4a54; --day-bg: #ffffffd9; --sys-bg: #fff5c4; --sys-text: #54656f;
  --row-line: #f0f2f5; --chip-on: #d9fdd3; --shadow: #0003; --input: #ffffff; --code-bg: #f6f8fa; --assume: #fff8e1;
  color-scheme: light;
}
:root {
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; } .right { text-align: right; }
.grow { flex: 1; min-width: 0; } .nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error, .err-text { color: var(--red); } .ok-text { color: var(--green); }
a { color: var(--blue); }
code { background: var(--panel3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; }
h2, h3, h4 { margin: 0; } h4 { margin: 18px 0 6px; color: var(--green); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

input, select, textarea { background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font: inherit; outline: none; width: auto; max-width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--green); }
input[type=checkbox] { accent-color: var(--green); width: 17px; height: 17px; }
input[type=color] { padding: 0; width: 26px; height: 26px; border: 0; background: none; cursor: pointer; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); font-size: 14.5px; }
label.check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
label.check span { display: flex; flex-direction: column; } label.check small { color: var(--muted); }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px;
  cursor: pointer; font: inherit; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn:hover:not(:disabled) { filter: brightness(1.2); } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.danger { color: var(--red); } .btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; } .btn.big { padding: 12px; font-size: 15px; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 8px; border-radius: 50%;
  line-height: 1; display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; }
.icon-btn:hover { background: var(--panel3); color: var(--text); }
.mini { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; font-size: 12px; }
.mini:disabled { opacity: .3; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap, .toolbar.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.on { color: var(--green); background: #00a88420; } .pill.off { color: var(--red); background: #f15c6d20; } .pill.wait { color: var(--yellow); background: #f59e0b20; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; } .status-dot.on { background: var(--green); } .status-dot.off { background: var(--muted); }
.badge { background: var(--green); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; min-width: 20px; text-align: center; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 4px; color: #fff; background: var(--c, #475569); white-space: nowrap; }
.tag.user { background: #334155; } .tag.inst { background: #1e3a4a; }
.big-icon { font-size: 52px; }
.empty-state { text-align: center; padding: 40px 20px; }
.loading { color: var(--muted); padding: 20px; text-align: center; }

/* switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--panel3); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch i::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--green); } .switch input:checked + i::before { transform: translateX(18px); }

/* ---------- login ---------- */
.auth { height: 100%; display: grid; place-items: center; padding: 20px; overflow: auto; }
.auth-card { background: var(--panel); padding: 32px; border-radius: 16px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.auth-card h1 { margin: 0; font-size: 32px; } .auth-card h1 span, .brand span { color: var(--green); }

/* ---------- estrutura ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.impersonation { background: #7c2d12; color: #fff; padding: 6px 14px; display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 13px; padding-top: calc(6px + var(--safe-t)); }
.shell { flex: 1; display: flex; min-height: 0; }
.spacer { flex: 1; }
main { flex: 1; min-width: 0; display: flex; min-height: 0; }
.page { flex: 1; overflow: auto; padding: 22px 26px 40px; } .page.narrow > * { max-width: 920px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; justify-content: space-between; }
.page-head p { margin: 4px 0 0; }

/* ---------- conversas ---------- */
.chat-layout { flex: 1; display: flex; min-width: 0; }
.conv-pane { width: 380px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); min-height: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px; }
.conv-search { padding: 4px 12px 8px; } .conv-search input { width: 100%; background: var(--panel2); border: 0; }
.chips { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.chip { background: var(--panel2); color: var(--muted); border: 0; border-radius: 99px; padding: 6px 12px; cursor: pointer; white-space: nowrap; font: inherit; font-size: 13px; }
.chip.active { background: var(--chip-on); color: var(--green); }
.inst-filter { margin: 0 12px 8px; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; align-items: center; border-bottom: 1px solid var(--row-line); }
.conv-item:hover { background: var(--panel2); } .conv-item.active { background: var(--panel3); }
.conv-item .row1, .conv-item .row2 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-item .name { font-weight: 500; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .time { color: var(--muted); font-size: 11.5px; flex-shrink: 0; } .conv-item .time.unread { color: var(--green); }
.conv-item .last { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.conv-item .row3 { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; } .conv-item .row3:empty { display: none; }
.typing { color: var(--green) !important; font-style: italic; }
.empty-list { padding: 30px; text-align: center; color: var(--muted); }

.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--c, #6b7c85); display: grid; place-items: center; flex-shrink: 0;
  color: #fff; font-weight: 700; position: relative; overflow: hidden; font-size: 16px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }

.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative;
  background-color: var(--chat-bg); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 20px 20px; }
.chat-empty { margin: auto; text-align: center; padding: 30px; max-width: 420px; } .chat-empty.small { margin: 40px auto; }
.chat-head { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: var(--panel2); min-height: 60px; padding-top: calc(8px + var(--safe-t)); }
.chat-head .avatar { width: 40px; height: 40px; }
.head-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-info small { color: var(--muted); font-size: 12.5px; }
.chat-tools { display: flex; gap: 6px; } .chat-tools select { padding: 6px 8px; font-size: 13px; max-width: 170px; }
.back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 14px 7% 10px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.day { align-self: center; margin: 10px 0; } .day span { background: var(--day-bg); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 8px; }
.msg-row { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 2px; max-width: 72%; align-self: flex-start; }
.msg-row.me { align-items: flex-end; align-self: flex-end; }
.msg-row.flash .bubble { box-shadow: 0 0 0 3px var(--green); }
.bubble { background: var(--bubble-in); box-shadow: 0 1px .5px #0000001a; padding: 6px 8px 6px 9px; border-radius: 8px; border-top-left-radius: 2px; position: relative; min-width: 80px; max-width: 100%; }
.msg-row.me .bubble { background: var(--bubble-out); border-top-left-radius: 8px; border-top-right-radius: 2px; }
.is-sticker .bubble { background: none !important; }
.bubble .text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; padding-right: 4px; }
.bubble .text code { background: #0003; }
.bubble .meta { float: right; font-size: 11px; color: var(--meta); margin: 6px 0 -4px 10px; white-space: nowrap; }
.tick.read { color: var(--blue); }
.bubble .msg-menu { position: absolute; top: 2px; right: 2px; background: inherit; border: 0; color: var(--muted); cursor: pointer; opacity: 0; font-size: 14px; border-radius: 50%; }
.bubble:hover .msg-menu { opacity: 1; }
.media { max-width: min(330px, 100%); max-height: 360px; border-radius: 6px; display: block; cursor: pointer; margin-bottom: 3px; }
video.media { cursor: auto; }
.sticker { width: 140px; height: 140px; object-fit: contain; }
.audio { display: flex; align-items: center; gap: 6px; } .audio audio { width: 250px; max-width: 60vw; height: 40px; }
.speed { background: var(--quote-bg); color: var(--text); border: 0; border-radius: 99px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.doc { display: flex; align-items: center; gap: 10px; background: var(--quote-bg); padding: 10px; border-radius: 6px; text-decoration: none; color: var(--text); min-width: 220px; }
.doc-icon { font-size: 26px; }
.no-media { color: var(--muted); font-style: italic; }
.fwd { color: var(--muted); font-size: 12px; font-style: italic; }
.agent { color: var(--green); font-size: 12px; font-weight: 600; }
.quote { background: var(--quote-bg); border-left: 4px solid var(--green); border-radius: 5px; padding: 5px 8px; margin-bottom: 4px; font-size: 13px; color: var(--quote-text);
  cursor: pointer; max-height: 70px; overflow: hidden; }
.deleted { color: var(--muted); font-style: italic; }
.reactions { background: var(--panel); border: 2px solid var(--chat-bg); border-radius: 99px; padding: 1px 7px; margin-top: -6px; font-size: 13px; cursor: pointer; z-index: 1; }
.reactions small { color: var(--muted); margin-left: 2px; }
.drop-hint { display: none; position: absolute; inset: 60px 0 0; background: #00a88433; border: 3px dashed var(--green); z-index: 5;
  align-items: center; justify-content: center; font-size: 20px; pointer-events: none; }
.chat-pane.dragging .drop-hint { display: flex; }
.reply-bar { display: flex; gap: 8px; align-items: center; background: var(--panel2); padding: 8px 12px 0; }
.attach-bar { display: flex; gap: 8px; padding: 10px 12px 0; background: var(--panel2); overflow-x: auto; flex-wrap: wrap; }
.att { position: relative; width: 120px; background: var(--panel); border-radius: 8px; overflow: hidden; }
.att img, .att video { width: 120px; height: 90px; object-fit: cover; display: block; }
.att-icon { height: 90px; display: grid; place-items: center; font-size: 38px; }
.att-name { padding: 4px 6px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name small { display: block; color: var(--muted); }
.att-rm, .att-doc { position: absolute; top: 4px; background: #000a; color: #fff; border: 0; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px; }
.att-rm { right: 4px; } .att-doc { right: 32px; }
.att-hint { width: 100%; font-size: 12px; }
.composer, .recording-bar { display: flex; gap: 4px; padding: 8px 10px; background: var(--panel2); align-items: flex-end; padding-bottom: calc(8px + var(--safe-b)); }
.composer textarea { flex: 1; resize: none; max-height: 160px; background: var(--panel3); border: 0; border-radius: 10px; padding: 11px 14px; line-height: 1.35; }
.icon-btn.send { background: var(--green); color: #fff; font-size: 18px; } .icon-btn.send:hover { background: var(--green); filter: brightness(1.1); }
.recording-bar { align-items: center; gap: 10px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* menus, modais, emojis */
.ctx-menu { position: fixed; z-index: 60; background: var(--panel); border-radius: 10px; padding: 6px 0; min-width: 210px; box-shadow: 0 8px 30px var(--shadow); border: 1px solid var(--line); }
.ctx-menu > button { display: flex; gap: 12px; align-items: center; width: 100%; background: none; border: 0; color: var(--text); padding: 10px 18px; cursor: pointer; font: inherit; text-align: left; }
.ctx-menu > button:hover { background: var(--panel3); } .ctx-menu > button.danger { color: var(--red); }
.quick-react { display: flex; gap: 2px; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.quick-react button { background: none; border: 0; font-size: 22px; cursor: pointer; border-radius: 50%; width: 38px; height: 38px; }
.quick-react button:hover, .quick-react button.on { background: var(--panel3); }
.emoji-menu { padding: 0; }
.emoji-picker { width: 320px; max-width: 92vw; height: 300px; overflow-y: auto; padding: 8px; }
.emoji-cat { color: var(--muted); font-size: 12px; margin: 6px 4px 2px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-grid button { background: none; border: 0; font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--panel3); }
.modal-backdrop { position: fixed; inset: 0; background: #000a; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(780px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { flex: 1; font-size: 17px; } .modal-back { display: none; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; }
.modal-actions.sticky { position: sticky; bottom: -18px; background: var(--panel); padding: 12px 0 4px; }
.modal-actions .muted { margin-right: auto; }
.lightbox-modal { background: none; width: auto !important; } .lightbox-modal .modal-head { border: 0; } .lightbox-modal .modal-head h3 { visibility: hidden; }
.lightbox { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.lightbox img, .lightbox video { max-width: 90vw; max-height: 78vh; border-radius: 8px; }
.pick-list { list-style: none; padding: 0; margin: 10px 0 0; max-height: 50vh; overflow-y: auto; }
.pick-list label { flex-direction: row; align-items: center; gap: 10px; padding: 8px 4px; color: var(--text); cursor: pointer; border-radius: 8px; }
.pick-list label:hover { background: var(--panel2); }

/* configurações */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 10px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; cursor: pointer; font: inherit; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--green); border-bottom-color: var(--green); }
.setting { display: flex; flex-direction: row; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.setting.col { flex-direction: column; align-items: stretch; cursor: default; }
.setting strong { display: block; font-weight: 500; } .setting small { color: var(--muted); display: block; margin-top: 2px; font-size: 12.5px; }
.setting textarea, .setting select { width: 100%; }
.help-box { margin-bottom: 14px; color: var(--muted); }
details summary { cursor: pointer; color: var(--blue); margin: 4px 0; }
.events { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.events legend { color: var(--muted); padding: 0 6px; }
.event-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; } .event-grid.disabled { opacity: .4; pointer-events: none; }
.row.hdr input { flex: 1; min-width: 0; }

/* tabelas */
.table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat small { color: var(--muted); display: block; } .stat b { font-size: 26px; }
.plan-info { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); }

/* conexões */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.inst-card { display: flex; flex-direction: column; gap: 14px; }
.inst-head { display: flex; gap: 12px; align-items: center; } .inst-icon { font-size: 30px; }
.qr-box { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.qr-box img { width: 220px; background: #fff; padding: 8px; border-radius: 10px; }
.qr-box ol { margin: 0; padding-left: 18px; color: var(--muted); flex: 1; min-width: 160px; }

/* webhooks */
.hook-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hook-info { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.secret code { word-break: break-all; }
.help { margin-top: 18px; }

/* kanban */
.view-kanban .page { display: flex; flex-direction: column; }
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; flex: 1; padding-bottom: 12px; }
.col { background: var(--panel); border-radius: var(--radius); width: 300px; flex-shrink: 0; display: flex; flex-direction: column; max-height: 100%; border-top: 4px solid var(--c); }
.col-head { padding: 10px 10px 8px 12px; display: flex; align-items: center; gap: 6px; }
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.col-head [data-rename] { cursor: pointer; }
.col-head .count { background: var(--panel3); color: var(--muted); font-size: 12px; border-radius: 99px; padding: 0 8px; }
.col-body { padding: 0 8px 10px; overflow-y: auto; min-height: 70px; display: flex; flex-direction: column; gap: 8px; }
.col.over { outline: 2px dashed var(--green); outline-offset: -2px; }
.col-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 18px 6px; border: 1px dashed var(--line); border-radius: 8px; }
.card { background: var(--panel2); border-radius: 8px; padding: 10px; cursor: grab; display: flex; gap: 10px; }
.card:hover { background: var(--panel3); } .card.dragging { opacity: .4; }
.card-top { display: flex; justify-content: space-between; gap: 6px; } .card-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { display: flex; gap: 5px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.move-select { display: none; margin-top: 6px; width: 100%; padding: 5px; font-size: 12.5px; }
.more { width: 100%; }

.toast { position: fixed; bottom: calc(24px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel);
  padding: 11px 18px; border-radius: 10px; z-index: 99; box-shadow: 0 6px 20px #0008; max-width: 92vw; text-align: center; }
.toast.err { background: #b91c1c; color: #fff; }

/* ================= CELULAR ================= */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { flex-direction: column-reverse; }
  .nav-bar { width: 100%; height: calc(60px + var(--safe-b)); flex-direction: row; padding: 0 4px var(--safe-b); border-right: 0; border-top: 1px solid var(--line); justify-content: space-around; }
  .brand, .nav-bar .spacer { display: none; }
  .nav-item { width: auto; flex: 1; padding: 6px 0; font-size: 20px; border-radius: 10px; }
  .nav-item small { font-size: 10px; }
  .page { padding: 14px 12px 30px; padding-top: calc(14px + var(--safe-t)); }
  .page-head .btn.primary { width: 100%; }

  /* lista e chat em telas separadas */
  .conv-pane { width: 100%; border-right: 0; padding-top: var(--safe-t); }
  .chat-pane { display: none; }
  .chat-layout.open .conv-pane { display: none; }
  .chat-layout.open .chat-pane { display: flex; }
  body[data-route="chat"] .chat-layout.open ~ * , body[data-route="chat"]:has(.chat-layout.open) .nav-bar { display: none; }
  .back { display: inline-flex; margin-left: -6px; }
  .chat-head { flex-wrap: wrap; gap: 8px; }
  .chat-tools { order: 5; width: 100%; } .chat-tools select { flex: 1; max-width: none; }
  .messages { padding: 10px 10px; }
  .msg-row { max-width: 88%; }
  .bubble .msg-menu { display: none; }
  .media { max-width: 100%; }
  .audio audio { width: 200px; }
  .composer textarea { font-size: 16px; } /* evita zoom no iPhone */

  .modal-backdrop { padding: 0; place-items: stretch; }
  .modal, .modal.wide { width: 100%; max-height: 100%; height: 100%; border-radius: 0; padding-top: var(--safe-t); }
  .modal-back { display: inline-flex; } .modal-head [data-close]:last-child { display: none; }
  .lightbox-modal { height: 100%; background: #000; } .lightbox-modal .modal-head [data-close]:last-child { display: inline-flex; }
  .grid2, .grid3, .event-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .qr-box img { width: 100%; max-width: 280px; }

  /* kanban no celular: rolagem lateral por etapa + mover pelo seletor */
  .board { scroll-snap-type: x mandatory; }
  .col { width: 86vw; scroll-snap-align: center; }
  .card { cursor: pointer; } .move-select { display: block; }

  /* tabelas viram cartões */
  .table thead { display: none; }
  .table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 5px 4px; text-align: right; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .table td.right { justify-content: flex-end; flex-wrap: wrap; }
  .ctx-menu { left: 8px !important; right: 8px; bottom: calc(8px + var(--safe-b)); top: auto !important; min-width: 0; }
}
@media (hover: none) { .bubble .msg-menu { display: none; } }
.setting.col { width: 100%; }

/* ---------- fila, abas e setores ---------- */
.state-tabs { display: flex; border-bottom: 1px solid var(--line); margin: 0 12px 8px; }
.state-tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 4px; cursor: pointer; font: inherit; font-size: 13.5px; border-bottom: 3px solid transparent; }
.state-tabs button.active { color: var(--green); border-bottom-color: var(--green); }
.state-tabs b, .chip b { font-size: 11px; background: var(--panel3); border-radius: 99px; padding: 0 6px; margin-left: 2px; }
.state-tabs b:empty, .chip b:empty { display: none; }
.chips { flex-wrap: wrap; } .chip.active b { background: var(--panel); }
.mini-select { padding: 5px 8px; font-size: 12.5px; border-radius: 99px; max-width: 150px; }
.btn.xs { padding: 2px 8px; font-size: 11.5px; border-radius: 6px; }
.tag.offer { background: #b45309; } .tag.waiting { background: #92400e; } .tag.closed { background: #475569; }
.badge.muted { background: var(--muted); }
.assume-bar { background: var(--assume); padding: 8px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); }
.sys-msg { align-self: center; margin: 6px 0; } .sys-msg span { background: var(--sys-bg); color: var(--sys-text); font-size: 12px; padding: 4px 12px; border-radius: 8px; }
.deleted-flag { color: #fca5a5; font-size: 11.5px; font-style: italic; }
.kept-deleted .bubble { opacity: .78; outline: 1px dashed #f15c6d66; }
.edited { cursor: pointer; text-decoration: underline dotted; }
.pre { white-space: pre-wrap; }
.result-list { list-style: none; padding: 0; margin: 10px 0 0; max-height: 60vh; overflow-y: auto; }
.result-list li { padding: 10px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.result-list li:hover { background: var(--panel2); }
.two-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.list-item.inactive { opacity: .55; }
.list-item .dot, .col-head .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 8px; }
.check-grid.disabled { opacity: .4; pointer-events: none; }
.queue-explain { background: var(--panel2); border-radius: 8px; padding: 4px 12px; color: var(--muted); }
.inst-icon img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; display: block; }
@media (max-width: 760px) {
  .two-cols { grid-template-columns: 1fr; }
  .chat-tools .btn.sm { flex: 1; }
  .chat-tools { flex-wrap: wrap; }
}
.sys-msg { max-width: 92%; text-align: center; } .sys-msg span { display: inline-block; line-height: 1.4; }

/* tema claro: ajustes finos */
[data-theme="light"] .conv-item.active { background: var(--panel3); }
[data-theme="light"] .tag { color: #fff; }
[data-theme="light"] .tag.user { background: #64748b; } [data-theme="light"] .tag.inst { background: #0e7490; }
[data-theme="light"] .icon-btn.send, [data-theme="light"] .btn.primary { color: #fff; }
[data-theme="light"] .modal-backdrop { background: #0006; }
[data-theme="light"] .impersonation { background: #c2410c; }
[data-theme="light"] .qr-box img { border: 1px solid var(--line); }
[data-theme="light"] .kept-deleted .bubble { outline-color: #e0245e55; }
[data-theme="light"] .deleted-flag { color: #be123c; }


/* =================================================================== DESIGN v2 */
:root { --accent-soft: #00a88422; --nav-w: 72px; }
[data-theme="light"] { --accent-soft: #00a8841a; }
* { scrollbar-width: thin; scrollbar-color: var(--panel3) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 8px; } ::-webkit-scrollbar-track { background: transparent; }
.ic { display: block; flex-shrink: 0; }
.btn .ic { width: 16px; height: 16px; }

/* ---- menu lateral ---- */
.nav-bar { width: var(--nav-w); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 4px; }
.brand { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, #00a884, #017561); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; letter-spacing: -.5px; margin-bottom: 14px; box-shadow: 0 4px 14px #00a88440; }
.brand span { color: #d9fdd3; }
.nav-item { position: relative; background: none; border: 0; color: var(--muted); cursor: pointer; width: 60px; padding: 7px 0 6px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; font-family: inherit; transition: background .15s, color .15s; }
.nav-ic { width: 40px; height: 32px; display: grid; place-items: center; border-radius: 16px; transition: background .15s; }
.nav-item small { font-size: 10.5px; font-weight: 500; letter-spacing: .1px; }
.nav-item:hover { color: var(--text); } .nav-item:hover .nav-ic { background: var(--panel2); }
.nav-item.active { color: var(--green); } .nav-item.active .nav-ic { background: var(--accent-soft); }
.nav-item.active::before { content: ''; position: absolute; left: -6px; top: 12px; bottom: 26px; width: 3px; border-radius: 0 3px 3px 0; background: var(--green); }
.nav-me { width: 34px; height: 34px; border-radius: 50%; background: var(--panel3); color: var(--text); display: grid; place-items: center; font-weight: 700; font-size: 14px; margin: 6px 0 4px; }
.nav-item.logout:hover { color: var(--red); }

/* ---- lista ---- */
.pane-head h2 { font-size: 21px; font-weight: 700; }
.conv-search input { border-radius: 10px; padding-left: 14px; }
.conv-item { border-bottom: 0; margin: 0 6px; border-radius: 10px; padding: 9px 10px; }
.conv-item + .conv-item { box-shadow: 0 -1px 0 var(--row-line); }
.conv-item:hover { background: var(--panel2); box-shadow: none; } .conv-item.active { background: var(--panel3); box-shadow: none; }
.conv-item:hover + .conv-item, .conv-item.active + .conv-item { box-shadow: none; }

/* ---- cabeçalho e composer ---- */
.chat-head { border-bottom: 1px solid var(--line); background: var(--panel2); }
.composer { align-items: center; gap: 6px; padding: 8px 12px calc(8px + var(--safe-b)); }
.composer .icon-btn { color: var(--muted); }
.input-wrap { flex: 1; background: var(--input); border-radius: 22px; padding: 2px 6px; display: flex; border: 1px solid var(--line); }
[data-theme="dark"] .input-wrap { background: var(--panel3); border-color: transparent; }
.input-wrap textarea { flex: 1; background: none !important; border: 0 !important; padding: 10px 10px; max-height: 160px; }
.icon-btn.send { width: 46px; height: 46px; min-width: 46px; background: var(--green); color: #fff !important; box-shadow: 0 2px 8px #00a88455; }
.recording-bar { gap: 12px; } .rec-time { font-variant-numeric: tabular-nums; min-width: 42px; }
.rec-wave { display: flex; gap: 3px; align-items: center; height: 26px; }
.rec-wave i { width: 3px; border-radius: 3px; background: var(--green); animation: wave 1s ease-in-out infinite; height: 30%; }
.rec-wave i:nth-child(3n) { animation-delay: .15s; } .rec-wave i:nth-child(3n+1) { animation-delay: .3s; } .rec-wave i:nth-child(4n) { animation-delay: .45s; }
@keyframes wave { 50% { height: 100%; } }

/* ---- mensagens: agrupadas e com "rabinho" ---- */
.messages { gap: 0; padding-top: 18px; }
.msg-row { margin-top: 2px; }
.msg-row.first { margin-top: 10px; }
.bubble { border-radius: 9px; padding: 6px 9px 7px; }
.msg-row.first:not(.me) .bubble { border-top-left-radius: 0; }
.msg-row.first.me .bubble { border-top-right-radius: 0; }
.msg-row.first:not(.me):not(.is-sticker) .bubble::before, .msg-row.first.me:not(.is-sticker) .bubble::before {
  content: ''; position: absolute; top: 0; width: 9px; height: 13px; background: inherit; }
.msg-row.first:not(.me) .bubble::before { left: -8px; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.msg-row.first.me .bubble::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.bubble .msg-menu { top: 4px; right: 4px; width: 24px; height: 24px; display: grid; place-items: center; background: linear-gradient(90deg, transparent, var(--bubble-in) 40%); border-radius: 0 8px 0 12px; }
.msg-row.me .bubble .msg-menu { background: linear-gradient(90deg, transparent, var(--bubble-out) 40%); }
.day span { font-size: 12px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px .5px #0000001a; text-transform: none; }
.sys-msg span { border-radius: 8px; box-shadow: 0 1px .5px #0000001a; }

/* ---- player de áudio ---- */
.is-audio .bubble { min-width: 290px; padding: 8px 10px 6px; }
.ap { display: flex; align-items: center; gap: 10px; }
.ap-avatar { width: 44px; height: 44px; border-radius: 50%; background: #6b7c85; color: #fff; position: relative; display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.ap-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-avatar span { position: absolute; right: -2px; bottom: -2px; color: var(--green); background: var(--bubble-in); border-radius: 50%; padding: 2px; display: none; }
.ap-avatar img + span { display: block; }
.ap-avatar.me { background: var(--green); }
.ap-play { width: 34px; height: 34px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; flex-shrink: 0; padding: 0; }
.ap-play:hover { color: var(--text); }
.ap-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ap-wave { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; }
.ap-wave i { flex: 1; max-width: 4px; min-width: 2px; border-radius: 3px; background: var(--muted); opacity: .55; transition: background .1s, opacity .1s; }
.ap-wave i.played { background: var(--blue); opacity: 1; }
.msg-row.me .ap-wave i.played { background: var(--green); }
.ap-info { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--meta); font-variant-numeric: tabular-nums; padding-right: 54px; }
.ap-speed { border: 0; background: var(--quote-bg); color: var(--text); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; cursor: pointer; }
.ap.on .ap-speed { background: var(--green); color: #fff; }
.ap audio { display: none; }
.is-audio .bubble .meta { position: absolute; right: 10px; bottom: 6px; margin: 0; }

/* ---- seletor de emojis ---- */
.emoji-pop { position: fixed; z-index: 70; width: 360px; max-width: calc(100vw - 16px); height: 400px; max-height: 60vh; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 12px 40px var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.emoji-tabs { display: flex; justify-content: space-between; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.emoji-tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 9px; cursor: pointer; display: grid; place-items: center; border-bottom: 3px solid transparent; }
.emoji-tabs button:hover { color: var(--text); } .emoji-tabs button.on { color: var(--green); border-bottom-color: var(--green); }
.emoji-search { display: flex; align-items: center; gap: 8px; margin: 8px 10px 2px; background: var(--panel2); border-radius: 10px; padding: 0 10px; color: var(--muted); }
.emoji-search input { flex: 1; border: 0 !important; background: none !important; padding: 9px 0; }
.emoji-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 8px 8px; }
.emoji-scroll h5 { margin: 10px 4px 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.emoji-pop .emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; }
.emoji-pop .emoji-grid button { background: none; border: 0; font-size: 24px; line-height: 1; aspect-ratio: 1; border-radius: 8px; cursor: pointer; padding: 0; display: grid; place-items: center; transition: transform .08s, background .08s; }
.emoji-pop .emoji-grid button:hover { background: var(--panel2); transform: scale(1.15); }
.emoji-empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- menus de contexto ---- */
.ctx-menu { border-radius: 12px; padding: 6px; }
.ctx-menu > button { border-radius: 8px; padding: 9px 14px; }
.quick-react { gap: 4px; padding: 4px 4px 8px; }
.quick-react button { transition: transform .1s; } .quick-react button:hover { transform: scale(1.2); }

/* ---- cartões, botões ---- */
.btn { border-radius: 10px; font-weight: 500; transition: filter .15s, background .15s; }
.btn.sm { border-radius: 8px; }
.panel { border-radius: 14px; }
.modal { border-radius: 16px; box-shadow: 0 20px 60px var(--shadow); }

@media (max-width: 760px) {
  .nav-bar { padding: 0 2px var(--safe-b); }
  .nav-item { width: auto; padding: 5px 0; } .nav-ic { width: 52px; height: 28px; }
  .nav-item.active::before, .nav-me, .theme-btn { display: none; }
  .brand { display: none; }
  .is-audio .bubble { min-width: 240px; }
  .emoji-pop { left: 8px !important; right: 8px; width: auto; top: auto !important; bottom: calc(70px + var(--safe-b)); }
}
.brand { white-space: nowrap; display: flex; align-items: center; justify-content: center; }
.is-audio .bubble { padding-bottom: 20px; }
.is-audio .bubble .meta { bottom: 4px; }
.ap-info { padding-right: 0; }
.ap-avatar span { position: static; display: grid; color: #fff; background: none; padding: 0; }
.ap-avatar img + span { position: absolute; right: -3px; bottom: -3px; display: grid; color: var(--green); background: var(--bubble-in); border-radius: 50%; padding: 2px; }
.msg-row.me .ap-avatar img + span { background: var(--bubble-out); }
/* fotos e vídeos: balão do tamanho da imagem, como no WhatsApp */
.is-media .bubble { padding: 4px 4px 6px; max-width: 340px; }
.is-media .bubble .media { width: 100%; max-width: 330px; height: auto; max-height: 420px; object-fit: cover; border-radius: 7px; margin: 0; background: var(--panel3); }
.is-media .bubble .text { padding: 4px 6px 0; }
.is-media .bubble .meta { margin-right: 4px; }
.is-media .bubble .fwd, .is-media .bubble .quote, .is-media .bubble .agent { margin: 2px 4px 4px; }
.att img { background: repeating-conic-gradient(var(--panel3) 0 25%, var(--panel) 0 50%) 0 0 / 14px 14px; }

/* celular: menu vira barra inferior (precisa vir depois do estilo do menu lateral) */
@media (max-width: 760px) {
  .nav-bar { width: 100%; height: calc(62px + var(--safe-b)); flex-direction: row; align-items: center; justify-content: space-around;
    padding: 0 4px var(--safe-b); gap: 0; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .nav-bar .spacer, .nav-bar .brand, .nav-bar .nav-me, .nav-bar .theme-btn { display: none; }
  .nav-item { flex: 1; min-width: 54px; padding: 4px 0; gap: 2px; }
  .nav-ic { width: 48px; height: 28px; }
  .nav-item small { font-size: 10px; }
  .nav-item.active::before { display: none; }
  .chips .mini-select { max-width: 46%; }
}
.install-banner { display: flex; align-items: center; gap: 10px; margin: 8px 10px 4px; padding: 10px 10px 10px 12px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid #00a88440; }
.install-banner img { width: 38px; height: 38px; border-radius: 10px; }
.install-banner strong { display: block; font-size: 14px; } .install-banner small { color: var(--muted); font-size: 12px; }
/* no app instalado, respeita a área do relógio/notch */
@media (display-mode: standalone) { .conv-pane, .page { padding-top: max(env(safe-area-inset-top), 0px); } }
.install-steps { counter-reset: st; list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { counter-increment: st; display: flex; gap: 12px; align-items: flex-start; line-height: 1.45; }
.install-steps li::before { content: counter(st); flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
#instNow { width: 100%; margin-bottom: 8px; }
.install-steps li { display: block; position: relative; padding: 2px 0 0 38px; min-height: 28px; }
.install-steps li::before { position: absolute; left: 0; top: 0; }

/* logo */
.brand { background: none !important; box-shadow: none !important; padding: 0; }
.brand img { width: 44px; height: 44px; display: block; filter: drop-shadow(0 4px 10px #00a88455); }
.auth-logo { display: flex; align-items: center; gap: 12px; }
.auth-logo img { width: 54px; height: 54px; filter: drop-shadow(0 6px 14px #00a88455); }
.m-only { display: none !important; }

/* celular: barra inferior só com Conversas e Tema */
@media (max-width: 760px) {
  .nav-bar .nav-item:not(.m-keep) { display: none; }
  .nav-bar .theme-btn.m-keep { display: flex; }
  .nav-bar { justify-content: center; gap: 40px; }
  .nav-bar .nav-item { flex: 0 0 auto; width: 110px; }
  .m-only { display: inline-flex !important; }
}
.nav-me { flex-shrink: 0; }
.empty-logo { width: 88px; height: 88px; margin-bottom: 8px; opacity: .95; filter: drop-shadow(0 10px 24px #00a88440); }
.online-tag { color: var(--green); margin-top: 2px; }
