/* Componentes reutilizáveis do Design System H3 (DESIGN.md §9). */

/* ---------- Painéis e cards ---------- */
.panel {
  width: 100%;
  max-width: 640px;
  padding: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-panel);
}
.panel--narrow { max-width: 420px; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  min-width: 0;
}
.card--form { max-width: 560px; }
.card__header > .btn { white-space: nowrap; flex-shrink: 0; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.card__title { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.card__subtitle { color: var(--text-muted); font-size: var(--text-sm); margin: 0; }

/* ---------- Cabeçalho de página ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.page-header__text p { margin: var(--space-1) 0 0; color: var(--text-secondary); }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.breadcrumb { margin-bottom: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--space-2); color: var(--border-strong); }
.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-primary); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--text-primary); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: inherit;
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--h3-brand); color: var(--text-on-brand); }
.btn--primary:hover { filter: brightness(1.1); color: var(--text-on-brand); }
.btn--secondary { background: var(--bg-surface-raised); color: var(--text-primary); border-color: var(--border-subtle); }
.btn--secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-subtle); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--danger { background: var(--status-error); color: var(--text-on-brand); }
.btn--danger:hover { filter: brightness(1.1); color: var(--text-on-brand); }
.btn--block { width: 100%; }
.btn--sm { min-height: 32px; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.actions form { margin: 0; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: var(--space-4); margin-top: var(--space-4); }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-weight: var(--weight-medium); color: var(--text-secondary); }
.field input, .field select, .field textarea, .composer textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px var(--space-3);
  background: var(--bg-app);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  font: inherit;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .composer textarea:focus-visible { border-color: var(--h3-brand); }
.field [aria-invalid="true"] { border-color: var(--status-error); }
.field__error { color: var(--status-error); font-size: var(--text-xs); }
.hint { margin: var(--space-1) 0 0; padding-left: 18px; color: var(--text-muted); font-size: var(--text-xs); }

/* ---------- Alertas (cor + texto: não dependem só da cor) ---------- */
.alert {
  display: flex;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  padding: var(--space-3) 14px;
  border: 1px solid var(--border-subtle);
  border-left-width: 4px;
  border-radius: var(--radius-control);
  background: var(--bg-surface-raised);
}
.alert p { margin: 0 0 var(--space-1); }
.alert ul { margin: 0; padding-left: 18px; }
.alert--page { margin: 0 0 var(--space-6); }
.alert--error { border-left-color: var(--status-error); }
.alert--error .icon { color: var(--status-error); }
.alert--success { border-left-color: var(--status-success); }
.alert--success .icon { color: var(--status-success); }
.alert--warning { border-left-color: var(--status-warning); }
.alert--warning .icon { color: var(--status-warning); }
.alert--info { border-left-color: var(--status-info); }
.alert--info .icon { color: var(--status-info); }

/* ---------- Badges de status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { color: var(--status-success); }
.badge--warning { color: var(--status-warning); }
.badge--error { color: var(--status-error); }
.badge--info { color: var(--h3-cyan); }
.badge--neutral { color: var(--text-muted); }
.badge--plain::before { display: none; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--grid-gap);
  margin-bottom: var(--grid-gap);
}
.kpi {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}
.kpi__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--radius-control);
  background: var(--bg-active);
  color: var(--h3-brand);
}
.kpi__label { margin: 0; color: var(--text-secondary); font-weight: var(--weight-medium); }
.kpi__value { margin: 2px 0; font-size: var(--text-kpi); font-weight: var(--weight-bold); line-height: 1.15; }
.kpi__meta { margin: 0; color: var(--text-muted); font-size: var(--text-xs); }

/* ---------- Estados vazio / carregando / erro ---------- */
.state {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-secondary);
}
.state__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-surface-raised);
  color: var(--text-muted);
}
.state__title { margin: 0; color: var(--text-primary); font-weight: var(--weight-semibold); }
.state__text { margin: 0; max-width: 46ch; font-size: var(--text-sm); }
.state--error .state__icon { color: var(--status-error); }

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--h3-brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2400ms; } }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--border-subtle); }
.table th { color: var(--text-muted); font-weight: var(--weight-semibold); background: var(--bg-surface-raised); white-space: nowrap; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Resumo (lista de definições) ---------- */
.summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px var(--space-4);
  margin: var(--space-4) 0;
  padding: var(--space-3) 14px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
}
.summary dt { color: var(--text-muted); }
.summary dd { margin: 0; font-weight: var(--weight-semibold); }

