:root {
  --analytics-chart-heat-0: color-mix(in srgb,var(--analytics-theme-accent) 8%,transparent); --analytics-chart-heat-1: color-mix(in srgb,var(--analytics-theme-accent) 20%,transparent);
  --analytics-chart-heat-2: color-mix(in srgb,var(--analytics-theme-accent) 32%,transparent); --analytics-chart-heat-3: color-mix(in srgb,var(--analytics-theme-accent) 44%,transparent);
  --analytics-chart-heat-4: color-mix(in srgb,var(--analytics-theme-accent) 56%,transparent); --analytics-chart-heat-5: color-mix(in srgb,var(--analytics-theme-accent) 68%,transparent);
  --analytics-chart-heat-6: color-mix(in srgb,var(--analytics-theme-accent) 80%,transparent); --analytics-chart-heat-7: color-mix(in srgb,var(--analytics-theme-accent) 92%,transparent);
}

:is(
  body[data-view="atendimento"] .channel-legend,
  body[data-view="leads"] .funnel-body,
  body[data-view="leads"] .table-wrap,
  body[data-view="carteira"] .summary-table .table-wrap,
  body[data-view="carteira"] .sku-wrap,
  body[data-view="nine-box"] .components
) {
  scrollbar-color: var(--analytics-theme-scroll-thumb, #2b6472) var(--analytics-theme-scroll-track, #07151e);
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

:is(
  body[data-view="atendimento"] .channel-legend,
  body[data-view="leads"] .funnel-body,
  body[data-view="leads"] .table-wrap,
  body[data-view="carteira"] .summary-table .table-wrap,
  body[data-view="carteira"] .sku-wrap,
  body[data-view="nine-box"] .components
)::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

:is(
  body[data-view="atendimento"] .channel-legend,
  body[data-view="leads"] .funnel-body,
  body[data-view="leads"] .table-wrap,
  body[data-view="carteira"] .summary-table .table-wrap,
  body[data-view="carteira"] .sku-wrap,
  body[data-view="nine-box"] .components
)::-webkit-scrollbar-track {
  background: var(--analytics-theme-scroll-track, #07151e);
  border-radius: 999px;
}

:is(
  body[data-view="atendimento"] .channel-legend,
  body[data-view="leads"] .funnel-body,
  body[data-view="leads"] .table-wrap,
  body[data-view="carteira"] .summary-table .table-wrap,
  body[data-view="carteira"] .sku-wrap,
  body[data-view="nine-box"] .components
)::-webkit-scrollbar-thumb {
  background: var(--analytics-theme-scroll-thumb, #2b6472);
  border: 1px solid var(--analytics-theme-scroll-track, #07151e);
  border-radius: 999px;
}

body[data-view="visao-geral"] :is(.quick-item, .quick-item > *, .alert-row p, .team-row .name) {
  min-width: 0;
}

body[data-view="atendimento"] .channels-body,
body[data-view="atendimento"] .channel-legend,
body[data-view="atendimento"] .ch-row,
body[data-view="atendimento"] .ch-name {
  min-width: 0;
}

body[data-view="atendimento"] .channel-legend {
  max-height: 56px;
  overflow-x: hidden;
  overflow-y: auto;
}

body[data-view="atendimento"] .ch-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Leads: o funil completo rola dentro do card, sem cortar as ultimas etapas. */
body[data-view="leads"] .funnel-body {
  overflow-x: hidden;
  overflow-y: auto;
}

body[data-view="leads"] .table-wrap {
  overflow: auto;
  padding-bottom: 0;
}

body[data-view="leads"] .table-wrap thead th,
body[data-view="carteira"] :is(.summary-table .table-wrap, .sku-wrap) thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--analytics-theme-surface-2, #081821);
}

/* Carteira: nomes/produtos longos truncam, e tabelas extensas rolam internamente. */
body[data-view="carteira"] :is(.summary-table .table-wrap, .sku-wrap) {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

body[data-view="carteira"] :is(.bar-name, .person, .sku-table td) {
  min-width: 0;
}

body[data-view="carteira"] .bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Equipe: o maior valor monetario cabe no KPI, sem rolagem ou escape lateral. */
body[data-view="equipe"] .kpi-value[data-final^="R$"] {
  min-width: 0;
  overflow: hidden;
  font-size: 15.9px;
  letter-spacing: -.72px;
  text-overflow: ellipsis;
}

body[data-view="equipe"] :is(.seller-cell, .seller-name, .bar-row .name, .sku-table td) {
  min-width: 0;
}

/* Nine Box: 12 componentes permanecem no card e passam a ter rolagem interna. */
body[data-view="nine-box"] .components {
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

body[data-view="nine-box"] :is(.comp, .metric, .metric > *) {
  min-width: 0;
}

@media (forced-colors: active) {
  :root, html[data-analytics-theme] {
    --analytics-theme-bg: Canvas; --analytics-theme-surface-0: Canvas; --analytics-theme-surface-1: Canvas; --analytics-theme-surface-2: Canvas; --analytics-theme-surface-3: Canvas;
    --analytics-theme-elevated: Canvas; --analytics-theme-elevated-hover: Canvas; --analytics-theme-active: Canvas;
    --analytics-theme-border: CanvasText; --analytics-theme-border-strong: Highlight;
    --analytics-theme-text: CanvasText; --analytics-theme-text-secondary: CanvasText; --analytics-theme-muted: CanvasText; --analytics-theme-icon: CanvasText;
    --analytics-theme-accent: LinkText; --analytics-theme-accent-strong: LinkText; --analytics-theme-focus: Highlight;
    --analytics-theme-overlay: transparent; --analytics-theme-shadow: none; --analytics-theme-scroll-track: Canvas; --analytics-theme-scroll-thumb: CanvasText;
    --analytics-modal-surface-0: Canvas; --analytics-modal-surface-1: Canvas; --analytics-modal-surface-2: Canvas; --analytics-modal-surface-3: Canvas; --analytics-modal-text: CanvasText; --analytics-modal-muted: CanvasText; --analytics-modal-soft: CanvasText;
  }
  .analytics-shell-sidebar .nav-item.active { outline: 1px solid Highlight !important; outline-offset: -2px !important; }
  .analytics-shell-sidebar :is(.analytics-theme-select,.side-collapse,.filter-btn,.nav-item):focus-visible { outline-color: Highlight !important; }
}
