/* Connect Hub — tema de painel de atendimento (sem build). Contraste AA nas combinações de texto. */
:root {
  --bg: #f1f4f8; --surface: #fff; --surface-2: #f7f9fc; --border: #e1e6ee; --border-strong: #c6cfdb;
  --text: #19222e; --muted: #566377; --primary: #0a7d5c; --primary-hover: #086a4e; --primary-weak: #e2f4ec;
  --danger: #c62828; --focus: #1a73e8;
  --side: #0f1b2a; --side-2: #172638; --side-text: #c9d4e2; --side-muted: #8da0b6;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --blue-tick: #0b7be0;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 20px; } h3 { font-size: 16px; } h4 { font-size: 15px; }
p { margin: 0; }
a { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; width: 100%; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: #8ab4ff; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; background: #fff; padding: 8px 12px; border-radius: 8px; z-index: 1000; box-shadow: var(--shadow); }
.skip-link:focus { top: 8px; }
.noscript { padding: 2rem; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; } .pre { white-space: pre-wrap; }
.wrap-any { overflow-wrap: anywhere; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.grow { flex: 1; min-width: 0; } .flip { display: inline-flex; transform: scaleX(-1); }
.topbar-spacer { flex: 1; }
.icon { flex: none; vertical-align: middle; }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 8px; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.2; position: relative; }
.btn:hover:not(:disabled) { background: #f3f6fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a81f1f; }
.btn-danger-ghost { color: #b3261e; border-color: #efc2be; }
.btn-danger-ghost:hover:not(:disabled) { background: #fdeceb; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-left { margin-right: auto; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(120, 130, 145, .5); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary.is-busy::after { border-color: rgba(255, 255, 255, .5); border-top-color: #fff; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; background: transparent; color: inherit; border-radius: 8px; cursor: pointer; padding: 0; }
.icon-btn:hover:not(:disabled) { background: rgba(100, 116, 139, .14); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.link { color: var(--primary); font-weight: 500; }
.link-btn { border: 0; background: none; color: var(--primary); text-decoration: underline; cursor: pointer; padding: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; margin-bottom: 6px; }
.chip-btn { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; color: var(--text); }
.chip-btn:hover { background: #eef2f7; }
.chip-toggle[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
input[type=color] { width: 54px; height: 38px; padding: 2px; }
input[type=file] { padding: 6px; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: #667085; }
input:disabled, select:disabled, textarea:disabled { background: #f0f2f5; color: #6b7686; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label-like { font-weight: 600; font-size: 13px; }
.req { color: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); }
.warn-text { color: #8a5300; font-weight: 500; }
.form-error { color: #b3261e; font-weight: 500; font-size: 13px; }
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 14px; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.fieldset legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.radios { display: flex; flex-wrap: wrap; gap: 14px; }
.radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.input-group { display: flex; gap: 6px; align-items: center; }
.input-group .input-btn { border: 1px solid var(--border-strong); flex: none; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field:first-child { flex: 1; min-width: 200px; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions.wrap { flex-wrap: wrap; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; } }

/* ---------- peças comuns ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 16px; text-align: center; color: var(--muted); }
.state-loading { flex-direction: row; justify-content: center; }
.state-empty strong { color: var(--text); font-size: 15px; }
.state-error { color: #b3261e; }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-green { background: #dff3ea; color: #086446; } .pill-red { background: #fde7e5; color: #a8231b; } .pill-amber { background: #fff1d6; color: #7d4a00; }
.pill-blue { background: #e3eeff; color: #1b55b0; } .pill-gray { background: #eceff4; color: #3f4b5e; } .pill-violet { background: #efe7fb; color: #5d33a3; }
.tag { --tag: #22c55e; display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: color-mix(in srgb, var(--tag) 16%, white); border: 1px solid color-mix(in srgb, var(--tag) 45%, white); color: #1e2a38; max-width: 160px; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tag); flex: none; }
.tag-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-x { display: inline-flex; border: 0; background: transparent; cursor: pointer; padding: 1px; color: inherit; border-radius: 50%; }
.tag-x:hover { background: rgba(0, 0, 0, .12); }
.tags-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.avatar { width: var(--sz, 40px); height: var(--sz, 40px); border-radius: 50%; background: var(--av, #475467); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: calc(var(--sz, 40px) * .38); flex: none; }
.pv { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 7px; color: #fff; flex: none; }
.pv-uazapi { background: #128c4a; } .pv-umclique { background: #6d3fc0; } .pv-meta { background: #0b6bcb; } .pv-instagram { background: linear-gradient(135deg, #f58529, #dd2a7b 55%, #8134af); } .pv-fake { background: #5b6678; }
.badge { background: var(--primary); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; }
.banner-text { flex: 1; }
.banner-warn { background: #fff4d9; color: #6b4200; border: 1px solid #f0d28a; border-radius: 0; border-left: 0; border-right: 0; }
.banner-error { background: #fde7e5; color: #8f1d17; border: 1px solid #f1b9b4; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #fafbfd; } .table tr.is-off { opacity: .65; }
.table-card { padding: 0; overflow: hidden; gap: 0; }
.is-loading { opacity: .55; transition: opacity .15s; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin: 0; }
.kv dt { font-size: 12px; color: var(--muted); } .kv dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 170px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 12px; flex-wrap: wrap; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 32px; }
.switch { width: 44px; height: 24px; border-radius: 999px; border: 0; background: #98a2b3; position: relative; cursor: pointer; padding: 0; transition: background .15s; flex: none; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }
.switch-wrap { display: flex; align-items: center; gap: 8px; }
.var-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.var-buttons .chip-btn { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 16px; left: 248px; z-index: 900; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 28px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 11px 8px 11px 14px; border-radius: 10px; background: #1f2a3a; color: #fff; box-shadow: 0 6px 20px rgba(15, 27, 42, .28); animation: toast-in .18s ease-out; }
.toast .icon { margin-top: 2px; } .toast-msg { flex: 1; overflow-wrap: anywhere; }
.toast-success { background: #0b6b4e; } .toast-error { background: #b42318; } .toast-warn { background: #8a5300; }
.toast-close { width: 26px; height: 26px; color: #fff; } .toast-close:hover { background: rgba(255, 255, 255, .18) !important; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- modais e popovers ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 27, 42, .55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 800; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(15, 27, 42, .35); }
.modal-sm { max-width: 430px; } .modal-lg { max-width: 860px; } .modal-xl { max-width: 1080px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow: auto; flex: 1; min-height: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.modal-footer:empty { display: none; }
.confirm-msg { font-size: 14.5px; }
.popover { position: fixed; z-index: 700; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 27, 42, .22); max-width: calc(100vw - 16px); max-height: 70vh; overflow: auto; }
.pop-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.pop-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pop-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--text); }
.pop-item:hover { background: #eef2f7; }
.pick-list { margin-top: 10px; max-height: 320px; overflow: auto; }
.tag-form { display: flex; flex-direction: column; gap: 8px; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: var(--sw); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }

/* ---------- login ---------- */
.login-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #1d3a57 0, transparent 60%), var(--side); }
.login-card { background: var(--surface); width: min(100%, 400px); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.login-card h1 { font-size: 22px; }
.brand-lg { color: var(--text) !important; font-size: 20px !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100dvh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 14px 10px; gap: 14px; z-index: 600; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #fff; padding: 4px 8px; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--side-text); text-decoration: none; font-weight: 500; position: relative; }
.nav-link:hover { background: var(--side-2); color: #fff; }
.nav-link.active { background: #1f3550; color: #fff; }
.nav-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #2fd39b; }
.nav-label { flex: 1; }
.nav-badge { background: #2fd39b; color: #06281d; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--side-muted); }
.stream-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; } .stream-dot[data-ok="1"] { background: #2fd39b; } .stream-dot[data-ok="0"] { background: #f5a524; }
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 18px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; }
.page-title { font-size: 17px; }
.topbar-btn { color: var(--muted); } .menu-btn { display: none; }
.presence-box { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 8px 0 12px; height: 34px; }
.presence-select { border: 0; background: transparent; padding: 0 4px; width: auto; font-weight: 500; cursor: pointer; }
.presence-select:focus-visible { outline-offset: 4px; }
.presence-dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; } .presence-dot[data-p="online"] { background: #16a34a; } .presence-dot[data-p="away"] { background: #f59e0b; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 4px; } .user-name { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; min-height: 0; overflow: auto; outline: none; }
.main[data-view="chat"] { overflow: hidden; }
.page { padding: 22px 26px 40px; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.page-narrow { max-width: 920px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.sidebar-backdrop { display: none; }

/* ---------- início ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-decoration: none; color: inherit; height: 100%; }
a.stat-card:hover { border-color: var(--primary); }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tone-green { background: #dff3ea; color: #086446; } .tone-amber { background: #fff1d6; color: #7d4a00; } .tone-blue { background: #e3eeff; color: #1b55b0; } .tone-red { background: #fde7e5; color: #a8231b; } .tone-violet { background: #efe7fb; color: #5d33a3; }
.stat-text { display: flex; flex-direction: column; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; } .stat-value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; background: var(--surface); }
.conv-panel { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; min-width: 0; padding-top: 12px; gap: 10px; background: var(--surface); }
.conv-panel > * { margin-left: 14px; margin-right: 14px; }
.conv-head { display: flex; justify-content: space-between; align-items: center; }
.seg { display: flex; background: #eceff4; border-radius: 9px; padding: 3px; gap: 2px; }
.seg-btn { flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: #fff; color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.filter-row { display: flex; gap: 6px; align-items: center; }
.filter-row select { flex: 1 1 0; font-size: 12.5px; padding: 6px 4px 6px 8px; text-overflow: ellipsis; }
.filter-row .chip-btn { white-space: nowrap; padding: 6px 10px; }
.conv-scroll { flex: 1; overflow-y: auto; margin: 0; border-top: 1px solid var(--border); min-height: 0; }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-li { border-bottom: 1px solid #edf0f5; }
.conv-item { display: flex; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: transparent; cursor: pointer; color: inherit; border-left: 3px solid transparent; }
.conv-item:hover { background: #f5f8fb; } .conv-item.active { background: var(--primary-weak); border-left-color: var(--primary); }
.conv-item:focus-visible { outline-offset: -2px; }
.conv-av { position: relative; flex: none; }
.conv-pv { position: absolute; right: -4px; bottom: -3px; display: inline-flex; }
.conv-pv .pv { width: 18px; height: 18px; border-radius: 6px; border: 2px solid #fff; }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .conv-name { font-weight: 700; }
.conv-time { font-size: 12px; color: var(--muted); flex: none; } .conv-item.unread .conv-time { color: var(--primary); font-weight: 600; }
.conv-pin { color: var(--muted); display: inline-flex; }
.conv-last { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conv-item.unread .conv-last { color: var(--text); font-weight: 500; }
.conv-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.conv-meta .tag { font-size: 11px; padding: 0 6px; max-width: 110px; }
.conv-assignee { display: inline-flex; align-items: center; gap: 2px; background: #eceff4; border-radius: 999px; padding: 0 6px; }
.conv-channel { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.conv-state .state { padding: 28px 14px; } .conv-scroll > .btn { margin: 10px 14px; width: calc(100% - 28px); }
.thread-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e9edf2; position: relative; }
.thread-empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); padding: 24px; text-align: center; }
.thread-empty h2 { color: var(--text); }
.thread-main { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.thread-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.back-btn { display: none; }
.thread-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thread-id-text { min-width: 0; }
.thread-name { font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.thread-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.thread-sub .pv { width: 18px; height: 18px; border-radius: 5px; }
.thread-tags { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 80px; }
.thread-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.assign-wrap { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.assign-sel { width: auto; max-width: 170px; padding: 5px 8px; font-size: 13px; }
.thread-actions .compact { padding: 5px 8px; }
.thread-actions .compact .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thread-actions .btn[aria-pressed="true"] { background: var(--primary-weak); border-color: var(--primary); }
.thread-body { flex: 1; min-height: 0; position: relative; display: flex; }
.thread-scroll { flex: 1; overflow-y: auto; padding: 14px 18px 8px; scroll-behavior: auto; background: #e9edf2; outline-offset: -2px; }
.msg-list { display: flex; flex-direction: column; gap: 3px; }
.older-btn { display: block; margin: 0 auto 10px; }
.thread-state .state { padding: 24px; }
.new-pill { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: inline-flex; gap: 6px; align-items: center; background: var(--primary); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); font-weight: 600; font-size: 13px; }
.day-sep { text-align: center; margin: 10px 0 6px; } .day-sep span { background: #fff; border-radius: 8px; padding: 3px 12px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow); }
.msg { display: flex; } .msg-in { justify-content: flex-start; } .msg-out { justify-content: flex-end; } .msg-note { justify-content: center; }
.bubble { max-width: min(560px, 82%); padding: 7px 10px 5px; border-radius: 10px; box-shadow: 0 1px 1px rgba(16, 24, 40, .1); overflow-wrap: anywhere; min-width: 0; }
.msg-in .bubble { background: #fff; border-top-left-radius: 2px; } .msg-out .bubble { background: #d4f1e3; border-top-right-radius: 2px; }
.msg-note .bubble { background: #fff3bf; border: 1px solid #e6cf6e; max-width: min(620px, 90%); }
.msg-out[data-status="failed"] .bubble { background: #fde9e7; border: 1px solid #f2b5af; }
.bubble-author, .bubble-tag { font-size: 11.5px; font-weight: 700; color: #3f4b5e; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.msg-note .bubble-tag { color: #6b5200; } .bubble-tag.tpl { color: #5d33a3; }
.msg-text { white-space: pre-wrap; } .msg-text a { color: #0b5cad; }
.bubble-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: #5b6778; margin-top: 2px; }
.ticks { display: inline-flex; color: #5b6778; } .tick-read { color: var(--blue-tick); } .tick-failed { color: var(--danger); } .tick-queued { color: #7b8798; }
.msg-error { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: #a8231b; font-size: 12.5px; font-weight: 500; margin-top: 4px; }
.media-link { display: block; margin-bottom: 4px; } .media-link img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; background: #dde3ea; }
.media-fail { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; background: #eef1f5; border-radius: 8px; color: var(--muted); }
.media-video { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 4px; } .media-audio { display: block; width: 260px; max-width: 100%; margin-bottom: 4px; }
.doc-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(0, 0, 0, .06); border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 4px; max-width: 100%; }
.doc-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 8px 14px 8px; display: flex; flex-direction: column; gap: 8px; flex: none; }
.composer.is-note { background: #fff9d9; }
.ctabs { display: flex; gap: 4px; }
.ctab { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.ctab[aria-selected="true"] { background: var(--primary-weak); color: var(--primary); } .ctab-note[aria-selected="true"] { background: #fbe9a1; color: #6b5200; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer-btn { color: var(--muted); flex: none; height: 40px; width: 40px; }
.composer-input { position: relative; flex: 1; min-width: 0; }
.composer-input textarea { min-height: 40px; max-height: 170px; border-radius: 12px; resize: none; line-height: 1.4; }
.send-btn { height: 40px; flex: none; }
.composer-hint { padding-left: 4px; }
.qr-pop { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 27, 42, .2); max-height: 220px; overflow: auto; z-index: 20; }
.qr-item { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; align-items: baseline; }
.qr-item strong { flex: none; color: var(--primary); } .qr-item span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-item.active, .qr-item:hover { background: var(--primary-weak); } .qr-empty { padding: 8px 10px; color: var(--muted); }
.qr-manage .pre { max-width: 100%; }
.attach-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.attach-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #dde3ea; }
.attach-ico { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.attach-info { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; } .attach-info .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-panel { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.attach-grid { display: grid; grid-template-columns: 1fr 160px; gap: 10px; }
.tpl-params { display: flex; flex-direction: column; gap: 10px; }
.tpl-preview { background: #d4f1e3; border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font: inherit; margin: 0; }

/* ---------- canais ---------- */
.channel-groups { display: flex; flex-direction: column; gap: 22px; }
.group-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.count { background: #e3e8ef; color: var(--text); border-radius: 999px; padding: 0 8px; font-size: 12px; letter-spacing: 0; }
.ch-card.is-off { background: #f7f8fa; } .ch-card.is-off .ch-title h4 { color: var(--muted); }
.ch-top { display: flex; align-items: center; gap: 10px; } .ch-top .pv { width: 36px; height: 36px; border-radius: 10px; }
.ch-title { flex: 1; min-width: 0; display: flex; flex-direction: column; } .ch-title h4 { overflow: hidden; text-overflow: ellipsis; }
.ch-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.webhook-panel { border-top: 1px dashed var(--border-strong); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.webhook-panel.embedded { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface-2); margin-top: 12px; }
.wh-label { font-weight: 600; font-size: 13px; }
.wh-verify { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .wh-verify code { background: #eef1f5; border-radius: 6px; padding: 3px 8px; overflow-wrap: anywhere; }
.wh-steps { margin: 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

.ch-warn { display: flex; gap: 6px; align-items: flex-start; margin: 0; padding: 8px 10px; border-radius: 8px; background: #fff4d9; color: #6b4200; font-size: 12.5px; }
.ch-warn .icon { margin-top: 2px; }

/* ---------- contatos ---------- */
.report { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.rep-stat { border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; } .rep-stat strong { font-size: 22px; line-height: 1.1; }
.import-result { margin-top: 4px; }

/* ---------- disparos ---------- */
.bc-list { display: flex; flex-direction: column; gap: 12px; }
.bc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.bc-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .bc-title h3 a { text-decoration: none; color: var(--text); } .bc-title h3 a:hover { color: var(--primary); }
.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress { height: 10px; background: #e5e9f0; border-radius: 999px; overflow: hidden; }
.progress-bar { display: block; height: 100%; width: var(--pct, 0%); background: linear-gradient(90deg, #0a7d5c, #2fd39b); border-radius: 999px; transition: width .4s ease; }
.pause-note { display: flex; gap: 6px; align-items: flex-start; margin: 0; padding: 8px 10px; border-radius: 8px; background: #fff4d9; color: #6b4200; font-size: 13px; }
.progress-counts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; } .progress-counts strong { color: var(--text); } .progress-pct { margin-left: auto; font-weight: 600; color: var(--text); }
.bc-detail-head { margin-bottom: 14px; } .detail-msg { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.bc-form-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.bc-preview { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; }
.wa-phone { background: #e5ddd5; border-radius: 18px; overflow: hidden; border: 1px solid var(--border-strong); min-height: 260px; display: flex; flex-direction: column; }
.wa-head { background: #0b5e4d; color: #fff; padding: 10px 12px; display: flex; align-items: center; gap: 8px; } .wa-dot { width: 26px; height: 26px; border-radius: 50%; background: #9bb; display: inline-block; } .wa-sub { margin-left: auto; font-size: 12px; opacity: .85; }
.wa-body { padding: 14px 12px; flex: 1; }
.wa-bubble { background: #d9fdd3; border-radius: 10px 10px 2px 10px; padding: 6px 8px 4px; margin-left: auto; max-width: 92%; box-shadow: 0 1px 1px rgba(0, 0, 0, .13); display: flex; flex-direction: column; gap: 4px; }
.wa-text { white-space: pre-wrap; overflow-wrap: anywhere; color: #111b21; } .wa-placeholder { color: #5b6a72; font-style: italic; }
.wa-media { max-width: 100%; border-radius: 8px; display: block; } .wa-file { display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .07); border-radius: 8px; padding: 8px; font-size: 13px; color: #111b21; }
.wa-meta { align-self: flex-end; font-size: 11px; color: #5b6a72; display: flex; align-items: center; gap: 3px; } .wa-ticks { color: var(--blue-tick); display: inline-flex; }

/* ---------- automações ---------- */
.flow-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.flow-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.flow-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; } .flow-title h3 a { color: var(--text); text-decoration: none; } .flow-title h3 a:hover { color: var(--primary); }
.flow-card.is-off { background: #f8f9fb; }
.editor { display: flex; flex-direction: column; gap: 14px; }
.kw-box { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px; background: #fff; }
.kw-box:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }
.kw-box input { border: 0; padding: 4px 6px; outline: 0 !important; }
.kw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; } .kw-list:empty { display: none; }
.kw { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-weak); color: #064d38; border-radius: 999px; padding: 2px 6px 2px 10px; font-weight: 500; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.step { border: 1px solid var(--border-strong); border-radius: 12px; background: #fff; }
.step.has-error { border-color: var(--danger); box-shadow: 0 0 0 2px #fbd6d3; }
.step.dragging { opacity: .45; } .step.drop-target { border-color: var(--primary); box-shadow: 0 0 0 2px #bfe8d8; }
.step-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.step-head select { width: auto; min-width: 190px; padding: 5px 8px; }
.step-num { font-weight: 700; color: var(--muted); }
.grip { cursor: grab; color: var(--muted); display: inline-flex; padding: 4px; }
.step-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.step-error { padding: 0 12px 10px; }
.steps-empty { padding: 10px; }
.add-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.url-row { grid-template-columns: 130px 1fr; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .chat { grid-template-columns: 320px minmax(0, 1fr); }
  .bc-form-cols { grid-template-columns: 1fr; } .bc-preview { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s, box-shadow .2s; }
  .sidebar-open .sidebar { transform: none; box-shadow: 6px 0 24px rgba(0, 0, 0, .3); }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 500; }
  .menu-btn { display: inline-flex; }
  .user-name, .presence-select { font-size: 13px; } .user-name { display: none; }
  .topbar { padding: 0 10px; }
  .chat { grid-template-columns: minmax(0, 1fr); }
  .thread-panel { display: none; } .chat.show-thread .conv-panel { display: none; } .chat.show-thread .thread-panel { display: flex; }
  .back-btn { display: inline-flex; }
  .thread-actions { margin-left: 0; width: 100%; }
  .thread-actions .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .composer-hint { display: none; }
  .page { padding: 16px 14px 32px; }
  .toasts { left: 14px; bottom: 14px; }
  .two-cols, .attach-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 8px; align-items: flex-end; } .modal { max-height: calc(100dvh - 16px); border-radius: 14px 14px 0 0; }
  .send-btn .btn-label { display: none; }
}
@media (max-width: 520px) {
  .card-grid, .flow-list { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; } .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; } .stat-value { font-size: 22px; }
}
