/* ════════════════════════════════════════════════════════════════════════════
   AgentERP · Design System
   "A interface é silenciosa, os dados falam e o laranja aparece só quando o
   Agente age." Laranja = Agente. Azul = ERP / usuário no comando.
   Tema claro padrão; escuro via [data-theme="dark"] no <html>.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Tokens de cor ───────────────────────────────────────────────────────── */
:root,
[data-theme="light"] {
  --orange: #ff7a00;
  --onOrange: #0f1b2d;
  --orangeInk: #a84f00;
  --orangeSoft: #fff1e5;
  --navy: #315580;
  --navyHover: #26446a;
  --onNavy: #ffffff;
  --navySoft: #e8eef6;
  --canvas: #e6e9ee;
  --surface: #f5f7fa;
  --surfaceRaised: #ffffff;
  --hover: #eef1f5;
  --line: #e3e7ee;
  --lineHover: #c5ccd6;
  --lineStrong: #8792a3;
  --ink: #0f1b2d;
  --inkMuted: #5b6678;
  --success: #1f7a4d;
  --successSoft: #e6f4ec;
  --warning: #8a5a00;
  --warningSoft: #fdf3d7;
  --danger: #c62828;
  --dangerSoft: #fdecec;
  --focus: #315580;
  --link: var(--navy);
  --shadowOverlay: 0 8px 24px rgba(15, 27, 45, 0.12);
  --shadowShell: 0 30px 80px -30px rgba(15, 27, 45, 0.28), 0 0 0 1px rgba(15, 27, 45, 0.05);
  --shadowMain: 0 0 0 1px rgba(15, 27, 45, 0.04), 0 1px 3px rgba(15, 27, 45, 0.04);
  --shadowActive: 0 0 0 1px var(--line), 0 1px 2px rgba(15, 27, 45, 0.04);
  --scrim: rgba(15, 27, 45, 0.4);
  --seriesIn: #2a78d6;   /* gráficos: entradas (validado com seriesOut, claro e escuro) */
  --seriesOut: #eb6834;  /* gráficos: saídas */
  color-scheme: light;
}

[data-theme="dark"] {
  --orange: #ff7a00;
  --onOrange: #0f1b2d;
  --orangeInk: #ff9a3d;
  --orangeSoft: #3a2008;
  --navy: #8fb0d9;
  --navyHover: #a9c3e4;
  --onNavy: #0b1220;
  --navySoft: #16243a;
  --canvas: #060a12;
  --surface: #0b1220;
  --surfaceRaised: #131c2c;
  --hover: #1a2536;
  --line: #243044;
  --lineHover: #34425a;
  --lineStrong: #5f6d82;
  --ink: #eef2f7;
  --inkMuted: #9aa6b8;
  --success: #4ade80;
  --successSoft: #0f2a1c;
  --warning: #facc15;
  --warningSoft: #2e2506;
  --danger: #f87171;
  --dangerSoft: #34141a;
  --focus: #8fb0d9;
  --link: var(--navy);
  --shadowOverlay: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadowShell: 0 30px 80px -30px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadowMain: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadowActive: 0 0 0 1px var(--line);
  --scrim: rgba(0, 0, 0, 0.6);
  --seriesIn: #3987e5;
  --seriesOut: #d95926;
  color-scheme: dark;
}

/* ── Tokens de espaço, forma e tipo ──────────────────────────────────────── */
:root {
  --space1: 4px;
  --space2: 8px;
  --space3: 12px;
  --space4: 16px;
  --space6: 24px;
  --space8: 32px;
  --space12: 48px;
  --space16: 64px;
  --radiusSm: 4px;
  --radiusMd: 8px;
  --radiusLg: 12px;
  --radiusFull: 999px;
  --font-display: Anton, Impact, "Arial Narrow", sans-serif;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --sidebar-w: 248px;
  --content-w: 680px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
img, svg { display: block; }
a { color: var(--link); }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radiusSm);
  padding: 1px 5px;
}
kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 16px;
  color: var(--inkMuted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  background: var(--surfaceRaised);
}
[hidden] { display: none !important; }
::selection { background: var(--navySoft); color: var(--ink); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radiusMd);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 1000;
  background: var(--navy); color: var(--onNavy);
  padding: 8px 12px; border-radius: var(--radiusMd);
  transform: translateY(-200%); transition: transform .15s var(--ease);
  text-decoration: none; font-size: 13px; font-weight: 600;
}
.skip-link:focus { transform: none; }

.muted { color: var(--inkMuted); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 13px; }

/* ── Ícones ──────────────────────────────────────────────────────────────── */
.icon {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon--xs { width: 13px; height: 13px; stroke-width: 1.8; }
.icon--sm { width: 14px; height: 14px; stroke-width: 2; }
.icon--lg { width: 22px; height: 22px; stroke-width: 1.5; }

/* ── Logo (troca junto com o tema) ───────────────────────────────────────── */
.brand-logo img { height: auto; width: 100%; }
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }

/* ── Tipografia utilitária ───────────────────────────────────────────────── */
.display-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: 0.5px;
  color: var(--ink);
}
.h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
.label-caps {
  font-size: 11px; line-height: 16px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--inkMuted);
}
.eyebrow {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--inkMuted);
}

/* ── Botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space2);
  height: 40px; padding: 0 var(--space4);
  border-radius: var(--radiusMd);
  font-size: 14px; font-weight: 600; line-height: 1;
  border: 1px solid transparent;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
  white-space: nowrap;
}
.btn-primary { background: var(--navy); color: var(--onNavy); }
.btn-primary:hover:not(:disabled) { background: var(--navyHover); }
.btn-primary:disabled { opacity: .55; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); height: 36px; font-weight: 500; font-size: 13px; }
.btn-ghost:hover { background: var(--hover); }
.btn-agent { background: var(--orange); color: var(--onOrange); }
.btn-block { width: 100%; }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--link); font-weight: 500; font-size: inherit;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px;
  transition: text-decoration-color .15s var(--ease);
}
.btn-link:hover { text-decoration-color: currentColor; }
.btn .spinner, .btn-send .spinner { width: 14px; height: 14px; }

.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--radiusMd);
  color: var(--inkMuted);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn--outlined {
  width: 30px; height: 30px;
  border: 1px solid var(--line); background: var(--surfaceRaised);
}
.icon-btn--outlined .icon { width: 14px; height: 14px; stroke-width: 2; }
.icon-btn--outlined:hover { background: var(--surface); }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Formulários ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space4); }
.field label {
  font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.4px; color: var(--ink);
}
.field input,
.field select {
  height: 42px; width: 100%;
  padding: 0 var(--space3);
  background: var(--surfaceRaised);
  border: 1px solid var(--lineStrong);
  border-radius: var(--radiusMd);
  font-size: 15px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238792a3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}
.field input::placeholder { color: var(--inkMuted); opacity: .8; }
.field input:hover, .field select:hover { border-color: var(--inkMuted); }
.field input:focus-visible, .field select:focus-visible,
.filter-dates input:focus-visible, .rename-chat-input:focus-visible { outline: none; }
.field input:focus, .field select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--navySoft);
}
.field input[readonly] { background: var(--surface); color: var(--inkMuted); border-color: var(--line); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-help { font-size: 12px; line-height: 16px; color: var(--inkMuted); }
.mono-input { font-family: var(--font-mono) !important; font-size: 14px !important; letter-spacing: .02em; }
.input-otp {
  font-family: var(--font-mono) !important; font-size: 22px !important;
  letter-spacing: .5em; text-align: center; height: 52px !important;
  font-variant-numeric: tabular-nums;
}
.field-grid { display: grid; grid-template-columns: 180px 1fr; gap: 0 var(--space4); }
.field-grid .field--span { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space2); margin-top: var(--space2); }

.form-error {
  display: none;
  align-items: flex-start; gap: var(--space2);
  background: var(--dangerSoft); color: var(--danger);
  border-radius: var(--radiusMd);
  padding: 10px var(--space3); margin-bottom: var(--space4);
  font-size: 13px; line-height: 20px; font-weight: 500;
}
.form-error.visible { display: flex; animation: shake .3s var(--ease); }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* Switch */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space4);
  padding: var(--space3) 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.switch-row:last-of-type { margin-bottom: var(--space4); }
.switch-title { display: block; font-size: 14px; font-weight: 500; }
/* Configurações → Financeiro: multa e juros por atraso */
.encargos-bloco { border: 0; padding: 0; margin: 0 0 var(--space6); min-width: 0; }
.encargos-titulo { font-size: 14px; line-height: 20px; font-weight: 600; padding: 0; }
.encargos-vale { margin-top: var(--space6); padding-top: var(--space4); border-top: 1px solid var(--line); }
.encargos-vale .encargos-titulo { margin-bottom: var(--space3); }
.encargos-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--space4); }
@media (max-width: 600px) { .encargos-grid { grid-template-columns: 1fr; } }
.switch-sub { display: block; font-size: 13px; line-height: 20px; color: var(--inkMuted); }
.switch {
  appearance: none; flex-shrink: 0;
  width: 36px; height: 20px; border-radius: var(--radiusFull);
  background: var(--lineStrong); position: relative; cursor: pointer;
  transition: background-color .15s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .15s var(--ease);
}
.switch:checked { background: var(--navy); }
.switch:checked::after { transform: translateX(16px); }
[data-theme="dark"] .switch:checked::after { background: var(--onNavy); }

/* Segmented control */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radiusMd);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 var(--space3);
  border-radius: 6px; font-size: 13px; color: var(--inkMuted); font-weight: 500;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.segmented button:hover { color: var(--ink); }
.segmented button.active,
.segmented button[aria-pressed="true"] {
  background: var(--surfaceRaised); color: var(--navy); box-shadow: var(--shadowActive);
}
.segmented--block { display: flex; }
.segmented--block button { flex: 1; min-width: 0; justify-content: center; padding: 0 4px; font-size: 12.5px; }
.segmented--block .icon { display: none; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: var(--radiusSm);
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--surface); color: var(--inkMuted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--successSoft); color: var(--success); }
.badge--warning { background: var(--warningSoft); color: var(--warning); }
.badge--danger  { background: var(--dangerSoft);  color: var(--danger); }
.badge--info    { background: var(--navySoft);    color: var(--navy); }
.badge--agent   { background: var(--orangeSoft);  color: var(--orangeInk); }
.badge--agent::before { background: var(--orange); }

/* ── Avisos ──────────────────────────────────────────────────────────────── */
.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: var(--space3) var(--space4);
  border-radius: var(--radiusMd);
  font-size: 13px; line-height: 20px;
}
.notice .icon { margin-top: 2px; }
.notice--info    { background: var(--navySoft);    color: var(--ink); }
.notice--info .icon { color: var(--navy); }
.notice--warning { background: var(--warningSoft); color: var(--ink); }
.notice--warning .icon { color: var(--warning); }
.notice--danger  { background: var(--dangerSoft);  color: var(--ink); }
.notice--danger .icon { color: var(--danger); }
.notice--success { background: var(--successSoft); color: var(--ink); }
.notice--success .icon { color: var(--success); }
/* Fiscal (NFC-e) e certificado A1 */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space4, 16px); }
@media (max-width: 700px) { .form-grid-2 { grid-template-columns: 1fr; } }
.fiscal-prontidao { align-items: flex-start; margin-bottom: 16px; }
.fiscal-lista { list-style: none; margin: 6px 0 0; padding: 0; font-size: 0.92em; }
.fiscal-lista li { margin: 2px 0; }
.certificado-atual { margin-bottom: 16px; }
.nota-acoes { display: flex; gap: 12px; flex-wrap: wrap; }
.texto-perigo { color: var(--danger); }

