/* Mobile-first refinements (4.1.6). Loaded last, so it only adds to the rules above. Phones first, larger screens keep the desktop layout. */

/* Long references, emails and reasons wrap instead of pushing the page sideways */
.cell-sub,
.cell-main,
td,
.activity-sub,
.activity-title {
  overflow-wrap: anywhere;
  min-width: 0;
}
img, video, canvas, svg { max-width: 100%; }
.shell, .main, main { min-width: 0; }

/* Touch targets: at least 44px tall where a finger has to hit them */
@media (pointer: coarse) {
  .btn, .chip, .nav-item, .select-wrap select, .select-wrap input, .icon-btn { min-height: 44px; }
  .nav-item { height: 44px; }
}

/* iOS zooms into any input smaller than 16px, so keep form text at 16px on phones */
@media (max-width: 760px) {
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  .btn { white-space: normal; text-align: center; }
  .table-cards td { gap: 12px; flex-wrap: wrap; align-items: flex-start; }
  .table-cards td > * { min-width: 0; max-width: 100%; }
  .table-cards td::before { max-width: 42%; }
  .table-cards td .cell-sub { white-space: normal; max-width: none; }
  .card-body, .card-head { padding-left: 14px; padding-right: 14px; }
}

/* Phones: action rows wrap and buttons take the full width of their row */
@media (max-width: 560px) {
  .page-head, .page-actions, .card-head { flex-wrap: wrap; gap: 10px; }
  .page-actions > .btn, .card-head > .btn { flex: 1 1 auto; justify-content: center; }
  .date-range, .filters, .table-tools { flex-wrap: wrap; }
}

/* Keep the WhatsApp button clear of the bottom of forms and tables on phones */
@media (max-width: 760px) {
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
}
