/* Análise Geral do Grupo (Dashbi) -- estilos do módulo. */
.dbPage { max-width: 1360px; }

.dbHeader { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.dbHeader h1 { font-family: var(--font-ui); font-weight: 300; font-size: clamp(1.375rem, calc(2.6vw * var(--fs-scale)), 1.875rem); letter-spacing: -.01em; margin: 0; }
.dbHeader p { color: var(--color-text-secondary); margin: var(--space-1) 0 0; font-size: 0.8125rem; }

.dbFixtureBar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2) var(--space-3); margin-bottom: var(--space-4); border: 1px dashed var(--color-hairline-strong); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.6562rem; color: var(--color-text-muted); }
.dbFixtureBar .dbFixtureLabel { text-transform: uppercase; letter-spacing: .06em; color: var(--color-warning); }
.dbFixtureBar select { background: var(--color-surface-2); border: 1px solid var(--color-hairline-strong); color: var(--color-text-primary); font-family: var(--font-mono); font-size: 0.6875rem; padding: 3px var(--space-2); border-radius: var(--radius-sm); }
.dbFixtureBar select:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.dbFilters { display: flex; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--color-hairline); }
.dbField { display: flex; flex-direction: column; gap: var(--space-1); min-width: 160px; }
.dbField label { color: var(--color-text-muted); font-size: 0.6562rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.dbField select, .dbField input[type="date"] { background: var(--color-surface-2); border: 1px solid var(--color-hairline-strong); color: var(--color-text-primary); font-family: var(--font-ui); font-size: 0.8125rem; padding: var(--space-2); border-radius: var(--radius-sm); }
.dbField select:focus-visible, .dbField input:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.dbPresetGroup, .dbViewGroup { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.dbBtn { background: none; border: 1px solid var(--color-hairline-strong); color: var(--color-text-secondary); font-family: var(--font-ui); font-size: 0.7812rem; font-weight: 500; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); cursor: pointer; }
.dbBtn:hover:not(.dbBtnActive) { color: var(--color-text-primary); }
.dbBtn:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.dbBtnActive { color: var(--color-canvas); background: var(--color-text-primary); border-color: var(--color-text-primary); }

.dbFechamentoBar { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }

.dbSubnav:empty { display: none; }
.dbSubnav { margin-bottom: var(--space-4); }
.dbModeGroup { display: flex; gap: var(--space-1); flex-wrap: wrap; padding-bottom: var(--space-2); margin: 0; border-top: none; border-bottom: 1px solid var(--color-hairline); }
.dbModeBtn { position: relative; }
.dbModeBtn.dbBtnActive::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -7px; height: 2px; background: var(--color-accent-primary); }
.dbModeHint { padding: var(--space-4) 0; }
.dbFechamentoBar .dbMuted { margin: 0; }
.dbFechamento { display: inline-block; font-family: var(--font-mono); font-size: 0.6562rem; text-transform: uppercase; letter-spacing: .07em; color: var(--color-success); border: 1px solid var(--color-success); border-radius: var(--radius-sm); padding: 2px 7px; flex-shrink: 0; }

.dbBlockedNotice { border: 1px solid var(--color-critical); border-radius: var(--radius-md); padding: var(--space-4); color: var(--color-critical); font-size: 0.8125rem; margin-bottom: var(--space-4); }
.dbBlockedNotice b { color: var(--color-text-primary); }

.dbPage h2 { font-family: var(--font-ui); font-weight: 400; font-size: 1.0625rem; margin: var(--space-6) 0 var(--space-3); }
.dbPage h2:first-of-type { margin-top: 0; }
.dbMuted { color: var(--color-text-muted); font-size: 0.75rem; margin: 0 0 var(--space-3); }
.dbExportBar { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-3); flex-wrap: wrap; }
.dbExportStatus { margin: 0; }
.dbExportResumoBtn:disabled { opacity: .55; cursor: default; }
.dbDiagJson { font-family: var(--font-mono); overflow-wrap: anywhere; }