/* ── Cartões ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surfaceRaised);
  border: 1px solid var(--line);
  border-radius: var(--radiusLg);
  padding: var(--space6);
}

/* ── Avatares ────────────────────────────────────────────────────────────── */
.avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--line); color: var(--ink);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar--square { border-radius: var(--radiusMd); background: var(--navySoft); color: var(--navy); }

/* Marca do Agente: ícone oficial do AgentERP */
.agent-mark {
  width: 28px; height: 28px; flex-shrink: 0;
  display: block; object-fit: contain;
}
.agent-mark--lg { width: 44px; height: 44px; }

/* ════════════════════════════════════════════════════════════════════════════
   VIEWS
   ════════════════════════════════════════════════════════════════════════════ */
.view-panel { display: none; }
.view-panel.active { display: flex; animation: fadeIn .2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Autenticação ────────────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space8) var(--space4);
  gap: var(--space4);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surfaceRaised);
  border-radius: 20px;
  box-shadow: var(--shadowShell);
  padding: 40px 36px 32px;
}
.auth-card--wide { max-width: 480px; }
.auth-logo { width: 132px; margin-bottom: var(--space8); }
.auth-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: 34px; line-height: 1.1; letter-spacing: 0.5px;
  margin-bottom: var(--space2);
}
.auth-sub { color: var(--inkMuted); font-size: 14.5px; line-height: 22px; margin-bottom: var(--space6); }
.auth-form { margin: 0; }
.forgot-link { margin: calc(-1 * var(--space2)) 0 var(--space4); text-align: right; font-size: 13.5px; }
.forgot-link--center { margin: var(--space4) 0 0; text-align: center; }
.auth-switch {
  margin-top: var(--space6); padding-top: var(--space4);
  border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--inkMuted); text-align: center;
}
.auth-foot {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--inkMuted);
}
.auth-legal { margin-top: 4px; }
.auth-legal a { color: inherit; }
/* Caixa de aceite dos termos (core/termos.py): cadastro, convite e tela de aceite. */
.aceite-termos {
  display: flex; align-items: flex-start; gap: var(--space2);
  font-size: 13.5px; line-height: 1.45; color: var(--inkMuted); cursor: pointer;
  margin-bottom: var(--space2);
}
.aceite-termos input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--navy); }
.aceite-termos[aria-invalid="true"] { color: var(--danger); }
.otp-actions {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space2);
  margin-top: var(--space3); font-size: 13px;
}

.company-list { display: flex; flex-direction: column; gap: var(--space2); margin-bottom: var(--space6); }
.company-card {
  display: flex; align-items: center; gap: var(--space3);
  width: 100%; text-align: left;
  padding: var(--space3) var(--space4);
  background: var(--surfaceRaised);
  border: 1px solid var(--line);
  border-radius: var(--radiusLg);
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.company-card:hover { border-color: var(--navy); background: var(--surface); }
.company-card .avatar { width: 40px; height: 40px; font-size: 14px; }
.company-info { flex: 1; min-width: 0; }
.company-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-cnpj { font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--inkMuted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-chevron { color: var(--inkMuted); }
.company-card.is-loading { pointer-events: none; opacity: .7; }

.user-row {
  display: flex; align-items: center; gap: var(--space2);
  padding-top: var(--space4); border-top: 1px solid var(--line);
  font-size: 13px; color: var(--inkMuted);
}
.user-row-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row strong { color: var(--ink); font-weight: 600; }

/* ── Shell da aplicação ──────────────────────────────────────────────────── */
#view-app, #view-plataforma { height: 100vh; height: 100dvh; padding: var(--space8); justify-content: center; }
.shell {
  position: relative;
  flex: 1; max-width: 1440px; min-height: 0; min-width: 0;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadowShell);
  display: flex; padding: var(--space2);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  min-height: 0;
  transition: margin-left .25s var(--ease), opacity .2s var(--ease);
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); opacity: 0; visibility: hidden; }
.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--line);
}
.sb-logo { width: 104px; }
.sb-close { display: none; }
.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.sb-label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--inkMuted); padding: 20px 8px 8px;
}

/* Histórico */
.hist { display: flex; flex-direction: column; gap: 2px; }
.hg-label {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  font-size: 11.5px; font-weight: 500; color: var(--inkMuted);
  padding: 8px 10px 4px; border-radius: 6px;
}
.hg-label:hover { color: var(--ink); }
.hg-label .icon { width: 12px; height: 12px; }
.hg-items-container { display: flex; flex-direction: column; gap: 2px; }
.hg-items-container.collapsed { display: none; }
.hist-empty { font-size: 13px; color: var(--inkMuted); padding: 4px 10px; }

.hi {
  position: relative;
  display: flex; align-items: center; gap: var(--space2);
  border-radius: var(--radiusMd);
  color: var(--inkMuted);
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.hi:hover { color: var(--ink); background: var(--hover); }
.hi-btn {
  flex: 1; min-width: 0; text-align: left;
  padding: 8px 10px; font-size: 13.5px; line-height: 20px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: var(--radiusMd);
}
.hi.active {
  background: var(--surfaceRaised); box-shadow: var(--shadowActive);
  color: var(--navy); font-weight: 500;
}
.chat-menu-btn {
  width: 26px; height: 26px; margin-right: 4px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 6px;
  color: var(--inkMuted); opacity: 0;
  transition: opacity .12s var(--ease), background-color .12s var(--ease);
}
.chat-menu-btn .icon { width: 14px; height: 14px; }
.hi:hover .chat-menu-btn,
.hi.active .chat-menu-btn,
.chat-menu-btn:focus-visible,
.chat-menu-btn[aria-expanded="true"] { opacity: 1; }
.chat-menu-btn:hover { background: var(--hover); color: var(--ink); }
.rename-chat-input {
  width: 100%; height: 36px; padding: 0 10px;
  font-size: 13.5px; color: var(--ink);
  background: var(--surfaceRaised);
  border: 1px solid var(--focus); border-radius: var(--radiusMd);
  box-shadow: 0 0 0 3px var(--navySoft);
}

/* Áreas */

/* Rodapé da sidebar */
.sb-foot {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--space3) 0; border-bottom: 1px solid var(--line);
}
.sb-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--radiusMd);
  font-size: 13.5px; color: var(--ink);
  transition: background-color .12s var(--ease);
}
.sb-link:hover { background: var(--hover); }
.sb-user-wrap { position: relative; }
.sb-user {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 14px 8px 4px; border-radius: var(--radiusMd);
}
.sb-user:hover .sb-user-name { color: var(--navy); }
.sb-user-text { flex: 1; min-width: 0; }
.sb-user-name { font-size: 13.5px; font-weight: 500; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-sub { font-size: 12px; line-height: 16px; color: var(--inkMuted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Popover / menus */
.popover {
  position: absolute; z-index: 60;
  background: var(--surfaceRaised);
  border: 1px solid var(--line);
  border-radius: var(--radiusLg);
  box-shadow: var(--shadowOverlay);
  padding: 6px;
  animation: popIn .14s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.user-menu { left: 0; right: 0; bottom: calc(100% + 6px); }
.user-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-menu-section { padding: 4px 4px 8px; }
.menu-label { font-size: 11.5px; font-weight: 500; color: var(--inkMuted); padding: 0 4px 6px; }
.menu-sep { height: 1px; background: var(--line); margin: 2px -6px 6px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13.5px; color: var(--ink);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.chat-context-menu { position: fixed; min-width: 168px; }

/* ── Área principal ──────────────────────────────────────────────────────── */
.main {
  flex: 1; min-width: 0;
  background: var(--surfaceRaised);
  border-radius: 22px;
  box-shadow: var(--shadowMain);
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.topbar {
  min-height: 56px; flex-shrink: 0;
  display: grid; grid-template-columns: minmax(72px, auto) minmax(0, 1fr) minmax(72px, auto); align-items: center; gap: var(--space2);
  padding: 8px 18px;
}
/* Nome completo da conversa: quebra em até duas linhas antes de cortar. */
.topbar-title {
  font-size: 13.5px; line-height: 20px; font-weight: 500; color: var(--ink);
  text-align: center; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.topbar-actions { display: flex; justify-content: flex-end; gap: 2px; }
.topbar-new { display: none; }
.sidebar.collapsed ~ .main .topbar-new { display: grid; }

.workspace-content { flex: 1; min-height: 0; position: relative; display: flex; }
.app-panel { display: none; flex: 1; min-width: 0; }
.app-panel.active { display: flex; flex-direction: column; animation: fadeIn .18s var(--ease); }

/* ── Chat ────────────────────────────────────────────────────────────────── */
#panel-chat { min-height: 0; }
.chat-hero {
  display: none;
  flex: 1; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 0 var(--space8);
}
.chat-hero-inner { width: 100%; max-width: 640px; display: flex; flex-direction: column; }
.chat-hero .agent-mark { margin-bottom: 22px; }
.chat-hero-sub { margin: 8px 0 26px; font-size: 14.5px; line-height: 22px; color: var(--inkMuted); }
.chat-spacer { display: none; flex: 1; }
.trust-row {
  display: none;
  flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px;
  padding: 22px 24px; font-size: 12.5px; color: var(--inkMuted);
}
.trust-row > span { display: inline-flex; align-items: center; gap: 6px; }
.trust-row .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--lineHover); }

#panel-chat.is-empty .chat-hero,
#panel-chat.is-empty .trust-row { display: flex; }
#panel-chat.is-empty .chat-spacer { display: block; }
#panel-chat.is-empty .messages { display: none; }
#panel-chat:not(.is-empty) .suggestions { display: none; }
#panel-chat:not(.is-empty) .composer-area { padding-bottom: max(20px, env(safe-area-inset-bottom)); }

.messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px var(--space8) var(--space6);
  display: flex; flex-direction: column; gap: 22px;
  scroll-behavior: smooth;
}
.messages > * { width: 100%; max-width: var(--content-w); margin-left: auto; margin-right: auto; }

.msg { display: flex; animation: msgIn .22s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg--user { justify-content: flex-end; }
.msg--user .bubble {
  max-width: 78%;
  background: var(--navySoft); color: var(--ink);
  border-radius: 12px 12px 4px 12px;
  padding: 11px 15px;
  font-size: 14.5px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg--user .bubble::after { content: ""; display: block; clear: both; }
/* Horário dentro do balão, no canto inferior direito, como no WhatsApp */
.bubble-time {
  float: right; margin: 8px -5px -6px 14px;
  font-size: 11px; line-height: 16px; color: var(--inkMuted);
  font-variant-numeric: tabular-nums; white-space: nowrap; user-select: none;
}

/* Separador de dia entre as mensagens */
.day-sep { display: flex; justify-content: center; margin: 4px auto -4px; }
.day-sep span {
  font-size: 12px; line-height: 16px; font-weight: 500; color: var(--inkMuted);
  background: var(--surface); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: var(--radiusFull);
}
.msg--ai { gap: 14px; align-items: flex-start; }
.msg-body { flex: 1; min-width: 0; padding-top: 3px; }
.msg-text {
  font-size: 14.5px; line-height: 1.65; color: var(--ink);
  overflow-wrap: anywhere; text-wrap: pretty;
}
.msg-text > * { margin: 0; }
.msg-text > * + * { margin-top: 10px; }
.msg-text strong { font-weight: 600; }
.msg-text em { font-style: italic; color: var(--inkMuted); }
.msg-text em strong { color: var(--ink); }
.msg-text del { color: var(--inkMuted); }
.msg-text .sep { color: var(--lineStrong); margin: 0 2px; }
/* Pares "Campo: valor" (ex.: dados de um cadastro para confirmar) */
.msg-text .kv {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radiusMd);
  background: var(--surface); font-size: 14px; line-height: 20px;
}
.msg-text .kv dt { color: var(--inkMuted); }
.msg-text .kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.msg-text h3, .msg-text h4 { font-size: 15px; line-height: 22px; font-weight: 600; margin-top: 14px; }
.msg-text ul, .msg-text ol { margin: 0; padding-left: 20px; }
.msg-text li + li { margin-top: 4px; }
.msg-text li::marker { color: var(--inkMuted); }
.msg-text a { color: var(--link); text-underline-offset: 2px; }
.msg-text hr { border: 0; border-top: 1px solid var(--line); }
.msg-text .md-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radiusMd); }
.msg-text table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.msg-text th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .4px; color: var(--inkMuted); background: var(--surface); }
.msg-text th, .msg-text td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.msg-text tr:last-child td { border-bottom: 0; }
.msg-text .alert-inline {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-radius: var(--radiusMd);
  background: var(--warningSoft); font-size: 13.5px; line-height: 20px;
}
.msg-text .alert-inline .icon { color: var(--warning); margin-top: 2px; }
.msg-text .alert-inline.danger { background: var(--dangerSoft); }
.msg-text .alert-inline.danger .icon { color: var(--danger); }
.msg-text .alert-inline.success { background: var(--successSoft); }
.msg-text .alert-inline.success .icon { color: var(--success); }
.msg-text .alert-inline.neutro { background: transparent; padding: 2px 0; }
.msg-text .alert-inline.neutro .icon { color: var(--inkMuted); }
/* Linha que começa com emoji: o emoji numa coluna fixa, o texto alinhado (como na demonstração do site). */
.msg-text .md-linha-emoji { display: flex; align-items: flex-start; gap: 8px; }
.msg-text .md-linha-emoji .md-emoji { flex: none; width: 22px; text-align: center; }
.msg-text .md-linha-emoji + .md-linha-emoji { margin-top: 4px; }   /* as linhas seguidas ficam juntas */

.msg--error .msg-text {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--dangerSoft); border-radius: var(--radiusMd);
  padding: 10px 12px; font-size: 13.5px; line-height: 20px;
}
.msg--error .msg-text .icon { color: var(--danger); margin-top: 2px; }
.msg--error .msg-text > * + * { margin-top: 0; }
.msg--error .msg-erro-texto { flex: 1; min-width: 0; }
.msg--error .msg-erro-texto > :first-child { margin-top: 0; }
.msg--error .msg-erro-texto > :last-child { margin-bottom: 0; }
.msg--error .msg-erro-texto > * + * { margin-top: 6px; }

.msg-meta { display: flex; align-items: center; gap: 4px; margin: 6px 0 -6px; min-height: 28px; }
.msg-time { font-size: 11.5px; color: var(--inkMuted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.msg-meta .msg-action { opacity: 0; transition: opacity .15s var(--ease); }
.msg--ai:hover .msg-action,
.msg--ai:focus-within .msg-action,
.msg--ai:last-child .msg-action { opacity: 1; }
.msg-action {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; color: var(--inkMuted);
}
.msg-action:hover { background: var(--hover); color: var(--ink); }
.msg-action .icon { width: 14px; height: 14px; }

.typing { display: flex; gap: 4px; align-items: center; height: 28px; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--orange);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.typing-label { font-size: 13px; color: var(--inkMuted); margin-left: 8px; }

/* Chips (sugestões) */
.chips, .suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { margin-top: 12px; }
.suggestions { justify-content: center; margin-top: 16px; max-width: 640px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surfaceRaised);
  border-radius: var(--radiusMd);
  padding: 7px 11px; font-size: 13px; line-height: 18px; color: var(--ink);
  transition: background-color .12s var(--ease), border-color .12s var(--ease);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--navy); flex-shrink: 0; }
.chip:hover { background: var(--surface); border-color: var(--lineHover); }
.chip:disabled { opacity: .5; }

/* Composer */
.composer-area {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px var(--space8) 0;
}
.composer {
  width: 100%; max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radiusLg);
  padding: 12px 12px 10px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
#panel-chat:not(.is-empty) .composer { max-width: var(--content-w); }
.composer:focus-within { border-color: var(--navy); }
.composer { position: relative; }
.composer-row { display: flex; gap: 10px; align-items: flex-start; }
.agent-tag {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  max-width: 160px;
  background: var(--surfaceRaised); border: 1px solid var(--line); border-radius: var(--radiusMd);
  padding: 3px 8px; margin-top: 1px;
  font-family: var(--font-mono); font-size: 11.5px; line-height: 16px; color: var(--inkMuted);
}
.agent-tag > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); flex-shrink: 0; }
.chat-input {
  flex: 1; min-width: 0;
  border: 0; outline: none; background: transparent; resize: none;
  font-size: 14.5px; line-height: 1.5; color: var(--ink);
  padding: 3px 0 0; min-height: 66px; max-height: 240px;
}
#panel-chat:not(.is-empty) .chat-input { min-height: 24px; }
.chat-input::placeholder { color: var(--inkMuted); }
.chat-input:disabled { opacity: .6; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space2); margin-top: 6px; }
.composer-hint { font-size: 12px; color: var(--inkMuted); display: inline-flex; align-items: center; gap: 4px; }
.btn-send {
  width: 34px; height: 34px; margin-left: auto;
  display: grid; place-items: center;
  border-radius: var(--radiusMd);
  background: var(--navy); color: var(--onNavy);
  transition: background-color .15s var(--ease), opacity .15s var(--ease);
}
.btn-send .icon { width: 15px; height: 15px; stroke-width: 2; }
.btn-send:hover:not(:disabled) { background: var(--navyHover); }
.btn-send:disabled { opacity: .35; }
.btn-send.is-busy { opacity: 1; }