/* ---------- Lista de escolha (ex.: seleção de empresa) ---------- */
.choice-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.choice-list form { margin: 0; }
.choice {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: var(--space-3) 14px;
  text-align: left;
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  font: inherit;
  cursor: pointer;
}
.choice:hover { background: var(--bg-hover); }
.choice--current { border-color: var(--h3-brand); }
.choice__title { font-weight: var(--weight-semibold); }
.choice__meta { color: var(--text-muted); font-size: var(--text-xs); }

/* ---------- Menu suspenso ---------- */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: var(--z-popover);
  min-width: 220px;
  padding: var(--space-2);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-popover);
}
.dropdown__menu[hidden] { display: none; }
.dropdown__header { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-1); }
.dropdown__header strong { display: block; }
.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.dropdown__item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown__menu form { margin: 0; }

/* ---------- Barra de filtros ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.filter-bar .field { min-width: 180px; }
.filter-bar .field--grow { flex: 1; min-width: 240px; }
.filter-bar .actions { margin: 0; }

/* ---------- Paginação ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.pagination__summary { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }
.pagination__list { display: flex; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.pagination__link, .pagination__gap {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
}
.pagination__gap { border-color: transparent; }
a.pagination__link:hover { background: var(--bg-hover); color: var(--text-primary); }
.pagination__link.is-current { background: var(--h3-brand); border-color: var(--h3-brand); color: var(--text-on-brand); }
.pagination__link.is-disabled { opacity: .4; }

/* Select compacto (dentro de tabelas) */
.select--sm {
  min-height: 32px;
  padding: var(--space-1) var(--space-2);
  background: var(--bg-app);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  font: inherit;
  font-size: var(--text-sm);
}

/* Caixa de seleção com rótulo */
.check { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); cursor: pointer; }
.check input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--h3-brand); }
.field textarea { resize: vertical; min-height: 80px; }
.field :disabled { opacity: .7; cursor: not-allowed; }

/* ---------- Abas de navegação ---------- */
.tabs { margin-bottom: var(--space-6); border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.tabs__list { display: flex; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.tabs__link {
  display: inline-block;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
}
.tabs__link:hover { color: var(--text-primary); }
.tabs__link[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--h3-brand); }

/* ---------- Seções de detalhes (dl em grade) ---------- */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin: 0; }
.details dt { color: var(--text-muted); font-size: var(--text-xs); }
.details dd { margin: 2px 0 0; font-weight: var(--weight-semibold); }

/* Lista de alterações (auditoria) */
.change-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: var(--text-sm); }
.change-list__field { color: var(--text-muted); }
.change-list__before { color: var(--text-muted); text-decoration: line-through; }

.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0; }

/* ---------- Ações em tabelas ---------- */
.table-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.table-actions form { margin: 0; }
.table td.num, .table th.num { text-align: right; }
.table .cell-strong { color: var(--text-primary); font-weight: var(--weight-semibold); }
.table .cell-sub { display: block; color: var(--text-muted); font-size: var(--text-xs); }

/* ---------- Formulário em colunas ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.form-grid .field--full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field .optional { color: var(--text-muted); font-weight: var(--weight-regular); font-size: var(--text-xs); }
.field__help { color: var(--text-muted); font-size: var(--text-xs); }

/* ---------- Diálogo de confirmação ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover);
}
.dialog::backdrop { background: var(--bg-overlay); }
.dialog__body { padding: var(--space-6); }
.dialog__title { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.dialog__text { margin: 0; color: var(--text-secondary); }
.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

/* ---------- Senha temporária (exibida uma única vez) ---------- */
.secret {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-app);
  border: 1px dashed var(--h3-yellow);
  border-radius: var(--radius-control);
}
.secret code { font-size: var(--text-lg); letter-spacing: .04em; color: var(--text-primary); user-select: all; }

/* ---------- Galeria de ícones (referência do Design System) ---------- */
.icon-gallery {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-3);
}
.icon-gallery li {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-size: 11px;
}

