:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #EEF0EF;
  --panel: #FFFFFF;
  --panel-2: #F2F4F3;
  --line: #E2E6E4;
  --text: #111614;
  --muted: #5F6A65;
  --green: #12805C;
  --green-dark: #12805C;
  --accent: #12805C;
  --accent-hover: #0E6B4C;
  --on-accent: #FFFFFF;
  --accent-soft: #DDF1E7;
  --accent-text: #0B5E43;
  --amber: #B86E00;
  --on-amber: #FFFFFF;
  --amber-soft: #FCEBD2;
  --amber-text: #7A4A00;
  --red: #C93A3A;
  --red-soft: #FBE3E3;
  --red-text: #8E2020;
  --blue: #2F72C9;
  --blue-soft: #E1ECFA;
  --blue-text: #1C4F91;
  --orange-soft: #FCE9DA;
  --orange-text: #8A4310;
  --violet: #7C4DCC;
  --link: #B8540C;
  --bubble-in: #FFFFFF;
  --bubble-out: #D9FDD3;
  --bubble-ai: #E3EEFB;
  --chat-bg: #EFEAE2;
  --chat-dot: rgba(17, 22, 20, .045);
  --shadow: 0 1px 2px rgba(17, 22, 20, .06), 0 8px 24px rgba(17, 22, 20, .06);
  --shadow-pop: 0 12px 40px rgba(17, 22, 20, .18);
  --scrim: rgba(17, 22, 20, .35);
  --radius: 14px;
  --radius-card: 22px;
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B100E;
  --panel: #151C19;
  --panel-2: #1E2723;
  --line: #2A3530;
  --text: #EDF3F0;
  --muted: #9BAAA3;
  --green: #3DDC97;
  --green-dark: #3DDC97;
  --accent: #3DDC97;
  --accent-hover: #5FE6AB;
  --on-accent: #06140E;
  --accent-soft: #173A2B;
  --accent-text: #7CEBB8;
  --amber: #F5B53F;
  --on-amber: #1A1200;
  --amber-soft: #3A2E12;
  --amber-text: #F7C873;
  --red: #EF5B5B;
  --red-soft: #3A1A1A;
  --red-text: #FFB4B4;
  --blue: #5AA9FF;
  --blue-soft: #172A42;
  --blue-text: #9ACBFF;
  --orange-soft: #3A2414;
  --orange-text: #FFB57A;
  --violet: #C58CFF;
  --link: #FF9F43;
  --bubble-in: #1E2723;
  --bubble-out: #0F4D36;
  --bubble-ai: #22324A;
  --chat-bg: #0E1411;
  --chat-dot: rgba(237, 243, 240, .035);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-pop: 0 16px 44px rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .55);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* "hidden" vale sempre, mesmo em quem tem display próprio */
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 14px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
label.check { flex-direction: row; align-items: center; }
label.check input { width: auto; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; }
.logo { width: 28px; height: 28px; flex: none; border-radius: 9px; display: block; }
.wordmark { font-size: 18px; letter-spacing: -0.3px; white-space: nowrap; }
.wordmark b { font-weight: 700; }
.wordmark span { color: var(--green); font-weight: 500; }
.auth-card h1 .logo { width: 38px; height: 38px; border-radius: 12px; }
.auth-card h1 .wordmark { font-size: 24px; }
.brand select { width: auto; min-width: 180px; }
.tabs { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { white-space: nowrap; }
html, body { overflow-x: hidden; }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); }
.tabs button.active { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.badge { background: var(--amber); color: var(--on-amber); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 4px; }

.autonomy { display: flex; align-items: center; gap: 8px 12px; font-size: 13px; flex-wrap: wrap; min-width: 0; }
.autonomy > * { white-space: nowrap; }
.levels { flex-wrap: wrap; }
.levels { display: flex; gap: 4px; }
.level { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.level.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.rate { padding: 4px 10px; border-radius: 999px; background: var(--panel-2); }
.rate b { color: var(--green); }
.promote { background: var(--amber); color: var(--on-amber); border-color: var(--amber); font-weight: 600; }

.banner { background: var(--amber-soft); color: var(--amber-text); padding: 8px 16px; font-size: 14px; border-bottom: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); }

main { flex: 1; min-height: 0; }
.tab { display: none; height: 100%; }
.tab.active { display: flex; }
#tab-conversas.active { display: grid; grid-template-columns: 350px minmax(0, 1fr); }
#tab-base.active, #tab-canais.active, #tab-config.active, #tab-equipe.active, #tab-vendas.active { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; padding: 20px 24px; overflow: auto; align-items: start; }
.col { min-width: 0; }

.contacts { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.contacts-head { padding: 10px; border-bottom: 1px solid var(--line); }
#contactList { list-style: none; margin: 0; padding: 0; overflow: auto; }
#contactList li { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; }
#contactList li:hover { background: var(--panel); }
#contactList li.active { background: var(--panel-2); }
#contactList .name { font-weight: 600; }
#contactList .preview { grid-column: 1 / -1; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.human { background: var(--red-soft); color: var(--red-text); }
.pill.pending { background: var(--amber-soft); color: var(--amber-text); }
.pill.unread { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.chat-head .title { font-weight: 600; }
.chat-head select { width: auto; }
.chat-head .avatar { width: 32px; height: 32px; font-size: 12px; }
.chat-who { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.chat-who .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; font-size: 15px; line-height: 1.35; }
.msg.in { background: var(--bubble-in); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--bubble-out); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.out.ia { background: var(--bubble-ai); }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
/* bolinha com as iniciais (lista de conversas, conversa aberta, equipe) */
.avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: #fff; background: hsl(var(--h, 210) 36% 34%); }
.avatar.mail { background: var(--panel-2); color: var(--muted); border: 1px dashed var(--line); font-weight: 400; font-size: 16px; }
/* lista de conversas: bolinha | nome | data, prévia | selos */
#contactList li { grid-template-columns: 38px minmax(0, 1fr) auto; column-gap: 10px; align-items: baseline; }
#contactList li.muted { display: block; }
#contactList .avatar { grid-row: 1 / span 2; align-self: center; }
#contactList .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#contactList .when { font-size: 11px; color: var(--muted); white-space: nowrap; }
#contactList .preview { grid-column: 2 !important; }
#contactList .badges { display: flex; gap: 4px; justify-content: flex-end; }
#contactList li.is-unread .name { color: var(--text); }
#contactList li.is-unread .when { color: var(--green); font-weight: 600; }
#contactList li.is-unread .preview { color: var(--text); }
#contactList .preview.found { color: var(--text); }

/* ---- login, convite, senha nova ---- */
.auth-page { display: grid; place-items: center; min-height: 100vh; margin: 0; padding: 16px; box-sizing: border-box; }
.auth-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; box-sizing: border-box; }
.auth-card h1 { font-size: 20px; margin: 0; display: flex; align-items: center; gap: 8px; }
.auth-card p { margin: 0; }
.auth-card input { width: 100%; box-sizing: border-box; }
.auth-card .err { color: var(--red); font-size: 14px; min-height: 20px; }
.auth-card[hidden] { display: none; }

/* ---- conta ---- */
.user-menu { position: relative; margin-left: 8px; }
#userBtn { width: 34px; height: 34px; border-radius: 50%; padding: 0; font-weight: 700; }
.user-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-pop); }
.user-pop[hidden], .user-menu[hidden], .tabs button[hidden] { display: none; }
.user-pop .who { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-pop button { text-align: left; }
#pwDialog form { min-width: min(360px, 80vw); }

/* ---- equipe ---- */
.people { list-style: none; margin: 12px 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.person { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 10px 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.person .who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person .name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.person .name b, .person .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.person .controls { grid-column: 2; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.person .controls select { width: auto; min-width: 130px; padding: 6px 8px; }
.person.invite { border-style: dashed; }
button.danger { color: var(--red); }
.invite-link { margin: 14px 0; padding: 12px; border: 1px solid var(--green, #2fb37a); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; scroll-margin: 12px; }
.invite-link p { margin: 0; }
.invite-link .link-row { display: flex; gap: 8px; }
.invite-link .link-row input { flex: 1; min-width: 0; }
.empty-ws { max-width: 520px; margin: 80px auto; text-align: center; padding: 0 16px; }
#contactList .preview mark, .msg mark { background: color-mix(in srgb, var(--amber) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.msg.found-flash { outline: 2px solid var(--amber); outline-offset: 2px; transition: outline-color .4s; }
.list-filter { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.list-filter .chip { padding: 3px 10px; font-size: 12px; }

/* reações */
.msg { position: relative; }
.react-badge { position: absolute; bottom: -10px; right: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; font-size: 13px; line-height: 20px; }
.msg.in:has(.react-badge) { margin-bottom: 10px; }
.react-bar { display: none; position: absolute; top: -16px; right: -4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px; box-shadow: var(--shadow); z-index: 2; white-space: nowrap; }
.msg.in:hover .react-bar { display: inline-flex; }
.react-bar button { background: transparent; border: 0; padding: 2px 4px; font-size: 16px; line-height: 1; border-radius: 999px; }
.react-bar button:hover, .react-bar button.on { background: var(--line); }
.phone { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 400; }
.phone.small { font-size: 12px; }

/* mídia e links dentro das mensagens */
.msg a { color: var(--link); word-break: break-all; }
.msg .msg-text { white-space: pre-wrap; }
.media-img { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 8px; margin-bottom: 4px; background: var(--panel-2); }
.media-img.sticker { max-width: 140px; background: transparent; }
.media-audio { width: min(280px, 100%); height: 40px; display: block; margin: 2px 0 4px; }
.media-video { display: block; max-width: min(300px, 100%); max-height: 320px; border-radius: 8px; margin-bottom: 4px; background: #000; }
.media-doc { display: inline-block; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--text) 7%, transparent); margin-bottom: 4px; text-decoration: none; }
.media-img { cursor: zoom-in; }
/* áudio no estilo WhatsApp */
.wa-audio { display: flex; align-items: center; gap: 10px; width: min(300px, 100%); padding: 4px 2px 6px; }
.wa-play { width: 38px; height: 38px; border-radius: 50%; padding: 0; flex-shrink: 0; background: var(--accent); border: 0; color: var(--on-accent); font-size: 14px; display: grid; place-items: center; }
.wa-play:hover { background: var(--accent-hover); color: var(--on-accent); }
.wa-track { position: relative; flex: 1; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 22%, transparent); cursor: pointer; }
.wa-track::before { content: ""; position: absolute; inset: -8px 0; } /* área de clique maior */
.wa-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px; background: var(--green); }
.wa-dot { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--green); }
.wa-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; }
.wa-speed { padding: 2px 7px; font-size: 11px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); border: 0; min-width: 36px; }
.wa-audio audio { display: none; }
/* imagem ampliada */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 85vh; border-radius: 8px; cursor: default; }
.lb-open { color: var(--muted); font-size: 13px; }
.media-pending { font-size: 13px; color: var(--muted); padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, var(--text) 6%, transparent); margin-bottom: 4px; }
.media-missing { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 4px; }
.og:empty { display: none; }
.og-card { display: flex; gap: 10px; margin-top: 6px; padding: 8px; border-radius: 8px; background: color-mix(in srgb, var(--text) 6%, transparent); border-left: 3px solid var(--green); text-decoration: none; color: var(--text) !important; word-break: normal !important; max-width: 340px; }
.og-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.og-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.og-body b { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.og-site { font-size: 11px; color: var(--muted); text-transform: lowercase; }
.og-desc { color: var(--muted); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg.msg-failed { border: 1px solid var(--red); background: var(--red-soft); }
.msg .failed { color: var(--red); }
.msg .sending { color: var(--amber); }
.msg .meta button { margin-left: 6px; padding: 2px 8px; font-size: 11px; }
.msg.shadow { align-self: flex-end; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.msg.shadow .score { color: var(--amber); }

.suggestion { margin: 0 16px 8px; border: 1px solid var(--amber); border-radius: var(--radius); background: var(--panel); padding: 12px 14px; }
.suggestion.scheduled { border-color: var(--blue); }
.suggestion .head { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.suggestion .conf { font-weight: 700; color: var(--amber); }
.suggestion .conf.high { color: var(--green); }
.suggestion .conf.low { color: var(--red); }
.suggestion textarea { background: var(--panel); min-height: 64px; }
.suggestion .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.suggestion .reason { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.suggestion .ask { margin: 0 0 8px; font-size: 15px; color: var(--amber); }
.platform-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); font-size: 14px; }
.platform-action label { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; font-weight: 600; font-size: 14px; color: var(--text, inherit); cursor: pointer; white-space: nowrap; }
.platform-action input { flex: none; width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--amber); cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }

.keybox { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--panel); transition: border-color .2s, background .2s; margin-bottom: 8px; }
.keybox .keyrow { display: flex; gap: 10px; align-items: center; }
.keybox input { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; }
.keyicon { font-size: 22px; width: 28px; text-align: center; flex-shrink: 0; }
.keymsg { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.keymsg a { color: var(--link); }
.keybox.checking { border-color: var(--amber); }
.keybox.checking .keyicon::after { content: "⏳"; }
.keybox.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 8%, transparent); }
.keybox.ok input { border-color: var(--green); }
.keybox.ok .keyicon { color: var(--green); }
.keybox.ok .keyicon::after { content: "✓"; font-weight: 700; }
.keybox.ok .keymsg { color: var(--green); }
.keybox.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); }
.keybox.bad .keyicon { color: var(--red); }
.keybox.bad .keyicon::after { content: "✕"; font-weight: 700; }
.keybox.bad .keymsg { color: var(--red); }