/* Ditado por voz */
.btn-mic {
  width: 34px; height: 34px; margin-left: auto;
  display: grid; place-items: center;
  border-radius: var(--radiusMd);
  color: var(--inkMuted); background: transparent;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.btn-mic .icon { width: 17px; height: 17px; stroke-width: 2; }
.btn-mic:hover:not(:disabled) { background: var(--surface); color: var(--ink); }
.btn-mic:disabled { opacity: .35; }
.btn-mic.is-listening { background: var(--dangerSoft); color: var(--danger); animation: micPulse 1.4s ease-in-out infinite; }
.btn-mic:not([hidden]) ~ .btn-send { margin-left: 0; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 var(--dangerSoft); } 50% { box-shadow: 0 0 0 6px var(--dangerSoft); } }

/* ── Páginas (painéis e configurações) ───────────────────────────────────── */
#panel-dashboard, #panel-settings { overflow-y: auto; }
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: var(--space2) var(--space8) var(--space12); }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space4);
  margin-bottom: var(--space6);
}
.page-title { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.4px; }
.page-sub { font-size: 14px; line-height: 22px; color: var(--inkMuted); margin-top: 2px; }
.page-sub:empty { display: none; }

/* Entrada suave dos blocos do painel, em sequência curta */
.module-dash-body > *, .dash-kpi-row > .kpi-card { animation: riseIn .35s var(--ease) both; }
.dash-kpi-row > .kpi-card:nth-child(2) { animation-delay: 40ms; }
.dash-kpi-row > .kpi-card:nth-child(3) { animation-delay: 80ms; }
.dash-kpi-row > .kpi-card:nth-child(4) { animation-delay: 120ms; }
.module-dash-body > .dash-card { animation-delay: 120ms; }
.module-dash-body > .dash-card ~ .dash-card { animation-delay: 180ms; }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kpi-card { transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.kpi-card:not(.kpi-card--hero):hover { border-color: var(--lineHover); }
.section-sub { font-size: 13px; line-height: 20px; color: var(--inkMuted); margin: 2px 0 var(--space6); }

.tabs {
  display: flex; gap: var(--space1);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space6);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: var(--space2);
  padding: 10px 12px; margin-bottom: -1px;
  font-size: 14px; font-weight: 500; color: var(--inkMuted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .12s var(--ease), border-color .12s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }

/* Filtro de período */
.dash-filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space3);
  margin-bottom: var(--space6);
}
.filter-dates { display: flex; align-items: center; gap: var(--space2); }
.filter-dates input[type="date"] {
  height: 36px; padding: 0 10px;
  background: var(--surfaceRaised); color: var(--ink);
  border: 1px solid var(--lineStrong); border-radius: var(--radiusMd);
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.filter-dates input[type="date"]:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--navySoft); }
.filter-sep { color: var(--inkMuted); font-size: 13px; }
.filter-fornecedor select {
  height: 36px; max-width: 280px; padding: 0 10px;
  background: var(--surfaceRaised); color: var(--ink);
  border: 1px solid var(--lineStrong); border-radius: var(--radiusMd); font-size: 13px;
}
.filter-fornecedor select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--navySoft); }
.filter-chip {
  display: inline-flex; align-items: center; gap: var(--space2);
  margin: calc(-1 * var(--space3)) 0 var(--space6); padding: 4px 4px 4px 12px;
  background: var(--navySoft); color: var(--navy); border-radius: 999px; font-size: 13px;
}
.filter-chip .icon-btn { width: 28px; height: 28px; }
.cp-abas { margin-bottom: var(--space3); }
.tab-count { font-size: 12px; color: var(--inkMuted); font-weight: 400; font-variant-numeric: tabular-nums; }
.cp-janela { margin-bottom: var(--space2); }

/* KPIs */
.dash-kpi-row {
  display: flex; flex-wrap: wrap;
  gap: var(--space4); margin-bottom: var(--space6);
}
.kpi-card {
  flex: 1 1 190px;
  background: var(--surfaceRaised); border: 1px solid var(--line); border-radius: var(--radiusLg);
  padding: 20px var(--space6);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.kpi-card--hero { flex: 1.3 1 300px; }
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space2); }
.kpi-icon {
  width: 32px; height: 32px; flex-shrink: 0; margin: -4px -6px 0 0;
  display: grid; place-items: center; border-radius: var(--radiusMd);
  background: var(--navySoft); color: var(--navy);
}
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-icon--success { background: var(--successSoft); color: var(--success); }
.kpi-icon--danger  { background: var(--dangerSoft);  color: var(--danger); }
.kpi-icon--warning { background: var(--warningSoft); color: var(--warning); }
.kpi-card--hero .kpi-icon { background: var(--surfaceRaised); }

