/* Native customized KPI groups only. Flex growth fills the final row without JS. */
html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats){display:flex!important;flex-wrap:wrap!important;--rm-kpi-columns:4;--rm-kpi-gap:16px;gap:var(--rm-kpi-gap)!important}
html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats)::before,html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats)::after{display:none!important;content:none!important}
html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats) > *{flex:1 1 calc((100% - (var(--rm-kpi-columns) - 1)*var(--rm-kpi-gap))/var(--rm-kpi-columns))!important;min-width:0!important;width:auto!important;margin:0!important;box-sizing:border-box}
html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats):has(>:nth-child(5):last-child){--rm-kpi-columns:3}
html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats):has(>:nth-child(6):last-child){--rm-kpi-columns:3}
html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats):has(>:nth-child(9):last-child){--rm-kpi-columns:3}
@media(max-width:1100px){html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats){--rm-kpi-columns:2!important;--rm-kpi-gap:12px}}
@media(max-width:345px){html :is(body .rm-dashboard-kpis,
body.rm-commerce-page .rm-commerce-stats,
body.rm-premium-invoices .quick-top-stats > .tw-grid,
body.rm-premium-estimates .quick-top-stats > .tw-grid,
body.rm-premium-proposals .quick-top-stats > .tw-grid,
body .rm-invoice-stats,
body .rm-estimate-stats,
body .rm-proposal-stats,
body.customers .rm-client-home dl:has(>a[href*="/clients/projects/"]),
body.customers .rm-client-page__hero ~ .tw-mb-2 dl,
body.customers .rm-client-page__hero ~ dl,
body.customers .invoices-stats,
body.customers .estimates-stats){--rm-kpi-columns:1!important}}

/* Compact admin cards: equal widths on wrapped rows; customer layout stays independent. */
html body.admin #wrapper :is(.rm-dashboard-kpis,.rm-commerce-stats,.rm-invoice-stats,.rm-estimate-stats,.rm-proposal-stats,.quick-top-stats > .tw-grid){display:flex!important;flex-wrap:wrap!important;justify-content:center!important;align-items:stretch!important;--rm-kpi-gap:12px!important}
@media(min-width:768px){html body.admin #wrapper :is(.rm-dashboard-kpis,.rm-commerce-stats,.rm-invoice-stats,.rm-estimate-stats,.rm-proposal-stats,.quick-top-stats > .tw-grid) > *{flex-grow:0!important}}
@media(min-width:1280px){html body.admin #wrapper :is(.rm-dashboard-kpis,.rm-commerce-stats,.rm-invoice-stats,.rm-estimate-stats,.rm-proposal-stats,.quick-top-stats > .tw-grid):has(>:nth-child(5):last-child){--rm-kpi-columns:5!important}}
@media(min-width:1600px){html body.admin #wrapper :is(.rm-dashboard-kpis,.rm-commerce-stats,.rm-invoice-stats,.rm-estimate-stats,.rm-proposal-stats,.quick-top-stats > .tw-grid):has(>:nth-child(6):last-child){--rm-kpi-columns:6!important}}
html body.admin #wrapper :is(.rm-commerce-kpi,.rm-kpi-inspired,.rm-dashboard-kpi){min-height:158px!important;padding:16px!important;border-radius:16px!important;gap:0!important}
html body.admin :is(.rm-commerce-kpi-top,.rm-invoice-stat__visual,.rm-estimate-stat__visual,.rm-proposal-stat__visual){min-height:42px!important;margin-bottom:8px!important}
html body.admin :is(.rm-commerce-gauge,.rm-invoice-stat__percent,.rm-estimate-stat__percent,.rm-proposal-stat__percent){width:44px!important;height:44px!important;flex-basis:44px!important;font-size:10px!important}
html body.admin :is(.rm-commerce-kpi-icon,.rm-invoice-stat__icon,.rm-estimate-stat__icon,.rm-proposal-stat__icon,.rm-dashboard-kpi__icon){width:30px!important;height:30px!important;font-size:17px!important}
html body.admin :is(.rm-commerce-kpi-value,.rm-invoice-stat__count,.rm-estimate-stat__count,.rm-proposal-stat__count){font-size:26px!important;margin-top:4px!important;line-height:1.2!important}
html body.admin :is(.rm-commerce-kpi-sub,.rm-invoice-stat__total,.rm-estimate-stat__total,.rm-proposal-stat__total){margin-top:4px!important}
@media(max-width:767px){html body.admin #wrapper :is(.rm-commerce-kpi,.rm-kpi-inspired,.rm-dashboard-kpi){min-height:148px!important;padding:12px!important}html body.admin :is(.rm-commerce-kpi-value,.rm-invoice-stat__count,.rm-estimate-stat__count,.rm-proposal-stat__count){font-size:24px!important}html body.rm-commerce-credit_notes .rm-commerce-kpi-value{font-size:18px!important}}

@media(max-width:767px){html body.admin:is(.rm-commerce-expenses,.rm-commerce-payments,.rm-commerce-credit_notes,.rm-commerce-reports_expenses) #wrapper .rm-commerce-kpi-value{font-size:18px!important}html body.admin #wrapper .rm-commerce-gauge{font-size:9px!important}}

/* Large portfolios keep complete monetary values in compact cards. */
@media (min-width:768px) {
  html body.admin:is(.expenses,.payments,.credit_notes,.reports_expenses) #wrapper .rm-commerce-kpi-value { font-size:20px!important; }
}
@media (max-width:767px) {
  html body.admin:is(.expenses,.payments,.credit_notes,.reports_expenses) #wrapper .rm-commerce-kpi-value { font-size:16px!important; }
}

@media (min-width:768px) and (max-width:1399px) {
 html body.admin:is(.expenses,.payments,.credit_notes,.reports_expenses) #wrapper .rm-commerce-kpi-value { font-size:18px!important; }
}
