/* RAMPA Conversas — design system (Fase 3). Sem dependências externas (CSP: style-src 'self'). */

/* ------------------------------------------------------------------ tokens */
:root {
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 24px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --radius: 8px; --radius-lg: 12px; --pill: 999px;

  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --surface-3: #eef2f5;
  --border: #dde3e8; --border-strong: #c5ced6;
  --text: #17222b; --text-2: #4b5a66; --text-3: #75838e;
  --brand: #0e6b72; --brand-strong: #0a5459; --brand-soft: #e3f2f2; --on-brand: #ffffff;
  --ok: #1f7a43; --ok-soft: #e4f4ea; --warn: #8a5a00; --warn-soft: #fdf1d8;
  --err: #b42318; --err-soft: #fdecea; --info: #1f5fa8; --info-soft: #e5effa;
  --ai: #6941c6; --ai-soft: #efeafc; --human: #0b7a6e; --human-soft: #e0f3f0;
  --wait: #9a5b00; --wait-soft: #fff1d6; --done: #5b6670; --done-soft: #eceff2;
  --note: #fff6d1; --note-border: #ecd98b; --sim: #7a4b00; --sim-soft: #fff4dc;
  --bubble-in: #ffffff; --bubble-ai: #efeafc; --bubble-human: #dff3ee; --chat-bg: #eef1ee;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --focus: 0 0 0 3px rgba(14, 107, 114, .35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1418; --surface: #161d22; --surface-2: #1b242a; --surface-3: #222d34;
    --border: #2b3740; --border-strong: #3a4954;
    --text: #e6edf2; --text-2: #b3c0ca; --text-3: #8696a2;
    --brand: #3fb3ba; --brand-strong: #63c7cd; --brand-soft: #123a3d; --on-brand: #06272a;
    --ok: #5bc58a; --ok-soft: #133524; --warn: #f0b84d; --warn-soft: #3a2c0e; --err: #f1786b; --err-soft: #3d1714;
    --info: #79aef0; --info-soft: #14283f; --ai: #b39cf5; --ai-soft: #2a2145; --human: #52c7b8; --human-soft: #12332f;
    --wait: #f0b84d; --wait-soft: #3a2c0e; --done: #9aa6b0; --done-soft: #252e35;
    --note: #3a3418; --note-border: #6b5d22; --sim: #f0c069; --sim-soft: #3a2c0e;
    --bubble-in: #1f282e; --bubble-ai: #2a2145; --bubble-human: #133a35; --chat-bg: #12181c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1418; --surface: #161d22; --surface-2: #1b242a; --surface-3: #222d34;
  --border: #2b3740; --border-strong: #3a4954;
  --text: #e6edf2; --text-2: #b3c0ca; --text-3: #8696a2;
  --brand: #3fb3ba; --brand-strong: #63c7cd; --brand-soft: #123a3d; --on-brand: #06272a;
  --ok: #5bc58a; --ok-soft: #133524; --warn: #f0b84d; --warn-soft: #3a2c0e; --err: #f1786b; --err-soft: #3d1714;
  --info: #79aef0; --info-soft: #14283f; --ai: #b39cf5; --ai-soft: #2a2145; --human: #52c7b8; --human-soft: #12332f;
  --wait: #f0b84d; --wait-soft: #3a2c0e; --done: #9aa6b0; --done-soft: #252e35;
  --note: #3a3418; --note-border: #6b5d22; --sim: #f0c069; --sim-soft: #3a2c0e;
  --bubble-in: #1f282e; --bubble-ai: #2a2145; --bubble-human: #133a35; --chat-bg: #12181c;
  color-scheme: dark;
}

