
/* V178 — Auto-fit money/large numeric values without hiding digits.
   Visual only; no calculation/data changes. */

/* Generic numeric containers commonly used across the app. */
.v178-money-fit,
.stat-figure,
.tabular,
.tabular-nums {
  min-width: 0;
  max-width: 100%;
}

/* Prevent clipping of long amounts. */
.v178-money-fit,
.stat-figure {
  overflow: visible;
  white-space: nowrap;
  text-overflow: clip;
}

/* Allow large monetary figures to scale responsively with container width.
   clamp() keeps normal values visually unchanged but prevents oversized text on narrow cards. */
.v178-money-fit,
.stat-figure {
  font-size: clamp(0.78rem, 4.2cqw, 1.5rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
}

/* Cards become size containers so cqw scales to the actual card, not viewport. */
.ledger-cell,
[data-slot="card"] {
  container-type: inline-size;
}

/* Shared numeric spans in compact cards/tables:
   keep all digits visible, wrapping only as a last resort. */
.tabular,
.tabular-nums {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: clip;
}

/* For direct money strings ending with currency inside narrow cells,
   allow emergency wrapping rather than clipping digits. */
td .tabular,
td .tabular-nums,
.responsive-report-table .tabular,
.responsive-report-table .tabular-nums {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Dashboard/KPI/finance top figures should shrink smoothly in small cards. */
.grid .stat-figure,
.ledger-cell .stat-figure {
  max-width: 100%;
  font-size: clamp(0.76rem, 4cqw, 1.5rem);
}

/* Mobile: prioritize complete digits over large typography. */
@media (max-width: 639px) {
  .v178-money-fit,
  .stat-figure {
    font-size: clamp(0.72rem, 7.8vw, 1.25rem);
    line-height: 1.1;
  }

  .ledger-cell .tabular,
  .ledger-cell .tabular-nums,
  .responsive-report-table .tabular,
  .responsive-report-table .tabular-nums {
    max-width: 100%;
    font-size: clamp(0.68rem, 3.4vw, 0.88rem);
    line-height: 1.25;
  }

  /* Monetary values inside 2-column KPI/stat cards may be very long. */
  .grid.grid-cols-2 .stat-figure,
  .grid.grid-cols-2 .tabular,
  .grid.grid-cols-2 .tabular-nums {
    font-size: clamp(0.66rem, 4.8vw, 1rem);
  }
}

/* Very narrow phones: keep every digit, even for tens/hundreds of billions. */
@media (max-width: 380px) {
  .v178-money-fit,
  .stat-figure {
    font-size: clamp(0.66rem, 6.8vw, 1rem);
  }

  .tabular,
  .tabular-nums {
    font-size: clamp(0.64rem, 3.1vw, 0.82rem);
  }
}

/* Fallback for browsers without container query units. */
@supports not (font-size: 1cqw) {
  .v178-money-fit,
  .stat-figure {
    font-size: clamp(0.78rem, 2.2vw, 1.5rem);
  }
}