/* ---------- Grid de conteúdo ---------- */
.grid { display: grid; gap: var(--grid-gap); }
.grid + .grid { margin-top: var(--grid-gap); }
.grid > .kpi-grid { margin-bottom: 0; }
.grid--2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid--2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Barra de progresso (checklist) ---------- */
.progress-bar { appearance: none; display: block; width: 100%; height: 8px; border: 0; border-radius: var(--radius-pill); background: var(--bg-surface-raised); overflow: hidden; }
.progress-bar::-webkit-progress-bar { background: var(--bg-surface-raised); border-radius: var(--radius-pill); }
.progress-bar::-webkit-progress-value { background: var(--status-success); border-radius: var(--radius-pill); }
.progress-bar::-moz-progress-bar { background: var(--status-success); border-radius: var(--radius-pill); }

/* ---------- Código para copiar (instalação) ---------- */
.code-snippet { width: 100%; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.5; resize: vertical; }

/* ---------- Mensagem de formulário em tabela (CRM) ---------- */
.table .cell-message { max-width: 420px; white-space: normal; overflow-wrap: anywhere; }

/* ---------- Kanban (CRM 5.3) ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(272px, 1fr); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-3); margin-top: var(--grid-gap); align-items: start; }
.kanban__column { display: grid; gap: var(--space-3); align-content: start; min-height: 160px; padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--bg-surface); }
.kanban__column--closed { opacity: .8; }
.kanban__column.is-drop-target { border-color: var(--h3-brand); background: var(--bg-hover); }
.kanban__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.kanban__title { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.kanban__empty { margin: 0; color: var(--text-muted); font-size: var(--text-xs); }
.kanban__more { font-size: var(--text-xs); }
.kanban-card { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-control); background: var(--bg-surface-raised); }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.is-dragging { opacity: .5; }
.kanban-card__title { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.kanban-card__title a { color: var(--text-primary); }
.kanban-card__meta { margin: 0; color: var(--text-muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
.kanban-card__badges { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.kanban-card__badges:empty { display: none; }
.kanban-card__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin: 0; font-size: var(--text-xs); }
.kanban-card__facts dt { color: var(--text-muted); }
.kanban-card__facts dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.kanban-card__move { display: flex; gap: var(--space-2); align-items: center; margin: 0; }
.kanban-card__move .select--sm { flex: 1; min-width: 0; }
.kanban-card__wide { grid-column: 1 / -1; }

/* ---------- Linha do tempo (CRM 5.4) ---------- */
.timeline { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: grid; gap: var(--space-4); }
.timeline__item { position: relative; padding-left: var(--space-5); border-left: 2px solid var(--border-subtle); }
.timeline__item::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--h3-brand); }
.timeline__meta { margin: 0 0 var(--space-1); color: var(--text-muted); font-size: var(--text-xs); }
.timeline__text { margin: 0; overflow-wrap: anywhere; }
.text-danger { color: var(--status-error); font-weight: var(--weight-semibold); }

/* ---------- Lista de caixas de seleção (equipes do CRM) ---------- */
.checkbox-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-2); }

/* ---------- Conversa de WhatsApp (6.1) ---------- */
.chat { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: grid; gap: var(--space-3); max-height: 70vh; overflow-y: auto; }
.chat__message { max-width: 78%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); background: var(--bg-surface-raised); border: 1px solid var(--border-subtle); }
.chat__message--out { justify-self: end; background: var(--bg-active); }
.chat__text { margin: 0; overflow-wrap: anywhere; }
.chat__media { margin: 0 0 var(--space-1); color: var(--text-secondary); font-size: var(--text-sm); }
.chat__hint { color: var(--text-muted); font-size: var(--text-xs); }
.chat__meta { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: var(--text-xs); }