/* ------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: var(--fs-md); line-height: 1.45; color: var(--text); background: var(--bg);
  overflow-x: hidden; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); } h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-2); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); } .subtle { color: var(--text-3); font-size: var(--fs-sm); }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack.tight { gap: var(--sp-1); }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 36px;
  padding: 0 var(--sp-4); border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer; font-weight: 600; font-size: var(--fs-sm); white-space: nowrap;
  transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--err); border-color: var(--err); background: transparent; }
.btn.danger:hover { background: var(--err-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 30px; }

/* --------------------------------------------------------------- formulários */
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.input, .select, .textarea { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); }
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--focus); outline: none; }
.input[readonly], .textarea[readonly] { background: var(--surface-2); color: var(--text-2); }
.check { display: inline-flex; gap: var(--sp-2); align-items: center; cursor: pointer; font-size: var(--fs-sm); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid .full { grid-column: 1 / -1; }

/* ------------------------------------------------------------- badges/chips */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--pill);
  font-size: var(--fs-xs); font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.ia { background: var(--ai-soft); color: var(--ai); }
.badge.humano { background: var(--human-soft); color: var(--human); }
.badge.aguardando { background: var(--wait-soft); color: var(--wait); }
.badge.finalizada { background: var(--done-soft); color: var(--done); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.sim { background: var(--sim-soft); color: var(--sim); border: 1px dashed currentColor; }
.badge.count { background: var(--brand); color: var(--on-brand); min-width: 20px; justify-content: center; }
.chips { display: flex; gap: var(--sp-1); overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip { flex: none; display: inline-flex; gap: 6px; align-items: center; height: 30px; padding: 0 var(--sp-3);
  border-radius: var(--pill); border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-2); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chip .n { font-size: var(--fs-xs); color: var(--text-3); }

/* ----------------------------------------------------------- cartões/blocos */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4);
  box-shadow: var(--shadow); min-width: 0; }
.card > h3 { margin-bottom: var(--sp-3); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.banner { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius); border: 1px solid; font-size: var(--fs-sm); }
.banner.info { background: var(--info-soft); border-color: var(--info); color: var(--text); }
.banner.warn, .banner.sim { background: var(--sim-soft); border-color: var(--warn); color: var(--text); }
.banner.err { background: var(--err-soft); border-color: var(--err); color: var(--text); }
.banner.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--text-2); }
.empty .icon { width: 36px; height: 36px; color: var(--text-3); margin-bottom: var(--sp-2); }
.empty h3 { color: var(--text); margin-bottom: var(--sp-1); }
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 200% 100%; animation: shimmer 1.2s infinite; height: 14px; margin: 8px 0; }
.skeleton.block { height: 56px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-3); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); }
.kpi .k-label { font-size: var(--fs-sm); color: var(--text-2); }
.kpi .k-value { font-size: var(--fs-2xl); font-weight: 700; margin: 2px 0 6px; }
.kpi .k-src { display: flex; gap: 4px; flex-wrap: wrap; }
.src-tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.src-tag.meta { background: var(--info-soft); color: var(--info); }
.src-tag.wa { background: var(--human-soft); color: var(--human); }
.src-tag.com { background: var(--ok-soft); color: var(--ok); }
.src-tag.fict { background: var(--sim-soft); color: var(--sim); }
.src-tag.int { background: var(--ai-soft); color: var(--ai); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); color: var(--text-2); font-weight: 600; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }

