/* ===== tokens — cores da CMM (marinho + azul da logo + dourado) ===== */
:root {
  --navy: #0f2a44; --navy-2: #163a5c; --sky: #82d4f7; --cyan: #01bef2; --gold: #c9a46c;
  --bg: #dfe6ec; --panel: #ffffff; --panel-2: #f0f3f6; --panel-3: #e6ebf0; --line: #e4e9ee; --sep: #e9edf1;
  --text: #0f1c28; --muted: #5f7181; --faint: #8fa0ae;
  --accent: #0877ad; --accent-hover: #06628f; --accent-ink: #ffffff; --accent-soft: #dcf0fb; --accent-softer: #eef7fc;
  --head: #0f2a44; --head-ink: #ffffff; --chat-head: #f0f3f6;
  --in: #ffffff; --out: #d4eefc; --note: #fff4d1; --note-line: #d9a520;
  --chat-bg: #e9eff4; --mark-opacity: .085; --vignette: rgb(15 42 68 / .16);
  --sel: #e8eef4; --hover: #f5f7f9;
  --danger: #d93636; --warn-bg: #fff3d6; --warn-ink: #7f5300; --read: #01a7e1;
  --shadow-sm: 0 1px .5px rgb(11 20 26 / .13);
  --shadow-md: 0 6px 24px rgb(11 26 40 / .10), 0 1px 3px rgb(11 26 40 / .08);
  --shadow-lg: 0 24px 60px rgb(11 26 40 / .25);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07111b; --panel: #0e1d2c; --panel-2: #142839; --panel-3: #1b3247; --line: #1d3245; --sep: #1a2d3f;
    --text: #e5edf4; --muted: #8fa5b8; --faint: #5f7487;
    --accent: #3fb8ec; --accent-hover: #64c7f1; --accent-ink: #04192a; --accent-soft: #123a55; --accent-softer: #0f2c42;
    --head: #0b2034; --head-ink: #e8f1f8; --chat-head: #142839;
    --in: #172b3d; --out: #0d4565; --note: #3a2f10; --note-line: #d9a520;
    --chat-bg: #0a1622; --mark-opacity: .06; --vignette: rgb(0 0 0 / .45);
    --sel: #1b3247; --hover: #142839;
    --danger: #f37272; --warn-bg: #3a2f10; --warn-ink: #f5cf6b; --read: #5ccdf5;
    --shadow-sm: 0 1px .5px rgb(0 0 0 / .45);
    --shadow-md: 0 6px 24px rgb(0 0 0 / .45);
    --shadow-lg: 0 24px 60px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

/* ===== base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", "Helvetica Neue", Helvetica, ui-sans-serif, system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; font-size: 14px; }
svg { flex: none; display: block; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== controls ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap; font-weight: 500; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.lg { padding: 12px 16px; justify-content: center; font-size: 16px; }
.btn.danger { color: var(--danger); }
.btn.success { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; background: none; border-radius: 50%;
  cursor: pointer; color: var(--muted); transition: background .15s, color .15s; text-decoration: none; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.light { color: #fff; } .icon-btn.light:hover { background: rgb(255 255 255 / .15); color: #fff; }
.badge { white-space: nowrap; font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 15px;
  color: #fff; background: var(--accent); flex: none; letter-spacing: .02em; user-select: none; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text);
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select { cursor: pointer; }

/* ===== login ===== */
.login { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(120% 100% at 0% 0%, #1d4a73 0%, var(--navy) 50%, #081a2c 100%); color: #fff; display: grid; place-items: center; padding: 48px; position: relative; overflow: hidden; }
.login-hero::before { content: ""; position: absolute; width: 760px; height: 760px; right: -260px; bottom: -300px; background: url(/brand/cmm-marca.png) center / contain no-repeat; opacity: .07;
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent); mask-image: radial-gradient(closest-side, #000 35%, transparent); }
.hero-inner { position: relative; z-index: 1; max-width: 440px; }
.hero-logo { display: block; height: 58px; width: auto; }
.login-hero h2 { font-size: 40px; line-height: 1.12; margin: 34px 0 22px; letter-spacing: -.02em; font-weight: 700; }
.login-hero h2 span { color: var(--sky); }
.login-hero ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; font-size: 16px; opacity: .92; }
.login-hero li { padding-left: 30px; position: relative; }
.login-hero li::before { content: "✓"; position: absolute; left: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: var(--navy);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; top: 1px; }
.login-side { display: grid; place-items: center; padding: 24px 16px; background: var(--panel); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login-card h1 { margin: 6px 0 0; font-size: 28px; letter-spacing: -.02em; }
.login-card > p { margin: -10px 0 10px; }
.login-logo { display: none; height: 44px; width: auto; }
.login-card input { padding: 12px 14px; font-size: 16px; }

/* ===== shell ===== */
.app { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--bg); }
.layout { display: grid; grid-template-columns: minmax(340px, 30%) minmax(0, 1fr); min-height: 0; height: 100dvh; width: 100%; max-width: 1720px; margin: 0 auto; box-shadow: var(--shadow-md); }

/* ===== lista (lado esquerdo) ===== */
.list-pane { background: var(--panel); border-right: 1px solid var(--line); display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); min-height: 0; min-width: 0; overflow: hidden; }
.list-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px 0 16px; height: 60px; min-width: 0; background: var(--head); color: var(--head-ink); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-name { display: none; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--sky); padding-left: 10px; border-left: 1px solid rgb(255 255 255 / .25); letter-spacing: .02em; }
.list-top .icon-btn { color: rgb(255 255 255 / .82); }
.list-top .icon-btn:hover { background: rgb(255 255 255 / .12); color: #fff; }
.link-btn { border: 0; background: none; padding: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.legal { max-width: 720px; margin: 0 auto; padding: 40px 20px 60px; line-height: 1.6; }
.legal h1 { letter-spacing: -.02em; }
.legal h2 { font-size: 17px; margin-top: 28px; }
.steps { margin: 10px 0 16px; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; }
.steps code, .copy code { background: var(--panel-3); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; word-break: break-all; }
.copy { display: flex; gap: 8px; align-items: center; }
.copy code { flex: 1; padding: 8px 10px; }
.wa-status { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--accent-softer); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); }
.wa-status.off { background: var(--warn-bg); border-color: transparent; color: var(--warn-ink); }
.wa-status .grow { flex: 1; min-width: 0; }
.wa-status b { display: block; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.test-strip { margin: 8px 12px 0; padding: 7px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12.5px; }
.top-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.me { border: 0; background: none; padding: 2px; margin-left: 6px; border-radius: 50%; cursor: pointer; }
.me .avatar { box-shadow: 0 0 0 2px rgb(255 255 255 / .35); }
.me:hover .avatar { box-shadow: 0 0 0 3px var(--gold); }
.list-head { padding: 8px 12px 8px; display: grid; gap: 8px; background: var(--panel); }
.search { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border-radius: 10px; padding: 0 14px; color: var(--muted); height: 38px; }
.search input { border: 0; background: transparent; padding: 0; height: 100%; flex: 1; min-width: 0; box-shadow: none; font-size: 14.5px; }
.search input:focus { box-shadow: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); color: var(--accent); background: var(--panel); }
.filters { display: flex; gap: 8px; align-items: center; min-width: 0; padding-bottom: 2px; }
.filters button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); padding: 5px 13px; border-radius: 99px; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.filters button:hover { background: var(--panel-2); color: var(--text); }
.filters button.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.filters b { font-weight: 700; margin-left: 2px; }
.conv-list { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; overflow-x: hidden; min-width: 0; border-top: 1px solid var(--sep); }
.conv { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 14px; padding: 0 14px 0 13px; cursor: pointer; align-items: center; transition: background .1s; position: relative; height: 74px; }
.conv:hover { background: var(--hover); }
.conv.on { background: var(--sel); }
.conv.on::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.conv .avatar { width: 49px; height: 49px; font-size: 16px; }
.conv-main, .conv-side { align-self: stretch; display: grid; align-content: center; }
.conv::after { content: ""; position: absolute; left: 76px; right: 0; bottom: 0; border-bottom: 1px solid var(--sep); }
.conv:last-child::after, .conv.on::after, .conv:hover::after, .conv:has(+ .conv.on)::after, .conv:has(+ .conv:hover)::after { border-bottom-color: transparent; }
.conv-main { min-width: 0; gap: 2px; }
.conv-name { font-weight: 400; display: flex; gap: 6px; align-items: baseline; min-width: 0; white-space: nowrap; font-size: 16.5px; color: var(--text); }
.conv.unread-row .conv-name { font-weight: 600; }
.conv-contact { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.owner-tag { flex: 0 0 auto; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.conv-name .conv-contact { flex: 0 1 auto; }
.conv-preview { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread-row .conv-preview { color: var(--text); }
.conv-side { justify-items: end; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.conv.unread-row .conv-time { color: var(--accent); font-weight: 600; }
.unread { background: var(--accent); color: var(--accent-ink); border-radius: 99px; min-width: 21px; height: 21px; padding: 0 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.list-empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ===== chat (lado direito) ===== */
.chat-pane { min-height: 0; min-width: 0; display: grid; background: var(--chat-bg); position: relative; overflow: hidden; }
/* logo da CMM atrás das conversas, esmaecendo nas bordas */
.chat-pane::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: url(/brand/cmm-marca.png) center 46% / min(46%, 460px) auto no-repeat; opacity: var(--mark-opacity);
  -webkit-mask-image: radial-gradient(ellipse 34% 30% at 50% 46%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 34% 30% at 50% 46%, #000 30%, transparent 100%); }
.chat-pane::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 46%, transparent 45%, var(--vignette) 100%); }
.chat-pane > * { position: relative; z-index: 1; }
.chat-pane:has(> #empty:not([hidden]))::before { display: none; }
.empty { display: grid; place-content: center; justify-items: center; text-align: center; gap: 4px; padding: 24px; border-bottom: 5px solid var(--gold); }
.empty-art { margin-bottom: 26px; }
.empty-art img { height: 82px; width: auto; display: block; }
.empty h3 { margin: 0; font-size: 30px; font-weight: 300; letter-spacing: -.01em; color: var(--text); }
.empty p { margin: 10px 0 0; line-height: 1.6; font-size: 14.5px; }
.empty-foot { margin-top: 36px; font-size: 13px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--chat-head); border-left: 1px solid var(--line); min-height: 60px; z-index: 2; box-shadow: 0 1px 0 var(--line); }
.chat-head .avatar { width: 42px; height: 42px; }
.chat-title { display: grid; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.chat-title strong { white-space: nowrap; overflow: hidden; font-size: 16.5px; font-weight: 500; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.chat-title strong .conv-contact { flex: 0 1 auto; }
.chat-title strong .owner-tag { font-size: 13px; }
#chat-phone { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.assign { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.assign select { padding: 7px 30px 7px 10px; font-size: 13.5px; font-weight: 500; max-width: 210px; background-color: var(--panel); }
.assign span { white-space: nowrap; }
.back { display: none; }

.messages-wrap { position: relative; min-height: 0; display: grid; }
.messages { overflow-y: auto; padding: 16px max(7%, 18px) 14px; display: flex; flex-direction: column; }
.day { align-self: center; background: var(--panel); color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 5px 12px 6px; border-radius: 8px; margin: 12px 0 8px; box-shadow: var(--shadow-sm); text-transform: uppercase; letter-spacing: .02em; position: sticky; top: 6px; z-index: 1; }
.msg { max-width: min(640px, 72%); padding: 6px 8px 6px 9px; border-radius: 8px; box-shadow: var(--shadow-sm); white-space: pre-wrap; overflow-wrap: anywhere; position: relative; margin-top: 12px; font-size: 14.5px; line-height: 1.4; }
.msg.cont { margin-top: 2px; }
.msg.in { align-self: flex-start; background: var(--in); }
.msg.out { align-self: flex-end; background: var(--out); }
/* "rabinho" do balão, como no WhatsApp */
.msg.in:not(.cont) { border-top-left-radius: 0; }
.msg.out:not(.cont), .msg.note:not(.cont) { border-top-right-radius: 0; }
.msg.in:not(.cont)::before, .msg.out:not(.cont)::before, .msg.note:not(.cont)::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.msg.in:not(.cont)::before { left: -8px; background: var(--in); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg.out:not(.cont)::before { right: -8px; background: var(--out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.note:not(.cont)::before { right: -8px; background: var(--note); clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.sticker::before { display: none; }
.msg.note { align-self: flex-end; background: var(--note); box-shadow: var(--shadow-sm), inset 3px 0 0 var(--note-line); }
.msg.system { align-self: center; background: color-mix(in srgb, var(--panel) 92%, var(--accent)); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; margin: 10px 0; box-shadow: var(--shadow-sm); }
.msg.has-media { padding: 3px 3px 4px; }
.msg.has-media .msg-author { padding: 3px 6px 2px; }
.msg.has-media .msg-text { padding: 4px 6px 0; }
.msg.has-media .msg-meta { padding-right: 6px; }
.msg.sticker { background: transparent; box-shadow: none; padding: 0; }
.msg-author { font-size: 12.8px; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.msg-meta { font-size: 11px; color: var(--muted); display: flex; gap: 3px; justify-content: flex-end; align-items: center; margin: 1px 0 -3px 14px; float: right; position: relative; top: 6px; }
.msg-text + .msg-meta, .media + .msg-meta { float: none; top: 0; margin-top: 2px; }
.msg.has-media .msg-text + .msg-meta { margin-top: 0; }
.msg-body::after { content: ""; display: block; clear: both; }
.tick { display: inline-flex; color: var(--faint); }
.tick.read { color: var(--read); }
.tick.failed { color: var(--danger); }
.msg-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: flex; gap: 4px; align-items: center; white-space: normal; }

/* mídia */
.media { border-radius: 8px; overflow: hidden; display: block; }
.media-img { display: block; width: fit-content; cursor: zoom-in; background: var(--panel-3); border: 0; padding: 0; border-radius: 8px; overflow: hidden; }
.media-img img { display: block; width: auto; height: auto; max-width: min(330px, 66vw); max-height: 360px; min-width: 120px; min-height: 80px; object-fit: cover; }
.media video { display: block; width: min(360px, 66vw); max-height: 380px; background: #000; border-radius: 8px; }
.sticker img { width: 150px; height: 150px; object-fit: contain; }
.doc { display: flex; align-items: center; gap: 10px; padding: 10px; background: color-mix(in srgb, var(--text) 5%, transparent); border-radius: 8px; min-width: 240px; max-width: 330px; text-decoration: none; color: var(--text); }
.doc:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
.doc-icon { width: 38px; height: 44px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 10px; font-weight: 800; text-transform: uppercase; flex: none; }
.doc-info { min-width: 0; flex: 1; display: grid; }
.doc-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 12px; color: var(--muted); }
.doc .dl { color: var(--muted); }
.media-missing { display: flex; align-items: center; gap: 6px; padding: 10px 12px; color: var(--muted); font-size: 13.5px; font-style: italic; }

/* player de áudio */
.ap { display: flex; align-items: center; gap: 10px; padding: 6px 8px 2px 4px; width: min(300px, 64vw); }
.ap-mic { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.msg.out .ap-mic { background: color-mix(in srgb, var(--accent) 80%, #000); }
.ap-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; display: grid; place-items: center; border-radius: 50%; }
.ap-btn:hover { color: var(--text); }
.ap-mid { flex: 1; display: grid; gap: 2px; min-width: 0; }
.ap-bar { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; padding: 0; border: 0;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), color-mix(in srgb, var(--muted) 35%, transparent) var(--p, 0%)); cursor: pointer; }
.ap-bar:focus { box-shadow: none; }
.ap-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); border: 0; }
.ap-bar::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); border: 0; }
.ap-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.ap-speed { border: 0; background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); font-size: 10.5px; font-weight: 700; border-radius: 99px; padding: 0 7px; cursor: pointer; }

/* aviso 24h, arrastar */
.window-closed { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 13.5px; border-top: 1px solid color-mix(in srgb, var(--warn-ink) 20%, transparent); }
.drop { position: absolute; inset: 10px; border: 2.5px dashed var(--accent); border-radius: 16px; background: color-mix(in srgb, var(--panel) 88%, transparent);
  display: grid; place-items: center; color: var(--accent); font-weight: 700; font-size: 18px; z-index: 3; pointer-events: none; }
.drop div { display: grid; justify-items: center; gap: 8px; }

/* composer (barra de digitar, igual ao WhatsApp) */
.composer { background: var(--chat-head); padding: 4px 16px 10px; position: relative; }
.composer-tabs { display: flex; gap: 4px; align-items: center; margin: 2px 0 6px; min-width: 0; }
.composer-tabs button { white-space: nowrap; border: 0; background: none; padding: 4px 10px; border-radius: 99px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.composer-tabs button:hover { color: var(--text); background: var(--panel-3); }
.composer-tabs button.on { background: var(--accent-soft); color: var(--accent); }
.composer.note .composer-tabs button.on { color: var(--warn-ink); background: var(--note); }
.composer-tabs #sign-hint { margin-left: auto; min-width: 0; padding-left: 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-row { display: flex; gap: 6px; align-items: flex-end; }
.composer-row .icon-btn { width: 42px; height: 42px; color: var(--muted); }
.composer-input { flex: 1; min-width: 0; display: flex; align-items: flex-end; background: var(--panel); border-radius: 10px; padding: 0 4px 0 12px; box-shadow: var(--shadow-sm); }
.composer.note .composer-input { background: var(--note); box-shadow: var(--shadow-sm), inset 3px 0 0 var(--note-line); }
.composer textarea { flex: 1; resize: none; max-height: 168px; border: 0; background: transparent; padding: 11px 4px 10px; box-shadow: none; line-height: 1.4; min-width: 0; font-size: 15px; }
.composer textarea:focus { box-shadow: none; }
.composer.note .attach, .composer.note .emoji-btn { display: none; }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; transition: background .15s, transform .1s; }
.send:hover { background: var(--accent-hover); }
.send:active { transform: scale(.94); }
.send svg { margin-left: 2px; }
.emoji-pop { position: absolute; left: 16px; bottom: calc(100% + 6px); width: min(352px, calc(100% - 32px)); max-height: 260px; overflow-y: auto; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; z-index: 5; }
.emoji-pop button { border: 0; background: none; font-size: 24px; line-height: 1; height: 40px; border-radius: 8px; cursor: pointer; }
.emoji-pop button:hover { background: var(--panel-2); }
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
.chip { position: relative; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 30px 6px 6px; min-width: 0; max-width: 240px; flex: none; overflow: hidden; }
.chip-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--panel-3); display: grid; place-items: center; color: var(--muted); }
.chip-info { min-width: 0; display: grid; font-size: 12.5px; }
.chip-info b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-info span { color: var(--muted); }
.chip-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--panel-3); cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.chip-prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; transition: width .15s; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgb(6 16 26 / .95); z-index: 20; display: grid; place-items: center; padding: 56px 16px 16px; }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 80px); object-fit: contain; border-radius: 6px; box-shadow: var(--shadow-lg); }
.lb-bar { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }

