/* Phone: the work comes first. Loaded last. */
@media (max-width: 639.98px){
  /* Tiles in one swipeable strip, problems first. */
  body :is(.kpi-grid, .stat-grid):not(.hidden){ flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; }
  body :is(.kpi-grid, .stat-grid)::-webkit-scrollbar{ display: none; }
  body :is(.kpi-grid, .stat-grid) > *{ flex: 0 0 43%; scroll-snap-align: start; }
  body :is(.kpi-grid, .stat-grid) > :only-child{ flex-basis: 100%; }
  body :is(.kpi-grid, .stat-grid) > [data-tone="bad"]{ order: -2; }
  body :is(.kpi-grid, .stat-grid) > [data-tone="warn"]{ order: -1; }
  /* The dashboard's channel, float and service cards: one swipe strip, not two screens of cards. */
  body .hv-grid:not(.hidden){ flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; }
  body .hv-grid::-webkit-scrollbar{ display: none; }
  body .hv-grid > .hv-card{ flex: 0 0 88%; scroll-snap-align: start; }
  body .hv-grid > .hv-card:only-child{ flex-basis: 100%; }
  body .kpi-grid .kpi{ padding: 10px 12px; }
  body .kpi-grid .kpi-value{ font-size: 20px; line-height: 26px; }
  body .kpi-grid .kpi-meta{ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  /* Rows: name across, then two values a line. :is(#_, …) outranks the per-page table rules. */
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) tr{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; align-items: start; padding: 10px 16px; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) tr:is(.ov-extra, .hidden, [hidden]){ display: none; }
  body :is(#_, .view) .all table.stack tr.ov-extra, body :is(#_, .view) table.stack tr.ov-extra.ov-found{ display: grid; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td{ display: flex; flex-direction: column; flex-wrap: nowrap; align-items: flex-start; justify-content: flex-start; gap: 0; min-width: 0; min-height: 0; padding: 0; text-align: left; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td:empty{ display: none; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td::before{ max-width: none; margin: 0; font-size: 12px; line-height: 16px; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td :is(div, span, .sub-line, .ov-sub, .lede){ text-align: left; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td > :is(.sub-line, .ov-sub, .lede){ flex: 0 0 auto; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td > :is(.user-cell, .row-action-btn){ flex: 0 0 auto; margin-left: 0; text-align: left; }
  body :is(#_, .view) table.stack td > .user-cell .name-with-avatar{ justify-content: flex-start; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td:is(:first-child, [colspan], .stack-note, .reason-cell, [data-label=""]){ grid-column: 1 / -1; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td:is(:first-child, [colspan], .stack-note)::before{ content: none; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td { overflow: visible; white-space: normal; overflow-wrap: anywhere; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td :is(div, span, a, .sub-line, .ov-sub, .chip, .user-cell){ min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td .chip{ height: auto; padding-block: 3px; line-height: 18px; border-radius: 14px; }
  body :is(#_, .view) table.stack:not(.mn-list table, .kyc-q table, .mk-segments table) td > .row-action-btn:not([data-label=""] > *){ min-width: 0; padding-left: 0; }

  /* A long failure cause takes the full width, two lines; the record has it all. */
  body :is(#_, .view) table.stack td[data-label="Why it failed"]{ grid-column: 1 / -1; }
  body :is(#_, .view) table.stack td[data-label="Why it failed"] > :first-child{ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  /* Choice cards: the effect sits under its name. */
  #fsForm .kp-opt{ display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; align-items: start; column-gap: 10px; }
  #fsForm .kp-opt > input{ grid-row: 1 / span 2; }
  #fsForm :is(.kp-opt-name, .kp-opt-sub){ grid-column: 2; }
}
