
/* V177 — Mobile layout for Finance, Debts and KPI. Desktop unchanged. */
@media (max-width: 639px) {
  .v177-finance-mobile,
  .v177-debts-mobile,
  .v177-kpi-mobile {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .v177-finance-mobile .ledger-cell,
  .v177-debts-mobile .ledger-cell,
  .v177-kpi-mobile .ledger-cell {
    max-width: 100%;
    overflow: hidden;
    border-radius: 9px;
  }

  .v177-finance-mobile .ledger-cell.p-4,
  .v177-finance-mobile .ledger-cell.lg\:p-5,
  .v177-debts-mobile .ledger-cell.p-4,
  .v177-debts-mobile .ledger-cell.lg\:p-5,
  .v177-kpi-mobile .ledger-cell.p-4,
  .v177-kpi-mobile .ledger-cell.lg\:p-5 {
    padding: 13px !important;
  }

  /* Shared report tables become cards. */
  .v177-finance-mobile .responsive-report-table,
  .v177-debts-mobile .responsive-report-table,
  .v177-kpi-mobile .responsive-report-table {
    overflow: visible !important;
    width: 100%;
    max-width: 100%;
  }

  .v177-finance-mobile .responsive-report-table table,
  .v177-finance-mobile .responsive-report-table tbody,
  .v177-finance-mobile .responsive-report-table tr,
  .v177-finance-mobile .responsive-report-table td,
  .v177-debts-mobile .responsive-report-table table,
  .v177-debts-mobile .responsive-report-table tbody,
  .v177-debts-mobile .responsive-report-table tr,
  .v177-debts-mobile .responsive-report-table td,
  .v177-kpi-mobile .responsive-report-table table,
  .v177-kpi-mobile .responsive-report-table tbody,
  .v177-kpi-mobile .responsive-report-table tr,
  .v177-kpi-mobile .responsive-report-table td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .v177-finance-mobile .responsive-report-table table,
  .v177-debts-mobile .responsive-report-table table,
  .v177-kpi-mobile .responsive-report-table table {
    min-width: 0 !important;
  }

  .v177-finance-mobile .responsive-report-table thead,
  .v177-debts-mobile .responsive-report-table thead,
  .v177-kpi-mobile .responsive-report-table thead {
    display: none !important;
  }

  .v177-finance-mobile .responsive-report-table tbody,
  .v177-debts-mobile .responsive-report-table tbody,
  .v177-kpi-mobile .responsive-report-table tbody {
    display: grid !important;
    gap: 10px;
  }

  .v177-finance-mobile .responsive-report-table tr,
  .v177-debts-mobile .responsive-report-table tr,
  .v177-kpi-mobile .responsive-report-table tr {
    border: 1px solid var(--border) !important;
    border-radius: 9px;
    background: var(--background);
    padding: 4px 11px;
    overflow: hidden;
  }

  .v177-finance-mobile .responsive-report-table td,
  .v177-debts-mobile .responsive-report-table td,
  .v177-kpi-mobile .responsive-report-table td {
    display: grid !important;
    grid-template-columns: minmax(98px, 42%) minmax(0, 1fr) !important;
    gap: 10px;
    align-items: start;
    padding: 8px 0 !important;
    border-bottom: 1px dashed color-mix(in srgb, currentColor 10%, transparent);
    white-space: normal !important;
    text-align: right !important;
    overflow-wrap: anywhere;
    font-size: 11.5px;
    line-height: 1.4;
  }

  .v177-finance-mobile .responsive-report-table td:last-child,
  .v177-debts-mobile .responsive-report-table td:last-child,
  .v177-kpi-mobile .responsive-report-table td:last-child {
    border-bottom: 0;
  }

  .v177-finance-mobile .responsive-report-table td::before,
  .v177-debts-mobile .responsive-report-table td::before,
  .v177-kpi-mobile .responsive-report-table td::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: .025em;
    text-align: left;
    text-transform: uppercase;
  }

  .v177-finance-mobile .responsive-report-table td > *,
  .v177-debts-mobile .responsive-report-table td > *,
  .v177-kpi-mobile .responsive-report-table td > * {
    min-width: 0;
    max-width: 100%;
    justify-self: end;
    text-align: right;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  .v177-finance-mobile .responsive-report-table td:first-child,
  .v177-debts-mobile .responsive-report-table td:first-child,
  .v177-kpi-mobile .responsive-report-table td:first-child {
    grid-template-columns: 1fr !important;
    text-align: left !important;
    padding-top: 10px !important;
  }

  .v177-finance-mobile .responsive-report-table td:first-child > *,
  .v177-debts-mobile .responsive-report-table td:first-child > *,
  .v177-kpi-mobile .responsive-report-table td:first-child > * {
    justify-self: start;
    text-align: left;
  }

  /* KPI top cards: 1 column on very narrow phones, 2 otherwise. */
  .v177-kpi-mobile .grid.grid-cols-2 {
    grid-template-columns: 1fr 1fr !important;
  }

  @media (max-width: 380px) {
    .v177-kpi-mobile .grid.grid-cols-2 {
      grid-template-columns: 1fr !important;
    }
  }

  /* Finance/Debt/KPI action rows and filters stack cleanly. */
  .v177-finance-mobile .flex.flex-wrap,
  .v177-debts-mobile .flex.flex-wrap,
  .v177-kpi-mobile .flex.flex-wrap {
    row-gap: 8px;
  }

  .v177-finance-mobile select,
  .v177-finance-mobile input,
  .v177-finance-mobile button,
  .v177-debts-mobile select,
  .v177-debts-mobile input,
  .v177-debts-mobile button,
  .v177-kpi-mobile select,
  .v177-kpi-mobile input,
  .v177-kpi-mobile button {
    max-width: 100%;
  }

  /* Debt order-code links wrap in-card rather than stretching the row. */
  .v177-debts-mobile a[href*="/invoices/"] {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  /* Charts should fit the card width. */
  .v177-finance-mobile .recharts-responsive-container,
  .v177-debts-mobile .recharts-responsive-container,
  .v177-kpi-mobile .recharts-responsive-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Long financial values do not create horizontal overflow. */
  .v177-finance-mobile .tabular,
  .v177-finance-mobile .tabular-nums,
  .v177-debts-mobile .tabular,
  .v177-debts-mobile .tabular-nums,
  .v177-kpi-mobile .tabular,
  .v177-kpi-mobile .tabular-nums {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