/* ---------- métricas ---------- */
#tab-metricas.active { display: flex; justify-content: center; overflow: auto; padding: 20px 16px; }
.metrics { width: min(1000px, 100%); }
.m-head { display: flex; align-items: baseline; gap: 12px; }
.m-head h2 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 14px 0; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 28px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile.warn .value { color: var(--amber); }
.m-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; position: relative; }
.card h3 { margin: 0 0 12px; font-size: 14px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; border-bottom: 1px solid var(--line); padding-top: 18px; }
.bars .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; }
.bars .bar { width: 100%; max-width: 26px; background: var(--green-dark); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .col:hover .bar { background: var(--green); }
.bars .bar.empty { background: var(--panel-2); }
.bars.short { height: 110px; }
.bars.vol .bar { background: color-mix(in srgb, var(--blue) 70%, var(--panel)); }
.bars.vol .col:hover .bar, .bars.vol .col.hl .bar { background: var(--blue); }
.bars .col.hl .bar { background: var(--green); }
.bars .bar.empty, .bars.vol .bar.empty { background: var(--panel-2); }
.chart-sub { margin: 14px 0 0; font-size: 13px; font-weight: 600; }
.chart-sub .muted { font-weight: 400; margin-left: 4px; }
.bars .x { font-size: 10px; color: var(--muted); margin-top: 4px; height: 12px; }
.bars-x { display: flex; gap: 6px; }
.bars-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }
.tip { position: absolute; pointer-events: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow-pop); }
.m-table summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 10px; }
.m-table table, table.split { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.m-table td, .m-table th, table.split td, table.split th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
.m-table th, table.split th { color: var(--muted); font-weight: 500; }
.rt-pill { padding: 4px 10px; border-radius: 999px; background: var(--panel-2); font-size: 13px; cursor: pointer; }
.rt-pill b { color: var(--text); }
@media (max-width: 900px) { .m-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- layout compacto: a conversa ocupa a tela ---------- */
html, body { height: 100%; }
body { overflow: hidden; }
.topbar { flex-wrap: nowrap; gap: 10px; padding: 6px 12px; min-height: 0; }
.brand select { min-width: 0; max-width: 170px; padding: 6px 8px; }
.topbar .tabs { margin-left: 0; flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.topbar .tabs::-webkit-scrollbar { display: none; }
.topbar .tabs button { padding: 6px 10px; }
.topbar .autonomy { flex-wrap: nowrap; flex-shrink: 0; gap: 6px; }
.topbar .level, .topbar .rate, .rt-pill { padding: 3px 9px; font-size: 12px; }
main { min-height: 0; overflow: hidden; }
.tab.active { height: 100%; }
#tab-base.active, #tab-canais.active, #tab-config.active, #tab-equipe.active, #tab-metricas.active, #tab-vendas.active { overflow: auto; }
@media (max-width: 600px) {
  .topbar .rate { display: none; }
}

/* Fila: cabeçalho fino, mensagens ocupam o meio, resposta fixa embaixo */
#tab-fila.active { padding: 0 !important; overflow: hidden !important; }
.queue { height: 100%; padding: 8px 12px; gap: 8px; min-height: 0; }
.q-head { flex-shrink: 0; gap: 8px; }
.q-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-messages { flex: 1; min-height: 80px; max-height: none !important; }
.q-answer, .suggestion { flex-shrink: 0; }
.suggestion { padding: 10px 12px; margin: 0 12px 8px; }
.q-answer.suggestion { margin: 0; }
.suggestion .head { margin-bottom: 6px; }
.suggestion textarea { min-height: 52px; max-height: 30vh; }
.suggestion .reason { font-size: 12px; margin: 4px 0 0; max-height: 3.2em; overflow: hidden; }
.suggestion .actions { margin-top: 6px; }
.q-empty { margin: auto; }
.q-note { flex-shrink: 0; font-size: 13px; color: var(--amber-text); padding: 6px 10px; border-radius: 10px; background: var(--amber-soft); }
.q-note[hidden] { display: none; }

/* Conversas: cabeçalho da conversa fino */
.chat-head { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
.chat-head select { padding: 5px 8px; font-size: 13px; max-width: 100%; }
.composer { padding: 8px 12px; }
.composer[hidden] { display: none; }
.composer textarea { min-height: 40px; }
.messages { padding: 12px; }
.banner { padding: 6px 12px; font-size: 13px; }
.banner a { color: var(--amber); font-weight: 600; }
.banner.wa-down { background: var(--red-soft); color: var(--red-text); border-bottom-color: var(--red); font-size: 14px; }
.banner.wa-down a { color: var(--red-text); text-decoration: underline; }

#tab-fila.active { display: flex; justify-content: center; overflow: auto; padding: 20px 16px; }
.queue { width: min(760px, 100%); display: flex; flex-direction: column; gap: 12px; }
.q-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.q-head .q-count { margin-left: auto; }
.q-btns { display: flex; align-items: center; gap: 8px; }
.q-messages { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow: auto; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.q-answer { margin: 0; }
.q-empty { text-align: center; padding: 60px 20px; }
.q-empty .big { font-size: 42px; color: var(--green); }
.q-empty h3 { margin: 8px 0; }
.composer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; }

.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cards li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.cards.compact li { padding: 8px 12px; font-size: 13px; }
.cards .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); }
.cards .kind.regra { color: var(--amber); }
.cards .kind.estilo { color: var(--violet); }
.cards .text { margin: 6px 0; white-space: pre-wrap; }
.cards .src { color: var(--muted); font-size: 12px; }
.cards .actions { display: flex; gap: 6px; margin-top: 8px; }
.cards .q { color: var(--muted); }
.cards .a { margin-top: 4px; }
.filters { display: flex; gap: 6px; margin-bottom: 10px; }
.chip { border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.status { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.status.conectado { background: var(--green); }
.status.aguardando_qr, .status.conectando { background: var(--amber); }
#qrImage { width: 320px; max-width: 100%; background: #fff; padding: 10px; border-radius: 10px; }
.how li { margin-bottom: 8px; }
.importing { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--green-dark); font-size: 14px; }
.importing[hidden] { display: none; }
.importing .imp-body { flex: 1; min-width: 0; }
.importing .imp-text { margin-bottom: 6px; }
.importing.done { background: var(--panel); border-bottom-color: var(--green); }
.importing.empty { background: var(--amber-soft); border-bottom-color: var(--amber); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--green) 25%, transparent); border-top-color: var(--green); animation: spin .8s linear infinite; flex-shrink: 0; }
.importing.done .spinner, .importing.empty .spinner { animation: none; border-color: var(--green); }
.importing.empty .spinner { border-color: var(--amber); }
@keyframes spin { to { transform: rotate(360deg); } }
.importing .qrbar span.indeterminate { width: 35% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.qrtimer { width: 320px; max-width: 100%; margin-top: 10px; }
.qrbar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.qrbar span { display: block; height: 100%; background: var(--green); transition: width 1s linear, background .3s; }
.qrbar span.low { background: var(--amber); }
.qrtimer p { margin: 6px 0 0; font-size: 14px; }
#qrImage.refreshing { opacity: .25; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(520px, 92vw); }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 6px; }
dialog textarea { margin: 10px 0 14px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 8px; max-width: 360px; font-size: 14px; box-shadow: var(--shadow-pop); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }

.back-btn { display: none; }
@media (max-width: 900px) {
  /* Tela estreita: lista de conversas primeiro; ao abrir uma, mostra só o chat com botão de voltar. */
  #tab-conversas.active { grid-template-columns: minmax(0, 1fr); }
  #tab-conversas .chat { display: none; }
  #tab-conversas.chat-open .contacts { display: none; }
  #tab-conversas.chat-open .chat { display: flex; }
  .back-btn { display: inline-block; }
  #tab-base.active, #tab-canais.active, #tab-config.active, #tab-equipe.active, #tab-vendas.active { grid-template-columns: minmax(0, 1fr); }
  .tabs { margin-left: 0; }
}

/* Respondidas pela IA */
#tab-ia.active { display: flex; justify-content: center; overflow: auto; padding: 20px 16px; }
#tab-ia .col.wide { width: 100%; max-width: 820px; }
.cards.auto .auto-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.cards.auto .auto-head .src { margin-left: auto; }
.cards.auto .a, .cards.auto .q { white-space: pre-wrap; }
.cards.auto li.flagged { border-color: var(--red); }


/* O que a IA já domina */
.mastery-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cards.mastery li { border-left: 3px solid var(--green); }
.cards.mastery .topic { font-weight: 600; }
.cards.mastery .hits { color: var(--green); font-size: 12px; margin-left: 6px; }
.learning { margin: 10px 0 18px; }
.learning summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.learning .cards li { border-left: 3px solid var(--amber); }

/* Quem respondeu */
.who-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.who-head h3 { margin: 0; }
.who-head .filters { margin: 0; }
.stack-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--panel-2); margin-bottom: 12px; gap: 2px; }
.stack-bar span { display: block; height: 100%; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.who-sozinha { background: var(--green); }
.who-aprovada { background: var(--blue); }
.who-ajustada { background: var(--amber); }
.who-naoSabia { background: var(--muted); }
.who-sozinhaErro { background: var(--red); }
/* ---------- peças que só aparecem no celular ---------- */
.ic { display: none; width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs-more { display: contents; } /* no computador os botões ficam soltos na mesma linha */
.tabs .more-btn, .only-mobile, .lbl-short, .q-pos, .chat-more { display: none; }
.q-who .phone + .q-wait::before { content: "· "; }
.autonomy .k, #userBtn .uname { display: none; } /* rótulos que só o menu lateral do computador mostra */
.content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* ---------- acabamento geral ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
button, input, select, textarea { transition: border-color .15s, background-color .15s, color .15s; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--green) 65%, transparent); outline-offset: 1px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-dark); }
#contactList li.active { box-shadow: inset 3px 0 0 var(--green); }
.avatar.anon { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.avatar .ic { display: block; width: 55%; height: 55%; }
.composer textarea { resize: none; }
.composer button { align-self: flex-end; }
#channelForm { margin-top: 10px; }
#wsNameForm { margin-bottom: 22px; }
.row > button { white-space: nowrap; flex-shrink: 0; }
.tab .row + label.check { margin-top: 12px; }
.user-pop .who .pill { align-self: flex-start; }
input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--green); }
input[type="checkbox"] { accent-color: var(--green); flex-shrink: 0; }

