/* SD360 mobile stability. Desktop rules are deliberately outside this file. */
@media (max-width: 900px) and (pointer: coarse) {
  html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-block-size: 100svh; overflow-x: clip; }
  #app { min-width: 0; padding-inline-start: max(14px, env(safe-area-inset-right)); padding-inline-end: max(14px, env(safe-area-inset-left)); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  input, select, textarea, .photo-upload input { font-size: max(16px, 1rem); }
  input, select, textarea { min-width: 0; max-width: 100%; }
  .top, .top-actions, .toolbar, .crm-topline, .crm-lead-head, .crm-dialog header { flex-wrap: wrap; }
  .toolbar > input { flex: 1 1 180px; }
  .top-actions > *, .actions > *, .crm-filters > *, .card-head > * { min-width: 0; }
  .actions { display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .actions > button, .actions > a { width: 100%; max-width: 100%; min-height: 48px; }
  .actions button, .actions a, .toolbar button, .nav button { white-space: normal; word-break: normal; overflow-wrap: normal; }
  .card, .panel, .order-row-details, .crm-lead, .crm-task { overflow-wrap: anywhere; }
  .crm-layout, .crm-detail-columns { grid-template-columns: minmax(0, 1fr); }
  .crm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-stat { min-width: 0; }
  .finance-table-wrap, .crm-ad-table { max-width: 100%; overflow-x: auto; touch-action: pan-x pan-y; }
  .loading-dialog, .crm-dialog {
    box-sizing: border-box; max-width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
    max-height: calc(var(--sd360-visible-height, 100dvh) - 24px);
    overflow-y: auto; overscroll-behavior-y: contain;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  #notice { bottom: max(20px, env(safe-area-inset-bottom)); overflow-wrap: anywhere; }
}
