/* App-like mobile stability: prevent iOS auto-zoom and layout jumping. */
html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.app,
.workspace,
.content,
.panel,
.form-card,
.sales-layout,
.catalog-panel,
.review-shell,
.branch-stock-manager {
  min-width: 0;
  max-width: 100%;
}

img, svg, canvas, video {
  max-width: 100%;
}

button,
a,
[role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

/* iOS Safari auto-zooms focused controls below 16px. Keep them at 16px. */
@media (max-width: 900px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
    line-height: 1.25;
  }

  input:focus,
  select:focus,
  textarea:focus {
    font-size: 16px !important;
    transform: none !important;
  }

  .content {
    width: 100%;
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
    overflow-x: hidden;
  }

  .topbar {
    width: 100%;
    max-width: 100vw;
  }

  .form-row,
  .grid,
  .metrics,
  .sales-layout,
  .review-shell,
  .management-product-grid,
  .material-list {
    min-width: 0;
  }

  .table-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .ns4-order-appbar {
    max-width: calc(100vw - 20px) !important;
    inset-inline: 0;
  }
}

/* Installed PWA / iPhone safe areas. */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Do not let focus/active states scale cards or forms. */
.form-card:focus-within,
.panel:focus-within,
.sales-product-card:focus-within,
.stock-product-row:focus-within {
  transform: none !important;
}
