/* NALQIVO ERP — tablet layer (iPad 768–1366 portrait/landscape + split view ≥600px), 2026-11-22.
   Loads after mobile.css (whose v4 section already keeps a one-row header, 16px controls and
   sticky table heads). This file only fills the gaps found by the iPad audit:
   - compact controls that stay under 44px (command-center period chips, chat icons, stat buttons)
   - small inline links inside meta rows (bigger hit area, same layout)
   - hover-only affordances made visible on touch
   - modals + on-screen keyboard, signature pads, landscape safe areas.
   Module sheets are injected after this file, so selectors carry an extra `html body`
   to win ties without !important. Phones (<600px) and mouse/trackpad users are untouched. */

@media (hover: none) and (pointer: coarse) and (min-width: 600px) and (max-width: 1400px) {
  /* ---- 1) touch targets ≥ 44px ---- */
  html body .cc-seg button { min-height: 44px; padding-inline: 14px; }
  html body .cc-toolbar-group select,
  html body .cc-toolbar-group input { min-height: 44px; font-size: 16px; }
  html body .cc-btn { min-height: 44px; }
  html body .cc-alert-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
  /* work-order follow-up readings: the slim «reason» input was 34px / 10.5px (iPadOS zooms under 16px) */
  html body .fu-field .fu-reason { min-height: 44px; font-size: 16px; }
  html body .dx-icon-btn { width: 44px; height: 44px; }
  html body .dx-tab { min-height: 44px; }
  html body .dx-msg-actions .dx-icon-btn { width: 40px; height: 40px; }
  html body .stat-btn { min-height: 48px; }
  html body .btn.sm { min-height: 40px; }
  html body .btn.xs { min-height: 36px; padding-inline: 10px; }
  html body .icon-btn, html body .icon-action { min-width: 44px; min-height: 44px; }
  html body .input, html body .select { min-height: 44px; }
  html body .pill, html body .chip { min-height: 36px; }

  /* Inline links in detail headers / meta rows: a 44px tap area without moving the text. */
  html body .meta-value a, html body .detail-sub a, html body .k a,
  html body .mk-mini-stats a, html body td a.cell-main, html body .doc-link-chip {
    display: inline-block; padding-block: 12px; margin-block: -12px;
  }

  /* ---- 2) hover-only affordances are always visible on touch ---- */
  html body .stat .stat-arrow { opacity: 1; }
  html body .dx-person .dx-person-go { opacity: 1; }

  /* ---- 3) no accidental text selection / callout on controls (long-press) ---- */
  .btn, .tab, .icon-btn, .context-tab, .cc-seg button, .dx-tab, .stat-btn {
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  }

  /* ---- 4) dialogs with the on-screen keyboard: the body scrolls, the footer stays reachable ---- */
  html body .modal {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  html body .modal .modal-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

  /* ---- 5) signature pads (work-order sign-off + site representative) ---- */
  canvas[data-sig] { touch-action: none; -webkit-user-select: none; user-select: none; margin-top: 8px; }
  html body [data-sig-clear] { min-height: 44px; min-width: 72px; }

  /* ---- 6) scrolling containers keep momentum and do not drag the page sideways ---- */
  .table-wrap, .context-tabs, .mk-board { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
}

/* Portrait tablets: KPI grids use the width (no lonely last card in a 2-column grid). */
@media (hover: none) and (pointer: coarse) and (min-width: 600px) and (max-width: 1024px) and (orientation: portrait) {
  html body .stat-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  html body .sales-pulse, html body .sales-pulse.pulse-6 { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
