:root { --g: #128c7e; --line: #dfe5ea; --mut: #6b7785; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, sans-serif; color: #1f2933; background: #f6f8fa; }
header { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px 0; }
h1 { margin: 0 0 8px; font-size: 18px; color: var(--g); }
h2 { font-size: 16px; margin: 0 0 8px; } h3 { font-size: 14px; margin: 16px 0 6px; }
nav { display: flex; gap: 4px; }
.tab { border: 0; background: none; padding: 10px 14px; cursor: pointer; font: inherit; border-bottom: 3px solid transparent; color: var(--mut); }
.tab.active { color: var(--g); border-color: var(--g); font-weight: 600; }
main { max-width: 980px; margin: 0 auto; padding: 20px 24px 60px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
label.big { font-size: 15px; margin-top: 4px; }
label.switch { padding: 12px; border: 2px solid var(--g); border-radius: 10px; background: #f0faf8; align-items: center; }
[hidden] { display: none !important; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px; border: 1px solid #c4ccd4; border-radius: 6px; font: inherit; background: #fff;
}
textarea { resize: vertical; margin-top: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 16px 0; }
.inline { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
button { padding: 8px 14px; border: 1px solid #c4ccd4; border-radius: 6px; background: #f4f6f8; cursor: pointer; font: inherit; white-space: nowrap; }
button.primary { background: #25d366; border-color: #25d366; color: #fff; font-weight: 600; }
button.danger { color: #c0392b; }
button:disabled { opacity: .5; cursor: default; }
.hint { color: var(--mut); font-size: 12px; } .ok { color: #1e8e3e; font-weight: 600; } .err { color: #c0392b; }
.badge { background: #c0392b; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; }
details { margin: 12px 0; }
summary { cursor: pointer; font-weight: 600; }

#chat { margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 12px; border-radius: 10px; max-width: 85%; white-space: pre-wrap; }
.msg.user { background: #dcf8c6; align-self: flex-end; }
.msg.ai { background: #f1f3f5; align-self: flex-start; }
.msg ul { margin: 6px 0 0 18px; padding: 0; }
.profile { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 8px 0 12px; background: #fafbfc; }
.profile dt { font-weight: 600; margin-top: 8px; } .profile dd { margin: 2px 0 0; }

.split { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
#convoList { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow: auto; }
#convoList li { padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
#convoList li.sel { border-color: var(--g); background: #f0faf8; }
#convoList .top { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; }
#convoList .snip { color: var(--mut); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #e8f5e9; color: #1e8e3e; font-weight: 600; }
.chip.handoff { background: #fff4e0; color: #b26a00; } .chip.goal { background: #e3f2fd; color: #1565c0; }
.chip.optout { background: #fdecea; color: #c0392b; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c0392b; display: inline-block; margin-right: 4px; }
.thread { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow: auto; padding: 8px; background: #efeae2; border-radius: 8px; margin: 10px 0; }
.bubble { padding: 6px 10px; border-radius: 8px; max-width: 80%; white-space: pre-wrap; }
.bubble.in { background: #fff; align-self: flex-start; } .bubble.out { background: #d9fdd3; align-self: flex-end; }
.bubble small { display: block; color: var(--mut); font-size: 10px; }
.box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 10px 0; background: #fafbfc; }
.box.draft { border-color: #25d366; background: #f0fbf4; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } .grid3 { grid-template-columns: 1fr; } }

/* login pelo QR (painel web) */
.loginOverlay { position: fixed; inset: 0; background: rgba(15, 30, 28, .72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.loginCard { background: #fff; border-radius: 14px; padding: 24px 28px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.loginCard h2 { margin: 0 0 8px; color: var(--g); }
.loginCard ol { text-align: left; margin: 8px auto 12px; padding-left: 20px; max-width: 320px; font-size: 14px; }
.qrBox { width: 300px; height: 300px; max-width: 100%; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fafbfc; }
.qrBox img { width: 100%; height: 100%; border-radius: 10px; }
.qrWait { color: var(--mut); padding: 16px; }
.qrMsg { min-height: 20px; margin: 8px 0; }
.small { font-size: 11px; margin-top: 12px; }
.loginCard button { margin: 4px; }
.waRow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.dot2 { width: 10px; height: 10px; border-radius: 50%; background: #c4ccd4; display: inline-block; }
.dot2.on { background: #25d366; } .dot2.off { background: #c0392b; } .dot2.mid { background: #f0a500; }

.locked main, .locked header nav { visibility: hidden; }

/* tela de conversas estilo WhatsApp Web */
.waPanel { padding: 0; overflow: hidden; }
.waApp { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 150px); min-height: 480px; }
.waList { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: #fff; }
.waListHead { padding: 10px; border-bottom: 1px solid var(--line); }
.waListHead input { width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: #f0f2f5; font: inherit; }
#convoList { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; max-height: none; border: 0; border-radius: 0; }
#convoList li { display: flex; gap: 10px; padding: 10px 12px; border: 0; border-bottom: 1px solid #f0f2f5; border-radius: 0; margin: 0; cursor: pointer; align-items: center; }
#convoList li:hover { background: #f5f6f6; }
#convoList li.sel { background: #e9edef; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.avatar.ai { background: #d9fdd3; color: #0b6b5f; }
.cMain { flex: 1; min-width: 0; }
.cTop { display: flex; justify-content: space-between; gap: 6px; }
.cTitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cTime { font-size: 11px; color: var(--mut); flex: none; }
.cSnip { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--mut); }
.cSnip span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cBadge { background: #25d366; color: #fff; border-radius: 10px; min-width: 18px; padding: 0 6px; font-size: 11px; text-align: center; line-height: 18px; flex: none; }
.cBadge.warn { background: #c0392b; }
.waEmpty { padding: 20px; text-align: center; }
.waChat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.waPlaceholder { margin: auto; color: var(--mut); }
.waHead { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #f0f2f5; border-bottom: 1px solid var(--line); }
.waHead .back { display: none; border: 0; background: none; font-size: 20px; padding: 0 6px; }
.waHead .who { flex: 1; min-width: 0; }
.waHead .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.waHead .who small { color: var(--mut); }
.waHead .aiBtn2 { padding: 6px 10px; font-size: 12px; }
.waMenu { position: relative; }
.waMenu summary { list-style: none; cursor: pointer; padding: 4px 8px; font-size: 18px; }
.waMenu summary::-webkit-details-marker { display: none; }
.waMenu .menuBox { position: absolute; right: 0; top: 28px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); z-index: 5; min-width: 220px; }
.waMenu .menuBox button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; }
.waMenu .menuBox button:hover { background: #f5f6f6; }
.waThread { flex: 1; overflow: auto; padding: 14px 8%; display: flex; flex-direction: column; gap: 4px; }
.waThread .bubble { padding: 6px 9px 4px; border-radius: 8px; max-width: 75%; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.waThread .bubble.in { background: #fff; align-self: flex-start; }
.waThread .bubble.out { background: #d9fdd3; align-self: flex-end; }
.waThread .bubble small { display: block; text-align: right; color: var(--mut); font-size: 10px; margin-top: 2px; }
.waThread .tag { font-size: 10px; font-weight: 700; margin-right: 6px; }
.waThread .tag.ia { color: #0b6b5f; } .waThread .tag.vc { color: #1565c0; } .waThread .tag.dj { color: #b26a00; }
.waDraft { margin: 0 10px 6px; padding: 10px; border-radius: 8px; background: #f0fbf4; border: 1px solid #25d366; }
.waDraft textarea { margin: 6px 0; }
.waInfo { margin: 0 10px 6px; font-size: 12px; }
.waInfo summary { cursor: pointer; color: var(--mut); }
.waInfo .box { background: #fff; }
.waComposer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px; background: #f0f2f5; }
.waComposer textarea { margin: 0; flex: 1; max-height: 120px; border-radius: 20px; padding: 9px 14px; }
.waComposer button { border-radius: 50%; width: 42px; height: 42px; padding: 0; font-size: 18px; }
.waErr { color: #c0392b; font-size: 12px; padding: 0 14px 6px; min-height: 0; }
@media (max-width: 760px) {
  .waApp { grid-template-columns: 1fr; height: calc(100vh - 130px); }
  .waApp.chatOpen .waList { display: none; }
  .waApp:not(.chatOpen) .waChat { display: none; }
  .waHead .back { display: block; }
  .waThread { padding: 12px 10px; }
}

.waBanner { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 16px; background: #fff4e0; color: #8a5200; border-bottom: 1px solid #f0d9a8; }
.waBanner[hidden] { display: none !important; }

.meter { height: 8px; background: #e8edf1; border-radius: 6px; overflow: hidden; margin: 6px 0; }
.meter div { height: 100%; width: 0; background: #25d366; transition: width .3s; }
.meter div.warn { background: #f0a500; } .meter div.bad { background: #c0392b; }
.planBanner { background: #fdecea; color: #8a1f12; border-bottom-color: #f3c3bd; }
.planBanner.soft { background: #fff4e0; color: #8a5200; border-bottom-color: #f0d9a8; }

.brandSmall { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--mut); text-transform: uppercase; margin-bottom: 4px; }