/* diálogos */
dialog { border: 0; border-radius: 18px; padding: 0; background: var(--panel); color: var(--text); width: min(540px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); }
dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
dialog::backdrop { background: rgb(6 18 30 / .55); backdrop-filter: blur(2px); }
#dialog-form { padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-height: calc(100dvh - 40px); overflow-y: auto; }
#dialog-form h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
#dialog-form h4 { margin: 6px 0 -4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
#dialog-form p { margin: -6px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }
.team { display: grid; gap: 6px; max-height: 42vh; overflow: auto; }
.team-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.team-row .grow { flex: 1; min-width: 0; }
.team-row .grow b { display: block; }
.team-row .grow div { font-size: 13px; }
.team-row.off { opacity: .55; }
.team-row .btn { padding: 6px 10px; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tpl { display: grid; gap: 8px; max-height: 40vh; overflow: auto; }
.tpl label { display: flex; gap: 10px; align-items: start; border: 1px solid var(--line); border-radius: 12px; padding: 10px; color: var(--text); cursor: pointer; font-weight: 400; }
.tpl label:has(input:checked) { border-color: var(--accent); background: var(--accent-softer); }
.tpl small { color: var(--muted); display: block; }
.file-pick { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }
.file-pick input { border: 0; padding: 0; background: none; font-size: 13px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 11px 18px; border-radius: 12px; z-index: 30;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg); font-weight: 500; animation: up .2s ease-out; }
@keyframes up { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ===== notebooks / telas médias ===== */
@media (min-width: 1600px) { .brand-name { display: inline; } }
@media (min-width: 1721px) { .app { background: linear-gradient(var(--navy) 0 128px, var(--bg) 128px); padding: 19px 0; height: 100dvh; } .layout { height: calc(100dvh - 38px); } }
@media (max-width: 1280px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr); }
  .assign span { display: none; }
  .assign select { max-width: 180px; }
}
@media (max-width: 1040px) {
  .layout { grid-template-columns: 310px minmax(0, 1fr); }
  .conv { column-gap: 12px; padding: 0 10px; height: 70px; }
  .conv .avatar { width: 44px; height: 44px; font-size: 15px; }
  .brand-logo { height: 28px; }
  #sign-hint { display: none; }
  .msg { max-width: 86%; }
  .chat-head { flex-wrap: wrap; row-gap: 6px; padding: 8px 14px; }
  .chat-tools { width: 100%; justify-content: flex-end; }
  .chat-tools .assign { flex: 1; }
  .chat-tools select { width: 100%; max-width: none; }
}