/* Visual do card principal: tendência ou proporção */
.kpi-spark { width: 100%; height: 40px; margin-top: var(--space2); overflow: visible; }
.kpi-spark-line { fill: none; stroke: var(--navy); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.kpi-spark-area { fill: var(--navy); opacity: .1; }
.kpi-split { margin-top: var(--space3); }
.split-bar { display: flex; gap: 2px; height: 8px; border-radius: var(--radiusFull); overflow: hidden; background: var(--line); }
.split-seg { height: 100%; transform-origin: left; animation: growX .6s var(--ease) both; }
.split-seg--navy { background: var(--navy); }
.split-seg--muted { background: var(--lineStrong); opacity: .55; }
.split-seg--success { background: var(--success); }
.split-seg--danger { background: var(--danger); }
.split-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: var(--space2); font-size: 12.5px; color: var(--inkMuted); }
.split-key { display: inline-flex; align-items: center; gap: 6px; }
.split-key strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.split-dot { width: 8px; height: 8px; border-radius: 2px; animation: none; }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.kpi-label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.4px; color: var(--inkMuted); }
.kpi-value {
  font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-card--hero { background: var(--navySoft); border-color: transparent; }
.kpi-card--hero .kpi-value {
  font-family: var(--font-display); font-weight: 400;
  font-size: 44px; line-height: 48px; letter-spacing: 0.3px;
}
.kpi-sub { font-size: 13px; line-height: 20px; color: var(--inkMuted); }
.kpi-sub.is-danger { color: var(--danger); font-weight: 500; }
.kpi-sub.is-success { color: var(--success); font-weight: 500; }

.dash-card {
  background: var(--surfaceRaised); border: 1px solid var(--line); border-radius: var(--radiusLg);
  padding: var(--space6); margin-bottom: var(--space6);
}
.dash-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space3); flex-wrap: wrap;
  margin-bottom: var(--space4);
}
.dash-card-title { font-size: 16px; line-height: 24px; font-weight: 600; }
.dash-card-meta { font-size: 13px; color: var(--inkMuted); }
.dash-card-resultado { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-card-foot { display: flex; justify-content: flex-end; margin-top: var(--space4); }

.dash-alert { margin-bottom: var(--space6); }

/* Tabela */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space6)); padding: 0 var(--space6); }
.dash-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.dash-table th {
  text-align: left; white-space: nowrap;
  font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.4px; color: var(--inkMuted);
  padding: 0 var(--space3) 10px; border-bottom: 1px solid var(--line);
}
.dash-table td { padding: var(--space3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.dash-table th:first-child, .dash-table td:first-child { padding-left: 0; }
.dash-table th:last-child, .dash-table td:last-child { padding-right: 0; }
.dash-table tbody tr:last-child td { border-bottom: 0; }
.dash-table tbody tr:hover td { background: var(--surface); }
.dash-table .text-right { text-align: right; }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-table .mono { font-family: var(--font-mono); font-size: 13px; }
.dash-table .nowrap { white-space: nowrap; }
.dash-table .unit { font-size: 12px; color: var(--inkMuted); }
.fw600 { font-weight: 600; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--inkMuted); }

.stock-cell { display: flex; align-items: center; gap: var(--space3); }
.stock-bar-wrap { width: 64px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; flex-shrink: 0; }
.stock-bar { height: 100%; background: var(--danger); border-radius: 2px; }
.stock-bar--ok { background: var(--success); }

/* Gráfico de barras: uma série em azul, referências discretas */
.chart-summary {
  display: flex; flex-wrap: wrap; gap: 4px 20px; margin: -8px 0 var(--space4);
  font-size: 13px; color: var(--inkMuted); font-variant-numeric: tabular-nums;
}
.chart-summary strong { color: var(--ink); font-weight: 600; }
.bar-chart {
  position: relative;
  display: flex; align-items: flex-end; gap: 6px;
  height: 240px; padding: 20px 0 0 64px;
  border-bottom: 1px solid var(--line);
}
.chart-gridline, .chart-avg {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px solid var(--line); pointer-events: none;
}
.chart-gridline span {
  position: absolute; left: 0; bottom: 3px;
  font-size: 11px; color: var(--inkMuted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart-avg { left: 64px; border-top: 1px dashed var(--lineStrong); z-index: 3; }
.chart-avg span {
  position: absolute; right: 0; bottom: 3px;
  font-size: 11px; font-weight: 500; color: var(--inkMuted); white-space: nowrap;
  background: var(--surfaceRaised); padding: 0 4px; border-radius: 4px;
}
.bar-col {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  position: relative; z-index: 2;
}
.bar-fill {
  width: 100%; max-width: 40px;
  background: var(--navy); border-radius: 4px 4px 0 0;
  transform-origin: bottom; animation: growUp .5s var(--ease) both;
  transition: opacity .12s var(--ease);
}
.bar-fill.is-zero { background: var(--line); }
.bar-chart:hover .bar-fill { opacity: .45; }
.bar-chart .bar-col:hover .bar-fill { opacity: 1; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.bar-value {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; opacity: 0; pointer-events: none;
  background: var(--surfaceRaised); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 6px; box-shadow: var(--shadowOverlay);
  transition: opacity .12s var(--ease);
}
.bar-col:hover .bar-value { opacity: 1; }
.bar-col.is-max .bar-value { opacity: 1; box-shadow: none; }
.bar-chart:hover .bar-col.is-max:not(:hover) .bar-value { opacity: 0; }
.bar-labels { display: flex; gap: 6px; margin-top: 8px; padding-left: 64px; }
.bar-label {
  flex: 1; min-width: 0; text-align: center;
  font-size: 11px; color: var(--inkMuted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden;
}
.bar-chart--dense + .bar-labels .bar-label:nth-child(even) { visibility: hidden; }

/* Entradas × saídas: duas barras por período, 2px entre elas */
.bar-pair { display: flex; align-items: flex-end; gap: 2px; width: 100%; max-width: 44px; height: 100%; }
.bar-pair .bar-fill { flex: 1; max-width: none; }
.bar-fill--in { background: var(--seriesIn); }
.bar-fill--out { background: var(--seriesOut); }
.legend-in { background: var(--seriesIn); }
.legend-out { background: var(--seriesOut); }
.bar-chart:hover .bar-col--pair .bar-fill { opacity: .45; }
.bar-chart .bar-col--pair:hover .bar-fill, .bar-chart .bar-col--pair:focus .bar-fill { opacity: 1; }
.bar-col--pair { outline: none; }
.bar-tip {
  position: absolute; bottom: calc(100% - 12px); left: 50%; transform: translateX(-50%);
  font-size: 12px; line-height: 18px; color: var(--inkMuted); white-space: nowrap; z-index: 5;
  background: var(--surfaceRaised); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; box-shadow: var(--shadowOverlay); opacity: 0; pointer-events: none;
  transition: opacity .12s var(--ease);
}
.bar-tip strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-col--pair:hover .bar-tip, .bar-col--pair:focus .bar-tip { opacity: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: -8px 0 var(--space4); font-size: 13px; color: var(--inkMuted); }
.chart-legend .split-key strong { color: var(--ink); }
.chart-table { margin-top: var(--space4); font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--link); width: max-content; }
.chart-table .table-wrap { margin-top: var(--space3); }

/* Duas colunas de cards (uma no celular) */
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space6); }
@media (max-width: 900px) { .dash-grid-2 { grid-template-columns: 1fr; } }

/* Barras horizontais: uma série, magnitude */
.hbars { display: flex; flex-direction: column; gap: var(--space3); }
.hbar-row { display: grid; grid-template-columns: minmax(80px, 28%) 1fr max(148px, var(--hbar-valor, 148px)); align-items: center; gap: var(--space3); font-size: 13px; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--seriesIn); border-radius: 0 4px 4px 0; transform-origin: left; animation: growX .6s var(--ease) both; }
.hbar-value { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; text-align: right; }
.hbar-value .text-muted { display: inline-block; min-width: 36px; }
@media (max-width: 600px) {
  /* Celular: o nome em cima, a barra e o valor embaixo */
  .hbar-row { grid-template-columns: minmax(0, 1fr) var(--hbar-valor, auto); row-gap: 4px; }
  .hbar-label { grid-column: 1 / -1; white-space: normal; }
}
.hbar-value .text-muted { font-weight: 400; }

/* DRE resumida */
.dre { display: flex; flex-direction: column; font-size: 14px; }
.dre-modo { margin-bottom: var(--space3); }
.dre-row { display: flex; justify-content: space-between; gap: var(--space3); padding: 10px 0; border-bottom: 1px solid var(--line); }
.dre-row--total { border-bottom: 0; font-weight: 600; font-size: 15px; }
.cell-sub { font-size: 12px; color: var(--inkMuted); }
.table-note { margin-top: var(--space3); }

/* Exportar planilha (acima dos indicadores) */
.dash-export { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space2); margin: calc(-1 * var(--space2)) 0 var(--space6); }
.dash-export-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--inkMuted); margin-right: var(--space1); }

/* Visão geral */
.atencao-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space2); }
.atencao-item {
  display: flex; align-items: center; gap: var(--space3);
  padding: var(--space3); border-radius: var(--radiusMd); border: 1px solid var(--line);
}
.atencao-item--danger { background: var(--dangerSoft); border-color: transparent; }
.atencao-item--warning { background: var(--warningSoft); border-color: transparent; }
.atencao-icon { display: inline-flex; flex-shrink: 0; }
.atencao-item--danger .atencao-icon { color: var(--danger); }
.atencao-item--warning .atencao-icon { color: var(--warning); }
.atencao-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.atencao-text span { font-size: 13px; color: var(--inkMuted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atencao-item .btn { flex-shrink: 0; background: var(--surfaceRaised); }
@media (max-width: 600px) {
  .atencao-item { flex-wrap: wrap; align-items: flex-start; }
  .atencao-text { flex-basis: calc(100% - 40px); }
  .atencao-text span { white-space: normal; }
  .atencao-item .btn { margin-left: 32px; }
}
.vg-bloco { display: flex; flex-direction: column; }
.vg-bloco .dash-card-head .btn-link { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }
.vg-numeros { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space4); margin-bottom: var(--space3); }
.vg-numeros .kpi-value { font-size: 22px; }
.vg-spark-label { font-size: 12px; font-weight: 600; letter-spacing: .4px; color: var(--inkMuted); margin-top: var(--space2); }
.vg-linha { display: flex; justify-content: space-between; gap: var(--space3); padding: 8px 0; font-size: 14px; border-top: 1px solid var(--line); }
.vg-linha strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.vg-linha--quebra strong { white-space: normal; overflow-wrap: anywhere; text-align: right; }

/* Estados vazios, carregamento */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: var(--space8) var(--space4); color: var(--inkMuted);
}
.empty-state .icon { width: 24px; height: 24px; margin-bottom: 6px; stroke-width: 1.5; }
.empty-state strong { color: var(--ink); font-weight: 600; font-size: 14px; }
.empty-state span { font-size: 13px; line-height: 20px; }
.empty-state .btn { margin-top: var(--space3); }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--hover) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
  border-radius: var(--radiusLg);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space4); margin-bottom: var(--space6); }
.skeleton-kpis .skeleton { height: 112px; }
.skeleton-block { height: 280px; }

/* ── Configurações ───────────────────────────────────────────────────────── */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: var(--space8); align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.settings-nav-item {
  text-align: left; padding: 8px 10px; border-radius: var(--radiusMd);
  font-size: 13.5px; color: var(--inkMuted);
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.settings-nav-item:hover { background: var(--hover); color: var(--ink); }
.settings-nav-item.active { background: var(--navySoft); color: var(--navy); font-weight: 500; }
.settings-content { min-width: 0; max-width: 620px; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn .15s var(--ease); }
.settings-panel .notice { margin-top: var(--space2); }

.user-list { display: flex; flex-direction: column; margin-bottom: var(--space4); }
.user-list-row {
  display: flex; align-items: center; gap: var(--space3);
  padding: var(--space3) 0; border-bottom: 1px solid var(--line);
}
.user-list-row:last-child { border-bottom: 0; }
.user-list-info { flex: 1; min-width: 0; }
.user-list-name { font-size: 14px; font-weight: 500; }
.user-list-email { font-size: 13px; color: var(--inkMuted); overflow: hidden; text-overflow: ellipsis; }

.plan-box {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 20px var(--space6); margin-bottom: var(--space4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radiusLg);
}
.plan-name { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.2px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim);
  display: grid; place-items: center; padding: var(--space4);
  animation: fadeIn .15s var(--ease);
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--surfaceRaised);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadowOverlay);
  padding: 20px;
  animation: popIn .18s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space4); }