/* -------------------------------------------------------------------- abas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tab { flex: none; padding: 10px 14px; border: 0; background: none; cursor: pointer; color: var(--text-2);
  font-weight: 600; font-size: var(--fs-sm); border-bottom: 2px solid transparent; }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* ----------------------------------------------------------- modal e toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 16, 20, .5); display: flex; align-items: center;
  justify-content: center; padding: var(--sp-4); z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%;
  max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; }
.modal header, .modal footer { padding: var(--sp-4); display: flex; gap: var(--sp-2); align-items: center; }
.modal header { justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal footer { justify-content: flex-end; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal .body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2);
  z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm); }
.toast.err { background: var(--err); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

/* ------------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0; }
.brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4); font-weight: 800; font-size: var(--fs-lg); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; }
.brand small { display: block; font-weight: 500; font-size: var(--fs-xs); color: var(--text-3); }
.tenant-switch { margin: 0 var(--sp-3) var(--sp-3); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--sp-2); overflow-y: auto; flex: 1 1 auto; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: var(--sp-4) var(--sp-3) var(--sp-1); }
.nav a { display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-3); border-radius: var(--radius);
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.nav a .badge { margin-left: auto; }
.side-foot { border-top: 1px solid var(--border); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.who { display: flex; gap: var(--sp-2); align-items: center; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: var(--fs-xl); }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); background: var(--surface);
  border-bottom: 1px solid var(--border); min-height: 60px; }
.topbar h1 { font-size: var(--fs-xl); }
.topbar .menu-btn { display: none; }
.content { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-5); }
.content.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-4); }
.demo-ribbon { background: var(--sim-soft); color: var(--sim); font-size: var(--fs-xs); font-weight: 700; text-align: center;
  padding: 4px var(--sp-3); border-bottom: 1px solid var(--note-border); }
.mobile-nav { display: none; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.login .card { width: 100%; max-width: 560px; padding: var(--sp-6); }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.profile { text-align: left; display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; }
.profile:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ------------------------------------------------------------ caixa de entrada */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 340px; flex: 1 1 auto; min-height: 0; }
.inbox.no-panel { grid-template-columns: 340px minmax(0, 1fr); }
.conv-list { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.conv-list .tools { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); border-bottom: 1px solid var(--border); }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.search .input { padding-left: 34px; }
.conv-scroll { overflow-y: auto; flex: 1 1 auto; }
.conv-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: var(--sp-3); padding: var(--sp-3);
  border-bottom: 1px solid var(--border); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; }
.conv-item:hover { background: var(--surface-2); }
.conv-item[aria-current="true"] { background: var(--brand-soft); }
.conv-item .avatar { width: 42px; height: 42px; }
.conv-item .name { font-weight: 700; }
.conv-item.unread .name, .conv-item.unread .preview { color: var(--text); font-weight: 700; }
.conv-item .preview { color: var(--text-2); font-size: var(--fs-sm); }
.conv-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: var(--fs-xs); color: var(--text-3); }
.conv-item .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); }
.thread-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); background: var(--surface);
  border-bottom: 1px solid var(--border); min-height: 60px; flex-wrap: wrap; }
.thread-head .back { display: none; }
.thread-actions { display: flex; gap: var(--sp-2); margin-left: auto; flex-wrap: wrap; }
.messages { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.day-sep { align-self: center; font-size: var(--fs-xs); color: var(--text-2); background: var(--surface); padding: 2px 10px;
  border-radius: var(--pill); border: 1px solid var(--border); margin: var(--sp-2) 0; }
.bubble { max-width: min(560px, 82%); padding: 8px 12px; border-radius: 12px; box-shadow: var(--shadow); position: relative;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 4px; }
.bubble.ai { align-self: flex-end; background: var(--bubble-ai); border-top-right-radius: 4px; }
.bubble.human { align-self: flex-end; background: var(--bubble-human); border-top-right-radius: 4px; }
.bubble.app { align-self: flex-end; background: var(--surface-3); }
.bubble .who { font-size: var(--fs-xs); font-weight: 700; margin-bottom: 2px; display: flex; gap: 6px; }
.bubble.ai .who { color: var(--ai); } .bubble.human .who { color: var(--human); }
.bubble .foot { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 4px; font-size: 11px;
  color: var(--text-3); white-space: normal; flex-wrap: wrap; }
.bubble .ad { font-size: var(--fs-xs); background: var(--info-soft); color: var(--info); border-radius: 6px; padding: 4px 8px; margin-bottom: 4px; }
.bubble.hidden-content { font-style: italic; color: var(--text-2); }
.note { align-self: center; width: min(620px, 92%); background: var(--note); border: 1px solid var(--note-border); border-radius: var(--radius);
  padding: 8px 12px; font-size: var(--fs-sm); white-space: pre-wrap; }
.note .who { font-size: var(--fs-xs); font-weight: 700; margin-bottom: 2px; }
.sys { align-self: center; font-size: var(--fs-xs); color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--pill); padding: 3px 12px; text-align: center; max-width: 92%; }
.sys.stage { border-color: var(--brand); color: var(--brand); }
.sys.sug { border-style: dashed; border-color: var(--ai); color: var(--ai); }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); display: flex;
  flex-direction: column; gap: var(--sp-2); }