/* ===== tablet/celular ===== */
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-logo { display: block; }
}
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); box-shadow: none; }
  .brand-logo { height: 30px; }
  .conv { padding: 0 14px; column-gap: 14px; height: 72px; }
  .conv .avatar { width: 49px; height: 49px; font-size: 16px; }
  .layout.open .list-pane { display: none; }
  .layout:not(.open) .chat-pane { display: none; }
  .back { display: grid; margin-left: -8px; }
  .chat-head { padding: 6px 10px; gap: 8px; flex-wrap: wrap; background: var(--head); color: var(--head-ink); border-left: 0; }
  .chat-head .muted, .chat-head .icon-btn { color: rgb(255 255 255 / .75); }
  .chat-head .btn { background: transparent; color: #fff; border-color: rgb(255 255 255 / .3); }
  .chat-head .avatar { width: 38px; height: 38px; font-size: 14px; }
  .chat-pane::before { background-size: 70% auto; }
  .messages { padding: 12px 14px; }
  .msg { max-width: 86%; }
  #sign-hint { display: none; }
  .composer { padding: 4px 6px calc(8px + env(safe-area-inset-bottom)); }
  .composer-row .icon-btn { width: 38px; }
  .grid2 { grid-template-columns: 1fr; }
  .window-closed { flex-direction: column; align-items: stretch; }
  .emoji-btn { display: none !important; }
}