.modal--aviso { max-width: 400px; }
.modal--aviso p { margin: 0 0 var(--space4); color: var(--ink); }
.modules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space3); }
.modules-grid .module-item[data-module="Visão geral"] { grid-column: 1 / -1; }
.module-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: var(--space4);
  border: 1px solid var(--line); border-radius: var(--radiusLg);
  color: var(--ink);
  transition: border-color .12s var(--ease), background-color .12s var(--ease);
}
.module-item .icon { color: var(--navy); margin-bottom: var(--space3); }
.module-item:hover { border-color: var(--navy); background: var(--surface); }
.module-name { font-size: 14px; font-weight: 600; }
.module-sub { font-size: 12.5px; color: var(--inkMuted); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-region {
  position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--surfaceRaised);
  padding: 10px 14px 10px 12px; border-radius: var(--radiusMd);
  font-size: 14px; line-height: 20px; font-weight: 500;
  box-shadow: var(--shadowOverlay);
  pointer-events: auto;
  animation: toastIn .2s var(--ease);
}
.toast .icon { width: 16px; height: 16px; }
.toast--success .icon { color: #4ade80; }
.toast--error .icon { color: #f87171; }
.toast--info .icon { color: var(--navySoft); }
[data-theme="dark"] .toast--success .icon { color: #1f7a4d; }
[data-theme="dark"] .toast--error .icon { color: #c62828; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all .2s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Drawer overlay (mobile) */
.drawer-overlay {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: var(--scrim);
}
.drawer-overlay.active { display: block; animation: fadeIn .15s var(--ease); }

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVO
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  #view-app { padding: var(--space4); }
}

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; gap: var(--space4); }
  .settings-nav {
    position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none;
    border-bottom: 1px solid var(--line); padding-bottom: var(--space2);
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav-item { white-space: nowrap; }
}

@media (max-width: 767px) {
  body { font-size: 14px; }
  #view-app { padding: 0; }
  .shell { border-radius: 0; padding: 0; box-shadow: none; background: var(--surfaceRaised); }
  .main { border-radius: 0; box-shadow: none; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(86vw, 300px);
    background: var(--surface);
    transform: translateX(-100%);
    transition: transform .25s var(--ease);
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .sidebar.collapsed { margin-left: 0; opacity: 1; visibility: visible; }
  .sidebar.active { transform: none; box-shadow: var(--shadowOverlay); }
  .sb-close { display: grid; }
  .sb-head { gap: 4px; }
  .sb-head .brand-logo { margin-right: auto; }

  .topbar { grid-template-columns: 40px minmax(0, 1fr) minmax(72px, auto); padding: calc(6px + env(safe-area-inset-top)) 8px 6px; min-height: calc(52px + env(safe-area-inset-top)); }
  .topbar-new { display: grid; }
  .topbar-title { font-size: 13px; }

  .chat-hero { padding: 0 var(--space4); }
  .display-title { font-size: 34px; }
  .messages { padding: 8px var(--space4) var(--space4); }
  .msg--user .bubble { max-width: 88%; }
  .msg-meta .msg-action { opacity: 1; }
  .composer-area { padding: 8px var(--space3) 0; }
  .composer-hint { display: none; }
  .agent-tag { max-width: 110px; }
  .chat-input { font-size: 16px; min-height: 48px; }
  .trust-row { gap: 8px 12px; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .trust-row .dot-sep { display: none; }

  .page { padding: var(--space2) var(--space4) var(--space8); }
  .page-head .btn-ghost { display: none; }
  .page-title { font-size: 24px; line-height: 32px; }
  .dash-kpi-row { gap: var(--space3); }
  .skeleton-kpis { grid-template-columns: 1fr 1fr; gap: var(--space3); }
  .kpi-card { padding: var(--space4); flex-basis: calc(50% - 6px); }
  .kpi-card--hero { flex-basis: 100%; }
  .bar-chart { padding-left: 48px; height: 200px; gap: 3px; }
  .bar-labels { padding-left: 48px; gap: 3px; }
  .chart-avg { left: 48px; }
  .bar-chart--dense + .bar-labels .bar-label:not(:nth-child(3n+1)) { visibility: hidden; }
  .bar-chart--dense + .bar-labels .bar-label:nth-child(3n+1) { visibility: visible; overflow: visible; }
  .kpi-value { font-size: 22px; line-height: 28px; }
  .kpi-card--hero .kpi-value { font-size: 40px; line-height: 44px; }
  .dash-card { padding: var(--space4); }
  .table-wrap { margin: 0 calc(-1 * var(--space4)); padding: 0 var(--space4); }
  .dash-filter-bar .segmented { width: 100%; overflow-x: auto; }
  .dash-filter-bar .segmented button { flex: 1; justify-content: center; padding: 0 8px; white-space: nowrap; }
  .filter-fornecedor, .filter-fornecedor select { width: 100%; max-width: none; }
  .filter-dates { width: 100%; }
  .filter-dates input[type="date"] { flex: 1; min-width: 0; }
  .field-grid { grid-template-columns: 1fr; }
  .field input, .field select { font-size: 16px; }
  .card { padding: var(--space4); }

  .auth-card { padding: 32px 22px 24px; box-shadow: none; border: 1px solid var(--line); }
  .auth-title { font-size: 30px; }
}

@media (min-width: 768px) {
  .sidebar.active { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar, .composer-area, .trust-row { display: none !important; }
  #view-app { padding: 0; height: auto; }
  .shell, .main { box-shadow: none; border-radius: 0; }
}

@media (max-width: 420px) {
  .agent-tag { display: none; }
}

/* ── Empresas, convites e equipe ─────────────────────────────────────────── */
.company-section { margin-bottom: var(--space2); }
.company-section-label {
  font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
  color: var(--inkMuted); margin-bottom: var(--space2);
}
.company-sub { font-size: 12.5px; line-height: 18px; color: var(--inkMuted); }
.company-card .badge { flex-shrink: 0; }
.company-card--invite { border-color: var(--navy); background: var(--navySoft); cursor: default; flex-wrap: wrap; }
.company-card--invite:hover { background: var(--navySoft); }
.company-card--new { border-style: dashed; margin-bottom: var(--space6); }
.company-card--new .company-info { display: flex; flex-direction: column; }
.avatar--dashed { background: transparent; border: 1px dashed var(--lineStrong); color: var(--inkMuted); display: grid; place-items: center; }
.avatar--dashed .icon { width: 18px; height: 18px; }
.invite-actions { display: flex; justify-content: flex-end; gap: var(--space2); width: 100%; }
.company-new-form {
  padding: var(--space4); margin-bottom: var(--space6);
  border: 1px solid var(--line); border-radius: var(--radiusLg); background: var(--surface);
}
.company-new-form .h3 { margin-bottom: var(--space3); }
.btn-sm { height: 32px; padding: 0 var(--space3); font-size: 13px; }

/* ── Aprovação de empresas: espera e painel da plataforma ────────────────── */
.company-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space2); }
.company-section-head .btn-link { font-size: 13px; }
.company-card--waiting { cursor: default; align-items: flex-start; }
.company-card--waiting:hover { border-color: var(--line); background: var(--surfaceRaised); }
.company-card--waiting .company-sub { margin-top: 4px; white-space: normal; }
.company-card--plataforma { margin-bottom: var(--space6); }
.company-card--plataforma .avatar { display: grid; place-items: center; background: var(--navySoft); color: var(--navy); }
.company-card--plataforma .company-info { display: flex; flex-direction: column; }

.plat-topo { margin-bottom: var(--space4); display: flex; align-items: center; justify-content: space-between; gap: var(--space3); flex-wrap: wrap; }
.plat-ao-entrar { display: inline-flex; align-items: center; gap: var(--space2); font-size: 13px; color: var(--inkMuted); cursor: pointer; }
.plat-aviso { margin-bottom: var(--space4); }
.plat-abas { margin-bottom: var(--space4); }
.plat-contador:not(:empty) {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--warningSoft); color: var(--warning); font-size: 12px; font-weight: 600;
}
.plat-busca { margin-bottom: var(--space3); }
.plat-vazio { padding: var(--space6) var(--space4); text-align: center; color: var(--inkMuted); font-size: 14px;
  border: 1px dashed var(--line); border-radius: var(--radiusLg); }
.plat-cab { display: flex; align-items: center; gap: var(--space3); flex-wrap: wrap; margin: var(--space2) 0 var(--space4); }
.plat-cab .h3 { flex: 1; min-width: 0; font-size: 20px; line-height: 28px; }
.plat-dados { display: grid; grid-template-columns: max-content 1fr; gap: var(--space2) var(--space4);
  margin: 0 0 var(--space6); padding: var(--space4); border: 1px solid var(--line); border-radius: var(--radiusLg); font-size: 14px; }
.plat-dados dt { color: var(--inkMuted); font-size: 12.5px; padding-top: 1px; }
.plat-dados dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.plat-acoes { display: flex; flex-wrap: wrap; gap: var(--space2); }
.plat-acoes .btn { flex: 1 1 160px; height: 40px; }
.btn-perigo { background: var(--danger); color: #fff; }
.btn-perigo:hover:not(:disabled) { filter: brightness(.92); }
.btn-perigo:disabled { opacity: .55; }
.plat-motivo { margin-top: var(--space4); padding: var(--space4); border: 1px solid var(--line); border-radius: var(--radiusLg); background: var(--surface); }
.plat-motivo textarea {
  width: 100%; min-height: 84px; padding: var(--space2) var(--space3); resize: vertical;
  background: var(--surfaceRaised); border: 1px solid var(--lineStrong); border-radius: var(--radiusMd); font-size: 15px;
}
@media (max-width: 480px) {
  .plat-dados { grid-template-columns: 1fr; gap: 2px; }
  .plat-dados dd { margin-bottom: var(--space2); }
}

.team-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space4); }
.team-head .btn.is-hidden { visibility: hidden; }
.invite-form {
  padding: var(--space4); margin: var(--space2) 0 var(--space4);
  border: 1px solid var(--line); border-radius: var(--radiusLg); background: var(--surface);
}
.invite-grid { display: grid; grid-template-columns: 1fr 200px; gap: 0 var(--space3); }
.invite-grid .field { margin-bottom: var(--space2); }
.invite-role-help { margin-bottom: var(--space2); min-height: 16px; }
.user-list-row.is-pending .avatar { opacity: .6; }
.role-select {
  height: 32px; padding: 0 28px 0 10px;
  border: 1px solid var(--line); border-radius: var(--radiusMd);
  background: var(--surfaceRaised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238792a3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none; font-size: 13px; color: var(--ink);
}
.role-select:hover { border-color: var(--lineHover); }
.role-select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.role-select:disabled { opacity: .6; }
.roles-help { margin-top: var(--space2); font-size: 13px; }
.roles-help summary { cursor: pointer; color: var(--link); font-weight: 500; }
.roles-list { display: grid; grid-template-columns: 150px 1fr; gap: 6px var(--space3); margin-top: var(--space3); }
.roles-list dt { font-weight: 600; }
.roles-list dd { color: var(--inkMuted); margin: 0; }
.team-foot { margin-top: var(--space6); padding-top: var(--space4); border-top: 1px solid var(--line); }
.btn-link--danger { color: var(--danger); font-size: 13.5px; }
.member-menu-spacer { width: 32px; flex-shrink: 0; }
.menu-item--danger { color: var(--danger); }
.settings-readonly-notice { margin-bottom: var(--space4); }

@media (max-width: 640px) {
  .invite-grid { grid-template-columns: 1fr; }
  .roles-list { grid-template-columns: 1fr; }
  .roles-list dd { margin-bottom: var(--space2); }
  .user-list-row { flex-wrap: wrap; }
  .user-list-row .user-list-info { flex-basis: calc(100% - 52px); }
}

/* ── Conversas (lista, menções, participantes) ───────────────────────────── */
.avatar--xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar--xs .icon { width: 12px; height: 12px; }
.avatar.is-hidden, .agent-mark.is-hidden { visibility: hidden; }

.conv-btn { display: flex; align-items: center; gap: 9px; padding: 6px 10px; }
.conv-btn .agent-mark { width: 22px; height: 22px; }
.conv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.is-unread .conv-title { color: var(--ink); font-weight: 600; }
.conv-item.is-readonly .conv-title { font-style: italic; }
.conv-unread {
  min-width: 18px; height: 18px; padding: 0 5px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--radiusFull);
  background: var(--navy); color: var(--onNavy);
  font-size: 11px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums;
}
.conv-mention { font-size: 12px; font-weight: 700; color: var(--orangeInk); flex-shrink: 0; }

.mention {
  display: inline; padding: 0 3px; margin: 0 1px;
  border-radius: var(--radiusSm);
  background: var(--navySoft); color: var(--navy);
  font: inherit; font-weight: 600; line-height: inherit;
  cursor: pointer;
}
.mention:hover { text-decoration: underline; }
.mention--agent { background: var(--orangeSoft); color: var(--orangeInk); }
.mention--inactive { background: transparent; color: var(--inkMuted); text-decoration: line-through; }

.msg-system {
  text-align: center; font-size: 12.5px; line-height: 18px; color: var(--inkMuted);
  margin-top: -8px; margin-bottom: -8px;
}
.msg--person .avatar { margin-top: 2px; }
.msg-author { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.msg-author-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.msg-author:hover .msg-author-name { text-decoration: underline; }
.msg-text--plain { white-space: pre-wrap; }
.msg-note { font-size: 12px; color: var(--inkMuted); margin-top: 4px; }
.bubble.is-pending { opacity: .6; }

.mention-popup {
  left: 8px; right: 8px; bottom: calc(100% + 6px);
  max-height: 280px; overflow-y: auto;
}
.mention-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13.5px; color: var(--ink);
}
.mention-opt .agent-mark { width: 22px; height: 22px; }
.mention-opt.active, .mention-opt:hover { background: var(--hover); }
.mention-opt-handle { font-weight: 600; }
.mention-opt-name { color: var(--inkMuted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-popover { position: fixed; width: 272px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.profile-head { display: flex; align-items: center; gap: 10px; }
.profile-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.profile-handle { font-size: 12.5px; color: var(--inkMuted); }
.profile-sub { font-size: 13px; line-height: 19px; color: var(--inkMuted); }
.user-menu-handle { color: var(--navy); }

.conv-dialog { max-width: 520px; }
.conv-dialog-body { display: flex; flex-direction: column; gap: 12px; max-height: min(70vh, 640px); overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.conv-dialog-body .field { margin-bottom: 0; }
.conv-dialog-body input[type="search"],
.inline-form input, .inline-form select {
  height: 38px; flex: 1; min-width: 0; width: 100%;
  padding: 0 var(--space3);
  background: var(--surfaceRaised); border: 1px solid var(--lineStrong); border-radius: var(--radiusMd);
  font-size: 14px; color: var(--ink);
}
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .btn { flex-shrink: 0; height: 38px; }
.member-list { display: flex; flex-direction: column; gap: 2px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.member-text { flex: 1; min-width: 0; }
.member-name { font-size: 13.5px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: 12px; line-height: 16px; color: var(--inkMuted); }
.member-pick { width: 100%; text-align: left; border-radius: var(--radiusMd); }
.member-pick:hover, .member-pick:focus-visible { background: var(--hover); }
.pick-group { border: 1px solid var(--line); border-radius: var(--radiusLg); padding: 6px 10px 8px; margin: 0; }
.pick-group legend { font-size: 12px; font-weight: 600; padding: 0 4px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; cursor: pointer; }
.pick-row .member-row { flex: 1; padding: 2px 0; }
.pick-row .agent-mark { width: 22px; height: 22px; }
.pick-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--navy); flex-shrink: 0; }
.proactive-box { border-top: 1px solid var(--line); padding-top: 10px; }
.mention-results { display: flex; flex-direction: column; gap: 6px; }
.mention-result {
  text-align: left; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radiusLg);
}
.mention-result:hover { border-color: var(--lineHover); background: var(--surface); }
.mention-result.is-unread { border-color: var(--navy); }
.mention-result-text { font-size: 14px; line-height: 21px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

/* "Para:" da nova conversa */
.para-bar {
  width: 100%; max-width: 640px; margin-bottom: 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.para-label { font-size: 13px; font-weight: 500; color: var(--inkMuted); margin-right: 2px; }
.para-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 10px; border-radius: var(--radiusFull);
  background: var(--navySoft); color: var(--navy); font-size: 13px; font-weight: 500;
}
.para-chip--agent { background: var(--orangeSoft); color: var(--orangeInk); }
.para-remove { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: inherit; }
.para-remove:hover { background: var(--hover); }
.para-remove .icon { width: 12px; height: 12px; }
.para-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radiusFull);
  border: 1px dashed var(--lineHover); color: var(--inkMuted); font-size: 13px;
}
.para-add:hover { color: var(--ink); border-color: var(--lineStrong); }
.para-add .icon { width: 12px; height: 12px; }
.para-picker { width: 300px; max-height: 360px; overflow-y: auto; }
.para-picker input[type="search"] {
  height: 36px; width: 100%; padding: 0 var(--space3);
  background: var(--surfaceRaised); border: 1px solid var(--lineStrong); border-radius: var(--radiusMd);
  font-size: 14px; color: var(--ink);
}

/* Responder a uma mensagem */
.msg-quote {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; max-width: 520px; text-align: left;
  margin: 2px 0 6px; padding: 6px 10px;
  border-left: 3px solid var(--navy); border-radius: var(--radiusSm);
  background: var(--surface); color: var(--ink);
  font-size: 13px; line-height: 18px;
}
.msg-quote--agent { border-left-color: var(--orange); }
.msg--user .msg-quote { background: var(--surfaceRaised); }
.msg-quote-author { font-weight: 600; }
.msg-quote-text { color: var(--inkMuted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.msg-quote:hover .msg-quote-text { color: var(--ink); }
.msg--user { align-items: center; gap: 6px; }
.msg-reply-own {
  width: 28px; height: 28px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 50%; color: var(--inkMuted); opacity: 0;
  transition: opacity .15s var(--ease), background-color .15s var(--ease);
}
.msg-reply-own .icon { width: 14px; height: 14px; }
.msg--user:hover .msg-reply-own, .msg-reply-own:focus-visible { opacity: 1; }
.msg-reply-own:hover { background: var(--hover); color: var(--ink); }
.msg.is-highlight { animation: msgHighlight 1.4s var(--ease); }
@keyframes msgHighlight { 0%, 60% { background: var(--navySoft); } 100% { background: transparent; } }
.reply-bar {
  display: flex; align-items: flex-start; gap: 8px;
  margin: -2px 0 8px; padding: 6px 8px 6px 10px;
  border-left: 3px solid var(--navy); border-radius: var(--radiusSm);
  background: var(--surfaceRaised);
}
.reply-bar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12.5px; line-height: 17px; }
.reply-bar-label { font-weight: 600; color: var(--ink); }
.reply-bar-text { color: var(--inkMuted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) { .msg-reply-own { opacity: 1; } }

/* ── Assinatura: faixa de aviso e aba ───────────────────────────────────── */
.aviso-assinatura {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 var(--space4) var(--space2); padding: 10px 14px; border-radius: var(--radiusMd);
  background: var(--warningSoft); color: var(--ink); font-size: 13.5px; line-height: 19px;
}
.aviso-assinatura[hidden] { display: none; }
.aviso-assinatura .icon { color: var(--warning); flex-shrink: 0; }
/* Só o texto da faixa (não o trecho dentro do botão "Ver assinatura"). */
.aviso-assinatura > span { flex: 1; min-width: 200px; }
.aviso-assinatura--atraso { background: var(--dangerSoft); }
.aviso-assinatura--atraso .icon { color: var(--danger); }
.assinatura-resumo { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: var(--space3) 0 var(--space4);
  padding: var(--space4); border: 1px solid var(--line); border-radius: var(--radiusLg); font-size: 14px; }
.assinatura-resumo dt { color: var(--inkMuted); font-size: 12.5px; padding-top: 1px; }
.assinatura-resumo dd { margin: 0; }
.pagamentos-lista { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.pagamentos-lista li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radiusMd); }
.pagamentos-lista .muted { color: var(--inkMuted); font-size: 12.5px; }
.plat-secao { margin-top: var(--space6); padding-top: var(--space4); border-top: 1px solid var(--line); }
.plat-secao .h3 { margin-bottom: var(--space3); }
.plat-pagamento { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space3); margin-top: var(--space3);
  padding: var(--space4); border: 1px solid var(--line); border-radius: var(--radiusLg); background: var(--surface); }
.plat-pagamento .field-full, .plat-pagamento .form-actions { grid-column: 1 / -1; }
@media (max-width: 480px) {
  .assinatura-resumo { grid-template-columns: 1fr; gap: 2px; }
  .plat-pagamento { grid-template-columns: 1fr; }
}
.plat-contador--perigo:not(:empty) { background: var(--dangerSoft); color: var(--danger); }

/* ── Plataforma: financeiro da carteira ─────────────────────────────────── */
.plat-fin-topo { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space3); flex-wrap: wrap; margin-bottom: var(--space4); }
.plat-fin-mes { margin: 0; max-width: 200px; }
.plat-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space3); margin-bottom: var(--space4); }
.plat-kpi { padding: var(--space4); }
.plat-kpi .kpi-value { font-size: 22px; line-height: 28px; }
.plat-kpi--ok .kpi-value { color: var(--success); }
.plat-kpi--perigo .kpi-value { color: var(--danger); }
.plat-fin-titulo { margin: var(--space6) 0 var(--space3); }
.plat-devido { font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.plat-devido strong { color: var(--danger); }
.plat-mensalidade { display: inline-flex; align-items: baseline; gap: var(--space3); flex-wrap: wrap; }
.plat-mensalidade-form { display: flex; gap: var(--space2); align-items: center; flex-wrap: wrap; }
.plat-mensalidade-form input { max-width: 140px; }
@media (max-width: 520px) {
  .plat-kpis { grid-template-columns: 1fr; }
  .plat-abas .tab { padding: 10px 8px; }
}

/* ── Plataforma: painel em tela cheia ───────────────────────────────────── */
.plat-selo { margin-right: auto; margin-left: var(--space2); }
.plat-nav { display: flex; flex-direction: column; gap: 2px; padding-top: var(--space4); }
.plat-nav .sb-link.active { background: var(--surfaceRaised); box-shadow: var(--shadowActive); color: var(--navy); font-weight: 500; }
.plat-nav .plat-contador { margin-left: auto; }
.plat-sidebar .sb-foot { gap: 4px; }
.plat-sidebar .plat-ao-entrar { justify-content: space-between; padding: 8px 10px; font-size: 12.5px; line-height: 16px; }
.plat-usuario { cursor: default; }
.plat-main { overflow-y: auto; }
.plat-topbar { grid-template-columns: 40px minmax(0, 1fr) 40px; border-bottom: 1px solid var(--line); }
.plat-menu-btn { visibility: hidden; }
.plat-titulo { font-size: 15px; line-height: 22px; font-weight: 600; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat-page { padding: var(--space6) var(--space8) var(--space8); width: 100%; max-width: 1200px; margin: 0 auto; }
.plat-secao-titulo { font-size: 13px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--inkMuted); margin: var(--space2) 0 var(--space3); }
.plat-kpis--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.plat-page .plat-kpis:not(.plat-kpis--5) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.plat-kpi--link { text-align: left; cursor: pointer; }
.plat-kpi--link:hover { border-color: var(--lineHover); }
.plat-kpi--aviso .kpi-value { color: var(--warning); }
.plat-linha-link { cursor: pointer; }
.plat-linha-link:hover td, .plat-linha-link:focus-visible td { background: var(--hover); }
.plat-ia-barras.bar-chart { gap: 2px; height: 180px; padding-left: 0; }
.plat-ia-barras.bar-labels { gap: 2px; padding-left: 0; }
.plat-ia-barras .bar-label { overflow: visible; }
.plat-ia-cotacao { font-size: 13px; align-self: center; }
.plat-duas-colunas { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--space4); margin-top: var(--space2); }
.plat-card { margin-bottom: var(--space4); }
.plat-card .dash-card-head { gap: var(--space3); }
.plat-acoes-grid { display: grid; gap: var(--space4); }
.plat-acao-titulo { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: var(--space2); }
.plat-acao-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.plat-acao-item { display: flex; justify-content: space-between; gap: var(--space3); width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radiusMd); font-size: 13.5px; }
.plat-acao-item:hover { background: var(--hover); }
.plat-acao-item strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat-acao-item span { flex-shrink: 0; font-size: 12.5px; }
.plat-acao-vazia { font-size: 13px; color: var(--inkMuted); padding: 4px 10px; margin: 0; }
.plat-filtros { display: flex; flex-wrap: wrap; gap: var(--space2); margin-bottom: var(--space4); align-items: center; }
.plat-filtros.field { margin: 0 0 var(--space4); flex-direction: row; gap: var(--space2); }
.plat-filtros input[type="search"] { flex: 1 1 240px; width: auto; font-size: 14px; }
.plat-filtros select { flex: 0 1 210px; width: auto; font-size: 14px; }
.plat-filtros .btn { margin-left: auto; }
.plat-ordenar { font: inherit; color: inherit; letter-spacing: inherit; padding: 0; }
.plat-ordenar:hover { color: var(--ink); }
.plat-tabela .plat-linha { cursor: pointer; }
.plat-tabela { font-size: 13.5px; }
.plat-tabela th, .plat-tabela td { padding-left: 8px; padding-right: 8px; }
.plat-tabela .mono, .plat-tabela .num, .plat-tabela .badge { white-space: nowrap; }
.plat-tabela .plat-linha:focus-visible td { background: var(--surface); outline: none; }
.plat-voltar { margin-bottom: var(--space3); }
.plat-cab { justify-content: space-between; align-items: flex-start; margin: 0 0 var(--space4); }
.plat-cab-texto { min-width: 0; }
.plat-empresa-nome { font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: -0.2px; }
.plat-cab-selos { display: flex; gap: var(--space2); flex-wrap: wrap; }
.plat-aba-painel { padding-top: var(--space2); }
.plat-aba-painel > .plat-dados { margin-bottom: var(--space4); }
.plat-aba-painel .plat-secao { margin-top: 0; padding-top: 0; border-top: 0; }
.plat-aba-painel .plat-secao > .h3 { display: none; }
.plat-historico { list-style: none; margin: 0; padding: 0; }
.plat-historico li { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--space3); padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.plat-historico li:last-child { border-bottom: 0; }
.plat-historico-quando { color: var(--inkMuted); font-variant-numeric: tabular-nums; font-size: 13px; }

