/*
 * Stat-card rows: ONE rule for the whole platform (owner 2026-10-15; the back office already follows it in admin/assets/admin.css).
 *   large screens (992 px and over) .... up to 6 cards per row; a row with 5, 4, 3 or 2 cards fills the width with exactly that many
 *   sm and md (576 to 991 px) .......... 3 per row  (12 cards = 4 rows)
 *   xs (under 576 px) .................. 2 per row  (12 cards = 6 rows); a lonely last card takes the full width
 * Covers the shared card rows (.wb-stats, .bf-kpis) and the page-specific ones. Loaded from includes/head.php after the page
 * styles, and uses !important so older per-page rules cannot undo it.
 */
:is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis) {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
}
:is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis) > * { min-width: 0; }

/* xs: a lonely last card takes the whole row */
:is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis) > :last-child:nth-child(odd) { grid-column: 1 / -1; }

@media (min-width: 576px) {
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis) > :last-child:nth-child(odd) { grid-column: auto; }
  /* two cards (or one) never leave a blank third */
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(1):last-child) { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (min-width: 992px) {
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis) { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  :is(.wb-stats, .wb .wb-stats, .bf-kpis, .pv-stats, .pd-kpis, .sh-stats, .wb .sh-stats, .sh-kpis, .cbz-kpis, .cgt-kpis, .st-facts, .pw-facts, .cx-facts, .po-kpis):has(> :nth-child(1):last-child) { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ── Dashboard-style cards (.dsh-kpi, adm_kpis) on narrower screens: nothing is cut (owner rule "no cut-offs", 2026-10-16) ──
   the big number scales with the screen instead of ending in "…", and the small line wraps onto a second line instead of being clipped. */
.dsh-kpis .dsh-kpi-v { font-size: clamp(13px, 1.4vw, 22px) !important; white-space: nowrap; overflow: visible !important; text-overflow: clip !important; }
.dsh-kpis .dsh-kpi-s { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; line-height: 1.25; }
.dsh-kpis .dsh-kpi-top { flex-wrap: wrap; row-gap: 1px; }
.dsh-kpis .dsh-lbl { flex: 1 1 auto !important; white-space: normal !important; overflow: visible !important; text-overflow: clip !important; line-height: 1.2; }
.dsh-kpis .dsh-kpi-side { white-space: normal !important; max-width: none !important; }
.dsh-kpis .dsh-kpi-mid { flex-wrap: wrap; column-gap: 6px; }