/* ---------- setores (um WhatsApp por setor) ---------- */
.filters { align-items: center; min-width: 0; }
.setor-select { margin-left: auto; flex: 0 1 150px; width: 150px; min-width: 92px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 99px; padding: 5px 10px; font-size: 13px; font-weight: 600; cursor: pointer; text-overflow: ellipsis; }
.line-tag { display: inline-block; vertical-align: 1px; margin-right: 6px; padding: 0 7px; border-radius: 99px; font-size: 11px; font-weight: 700; line-height: 18px; background: color-mix(in srgb, currentColor 13%, transparent); white-space: nowrap; }
#chat-phone .line-tag { margin-right: 8px; }
.lines { display: grid; gap: 8px; }
.line-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.line-row.on { background: var(--accent-softer); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.line-row .grow { flex: 1; min-width: 0; }
.line-row .grow b { display: block; }
.line-row .grow span { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-row .btn { padding: 6px 10px; font-size: 13px; flex: none; }
.line-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.line-add { display: flex; gap: 8px; margin-top: 10px; }
.line-add input { flex: 1; min-width: 0; }
@media (max-width: 560px) {
  .line-row { flex-wrap: wrap; }
  .line-row .grow { flex-basis: calc(100% - 30px); }
  .line-row .btn.primary { margin-left: auto; }
}
.line-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.line-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.line-chip.on { border-style: solid; border-color: transparent; color: inherit; background: color-mix(in srgb, currentColor 14%, transparent); }
.line-chip:not(.on) { color: var(--muted) !important; }
.line-chip:hover { border-color: currentColor; }
.warn-text { font-size: 12px; color: var(--warn-ink); font-weight: 600; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }
.line-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.line-pick { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 14px; color: var(--text) !important; }
.line-pick input { width: auto !important; margin: 0; }
.team-row { align-items: flex-start; }
.team-row > .btn, .team-row > .avatar { margin-top: 2px; }

/* ---------- planos e demonstração ---------- */
.plan-use { font-size: 13px; color: var(--muted); background: var(--panel-2); border-radius: 10px; padding: 8px 12px; }
.plan-use b { color: var(--accent); }
.plan-use.full { background: var(--warn-bg); color: var(--warn-ink); }
.plan-use.full b { color: inherit; }
.demo-strip { margin: 8px 12px 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 12.5px; line-height: 1.45; }
.demo-strip b { color: var(--accent); }
.demo-pill { justify-self: start; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px; padding: 5px 12px; border-radius: 99px; letter-spacing: .02em; }
.demo-sub { margin: -6px 0 6px !important; }
.demo-btn { display: grid !important; justify-items: start; text-align: left; gap: 2px; padding: 14px 18px !important; }
.demo-btn b { font-size: 16px; }
.demo-btn small { font-size: 13px; font-weight: 400; opacity: .85; }
.demo-note { font-size: 13px; margin-top: 6px !important; }

/* ---------- marca Atende+ (BRAND=atende) ---------- */
:root[data-brand="atende"] {
  --navy: #0b3b5c; --sky: #5eead4; --gold: #fcd34d;
  --accent: #0f766e; --accent-hover: #0b5f58; --accent-soft: #d3f2ea; --accent-softer: #ecf9f5;
  --head: #0f766e; --out: #d3f5e7; --chat-bg: #e7efed; --read: #0ea5e9; --vignette: rgb(11 59 92 / .14);
}
@media (prefers-color-scheme: dark) {
  :root[data-brand="atende"] { --accent: #2dd4bf; --accent-hover: #5eead4; --accent-ink: #042f2e; --accent-soft: #10403b; --accent-softer: #0c302d;
    --head: #0c3b37; --out: #0f4a42; --chat-bg: #08161a; --vignette: rgb(0 0 0 / .45); }
}
:root[data-brand="atende"] .login-hero { background: radial-gradient(120% 100% at 0% 0%, #14b8a6 0%, #0f766e 45%, #0b3b5c 100%); }
:root[data-brand="atende"] .login-hero::before { background-image: url(/brand/atende-marca.png); opacity: .1; }
:root[data-brand="atende"] .chat-pane::before { background-image: url(/brand/atende-marca.png); }
:root[data-brand="atende"] .brand-name { color: #ccfbf1; }
:root[data-brand="atende"] .brand-logo { height: 26px; }
:root[data-brand="atende"] .empty-art img { height: 58px; }