/* ---------- Caixa de atendimento (WhatsApp 6.2) ---------- */
.inbox { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(240px, 300px); gap: var(--grid-gap); align-items: start; }
.inbox--empty { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); }
@media (max-width: 1200px) { .inbox { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); } .inbox__crm { grid-column: 2; } }
@media (max-width: 820px) { .inbox, .inbox--empty { grid-template-columns: minmax(0, 1fr); } .inbox__crm { grid-column: auto; } }
.filter-bar--compact { flex-direction: column; align-items: stretch; gap: var(--space-2); }
.filter-bar--compact .field { min-width: 0; }
.inbox__items { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-1); max-height: 65vh; overflow-y: auto; }
.inbox__item { display: grid; gap: 2px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-control); color: var(--text-secondary); text-decoration: none; border: 1px solid transparent; }
.inbox__item:hover { background: var(--bg-hover); }
.inbox__item.is-current { background: var(--bg-active); border-color: var(--h3-brand); }
.inbox__name { display: flex; justify-content: space-between; gap: var(--space-2); color: var(--text-primary); font-weight: var(--weight-semibold); }
.inbox__preview { font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox__meta { font-size: var(--text-xs); color: var(--text-muted); }
.chat__message--failed { border-color: var(--status-error); }
.chat__error { margin: var(--space-1) 0; color: var(--status-error); font-size: var(--text-xs); }
.composer { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.composer textarea { width: 100%; resize: vertical; }
.composer__actions { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.details--stack { grid-template-columns: minmax(0, 1fr); margin-bottom: var(--space-4); }

/* ---------- Atendentes e SLA (WhatsApp 6.3) ---------- */
.inbox__sla { margin-top: 2px; }
.inbox__conversation .card__header p { margin: var(--space-1) 0 0; }
.form--compact { gap: var(--space-3); margin: 0 0 var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.sla-form { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); }
.sla-form .field { max-width: 180px; }
.card__header .actions, .form--compact .actions, .sla-form .actions { margin-top: 0; gap: var(--space-2); }
.card__header .actions { flex-wrap: nowrap; flex: none; }
.inbox .card__header { flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); }

/* ---------- Auditoria de atendimento (WhatsApp 6.4) ---------- */
.inbox__audit { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.audit-criteria { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.audit-criterion { padding: var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-control); background: var(--bg-surface-raised); }
.audit-criterion legend { font-weight: var(--weight-semibold); color: var(--text-primary); }
.audit-scale { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0; }
.audit-scale__option { display: inline-flex; align-items: center; gap: 6px; padding: 6px var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); cursor: pointer; font-size: var(--text-sm); color: var(--text-secondary); }
.audit-scale__option:has(input:checked) { border-color: var(--h3-brand); background: var(--bg-active); color: var(--text-primary); }
.audit-total { margin: var(--space-3) 0; }
.audit-comment__title { margin-top: var(--space-5); }
.audit-comment { margin: var(--space-2) 0 0; overflow-wrap: anywhere; }
.cell-wrap { white-space: normal; overflow-wrap: anywhere; max-width: 480px; }
.criteria-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-3); }
.criteria-list__item { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.criteria-list__item.is-archived { opacity: .7; }
.criteria-form { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; flex: 1; }
.criteria-form .field { min-width: 160px; }
.criteria-form__description { flex: 1; min-width: 220px; }
.criteria-form .actions, .criteria-list__status { margin: 0; }
.audit-criterion fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.audit-scale__option input[type="radio"] { width: auto; min-height: 0; height: auto; padding: 0; margin: 0; accent-color: var(--h3-brand); }
.audit-scale__option span { white-space: nowrap; }
.criteria-form .field:first-of-type { min-width: 240px; }

/* ---------- Integrações → Google Ads (G2) ---------- */
.google-connection { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.google-connection > .actions { margin-top: var(--space-3); }
.google-connection__title { margin-top: var(--space-5); }
.google-tree--2 { padding-left: var(--space-6); }
.google-tree--3 { padding-left: calc(var(--space-6) * 2); }
.google-tree .badge { margin-top: 4px; }
.card__header .btn.is-active { background: var(--bg-active); color: var(--text-primary); }

/* ---------- Tabelas largas: rolagem lateral dentro do quadro (não empurra a página) ---------- */
.grid { grid-template-columns: minmax(0, 1fr); }
.table-wrap--scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table--compact th, .table--compact td { padding: var(--space-2) var(--space-3); vertical-align: top; }
.table--compact .btn--sm { padding: 4px 10px; }
.table--google { min-width: 760px; }
.table--runs { min-width: 720px; }
.table--google td:first-child { max-width: 300px; }
.table .cell-clamp, .cell-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 340px; white-space: normal; }
/* Coluna de ações sempre visível, mesmo com rolagem lateral. */
.table .col-actions { position: sticky; right: 0; background: var(--bg-surface); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .45); white-space: nowrap; }
.table thead .col-actions { background: var(--bg-surface-raised); }
.table tbody tr:hover .col-actions { background: var(--bg-hover); }
.table .col-actions .table-actions { flex-wrap: nowrap; }
.table--google .inline-form { flex-wrap: nowrap; }
.table--google .inline-form select { max-width: 200px; }
/* Contas da MCC: larguras por coluna e ações empilhadas para caber em notebooks (~1024 px). */
.table--google { min-width: 640px; table-layout: fixed; }
.table--google th:nth-child(1) { width: 30%; }
.table--google th:nth-child(2) { width: 27%; }
.table--google th:nth-child(3) { width: 27%; }
.table--google th:nth-child(4) { width: 132px; }
.table--google td { overflow-wrap: anywhere; }
.table--google td:first-child { max-width: none; }
.table--google .col-actions .table-actions { flex-direction: column; align-items: stretch; }
.table--google .col-actions .btn { width: 100%; justify-content: center; }
.table--google .inline-form { flex-wrap: wrap; gap: var(--space-2); }
.table--google .inline-form select { max-width: 100%; width: 100%; }
/* Detalhe da campanha (G4) */
.table--detail { min-width: 820px; }
.table--detail td:first-child { max-width: 320px; }
.retention-form { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.retention-form .inline-form { flex-wrap: nowrap; }
.table--detail td:not(:first-child):not(.cell-clamp) { white-space: nowrap; }

/* ---------- Painel do Google Ads e gráficos SVG (G6) ---------- */
.dashboard-filters { flex-wrap: wrap; }
.dashboard-filters .field { min-width: 140px; }
.dashboard-filters__custom { display: none; }
.dashboard-filters:has([data-period-select] option[value="personalizado"]:checked) .dashboard-filters__custom { display: grid; }
.dashboard-period { margin: 0; color: var(--text-secondary); font-size: var(--text-sm); }
.dashboard-note { margin: 0; color: var(--text-muted); font-size: var(--text-xs); }
.card__note { margin: var(--space-3) 0 0; color: var(--text-muted); font-size: var(--text-xs); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-3); }
.stat { padding: var(--space-3) var(--space-4); background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); min-width: 0; }
.stat__label { margin: 0; color: var(--text-secondary); font-size: var(--text-sm); }
.stat__value { margin: 4px 0; font-size: var(--text-xl); font-weight: var(--weight-semibold); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat__delta { margin: 0; font-size: var(--text-xs); display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.stat__delta--good { color: var(--status-success); }
.stat__delta--bad { color: var(--status-error); }
.stat__delta--neutral { color: var(--text-secondary); }
.stat__muted { color: var(--text-muted); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--grid-gap); }
.chart-card { display: grid; gap: var(--space-2); align-content: start; }
.chart-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart__grid { stroke: var(--border-subtle); stroke-width: 1; }
.chart__axis { fill: var(--text-muted); font-size: 11px; }
.chart__axis--strong { fill: var(--text-secondary); font-size: 12px; }
.chart__value { fill: var(--text-primary); font-size: 12px; }
.chart__label { fill: var(--text-primary); font-size: 11px; font-weight: 600; }
.chart__label--muted { fill: var(--text-muted); font-weight: 400; }
.chart__line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--current { stroke: var(--h3-brand); }
.chart__line--previous { stroke: var(--text-muted); }
.chart__dot--current { fill: var(--h3-brand); stroke: var(--bg-surface); stroke-width: 2; }
.chart__bar { fill: var(--h3-brand); }
.chart__hit { fill: transparent; }
.chart__hit:hover { fill: rgba(255, 255, 255, .04); }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-3); font-size: var(--text-xs); color: var(--text-secondary); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend__key { width: 14px; height: 2px; border-radius: 1px; }
.chart-legend__key--current { background: var(--h3-brand); }
.chart-legend__key--previous { background: var(--text-muted); }
.chart-table summary { cursor: pointer; color: var(--text-secondary); font-size: var(--text-xs); }
