:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-muted: #eef4f1;
  --ink: #18211f;
  --muted: #65736f;
  --line: #dbe4df;
  --green: #147a5a;
  --green-strong: #0f6148;
  --teal: #177f89;
  --blue: #315f9f;
  --amber: #b7791f;
  --red: #bd3b3b;
  --shadow: 0 18px 42px rgba(33, 45, 42, 0.12);
  /* Tokens da identidade NexoFarma */
  --brand-navy: #0d3b3e;
  --brand-green: #4caf74;
  --brand-green-dark: #2f9a5d;
  --brand-teal: #1488a6;
  --brand-blue: #60a5fa;
  --brand-mint: #e6eef2;
  --brand-surface: #ffffff;
  --primary: var(--brand-green);
  --text: var(--ink);
  --border: var(--line);
  --auth-gradient: linear-gradient(145deg, #e8f7ef 0%, #e6eef2 42%, #f4fbff 100%);
  --auth-card-shadow: 0 24px 60px rgba(13, 59, 62, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
}

/* Navegacao em dois niveis — primaria (icones) + secundaria (submenus) */
.nav-shell {
  display: flex;
  overflow: visible;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  z-index: 30;
}

.sidebar-primary {
  align-items: center;
  background: #0f1614;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 12px;
  height: 100vh;
  /* Corta overflow horizontal; popover de unidade usa position:fixed e nao e afetado */
  min-width: 0;
  overflow-x: hidden;
  overflow-y: visible;
  padding: 14px 0;
  position: relative;
  transition: width 0.25s ease, padding 0.25s ease;
  width: 60px;
}

/* Modo expandido: icones + rotulos (estilo Umbler Talk) */
body.sidebar-expanded .sidebar-primary {
  align-items: stretch;
  padding: 14px 10px;
  width: 220px;
}

.sidebar-primary-head {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  min-height: 40px;
  position: relative;
  width: 100%;
}

body.sidebar-expanded .sidebar-primary-head {
  justify-content: flex-start;
  padding: 0 4px;
}

.sidebar-primary .brand-mark {
  border-radius: 10px;
  flex-shrink: 0;
  font-size: 14px;
  height: 40px;
  margin-bottom: 0;
  width: 40px;
}

/* Slot do toggle: acima do primeiro item no modo recolhido */
.sidebar-toggle-wrap {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  padding: 2px 0 6px;
  transition: padding 0.25s ease;
  width: 100%;
}

/* Expandida: overlay no topo direito (estilo Umbler), sem ocupar espaco no fluxo */
body.sidebar-expanded .sidebar-toggle-wrap {
  height: 40px;
  left: 0;
  padding: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 14px;
  z-index: 35;
}

/* Botao chevron — recolhe/expande a sidebar */
.sidebar-toggle {
  align-items: center;
  background: #15201d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  color: #9eb5ad;
  display: inline-flex;
  flex-shrink: 0;
  height: 26px;
  justify-content: center;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.25s ease;
  width: 26px;
  z-index: 35;
}

/* Expandida: topo direito, dentro da sidebar (overflow-x:hidden corta valores negativos) */
body.sidebar-expanded .sidebar-toggle-wrap .sidebar-toggle {
  pointer-events: auto;
  position: absolute;
  right: 6px;
  top: 7px;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(33, 167, 124, 0.35);
  color: #eff8f4;
}

.sidebar-toggle-icon {
  height: 14px;
  transition: transform 0.2s ease;
  width: 14px;
}

/* Recolhida: chevron aponta para direita (expandir) */
body.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.nav-primary {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  min-width: 0;
  /* overflow-y:auto forca overflow-x:auto no spec — escondemos o eixo horizontal */
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 8px;
  width: 100%;
}

.nav-icon-btn {
  align-items: center;
  background: transparent;
  border-radius: 10px;
  color: #9eb5ad;
  display: inline-flex;
  flex-shrink: 0;
  gap: 0;
  height: 44px;
  justify-content: center;
  margin: 0 auto;
  max-width: 44px;
  transition: background 0.15s ease, color 0.15s ease, gap 0.2s ease, max-width 0.25s ease;
  width: 100%;
}

body.sidebar-expanded .nav-icon-btn {
  gap: 10px;
  justify-content: flex-start;
  margin: 0;
  max-width: none;
  padding: 0 10px;
}

/* Rotulo oculto no modo recolhido; aparece com transicao no expandido */
.nav-icon-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  text-align: left;
  transition: opacity 0.2s ease, max-width 0.25s ease;
  white-space: nowrap;
}

body.sidebar-expanded .nav-icon-label {
  max-width: 160px;
  opacity: 1;
}

.nav-icon-btn svg {
  height: 20px;
  width: 20px;
}

.nav-icon-btn:hover,
.nav-icon-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #eff8f4;
}

.nav-icon-btn.active {
  background: rgba(33, 167, 124, 0.22);
  color: #6ee7b7;
  box-shadow: inset 0 0 0 1px rgba(33, 167, 124, 0.35);
}

.nav-icon-btn--logout:hover {
  background: rgba(189, 59, 59, 0.18);
  color: #fca5a5;
}

.sidebar-primary-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 4px;
  margin-top: auto;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: visible;
  padding: 8px 6px 4px;
  width: 100%;
}

/* Seletor compacto de unidade no rodape (estilo Umbler Talk) */
.tenant-picker {
  max-width: 100%;
  min-width: 0;
  position: relative;
  width: 100%;
}

.tenant-picker-trigger {
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-sizing: border-box;
  color: #d9ebe4;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 6px 2px 5px;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: 100%;
}

.tenant-picker-trigger:hover,
.tenant-picker-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(33, 167, 124, 0.35);
}

