/* =========================================================
   Recadô Zap — tema do painel
   ========================================================= */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8ee;
  --border-strong: #d3d9e2;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #059669;
  --primary-600: #047857;
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --accent: #25d366;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warning: #b45309;
  --warning-50: #fffbeb;
  --info: #2563eb;
  --info-50: #eff6ff;
  --sidebar: #0b1f19;
  --sidebar-2: #10291f;
  --sidebar-text: #a7c4b8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --ring: 0 0 0 4px rgba(5, 150, 105, .15);
  --sidebar-w: 248px;
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
[hidden] { display: none !important; }
h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
h3 { margin: 0 0 10px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
h4 { margin: 4px 0 8px; font-size: 14px; }
code { background: #eef2f6; padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); font-weight: normal; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0 10px; }

/* permissões por perfil */
body:not(.is-admin) [data-admin] { display: none !important; }
body.is-admin .user-only { display: none !important; }
body:not(.can-templates) [data-tpl-manager] { display: none !important; }
body:not(.is-super) [data-super] { display: none !important; }

/* =========================================================
   Estrutura: menu lateral + conteúdo
   ========================================================= */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar) 0%, #0d2a20 100%);
  color: var(--sidebar-text); padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; }
.brand b { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand small { display: block; font-size: 11.5px; color: var(--sidebar-text); }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--primary)); color: #fff;
  box-shadow: 0 6px 18px rgba(37, 211, 102, .35);
}
.logo svg { width: 22px; height: 22px; }
img.logo { background: none; display: block; }
.forgot-link { text-align: right; margin: -6px 0 4px; font-size: 13px; }
.forgot-link a { color: var(--primary-600); font-weight: 600; }
.alert.ok { background: var(--primary-50); color: #065f46; border-color: var(--primary-100); }
.login-links { text-align: center; font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.login-links a { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f8f82; padding: 14px 12px 6px; }
.tab {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--sidebar-text); font: inherit; font-weight: 500;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background .15s, color .15s;
}
.tab:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.tab.active { background: rgba(37, 211, 102, .14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.tab.active svg { color: var(--accent); }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; margin-top: 10px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #1e4a3a; color: #d1fae5; font-weight: 700; font-size: 13px;
}
.user-meta { min-width: 0; }
.user-meta #user-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--sidebar-text); font-size: 12px; }
.user-actions { display: flex; gap: 6px; }
.side-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255, 255, 255, .06); border: 0; color: var(--sidebar-text); font: inherit; font-size: 12.5px;
  padding: 8px; border-radius: 9px; cursor: pointer;
}
.side-btn svg { width: 15px; height: 15px; }
.side-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 12px 32px; background: rgba(243, 245, 248, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-weight: 600; color: var(--text-2); }
.account { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-toggle { display: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 7px; cursor: pointer; color: var(--text); }
.backdrop { display: none; }
main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 64px; }

/* =========================================================
   Blocos
   ========================================================= */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar.small { margin-bottom: 12px; }
