:root {
  --bg: #0b141a;
  --panel: #111b21;
  --head: #202c33;
  --line: #2a3942;
  --in: #202c33;
  --out: #005c4b;
  --text: #e9edef;
  --muted: #8696a0;
  --accent: #00a884;
  --accent-2: #25d366;
  --danger: #ea4335;
  --input: #2a3942;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
a { color: #53bdeb; }
.hidden { display: none !important; }

/* ---------- botões e campos */
.btn { background: var(--accent); color: #111b21; font-weight: 600; padding: 12px 18px; border-radius: 24px; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.field { width: 100%; background: var(--input); border: 1px solid transparent; border-radius: 10px; padding: 12px 14px; outline: none; }
.field:focus { border-color: var(--accent); }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: rgba(255,255,255,.06); }

/* ---------- layout de chat */
.app { height: 100dvh; display: flex; flex-direction: column; }
.topbar { background: var(--head); padding: calc(10px + var(--safe-t)) 12px 10px; display: flex; align-items: center; gap: 12px; min-height: 60px; flex: none; z-index: 2; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; flex: none; overflow: hidden; background: #6a7175; color: #fff; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who small.live { color: var(--accent-2); }

.thread { flex: 1; overflow-y: auto; padding: 12px 4% 8px; display: flex; flex-direction: column; gap: 2px;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23ffffff' fill-opacity='.025'%3E%3Ccircle cx='10' cy='10' r='3'/%3E%3Cpath d='M50 8h12v3H50zM30 40l6 6-6 6-6-6z'/%3E%3Ccircle cx='62' cy='52' r='5' fill='none' stroke='%23fff' stroke-opacity='.03' stroke-width='2'/%3E%3Cpath d='M8 62h10v10H8z' fill-opacity='.02'/%3E%3C/g%3E%3C/svg%3E"); }
.day { align-self: center; margin: 10px 0 6px; }
.day span { background: var(--head); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px .5px rgba(0,0,0,.13); }
.msg { max-width: min(78%, 520px); padding: 6px 8px 8px 9px; border-radius: 8px; position: relative; box-shadow: 0 1px .5px rgba(0,0,0,.13); word-wrap: break-word; overflow-wrap: anywhere; margin-top: 2px; }
.msg.in { align-self: flex-start; background: var(--in); border-top-left-radius: 0; }
.msg.out { align-self: flex-end; background: var(--out); border-top-right-radius: 0; }
.msg + .msg.in, .msg.out + .msg.out { border-radius: 8px; }
.msg .txt { display: inline; white-space: normal; }
.msg .meta { float: right; font-size: 11px; color: rgba(233,237,239,.6); margin: 8px 0 -4px 10px; display: inline-flex; align-items: center; gap: 3px; position: relative; top: 2px; }
.msg .tick { width: 16px; height: 11px; fill: #53bdeb; }
.msg img.pic { display: block; max-width: 100%; width: 300px; max-height: 360px; object-fit: cover; border-radius: 6px; margin: -2px -4px 0 -5px; cursor: zoom-in; background: #0003; }
.msg:has(img.pic) .meta, .msg:has(audio) .meta { float: none; display: flex; justify-content: flex-end; margin-top: 4px; }
.msg audio { width: 260px; max-width: 100%; height: 40px; display: block; }
.typing-bubble { align-self: flex-start; background: var(--in); border-radius: 8px; border-top-left-radius: 0; padding: 12px 14px; display: flex; gap: 4px; margin-top: 4px; }
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing-bubble i:nth-child(2) { animation-delay: .2s; } .typing-bubble i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- campo de digitação */
.composer { background: var(--head); padding: 6px 8px calc(6px + var(--safe-b)); display: flex; align-items: flex-end; gap: 6px; flex: none; }
.composer .box { flex: 1; display: flex; align-items: flex-end; background: var(--input); border-radius: 22px; padding: 0 4px 0 14px; min-height: 44px; }
.composer textarea { flex: 1; background: transparent; border: 0; outline: none; resize: none; padding: 11px 0; max-height: 140px; line-height: 1.4; font-size: 16px; }
.composer .box .icon-btn { width: 40px; height: 44px; }
.send { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #111b21; display: grid; place-items: center; flex: none; }
.send svg { width: 22px; height: 22px; }
.rec-bar { flex: 1; display: flex; align-items: center; gap: 12px; background: var(--input); border-radius: 22px; padding: 0 8px 0 14px; min-height: 44px; }
.rec-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.rec-bar .t { flex: 1; font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { opacity: .3; } }
.uploading { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); background: var(--head); padding: 8px 14px; border-radius: 16px; font-size: 13px; color: var(--muted); z-index: 30; }

/* ---------- extras */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; z-index: 100; }
.viewer img { max-width: 96vw; max-height: 90dvh; }
.viewer button { position: absolute; top: calc(12px + var(--safe-t)); right: 14px; font-size: 22px; width: 44px; height: 44px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; background: #e9edef; color: #111b21; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 200; transition: .25s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 150; }
.sheet { background: var(--panel); width: 100%; max-width: 480px; border-radius: 18px 18px 0 0; padding: 22px 20px calc(20px + var(--safe-b)); animation: up .2s ease-out; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 16px; } }
.sheet h3 { margin: 0 0 12px; font-weight: 600; }
.sheet ol { padding-left: 20px; color: var(--muted); line-height: 1.9; margin: 0 0 18px; }
.sheet ol b { color: var(--text); }
.ios-share { width: 18px; height: 18px; vertical-align: -3px; color: #53bdeb; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.banner { display: flex; align-items: center; gap: 10px; background: #182229; padding: 10px 14px; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); flex: none; }
.banner span { flex: 1; }
.banner svg { color: var(--accent); }
.banner .btn { width: auto; padding: 7px 14px; font-size: 13px; }
.banner .x { color: var(--muted); font-size: 18px; padding: 4px 6px; }

/* ---------- tela inicial do lead */
.welcome { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(30px + var(--safe-t)) 24px calc(30px + var(--safe-b));
  background: radial-gradient(ellipse at top, #0d3b33 0%, var(--bg) 60%); }
.welcome .card { width: 100%; max-width: 400px; }
.welcome .logo { width: 84px; height: 84px; border-radius: 22px; display: block; margin: 0 auto 18px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.welcome h1 { text-align: center; margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.welcome p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.welcome .err { color: #ff8a80; font-size: 14px; min-height: 20px; margin: 10px 0 0; text-align: center; }
.welcome .btn { margin-top: 18px; }
.welcome .online { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 20px; }
.welcome .online i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 4px rgba(37,211,102,.15); }

/* ================= PAINEL ================= */
.admin { height: 100dvh; display: flex; background: var(--panel); }
.side { width: 380px; max-width: 100%; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); flex: none; }
.side .topbar h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 600; }
.searchbar { padding: 8px 12px; display: flex; gap: 8px; }
.searchbar .s { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--head); border-radius: 8px; padding: 0 12px; color: var(--muted); }
.searchbar input { flex: 1; background: transparent; border: 0; outline: none; padding: 9px 0; font-size: 15px; }
.searchbar svg { width: 18px; height: 18px; }
.chips { display: flex; gap: 8px; padding: 2px 12px 8px; overflow-x: auto; flex: none; }
.chip { padding: 6px 12px; border-radius: 16px; background: var(--head); color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.chip.on { background: #0a332c; color: var(--accent-2); }
.convs { flex: 1; overflow-y: auto; }
.conv { display: flex; gap: 12px; padding: 0 0 0 14px; align-items: center; cursor: pointer; }
.conv:hover { background: #202c3388; }
.conv.active { background: var(--head); }
.conv .body { flex: 1; min-width: 0; border-bottom: 1px solid #222d34; padding: 12px 14px 12px 0; }
.conv .r1, .conv .r2 { display: flex; align-items: center; gap: 8px; }
.conv .r1 b { flex: 1; font-weight: 400; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .r1 small { color: var(--muted); font-size: 12px; }
.conv .r2 span { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .r2 span.live { color: var(--accent-2); }
.conv .badge { background: var(--accent-2); color: #111b21; font-size: 12px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.conv.unread .r1 small { color: var(--accent-2); }
.conv .tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #0a332c; color: var(--accent-2); }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; font-size: 14px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.main .placeholder { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); background: #222e35; border-bottom: 6px solid var(--accent); padding: 20px; }
.main .placeholder h2 { color: var(--text); font-weight: 300; font-size: 30px; margin: 18px 0 8px; }
.main .placeholder img { width: 110px; border-radius: 28px; opacity: .9; }

.funnelbar { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 10px; display: flex; gap: 8px; overflow-x: auto; flex: none; align-items: center; scrollbar-width: none; }
.funnelbar::-webkit-scrollbar { display: none; }
.fbtn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px 7px 9px; border-radius: 18px; font-size: 13.5px; white-space: nowrap; background: var(--head); border: 1px solid var(--line); flex: none; }
.fbtn svg { width: 16px; height: 16px; }
.fbtn:active { transform: scale(.96); }
.fbtn.manage { color: var(--muted); }
.fbtn.stop { background: #3b1d1d; border-color: #5c2a2a; color: #ff8a80; }
.running-strip { background: #0a332c; color: var(--accent-2); font-size: 13px; padding: 6px 14px; display: flex; align-items: center; gap: 8px; flex: none; }
.running-strip .bar { flex: 1; }

.menu { position: absolute; right: 10px; top: calc(56px + var(--safe-t)); background: var(--head); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.4); padding: 8px 0; z-index: 20; min-width: 210px; }
.menu button, .menu a { display: block; width: 100%; text-align: left; padding: 11px 20px; color: var(--text); text-decoration: none; font-size: 14.5px; }
.menu button:hover, .menu a:hover { background: #ffffff0d; }
.menu .danger { color: #ff8a80; }

/* ---------- editor de funis */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 120; display: flex; justify-content: center; align-items: stretch; }
.modal { background: var(--panel); width: 100%; max-width: 640px; display: flex; flex-direction: column; }
@media (min-width: 700px) { .modal-wrap { align-items: center; padding: 30px; } .modal { max-height: 92dvh; border-radius: 12px; overflow: hidden; } }
.modal .topbar h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.modal .content { flex: 1; overflow-y: auto; padding: 16px; }
.modal .foot { padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.flist .fitem { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; background: var(--head); margin-bottom: 8px; }
.flist .fitem .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.flist .fitem .info { flex: 1; min-width: 0; }
.flist .fitem .info small { display: block; color: var(--muted); font-size: 12.5px; }
.step { background: var(--head); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.step .row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.step .num { width: 24px; height: 24px; border-radius: 50%; background: var(--input); display: grid; place-items: center; font-size: 12px; color: var(--muted); flex: none; }
.step select, .step .delay { background: var(--input); border: 0; border-radius: 8px; padding: 8px; outline: none; }
.step .delay { width: 64px; text-align: center; }
.step .sp { flex: 1; }
.step textarea { width: 100%; min-height: 70px; resize: vertical; }
.step .media { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.step .media img { max-height: 90px; border-radius: 6px; }
.step .media audio { height: 36px; max-width: 100%; }
.step .icon-btn { width: 34px; height: 34px; }
.step .icon-btn svg { width: 20px; height: 20px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; }
.colors button.on { border-color: #fff; }
.setting-row { display: flex; align-items: center; gap: 10px; background: var(--head); padding: 12px; border-radius: 10px; margin-bottom: 14px; }
.setting-row span { flex: 1; font-size: 14px; }
.setting-row select { background: var(--input); border: 0; border-radius: 8px; padding: 8px; max-width: 55%; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at top, #1d2b33, var(--bg) 70%); }
.login .card { width: 100%; max-width: 360px; text-align: center; }
.login img { width: 80px; border-radius: 20px; margin-bottom: 14px; }
.login h1 { font-size: 22px; font-weight: 600; margin: 0 0 22px; }
.login .btn { margin-top: 14px; }

/* responsivo: no celular uma tela de cada vez */
@media (max-width: 860px) {
  .side { width: 100%; border-right: 0; }
  .main { position: fixed; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .22s ease; background: var(--bg); }
  .admin.chat-open .main { transform: none; }
  .main .placeholder { display: none; }
}
@media (min-width: 861px) { .only-mobile { display: none !important; } }

/* ---------- tela de instalação obrigatória */
.gate h1 { font-size: 22px; line-height: 1.3; }
.perks { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 0 0 24px; }
.perks span { background: #ffffff0f; border: 1px solid var(--line); border-radius: 16px; padding: 5px 12px; font-size: 13px; color: var(--text); }
.gate .btn.big { padding: 16px 18px; font-size: 16px; }
.gate .btn.big svg { width: 22px; height: 22px; }
.gate .hint { text-align: center; margin-top: 12px; font-size: 13.5px; }
.gsteps { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 10px; }
.gsteps li { display: flex; align-items: center; gap: 12px; background: var(--head); border-radius: 12px; padding: 12px 14px; font-size: 15px; text-align: left; }
.gsteps li i { font-style: normal; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #111b21; font-weight: 700; display: grid; place-items: center; flex: none; font-size: 13px; }
.gsteps li span { flex: 1; }
.gsteps li svg { width: 22px; height: 22px; color: #53bdeb; flex: none; }
.gate .done { text-align: center; }
.gate .done .big-ico { font-size: 44px; margin-bottom: 8px; }
.gate .arrow-down { position: fixed; bottom: calc(8px + var(--safe-b)); left: 50%; transform: translateX(-50%); font-size: 30px; animation: bounce 1.2s infinite; color: var(--accent-2); }
@keyframes bounce { 50% { transform: translate(-50%, 8px); } }
.gate .linkbox { display: flex; gap: 8px; margin-top: 14px; }
.gate .linkbox input { flex: 1; font-size: 13px; color: var(--muted); }
.btn { text-decoration: none; }

/* ---------- foto do lead */
.pick-photo { display: flex; align-items: center; gap: 16px; margin: 4px 0 6px; }
.photo-circle { width: 76px; height: 76px; border-radius: 50%; background: var(--head); border: 2px dashed var(--line); display: grid; place-items: center; overflow: hidden; flex: none; position: relative; }
.photo-circle .cam { width: 30px; height: 30px; color: var(--muted); }
.photo-circle img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-circle.has { border: 2px solid var(--accent); }
.pick-txt { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.pick-txt b { font-weight: 500; }
.pick-txt small { color: var(--muted); font-size: 13px; }
.link { color: #ff8a80; font-size: 13px; padding: 4px 0 0; }
.avatar img { cursor: zoom-in; }

/* ---------- atendente / etiquetas */
.agent-mini { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--accent-2); }
.welcome .online b { color: var(--text); font-weight: 500; }
.tagsbar { display: flex; gap: 6px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; align-items: center; scrollbar-width: none; }
.tagsbar::-webkit-scrollbar { display: none; }
.tg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 12px; white-space: nowrap; font-weight: 500; flex: none; }
.tg::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tg.add { color: var(--muted); border: 1px dashed var(--line); }
.tg.add::before { display: none; }
.conv .r3 { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.conv .r3 .tg { font-size: 11px; padding: 1px 7px; }
.chip.tagchip { display: inline-flex; align-items: center; gap: 6px; }
.chip.tagchip i { width: 8px; height: 8px; border-radius: 50%; }
.chips .sep { width: 1px; background: var(--line); flex: none; margin: 4px 2px; }
.tagpick { display: flex; flex-direction: column; gap: 8px; }
.tagpick label { display: flex; align-items: center; gap: 12px; background: var(--head); padding: 12px 14px; border-radius: 10px; cursor: pointer; }
.tagpick label span { flex: 1; }
.tagpick input { width: 20px; height: 20px; accent-color: var(--accent); }
.tagpick .dot, .tagedit .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.tagedit { display: flex; align-items: center; gap: 10px; background: var(--head); padding: 8px 8px 8px 14px; border-radius: 10px; margin-bottom: 8px; }
.tagedit input.field { flex: 1; padding: 8px 10px; }
.tagedit .colors button { width: 22px; height: 22px; }
.profile-edit { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0; }
.profile-edit .photo-circle { width: 110px; height: 110px; }
.preview-top { display: flex; align-items: center; gap: 12px; background: var(--head); border-radius: 12px; padding: 10px 14px; width: 100%; margin-top: 14px; }
.preview-top .avatar img { cursor: default; }
.audio-fail { display: block; padding: 8px 4px; color: #53bdeb; text-decoration: none; }