/* login, convite e senha nova: a página rola (teclado do celular aberto não corta o formulário) */
body.auth-page { height: auto; min-height: 100vh; min-height: 100dvh; overflow: auto; }
.auth-card button { min-height: 44px; }

/* altura real da tela no celular (desconta as barras do navegador) */
@supports (height: 100dvh) { html, body { height: 100dvh; } }

/* =====================================================================
   CELULAR (até 760px): topo enxuto, navegação embaixo, tudo em uma coluna
   ===================================================================== */
@media (max-width: 760px) {
  :root { --nav-h: 60px; --safe-b: env(safe-area-inset-bottom, 0px); }

  /* Menos que 16px o iPhone dá zoom sozinho ao tocar no campo. */
  input, select, textarea, .chat-head select { font-size: 16px; }
  .only-mobile { display: block; }

  /* Botões no tamanho do dedo. */
  .stack > button, .row > button, .suggestion .actions button, .composer button, dialog button, .invite-link button { min-height: 44px; }
  .cards .actions button, .person .controls button, .person .controls select, .q-btns button, .chat-tools button, .user-pop button { min-height: 36px; }
  .chip { min-height: 34px; padding: 4px 14px; }

  /* ---- topo: workspace, nível, tempo de resposta e conta ---- */
  .topbar { flex-wrap: nowrap; gap: 8px; row-gap: 0; padding: 6px 10px 6px 12px; }
  .brand { flex: 1; min-width: 0; gap: 4px; }
  .brand select { flex: 1; min-width: 0; max-width: none; padding: 6px 4px; border-color: transparent; background-color: transparent; font-weight: 600; text-overflow: ellipsis; }
  .topbar:has(.user-menu:not([hidden])) #newWorkspaceBtn { display: none; } /* vai para o menu da conta */
  .topbar .autonomy { margin-left: 0; gap: 6px; }
  .topbar .rate, .rt-wait, .lbl-long { display: none; }
  .lbl-short, .q-pos { display: inline; }

  /* aviso de WhatsApp fora do ar: uma linha só */
  .banner.wa-down { display: flex; align-items: center; gap: 10px; padding: 6px 12px; font-size: 13px; }
  .wa-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .banner.wa-down a { flex: none; white-space: nowrap; }
  .user-menu { margin-left: 0; }
  #userBtn { width: 36px; height: 36px; }
  .user-pop { min-width: 240px; padding: 14px; gap: 8px; }

  /* ---- navegação embaixo ---- */
  .topbar .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; order: 0; flex: none; height: calc(var(--nav-h) + var(--safe-b)); margin: 0; padding: 0 4px var(--safe-b); gap: 0; align-items: stretch; overflow: visible; background: var(--panel); border-top: 1px solid var(--line); }
  .tabs .ic { display: block; }
  .topbar .tabs > button { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 500; }
  .topbar .tabs > button.active { background: transparent; color: var(--green); }
  .topbar .tabs > button[hidden] { display: none; }
  .tabs > button .badge { position: absolute; top: 5px; left: calc(50% + 4px); margin: 0; min-width: 18px; padding: 0 5px; line-height: 18px; font-size: 11px; text-align: center; }
  main { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }

  /* menu "Mais": abas de admin numa folha acima da barra */
  .tabs-more { display: none; position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 2; flex-direction: column; gap: 2px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop); }
  .tabs.more-open .tabs-more { display: flex; }
  .tabs.more-open::before { content: ""; position: fixed; inset: 0 0 calc(var(--nav-h) + var(--safe-b)) 0; background: var(--scrim); }
  .topbar .tabs-more button { display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 16px; text-align: left; }
  .topbar .tabs-more button.active { background: var(--panel-2); color: var(--green); }
  .topbar .tabs-more button[hidden] { display: none; }
  .tabs-more .badge { margin-left: auto; }

  /* ---- Fila ---- */
  /* Tudo em volta fica enxuto para a conversa do cliente ocupar o máximo da tela. */
  .queue { padding: 6px 8px 8px; gap: 6px; }
  /* cliente em uma linha: bolinha | nome + espera | botões */
  .q-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 8px; }
  .q-head .avatar { width: 34px; height: 34px; font-size: 12px; }
  .q-who { white-space: normal; line-height: 1.25; }
  .q-who b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .q-who .phone, .q-head .q-count { display: none; } /* o telefone está em "Conversa"; a posição vai ao lado da espera */
  .q-who .phone + .q-wait::before { content: none; }
  .q-btns { flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 176px; }
  .q-btns #qOld { order: 3; flex: 1 1 100%; }
  .q-messages { padding: 8px; }
  .msg { max-width: 88%; }
  /* caixa de resposta: campo do tamanho do texto, motivo em uma linha, botões em uma fileira */
  .suggestion { padding: 8px 10px 10px; }
  .suggestion .head { margin-bottom: 4px; gap: 8px; font-size: 12px; }
  .suggestion textarea { min-height: 44px; max-height: 30vh; padding: 9px 11px; resize: none; }
  .suggestion .ask { margin-bottom: 6px; font-size: 14px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .suggestion .ask.open { display: block; }
  .suggestion .reason { margin: 4px 0 0; max-height: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .suggestion .reason.open { white-space: normal; }
  .suggestion .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .suggestion .actions button { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .suggestion .actions [data-act="thumb"] { order: 1; flex: none; min-width: 46px; font-size: 18px; }
  .suggestion .actions [data-act="discard"] { order: 2; flex: none; }
  .suggestion .actions .primary { order: 3; flex: 1 1 0; min-width: 0; font-size: 15px; }
  .suggestion .actions [data-act="cancel"] { order: 4; flex: 1 1 100%; }
  .platform-action { padding: 8px 10px; margin-bottom: 8px; }
  .platform-action label { white-space: normal; }

  /* ---- Conversas: lista em tela cheia; conversa aberta toma a tela toda ---- */
  .contacts { border-right: 0; }
  .contacts-head { padding: 10px 12px; }
  .list-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .list-filter::-webkit-scrollbar { display: none; }
  .list-filter .chip { flex-shrink: 0; padding: 4px 14px; font-size: 13px; }
  #contactList li { padding: 12px 14px; }
  #contactList .name { font-size: 16px; }
  #contactList .name .phone { display: none; } /* o nome ganha a linha inteira; o telefone aparece ao abrir */
  body:has(#tab-conversas.active.chat-open) .topbar { display: none; }
  body:has(#tab-conversas.active.chat-open) main { padding-bottom: 0; }
  .chat-head { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; background: var(--panel); }
  .back-btn, .chat-more { display: inline-block; min-width: 40px; min-height: 40px; padding: 0 8px; border: 0; font-size: 22px; line-height: 1; }
  .back-btn .lbl { display: none; }
  .chat-who { flex: 1; flex-direction: column; align-items: flex-start; gap: 0; }
  .chat-who .title { max-width: 100%; }
  .chat-tools { display: none; flex-basis: 100%; margin: 0; }
  .chat-head.tools-open .chat-tools { display: flex; }
  .chat-tools select { flex: 1; min-width: 0; }
  .messages { padding: 10px; }
  #tab-conversas .suggestion { margin: 0 8px calc(8px + var(--safe-b)); }
  .composer { gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); }
  .composer textarea { min-height: 44px; }

  /* ---- Métricas ---- */
  #tab-metricas.active { padding: 14px 12px 24px; }
  .m-head { flex-wrap: wrap; gap: 2px 12px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile .value { font-size: 22px; }
  .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .bars, .bars-x { gap: 3px; }

  /* ---- Base, Números, Equipe, Configurações: uma coluna ---- */
  #tab-base.active, #tab-canais.active, #tab-config.active, #tab-equipe.active { gap: 22px; padding: 16px 12px 28px; }
  .tab .row { flex-wrap: wrap; }
  .tab .row > input { flex: 1 1 100%; }
  .tab .row > button { flex: 1 1 auto; }
  .row.calibrate > span { flex-basis: 100%; }
  .filters, .cards .actions { flex-wrap: wrap; }
  #qrCol { text-align: center; }
  #qrImage, .qrtimer { width: 100%; max-width: 320px; margin-left: auto; margin-right: auto; }
  .person .controls { grid-column: 1 / -1; }
  .person .controls select { flex: 1 1 130px; }
  .person .controls button { flex: 1 1 auto; }

  /* ---- avisos e janelas ---- */
  #toasts { left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); }
  .toast { max-width: none; }
  dialog { width: calc(100vw - 24px); padding: 18px 16px; }
  dialog .row.end button { flex: 1; }
  #pwDialog form { min-width: 0; }
  .auth-card { padding: 24px 18px; }
  .auth-card input { padding: 12px; }
}

/* =====================================================================
   COMPUTADOR (a partir de 761px): menu lateral + área de trabalho
   ===================================================================== */
@media (min-width: 761px) {
  body { flex-direction: row; font-size: 15px; }

  /* ---- menu lateral: workspace, navegação, status da IA e conta ---- */
  .topbar { flex: none; width: 244px; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 18px; padding: 16px 12px 12px; border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
  .brand { gap: 8px; }
  .brand .logo { width: 30px; height: 30px; }
  .brand select { flex: 1; min-width: 0; max-width: none; padding: 8px 10px; font-weight: 600; }
  #newWorkspaceBtn { flex: none; width: 34px; height: 34px; padding: 0; font-size: 18px; line-height: 1; }

  .topbar .tabs { flex: 1 0 auto; flex-direction: column; flex-wrap: nowrap; gap: 2px; margin: 0; overflow: visible; }
  .tabs .ic { display: block; width: 18px; height: 18px; }
  .topbar .tabs button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px; font-size: 14px; font-weight: 500; text-align: left; color: var(--muted); }
  .topbar .tabs button:hover { background: color-mix(in srgb, var(--panel-2) 55%, transparent); color: var(--text); }
  .topbar .tabs button.active { background: var(--panel-2); color: var(--text); }
  .topbar .tabs button.active .ic { color: var(--green); }
  .topbar .tabs .more-btn { display: none; }
  .tabs .badge { margin-left: auto; }
  /* abas de admin: um grupo separado, com título */
  .tabs-more { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
  .tabs-more::before { content: "Gestão"; padding: 0 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); opacity: .75; }
  .tabs-more:not(:has(button:not([hidden]))) { display: none; }

  /* status da IA: um cartão com uma linha por informação */
  .topbar .autonomy { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0; margin: 0; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
  .topbar .autonomy > * { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font-size: 13px; white-space: nowrap; }
  .autonomy .k { display: inline; color: var(--muted); font-weight: 400; }
  .topbar .autonomy .rate > span { color: var(--muted); }
  .topbar .level.active { background: transparent; color: var(--green); font-weight: 600; }
  .topbar .rt-pill:hover { background: var(--panel); }
  .rt-wait { flex-basis: 100%; text-align: right; font-size: 12px; color: var(--amber); }
  .rt-wait .sep { display: none; }
  .topbar .autonomy .promote { justify-content: center; margin-top: 4px; padding: 8px; background: var(--amber); color: var(--on-amber); font-weight: 600; }

  /* conta: bolinha + nome; o menu abre para cima */
  .user-menu { margin: 0; }
  #userBtn { display: flex; align-items: center; gap: 10px; width: 100%; height: auto; padding: 6px 8px; border: 0; border-radius: 10px; text-align: left; font-weight: 600; font-size: 14px; }
  #userBtn:hover { background: var(--panel-2); }
  #userBtn .ini { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); font-size: 12px; }
  #userBtn .uname { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-pop { top: auto; bottom: calc(100% + 8px); left: 0; right: 0; min-width: 0; }

  /* ---- área de trabalho ---- */
  .banner { padding: 8px 20px; }
  #tab-conversas.active { grid-template-columns: 350px minmax(0, 1fr); }
  .queue { width: min(820px, 100%); padding: 16px; gap: 10px; }
  .q-who b { font-size: 16px; }
  #tab-metricas.active { padding: 24px; }

  /* Base, Números, Equipe e Configurações: cada coluna é um cartão; o conteúdo não estica demais em tela larga */
  #tab-base.active, #tab-canais.active, #tab-config.active, #tab-equipe.active { gap: 20px; padding: 24px max(24px, calc((100% - 1180px) / 2)); }
  .tab > .col { padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
  .tab > .col .cards li, .tab > .col .person, .tab > .col .keybox { background: var(--bg); }
  .tab > .col > :last-child { margin-bottom: 0; }
}
/* Computador estreito: menu mais fino, lista de conversas menor e seções em uma coluna. */
@media (min-width: 761px) and (max-width: 1100px) {
  .topbar { width: 208px; }
  #tab-conversas.active { grid-template-columns: 300px minmax(0, 1fr); }
  #tab-base.active, #tab-canais.active, #tab-config.active, #tab-equipe.active, #tab-vendas.active { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 761px) and (max-width: 900px) {
  #tab-conversas.active { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Conectar ao Claude ---------- */
#claudeDialog .stack { display: flex; flex-direction: column; gap: 10px; }
#claudeDialog p { margin: 0; }
.copy-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: nowrap; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.steps { margin: 4px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.conn-title { margin: 8px 0 0; font-size: 14px; }
.conn-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.conn-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.conn-list li > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.conn-list li.muted { display: block; }
/* Tela de autorização do Claude (servida pelo /oauth/authorize) */
.auth-card.consent { width: min(440px, 100%); }
.auth-card a { color: var(--green); }
.consent-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.consent-row > .muted { flex-basis: 100%; }
.consent-row select { width: 100%; }
.consent-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.consent-actions { display: flex; gap: 10px; }
.consent-actions button { flex: 1; }

/* ---------- Modelo da IA e consumo ---------- */
.models { display: grid; gap: 8px; margin-bottom: 12px; }
.model-opt {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 12px;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--panel);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.model-opt:hover { border-color: var(--muted); }
.model-opt.on { border-color: var(--green); background: color-mix(in srgb, var(--green) 7%, transparent); }
.model-opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--green); }
.model-txt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.model-price { grid-column: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; font-variant-numeric: tabular-nums; font-size: 13px; }
.usage { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px; margin-bottom: 22px; }
.usage-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 10px; }
.usage-k { color: var(--muted); font-size: 13px; }
.usage-total { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.usage-calls { color: var(--muted); font-size: 13px; white-space: nowrap; }
.usage-list { list-style: none; margin: 0; padding: 0; }
.usage-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.usage-list .u-name, .usage-list .u-val { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.usage-list .u-val { text-align: right; font-variant-numeric: tabular-nums; }
.usage-list .u-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.usage-list .u-bar span { display: block; height: 100%; border-radius: 4px; background: var(--green-dark); }
.usage-list .u-empty { display: block; padding: 12px 0 4px; }
.usage > p { margin: 8px 0 0; }
@media (max-width: 760px) {
  .usage-total { font-size: 22px; }
}

/* Texto longo nunca alarga a tela (principalmente no celular): as caixas encolhem e o texto quebra. */
.chat, .chat-head, .messages, .suggestion, .q-answer, .q-item, .contacts, .tab > *, .col, .card, .cards li { min-width: 0; }
.msg, .msg .msg-text, .suggestion .ask, .suggestion .reason, .cards .q, .cards .a, .cards .text { overflow-wrap: anywhere; }
.suggestion textarea, .composer textarea { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  /* O motivo da sugestão quebra em até 2 linhas em vez de esticar a caixa. */
  .suggestion .reason { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
}

/* Supervisor no WhatsApp */
.consult-box { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 18px; }
.consult-step { padding: 10px 12px; border-radius: 8px; background: var(--panel-2); }
.consult-step p { margin: 4px 0 8px; }
.consult-step.done { border-left: 3px solid var(--green); }
.consult-step .code { font-family: ui-monospace, monospace; font-size: 16px; font-weight: 700; color: var(--text); background: var(--bg, #000); padding: 2px 8px; border-radius: 6px; }
.consult-times label { flex: 1; min-width: 0; }
.pill.asked { background: var(--blue-soft); color: var(--blue-text); }

/* Transcrição automática de áudio */
.msg .msg-text.transcript { font-style: italic; color: color-mix(in srgb, var(--text) 85%, var(--muted)); margin-top: 4px; }

/* Inteligência artificial: provedor e chaves por workspace */
.providers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ai-keys { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 16px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.ai-key .row { margin-top: 6px; }
.ai-key .key-state.ok { color: var(--green); }
.models-title { margin: 6px 0 8px; font-size: 14px; }
.tag-cheap { display: inline-block; margin-left: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; vertical-align: middle; }

/* Tipo do workspace (suporte / vendas) */
.kind-pick .model-txt .muted { white-space: normal; }
.kind-badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-text); font-weight: 700; margin-left: 6px; vertical-align: middle; }

/* Vendas: contextos e leads */
dialog.wide { width: min(720px, calc(100vw - 32px)); }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 6px; flex-wrap: wrap; counter-reset: st; }
.steps li { counter-increment: st; font-size: 12px; color: var(--muted); padding: 4px 10px; border-radius: 999px; background: var(--panel-2); }
.steps li::before { content: counter(st) ". "; }
.steps li.on { background: var(--accent); color: var(--on-accent); }
.steps li.done { color: var(--green); }
#ctxForm fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.cards .ctx-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cards .ctx-head .src { margin-left: auto; }
.pill.ok { background: var(--accent-soft); color: var(--accent-text); }
.lead-tools { gap: 8px; margin: 8px 0; }
.lead-tools input { flex: 2; min-width: 0; } .lead-tools select { flex: 1; min-width: 0; }
.lead-add { margin: 6px 0; } .lead-add summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.cards.leads li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; }
.cards.leads .lead-meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.cards.leads select { width: auto; padding: 4px 8px; font-size: 12px; }
pre.code { background: var(--panel-2); border-radius: 8px; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
body.not-admin [data-admin-only] { display: none !important; }
#leadStages { flex-wrap: wrap; }
#ctxForm .steps { display: flex; flex-direction: row; flex-wrap: wrap; }
#ctxForm .steps li { flex: 0 0 auto; width: auto; }

/* Abordagens (templates) */
.steps-list { display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow: auto; }
.step-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 8px; }
.step-card .row { gap: 8px; flex-wrap: wrap; align-items: center; }
.step-card .row input, .step-card .row select { width: auto; }
.step-card .delay { width: 80px !important; }
.var-chip { display: inline-block; margin: 2px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; font-size: 12px; font-family: ui-monospace, monospace; }
.pill.APPROVED { background: var(--accent-soft); color: var(--accent-text); }
.pill.PENDING { background: var(--amber-soft); color: var(--amber-text); }
.pill.REJECTED, .pill.PAUSED, .pill.DISABLED { background: var(--red-soft); color: var(--red-text); }

.step-preview { font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.step-preview mark { background: color-mix(in srgb, var(--green) 25%, transparent); color: inherit; border-radius: 4px; padding: 0 3px; }
.step-preview mark.bad { background: color-mix(in srgb, var(--red) 35%, transparent); }

/* Editor de mensagem com campos (etiquetas) */
.msg-box { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.msg-box:focus-within { border-color: var(--green-dark); }
.msg-editor { min-height: 84px; padding: 10px 12px; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 15px; }
.msg-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.msg-tools { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid var(--line); }
.msg-tools .msg-count { margin-left: auto; }
.var-pill { display: inline-block; padding: 0 8px; margin: 0 1px; border-radius: 999px; background: color-mix(in srgb, var(--blue) 25%, transparent); border: 1px solid color-mix(in srgb, var(--blue) 55%, transparent); color: var(--text); font-size: 13px; line-height: 1.5; user-select: all; cursor: default; }
.var-pill.bad { background: color-mix(in srgb, var(--red) 30%, transparent); border-color: var(--red); }
.field-menu { position: fixed; z-index: 1000; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 2px; min-width: 240px; }
.field-menu > .muted { padding: 4px 8px; }
.field-menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; background: transparent; border: 0; padding: 6px 8px; border-radius: 6px; width: 100%; }
.field-menu button:hover { background: var(--panel-2); }

/* Configurações → Templates de abordagem */
.tpl-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.tpl-ctx { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 10px 12px; }
.tpl-ctx .ctx-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.tpl-ctx .ctx-head button { margin-left: auto; }
.tpl-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.tpl-step .meta { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 110px; }
.tpl-step .txt { overflow-wrap: anywhere; }
.tpl-step .txt .var-pill { font-size: 12px; }

/* Atalho na aba Vendas para os templates */
.tpl-shortcut { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin: 8px 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tpl-shortcut span { flex: 1 1 220px; }
@media (max-width: 600px) { .tpl-step { grid-template-columns: minmax(0, 1fr); } .tpl-step .meta { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; } }

/* Links em geral (produtos, leads, avisos): laranja, legível no fundo escuro */
a, a:visited { color: var(--link); }
a:hover { color: color-mix(in srgb, var(--link) 75%, var(--text)); }

/* Métricas de vendas por contexto */
#salesMetrics { margin-bottom: 22px; }

/* Funil horizontal (vendas por contexto) */
.funnel-card { margin-bottom: 12px; }
.funnel-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.funnel-head h3 { margin: 0; }
.funnel { position: relative; margin-top: 10px; }
.funnel svg { display: block; width: 100%; height: 150px; }
.funnel.mini svg { height: 70px; }
.funnel .f-labels { display: grid; gap: 4px; margin-top: 8px; }
.funnel .f-step { text-align: center; min-width: 0; }
.funnel .f-step .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel.mini .f-step .n { font-size: 16px; }
.funnel .f-step .l { font-size: 12px; color: var(--muted); }
.funnel .f-step .p { font-size: 12px; color: var(--green); font-weight: 600; }
.funnel .f-step .p.muted { color: var(--muted); font-weight: 400; }
.funnel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 12px; }
.funnel-grid .card { cursor: pointer; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.funnel-grid .card:hover, .funnel-grid .card.sel { border-color: var(--green-dark); }
.funnel-grid .card h4 { margin: 0; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
@media (max-width: 600px) { .funnel svg { height: 110px; } .funnel .f-step .n { font-size: 20px; } }
.funnel.mini .f-step .l { font-size: 10.5px; overflow-wrap: anywhere; }

/* Etiquetas do lead no topo da conversa (vendas) */
.chat-who:has(.lead-tags) { flex-wrap: wrap; row-gap: 4px; flex: 1 1 260px; }
.lead-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.lead-tags .ctx-tag { background: color-mix(in srgb, var(--link) 18%, transparent); border: 1px solid color-mix(in srgb, var(--link) 55%, transparent); color: var(--text); }
.lead-tags .stage-tag.comprou { background: color-mix(in srgb, var(--green) 22%, transparent); border-color: var(--green); }
.lead-tags .stage-tag.respondeu, .lead-tags .stage-tag.interessado { border-color: var(--amber); }
.lead-tags .ctx-tag.past { opacity: .6; }

/* Kanban dos leads (vendas) */
#tab-vendas.kanban-on > .col { display: none; }
#tab-vendas .kanban-bar, #tab-vendas .kanban-box { grid-column: 1 / -1; min-width: 0; }
#tab-vendas .kanban-bar .filters { margin: 0; }
.kanban-tools { gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.kanban-tools input { flex: 1 1 220px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kb-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 120px; }
.kb-col.drop { border-color: var(--green); }
.kb-col h4 { margin: 0; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); font-size: 13px; }
.kb-col h4 .n { color: var(--muted); font-weight: 500; }
.kb-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.kb-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: grab; font-size: 13px; }
.kb-card:hover { border-color: var(--green-dark); }
.kb-card.dragging { opacity: .5; }
.kb-card .nm { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.kb-card .nm .when { color: var(--muted); font-weight: 400; font-size: 11px; white-space: nowrap; }
.kb-card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.kb-card .tags .pill { font-size: 11px; padding: 1px 7px; }
.kb-card .meta { color: var(--muted); font-size: 11.5px; }
.kb-card .open { margin-top: 6px; font-size: 12px; }
.kb-col[data-stage="comprou"] h4 { color: var(--green); }
.kb-col[data-stage="respondeu"] h4, .kb-col[data-stage="interessado"] h4 { color: var(--amber); }
@media (max-width: 600px) { .kanban { grid-auto-columns: 82vw; } .kb-col { max-height: 70vh; } }
.kanban-tools { display: flex; align-items: center; }
.kanban-tools select { width: auto; flex: 0 1 260px; }
.kb-card .ctx-tag { background: color-mix(in srgb, var(--link) 18%, transparent); border: 1px solid color-mix(in srgb, var(--link) 55%, transparent); color: var(--text); }
.kb-card .ctx-tag.past { opacity: .6; }

/* No celular, só o ícone (o nome do workspace precisa do espaço) */
@media (max-width: 760px) { .brand-name { display: none; } }

/* =====================================================================
   VISUAL ACTION ZAP: claro e escuro, cartões arredondados, botões em pílula,
   conversa no jeito do WhatsApp. Só aparência: a estrutura das telas é a mesma.
   ===================================================================== */
body { font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body:not(.auth-page) { height: var(--app-h, 100dvh); }
button, input, select, textarea { font-family: inherit; }

/* botões e campos */
button { border-radius: 999px; padding: 8px 16px; font-weight: 500; background: var(--panel-2); border-color: var(--line); }
button:hover { border-color: color-mix(in srgb, var(--muted) 60%, transparent); }
button.small { padding: 5px 12px; }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.danger { background: transparent; border-color: color-mix(in srgb, var(--red) 55%, transparent); color: var(--red); }
button.danger:hover { background: var(--red-soft); }
input, select, textarea { border-radius: 12px; background: var(--panel-2); border-color: var(--line); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
h2 { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; }
h3 { font-weight: 600; }
.chip { border-radius: 999px; }
.pill { border-radius: 999px; font-weight: 500; }
.badge { border-radius: 999px; }
.level { border-radius: 999px; }
.avatar { background: hsl(var(--h, 210) 42% 42%); }
:root[data-theme="dark"] .avatar { background: hsl(var(--h, 210) 36% 34%); }
.avatar.mail, .avatar.anon { background: var(--panel-2); }

/* cartões */
.card, .tile, .cards li, .person, .keybox, .usage, .consult-box, .ai-keys, .tpl-ctx, .tpl-shortcut, .step-card, .model-opt, .kb-col, .q-messages { border-radius: var(--radius-card); }
.card, .tile, .usage, .kb-col { box-shadow: var(--shadow); }
.cards li, .person, .step-card, .model-opt, .tpl-ctx { border-radius: 18px; }
.kb-card { border-radius: 14px; background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.kb-col { background: var(--panel-2); }
.kb-col h4 { border-bottom: 0; font-size: 13.5px; }
.tile .label { letter-spacing: .04em; }
.tile .value { font-weight: 600; letter-spacing: -.5px; }
dialog { border-radius: 24px; box-shadow: var(--shadow-pop); border-color: var(--line); }
.user-pop, .field-menu { border-radius: 18px; }
.toast { border-radius: 14px; background: var(--panel); }
.suggestion { border-radius: 18px; box-shadow: var(--shadow); }
.banner { font-weight: 500; }

/* página de entrar, convite, senha nova */
.auth-card { border-radius: 26px; padding: 32px 28px; box-shadow: var(--shadow); border-color: var(--line); }
.auth-card h1 { gap: 10px; }
.auth-card button.primary { margin-top: 4px; }

/* botão de tema */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; flex: none; width: 38px; height: 38px; padding: 0; border: 0; color: var(--muted); }
.theme-btn .ic { display: block; width: 20px; height: 20px; }
.theme-btn .lbl { display: none; }
:root[data-theme="dark"] .theme-btn .ic-lua, :root:not([data-theme="dark"]) .theme-btn .ic-sol { display: none; }

/* ---------------- conversa no jeito do WhatsApp ---------------- */
.messages, .q-messages {
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-dot) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
}
.q-messages { border-color: var(--line); }
.messages { gap: 4px; padding: 14px 6%; }
.msg { border-radius: 12px; padding: 7px 10px 6px; font-size: 15px; line-height: 1.38; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); color: var(--text); }
.msg.in { border-top-left-radius: 4px; border-bottom-left-radius: 12px; }
.msg.out { border-top-right-radius: 4px; border-bottom-right-radius: 12px; }
.msg .meta { text-align: right; font-size: 11px; margin-top: 2px; color: color-mix(in srgb, var(--text) 52%, transparent); }
.msg.in + .msg.out, .msg.out + .msg.in { margin-top: 6px; }
.msg.shadow { box-shadow: none; }
.msg.msg-failed { background: var(--red-soft); }
.react-badge { background: var(--panel); box-shadow: var(--shadow); }

/* cabeçalho da conversa */
.chat-head { background: var(--panel); border-bottom: 1px solid var(--line); min-height: 60px; }
.chat-head .avatar { width: 40px; height: 40px; font-size: 13px; }
.chat-who .title { font-size: 16px; font-weight: 600; }
.lead-tags .pill { padding: 2px 9px; }
.lead-tags .ctx-tag { background: var(--orange-soft); border-color: transparent; color: var(--orange-text); }
.lead-tags .stage-tag { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.lead-tags .stage-tag.comprou { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.lead-tags .stage-tag.respondeu, .lead-tags .stage-tag.interessado { background: var(--amber-soft); border-color: transparent; color: var(--amber-text); }
.kb-card .ctx-tag { background: var(--orange-soft); border-color: transparent; color: var(--orange-text); }

/* caixa de digitar: barra de baixo com campo em pílula e botão redondo de enviar */
.composer { align-items: flex-end; gap: 8px; padding: 8px 12px; background: var(--panel-2); border-top: 1px solid var(--line); }
.composer textarea { border-radius: 22px; padding: 11px 16px; min-height: 44px; max-height: 160px; background: var(--panel); border: 1px solid var(--line); line-height: 1.35; }
.send-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; min-height: 44px; padding: 0 18px; border-radius: 999px; }
.send-btn .ic { display: block; width: 19px; height: 19px; stroke-width: 2; }

/* sugestão da IA: cartão acima da caixa */
.suggestion { background: var(--panel); border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.suggestion.scheduled { border-color: color-mix(in srgb, var(--blue) 60%, transparent); }
.suggestion textarea { background: var(--panel-2); border-radius: 14px; }
.suggestion .ask { color: var(--amber-text); }
.platform-action { border-radius: 14px; background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }

/* lista de conversas */
.contacts { background: var(--panel); }
.contacts-head { border-bottom: 0; padding: 12px 12px 6px; }
.contacts-head input[type="search"], .contacts-head input:not([type]) { border-radius: 999px; padding-left: 16px; }
#contactList { padding: 4px 8px 10px; }
#contactList li { border-bottom: 0; border-radius: 16px; padding: 10px 12px; margin-bottom: 2px; }
#contactList li:hover { background: var(--panel-2); }
#contactList li.active { background: var(--accent-soft); box-shadow: none; }
#contactList li.is-unread .when { color: var(--accent); }

/* fila */
.q-messages { padding: 14px; }
.q-note { border-radius: 14px; }

/* ---------------- computador e tablet deitado: menu lateral + painéis flutuando ---------------- */
@media (min-width: 761px) {
  body { background: var(--bg); }
  .topbar { background: var(--panel); border-right: 1px solid var(--line); gap: 16px; padding: 18px 14px 14px; }
  .brand { flex-wrap: wrap; row-gap: 12px; }
  .brand .wordmark { flex: 1 1 calc(100% - 40px); font-size: 19px; }
  .brand .logo { width: 32px; height: 32px; border-radius: 10px; }
  .brand select { flex: 1 1 0; min-width: 0; border-radius: 999px; background-color: var(--panel-2); }
  #newWorkspaceBtn { border-radius: 50%; }
  .topbar .tabs button { border-radius: 999px; padding: 10px 14px; }
  .topbar .tabs button:hover { background: var(--panel-2); }
  .topbar .tabs button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
  .topbar .tabs button.active .ic { color: var(--accent-text); }
  .topbar .autonomy { border-radius: 18px; background: var(--panel-2); border-color: transparent; padding: 8px; }
  .topbar .level.active { color: var(--accent-text); }
  .theme-btn { width: 100%; height: auto; justify-content: flex-start; padding: 9px 14px; font-size: 14px; color: var(--muted); }
  .theme-btn .lbl { display: inline; }
  .theme-btn:hover { color: var(--text); }
  #userBtn { border-radius: 999px; }

  /* Conversas: lista e conversa como dois cartões lado a lado */
  #tab-conversas.active { gap: 12px; padding: 12px; }
  #tab-conversas .contacts, #tab-conversas .chat { border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow); background: var(--panel); }
  .chat-head { border-radius: 0; }
  /* Fila */
  #tab-fila .queue { padding: 16px; }
  .tab > .col { border-radius: var(--radius-card); box-shadow: var(--shadow); }
  .tab > .col .cards li, .tab > .col .person, .tab > .col .keybox { background: var(--panel-2); border-color: transparent; }
}

/* ---------------- celular ---------------- */
@media (max-width: 760px) {
  .topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
  .topbar > .theme-btn { display: none; } /* fica no menu da conta */
  .only-mobile#themeBtn2 { display: block; }
  .brand select { border-radius: 999px; }
  /* barra de baixo: ícone com pílula verde clara na aba ativa */
  .topbar .tabs { background: var(--panel); border-top: 1px solid var(--line); }
  .topbar .tabs > button.active { color: var(--accent-text); font-weight: 600; }
  .topbar .tabs > button.active::before { content: ""; position: absolute; top: 6px; left: 50%; width: 52px; height: 30px; margin-left: -26px; border-radius: 999px; background: var(--accent-soft); z-index: -1; }
  .topbar .tabs > button .ic { margin-top: 2px; }
  .tabs-more { border-radius: 22px; }
  .topbar .tabs-more button { border-radius: 14px; }
  .topbar .tabs-more button.active { background: var(--accent-soft); color: var(--accent-text); }

  /* conversa em tela cheia, como no WhatsApp */
  .messages { padding: 10px 10px; }
  .chat-head { min-height: 56px; flex-wrap: wrap; }
  .chat-who, .chat-who:has(.lead-tags) { flex: 1 1 0; min-width: 0; }
  .lead-tags { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .lead-tags::-webkit-scrollbar { display: none; }
  .lead-tags > * { flex: none; }
  .composer { padding: 6px 8px calc(6px + var(--safe-b)); gap: 6px; }
  .send-btn { width: 46px; min-width: 46px; height: 46px; min-height: 46px; padding: 0; }
  .send-btn .lbl { display: none; }
  .suggestion { border-radius: 18px; }
  #contactList { padding: 2px 6px 10px; }
  #contactList li { border-radius: 14px; }

  /* Teclado aberto: só a conversa e a caixa de digitar. Nada fica por cima. */
  body.kb-open .topbar .tabs, body.kb-open .tabs-more { display: none !important; }
  body.kb-open main { padding-bottom: 0; }
  body.kb-open .banner, body.kb-open .importing { display: none; }
  body.kb-open .lead-tags, body.kb-open .chat-head .phone { display: none; }
  body.kb-open .chat-head { min-height: 0; padding-top: 4px; padding-bottom: 4px; }
  body.kb-open .chat-head .avatar { width: 32px; height: 32px; }
  body.kb-open .suggestion .reason, body.kb-open .platform-action { display: none; }
  body.kb-open .suggestion .ask { -webkit-line-clamp: 1; }
  body.kb-open .suggestion textarea { max-height: 22vh; }
  body.kb-open .composer, body.kb-open #tab-conversas .suggestion { padding-bottom: 6px; margin-bottom: 6px; }
  body.kb-open .q-head { display: none; }
  body.kb-open .q-messages { min-height: 60px; }
  body.kb-open #toasts { bottom: 10px; }
}

/* tablet em pé (761–900): lista ou conversa, uma de cada vez, em cartão */
@media (min-width: 761px) and (max-width: 900px) {
  .theme-btn .lbl { display: none; }
  .theme-btn { width: 38px; justify-content: center; padding: 0; height: 38px; }
}

/* seta do seletor de workspace não encosta no nome */
.topbar .brand select { padding-right: 30px; text-overflow: ellipsis; }

/* Vendas: etiquetas do lead no lugar do trecho da conversa, na lista */
#contactList .lead-preview { display: flex; gap: 4px; align-items: center; overflow: hidden; white-space: nowrap; }
#contactList .lead-preview .pill { flex: none; font-size: 11.5px; padding: 1px 9px; }
#contactList .lead-preview .pill:first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lead-preview .ctx-tag { background: var(--orange-soft); color: var(--orange-text); }
.lead-preview .stage-tag { background: var(--panel-2); color: var(--muted); }
.lead-preview .stage-tag.comprou { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.lead-preview .stage-tag.respondeu, .lead-preview .stage-tag.interessado { background: var(--amber-soft); color: var(--amber-text); }
.lead-preview .stage-tag.perdido, .lead-preview .stage-tag.saiu { background: var(--red-soft); color: var(--red-text); }

/* Seletor de workspace no visual do sistema (a lista nativa fica escondida por baixo) */
.brand select.ws-native { display: none !important; }
.ws-pick { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 14px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; text-align: left; }
.ws-pick:hover, .ws-pick.open { border-color: var(--accent); }
.ws-pick .ws-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-kind { flex: none; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); letter-spacing: .02em; }
.ws-caret { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.ws-pick.open .ws-caret { transform: rotate(180deg); }
.ws-scrim { position: fixed; inset: 0; z-index: 90; background: transparent; }
.ws-menu { position: fixed; z-index: 91; max-width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 460px); overflow: auto; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 2px; }
.ws-menu-title { padding: 6px 10px 8px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ws-opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 14px; background: transparent; text-align: left; font-weight: 500; color: var(--text); }
.ws-opt:hover, .ws-opt:focus-visible { background: var(--panel-2); outline: none; }
.ws-opt.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.ws-ini { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); font-weight: 700; font-size: 14px; }
.ws-opt.on .ws-ini { background: var(--accent); color: var(--on-accent); }
.ws-txt { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; }
.ws-check { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 760px) {
  .ws-pick { background: transparent; border-color: transparent; padding: 6px 8px; font-size: 16px; }
  .ws-pick .ws-kind { display: none; }
  /* celular: abre como painel de baixo, no tamanho do dedo */
  .ws-scrim { background: var(--scrim); }
  .ws-menu { left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; max-height: 75vh; border-radius: 24px 24px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom, 0px)); }
  .ws-menu::before { content: ""; align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 2px 0 6px; }
  .ws-opt { min-height: 52px; font-size: 16px; }
}
.ws-pick .ws-kind { display: none; }

/* =====================================================================
   CONFIGURAÇÕES EM ABAS: um assunto por vez, cada bloco num cartão
   ===================================================================== */
#tab-config.active { display: grid; grid-template-columns: 220px minmax(0, 860px); justify-content: center; align-items: start; gap: 28px; padding: 24px; overflow: auto; }
.cfg-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); }
.cfg-nav button { display: block; width: 100%; padding: 10px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 500; text-align: left; white-space: nowrap; }
.cfg-nav button:hover { background: var(--panel-2); color: var(--text); }
.cfg-nav button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.cfg-body { min-width: 0; }
.cfg-panel { display: none; flex-direction: column; gap: 16px; }
.cfg-panel.on { display: flex; }
.cfg-head { padding: 2px 4px 4px; }
.cfg-head h3 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.cfg-head p { margin: 0; line-height: 1.5; }

/* cada bloco é um cartão, com respiro entre título, texto, campos e botões */
.cfg-card, #tplSection, #modelSection, #keySection, #zernioSection, #apiKeySection {
  padding: 22px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); min-width: 0;
}
.cfg-panel h2 { margin: 0 0 10px; }
.cfg-panel h2 ~ h2 { margin-top: 26px; }
.cfg-panel p { line-height: 1.5; }
.cfg-panel p.muted { margin: 0 0 14px; }
.cfg-panel p.muted.small { margin: 6px 0 14px; }
.cfg-panel label { margin-bottom: 16px; }
.cfg-panel label.check { align-items: flex-start; gap: 10px; line-height: 1.45; color: var(--text); }
.cfg-panel label.check input { margin-top: 3px; }
.cfg-panel .row { flex-wrap: wrap; gap: 10px; margin: 10px 0 0; }
.cfg-panel .row + label, .cfg-panel .row + .row { margin-top: 16px; }
.cfg-panel textarea + .row { margin-top: 12px; }
.cfg-panel .row + label.check { margin-top: 16px; }
.cfg-panel .row.calibrate { margin: 4px 0 18px !important; align-items: center; }
.cfg-panel .row.calibrate > span { flex: 1 1 240px; line-height: 1.45; }
.cfg-panel #saveSettingsBtn { margin-top: 6px; }
.cfg-panel .how { margin: 0 0 12px; padding-left: 20px; line-height: 1.5; }
.cfg-panel .how li { margin-bottom: 10px; }
.cfg-panel .consult-box { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; gap: 14px; }
.cfg-panel .consult-step { border-radius: 16px; padding: 14px 16px; }
.cfg-panel .consult-step p { line-height: 1.45; }
.cfg-panel .ai-keys { border-radius: 18px; background: var(--panel-2); border-color: transparent; padding: 14px 16px; gap: 14px; }
.cfg-panel .ai-key label { margin-bottom: 8px; }
.cfg-panel .models { gap: 10px; }
.cfg-panel .model-opt { background: var(--panel-2); border-color: transparent; }
.cfg-panel .model-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.cfg-panel .models-title { margin: 20px 0 10px; }
.cfg-panel .usage { margin: 16px 0 0; box-shadow: none; background: var(--panel-2); border-color: transparent; }
.cfg-panel .keybox { margin: 0; background: var(--panel-2); border-color: transparent; }
.cfg-panel .tpl-ctx { background: var(--panel-2); border-color: transparent; padding: 14px 16px; }
.cfg-panel .tpl-list { gap: 12px; margin-bottom: 16px; }
.cfg-panel .cards.compact li { background: var(--panel-2); border-color: transparent; }
.cfg-panel #wsNameForm { margin: 0; flex-wrap: nowrap; }
.cfg-panel #wsNameForm input { flex: 1; min-width: 0; }
.cfg-panel input[type="range"] { margin-top: 4px; }

/* tablet e computador estreito: abas em cima, numa linha que desliza */
@media (max-width: 1100px) {
  #tab-config.active { display: block; padding: 0 20px 28px; }
  .cfg-nav { flex-direction: row; gap: 6px; margin: 0 -20px 16px; padding: 12px 20px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; overflow-x: auto; scrollbar-width: none; z-index: 5; }
  .cfg-nav::-webkit-scrollbar { display: none; }
  .cfg-nav button { flex: none; width: auto; padding: 8px 16px; background: var(--panel-2); color: var(--text); }
  .cfg-nav button.active { background: var(--accent); color: var(--on-accent); }
  .cfg-body { max-width: 860px; margin: 0 auto; }
}
/* celular */
@media (max-width: 760px) {
  #tab-config.active { padding: 0 12px 28px; }
  .cfg-nav { margin: 0 -12px 12px; padding: 10px 12px; }
  .cfg-nav button { min-height: 38px; font-size: 14px; }
  .cfg-head h3 { font-size: 20px; }
  .cfg-card, #tplSection, #modelSection, #keySection, #zernioSection, #apiKeySection { padding: 18px 16px; border-radius: 20px; }
  .cfg-panel .row > button { flex: 1 1 auto; }
  .cfg-panel #wsNameForm { flex-wrap: wrap; }
  .cfg-panel #wsNameForm input { flex: 1 1 100%; }
  .cfg-panel .providers { grid-template-columns: minmax(0, 1fr); }
}
/* o título da aba já diz o assunto: não repete no primeiro cartão */
#cfg-autonomia .cfg-card:first-of-type > h2:first-child, .cfg-panel #consult, #tplSection > h2:first-child, #modelSection > h2:first-child { display: none; }

/* Conectar ao Claude ou ChatGPT: passos como lista simples (não como etiquetas) */
#claudeDialog { width: min(560px, calc(100vw - 24px)); }
#claudeDialog ol.steps { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 8px; margin: 0; }
#claudeDialog ol.steps li { padding: 0 0 0 30px; position: relative; border-radius: 0; background: transparent; color: var(--text); font-size: 14px; line-height: 1.5; }
#claudeDialog ol.steps li::before { content: counter(st); position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: 11.5px; font-weight: 700; }
#claudeDialog .conn-title { margin: 6px 0 2px; font-size: 14px; }

/* Envio automático (Vendas): campos lado a lado no computador; no celular, um em cima do outro */
.cad-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; margin-top: 6px; }
.cad-fields label { min-width: 0; margin-bottom: 14px; }
.cad-fields input { width: 100%; min-width: 0; }
@media (max-width: 760px), (min-width: 761px) and (max-width: 1100px) {
  .cad-fields { grid-template-columns: minmax(0, 1fr); }
}

/* =====================================================================
   VENDAS EM ABAS (mesmo jeito das Configurações)
   ===================================================================== */
#tab-vendas.active { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: 28px; padding: 24px; overflow: auto; }
#tab-vendas .cfg-panel:not([data-panel="kanban"]) { max-width: 900px; }
#tab-vendas .cfg-panel .row { flex-wrap: wrap; gap: 10px; }
#tab-vendas .cfg-panel h2 { margin: 0 0 10px; }
#tab-vendas .cfg-panel h2 ~ h2 { margin-top: 24px; }
#tab-vendas .cfg-panel p { line-height: 1.5; }
#tab-vendas .cfg-panel .mastery-head { margin-bottom: 8px; }
#tab-vendas .cfg-panel .mastery-head > span:empty { flex: 1; }
#tab-vendas .cfg-panel .cards li { background: var(--panel-2); border-color: transparent; }
#tab-vendas .cfg-panel .tpl-shortcut { background: var(--panel-2); border-color: transparent; }
#tab-vendas .cfg-panel pre.code { margin: 8px 0 14px; }
#tab-vendas .cfg-panel .lead-add { margin: 10px 0; }
#tab-vendas .kanban-box { min-width: 0; }
#tab-vendas .kb-col { max-height: calc(100vh - 230px); }
#leadCountRow { margin: 0 0 6px; }
#leadCountRow:has(#leadCount:empty) { display: none; }
@media (max-width: 1100px) {
  #tab-vendas.active { display: block; padding: 0 20px 28px; }
  #tab-vendas .cfg-nav { flex-direction: row; gap: 6px; margin: 0 -20px 16px; padding: 12px 20px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; overflow-x: auto; scrollbar-width: none; z-index: 5; }
  #tab-vendas .cfg-panel:not([data-panel="kanban"]) { max-width: 860px; margin: 0 auto; }
}
@media (max-width: 760px) {
  #tab-vendas.active { padding: 0 12px 28px; }
  #tab-vendas .cfg-nav { margin: 0 -12px 12px; padding: 10px 12px; }
  #tab-vendas .cfg-card { padding: 18px 16px; border-radius: 20px; }
  #tab-vendas .kb-col { max-height: 70vh; }
}

/* =====================================================================
   CAMPOS NUNCA SAEM DA CAIXA (todas as telas)
   Linha com vários campos: lado a lado só se couber; no celular, um em cima do outro.
   ===================================================================== */
input, select, textarea { max-width: 100%; min-width: 0; }
input[type="time"], input[type="date"], input[type="datetime-local"], input[type="number"] { width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; }
.row > label:not(.check) { flex: 1 1 0; min-width: 0; }
.row > label:not(.check) > input:not([type="checkbox"]):not([type="radio"]), .row > label:not(.check) > select { width: 100%; }
.row > label.check { flex: none; margin-bottom: 0; }
@media (max-width: 760px) {
  .row:has(> label:not(.check)) { flex-direction: column; align-items: stretch; gap: 0; }
  .row:has(> label:not(.check)) > label { flex: none; width: 100%; }
}
@media (max-width: 760px) {
  /* botão de texto longo quebra a linha em vez de sair da caixa */
  .row > button, .cfg-panel .row > button { white-space: normal; flex-shrink: 1; min-width: 0; max-width: 100%; }
}

/* =====================================================================
   JEITO DE APLICATIVO: sem zoom de pinça/toque duplo e a tela nunca escorrega para o lado
   ===================================================================== */
html, body { overflow-x: hidden; overscroll-behavior-x: none; touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
main, .tab, .content { overflow-x: hidden; }
.tab.active > *, .metrics, .metrics > * { min-width: 0; max-width: 100%; }
/* tabelas: cabem no cartão; se não couber, rolam só dentro dele */
.card.m-table, .m-table, .card:has(> table) { overflow-x: auto; max-width: 100%; }
#smTable { width: 100%; }
@media (max-width: 760px) {
  #tab-metricas.active { display: block; }
  .metrics { width: 100%; }
  .card.m-table { padding: 10px 8px; }
  #smTable { font-size: 12.5px; }
  #smTable th { font-size: 11px; white-space: normal; line-height: 1.2; }
  #smTable td, #smTable th { padding: 7px 3px; }
  #smTable td:first-child { min-width: 78px; }
  #smTable .small { font-size: 10.5px; }
  .m-head { flex-wrap: wrap; }
  .funnel .f-step .l, .funnel .f-step .p { font-size: 11px; }
}
/* celular estreito: cada contexto vira um bloco (rótulo à esquerda, número à direita) */
@media (max-width: 400px) {
  #smTable, #smTable tbody, #smTable tr, #smTable td { display: block; width: 100%; }
  #smTable tr:first-child { display: none; }
  #smTable tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  #smTable td { display: flex; justify-content: space-between; gap: 10px; padding: 2px 4px; border: 0; }
  #smTable td::before { content: attr(data-l); color: var(--muted); }
  #smTable td[data-l="Contexto"] { font-weight: 600; font-size: 14px; }
  #smTable td[data-l="Contexto"]::before { content: none; }
  #smTable td[colspan] { color: var(--muted); }
  #smTable td[colspan]::before { content: none; }
}
@media (max-width: 400px) {
  #smTable td { justify-content: flex-start; gap: 4px; align-items: baseline; }
  #smTable td::before { margin-right: auto; }
}

/* Hot leads (Hotmart) */
.hot-flame { display: inline-block; font-size: 1.05em; line-height: 1; }
.pill.hot-tag { background: #FFE3D3; color: #A23B0B; font-weight: 600; }
:root[data-theme="dark"] .pill.hot-tag { background: #4A2414; color: #FFB48A; }
.hot-list li { display: flex; flex-direction: column; gap: 6px; }
.hot-list .row { margin-top: 2px; }
.hm-hot { margin: 18px 0 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Foguinho vivo do Hot lead: a chama tremula (não é um ícone parado) */
.flame { display: inline-flex; align-items: flex-end; justify-content: center; width: .9em; height: 1.15em; margin-right: .3em; vertical-align: -.18em; flex: none; position: relative; }
.flame svg { width: 100%; height: 100%; overflow: visible; transform-origin: 50% 100%; animation: flame-dance 1.1s ease-in-out infinite alternate; filter: drop-shadow(0 0 .14em rgba(255, 122, 26, .55)); }
.flame svg .fogo-dentro { transform-origin: 50% 100%; animation: flame-core .7s ease-in-out infinite alternate; }
@keyframes flame-dance {
  0% { transform: scale(1, 1) skewX(0deg); filter: drop-shadow(0 0 .12em rgba(255, 122, 26, .45)); }
  25% { transform: scale(.96, 1.06) skewX(-3deg); }
  50% { transform: scale(1.03, .95) skewX(2deg); filter: drop-shadow(0 0 .22em rgba(255, 150, 40, .7)); }
  75% { transform: scale(.98, 1.04) skewX(-1.5deg); }
  100% { transform: scale(1.02, .98) skewX(3deg); filter: drop-shadow(0 0 .16em rgba(255, 122, 26, .55)); }
}
@keyframes flame-core {
  0% { transform: scale(1, 1) translateY(0); opacity: .95; }
  100% { transform: scale(.88, 1.12) translateY(-.4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .flame svg, .flame svg .fogo-dentro { animation: none; } }
#contactList .name .flame, .chat-who .title .flame { margin-right: .28em; }
.chip .flame, .cfg-nav .flame { margin-right: .15em; }
