/*
 * V2.7.12 browser compatibility layer.
 * Layout-only overrides: no workflow, permission, document or calculation rules.
 */

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  min-width: 0 !important;
  min-height: 100%;
  overflow-x: hidden;
}

.workspace {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.workspace-header {
  width: 100%;
  height: auto;
  min-height: 72px;
}

.main,
.content,
.panel,
.panel-head,
.toolbar,
.table-wrap,
.line-editor,
.modal-body,
.product-picker-results {
  min-width: 0;
  max-width: 100%;
}

.table-wrap,
.line-editor,
.table-file-stack,
.order-status-filter-bar,
.export-field-grid,
.product-picker-results {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* The table height is measured from the real visible browser viewport. */
.workflow-table-scroll {
  max-width: 100%;
  max-height: var(--oms-table-height, calc(100vh - 235px)) !important;
  min-height: min(320px, var(--oms-table-height, calc(100vh - 235px))) !important;
  overflow: auto !important;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

/* Safari needs min-height:0 on every flex child before the middle can scroll. */
.modal {
  width: 100%;
  height: var(--oms-layout-height, 100vh);
  min-height: 0;
  overflow: hidden;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.modal-panel {
  position: relative;
  width: min(1240px, 100%);
  max-width: 100%;
  max-height: calc(var(--oms-layout-height, 100vh) - 24px);
  min-width: min(480px, calc(100vw - 24px));
  min-height: min(220px, calc(var(--oms-layout-height, 100vh) - 24px));
  resize: both;
}

.modal-panel > header,
.modal-panel > footer {
  flex: 0 0 auto;
}

.modal-panel > header > div {
  min-width: 0;
}

.modal-panel > header h3,
.modal-panel > header p {
  overflow-wrap: anywhere;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal select,
.modal input[list] {
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.modal-resize-grip {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 8;
  width: 18px;
  height: 18px;
  pointer-events: none;
  opacity: .62;
  background:
    linear-gradient(135deg, transparent 0 48%, #72928d 49% 55%, transparent 56% 66%, #72928d 67% 73%, transparent 74%);
}

/* Safari: avoid composited scrolling/backdrop layers swallowing native menus. */
html.oms-safari .modal,
html.oms-safari .product-picker-overlay {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

html.oms-safari .modal-body,
html.oms-safari .line-editor,
html.oms-safari .table-wrap,
html.oms-safari .product-picker-results {
  -webkit-overflow-scrolling: auto !important;
}

html.oms-safari .modal select {
  -webkit-appearance: menulist !important;
  appearance: auto !important;
  transform: none !important;
}

html.oms-safari .modal option {
  color: #173238;
  background: #fff;
}

html.oms-safari .safari-datalist-fallback {
  min-height: 36px;
  margin-top: 5px;
  border-color: #8fb7b1;
  background: #f5fbf9;
}

.modal-panel > footer {
  max-height: min(35vh, 220px);
  overflow-x: hidden;
  overflow-y: auto;
  flex-wrap: wrap;
  align-items: center;
  padding-bottom: max(13px, env(safe-area-inset-bottom));
}

.detail-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-right: auto;
}

.product-picker-overlay {
  width: 100%;
  height: var(--oms-layout-height, 100vh);
  min-height: 0;
  overflow: hidden;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.product-picker-panel {
  width: min(920px, 100%);
  max-width: 100%;
  max-height: calc(var(--oms-layout-height, 100vh) - 24px);
  min-height: 0;
}

.product-picker-panel > header,
.product-picker-tools,
.product-picker-help {
  flex: 0 0 auto;
}

.product-picker-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.action-dock.action-rail {
  max-height: calc(var(--oms-layout-height, 100vh) - 164px);
  min-height: 0;
}

.action-rail .action-scroll {
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.login-card {
  max-width: calc(100vw - 24px);
}

/* Header wraps instead of forcing half of the page outside the window. */
@media (max-width: 1180px) {
  .workspace-header {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 8px 14px;
  }

  .brand.horizontal {
    min-width: 190px;
  }

  .main-nav {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .main-nav .nav-btn {
    flex: 0 0 auto;
  }

  .account-area {
    min-width: 0;
    margin-left: auto;
  }

  .main {
    padding-right: 16px;
    padding-left: 16px;
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

html.oms-narrow-layout .workspace-header {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 14px;
}

html.oms-narrow-layout .brand.horizontal {
  min-width: 190px;
}

html.oms-narrow-layout .main-nav {
  order: 3;
  flex: 1 0 100%;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

html.oms-narrow-layout .main-nav .nav-btn {
  flex: 0 0 auto;
}

html.oms-narrow-layout .account-area {
  min-width: 0;
  margin-left: auto;
}

html.oms-narrow-layout .main {
  padding-right: 16px;
  padding-left: 16px;
}

html.oms-narrow-layout .panel-head {
  align-items: flex-start;
  flex-wrap: wrap;
}

/* 1024px windows and the app's 125%-140% zoom use a bottom action strip. */
@media (max-width: 1050px) {
  .order-action-rail,
  .order-action-rail.rail-collapsed {
    padding-left: 0;
    padding-bottom: 116px;
  }

  .action-dock.action-rail:not(.collapsed) {
    top: auto;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: min(42vh, 330px);
    padding: 12px 45px 12px 12px;
    flex-direction: row;
    align-items: center;
  }

  .action-rail:not(.collapsed) .selection-copy {
    display: block;
    width: auto;
    min-width: 116px !important;
    padding: 0 10px 0 0 !important;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .action-rail:not(.collapsed) .selection-tools {
    display: flex;
    width: auto;
    flex: 0 0 auto;
  }

  .action-rail:not(.collapsed) .action-scroll {
    display: flex;
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .action-rail:not(.collapsed) .action-scroll .btn {
    width: auto;
    flex: 0 0 auto;
    text-align: center;
  }

  .action-dock.action-rail.collapsed {
    top: auto;
    right: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 10px;
    width: 48px;
    max-height: 56px;
  }
}

/* Same compact layout when the built-in page zoom reduces effective width. */
html.oms-compact-layout .order-action-rail,
html.oms-compact-layout .order-action-rail.rail-collapsed {
  padding-left: 0;
  padding-bottom: 116px;
}

html.oms-compact-layout .action-dock.action-rail:not(.collapsed) {
  top: auto;
  right: 10px;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 10px;
  width: auto;
  max-height: min(42vh, 330px);
  padding: 12px 45px 12px 12px;
  flex-direction: row;
  align-items: center;
}

html.oms-compact-layout .action-rail:not(.collapsed) .selection-copy {
  display: block;
  width: auto;
  min-width: 116px !important;
  padding: 0 10px 0 0 !important;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

html.oms-compact-layout .action-rail:not(.collapsed) .selection-tools {
  display: flex;
  width: auto;
  flex: 0 0 auto;
}

html.oms-compact-layout .action-rail:not(.collapsed) .action-scroll {
  display: flex;
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
}

html.oms-compact-layout .action-rail:not(.collapsed) .action-scroll .btn {
  width: auto;
  flex: 0 0 auto;
  text-align: center;
}

html.oms-compact-layout .action-dock.action-rail.collapsed {
  top: auto;
  right: auto;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 10px;
  width: 48px;
  max-height: 56px;
}

@media (max-width: 820px) {
  .workspace-header {
    padding-right: 10px;
    padding-left: 10px;
  }

  .brand.horizontal {
    min-width: 0;
  }

  .brand.horizontal small,
  .account-copy {
    display: none;
  }

  .main {
    padding-right: 10px;
    padding-left: 10px;
  }

  .topbar {
    padding: 18px 2px 12px;
  }

  .topbar h2 {
    font-size: 23px;
  }

  .detail-grid,
  .form-grid.three,
  .permission-grid,
  .cards,
  .management-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .export-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .export-filter-row {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    padding: 6px;
  }

  .modal-panel {
    max-height: calc(var(--oms-layout-height, 100vh) - 12px);
    border-radius: 14px;
  }

  .modal-panel > header,
  .modal-body,
  .modal-panel > footer {
    padding: 14px;
  }
}

html.oms-mobile-layout .workspace-header {
  padding-right: 10px;
  padding-left: 10px;
}

html.oms-mobile-layout .brand.horizontal {
  min-width: 0;
}

html.oms-mobile-layout .brand.horizontal small,
html.oms-mobile-layout .account-copy {
  display: none;
}

html.oms-mobile-layout .main {
  padding-right: 10px;
  padding-left: 10px;
}

html.oms-mobile-layout .topbar {
  padding: 18px 2px 12px;
}

html.oms-mobile-layout .topbar h2 {
  font-size: 23px;
}

html.oms-mobile-layout .detail-grid,
html.oms-mobile-layout .form-grid.three,
html.oms-mobile-layout .permission-grid,
html.oms-mobile-layout .cards,
html.oms-mobile-layout .management-grid,
html.oms-mobile-layout .export-field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html.oms-mobile-layout .export-filter-row {
  grid-template-columns: 1fr 1fr;
}

html.oms-mobile-layout .modal {
  padding: 6px;
}

html.oms-mobile-layout .modal-panel {
  max-height: calc(var(--oms-layout-height, 100vh) - 12px);
  border-radius: 14px;
}

html.oms-mobile-layout .modal-panel > header,
html.oms-mobile-layout .modal-body,
html.oms-mobile-layout .modal-panel > footer {
  padding: 14px;
}

@media (max-width: 620px) {
  .zoom-controls {
    display: none;
  }

  .brand.horizontal strong {
    font-size: 13px;
  }

  .detail-grid,
  .form-grid,
  .form-grid.three,
  .permission-grid,
  .cards,
  .management-grid,
  .product-picker-items,
  .export-field-grid,
  .export-filter-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .search,
  .toolbar {
    width: 100%;
  }

  .product-picker-overlay {
    padding: 6px;
  }

  .product-picker-panel {
    max-height: calc(var(--oms-layout-height, 100vh) - 12px);
    border-radius: 14px;
  }

  .modal-panel {
    min-width: 0;
    min-height: 0;
    resize: none;
  }

  .modal-resize-grip {
    display: none;
  }
}

html.oms-small-layout .zoom-controls {
  display: none;
}

html.oms-small-layout .brand.horizontal strong {
  font-size: 13px;
}

html.oms-small-layout .detail-grid,
html.oms-small-layout .form-grid,
html.oms-small-layout .form-grid.three,
html.oms-small-layout .permission-grid,
html.oms-small-layout .cards,
html.oms-small-layout .management-grid,
html.oms-small-layout .product-picker-items,
html.oms-small-layout .export-field-grid,
html.oms-small-layout .export-filter-row {
  grid-template-columns: 1fr;
}

html.oms-small-layout .span-2 {
  grid-column: auto;
}

html.oms-small-layout .search,
html.oms-small-layout .toolbar {
  width: 100%;
}

html.oms-small-layout .product-picker-overlay {
  padding: 6px;
}

html.oms-small-layout .product-picker-panel {
  max-height: calc(var(--oms-layout-height, 100vh) - 12px);
  border-radius: 14px;
}

html.oms-small-layout .modal-panel {
  min-width: 0;
  min-height: 0;
  resize: none;
}

html.oms-small-layout .modal-resize-grip {
  display: none;
}

@media (pointer: coarse) {
  .modal-panel {
    resize: none;
  }

  .modal-resize-grip {
    display: none;
  }
}

@media (max-height: 720px) and (min-width: 1051px) {
  .topbar {
    padding-top: 14px;
    padding-bottom: 10px;
  }

  .modal {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .modal-panel {
    max-height: calc(var(--oms-layout-height, 100vh) - 12px);
  }

  .modal-panel > header,
  .modal-body,
  .modal-panel > footer {
    padding-top: 11px;
    padding-bottom: 11px;
  }

  html:not(.oms-compact-layout) .action-dock.action-rail {
    top: 104px;
    bottom: 10px;
    max-height: calc(var(--oms-layout-height, 100vh) - 114px);
  }
}

@supports not (height: 100dvh) {
  .workspace { min-height: 100vh; }
}