@media (max-width: 1100px) {
  #view-plataforma { padding: var(--space4); }
  .plat-kpis--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .plat-page .plat-kpis:not(.plat-kpis--5) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plat-duas-colunas { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  #view-plataforma { padding: 0; }
  .plat-menu-btn { visibility: visible; }
  .plat-page { padding: var(--space4); }
  .plat-kpis--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plat-filtros select, .plat-filtros input[type="search"] { flex: 1 1 100%; }
  .plat-filtros .btn { margin-left: 0; }
  /* Tabela vira cartões */
  .plat-tabela thead { display: none; }
  .plat-tabela, .plat-tabela tbody, .plat-tabela tr, .plat-tabela td { display: block; width: 100%; }
  .plat-tabela tr { border: 1px solid var(--line); border-radius: var(--radiusLg); padding: var(--space2) var(--space3); margin-bottom: var(--space2); }
  .plat-tabela td, .plat-tabela td:first-child, .plat-tabela td:last-child { display: flex; justify-content: space-between; gap: var(--space3); padding: 6px 0; border: 0; text-align: right; }
  .plat-tabela td::before { content: attr(data-label); color: var(--inkMuted); font-size: 12.5px; text-align: left; }
  .plat-tabela td[colspan]::before { content: none; }
  .plat-page .table-wrap { margin: 0; padding: 0; }
  .plat-historico li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* Assistente da Plataforma */
.plat-chat { display: flex; flex-direction: column; height: calc(100dvh - 180px); min-height: 420px; max-width: 860px; margin: 0 auto; }
.plat-chat-lista { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space4); padding: var(--space2) 0 var(--space4); }
.plat-chat-vazio { margin: auto; text-align: center; display: flex; flex-direction: column; gap: var(--space2); align-items: center; color: var(--inkMuted); }
.plat-chat-vazio strong { color: var(--ink); font-size: 18px; }
.plat-chat-vazio .chips { justify-content: center; margin-top: var(--space3); }
.plat-chat .msg--ai .msg-body { padding-top: 0; }
.plat-chat .chips { margin-top: var(--space2); }
.plat-chat-nota { font-size: 12.5px; color: var(--inkMuted); margin: 0 0 var(--space2); }
.plat-chat-form { display: flex; gap: var(--space2); align-items: flex-end; border: 1px solid var(--lineStrong); border-radius: var(--radiusLg); padding: var(--space2); background: var(--surfaceRaised); }
.plat-chat-form:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--navySoft); }
.plat-chat-form textarea { flex: 1; border: 0; resize: none; background: transparent; color: var(--ink); font: inherit; font-size: 15px; line-height: 22px; padding: 8px; max-height: 140px; outline: none; }
.plat-chat-form .btn { height: 40px; width: 44px; padding: 0; display: grid; place-items: center; }
@media (max-width: 767px) {
  .plat-chat { height: calc(100dvh - 130px); }
  .plat-chat-form textarea { font-size: 16px; }
}