.dbKpiGridPrimary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.dbKpiCardPrimary { border: 1px solid var(--color-hairline); border-radius: var(--radius-md); padding: var(--space-4); }
.dbKpiCardPrimary .dbK { color: var(--color-text-muted); font-size: 0.6562rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.dbKpiCardPrimary .dbV { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 500; margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.dbKpiCardPrimary .dbHint { color: var(--color-text-muted); font-size: 0.6875rem; margin-top: 2px; }

.dbKpiCardShare { border-left-width: 3px; }
.dbKpiCardShare.dbShareOk { border-left-color: var(--color-success); }
.dbKpiCardShare.dbShareOk .dbV { color: var(--color-success); }
.dbKpiCardShare.dbShareBaixa { border-left-color: var(--color-critical); }
.dbKpiCardShare.dbShareBaixa .dbV { color: var(--color-critical); }

.dbKpiCardReceitaTotal { border-top-width: 3px; border-top-color: var(--color-info); }
.dbKpiCardReceitaTotal .dbV { color: var(--color-info); font-weight: 700; }

.dbKpiDetailToggleWrap { margin: 0 0 var(--space-4); }
.dbKpiDetailPanel { border: 1px solid var(--color-hairline); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); background: var(--color-surface-2); margin: 0 0 var(--space-4); }

.dbPrevValue { display: inline-flex; align-items: baseline; gap: 4px; margin-left: 5px; font-family: var(--font-mono); font-size: 0.6875rem; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.dbPrevValueShort { font-size: 0.625rem; }
.dbPrevValueNA { font-weight: 600; }
.dbPrevArrow { font-weight: 700; }
.dbPrevArrowUp { color: var(--color-success); }
.dbPrevArrowDown { color: var(--color-critical); }
.dbPrevArrowFlat { color: var(--color-text-muted); }
.dbKpiCompare { margin-top: var(--space-1); display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.srOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* grid-column:1 on BOTH current and previous (not 1/-1 spanning both
   columns) is what makes them share the same right edge: column 1 is
   sized to max-content across everything placed in it, so it auto-widens
   to fit whichever of the two numbers is wider, and both then right-align
   (justify-self:end) to that SAME column's right edge. Column 2 exists
   only for the arrow -- it stays empty on the current row by construction
   (nothing is ever placed in it there), never affecting column 1's edge. */
.dbNumCompare { display: inline-grid; grid-template-columns: max-content max-content; column-gap: 4px; justify-content: end; }
.dbNumCurrent { grid-column: 1; justify-self: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dbPrevNum { grid-column: 1; justify-self: end; font-family: var(--font-mono); font-size: 0.6875rem; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--color-text-muted); }
.dbNumCompare .dbPrevValueNA { grid-column: 1; justify-self: end; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--color-text-muted); font-weight: 600; }
.dbNumCompare .dbPrevArrow { grid-column: 2; justify-self: start; }
.dbTable .dbNumCol .dbNumCompare, .dbMobileValue .dbNumCompare { display: inline-grid; }
.dbFamilyMetricBox .dbV .dbPrevValue { display: flex; margin-top: 2px; margin-left: 0; font-size: 0.625rem; }

.dbPlanGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.dbPlanCard { border: 1px solid var(--color-hairline); border-radius: var(--radius-sm); padding: var(--space-3); border-left: 3px solid var(--color-hairline-strong); }
.dbPlanCard .dbK { font-size: 0.6875rem; font-weight: 600; letter-spacing: .03em; }
.dbPlanCard .dbV { font-family: var(--font-mono); font-size: 1.125rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.dbPlanCard.planSubsidiado { border-left-color: var(--color-success); }
.dbPlanCard.planReversao { border-left-color: var(--color-warning); }
.dbPlanCard.planCoparticipado { border-left-color: var(--color-accent-primary); }
.dbPlanCard.planBalao { border-left-color: var(--color-info); }
.dbPlanCard.planLinear { border-left-color: var(--color-text-muted); }

.dbTableWrap { position: relative; overflow-x: auto; border: 1px solid var(--color-hairline); border-radius: var(--radius-md); margin-bottom: var(--space-4); }
/* position:relative contém os textos de leitor de tela (.srOnly, position:absolute) dentro da rolagem da
   tabela; sem isso eles escapavam e criavam rolagem horizontal na página quando a tabela rolava. */
.dbTable { width: 100%; border-collapse: collapse; font-size: 0.7812rem; }
.dbTable thead th { text-align: left; font-family: var(--font-mono); font-size: 0.625rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); font-weight: 500; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-hairline-strong); white-space: nowrap; }
.dbTable td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-hairline); white-space: nowrap; }
.dbTable tbody tr:last-child td { border-bottom: none; }
.dbTable tbody tr:hover td { background: rgba(255,255,255,.028); }
.dbTable .dbNumCol { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.dbTable thead th:first-child, .dbTable td:first-child { position: sticky; left: 0; background: var(--color-surface-1); }
.dbTable thead th:first-child { background: var(--color-surface-2); z-index: 1; }

.dbTableExpandable thead th:first-child, .dbTableExpandable tbody td:first-child { position: static; }
/* Root cause: with the table's default "auto" layout, a browser sizes the
   whole <table> from the WIDEST cell's min-content across every row —
   including the colspan'd detail <td>. .dbDetailPanel's grid/flex content
   reported a min-content width that grew the table past its .dbTableWrap
   container; the wrap's own overflow-x:auto then silently absorbed that
   into a hidden component-level scrollbar — a document-level scrollWidth
   check doesn't catch this, exactly what the no-scroll directive forbids.
   table-layout:fixed is the fix that actually held up under testing —
   column widths are set once from the primary row and never re-grown by a
   later (detail) row, regardless of that row's own content. */
.dbTableExpandable { table-layout: fixed; width: 100%; }
.dbTableExpandable thead th,
.dbTableExpandable > tbody > tr:not(.dbDetailRow) > td { white-space: normal; overflow-wrap: break-word; word-break: break-word; }
.dbTableWrapText { table-layout: fixed; width: 100%; }
.dbTableWrapText td { white-space: normal; overflow-wrap: break-word; }
/* No explicit width + white-space:normal (not nowrap) on both the cell and
   the button: under table-layout:fixed, a narrow fixed-layout column still
   lets its content overflow the cell's box visually if that content can't
   wrap — that ink overflow bled into .dbTableWrap's scrollWidth the same
   way the original bug did, just smaller (confirmed empirically: fixing
   the detail-panel blowout alone left a ~28px residual from exactly this).
   Letting the button's own text wrap removes that last source. */
/* Giving the toggle column a guaranteed FIXED pixel width (not a share of
   the auto-divided remainder) is what finally made this exact: any %-based
   or even-share width is one sub-pixel rounding step away from being
   slightly too small for "+ Detalhes"/"− Detalhes" at some viewport, which
   then bleeds a few px of ink overflow into .dbTableWrap's scrollWidth —
   confirmed repeatedly across several narrower attempts. A fixed px width
   sidesteps that arithmetic entirely, at the cost of every table reserving
   the same column width for its toggle regardless of its own column count. */
.dbTableExpandable thead th:last-child { width: 5.375rem; }
/* Identity column (Modelo/Loja/Vendedor/Família/#+Nome) gets a floor share
   too, otherwise it wraps character-by-character on narrow viewports once
   the remaining numeric+toggle columns claim their own width — long store/seller
   names need more than an even 1/N
   split. This is a floor (min-width via width on a fixed-layout column),
   not the earlier attempt's rigid 30% that itself caused a different
   overflow when combined with the (since-fixed) toggle/header bugs. */
.dbTableExpandable thead th:first-child { width: 34%; }
/* Telas largas: a coluna de identificação precisa de menos que 34% (nomes cabem com folga) e as colunas
   numéricas ganham a largura de que o título "FINANCIAMENTOS" precisa para ficar em uma linha.
   Abaixo de 1100 px o hífen suave do título continua valendo como antes. */
@media (min-width: 1100px) { .dbTableExpandable thead th:first-child { width: 26%; } }

.dbTable.dbTableExpandable td.dbNumCol {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

/* Qualified with .dbTableExpandable thead th (not standalone classes):
   .dbTableExpandable thead th:first-child{width:34%} above has specificity
   (0,2,2) (.dbTableExpandable + :first-child, 2 elements) -- a standalone
   ".dbColRank{width:40px}" is only (0,1,0) and silently lost to it (found
   empirically: "#" was still rendering at 34%/446px, starving "Nome" down
   to 194px, which then wrapped to multiple lines and inflated the whole
   row's height). Repeating the same ancestor context here matches that
   specificity exactly; being declared AFTER the :first-child rule wins the
   tie via normal cascade order, same safeguard reasoning as the numeric-
   atomicity rule above. */
.dbTableExpandable thead th.dbColRank { width: 2.5rem; }
.dbTableExpandable thead th.dbColName { width: 10.625rem; }
/* em rem: as larguras acompanham a escala do texto (e o nível Grande). A coluna de contagem
   ficou mais larga para o título "FINANCIAMENTOS" caber em uma linha nas telas largas. */
.dbTableExpandable thead th.dbColCount { width: 6.5rem; }
.dbTableExpandable thead th.dbColPercent { width: 5.125rem; }
.dbTableExpandable thead th.dbColMoney { width: 7.875rem; }
/* Loja (storeTableHtml): name+2count+1pct+2money+toggle. */
.dbTableLoja { min-width: 49.875rem; }
/* Ranking: rank+name+2count+1pct+2money+toggle -- one column wider than
   Loja (the rank column), which is also why the shared thead th:first-
   child{width:34%} above was wrong here (it targeted "#", not "Nome"). */
.dbTableRanking { min-width: 52.375rem; }
/* Modelos primary row: name+2count+2pct+3money+toggle. */
.dbTableModelos { min-width: 62.875rem; }

.dbDetailToggleCell { white-space: normal; }
.dbDetailToggle { box-sizing: border-box; max-width: 100%; background: none; border: 1px solid var(--color-hairline-strong); color: var(--color-text-secondary); font-family: var(--font-mono); font-size: 0.6562rem; padding: 3px 4px; border-radius: var(--radius-sm); cursor: pointer; white-space: normal; }
.dbDetailToggle:hover { color: var(--color-text-primary); border-color: var(--color-text-secondary); }
.dbDetailToggle:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.dbDetailToggle[aria-expanded="true"] { color: var(--color-canvas); background: var(--color-text-primary); border-color: var(--color-text-primary); font-weight: 700; }
.dbTable tr.dbDetailRow td { background: var(--color-surface-2); padding: var(--space-3); border-bottom: 1px solid var(--color-hairline); white-space: normal; }
.dbDetailPanel { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 160px)); gap: var(--space-4); }
.dbDetailGroupLabel { color: var(--color-text-muted); font-size: 0.5938rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: var(--space-2); padding-bottom: 3px; border-bottom: 1px solid var(--color-hairline); }
.dbDetailGroupItems { display: flex; flex-direction: column; gap: 5px; }
.dbDetailItem { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 0.7812rem; }
.dbDetailK { color: var(--color-text-muted); }
.dbDetailV { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

@media (max-width: 767px) {
  .dbDesktopCol { display: none; }
}

.dbDesktopOnly { display: block; }
.dbMobileOnly { display: none; }

@media (max-width: 767px) {
  .dbDesktopOnly { display: none; }
  .dbMobileOnly { display: block; }
}

.dbMobileCard {
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.dbMobileCard:last-child { margin-bottom: 0; }
.dbMobileCardTotal { border-color: var(--color-hairline-strong); font-weight: 600; }
.dbMobileIdentity { font-size: 0.9375rem; font-weight: 600; color: var(--color-text-primary); overflow-wrap: break-word; }
.dbMobileSub { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 1px; }
.dbMobileFieldGrid { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-3); }
.dbMobileField { flex-basis: 100%; }
.dbMobileFieldPair { flex-basis: calc(50% - var(--space-2)); }
.dbMobileFieldEmph { padding: var(--space-2); border: 1px solid var(--color-hairline-strong); border-radius: var(--radius-sm); }
.dbMobileLabel { font-family: var(--font-mono); font-size: 0.5625rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); margin-bottom: 2px; }
.dbMobileValue { font-family: var(--font-mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.dbMobileCard > .dbDetailToggle { display: block; width: 100%; margin-top: var(--space-3); }
.dbMobileCard > .dbDetailPanel { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--color-hairline); }

.dbFamilyMetricGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); margin: var(--space-3) 0 var(--space-4); }
.dbFamilyMetricBox { border: 1px solid var(--color-hairline); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }
.dbFamilyMetricBox .dbK { color: var(--color-text-muted); font-size: 0.5938rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.dbFamilyMetricBox .dbV { font-family: var(--font-mono); font-size: 0.9375rem; margin-top: 2px; font-variant-numeric: tabular-nums; }

.dbModelSection { border: 1px solid var(--color-hairline-strong); border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-5); }
.dbEntradaGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2); margin: var(--space-3) 0; }
.dbEntradaCard { border: 1px solid var(--color-hairline); border-radius: var(--radius-sm); padding: var(--space-3); border-left: 2px solid var(--color-accent-primary); }
.dbEntradaCard .dbK { color: var(--color-text-muted); font-size: 0.625rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.dbEntradaCard .dbV { font-family: var(--font-mono); font-size: 1.0625rem; margin-top: 2px; font-variant-numeric: tabular-nums; }

.dbPenetracaoBaixa { color: var(--color-critical); }
.dbPenetracaoOk { color: var(--color-success); }

/* Model selector (Análise por Modelos, Novos only) — compact text-only
   picker built from the models present in the data. No shadow, no glow,
   no gradient. Selected state is signaled by border weight + a check
   glyph + bold text, never color alone. */
.dbVehicleSelector { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-3) 0 var(--space-4); }
.dbVehicleCard { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); width: 132px; background: none; border: 1px solid var(--color-hairline); border-radius: var(--radius-sm); padding: var(--space-2); cursor: pointer; font-family: var(--font-ui); }
.dbVehicleCard:hover:not(.dbVehicleCardActive) { border-color: var(--color-hairline-strong); }
.dbVehicleCard:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
.dbVehicleCardActive { border-color: var(--color-accent-primary); border-width: 2px; padding: calc(var(--space-2) - 1px); }
.dbVehicleName { font-size: 0.7188rem; font-weight: 500; letter-spacing: .02em; text-align: center; color: var(--color-text-secondary); }
.dbVehicleCardActive .dbVehicleName { color: var(--color-text-primary); font-weight: 700; }
.dbVehicleCheck { color: var(--color-accent-primary); }

.dbSubHeading { font-family: var(--font-ui); font-weight: 500; font-size: 0.8125rem; margin: var(--space-4) 0 var(--space-2); color: var(--color-text-secondary); }
.dbRankingSection h3:first-of-type, .dbNovosLojaSection h3:first-of-type { margin-top: var(--space-2); }
.dbTableSub { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 1px; }
.dbTable tbody tr.dbTotalRow td { font-weight: 700; border-top: 1px solid var(--color-hairline-strong); }

@media (max-width: 480px) {
  .dbVehicleCard { width: calc(50% - var(--space-2) / 2); }
}

@media (max-width: 768px) {
  .dbField { min-width: 130px; }
  .dbKpiGridPrimary { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .dbKpiGridPrimary, .dbPlanGrid, .dbEntradaGrid, .dbFamilyMetricGrid { grid-template-columns: 1fr; }
}