.toolbar.small h3 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.grid-2.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 4px 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.top-gap { margin-top: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.empty {
  text-align: center; color: var(--muted); padding: 56px 20px; background: var(--surface);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
}
.alert { background: var(--danger-50); color: #991b1b; border: 1px solid #fecaca; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin: 10px 0; }

/* =========================================================
   Formulários
   ========================================================= */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.stack-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.stack-field > span { font-weight: 600; font-size: 13px; color: var(--text-2); }
.stack-field .hint { margin: 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; margin-top: 10px; }
.inline-field { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:hover, select:hover, textarea:hover { border-color: #b8c2cf; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; padding: 0; box-shadow: none; }
input[type="file"] { padding: 8px; background: var(--surface-2); }
textarea { resize: vertical; width: 100%; line-height: 1.5; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
legend { font-weight: 650; padding: 0 6px; color: var(--text-2); }

.btn {
  font: inherit; font-weight: 600; font-size: 13.5px; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: #b8c2cf; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(5, 150, 105, .3), 0 4px 12px rgba(5, 150, 105, .2); }
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--danger-50); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(15, 23, 42, .05); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px 16px; font-size: 14.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.linklike { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* =========================================================
   Tabelas
   ========================================================= */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; transition: background .12s; }
tr.clickable:hover td { background: #f6fbf9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
td.err { color: #b91c1c; font-size: 12.5px; max-width: 420px; cursor: help; }
.err-hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.failure-list { display: grid; gap: 8px; }
.failure-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); cursor: help; }
.failure-item .hint { margin: 2px 0 0; }
.failure-item.clickable-item { cursor: pointer; transition: border-color .15s, background .15s; }
.failure-item.clickable-item:hover { border-color: #9fb3c4; background: #fff; }
.failure-item.selected { border-color: var(--primary); background: var(--primary-50); box-shadow: inset 3px 0 0 var(--primary); }
.failure-count { font-size: 18px; font-weight: 700; color: #b91c1c; font-variant-numeric: tabular-nums; }
td.check, th.check { width: 40px; }
td.fields { color: var(--muted); font-size: 12.5px; max-width: 280px; }
td.detail { font-size: 12.5px; color: var(--muted); max-width: 420px; word-break: break-word; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; }
#msg-search, #audit-search, #template-search, #optout-search { min-width: 260px; }

/* =========================================================
   Selos, progresso e indicadores
   ========================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #f1f5f9; color: #475569; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.b-running, .b-sending, .b-pending, .b-scheduled, .b-trial { background: var(--info-50); color: #1d4ed8; }
.b-finished, .b-approved, .b-delivered, .b-read, .b-green, .b-active { background: var(--primary-50); color: #047857; }
.b-sent { background: #f0fdfa; color: #0f766e; }
.b-paused, .b-yellow, .b-in_appeal, .b-suspended, .b-awaiting_payment { background: var(--warning-50); color: var(--warning); }
.b-failed, .b-rejected, .b-cancelled, .b-disabled, .b-red { background: var(--danger-50); color: #b91c1c; }
.b-skipped, .b-draft { background: #f1f5f9; color: #475569; }

.progress { display: inline-block; width: 120px; height: 8px; background: #e8edf2; border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; }
.progress.big { width: 100%; height: 10px; margin: 16px 0 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat .p { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-left: 4px; }
.stat.highlight { background: linear-gradient(135deg, #064e3b, #047857); border-color: transparent; color: #fff; grid-column: span 2; }
.stat.highlight .l, .stat.highlight .p { color: #a7f3d0; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat.highlight .sub { color: #d1fae5; }

.detail-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.detail-head h2 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.detail-head .muted { margin-top: 6px; line-height: 1.7; }
.cost-cell { font-weight: 600; font-variant-numeric: tabular-nums; }

/* =========================================================
   Campanha: mapeamento e agendamento
   ========================================================= */
.slot-row { display: grid; grid-template-columns: minmax(160px, 220px) minmax(160px, 1fr) minmax(160px, 1fr); gap: 10px; align-items: center; margin-bottom: 10px; }
.slot-label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.audience-count { font-weight: 600; color: var(--primary-600); }
.audience-count.warn { color: var(--danger); }
.when { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.when .check { margin: 0; }
.when input[type="datetime-local"] { margin-left: 26px; }

/* =========================================================
   Templates e pré-visualização WhatsApp
   ========================================================= */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; }
.tpl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; }
.tpl-card:hover { box-shadow: 0 8px 28px rgba(15, 23, 42, .1); transform: translateY(-1px); }
.tpl-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.tpl-card-head b { word-break: break-all; }
.tpl-card-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: auto; }
.tpl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
.tpl-side { position: sticky; top: 80px; align-self: start; }
.btn-row { display: grid; grid-template-columns: 110px 1fr 1fr 1fr auto; gap: 6px; align-items: center; }
.btn-row[data-type="QUICK_REPLY"] { grid-template-columns: 110px 1fr auto; }
.btn-row[data-type="PHONE_NUMBER"] { grid-template-columns: 110px 1fr 1fr auto; }
.btn-type { font-size: 12px; color: var(--muted); font-weight: 600; }
#body-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
#body-examples label { margin: 0; }

.wa-preview {
  background-color: #efeae2; border-radius: var(--radius); padding: 18px; min-height: 130px;
  background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px); background-size: 14px 14px;
}
.wa-preview.small { padding: 12px; min-height: 0; max-height: 330px; overflow: auto; }
.wa-bubble { background: #fff; border-radius: 0 10px 10px 10px; max-width: 330px; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); overflow: hidden; }
.wa-inner { padding: 8px 10px 6px; }
.wa-head { font-weight: 700; margin-bottom: 4px; }
.wa-media { background: #d6dde3; color: #475569; text-align: center; padding: 30px 8px; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.wa-media small { display: block; font-weight: normal; word-break: break-all; margin-top: 4px; letter-spacing: 0; }
.wa-media-img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.wa-body { word-wrap: break-word; line-height: 1.45; color: #111b21; }
.wa-footer { color: #8696a0; font-size: 12px; margin-top: 6px; }
.wa-time { text-align: right; color: #8696a0; font-size: 11px; }
.wa-buttons { border-top: 1px solid #eef0f2; }
.wa-btn { text-align: center; color: #0a7cff; padding: 9px; border-top: 1px solid #eef0f2; font-size: 13.5px; font-weight: 500; }
.wa-btn:first-child { border-top: 0; }
.var { background: #d9fdd3; border-radius: 4px; padding: 0 3px; }

/* =========================================================
   Contatos e tags
   ========================================================= */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  display: inline-flex; flex-direction: row; align-items: center; gap: 7px; padding: 6px 12px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; cursor: pointer;
  font-size: 13px; font-weight: 500; margin: 0; user-select: none; transition: border-color .15s, background .15s;
}
.chip input { margin: 0; }
.chip:hover { border-color: #9fb3c4; }
.chip:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.chip .count { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 1px 3px 1px 0; white-space: nowrap; }
.tag-gray { background: #f1f5f9; color: #475569; }
.tag-blue { background: #eff6ff; color: #1d4ed8; }
.tag-green { background: #ecfdf5; color: #047857; }
.tag-yellow { background: #fefce8; color: #a16207; }
.tag-orange { background: #fff7ed; color: #c2410c; }
.tag-red { background: #fef2f2; color: #b91c1c; }
.tag-purple { background: #f5f3ff; color: #6d28d9; }
.tag-teal { background: #f0fdfa; color: #0f766e; }
.filters { margin-bottom: 14px; }
.filters input[type="search"] { min-width: 280px; }
.bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--primary-50);
  border: 1px solid #a7f3d0; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
}
.bulk-bar #bulk-count { font-weight: 700; color: var(--primary-600); margin-right: 6px; }
/* aviso da assinatura (suspensa, teste vencido, WhatsApp não conectado) */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--warning-50); border: 1px solid #fde68a; color: #92400e;
  padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px;
}
.banner.danger { background: var(--danger-50); border-color: #fecaca; color: #991b1b; }
.plan-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.plan-head b { font-size: 18px; letter-spacing: -.01em; }
.meters { display: grid; gap: 12px; margin-top: 14px; }
.meter-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.meter-row .progress { grid-column: 1 / -1; width: 100%; margin: 0; }
.meter-row .progress.full > span { background: #d97706; }
.meter-row .progress.over > span { background: var(--danger); }
.meter-row .hint { grid-column: 1 / -1; margin: 0; }
.es-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--primary-50); border: 1px solid var(--primary-100); border-radius: var(--radius-sm); padding: 14px 16px; margin: 12px 0; }
.es-box > div { flex: 1 1 320px; }
.es-box > .es-actions { flex: 0 1 auto; display: flex; flex-direction: column; gap: 8px; }
.slug-field { display: flex; align-items: center; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden; font-weight: 500; }
.slug-field > span { padding: 0 10px; color: var(--muted); font-size: 13px; white-space: nowrap; background: var(--surface-2); align-self: stretch;
  display: flex; align-items: center; }
.slug-field input { border: 0 !important; box-shadow: none !important; border-radius: 0; flex: 1; min-width: 80px; }
.coex-sync { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 14px; font-size: 13.5px; }
.coex-sync dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; }
.coex-sync dt { color: var(--muted); }
.coex-sync dd { margin: 0; }
.coex-sync .coex-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 0; }
.coex-sync .coex-err { color: #991b1b; margin: 10px 0 0; }
.coex-sync p.muted { margin: 10px 0 0; }
@media (max-width: 560px) { .coex-sync dl { grid-template-columns: 1fr; } }
.coex-info { background: var(--info-50); border: 1px solid #bfdbfe; color: #1e3a8a; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; margin: 0 0 12px; }
.es-box .hint { margin: 4px 0 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 13px; }
.kv code { word-break: break-all; }
.select-all-hint { background: var(--warning-50); border: 1px solid #fde68a; padding: 9px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 13px; }
#ninth-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ok-text { color: var(--primary-600); }

/* =========================================================
   Segurança
   ========================================================= */
.checks { display: grid; gap: 10px; }
.check-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.check-item .dot { width: 22px; height: 22px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.check-item .dot.ok { background: var(--primary); }
.check-item .dot.bad { background: #d97706; }
.check-item .hint { margin: 2px 0 0; }
.switch { flex-direction: row; align-items: center; gap: 8px; margin: 0; font-weight: 600; cursor: pointer; }
.qr { width: 200px; height: 200px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.qr svg { width: 100%; height: 100%; stroke: none; fill: initial; }

/* =========================================================
   Janelas e avisos
   ========================================================= */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(580px, 94vw); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); }
.dlg-body { padding: 24px; display: flex; flex-direction: column; gap: 6px; }
.dlg-body > h3 { font-size: 18px; margin-bottom: 12px; }
.dlg-body > label { margin-bottom: 4px; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.spacer { flex: 1; }
.field-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.tag-row { display: grid; grid-template-columns: 1fr 130px 60px auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 12px; max-width: min(640px, 92vw);
  box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .2s ease-out;
}
#toast.err { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* =========================================================
   Login
   ========================================================= */
.login-page { min-height: 100vh; background: var(--bg); }
.login-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-hero {
  position: relative; overflow: hidden; color: #e7f7f0; padding: 48px 56px; display: flex; flex-direction: column;
  background:
    radial-gradient(800px 400px at 110% 0%, rgba(37, 211, 102, .25), transparent 60%),
    radial-gradient(600px 400px at -10% 110%, rgba(16, 185, 129, .25), transparent 60%),
    linear-gradient(160deg, #0b1f19 0%, #0f3a2c 100%);
}
.login-hero .brand { padding: 0; }
.login-hero h1 { font-size: 38px; line-height: 1.15; letter-spacing: -.03em; margin: auto 0 14px; max-width: 520px; color: #fff; }
.login-hero p { color: #a7c4b8; font-size: 16px; max-width: 480px; margin: 0 0 28px; }
.hero-points { list-style: none; padding: 0; margin: 0 0 auto; display: grid; gap: 10px; color: #d1fae5; }
.hero-points li { display: flex; align-items: center; gap: 10px; }
.hero-points svg { color: var(--accent); }
.hero-chat { position: absolute; right: 48px; top: 110px; display: grid; gap: 10px; width: 260px; opacity: .95; }
.hero-chat .msg { background: #fff; color: #111b21; border-radius: 0 12px 12px 12px; padding: 10px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.hero-chat .msg.out { background: #d9fdd3; border-radius: 12px 0 12px 12px; justify-self: end; width: 80%; }
.hero-chat .msg small { display: block; text-align: right; color: #667781; font-size: 11px; margin-top: 4px; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin: 0 0 26px; }
.login-card label { margin-bottom: 16px; }
.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 44px; }
.password-field button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.password-field button:hover { color: var(--text); background: var(--surface-2); }
.login-foot { color: var(--muted); font-size: 12.5px; margin-top: 28px; display: flex; align-items: center; gap: 6px; }
.login-foot svg { width: 14px; height: 14px; color: var(--primary); }
.code-input { text-align: center; font-size: 24px; letter-spacing: .4em; font-weight: 700; padding: 12px; }

/* =========================================================
   Dashboard e gráficos
   ========================================================= */
.chart { position: relative; min-height: 230px; --series-1: #059669; --series-2: #2a78d6; --grid: #e8ecf1; --axis: #cbd3dc; }
.chart svg { width: 100%; height: auto; display: block; stroke: none; fill: none; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .peak { fill: var(--text-2); font-size: 11.5px; font-weight: 600; }
.chart .bar { transition: opacity .12s; }
.chart.hovering .bar { opacity: .35; }
.chart.hovering .bar.on { opacity: 1; }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: #0f172a; color: #fff; border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; box-shadow: var(--shadow-lg); min-width: 170px; line-height: 1.6;
}
.chart-tip b { display: block; margin-bottom: 2px; }
.chart-tip .k { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip .k span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.table-toggle summary { cursor: pointer; font-weight: 600; color: var(--text-2); }
.nav-badge { margin-left: auto; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.meter { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.meter-track { flex: 1; height: 8px; border-radius: 99px; background: #d1fae5; overflow: hidden; }
.meter-track > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.meter.warn .meter-track { background: #fef3c7; } .meter.warn .meter-track > span { background: #d97706; }
.meter.crit .meter-track { background: #fee2e2; } .meter.crit .meter-track > span { background: #dc2626; }
.meter small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.alerts-card h3 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.alert-item:first-of-type { border-top: 0; }
.alert-icon { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.alert-icon.critical { background: #dc2626; } .alert-icon.warning { background: #d97706; } .alert-icon.info { background: #2563eb; }
.alert-item .when { color: var(--muted); font-size: 12px; }

/* =========================================================
   Responsivo
   ========================================================= */
@media (max-width: 1100px) {
  .hero-chat { display: none; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 30; }
  .shell { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .appbar { padding: 10px 16px; }
  main { padding: 20px 16px 48px; }
  .tpl-layout { grid-template-columns: 1fr; }
  .tpl-side { position: static; }
  .slot-row, .btn-row, .btn-row[data-type], .tag-row, .field-row { grid-template-columns: 1fr; }
  .filters input[type="search"] { min-width: 0; width: 100%; }
  #msg-search, #audit-search, #template-search, #optout-search { min-width: 0; width: 100%; }
  .table-wrap td { white-space: nowrap; }
  .page-title { display: none; }
  .stat.highlight { grid-column: 1 / -1; }
  .failure-item { grid-template-columns: 44px 1fr; }
  .failure-item .badge { grid-column: 2; justify-self: start; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 24px; }
  .login-hero h1 { font-size: 28px; margin-top: 28px; }
  .hero-points { margin-bottom: 0; }
}

/* ================= cadastro público ================= */
.login-signup { text-align: center; font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.login-signup a { font-weight: 600; }
.signup-card { max-width: 420px; }
.signup-card label.check { align-items: flex-start; margin: 4px 0 16px; font-size: 13.5px; }
.signup-card label.check input { margin-top: 3px; }
.signup-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.signup-row label { margin-bottom: 6px; }
#signup-price { margin: 0 0 16px; }
.login-hero a.brand { color: inherit; text-decoration: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 480px) { .signup-row { grid-template-columns: 1fr; } }

/* ================= atendimento (caixa de entrada) ================= */
.inbox {
  display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 200px); min-height: 520px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.inbox-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.inbox-filters { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 8px; font: inherit; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.seg button.active { background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 600; color: var(--text); }
.inbox-items { flex: 1; overflow-y: auto; }
.inbox-none { padding: 16px; }
.inbox-item {
  display: flex; gap: 10px; width: 100%; padding: 12px; border: 0; border-bottom: 1px solid var(--border);
  background: none; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.inbox-item:hover { background: var(--surface-2); }
.inbox-item.active { background: var(--primary-50); }
.inbox-item-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.inbox-item-top, .inbox-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.inbox-item-top b, .inbox-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item-top small { color: var(--muted); font-size: 11.5px; flex: none; }
.inbox-preview { color: var(--text-2); font-size: 13px; }
.inbox-item.unread .inbox-preview, .inbox-item.unread .inbox-item-top small { font-weight: 650; color: var(--text); }
.inbox-item-bottom .nav-badge { margin-left: 0; flex: none; background: var(--primary); }
.inbox-item-meta { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-chat { display: flex; flex-direction: column; min-height: 0; background: #f2efe9; }
.inbox-empty { margin: auto; max-width: 360px; padding: 24px; text-align: center; color: var(--muted); }
.inbox-empty svg { width: 42px; height: 42px; color: var(--primary); }
.inbox-empty p { margin: 6px 0; }
.inbox-thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.thread-who { display: grid; min-width: 0; }
.thread-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-who small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-back { display: none; }
#thread-assign { width: auto; max-width: 210px; padding-top: 6px; padding-bottom: 6px; }
.thread-context { padding: 7px 14px; font-size: 12.5px; background: var(--info-50); color: #1e3a8a; border-bottom: 1px solid var(--border); }
.thread-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.msg-row { display: flex; }
.msg-row.out { justify-content: flex-end; }
.bubble { max-width: 72%; background: #fff; border-radius: 12px; padding: 7px 10px 5px; box-shadow: var(--shadow-sm); overflow-wrap: anywhere; }
.msg-row.out .bubble { background: #d9fdd3; }
.msg-text { white-space: normal; }
.msg-meta { margin-top: 2px; font-size: 11px; color: var(--muted); text-align: right; }
.tick { letter-spacing: -3px; margin-left: 2px; }
.tick.read { color: #2563eb; }
.tick.failed { color: var(--danger); letter-spacing: 0; }
.msg-context { margin-bottom: 4px; padding-left: 6px; border-left: 3px solid var(--primary); font-size: 12px; color: var(--muted); }
.msg-label { font-size: 10.5px; font-weight: 700; color: var(--primary-600); text-transform: uppercase; letter-spacing: .04em; }
.msg-img { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 8px; }
.msg-img.sticker { max-width: 140px; }
.bubble audio { width: 260px; max-width: 100%; }
.bubble video { max-width: min(300px, 100%); border-radius: 8px; }
.msg-doc { display: inline-block; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.msg-reaction { font-size: 26px; }
.msg-error { margin-top: 4px; font-size: 12px; color: var(--danger); }
.msg-day { text-align: center; margin: 8px 0; }
.msg-day span { background: rgba(255, 255, 255, .9); padding: 3px 10px; border-radius: 8px; font-size: 11.5px; color: var(--muted); }
.thread-window { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; background: var(--warning-50); color: var(--warning); font-size: 13px; border-top: 1px solid var(--border); }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; min-height: 40px; max-height: 160px; resize: none; margin: 0; }
#inbox-tpl-preview { margin: 10px 0; padding: 10px 12px; background: #d9fdd3; border-radius: 10px; font-size: 13.5px; }
#inbox-tpl-preview:empty { display: none; }
@media (max-width: 900px) {
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 170px); }
  .inbox.chat-open .inbox-list { display: none; }
  .inbox:not(.chat-open) .inbox-chat { display: none; }
  .thread-back { display: inline-flex; }
  .bubble { max-width: 86%; }
  .thread-head { flex-wrap: wrap; row-gap: 8px; }
  .thread-head .spacer { display: none; }
  .thread-who { flex: 1 1 calc(100% - 110px); }
  #thread-assign { flex: 1; max-width: none; }
}

/* gravação de áudio */
.composer { position: relative; }
.composer.recording > :not(.recorder) { visibility: hidden; }
.recorder { position: absolute; inset: 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1s infinite; }
@keyframes rec-pulse { 50% { opacity: .25; } }

/* ferramentas do atendimento */
.inbox-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.inbox-toolbar .spacer { flex: 1; }
#inbox-notify.active { color: var(--primary-600); }
.inbox-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.label-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.label-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: #ede9fe;
  color: #5b21b6; font-size: 11.5px; font-weight: 600; }
.label-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 11px; }
.label-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.label-form { display: flex; gap: 6px; margin-bottom: 14px; }
.label-form input { flex: 1; padding-top: 7px; padding-bottom: 7px; }
.thread-body { flex: 1; display: flex; min-height: 0; }
.thread-body .thread-msgs { flex: 1; min-width: 0; }
.thread-side { width: 290px; flex: none; overflow-y: auto; padding: 14px 16px; background: var(--surface); border-left: 1px solid var(--border); }
.thread-side h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.side-fields { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; margin: 8px 0; }
.side-fields dt { color: var(--muted); }
.side-fields dd { margin: 0; overflow-wrap: anywhere; }
.btn.block { display: flex; justify-content: center; width: 100%; margin-top: 14px; }
.optout-flag { color: var(--danger); font-weight: 600; }
.quote-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 14px;
  background: var(--primary-50); border-top: 1px solid var(--border); font-size: 13px; }
.quote-bar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#composer-note.active { background: #fef3c7; color: #92400e; }
.composer.note-mode textarea { background: #fffbeb; border-color: #f59e0b; }
.msg-row.note { justify-content: center; }
.bubble.note { background: #fef9c3; border: 1px dashed #eab308; max-width: 80%; }
.bubble.note .msg-label { color: #854d0e; }
.msg-row.in { align-items: center; gap: 6px; }
.msg-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .15s; position: relative; }
.msg-row:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions > button { border: 0; background: rgba(255, 255, 255, .9); border-radius: 50%; width: 28px; height: 28px; cursor: pointer;
  box-shadow: var(--shadow-sm); font-size: 14px; }
.react-menu { position: absolute; left: 0; bottom: 32px; display: flex; gap: 2px; padding: 4px 6px; background: #fff;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 5; }
.react-menu button { border: 0; background: none; font-size: 20px; cursor: pointer; padding: 2px; }
.react-menu button:hover { transform: scale(1.2); }
.qr-pop { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 4px); max-height: 260px; overflow-y: auto; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 10; padding: 4px; }
.qr-pop .hint { margin: 8px; }
.qr-item { display: grid; gap: 2px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font: inherit; color: inherit; }
.qr-item span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-item.active, .qr-item:hover { background: var(--primary-50); }
.qr-list { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; margin-bottom: 12px; }
.qr-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.qr-row .hint { margin: 4px 0 0; }
.qr-row-actions { display: flex; gap: 6px; align-items: flex-start; flex: none; }
.days-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tpl-preview-msg { margin: 10px 0; padding: 10px 12px; background: #d9fdd3; border-radius: 10px; font-size: 13.5px; }
.tpl-preview-msg:empty { display: none; }
dialog.wide { width: min(900px, 96vw); }
.report-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 16px; }
.report-kpis .stat { padding: 12px 14px; box-shadow: none; }
.report-kpis .stat b { display: block; font-size: 20px; letter-spacing: -.02em; }
.report-kpis .stat span { color: var(--muted); font-size: 12px; }
@media (max-width: 1100px) {
  .thread-side { position: absolute; right: 0; top: 0; bottom: 0; box-shadow: var(--shadow-lg); z-index: 6; }
  .inbox-thread { position: relative; }
}
@media (max-width: 900px) {
  .thread-side { width: 100%; }
  .inbox-toolbar .btn span { display: none; }
  .inbox-toolbar { flex-wrap: nowrap; overflow-x: auto; }
  .inbox-toolbar .btn { flex: none; }
  .report-kpis { grid-template-columns: repeat(2, 1fr); }
  .composer { flex-wrap: wrap; }
  .composer textarea { order: -1; flex: 1 1 100%; }
  #composer-send { margin-left: auto; }
}

/* ---- ligações de voz ---- */
.msg-row.call { justify-content: center; }
.bubble.call { background: #e0f2fe; color: #075985; font-size: 13px; padding: 6px 12px; border-radius: 999px; box-shadow: none; }
.bubble.call .msg-meta { display: inline; margin-left: 6px; }
.call-box { position: fixed; right: 20px; bottom: 20px; z-index: 1200; display: flex; flex-direction: column; gap: 10px; width: 320px; max-width: calc(100vw - 32px); }
.call-card { background: #fff; border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, .22); border: 1px solid #e2e8f0; }
.call-card.ringing { border-color: #34d399; animation: call-pulse 1.4s ease-in-out infinite; }
.call-card.active { border-color: #38bdf8; }
.call-title { font-size: 12.5px; font-weight: 600; color: #475569; display: flex; justify-content: space-between; }
.call-who { font-size: 17px; font-weight: 700; margin-top: 4px; }
.call-sub { font-size: 12.5px; color: #64748b; margin-top: 2px; }
.call-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
@keyframes call-pulse { 0%, 100% { box-shadow: 0 10px 30px rgba(15, 23, 42, .22); } 50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, .35), 0 10px 30px rgba(15, 23, 42, .22); } }
@media (max-width: 640px) { .call-box { right: 16px; left: 16px; bottom: 16px; width: auto; } }

/* ---- setores e menu automático ---- */
.inbox-selects .span-all { grid-column: 1 / -1; }
#thread-dept { max-width: 240px; min-width: 150px; }
.flow-tabs { margin: 6px 0 14px; max-width: 540px; }
.dept-list { display: grid; gap: 8px; margin-bottom: 12px; }
.dept-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dept-row > div { flex: 1; min-width: 0; display: grid; }
.dept-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- editor visual do fluxo (Drawflow) ---- */
dialog.full { width: 98vw; max-width: 98vw; height: 94vh; max-height: 94vh; }
dialog.full .dlg-body { height: 100%; display: flex; flex-direction: column; box-sizing: border-box; }
dialog.full #flow-menu { flex: 1; min-height: 0; display: flex; flex-direction: column; }
dialog.full #flow-menu[hidden] { display: none; }
.flow-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.flow-top label.check { margin-top: 0; }
.flow-top .hint { margin: 0; }
.flow-work { flex: 1; min-height: 0; display: grid; grid-template-columns: 150px minmax(0, 1fr) 300px; gap: 10px; }
.flow-palette { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.fb-pal { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 10px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.fb-pal:hover { border-color: var(--primary); background: var(--primary-50); }
.fb-pal span { width: 22px; text-align: center; }
.flow-canvas { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; outline: none;
  background-color: #f8fafc; background-image: radial-gradient(#cbd5e1 1px, transparent 1px); background-size: 22px 22px; }
.flow-props { border: 1px solid var(--border); border-radius: 12px; padding: 12px; overflow-y: auto; overflow-x: hidden; background: var(--surface); }
.flow-props input, .flow-props select, .flow-props textarea { max-width: 100%; box-sizing: border-box; min-width: 0; }
.flow-props .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.flow-props h4 { margin: 0 0 4px; }
.flow-props label { margin-top: 10px; }
.fb-options { display: grid; gap: 6px; margin-bottom: 6px; }
.fb-opt { display: flex; align-items: center; gap: 4px; }
.fb-opt input { flex: 1; min-width: 0; }
.fb-opt .btn { padding: 4px 7px; }
.dur { display: flex; gap: 6px; }
.dur input { width: 90px; }
.fb-props-foot { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--border); }
.drawflow .drawflow-node.fb { display: block; width: 240px; padding: 0; background: #fff; border: 1.5px solid #cbd5e1; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08); color: var(--text); min-height: 0; }
.drawflow .drawflow-node.fb:hover { cursor: grab; }
.drawflow .drawflow-node.fb.selected { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5, 150, 105, .2); }
.drawflow .drawflow-node.fb.fb-error { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); }
.drawflow .drawflow-node.fb .drawflow_content_node { display: block; }
.fb-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid #eef2f7; border-radius: 12px 12px 0 0; font-size: 13px; }
.fb-head b { flex: 1; }
.fb-icon { width: 20px; text-align: center; }
.fb-count { font-size: 11px; color: #047857; background: var(--primary-50); border-radius: 999px; padding: 1px 7px; }
.fb-body { padding: 8px 10px; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; white-space: pre-line; }
.fb-todo { color: #b45309; }
.fb-outs { padding: 0 18px 8px 10px; }
.fb-outs > div { height: 26px; line-height: 26px; text-align: right; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawflow .drawflow-node.fb .inputs { position: absolute; left: -9px; top: 10px; width: auto; }
.drawflow .drawflow-node.fb .outputs { position: absolute; right: -9px; bottom: 8px; width: auto; display: flex; flex-direction: column; }
.drawflow .drawflow-node.fb .input, .drawflow .drawflow-node.fb .output { width: 16px; height: 16px; left: 0; right: 0; top: 0; margin: 5px 0;
  border: 2px solid #64748b; background: #fff; }
.drawflow .drawflow-node.fb .output:hover, .drawflow .drawflow-node.fb .input:hover { background: var(--primary); border-color: var(--primary); }
.drawflow .connection .main-path { stroke: #64748b; stroke-width: 3px; }
.drawflow .connection .main-path:hover, .drawflow .connection .main-path.selected { stroke: var(--primary); }
.drawflow .drawflow-delete { background: #dc2626; border-color: #fff; width: 24px; height: 24px; line-height: 24px; font-size: 13px; }
.drawflow-node.fb-start .drawflow-delete { display: none; }
.fb-start .fb-head { background: #ecfdf5; }
.fb-department .fb-head, .fb-agent .fb-head, .fb-close .fb-head { background: #eff6ff; }
.fb-condition .fb-head { background: #fefce8; }
.fb-menu .fb-head, .fb-question .fb-head { background: #f5f3ff; }
@media (max-width: 900px) {
  .flow-work { grid-template-columns: 1fr; grid-template-rows: auto minmax(360px, 1fr) auto; }
  .flow-palette { flex-direction: row; overflow-x: auto; }
  .fb-pal { flex: none; }
  dialog.full { height: auto; max-height: 96vh; }
  dialog.full .dlg-body { height: auto; }
}

/* ---- automações ---- */
.flow-name { width: 260px; max-width: 100%; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; min-width: 0; font-size: 12px; }
.path-list { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.path-list button { text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 5px 8px;
  font: inherit; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.path-list button:hover { border-color: var(--primary); background: var(--primary-50); }
.path-list b { color: var(--text); font-weight: 600; }
.fb-template .fb-head, .fb-wait_reply .fb-head { background: #fff7ed; }
#flow-autos .toolbar { align-items: flex-start; gap: 12px; }
#flow-autos .toolbar .hint { flex: 1; margin: 0; }

/* ---- logo da empresa ---- */
.tenant-mark { margin: -10px 8px 18px; background: #fff; border-radius: 12px; padding: 8px 12px; display: grid; place-items: center; }
.tenant-mark img { max-width: 100%; max-height: 44px; object-fit: contain; }
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 220px; height: 90px; border: 1px dashed var(--border); border-radius: 12px; display: grid; place-items: center;
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 16px 16px; flex: none; }
.logo-preview img { max-width: 200px; max-height: 76px; object-fit: contain; }
.logo-row > div:last-child { flex: 1; min-width: 220px; }
.actions.left { justify-content: flex-start; }
.tenant-logo { display: block; max-width: 240px; max-height: 72px; object-fit: contain; margin: 0 auto 18px; }
.tenant-logo[hidden] { display: none; }

/* ---- janelas de cadastro (cliente e plano) ---- */
dialog.pro { width: min(720px, 96vw); max-height: 92vh; overflow: hidden; }
dialog.pro.wide-pro { width: min(940px, 96vw); }
dialog.pro[open] { display: flex; }
.pro-form { display: flex; flex-direction: column; width: 100%; max-height: 92vh; }
.pro-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 18px; border-bottom: 1px solid var(--border); }
.pro-head h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.pro-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.pro-head > div { flex: 1; min-width: 0; }
.pro-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; flex: none; }
.pro-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pro-x { border: 0; background: transparent; color: var(--muted); font-size: 16px; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; flex: none; }
.pro-x:hover { background: var(--surface-2); color: var(--text); }
.pro-body { padding: 8px 24px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.pro-sec { padding: 16px 0 6px; border-bottom: 1px solid var(--border); }
.pro-sec:last-child { border-bottom: 0; }
.pro-sec h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 14px; color: var(--text); }
.pro-sec h4 span { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.pro-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.pro-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pro-grid .span-2 { grid-column: 1 / -1; }
.pro-body label small, .pro-body .status-help { font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.4; }
.pro-body label.no-label { margin-bottom: 8px; }
.pro-body [hidden] { display: none !important; }
.status-help.s-active { color: #047857; }
.status-help.s-suspended, .status-help.s-awaiting_payment { color: #b45309; }
.status-help.s-cancelled { color: #b91c1c; }
.pro-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.affix { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.affix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5, 150, 105, .15); }
.affix em { font-style: normal; display: grid; place-items: center; padding: 0 12px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.affix input { border: 0 !important; box-shadow: none !important; border-radius: 0; flex: 1; min-width: 0; }
.switch { flex-direction: row !important; align-items: flex-start; gap: 12px; cursor: pointer; margin: 4px 0 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { flex: none; width: 40px; height: 22px; border-radius: 99px; background: #cbd5e1; position: relative; transition: background .15s; margin-top: 1px; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(5, 150, 105, .25); }
.switch span { display: grid; gap: 2px; }
.switch b { font-weight: 600; color: var(--text); }
.pro-split { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 24px; }
.plan-preview { padding: 18px 0; }
.plan-preview > small { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.pp-card { position: relative; border: 2px solid var(--primary); border-radius: 18px; padding: 22px 20px; background: var(--surface);
  box-shadow: 0 16px 32px rgba(5, 150, 105, .12); position: sticky; top: 8px; }
.pp-card.off { border-color: var(--border-strong); box-shadow: none; opacity: .75; }
.pp-off { position: absolute; top: -11px; left: 18px; background: #64748b; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.pp-name { display: block; font-size: 17px; overflow-wrap: anywhere; }
.pp-price { font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: #064e3b; margin: 6px 0 2px; }
.pp-price small { font-size: 14px; font-weight: 600; color: var(--muted); }
.pp-annual { font-size: 12.5px; color: var(--text-2); min-height: 18px; }
.pp-annual span { display: inline-block; margin-left: 4px; background: #fef3c7; color: #92400e; border-radius: 99px; padding: 1px 8px; font-weight: 600; font-size: 11.5px; }
.pp-card ul { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; font-size: 13px; color: var(--text-2); }
.pp-card li { position: relative; padding-left: 22px; }
.pp-card li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 800; }
@media (max-width: 760px) {
  .pro-split { grid-template-columns: 1fr; gap: 0; }
  .pro-grid, .pro-grid.three { grid-template-columns: 1fr; }
  .pro-head { padding: 18px 16px 14px; }
  .pro-body { padding: 4px 16px; }
  .pro-foot { padding: 12px 16px; flex-wrap: wrap; }
}

/* ---- clientes (dono da plataforma) ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; margin-right: 6px; vertical-align: -3px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: grid; gap: 2px; box-shadow: var(--shadow-sm); }
.kpi span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.kpi b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.2; }
.kpi small { font-size: 12px; color: var(--muted); }
.list-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { position: relative; flex: 1 1 280px; max-width: 420px; }
.search-box svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search-box input { width: 100%; padding-left: 36px; }
.tenant-filter { flex: 0 1 auto; }
.tenant-filter button { padding: 6px 12px; white-space: nowrap; }
.tenant-filter em { font-style: normal; font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 0 7px; margin-left: 4px; }
.tenant-filter button.active em { background: var(--primary-50); color: #047857; }
.tn-list { display: grid; gap: 10px; }
.tn-row { display: grid; grid-template-columns: minmax(240px, 1.7fr) minmax(120px, 1fr) minmax(150px, 1.2fr) minmax(140px, 1fr) minmax(150px, 1.1fr) minmax(220px, 1.5fr) auto;
  gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.tn-row:hover, .tn-row:focus-visible { border-color: #a7f3d0; box-shadow: 0 6px 18px rgba(15, 23, 42, .07); outline: none; }
.tn-row.own { background: linear-gradient(90deg, var(--primary-50), var(--surface) 30%); }
.tn-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.tn-avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-50); color: #047857; font-weight: 800; font-size: 14px; display: grid; place-items: center; flex: none; }
.tn-id { display: grid; gap: 2px; min-width: 0; }
.tn-id b { font-size: 15px; color: var(--text); }
.tn-id a { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-id small, .tn-col small, .tn-actions small { font-size: 12px; color: var(--muted); }
.tn-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-chip { font-size: 11px; font-weight: 600; color: #047857; background: var(--primary-50); border-radius: 99px; padding: 1px 8px; vertical-align: 2px; }
.tn-col { display: grid; gap: 3px; justify-items: start; min-width: 0; }
.tn-col b { font-size: 14px; color: var(--text); }
.tn-col b.tn-light { font-weight: 500; }
.tn-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tn-clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tn-wa { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.tn-wa i { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.tn-wa.on { color: #047857; }
.tn-wa.on i { background: #10b981; }
.tn-usage { display: grid; gap: 7px; min-width: 0; }
.tn-meter { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; font-size: 12px; }
.tn-meter span { color: var(--text-2); }
.tn-meter b { font-weight: 700; color: var(--text); text-align: right; }
.tn-meter b em { font-style: normal; font-weight: 500; color: var(--muted); }
.tn-meter i { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: #eef2f6; overflow: hidden; }
.tn-meter u { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.tn-meter.full u { background: #d97706; }
.tn-meter small { grid-column: 1 / -1; color: #b45309; font-size: 11.5px; }
.tn-actions { display: grid; gap: 6px; justify-items: end; }
/* a lista se ajusta à largura dela (o menu lateral ocupa parte da tela) */
.tn-list { container-type: inline-size; }
@container (max-width: 1240px) {
  .tn-row { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 14px; }
  .tn-main { grid-column: 1 / 4; }
  .tn-actions { grid-column: 4; grid-row: 1; }
  .tn-usage { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding-top: 12px; border-top: 1px dashed var(--border); }
}
@container (max-width: 640px) {
  .tn-row { grid-template-columns: 1fr 1fr; }
  .tn-main { grid-column: 1 / -1; }
  .tn-actions { grid-column: 1 / -1; grid-row: auto; justify-items: stretch; }
  .tn-usage { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi b { font-size: 21px; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tenant-filter { overflow-x: auto; max-width: 100%; }
}

/* ---- usuários ---- */
.kpi b em { font-style: normal; font-size: 16px; font-weight: 600; color: var(--muted); }
.kpi small.warn { color: #b45309; }
.us-row { grid-template-columns: minmax(230px, 1.6fr) minmax(130px, .9fr) minmax(200px, 1.6fr) minmax(150px, 1fr) minmax(110px, .8fr) auto; }
.us-row.off { opacity: .7; }
.us-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.us-chips .tag { margin: 0; }
.tn-avatar.admin { background: #dbeafe; color: #1d4ed8; }
.tn-wa.warn { color: #b45309; }
.tn-wa.warn i { background: #f59e0b; }
.role-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.role-card { flex-direction: row !important; align-items: flex-start; gap: 10px; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; margin: 0; transition: border-color .15s, background .15s; }
.role-card input { margin-top: 2px; flex: none; }
.role-card span { display: grid; gap: 4px; }
.role-card b { color: var(--text); font-size: 14px; }
.role-card small { font-weight: 400; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.role-card:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.pro-body .chips { margin-bottom: 14px; }
@container (max-width: 1240px) {
  .us-row { grid-template-columns: minmax(0, .9fr) minmax(0, 1.6fr) minmax(0, 1.1fr) minmax(0, .8fr) auto; }
  .us-row .tn-main { grid-column: 1 / 5; }
  .us-row .tn-actions { grid-column: 5; grid-row: 1; }
  .us-row .us-access { grid-column: auto; }
}
@container (max-width: 640px) {
  .us-row { grid-template-columns: 1fr 1fr; }
  .us-row .tn-main, .us-row .us-access, .us-row .tn-actions { grid-column: 1 / -1; }
  .us-row .tn-actions { grid-row: auto; justify-items: stretch; }
}
@media (max-width: 760px) { .role-cards { grid-template-columns: 1fr; } }

/* =========================================================
   Atendimento com a cara do WhatsApp Web
   ========================================================= */
#view-inbox { --wa-panel: #f0f2f5; --wa-chat: #efeae2; --wa-out: #d9fdd3; --wa-in: #ffffff; --wa-meta: #667781;
  --wa-green: #00a884; --wa-green-dark: #008069; --wa-read: #53bdeb; --wa-line: #e9edef; --wa-text: #111b21; }
#view-inbox .inbox { height: calc(100vh - 150px); border-radius: 12px; border-color: #d1d7db; box-shadow: 0 1px 3px rgba(11, 20, 26, .08); }
/* lista de conversas */
#view-inbox .inbox-list { background: #fff; border-right-color: #d1d7db; }
#view-inbox .inbox-filters { padding: 10px 12px; border-bottom: 1px solid var(--wa-line); gap: 8px; }
#view-inbox #inbox-q { background: var(--wa-panel); border: 0; border-radius: 8px; padding: 9px 12px 9px 38px; box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2354656f' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; background-size: 16px; }
#view-inbox #inbox-q:focus { background-color: #fff; box-shadow: 0 0 0 2px rgba(0, 168, 132, .35); }
#view-inbox .inbox-filters .seg { background: none; border: 0; padding: 0; gap: 6px; }
#view-inbox .inbox-filters .seg button { flex: 0 0 auto; padding: 5px 12px; border-radius: 999px; background: var(--wa-panel); color: #54656f; font-weight: 500; box-shadow: none; }
#view-inbox .inbox-filters .seg button.active { background: #d9fdd3; color: var(--wa-green-dark); font-weight: 600; }
#view-inbox .inbox-selects select { background-color: #fff; border-color: var(--wa-line); font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
#view-inbox .inbox-item { padding: 0 0 0 12px; border-bottom: 0; gap: 12px; align-items: center; }
#view-inbox .inbox-item .avatar { width: 46px; height: 46px; font-size: 15px; background: #dfe5e7; color: #54656f; flex: none; }
#view-inbox .inbox-item-main { padding: 11px 14px 11px 0; border-bottom: 1px solid var(--wa-line); gap: 3px; }
#view-inbox .inbox-item:hover { background: #f5f6f6; }
#view-inbox .inbox-item.active { background: var(--wa-panel); }
#view-inbox .inbox-item-top b { font-weight: 500; font-size: 15.5px; color: var(--wa-text); }
#view-inbox .inbox-item-top small { color: var(--wa-meta); font-size: 12px; }
#view-inbox .inbox-item.unread .inbox-item-top small { color: #1fa855; font-weight: 600; }
#view-inbox .inbox-preview { color: var(--wa-meta); font-size: 13.5px; }
#view-inbox .inbox-item.unread .inbox-preview { color: var(--wa-text); font-weight: 500; }
#view-inbox .inbox-item-bottom .nav-badge { background: #25d366; color: #fff; min-width: 20px; height: 20px; border-radius: 999px; font-size: 11.5px; display: grid; place-items: center; padding: 0 6px; }
#view-inbox .inbox-item-meta { color: var(--wa-meta); }
/* cabeçalho da conversa */
#view-inbox .inbox-chat { background: var(--wa-chat); }
#view-inbox .thread-head { background: var(--wa-panel); border-bottom: 1px solid #d1d7db; padding: 8px 14px; min-height: 60px; }
#view-inbox .thread-head .avatar { width: 42px; height: 42px; background: #dfe5e7; color: #54656f; }
#view-inbox .thread-who b { font-weight: 500; font-size: 16px; color: var(--wa-text); }
#view-inbox .thread-who small { color: var(--wa-meta); }
#view-inbox .thread-head select { background-color: #fff; border: 0; border-radius: 999px; font-size: 13px; padding: 6px 30px 6px 12px; box-shadow: 0 1px 1px rgba(11, 20, 26, .06); }
#view-inbox .thread-head .btn { border-radius: 999px; }
#view-inbox .thread-context { background: #fff7d6; color: #6b5300; border-bottom-color: #f0e2a8; }
/* área das mensagens: fundo com padrão discreto */
#view-inbox .thread-msgs { padding: 14px 7% 18px; gap: 2px;
  background-color: var(--wa-chat);
  background-image: radial-gradient(rgba(0, 0, 0, .045) 1.2px, transparent 1.3px), radial-gradient(rgba(0, 0, 0, .03) 1px, transparent 1.1px);
  background-size: 26px 26px, 26px 26px; background-position: 0 0, 13px 13px; }
#view-inbox .msg-day { margin: 10px 0 8px; }
#view-inbox .msg-day span { background: #fff; color: #54656f; font-size: 12.5px; padding: 5px 12px; border-radius: 7.5px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); text-transform: none; }
#view-inbox .msg-row { margin-top: 1px; }
#view-inbox .msg-row.tail { margin-top: 10px; }
#view-inbox .bubble { position: relative; max-width: min(65%, 560px); padding: 6px 7px 8px 9px; border-radius: 7.5px; background: var(--wa-in);
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); color: var(--wa-text); font-size: 14.2px; line-height: 19px; }
#view-inbox .msg-row.out .bubble { background: var(--wa-out); }
#view-inbox .msg-row.in.tail .bubble { border-top-left-radius: 0; }
#view-inbox .msg-row.out.tail .bubble { border-top-right-radius: 0; }
#view-inbox .msg-row.in.tail .bubble::before, #view-inbox .msg-row.out.tail .bubble::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
#view-inbox .msg-row.in.tail .bubble::before { left: -8px; background: var(--wa-in); clip-path: polygon(100% 0, 0 0, 100% 100%); }
#view-inbox .msg-row.out.tail .bubble::before { right: -8px; background: var(--wa-out); clip-path: polygon(0 0, 100% 0, 0 100%); }
#view-inbox .msg-row.in { padding-left: 8px; }
#view-inbox .msg-row.out { padding-right: 8px; }
/* hora e tracinhos dentro do balão, no canto (o espaço reservado no fim do texto evita sobrepor) */
#view-inbox .msg-text::after { content: ""; display: inline-block; width: 52px; height: 1px; }
#view-inbox .msg-row.out .msg-text::after { width: 70px; }
#view-inbox .bubble > .msg-meta { position: absolute; right: 7px; bottom: 3px; margin: 0; font-size: 11px; color: var(--wa-meta);
  display: inline-flex; align-items: center; gap: 3px; line-height: 15px; }
#view-inbox .bubble.no-text { padding-bottom: 20px; min-width: 70px; }
#view-inbox .bubble.media-only > .msg-meta { color: #fff; background: rgba(11, 20, 26, .35); border-radius: 8px; padding: 0 5px; bottom: 26px; right: 12px; }
#view-inbox .bubble.media-only { padding: 3px 3px 22px; }
#view-inbox .tick { display: inline-flex; letter-spacing: 0; margin: 0; color: #8696a0; }
#view-inbox .tick svg { width: 16px; height: 11px; fill: currentColor; }
#view-inbox .tick.read { color: var(--wa-read); }
#view-inbox .tick.failed { color: #ea0038; }
#view-inbox .msg-sender { font-size: 12.8px; font-weight: 500; color: var(--wa-green-dark); margin-bottom: 2px; line-height: 18px; }
#view-inbox .msg-sender.system { color: #54656f; font-weight: 400; font-style: italic; }
#view-inbox .msg-quote { background: rgba(11, 20, 26, .05); border-left: 4px solid #06cf9c; border-radius: 6px; padding: 5px 8px; margin: 1px 0 5px;
  font-size: 13px; line-height: 17px; color: #54656f; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#view-inbox .msg-row.out .msg-quote { background: rgba(11, 20, 26, .06); border-left-color: #53bdeb; }
#view-inbox .msg-buttons { display: grid; margin: 8px -7px -8px -9px; border-top: 1px solid rgba(11, 20, 26, .08); }
#view-inbox .msg-buttons span { text-align: center; color: #027eb5; font-size: 14px; padding: 9px 8px; border-top: 1px solid rgba(11, 20, 26, .06); }
#view-inbox .msg-buttons span:first-child { border-top: 0; }
#view-inbox .msg-buttons + .msg-error, #view-inbox .msg-buttons { position: relative; }
#view-inbox .bubble:has(.msg-buttons) { padding-bottom: 8px; }
#view-inbox .bubble:has(.msg-buttons) > .msg-meta { position: static; float: right; margin: -16px 0 0 8px; }
#view-inbox .msg-error { font-size: 12px; color: #ea0038; margin-top: 4px; }
#view-inbox .msg-img { border-radius: 6px; }
#view-inbox .msg-doc { background: rgba(11, 20, 26, .05); }
#view-inbox .bubble.note { max-width: 80%; border-radius: 7.5px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
#view-inbox .bubble.note .msg-meta, #view-inbox .bubble.call .msg-meta { position: static; display: inline; }
#view-inbox .bubble.call { border-radius: 7.5px; background: #fff; color: #54656f; font-size: 13px; padding: 5px 12px; }
#view-inbox .msg-actions > button { background: #fff; box-shadow: 0 1px 2px rgba(11, 20, 26, .15); }
/* aviso da janela de 24 h e barra de digitação */
#view-inbox .thread-window { background: #fff9e6; color: #6b5300; border-top: 1px solid #f0e2a8; justify-content: center; text-align: center; font-size: 13px; }
#view-inbox .composer { background: var(--wa-panel); border-top: 0; padding: 8px 12px; gap: 4px; align-items: center; }
#view-inbox .composer .btn.ghost { color: #54656f; border-radius: 50%; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
#view-inbox .composer .btn.ghost:hover { background: rgba(11, 20, 26, .06); }
#view-inbox .composer textarea { background: #fff; border: 0; border-radius: 8px; padding: 10px 12px; font-size: 15px; box-shadow: none; min-height: 42px; }
#view-inbox .composer textarea:focus { box-shadow: none; }
#view-inbox .composer textarea:disabled { background: #f7f8fa; }
#view-inbox #composer-send { border-radius: 999px; background: var(--wa-green); border-color: var(--wa-green); min-width: 42px; height: 42px; padding: 0 18px; box-shadow: none; }
#view-inbox #composer-send:hover { background: var(--wa-green-dark); }
#view-inbox #composer-send:disabled { background: #b8e6d9; border-color: #b8e6d9; }
#view-inbox .composer.note-mode textarea { background: #fffbeb; box-shadow: inset 0 0 0 1px #f59e0b; }
#view-inbox .recorder { background: var(--wa-panel); }
#view-inbox .quote-bar { background: var(--wa-panel); border-top: 0; border-left: 4px solid #06cf9c; margin: 0 12px; border-radius: 6px 6px 0 0; }
#view-inbox .inbox-empty { background: var(--wa-panel); margin: 0; max-width: none; height: 100%; display: grid; place-content: center; border-bottom: 6px solid #25d366; }
@media (max-width: 900px) {
  #view-inbox .inbox { height: calc(100vh - 120px); }
  #view-inbox .thread-msgs { padding: 10px 10px 14px; }
  #view-inbox .bubble { max-width: 85%; }
}
#view-inbox #thread-dept, #view-inbox #thread-assign { width: auto; min-width: 170px; max-width: 240px; }

/* Configurações do atendimento: explicação e botão abaixo da opção */
.settings-sub { margin: -4px 0 12px 28px; }
.settings-sub p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.45; }

/* Nova conversa do Atendimento: agenda no estilo do WhatsApp Web */
.agenda-dlg { width: min(520px, calc(100vw - 32px)); }
.agenda-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.agenda-tools .search-box { max-width: none; flex: 1 1 200px; }
.agenda-tools select { flex: 0 1 190px; min-width: 0; }
.agenda-tools select[hidden] { display: none; }
.agenda-list { max-height: min(52vh, 460px); overflow-y: auto; margin: 0 -8px; }
.agenda-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0;
  border-bottom: 1px solid #e9edef; background: none; text-align: left; cursor: pointer; font: inherit; color: #111b21; border-radius: 0; }
.agenda-item:hover, .agenda-item:focus-visible { background: #f5f6f6; outline: none; }
.agenda-item.blocked { opacity: .6; }
.agenda-new { margin: 0 -8px; width: calc(100% + 16px); border-bottom: 0; }
.agenda-avatar { width: 44px; height: 44px; border-radius: 50%; background: #dfe5e7; color: #54656f; font-weight: 700; font-size: 15px;
  display: grid; place-items: center; flex: none; }
.agenda-new .agenda-avatar { background: #00a884; color: #fff; }
.agenda-avatar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.agenda-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.agenda-text b { font-weight: 500; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-text small { color: #667781; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-label { color: #008069; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 14px 2px 6px; }
.agenda-tag { font-style: normal; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #f0f2f5; color: #54656f; flex: none; }
.agenda-tag.on { background: #d9fdd3; color: #008069; }
.agenda-tag.out { background: #fde2e1; color: #b42318; }
.agenda-empty { color: #667781; padding: 18px 4px; text-align: center; }

/* cor fixa por contato nos avatares (a API não fornece a foto) */
#view-inbox .avatar.av-0, .agenda-avatar.av-0 { background: #fde2e1; color: #b42318; }
#view-inbox .avatar.av-1, .agenda-avatar.av-1 { background: #ccfbf1; color: #0f766e; }
#view-inbox .avatar.av-2, .agenda-avatar.av-2 { background: #fef3c7; color: #92400e; }
#view-inbox .avatar.av-3, .agenda-avatar.av-3 { background: #e0e7ff; color: #4338ca; }
#view-inbox .avatar.av-4, .agenda-avatar.av-4 { background: #d1fae5; color: #047857; }
#view-inbox .avatar.av-5, .agenda-avatar.av-5 { background: #fce7f3; color: #be185d; }
#view-inbox .avatar.av-6, .agenda-avatar.av-6 { background: #ffe8cc; color: #b54708; }
#view-inbox .avatar.av-7, .agenda-avatar.av-7 { background: #dbeafe; color: #1d4ed8; }
#view-inbox .avatar.av-8, .agenda-avatar.av-8 { background: #ecfccb; color: #3f6212; }
#view-inbox .avatar.av-9, .agenda-avatar.av-9 { background: #ede9fe; color: #6d28d9; }
#view-inbox .avatar.av-10, .agenda-avatar.av-10 { background: #cffafe; color: #0e7490; }
#view-inbox .avatar.av-11, .agenda-avatar.av-11 { background: #fae8ff; color: #a21caf; }

.nowrap { white-space: nowrap; }

/* ================= avisos da plataforma ================= */
.announce-stack { display: grid; gap: 10px; margin: 0 0 14px; }
.announce-stack:empty { display: none; }
.announce { --k: #2563eb; --kb: #eff6ff; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  background: var(--kb); border: 1px solid color-mix(in srgb, var(--k) 25%, transparent); border-left: 4px solid var(--k);
  border-radius: var(--radius-sm); color: var(--text); }
.announce.k-novidade { --k: #059669; --kb: #ecfdf5; }
.announce.k-manutencao { --k: #d97706; --kb: #fffbeb; }
.announce.k-importante { --k: #dc2626; --kb: #fef2f2; }
.announce-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--k); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.announce-text { flex: 1; min-width: 0; font-size: 14px; }
.announce-text em { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--k); text-transform: uppercase; letter-spacing: .04em; margin-left: 6px; }
.announce-text p { margin: 4px 0 0; white-space: pre-line; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.announce-text a { color: var(--k); font-weight: 600; }
.announce .btn { flex: none; }
.ann-list { display: grid; gap: 12px; }
.ann-row { background: var(--card, #fff); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.ann-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.ann-meta .btn { margin-left: auto; }
.ann-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.ann-grid aside { display: grid; align-content: start; gap: 8px; font-size: 13px; }
.ann-audience { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 6px; margin: 6px 0 0; }
.ann-audience legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.ann-tenants { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 4px 24px; max-height: 160px; overflow: auto; }
@media (max-width: 760px) { .ann-grid { grid-template-columns: 1fr; } }

/* ================= cópias de segurança ================= */
.backup-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 0 0 18px; }
.backup-card { background: var(--card, #fff); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.backup-card h4 { margin: 0 0 6px; font-size: 15px; }
.backup-card p { margin: 6px 0 0; font-size: 13.5px; }
.backup-card .bk-err { color: #991b1b; overflow-wrap: anywhere; }
.section-title { font-size: 15px; margin: 6px 0 10px; }

/* avisos na tela de login */
.login-notices { width: 100%; max-width: 380px; margin: 0 auto 14px; display: grid; gap: 8px; }
.login-notice { border: 1px solid #fde68a; background: #fffbeb; border-left: 4px solid #d97706; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #78350f; }
.login-notice.k-novidade { border-color: #a7f3d0; background: #ecfdf5; border-left-color: #059669; color: #064e3b; }
.login-notice.k-importante { border-color: #fecaca; background: #fef2f2; border-left-color: #dc2626; color: #7f1d1d; }
.login-notice.k-info { border-color: #bfdbfe; background: #eff6ff; border-left-color: #2563eb; color: #1e3a8a; }
.login-notice p { margin: 4px 0 0; white-space: pre-line; }