.composer .mode { display: flex; gap: var(--sp-1); }
.composer .entry { display: flex; gap: var(--sp-2); align-items: flex-end; }
.composer textarea { min-height: 40px; max-height: 160px; resize: none; }
.composer.note-mode textarea { background: var(--note); border-color: var(--note-border); }

.contact-panel { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; min-height: 0; }
.contact-panel .sec { padding: var(--sp-4); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--sp-2); }
.contact-panel .sec h4 { color: var(--text-2); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px var(--sp-2); font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); align-items: center;
  padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm); }
.field-row:last-child { border-bottom: 0; }
.prov { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.prov.contato { background: var(--info-soft); color: var(--info); }
.prov.humano { background: var(--ok-soft); color: var(--ok); }
.prov.ia { background: var(--ai-soft); color: var(--ai); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.timeline li { border-left: 2px solid var(--border-strong); padding-left: 10px; }
.panel-close { display: none; }

/* ------------------------------------------------------------------ funil */
.board-tools { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end; }
.board-tools .field { min-width: 150px; }
.board { display: flex; gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-3); align-items: flex-start;
  min-height: 420px; scroll-snap-type: x proximity; }
.col { flex: 0 0 272px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 250px); scroll-snap-align: start; }
.col header { padding: var(--sp-3); display: flex; gap: var(--sp-2); align-items: center; border-bottom: 1px solid var(--border); }
.col header .n { margin-left: auto; }
.col .cards { padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); overflow-y: auto; min-height: 60px; }
.col.drop-ok { border-color: var(--brand); background: var(--brand-soft); }
.col.final-won header { border-bottom-color: var(--ok); } .col.final-lost header { border-bottom-color: var(--err); }
.opp { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3);
  display: flex; flex-direction: column; gap: 6px; cursor: grab; box-shadow: var(--shadow); }
.opp:hover { border-color: var(--border-strong); }
.opp.dragging { opacity: .5; }
.opp .t { font-weight: 700; }
.opp .meta { font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.opp .sug { font-size: var(--fs-xs); color: var(--ai); background: var(--ai-soft); border-radius: 6px; padding: 4px 6px; }
.stage-picker { display: none; }

/* ------------------------------------------------------------------ agente */
.agent-head { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.agent-head .actions { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.uses { font-size: 11px; font-weight: 600; color: var(--text-3); }
.uses.engine { color: var(--ok); } .uses.future { color: var(--ai); }
.kb-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.kb-item .c { color: var(--text-2); font-size: var(--fs-sm); white-space: pre-wrap; }
.lab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-4); }
.lab-chat { background: var(--chat-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2); min-height: 320px; max-height: 560px; overflow-y: auto; }
.insight { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); background: var(--surface);
  font-size: var(--fs-sm); display: flex; flex-direction: column; gap: 6px; }