.tenant-picker-avatar {
  align-items: center;
  background: linear-gradient(135deg, #1a8f6a, #147a5a);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  letter-spacing: 0.02em;
  width: 30px;
}

.tenant-picker-name {
  display: block;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* Chevron oculto na faixa de 60px — nao cabe sem estourar a largura */
.tenant-picker-chevron {
  color: #6d8a80;
  display: none;
  flex-shrink: 0;
  height: 10px;
  width: 10px;
}

/* Seletor de unidade em linha quando a sidebar esta expandida */
body.sidebar-expanded .tenant-picker-trigger {
  flex-direction: row;
  gap: 8px;
  padding: 8px 10px;
}

body.sidebar-expanded .tenant-picker-name {
  flex: 1;
  font-size: 12px;
  min-width: 0;
  text-align: left;
}

body.sidebar-expanded .tenant-picker-chevron {
  display: block;
}

.tenant-picker-menu {
  background: #15201d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 2px;
  grid-template-columns: minmax(0, 1fr);
  max-height: 220px;
  /* Largura fixa no intervalo permitido — evita max-content estourar com nomes longos */
  max-width: min(320px, calc(100vw - 16px));
  min-width: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px;
  /* fixed + coordenadas via JS: escapa do overflow da sidebar estreita */
  position: fixed;
  scrollbar-width: thin;
  width: min(320px, calc(100vw - 16px));
  z-index: 1000;
}

/* Esconde scrollbar horizontal nativa (WebKit/Edge) mantendo scroll vertical */
.tenant-picker-menu::-webkit-scrollbar {
  height: 0;
}

.tenant-picker-menu::-webkit-scrollbar:horizontal {
  display: none;
}

.tenant-picker-menu.hidden {
  display: none;
}

/* Header de rede/plataforma: apenas label, nao clicavel. */
.tenant-picker-group-header {
  color: rgba(200, 219, 212, 0.72);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-top: 4px;
  overflow: hidden;
  padding: 6px 10px 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tenant-picker-group-header:first-child {
  margin-top: 0;
}

.tenant-picker-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #c8dbd4;
  cursor: pointer;
  display: flex;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
}

/* Unidade indentada sob o header da rede (2+ unidades). */
.tenant-picker-item-nested {
  padding-left: 14px;
}

.tenant-picker-item-branch {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  height: 10px;
  margin-right: -2px;
  width: 8px;
}

.tenant-picker-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #eff8f4;
}

.tenant-picker-item.active {
  background: rgba(33, 167, 124, 0.18);
  color: #a7f3d0;
}

.tenant-picker-item-avatar {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #eff8f4;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.tenant-picker-item.active .tenant-picker-item-avatar {
  background: rgba(33, 167, 124, 0.35);
}

.tenant-picker-item-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}

.tenant-select-hidden {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

.sidebar-footer-actions {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.nav-icon-btn--footer {
  border-radius: 8px;
  flex: 0 0 auto;
  height: 36px;
  max-width: 44px;
  width: 36px;
}

.nav-icon-btn--footer svg {
  height: 18px;
  width: 18px;
}

.sidebar-secondary {
  background: #15201d;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #eff8f4;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
  width: 248px;
}

.sidebar-secondary.hidden {
  display: none;
}

.nav-secondary-head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  padding: 20px 18px 14px;
}

.nav-secondary-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.nav-secondary {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
}

.nav-secondary-group {
  display: grid;
  gap: 4px;
}

.nav-secondary-label {
  color: #6d8a80;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 8px 4px;
  text-transform: uppercase;
}

.nav-secondary-item {
  background: transparent;
  border-radius: 8px;
  color: #c8dbd4;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 12px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
}

.nav-secondary-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #eff8f4;
}

.nav-secondary-item.active {
  background: rgba(33, 167, 124, 0.18);
  color: #a7f3d0;
  font-weight: 600;
}

.tenant-card--secondary {
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  flex-shrink: 0;
  margin-top: auto;
}

/* Paineis individuais dentro de Configuracoes */
.settings-layout {
  display: grid;
  gap: 0;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-panel-header {
  margin-bottom: 18px;
}

.settings-panel-header h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.settings-panel-header p {
  color: var(--muted);
  font-size: 14px;
}

.settings-panel-body {
  display: grid;
  gap: 14px;
}

.settings-panel-body .form-card {
  margin-bottom: 0;
}

/* Compatibilidade: sidebar antiga removida, mantemos variaveis de tenant */
.sidebar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  overflow: hidden;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: transparent;
}

/* Logo da marca no topo da sidebar */
.brand-mark img {
  border-radius: inherit;
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.tenant-card span,
.tenant-card small {
  color: #a9beb6;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  background: transparent;
  color: #d9e8e2;
  text-align: left;
  padding: 0 12px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tenant-card {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.tenant-card select {
  margin: 12px 0 0;
  background: rgba(255, 255, 255, 0.08);
  color: #eff8f4;
  border-color: rgba(255, 255, 255, 0.16);
}

.tenant-card strong,
.tenant-card small {
  display: block;
  margin-top: 4px;
}

.logout-button {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.08);
}

/* Enquanto a sessao e verificada, oculta o shell e mostra apenas o overlay de carregamento. */
body.auth-checking .app-shell {
  visibility: hidden;
}

.auth-boot-overlay {
  display: none;
}

body.auth-checking .auth-boot-overlay,
body.auth-login .auth-page {
  background: var(--auth-gradient);
}

body.auth-checking .auth-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-boot-card {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: center;
}

.auth-boot-logo {
  height: auto;
  max-width: min(220px, 70vw);
  object-fit: contain;
}

.auth-boot-overlay p {
  color: var(--brand-navy);
  font-size: 15px;
  font-weight: 500;
  margin: 0;
}

.auth-boot-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(76, 175, 116, 0.2);
  border-top-color: var(--brand-green);
  border-radius: 50%;
  animation: auth-boot-spin 0.8s linear infinite;
}

@keyframes auth-boot-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Na tela de login a navegacao fica oculta e o conteudo ocupa a largura toda. */
body.auth-login .nav-shell {
  display: none;
}

body.auth-login .app-shell {
  grid-template-columns: 1fr;
}

body.auth-login .main {
  min-height: 100dvh;
  padding: 0;
}

/* Pagina de autenticacao: fundo com formas decorativas e card central */
.auth-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  overflow: hidden;
  padding: clamp(20px, 4vw, 40px);
  position: relative;
}