/* Equipe e histórico da plataforma */
.plat-filtros input[type="email"] { flex: 1 1 260px; width: auto; font-size: 14px; }
.plat-filtros input[type="date"] { flex: 0 1 170px; width: auto; font-size: 14px; }
.plat-tabela select { height: 34px; padding: 0 30px 0 10px; font-size: 13.5px; border: 1px solid var(--lineStrong); border-radius: var(--radiusMd); background-color: var(--surfaceRaised); color: var(--ink); }
.plat-tabela .muted { font-size: 12.5px; }
.plat-perfis { margin-top: var(--space4); font-size: 13px; color: var(--inkMuted); line-height: 20px; }
.plat-perfis strong { color: var(--ink); font-weight: 600; }

/* Assistente da Plataforma: cartão de confirmação de uma ação */
.plat-acao {
  margin-top: var(--space3); padding: var(--space3) var(--space4);
  border: 1px solid var(--line); border-left: 3px solid var(--orange); border-radius: var(--radiusMd);
  background: var(--surfaceRaised); display: flex; flex-direction: column; gap: var(--space2); font-size: 14px;
}
.plat-acao-linhas { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.plat-acao-botoes { display: flex; align-items: center; gap: var(--space2); flex-wrap: wrap; margin-top: var(--space1); }
.plat-acao-botoes .muted { font-size: 12px; }
.plat-acao-estado { font-size: 13px; font-weight: 600; color: var(--inkMuted); }
.plat-acao--feita { border-left-color: var(--success); }
.plat-acao--feita .plat-acao-estado { color: var(--success); }
.plat-acao--cancelada, .plat-acao--falhou { opacity: .75; border-left-color: var(--lineStrong); }

/* Confirmação no chat: Sim / Não / Corrigir (teclas S e N) */
.confirm-bar { display: flex; flex-wrap: wrap; gap: var(--space2); margin-top: var(--space3); }
.confirm-bar .btn { gap: 6px; }
.chips--extra { margin-top: var(--space2); }
.confirm-bar kbd {
  font: 500 11px/1 var(--fontMono, monospace); padding: 2px 5px; border-radius: 4px;
  border: 1px solid currentColor; opacity: .7;
}
@media (max-width: 640px) {
  .confirm-bar .btn { flex: 1 1 0; justify-content: center; min-height: 40px; }
  .confirm-bar kbd { display: none; }
}

/* Texto ditado: conferir antes de enviar */
#chat-textarea.is-revisar { box-shadow: inset 0 0 0 2px var(--warning); border-radius: var(--radiusMd); }
.composer-hint.is-revisar { display: inline-flex; color: var(--warning); font-weight: 500; }

/* Painel de Estoque: lista de produtos (filtros, ordenação) e a ficha lateral */
.estoque-filtros { flex-wrap: wrap; gap: var(--space3); }
.estoque-busca { flex: 1 1 240px; }
.estoque-busca input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--lineStrong); border-radius: var(--radiusMd); background: var(--surfaceRaised); color: var(--ink); font: inherit; font-size: 13px; }
.estoque-busca input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--navySoft); }
.estoque-inativos { display: inline-flex; align-items: center; gap: var(--space2); font-size: 13px; color: var(--inkMuted); cursor: pointer; }
.estoque-novo { margin-left: auto; }
.painel-abas { margin-bottom: var(--space4); }
.pagamentos-lista .btn-link { justify-content: flex-start; text-align: left; }
.busca-contas .dash-filter-bar { margin-bottom: 0; }
.th-ordenar { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit; }
.th-ordenar:hover { color: var(--ink); }
.th-ordenar--ativa { color: var(--ink); }
.th-sep { color: var(--ink-3, inherit); opacity: .6; }
.linha-clicavel { cursor: pointer; }
.linha-clicavel:hover td, .linha-clicavel:focus-visible td { background: var(--hover); }
.ficha-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .32); display: flex; justify-content: flex-end; animation: fadeIn .15s var(--ease); }
.ficha { width: min(480px, 100%); height: 100%; overflow-y: auto; background: var(--surfaceRaised); box-shadow: -8px 0 24px rgba(15, 23, 42, .12); padding: var(--space6); display: flex; flex-direction: column; gap: var(--space4); }
.ficha-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space3); }
.ficha-topo .h3 { margin: 2px 0 var(--space2); }
.ficha-acoes { display: flex; flex-wrap: wrap; gap: var(--space2); }
.ficha-secao { font-size: 13px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--inkMuted); margin: var(--space2) 0 0; }
.celula-produto { min-width: 180px; }
@media (max-width: 600px) {
  .ficha { width: 100%; padding: var(--space4); }
  .estoque-novo { margin-left: 0; width: 100%; justify-content: center; }
}