.layers li { margin-bottom: 4px; }
.hours { display: grid; grid-template-columns: 100px 80px 1fr 1fr; gap: var(--sp-2); align-items: center; }
.hours .input { min-height: 32px; padding: 4px 8px; }
.qual-row { display: grid; grid-template-columns: 1.1fr 0.8fr 0.9fr 1.6fr auto; gap: var(--sp-2); align-items: end;
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.list-editor { display: flex; flex-direction: column; gap: var(--sp-2); }
.list-editor .item { display: grid; grid-template-columns: 1fr 2fr auto; gap: var(--sp-2); }
.stage-row { display: grid; grid-template-columns: 28px 1.4fr 1.2fr auto auto; gap: var(--sp-2); align-items: center;
  padding: var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* --------------------------------------------------------- responsivo: tablet */
@media (max-width: 1099px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar .brand span:not(.brand-mark), .sidebar .nav a span, .nav-sec, .tenant-switch, .side-foot .who-txt { display: none; }
  .nav a { justify-content: center; padding: 10px 0; }
  .nav a .badge { position: absolute; margin: -18px 0 0 22px; }
  .nav a { position: relative; }
  .side-foot { align-items: center; }
  .inbox, .inbox.no-panel { grid-template-columns: 300px minmax(0, 1fr); }
  .contact-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 40; box-shadow: var(--shadow-lg);
    transform: translateX(105%); transition: transform .18s; }
  .contact-panel.open { transform: none; }
  .panel-close { display: inline-flex; }
  .lab { grid-template-columns: 1fr; }
  .qual-row { grid-template-columns: 1fr 1fr; }
}

/* -------------------------------------------------------- responsivo: celular */
@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0 25% 0 0; z-index: 45; box-shadow: var(--shadow-lg); }
  .sidebar.open .brand span, .sidebar.open .nav a span, .sidebar.open .nav-sec, .sidebar.open .tenant-switch,
  .sidebar.open .side-foot .who-txt { display: initial; }
  .sidebar.open .nav a { justify-content: flex-start; padding: 9px var(--sp-3); }
  .topbar { padding: var(--sp-2) var(--sp-3); min-height: 52px; }
  .topbar h1 { font-size: var(--fs-lg); }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: var(--sp-3); }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px;
    color: var(--text-2); text-decoration: none; font-weight: 600; position: relative; }
  .mobile-nav a[aria-current="page"] { color: var(--brand); }
  .mobile-nav a .badge { position: absolute; top: 2px; left: 55%; }
  .inbox, .inbox.no-panel { grid-template-columns: minmax(0, 1fr); }
  .inbox .thread { display: none; }
  .inbox.show-thread .conv-list { display: none; }
  .inbox.show-thread .thread { display: flex; }
  .thread-head { padding: var(--sp-2); gap: var(--sp-2); }
  .thread-head .back { display: inline-flex; }
  .thread-actions { width: 100%; margin-left: 0; }
  .thread-actions .btn { flex: 1 1 auto; }
  .bubble { max-width: 90%; }
  .contact-panel { width: 100vw; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .board { display: none; }
  .stage-picker { display: flex; flex-direction: column; gap: var(--sp-2); }
  .kv { grid-template-columns: 100px minmax(0, 1fr); }
  .hours { grid-template-columns: 1fr 1fr; }
  .qual-row, .list-editor .item, .stage-row { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-value { font-size: var(--fs-xl); }
  .agent-head .actions { margin-left: 0; width: 100%; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
}

/* ------------------------------------------------------------ visão geral */
.funnel-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 2fr 36px; gap: var(--sp-2); align-items: center; font-size: var(--fs-sm); }
.funnel-row strong { text-align: right; }
.track { height: 10px; background: var(--surface-3); border-radius: var(--pill); overflow: hidden; }
.track .bar { height: 100%; background: var(--brand); border-radius: var(--pill); min-width: 2px; }
a.kpi { color: inherit; text-decoration: none; } a.kpi:hover { border-color: var(--brand); }
a.conv-item { text-decoration: none; color: inherit; }
pre.table-wrap { padding: var(--sp-3); font-size: var(--fs-xs); max-height: 420px; overflow: auto; margin: 0; }
details summary { cursor: pointer; }
.conv-item .name, .conv-item .preview { display: block; }
.conv-item > .grow { min-width: 0; overflow: hidden; }
.conv-scroll { overflow-x: hidden; }

/* ---------------------------------------------- ajustes da validação visual (Fase 3) */
.thread-head, .composer, .conv-list .tools { flex: none; }      /* cabeçalho nunca encolhe sob as mensagens */
.bubble .who { flex-wrap: wrap; align-items: center; }
a.btn, a.btn:hover { text-decoration: none; }
.field-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.field-row .row.end { justify-content: flex-start; }
.kb-item { grid-template-columns: minmax(0, 1fr); }
.kb-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.avatar.lg .icon { width: 28px; height: 28px; }
.agent-head h2 { overflow-wrap: anywhere; }
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 20, .45); z-index: 39; }
.ribbon-short { display: none; }
details.filters > summary { display: none; }
@media (max-width: 1099px) {
  details.filters > summary { display: inline-flex; list-style: none; }
  details.filters > summary::-webkit-details-marker { display: none; }
  details.filters:not([open]) > .board-tools { display: none; }
  details.filters[open] > .board-tools { margin-top: var(--sp-2); }
}
@media (max-width: 767px) {
  .ribbon-long { display: none; } .ribbon-short { display: inline; }
  .sidebar.open .nav a .badge { position: static; margin: 0 0 0 auto; }
  .composer .subtle { font-size: var(--fs-xs); }
}
.col { width: 272px; }
.opp .meta .badge { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }

/* ======================================================= Fase 3.1 — simplificação */
.page.narrow { max-width: 920px; }
.fit { align-self: flex-start; }
.top-gap { margin-top: var(--sp-3); }
.nowrap { flex-wrap: nowrap; }
.textarea.short { min-height: 60px; }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
details.card > summary, details.more > summary { font-weight: 600; color: var(--text-2); list-style-position: inside; }
details.card[open] > summary { margin-bottom: var(--sp-1); }

/* status: ponto de cor discreto em vez de etiquetas */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 6px; vertical-align: middle; flex: none; }
.dot.ia { background: var(--ai); } .dot.humano { background: var(--human); } .dot.aguardando { background: var(--wait); }
.dot.finalizada { background: var(--done); } .dot.ok { background: var(--ok); }

/* menu de mais ações */
details.menu { position: relative; }
details.menu > summary { list-style: none; font-size: 18px; line-height: 1; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 220px; z-index: 30; padding: 4px; display: flex; flex-direction: column; }
.menu-item { text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: var(--fs-sm); }
.menu-item:hover { background: var(--surface-3); }

/* caixa de entrada */
.chip-select { width: auto; min-height: 30px; height: 30px; padding: 2px 8px; border-radius: var(--pill); font-size: var(--fs-sm); flex: none; }
.not-sent { font-size: 11px; color: var(--sim); font-weight: 600; }
.delivery.ok { font-size: 11px; color: var(--ok, #1a7f4b); font-weight: 600; }
.composer-note { font-size: var(--fs-xs); }
.composer .row.between { flex-wrap: nowrap; }
.kv.essentials { grid-template-columns: 100px minmax(0, 1fr); }
.kv.essentials dd .select { min-height: 32px; padding: 4px 8px; }
details.more > summary { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.inbox.no-panel .contact-panel { display: none; }
@media (min-width: 1100px) { .inbox:not(.no-panel) { grid-template-columns: 340px minmax(0, 1fr) 320px; } }
@media (max-width: 1099px) { .inbox.no-panel .contact-panel { display: block; } }

/* funil */
.board-bar .search { max-width: 360px; }
.board-bar .owner .select { min-width: 180px; }
.opp { cursor: pointer; gap: 4px; }
.opp .i { font-size: var(--fs-sm); color: var(--text-2); }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.sug-mini { color: var(--ai); display: inline-flex; }
.col header .n { margin-left: auto; color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; }
.empty-col { text-align: center; margin: var(--sp-2) 0; }
.stage-list { display: none; }
.stage-sec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: var(--sp-2); }
.stage-sec > summary { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3); font-weight: 700; list-style: none; }
.stage-sec > summary::-webkit-details-marker { display: none; }
.stage-sec > summary .n { color: var(--text-3); }
.stage-sec .cards { padding: 0 var(--sp-2) var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw); background: var(--surface); z-index: 40;
  box-shadow: var(--shadow-lg); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); overflow-y: auto;
  transform: translateX(105%); transition: transform .18s; visibility: hidden; }