.auth-page::before,
.auth-page::after {
  border-radius: 50%;
  content: "";
  filter: blur(0);
  opacity: 0.55;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.auth-page::before {
  background: radial-gradient(circle, rgba(76, 175, 116, 0.28) 0%, rgba(76, 175, 116, 0) 70%);
  height: 420px;
  left: -120px;
  top: -80px;
  width: 420px;
}

.auth-page::after {
  background: radial-gradient(circle, rgba(20, 136, 166, 0.22) 0%, rgba(20, 136, 166, 0) 70%);
  bottom: -100px;
  height: 360px;
  right: -80px;
  width: 360px;
}

.auth-card {
  background: var(--brand-surface);
  border: 1px solid rgba(230, 238, 242, 0.9);
  border-radius: 28px;
  box-shadow: var(--auth-card-shadow);
  max-width: 460px;
  padding: clamp(28px, 4vw, 40px);
  position: relative;
  width: 100%;
  z-index: 1;
}

.auth-brand {
  margin-bottom: 28px;
  text-align: center;
}

.auth-brand-logo {
  display: block;
  height: auto;
  margin: 0 auto 12px;
  max-width: min(240px, 80vw);
  object-fit: contain;
}

.auth-brand-tagline {
  color: var(--brand-navy);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  margin: 0;
  opacity: 0.82;
}

.auth-card h1 {
  color: var(--brand-navy);
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.auth-card-lead {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 24px;
}

.auth-alert {
  background: rgba(189, 59, 59, 0.08);
  border: 1px solid rgba(189, 59, 59, 0.18);
  border-radius: 14px;
  color: #9f2f2f;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.auth-alert[hidden] {
  display: none;
}

.auth-alert--success {
  background: rgba(76, 175, 116, 0.1);
  border-color: rgba(76, 175, 116, 0.24);
  color: var(--brand-green-dark);
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field span {
  color: var(--brand-navy);
  font-size: 13px;
  font-weight: 600;
}

.auth-input-wrap {
  align-items: center;
  background: var(--brand-mint);
  border: 1px solid transparent;
  border-radius: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr auto;
  padding: 0 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-input-wrap:focus-within {
  background: #fff;
  border-color: rgba(76, 175, 116, 0.45);
  box-shadow: 0 0 0 4px rgba(76, 175, 116, 0.12);
}

.auth-input-icon {
  color: var(--brand-teal);
  display: inline-flex;
  height: 20px;
  width: 20px;
}

.auth-input-icon svg {
  display: block;
  height: 20px;
  width: 20px;
}

.auth-input-wrap input {
  background: transparent;
  border: 0;
  color: var(--brand-navy);
  font: inherit;
  min-height: 48px;
  outline: none;
  padding: 0;
  width: 100%;
}

.auth-input-wrap input::placeholder {
  color: rgba(13, 59, 62, 0.42);
}

.auth-toggle-password {
  align-items: center;
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.auth-toggle-password:hover {
  background: rgba(13, 59, 62, 0.06);
  color: var(--brand-navy);
}

.auth-remember {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 14px;
  gap: 10px;
  line-height: 1.4;
  margin: 2px 0 4px;
  user-select: none;
}

.auth-remember input {
  accent-color: var(--brand-teal);
  height: 18px;
  margin: 0;
  width: 18px;
}

.auth-submit {
  align-items: center;
  background: linear-gradient(135deg, var(--brand-green) 0%, var(--brand-teal) 100%);
  border-radius: 999px;
  box-shadow: 0 14px 28px rgba(76, 175, 116, 0.28);
  color: #fff;
  display: inline-flex;
  font-size: 15px;
  font-weight: 700;
  gap: 10px;
  justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  width: 100%;
}

.auth-submit:hover:not(:disabled) {
  box-shadow: 0 18px 34px rgba(76, 175, 116, 0.34);
  transform: translateY(-1px);
}

.auth-submit:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.auth-link {
  background: transparent;
  color: var(--brand-teal);
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  text-decoration: none;
}

.auth-link:hover {
  color: var(--brand-green-dark);
  text-decoration: underline;
}

.auth-footer-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 18px 0 0;
  text-align: center;
}

@media (max-width: 640px) {
  .auth-page::before,
  .auth-page::after {
    opacity: 0.35;
    transform: scale(0.8);
  }

  .auth-card {
    border-radius: 22px;
    padding: 24px 20px;
  }

  .auth-links {
    flex-direction: column;
    gap: 10px;
  }
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 56px);
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
}

.login-card h1 {
  margin-bottom: 8px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Banner e hints do onboarding do gestor */
.setup-banner {
  background: linear-gradient(135deg, rgba(34, 139, 87, 0.08), rgba(34, 139, 87, 0.02));
  border: 1px solid rgba(34, 139, 87, 0.25);
  border-radius: 12px;
  max-width: 560px;
  padding: 12px 14px;
}

.setup-banner-inner {
  display: grid;
  gap: 10px;
}

.setup-banner-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.setup-banner-head strong {
  font-size: 15px;
}

.setup-banner-progress {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
}

.setup-banner-bar {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.setup-banner-bar-fill {
  background: var(--green);
  display: block;
  height: 100%;
  transition: width 0.25s ease;
}

.setup-banner-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.setup-step {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
}

.setup-step--done {
  background: rgba(34, 139, 87, 0.1);
  border-color: rgba(34, 139, 87, 0.35);
  color: var(--green);
}

.setup-step--pending {
  border-color: rgba(217, 119, 6, 0.35);
  color: #b45309;
}

.setup-step--partial {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.35);
  color: #1d4ed8;
}

.setup-inline-alert {
  background: rgba(217, 119, 6, 0.12);
  border: 1px solid rgba(217, 119, 6, 0.45);
  border-radius: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
}

.setup-inline-alert strong {
  display: block;
  margin-bottom: 4px;
}

.setup-inline-missing {
  margin: 8px 0 0;
  padding-left: 18px;
}

.setup-hint {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-width: 320px;
  padding: 14px;
  position: fixed;
  z-index: 1200;
}

.setup-hint-target {
  box-shadow: 0 0 0 3px rgba(34, 139, 87, 0.35);
  outline: 2px solid rgba(34, 139, 87, 0.5);
  outline-offset: 2px;
}

.eyebrow {
  color: var(--green);
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 19px;
}

.primary,
.secondary {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: var(--green);
  color: white;
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.metrics {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* Faixa compacta de KPIs — label e valor na mesma linha */
.metric-chip {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 6px;
  line-height: 1;
  padding: 6px 12px;
}

.metric-chip span {
  color: var(--muted);
  font-size: 12px;
}

.metric-chip strong {
  font-size: 14px;
  font-weight: 700;
}

.metric-chip--alert {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.35);
}

.metric-chip--alert strong {
  color: #b91c1c;
}

/* Cards maiores reservados para relatorios (ex.: pedidos) */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(33, 45, 42, 0.05);
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  font-size: 20px;
}

.metric-card--alert {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(254, 226, 226, 0.35);
}

.metric-card--alert strong {
  color: #b91c1c;
}

.pilot-metrics-grid {
  margin-top: 12px;
}

body.inbox-has-new .topbar {
  animation: inboxPulse 0.8s ease 2;
}

@keyframes inboxPulse {
  0%,
  100% {
    box-shadow: none;
  }
  50% {
    box-shadow: inset 0 -3px 0 #2563eb;
  }
}

.inbox-mobile-back,
.inbox-mobile-only {
  display: none;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
}

/* Inbox estilo Umbler: lista | chat | painel do contato (colunas redimensionaveis) */
.inbox-3col {
  display: grid;
  grid-template-columns:
    var(--inbox-col-list, 320px) 6px
    minmax(360px, 1fr) 6px
    var(--inbox-col-contact, 320px);
  gap: 0;
  padding: 0;
  overflow: hidden;
  min-height: calc(100vh - 180px);
}

.inbox-list-pane {
  grid-column: 1;
  border-right: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Garante que o conteudo nunca empurre a coluna alem da largura do painel. */
  min-width: 0;
  overflow: hidden;
  max-height: calc(100vh - 180px);
  padding: 10px;
}

.inbox-resizer {
  grid-row: 1;
  width: 6px;
  cursor: col-resize;
  background: var(--line);
  transition: background 0.15s ease;
  touch-action: none;
  user-select: none;
}

.inbox-resizer[data-resize="list"] {
  grid-column: 2;
}

.inbox-resizer[data-resize="contact"] {
  grid-column: 4;
}

.inbox-resizer:hover,
.inbox-resizer:active {
  background: var(--green);
}

body.inbox-resizing {
  cursor: col-resize;
  user-select: none;
}

body.inbox-resizing * {
  cursor: col-resize !important;
}

.inbox-chat-pane {
  grid-column: 3;
  border-right: 0;
  border-left: 0;
  padding: 0;
  min-height: 0;
  max-height: calc(100vh - 180px);
}

.inbox-contact-pane {
  grid-column: 5;
  background: #fafcfb;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: calc(100vh - 180px);
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.inbox-contact-pane .contact-panel-scroll {
  flex: 1;
  min-height: 0;
}

.inbox-header.panel-header {
  margin-bottom: 8px;
}

.inbox-header.panel-header h2 {
  font-size: 16px;
}

.inbox-header.panel-header span {
  font-size: 12px;
}

.inbox-search {
  display: block;
  margin-bottom: 8px;
}

.inbox-search input {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  padding: 7px 10px;
  width: 100%;
}

.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-card.has-unread {
  background: #f8fffb;
}

.conversation-card.has-delivery-failure {
  background: #fff3f3;
  border-color: #ffb4b4;
}

.conversation-delivery-failed {
  font-size: 10px !important;
  padding: 2px 6px !important;
}

.conversation-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d9f7e8, #b8ecd4);
  color: #0d6b3f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.conversation-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conversation-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conversation-row-top {
  justify-content: space-between;
}

.conversation-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 11px;
  flex-shrink: 0;
}

.conversation-preview {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.conversation-row-bottom {
  justify-content: space-between;
}

.conversation-status {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.conversation-status .status {
  font-size: 10px;
  padding: 2px 6px;
}

.conversation-assignee {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-sla {
  font-size: 10px !important;
  padding: 2px 5px !important;
}

.conversation-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.conversation-tags .tag {
  font-size: 10px;
  padding: 2px 6px;
}

.conversation-unread {
  align-items: center;
  background: var(--green);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 10px;
  font-weight: 700;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  flex-shrink: 0;
}

.chat-header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.contact-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d9f7e8, #b8ecd4);
  color: #0d6b3f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.contact-header-info strong {
  display: block;
  font-size: 14px;
}

.contact-header-info p {
  margin: 2px 0 0;
  font-size: 12px;
}

.contact-channel {
  font-size: 11px !important;
}

.contact-panel-scroll {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 8px 10px 12px;
}

.contact-header-simple {
  margin-bottom: 2px;
}

.contact-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.contact-section h4 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.contact-section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.contact-section-head h4 {
  margin: 0;
}

.contact-summary-line,
.contact-card-line {
  font-size: 13px;
  margin: 4px 0;
}

.contact-section-highlight {
  background: rgba(37, 99, 235, 0.04);
  border-color: rgba(37, 99, 235, 0.18);
}

.contact-section-warn {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.28);
}

.contact-empty-hint {
  font-size: 12px;
}

.tag-editor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag-chip {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  gap: 4px;
  padding: 4px 8px 4px 10px;
}

.tag-chip-remove {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.contact-tag-row {
  display: flex;
  gap: 6px;
}

.contact-tag-row input {
  flex: 1;
  font-size: 12px;
}

.contact-notes-section {
  margin-top: auto;
}

.contact-notes-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.contact-note {
  background: #f8faf9;
  border-radius: 8px;
  font-size: 12px;
  padding: 8px;
}

.contact-note strong {
  margin-right: 6px;
}

.contact-note p {
  margin: 4px 0 0;
}

.contact-note-form {
  display: flex;
  gap: 6px;
}

.contact-note-form input {
  flex: 1;
  font-size: 12px;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.contact-card-compact {
  padding: 8px 10px;
}

.contact-card p {
  margin: 4px 0;
  font-size: 12px;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag-editor input {
  flex: 1;
  min-width: 120px;
}

.message-day-sep {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
}

.message-day-sep span {
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-header span {
  color: var(--muted);
  font-size: 14px;
}

.panel-header.compact {
  margin-top: 24px;
}

.views {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.view-pill,
.tag,
.status,
.source-pill {
  border-radius: 999px;
  white-space: nowrap;
}

.view-pill {
  background: var(--surface-muted);
  color: var(--ink);
  padding: 5px 10px;
  font-size: 11px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 600;
}

.view-pill.active {
  background: #e9f5ef;
  border-color: var(--green);
  color: var(--green-strong);
}

.inbox-tabs {
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.inbox-tabs .view-pill {
  flex: 1 1 calc(50% - 6px);
  min-width: 0;
  text-align: center;
}

/* Aba "Todas" ocupa a linha inteira acima do grid 2x2 */
.inbox-tabs .view-pill[data-view="all"] {
  flex: 1 1 100%;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.channel-pill.web {
  background: #ebe8ff;
  color: #4a3f8f;
}

.channel-pill.cloud {
  background: #e5f0ff;
  color: #1f4f8a;
}

.conversation-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.inbox-empty {
  padding: 24px 12px;
}

.conversation-list {
  display: grid;
  /* minmax(0, 1fr) permite a coluna encolher abaixo do conteudo, ativando o ellipsis. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  overflow-x: hidden;
}

.conversation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfb;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  /* Card sempre acompanha a largura da coluna, sem estourar para os lados. */
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  text-align: left;
  cursor: pointer;
}

.conversation-card.active {
  border-color: var(--green);
  background: #f0faf4;
  box-shadow: inset 3px 0 0 var(--green);
}

.conversation-top,
.order-top,
.product-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.conversation-card p {
  color: var(--muted);
  margin-top: 8px;
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  background: #eef4f1;
  color: #30554c;
  padding: 4px 8px;
  font-size: 12px;
}

.tag.danger {
  background: #fff0f0;
  color: var(--red);
}

.conversation-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.chat-header,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
  align-items: center;
}

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d9f7e8, #b8ecd4);
  color: #0d6b3f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-header-info {
  min-width: 0;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-header-title h2 {
  margin: 0;
  font-size: 15px;
}

.chat-header-sub {
  margin: 2px 0 0;
  font-size: 12px;
}

.chat-pipeline-details {
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: #fafcfb;
}

.chat-pipeline-details summary {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.chat-pipeline-details .pipeline-guide {
  margin: 0 12px 8px;
}

.chat-banner {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.chat-banner-web {
  background: #ebe8ff;
  color: #4a3f8f;
}

.chat-banner-ok {
  background: #e9f5ef;
  color: var(--green-strong);
}

.chat-banner-warn {
  background: #fff0f0;
  color: var(--red);
}

.chat-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px 16px;
  background: #e8ece9;
  background-image: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35) 0, transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.25) 0, transparent 40%);
}

.chat-composer {
  flex-shrink: 0;
  margin-top: 0;
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  background: #f7f8f7;
}

.composer-template-banner {
  background: rgba(234, 179, 8, 0.12);
  border-bottom: 1px solid rgba(234, 179, 8, 0.25);
  color: #92400e;
  font-size: 12px;
  margin: 0;
  padding: 6px 12px;
}

.composer-input-row {
  align-items: flex-end;
  display: flex;
  gap: 8px;
}

.composer-input-row textarea {
  border-radius: 18px;
  flex: 1;
  font-size: 13px;
  max-height: 120px;
  min-height: 40px;
  padding: 8px 12px;
  resize: vertical;
}

.composer-actions {
  align-items: flex-end;
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  position: relative;
}

.composer-menu-btn {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 20px;
  height: 36px;
  justify-content: center;
  line-height: 1;
  width: 36px;
}

.composer-menu {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  bottom: calc(100% + 6px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  max-height: 220px;
  min-width: 200px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  right: 0;
  z-index: 20;
}

.composer-menu.hidden {
  display: none;
}

.composer-menu-item {
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  padding: 8px 10px;
  text-align: left;
}

.composer-menu-item:hover {
  background: rgba(37, 99, 235, 0.08);
}

.composer-menu-item-action {
  border-top: 1px solid var(--line);
  color: #b45309;
  margin-top: 4px;
  padding-top: 10px;
}

.composer-menu-empty {
  display: block;
  font-size: 12px;
  padding: 8px 10px;
}

.composer-send {
  border-radius: 18px;
  flex-shrink: 0;
  padding: 8px 14px;
}

.chat-alerts {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
}

.chat-alert {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border: 1px solid #f6d7aa;
  border-radius: 8px;
  background: #fff8ed;
  color: #8a4b0e;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 700;
}

.chat-insights {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fbfcfb;
}

.chat-insights summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  font-size: 14px;
}

.chat-insights .side-card {
  margin-top: 10px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  padding: 48px 20px;
}

.message-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 2px;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.4;
}

.message-attachment {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.message-attachment-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: #0b6bcb;
  text-decoration: underline;
}

.message-media {
  display: block;
  margin-top: 6px;
  max-width: 240px;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

.message-media-img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  background: #eef1f0;
  cursor: zoom-in;
}

.contact-proofs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.contact-proof-thumb {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.contact-proof-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.contact-proof-link {
  font-size: 12px;
  color: #0b6bcb;
}

.contact-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.message-time {
  display: block;
  text-align: right;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}

.message-meta .message-time {
  margin-top: 0;
}

.message-delivery-failed {
  font-size: 10px;
  padding: 2px 6px;
}

.message.message-failed .message-bubble {
  background: #ffe8e8;
  border: 1px solid #f5c2c2;
}

.status {
  align-self: start;
  background: #e9f5ef;
  color: var(--green-strong);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status.sla-breach {
  background: #fff0f0;
  color: var(--red);
}

.customer-history {
  font-size: 13px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f7faf8;
  border-radius: 8px;
}

.note-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.note-form input {
  margin-bottom: 0;
}

.quick-reply-form {
  align-items: end;
  flex-wrap: wrap;
}

.quick-reply-form .field {
  flex: 1 1 150px;
  margin-bottom: 0;
}

.quick-reply-form button {
  flex: 0 0 auto;
}

.ai-log-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.ai-alert-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ai-alert-row {
  border: 1px solid var(--line);
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 10px;
  background: #fffaf0;
}

.ai-alert-row.high {
  border-left-color: #dc2626;
}

.ai-log-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

.pharma-case {
  margin-bottom: 12px;
}

.bot-test-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.bot-test-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bot-test-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.bot-test-customer {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.bot-test-thread {
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f8faf9;
}

.bot-test-empty {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}

.bot-test-form {
  margin: 0;
}

.bot-test-form textarea {
  min-height: 56px;
}

.bot-test-result {
  margin-top: 4px;
}

.bot-test-reply {
  background: #f0f7f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  margin: 8px 0;
}

.bot-test-out.blocked .bot-test-reply {
  background: #fff7f0;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
}

.message {
  display: flex;
  margin-bottom: 2px;
  max-width: 100%;
}

.message.inbound {
  justify-content: flex-start;
}

.message.assistant,
.message.outbound {
  justify-content: flex-end;
}

.message.system {
  justify-content: center;
}

.message-bubble {
  max-width: 75%;
  padding: 6px 10px 4px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.message.inbound .message-bubble {
  background: #fff;
  border-bottom-left-radius: 4px;
}

.message.assistant .message-bubble,
.message.outbound .message-bubble {
  background: #d9fdd3;
  border-bottom-right-radius: 4px;
}

.message.system .message-bubble {
  max-width: 90%;
  background: #fff8e8;
  border-radius: 10px;
  text-align: center;
}

.message small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.side-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
  margin-bottom: 10px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.reply-form,
.form-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
  margin-bottom: 12px;
}

.chat-composer.reply-form {
  border: 0;
  border-radius: 0;
  padding: 8px 10px;
  margin-bottom: 0;
  background: #f7f8f7;
}

.form-card h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

/* Separador visual da secao de ID de pedidos no playbook. */
.playbook-section-title {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0;
}

.check-row input {
  width: auto;
  margin: 0;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.column-mapping-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8faf8;
}

.column-mapping-panel.hidden {
  display: none;
}

.column-mapping-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.column-mapping-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.column-mapping-table-wrap {
  overflow: auto;
  max-height: 180px;
}

.column-mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.column-mapping-table th,
.column-mapping-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  margin-bottom: 8px;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.selected-row {
  background: #ecf7f2;
}

/* Linhas da tabela de estoque sao clicaveis para editar o produto */
#productsTable tr {
  cursor: pointer;
}

#productsTable tr:hover:not(.selected-row) {
  background: #f5faf8;
}

.form-card .form-help {
  font-size: 12px;
  margin: 0 0 10px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.mini-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #eef4f1;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.mini-button:hover {
  background: #e2ebe6;
}

/* Variantes semanticas das acoes da conversa (inbox) */
.mini-button--transfer {
  background: #edf2fa;
  border-color: #c5d4eb;
  color: var(--blue);
}

.mini-button--transfer:hover {
  background: #dde8f6;
  border-color: #9fb6d9;
  box-shadow: 0 1px 0 rgba(49, 95, 159, 0.12);
}

.mini-button--finish {
  background: #fff0f0;
  border-color: #f0c4c4;
  color: var(--red);
}

.mini-button--finish:hover {
  background: #ffe3e3;
  border-color: #e39a9a;
  box-shadow: 0 1px 0 rgba(189, 59, 59, 0.12);
}

.mini-button--pix {
  background: #e8f6f7;
  border-color: #b7dde1;
  color: var(--teal);
}

.mini-button--pix:hover {
  background: #d5eef1;
  border-color: #8ec5cb;
  box-shadow: 0 1px 0 rgba(23, 127, 137, 0.12);
}

.mini-button--assign {
  background: #e8f7ef;
  border-color: #b7e2c8;
  color: var(--green-strong);
}

.mini-button--assign:hover {
  background: #d6f0e2;
  border-color: #8dcea8;
  box-shadow: 0 1px 0 rgba(15, 97, 72, 0.12);
}

.mini-button--resume-bot {
  background: #f7f3e8;
  border-color: #e4d6b0;
  color: var(--amber);
}

.mini-button--resume-bot:hover {
  background: #f0e8d2;
  border-color: #d4bf8a;
  box-shadow: 0 1px 0 rgba(183, 121, 31, 0.12);
}

.mini-button-link {
  background: transparent;
  color: var(--muted);
  padding: 0;
  min-height: auto;
  font-size: 0.82rem;
  text-decoration: underline;
  font-weight: 600;
}

.contact-phone-editor {
  margin-top: 0.5rem;
}

.xs-button {
  min-height: 28px;
  border-radius: 8px;
  background: #eef4f1;
  color: var(--ink);
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
  font-weight: 700;
}

.gateway-grid,
.channel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.gateway-card,
.channel-card,
.order-card,
.movement-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

/* Destaque visual para rascunhos da IA na aba Pedidos. */
.order-card--draft {
  border-style: dashed;
  background: #f7faf8;
}

/* Barra lateral de status para leitura rapida na operacao. */
.order-card {
  border-left: 4px solid var(--line);
}

.order-card--draft {
  border-left-color: #8aa39a;
}

.order-card--created,
.order-card--awaiting_payment_review {
  border-left-color: #d97706;
}

.order-card--ready_for_separation {
  border-left-color: var(--brand-teal);
}

.order-card--ready_for_pickup,
.order-card--out_for_delivery {
  border-left-color: var(--brand-green);
}

.order-card--completed {
  border-left-color: #94a3b8;
  opacity: 0.92;
}

.order-card--expired {
  border-left-color: var(--red);
}

.orders-toolbar {
  margin-bottom: 12px;
}

.orders-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.orders-filter-count {
  margin-left: 4px;
  opacity: 0.75;
  font-weight: 700;
}

.orders-board {
  display: grid;
  gap: 10px;
}

.orders-empty {
  padding: 18px 4px;
}

.order-heading {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.order-id-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.order-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--brand-navy);
}

.order-customer {
  font-size: 16px;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
}

.order-amount-col {
  text-align: right;
  display: grid;
  gap: 4px;
  align-content: start;
}

.order-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  background: #eef4f1;
  color: #30554c;
}

.order-status-badge.status-draft {
  background: #eef2f1;
  color: #4b635c;
}

.order-status-badge.status-created,
.order-status-badge.status-awaiting_payment_review {
  background: #fff7ed;
  color: #9a3412;
}

.order-status-badge.status-ready_for_separation {
  background: #e8f6f8;
  color: #0f5f6e;
}

.order-status-badge.status-ready_for_pickup,
.order-status-badge.status-out_for_delivery {
  background: #e9f5ef;
  color: var(--green-strong);
}

.order-status-badge.status-completed {
  background: #eef2f7;
  color: #475569;
}

.order-status-badge.status-expired {
  background: #fef2f2;
  color: #b91c1c;
}

.order-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button--primary {
  background: linear-gradient(135deg, var(--brand-green) 0%, var(--brand-teal) 100%);
  border-color: transparent;
  color: #fff;
}

.mini-button--primary:hover {
  filter: brightness(0.97);
}

.report-grid--orders {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ops-grid--compact {
  margin-bottom: 14px;
}

.gateway-card strong,
.channel-card strong {
  display: block;
  margin-bottom: 8px;
}

.gateway-card span,
.channel-card span,
.movement-card span {
  color: var(--muted);
  font-size: 13px;
}

.source-pill {
  display: inline-block;
  background: #edf7f4;
  color: var(--teal);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  margin-top: 10px;
}

.consys-connector-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
  background: #fbfcfb;
}

.consys-setup-form {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.consys-endpoint-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.consys-endpoint-row code {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface-muted, #eef2f4);
  color: var(--muted);
}

.consys-endpoint-row input {
  width: 100%;
  font-size: 12px;
}

.consys-setup-details {
  margin-top: 8px;
}

.consys-guide {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.consys-auto-list li {
  margin-bottom: 6px;
  color: var(--text, #1f2a28);
}

/* Assistente de conexao Consys em 3 passos. */
.consys-steps {
  list-style: none;
  margin: 14px 0 6px;
  padding: 0;
  display: grid;
  gap: 10px;
  counter-reset: consys-step;
}

.consys-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.consys-step.waiting {
  opacity: 0.62;
}

.consys-step.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px var(--teal) inset;
}

.consys-step.done {
  border-color: var(--green, #1f8a5f);
}

.consys-step-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
}

.consys-step-head strong {
  display: block;
  font-size: 14px;
}

.consys-step-head span {
  display: block;
  font-size: 12px;
}

.consys-step-num {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-muted, #eef2f4);
  color: var(--muted);
}

.consys-step.active .consys-step-num,
.consys-step.done .consys-step-num {
  background: var(--teal);
  color: #fff;
}

.consys-token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.consys-token-row input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.consys-token-warning {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #9a6700;
}

.consys-handoff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

.consys-selftest {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

/* Aviso do passo 3 e do endereco publico ausente. */
.consys-alert {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 12px;
}

.consys-alert span {
  color: var(--muted);
}

.consys-alert.ok {
  border-left-color: var(--green, #1f8a5f);
  background: #e9f5ef;
}

.consys-alert.danger {
  border-left-color: var(--red);
  background: #fdecea;
}

.consys-alert-fix {
  font-weight: 600;
}

/* Checklist do aperto de mao: cada linha acende quando a Consys chama a rota. */
.consys-handshake {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.consys-handshake-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.consys-handshake-row strong {
  display: block;
  font-size: 13px;
}

.consys-handshake-row span.muted {
  display: block;
  font-size: 11px;
}

.consys-handshake-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-muted, #eef2f4);
  color: var(--muted);
}

.consys-handshake-row.done .consys-handshake-icon {
  background: var(--green, #1f8a5f);
  color: #fff;
}

.consys-handshake-row.fail .consys-handshake-icon {
  background: var(--red);
  color: #fff;
}

.consys-handshake-row.done {
  border-color: #bfe3d1;
}

.consys-handshake-row.fail {
  border-color: #f6c9c3;
}

.consys-handshake-when {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.consys-sync-line {
  margin: 10px 0 0;
  font-size: 11px;
}

@media (max-width: 720px) {
  .consys-token-row,
  .consys-endpoint-row {
    grid-template-columns: 1fr;
  }

  .consys-handshake-row {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .consys-handshake-when {
    grid-column: 2;
    white-space: normal;
  }
}

.inventory-table-wrap {
  overflow-x: auto;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.ops-line {
  display: grid;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.ops-line:last-child {
  border-bottom: 0;
}

.ops-line span {
  color: var(--muted);
  font-size: 13px;
}

.inventory-divergence-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
  margin-bottom: 12px;
}

.inventory-divergence-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.inventory-divergence-head strong {
  display: block;
  font-size: 15px;
}

.inventory-divergence-head span {
  color: var(--muted);
  font-size: 13px;
}

.inventory-divergence-list {
  display: grid;
  gap: 8px;
}

.inventory-divergence-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.inventory-divergence-row.high {
  border-left-color: var(--red);
}

.inventory-divergence-row.medium {
  border-left-color: #d97706;
}

.inventory-divergence-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.divergence-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.divergence-numbers span {
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 6px 8px;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.order-list,
.movement-list {
  display: grid;
  gap: 10px;
}

.order-items {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.muted {
  color: var(--muted);
}

.amount {
  font-size: 20px;
  font-weight: 800;
}

/* Layout da pagina Conexao WhatsApp */
.wa-layout {
  display: grid;
  gap: 16px;
}

.wa-status-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wa-status-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fbfcfb;
}

.wa-status-card strong {
  display: block;
  font-size: 16px;
  margin: 4px 0 6px;
}

.wa-status-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.wa-status-badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.wa-status-ok .wa-status-badge {
  background: #e6f6ef;
  color: #0d6b4f;
}

.wa-status-warn .wa-status-badge {
  background: #fff4e5;
  color: #9a5b00;
}

.wa-status-pending .wa-status-badge {
  background: #e8f0ff;
  color: #1d4f91;
}

.wa-status-neutral .wa-status-badge {
  background: #eef2f4;
  color: var(--muted);
}

.wa-tabs,
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.wa-tab,
.subtab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}

.wa-tab.active,
.subtab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.wa-panel.hidden,
.subtab-panel.hidden {
  display: none;
}

/* Abas do Estoque: espacamento proprio e contador por aba. */
.subtabs {
  margin-bottom: 14px;
}

.subtab-count {
  margin-left: 6px;
  opacity: 0.75;
  font-weight: 800;
}

.subtab.active .subtab-count {
  opacity: 0.9;
}

.subtab-count.alert {
  color: var(--red);
  opacity: 1;
}

.subtab.active .subtab-count.alert {
  color: #ffe3e0;
}

/* Toolbar da aba Produtos: busca, filtros e acoes. */
.products-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.products-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.products-search {
  flex: 1 1 260px;
  min-width: 200px;
  margin-bottom: 0;
}

.products-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.products-result-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

/* Sinalizacao de estoque baixo na tabela de produtos. */
.stock-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: #fdecea;
  color: var(--red);
  border: 1px solid #f6c9c3;
  white-space: nowrap;
}

.product-row-actions {
  text-align: right;
  white-space: nowrap;
}

/* Some com a moldura da tabela quando o filtro nao retorna nenhum produto. */
.inventory-table-wrap.hidden {
  display: none;
}

.wa-panel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 360px);
  gap: 16px;
  align-items: start;
}

.wa-panel-single {
  max-width: 640px;
}

.wa-steps-card,
.wa-qr-card,
.wa-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fbfcfb;
}

.wa-steps-card h3,
.wa-qr-card h3,
.wa-block h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

.wa-steps {
  margin: 0 0 14px;
  padding-left: 20px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.wa-steps li + li {
  margin-top: 6px;
}

.wa-lead {
  margin: 0 0 16px;
}

.wa-hint {
  margin-top: 10px;
  min-height: 1.2em;
}

.wa-details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fbfcfb;
}

.wa-details summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 8px;
}

.wa-details[open] summary {
  margin-bottom: 12px;
}

.wa-templates-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.wa-dev-form {
  margin: 0;
}

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  margin-bottom: 0;
}

.qr-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 12px;
  background: #fff;
  min-height: 300px;
  justify-content: center;
}

.qr-visual img {
  border-radius: 8px;
}

.qr-placeholder {
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.stack-form {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.consent-line {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0.75rem 0;
  font-size: 0.92rem;
}

.wa-connect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.qr-box {
  display: grid;
  place-items: center;
  height: 120px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f6f7f5;
  color: var(--green);
  font-weight: 800;
  margin-top: 10px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
}

.empty strong,
.empty span {
  display: block;
}

.empty button {
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  border-radius: 8px;
  background: #15201d;
  color: white;
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  transform: translateY(12px);
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 20;
}

.toast.ok,
.toast.error,
.toast.warn {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--red);
}

.toast.warn {
  background: #b45309;
}

.field--invalid input,
.field--invalid textarea {
  border-color: #dc2626;
}

.field-hint-error {
  color: #dc2626;
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

/* Modal — criar/editar usuario da equipe e outros CRUDs de configuracao */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 25, 22, 0.55);
  backdrop-filter: blur(4px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.modal-narrow {
  width: min(420px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--line);
  color: var(--ink);
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 18px 22px 22px;
}

.modal-body .field {
  display: grid;
  gap: 6px;
}

.modal-body .field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.modal-body input[readonly] {
  background: #f5f8f6;
  color: var(--ink);
  cursor: default;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Modal criar pedido real — formulario um pouco mais largo */
.order-modal {
  width: min(560px, 100%);
}

.order-modal-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 520px) {
  .order-modal-row {
    grid-template-columns: 1fr;
  }
}

.team-panel {
  display: grid;
  gap: 14px;
}

.team-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.team-list {
  display: grid;
  gap: 8px;
}

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.team-row strong {
  display: block;
  font-size: 14px;
}

.team-row .muted {
  font-size: 12px;
}

.account-status-list {
  display: grid;
  gap: 8px;
}

.account-status-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.account-users-panel {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  gap: 12px;
}

.account-billing-panel {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  gap: 12px;
}

.account-users-panel-header,
.tenant-users-header,
.team-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-users-panel-header h4,
.admin-users-panel h3,
.tenant-users-block strong {
  margin: 0;
  font-size: 14px;
}

.tenant-users-block {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.tenant-users-block:first-of-type {
  border-top: none;
  padding-top: 0;
}

.admin-users-panel .team-list {
  margin-top: 8px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-shell {
    position: static;
    height: auto;
    flex-direction: column;
  }

  .sidebar-toggle,
  .sidebar-toggle-wrap {
    display: none;
  }

  body.sidebar-expanded .sidebar-primary,
  body.sidebar-collapsed .sidebar-primary {
    width: 100%;
  }

  .sidebar-primary {
    flex-direction: row;
    height: auto;
    width: 100%;
    padding: 10px 12px;
    gap: 8px;
  }

  .sidebar-primary-head {
    flex: 0 0 auto;
    min-height: 0;
  }

  body.sidebar-expanded .nav-icon-label {
    display: none;
  }

  .nav-primary {
    flex-direction: row;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
  }

  .sidebar-primary-footer {
    border-top: 0;
    flex-direction: row;
    gap: 8px;
    margin-top: 0;
    padding: 0;
  }

  .tenant-picker {
    flex: 0 0 auto;
  }

  .tenant-picker-trigger {
    flex-direction: row;
    gap: 6px;
    padding: 6px 10px;
    width: auto;
  }

  .tenant-picker-name {
    font-size: 11px;
    max-width: 120px;
  }

  /* Na barra horizontal mobile o chevron volta a indicar menu expansivel */
  .tenant-picker-chevron {
    display: block;
  }

  /* Posicionamento do popover continua via JS (position: fixed) */

  .sidebar-footer-actions {
    flex: 0 0 auto;
    flex-direction: row;
  }

  .sidebar-secondary {
    width: 100%;
    height: auto;
    max-height: 280px;
  }

  .sidebar-secondary.hidden {
    display: none;
  }

  .metrics,
  .gateway-grid,
  .channel-grid,
  .wa-status-row,
  .wa-panel-grid,
  .split,
  .inbox-3col {
    grid-template-columns: 1fr;
    --inbox-col-list: auto;
    --inbox-col-contact: auto;
  }

  .inbox-resizer {
    display: none;
  }

  .inbox-list-pane,
  .inbox-chat-pane,
  .inbox-contact-pane {
    display: none;
    grid-column: 1;
    border-right: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }

  .inbox-3col[data-mobile-pane="list"] .inbox-list-pane,
  .inbox-3col[data-mobile-pane="chat"] .inbox-chat-pane,
  .inbox-3col[data-mobile-pane="contact"] .inbox-contact-pane {
    display: flex;
    flex-direction: column;
  }

  .inbox-mobile-back,
  .inbox-mobile-only {
    display: inline-flex;
  }

  .inbox-mobile-back {
    align-items: center;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    height: 36px;
    justify-content: center;
    margin: 8px 8px 0;
    width: 36px;
  }

  .chat-header {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: auto 1fr;
  }

  .chat-header-actions {
    grid-column: 1 / -1;
  }

  .inbox-chat-pane {
    padding: 0;
  }

  .conversation-detail {
    border-left: 0;
    padding-left: 0;
    padding-top: 0;
    min-height: 420px;
  }
}

/* Guia de pipeline na inbox — proximo passo do operador */
.pipeline-guide {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 233, 0.06));
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
}

.pipeline-guide-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.pipeline-steps {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.pipeline-step {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
}

.pipeline-step.urgent {
  border-left: 3px solid #dc2626;
}

.pipeline-step.done {
  opacity: 0.65;
}

.pipeline-deviation {
  font-size: 13px;
  margin-top: 10px;
}

/* Bloqueio de login ate aceite legal */
.legal-gate {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 70vh;
}

.legal-gate-card {
  max-width: 640px;
  width: 100%;
}

.legal-docs {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  max-height: 240px;
  overflow: auto;
}

.legal-doc pre {
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
}

.pipeline-doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Modal de historico do cliente */
.history-modal {
  max-width: 520px;
}

.history-modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.history-summary .muted-tag {
  opacity: 0.85;
}

.history-section {
  margin-bottom: 16px;
}

.history-section h4 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.history-timeline {
  display: grid;
  gap: 8px;
}

.history-item {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.history-item-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.history-item-head strong {
  font-size: 13px;
}

.history-item-preview {
  font-size: 12px;
  margin: 6px 0 0;
}

.history-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.history-empty {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  text-align: center;
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header,
  .conversation-top,
  .order-top,
  .form-row {
    align-items: flex-start;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .order-amount-col {
    text-align: left;
  }

  .report-grid--orders,
  .ops-grid--compact {
    grid-template-columns: 1fr;
  }

  .orders-filters .view-pill {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }

  .nav-primary {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 24px;
  }
}

/* ===================== Console de Clientes ===================== */
/* Area de plataforma. Reaproveita os tokens do design system; o que e proprio daqui
   sao a tabela da carteira, os chips de saude e a gaveta de detalhe. */

.console-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.console-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.console-kpi-value { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.console-kpi-label { font-size: 12px; color: var(--muted); text-transform: lowercase; }
.console-kpi-critical .console-kpi-value { color: var(--red); }
.console-kpi-attention .console-kpi-value { color: #b8860b; }

.console-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.console-search {
  flex: 1 1 260px;
  min-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.console-select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.console-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.console-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.console-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.console-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.console-table tbody tr:last-child td { border-bottom: none; }
.console-row { cursor: pointer; }
.console-row:hover { background: var(--surface-muted); }
.console-row-sub { display: block; font-size: 12px; margin-top: 2px; }

.severity { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.severity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.severity-atencao .severity-dot { background: #d59a0b; }
.severity-critico .severity-dot { background: var(--red); }

.console-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.health-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface-muted);
  color: var(--muted);
  white-space: nowrap;
}
.health-chip-whatsapp_desconectado,
.health-chip-assinatura_irregular { background: #fdeaea; color: var(--red); }
.health-chip-sem_atendimento,
.health-chip-sem_pedidos,
.health-chip-cota_no_limite,
.health-chip-onboarding_parado { background: #fdf4e3; color: #8a6400; }

.console-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 0; }
.console-count { text-align: center; padding: 12px 0; }

/* Gaveta de detalhe: sobrepoe a lista sem perder o contexto da carteira. */
.console-drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 22, 20, .45); z-index: 60; }
.console-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--bg);
  border-left: 1px solid var(--line);
  z-index: 61;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(15, 22, 20, .15);
}
.console-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.console-drawer-head h3 { margin: 0 0 2px; }
.console-drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 32px; }
.console-drawer-section { margin-bottom: 26px; }
.console-drawer-section h4 { margin: 0 0 10px; font-size: 14px; }
.console-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.console-hint { font-size: 12px; margin: -4px 0 10px; }

.console-form { display: flex; flex-direction: column; gap: 10px; }
.console-inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.console-inline-form select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

.console-unit { padding: 12px 0; border-bottom: 1px solid var(--line); }
.console-unit:last-child { border-bottom: none; }
.console-unit-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.console-unit-head > div:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.console-unit-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.console-unit-metrics { font-size: 12px; margin: 6px 0 8px; line-height: 1.5; }
.xs-button.danger { color: var(--red); border-color: #f0cfcf; }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }

@media (max-width: 720px) {
  .console-toolbar { flex-direction: column; align-items: stretch; }
  .console-drawer { width: 100%; }
}

/* Busca dentro do seletor de unidades. Necessaria porque o bootstrap passou a mandar
   apenas um recorte da carteira. */
.tenant-picker-search { padding: 8px 8px 6px; border-bottom: 1px solid var(--line); }
.tenant-picker-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}
.tenant-picker-empty { padding: 10px 12px; font-size: 12px; margin: 0; }