/* Qualidade do agente (Plataforma): barra por dia com a parte não entendida em vermelho */
.qa-barra { position: relative; display: flex; flex-direction: column-reverse; overflow: hidden; }
.qa-ruim { display: block; width: 100%; background: var(--danger); opacity: .85; }
.qa-dot-ruim { background: var(--danger); }
.qa-legenda { margin-top: var(--space2); }
.qa-frase { font-style: italic; }

/* ── Celular e toque (parte B do app) ───────────────────────────────────────
   Só telas pequenas ou de toque: o computador com mouse não muda. */

/* iPhone: campo com letra menor que 16 px dá zoom ao tocar. */
@media (max-width: 767px) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea, .mono-input {
    font-size: 16px !important;
  }
  /* Letra mínima de 12 px no celular. */
  .eyebrow, .label-caps, .sb-label, .bar-value, .bar-label { font-size: 12px; }
  .fiscal-lista { font-size: 13px; }
}

/* Dedo: área de toque de pelo menos 44 px (o desenho quase não muda). */
@media (pointer: coarse) {
  .icon-btn, .chat-menu-btn, #btn-send, #btn-mic, #sidebar-toggle { min-width: 44px; min-height: 44px; }
  .chat-menu-btn { opacity: .7; }           /* sem mouse não há "passar por cima": o menu fica à vista */
  .para-remove { min-width: 32px; min-height: 32px; margin: -6px -8px -6px 0; }
  .btn, .btn-sm, .btn-ghost, .chip, .para-add, .tab, .settings-nav-item, .segmented button, .hi-btn { min-height: 44px; }
  .btn-link { min-height: 44px; display: inline-flex; align-items: center; }
  .switch-row { min-height: 48px; }
}

/* Abas que rolam para o lado (módulos dos Painéis, menu de Configurações):
   degradê na borda direita mostra que há mais opções. */
@media (max-width: 900px) {
  .tabs, .settings-nav {
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
    mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .tabs.no-fim, .settings-nav.no-fim { -webkit-mask-image: none; mask-image: none; }
}

/* Aviso "Instale o app" (celular, uma vez). */
.aviso-instalar {
  position: fixed; left: var(--space3); right: var(--space3);
  bottom: calc(var(--space3) + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; gap: var(--space3); align-items: center;
  padding: var(--space3) var(--space4); border-radius: var(--radiusLg);
  background: var(--surfaceRaised); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.aviso-instalar img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.aviso-instalar .aviso-texto { flex: 1; font-size: 14px; line-height: 20px; }
.aviso-instalar .aviso-acoes { display: flex; gap: var(--space2); flex: none; }
@media (max-width: 480px) {
  .aviso-instalar { flex-wrap: wrap; }
  .aviso-instalar .aviso-texto { flex: 1 1 calc(100% - 56px); }
  .aviso-instalar .aviso-acoes { flex: 1 1 100%; justify-content: flex-end; }
}
.passos-instalar { margin: var(--space2) 0 0; padding-left: 1.2em; line-height: 24px; }

/* Etiqueta num item de lista do chat (ex.: produto sem estoque). */
.etiqueta {
  display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; line-height: 20px; white-space: nowrap; vertical-align: 1px;
  background: var(--warningSoft, rgba(217, 119, 6, .14)); color: var(--warning, #b45309);
}
.etiqueta--perigo { background: var(--dangerSoft, rgba(220, 38, 38, .12)); color: var(--danger, #b91c1c); }

/* Lista em cartão no chat (app.js cartaoLista, core/cartao_lista.py). */
.lista-cartao { margin: 2px 0 4px; }
.lp-titulo { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.lp-resumo { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.lp-pilula {
  font-size: 12px; line-height: 20px; padding: 2px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--inkMuted);
}
.lp-pilula--perigo { background: var(--dangerSoft); color: var(--danger); border-color: transparent; }
.lp-pilula--alerta { background: var(--warningSoft); color: var(--warning); border-color: transparent; }
.lp-pilula--ok { background: var(--successSoft); color: var(--success); border-color: transparent; }
.lp-itens {
  list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; background: var(--surfaceRaised);
}
.lp-itens li + li { border-top: 1px solid var(--line); }
/* As listas comuns do chat têm recuo e espaço entre itens: o cartão não. */
.msg-text .lp-itens { padding: 0; }
.msg-text .lp-itens li + li { margin-top: 0; }
.lp-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; min-height: 60px;
  background: none; border: 0; text-align: left; color: var(--ink); font: inherit; cursor: pointer;
}
.lp-item:hover { background: var(--hover); }
.lp-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.lp-av {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--navySoft); color: var(--navy); font-weight: 600; font-size: 14px;
}
.lp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lp-nome {
  font-weight: 600; font-size: 15px; line-height: 20px; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;   /* até 2 linhas */
}
.lp-sub { font-size: 12px; line-height: 18px; color: var(--inkMuted); }
.lp-dir { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lp-preco { font-weight: 600; font-size: 15px; line-height: 20px; white-space: nowrap; }
.lp-saldo {
  font-size: 12px; line-height: 18px; padding: 0 8px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); color: var(--inkMuted);
}
.lp-saldo--perigo { background: var(--dangerSoft); color: var(--danger); }
.lp-saldo--alerta { background: var(--warningSoft); color: var(--warning); }
.lp-saldo--ok { background: var(--successSoft); color: var(--success); }
.lp-item--fixo { cursor: default; }
.lp-item--fixo:hover { background: none; }
.lp-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lp-acao {
  min-height: 36px; padding: 6px 14px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surfaceRaised); color: var(--ink);
}
.lp-acao:hover { border-color: var(--lineHover); }
.lp-acao.is-ativo { background: var(--navy); border-color: var(--navy); color: var(--onNavy); }
.lp-nota { margin: 8px 0 0; font-size: 12px; color: var(--inkMuted); }
.lp-secao + .lp-secao { margin-top: 14px; }
.lp-secao-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 2px 6px; }
.lp-secao-nome { font-weight: 600; font-size: 13px; color: var(--inkMuted); text-transform: uppercase; letter-spacing: .04em; }
.lp-secao-total { font-weight: 600; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lp-vazia { margin: 0 2px; }
@media (pointer: coarse) { .lp-acao { min-height: 44px; } }

/* Cartão de resumo (app.js cartaoResumo): Posição financeira. */
.rc-destaque {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); margin-bottom: 12px;
}
.rc-rotulo { font-size: 12px; color: var(--inkMuted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.rc-valor { font-size: 26px; line-height: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rc-nota { font-size: 13px; font-weight: 600; }
.rc-destaque--ok { background: var(--successSoft); border-color: transparent; }
.rc-destaque--ok .rc-valor, .rc-destaque--ok .rc-nota { color: var(--success); }
.rc-destaque--perigo { background: var(--dangerSoft); border-color: transparent; }
.rc-destaque--perigo .rc-valor, .rc-destaque--perigo .rc-nota { color: var(--danger); }
.rc-blocos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rc-bloco { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surfaceRaised); min-width: 0; }
.rc-bloco .lp-secao-nome { display: block; margin-bottom: 6px; }
.rc-bloco dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 14px; }
.rc-bloco dt { color: var(--inkMuted); }
.rc-bloco dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rc-avisos { display: grid; gap: 8px; margin-top: 12px; }
.rc-aviso {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 12px;
  font: inherit; font-size: 14px; text-align: left; border: 0; background: var(--surface); color: var(--ink);
}
button.rc-aviso { cursor: pointer; min-height: 44px; }
.rc-aviso span { flex: 1; }
.rc-aviso .icon { flex: none; width: 18px; height: 18px; }
.rc-aviso--perigo { background: var(--dangerSoft); color: var(--danger); }
.rc-aviso--alerta { background: var(--warningSoft); color: var(--warning); }

/* Cartão de ficha (app.js cartaoFicha): um registro só (produto, cliente, venda...). */
.ficha-cartao .fc-cab { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; background: var(--surfaceRaised); }
/* O rótulo quebra; o valor fica à direita e só quebra entre palavras (endereço, e-mail longo). */
.ficha-cartao .rc-bloco dl { grid-template-columns: minmax(0, 1fr) auto; }
.ficha-cartao .rc-bloco dt { min-width: 0; overflow-wrap: break-word; }
.ficha-cartao .rc-bloco dd { white-space: normal; overflow-wrap: break-word; max-width: 16em; }

/* Faixa da assinatura no celular: uma linha; o toque mostra a mensagem completa. */
.aviso-assinatura .aviso-curto { display: none; }
@media (max-width: 767px) {
  .aviso-assinatura { flex-wrap: nowrap; cursor: pointer; padding: 8px 12px; }
  .aviso-assinatura .so-largo { display: none; }
  .aviso-assinatura .aviso-curto { display: block; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .aviso-assinatura #aviso-assinatura-texto { display: none; }
  .aviso-assinatura.is-aberta { flex-wrap: wrap; }
  .aviso-assinatura.is-aberta .aviso-curto { display: none; }
  .aviso-assinatura.is-aberta #aviso-assinatura-texto { display: block; }
}

/* Listas dos painéis (dataTable em app.js): o visual dos cartões do chat (lp-*), no celular e no computador. */
.painel-lista { margin-top: var(--space2); }
.painel-item { cursor: default; }
.painel-item.linha-clicavel { cursor: pointer; }
.painel-item.linha-clicavel:hover, .painel-item.linha-clicavel:focus-visible { background: var(--hover); }
.painel-item .lp-nome { font-size: 15px; }
.painel-item .lp-nome .badge { vertical-align: 1px; }
.painel-item .lp-sub { font-size: 13px; line-height: 19px; overflow-wrap: anywhere; }
.painel-item .lp-sub .badge { font-size: 11px; }
.painel-item .lp-rot { color: var(--inkMuted); }
.painel-item .lp-sub .unit, .painel-item .lp-preco .unit { font-weight: 400; }
.painel-item .lp-preco { font-variant-numeric: tabular-nums; }
.lp-preco-sub { font-size: 12px; line-height: 16px; color: var(--inkMuted); white-space: nowrap; text-align: right; }
.painel-etiquetas { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.painel-acoes { flex: none; display: flex; gap: var(--space2); }
.painel-ordem { margin: 0 0 var(--space2); align-items: center; gap: 6px; }
.painel-ordem-rot { font-size: 12px; color: var(--inkMuted); margin-right: 2px; }
@media (max-width: 600px) {
  .painel-item { gap: 10px; padding: 10px 12px; }
  .painel-item .lp-av { width: 32px; height: 32px; }
  .painel-acoes { flex-basis: 100%; justify-content: flex-end; }
  .painel-item:has(.painel-acoes) { flex-wrap: wrap; }
}
.painel-ordem { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space2); }
.painel-ordem .painel-ordem-sel { flex: 1 1 120px; min-width: 0; max-width: 280px; width: auto; }
.painel-ordem .painel-ordem-sel select { width: 100%; }
.painel-ordem-dir { white-space: nowrap; }
.painel-ordem .painel-ordem-dir { min-height: 36px; }