.drawer.open { transform: none; visibility: visible; }
.kpis.compact { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* minha IA */
.publish-bar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.step { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); text-align: left; min-width: 0; }
.step .num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; flex: none; }
.step .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step[aria-selected="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.step[aria-selected="true"] .num { background: var(--brand); color: var(--on-brand); }
.kb-row { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.kb-row:last-of-type { border-bottom: 0; }
.kb-row .c { color: var(--text-2); font-size: var(--fs-sm); white-space: pre-wrap; margin: 2px 0 4px; }
.kb-edit { border: 1px solid var(--brand); border-radius: var(--radius); padding: var(--sp-3); background: var(--surface-2); }
.q-row { display: flex; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.q-row.off { opacity: .7; }
.q-actions { display: flex; flex-direction: column; gap: 2px; }
.list-editor .item.two { grid-template-columns: 1fr auto; }
.hours { grid-template-columns: 90px 1fr 1fr; max-width: 420px; }

/* configurações */
.people { display: flex; flex-direction: column; }
.person { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.person .select { width: auto; }
.add-person { display: grid; grid-template-columns: 1fr 1.3fr auto auto; gap: var(--sp-2); }
.stage-row { grid-template-columns: 24px minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.stage-more > summary { font-size: var(--fs-xs); }
.stage-more[open] { display: flex; flex-direction: column; gap: 4px; }

/* administração */
.company-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-3); }
.card.company { display: flex; gap: var(--sp-3); align-items: center; }
.wizard-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-2); }
.wizard-steps li { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; min-width: 0; }
.wizard-steps .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); flex: none; font-size: 12px; }
.wizard-steps .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wizard-steps li.on { color: var(--brand); }
.wizard-steps li.on .num { background: var(--brand); color: var(--on-brand); }
.wizard-steps li.done .num { background: var(--ok-soft); color: var(--ok); }
.seg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-2); }
.seg { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; }
.seg[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.w-row { display: flex; gap: var(--sp-2); align-items: center; }
.w-row > .w-cells, .w-row > .input { flex: 1 1 auto; min-width: 0; }
.w-cells { display: grid; gap: var(--sp-2); }
.w-cells.two { grid-template-columns: 1fr 1.6fr; }
.w-cells.three { grid-template-columns: 1fr 1.3fr 0.8fr; }
.num-col { width: 18px; }
.cat { font-size: var(--fs-xs); width: 170px; }
.input.time { width: 110px; }
.wizard-nav { margin-top: var(--sp-2); }

/* navegação do celular: quantos itens houver (até 4) */
@media (max-width: 767px) {
  .mobile-nav[data-n="4"] { grid-template-columns: repeat(4, 1fr); }
  .mobile-nav[data-n="3"] { grid-template-columns: repeat(3, 1fr); }
  .mobile-nav[data-n="2"] { grid-template-columns: repeat(2, 1fr); }
  .mobile-nav[data-n="1"] { grid-template-columns: 1fr; }
  .board, .board-bar .owner { display: none; }
  .stage-list { display: block; }
  .step { flex-direction: column; justify-content: center; padding: 8px 4px; gap: 4px; font-size: 11px; text-align: center; }
  .step .lbl { white-space: normal; line-height: 1.2; }
  .wizard-steps .lbl { display: none; }
  .wizard-steps li.on .lbl { display: inline; }
  .wizard-steps { grid-template-columns: repeat(5, auto); justify-content: space-between; }
  .w-cells.two, .w-cells.three { grid-template-columns: minmax(0, 1fr); }
  .w-row { align-items: flex-start; border-bottom: 1px dashed var(--border); padding-bottom: var(--sp-2); }
  .cat { display: none; }
  .add-person { grid-template-columns: minmax(0, 1fr); }
  .stage-row { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .stage-row .stage-more { grid-column: 2 / -1; grid-row: 2; }
  .person { flex-wrap: wrap; }
  .thread-actions { width: auto; margin-left: auto; flex-wrap: nowrap; }
  .thread-actions .btn { flex: none; }
  #panelToggle .lbl { display: none; }
  .q-row { flex-direction: column; }
  .q-actions { flex-direction: row; }
  .hours { grid-template-columns: 70px 1fr 1fr; }
  .company-list { grid-template-columns: minmax(0, 1fr); }
}

/* Fase 3.1 — ajustes da validação visual */
.opp .wait-txt { color: var(--wait); font-weight: 600; }
.opp .sug-mini { font-size: var(--fs-xs); color: var(--ai); display: flex; gap: 4px; align-items: center; }
.q-more > summary { font-size: var(--fs-xs); }
.contact-panel .kv dd .subtle { font-size: var(--fs-xs); }
@media (max-width: 767px) {
  .composer .row.between { flex-wrap: wrap; row-gap: 4px; }
}
