/*
 * Compact sales entry, matching preview/order-entry-compact/PRODUCT.md.
 * Keep this after the existing VI styles. The plan01 layer is deliberate:
 * legacy !important card rules otherwise outrank unlayered declarations.
 * Permission-layer [hidden] rules retain precedence over this presentation.
 */
@layer plan01 {
  body.erp-operate-ui #orderForm.order-entry-compact {
    --order-compact-ink: #1b293c;
    --order-compact-muted: #586e80;
    --order-compact-line: #dce6ed;
    --order-compact-pale: #eef5f8;
    --order-compact-accent: #008576;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    max-height: 100% !important;
    padding: 0 !important;
    overflow: hidden !important;
    color: var(--order-compact-ink) !important;
    font-variant-numeric: tabular-nums;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-entry-header {
    position: static !important;
    flex: 0 0 auto !important;
    min-height: 64px !important;
    gap: 12px !important;
    margin: 0 !important;
    padding: 14px 24px !important;
    border-bottom: 1px solid var(--order-compact-line) !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-entry-header h2 {
    margin: 0 !important;
    font-size: 22px !important;
    font-weight: 650 !important;
    line-height: 1.3 !important;
    letter-spacing: -0.02em !important;
    color: var(--order-compact-ink) !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-entry-header .dialog-subtitle {
    margin: 4px 0 0 !important;
    font-size: 12px !important;
    line-height: 1.5 !important;
    color: var(--order-compact-muted) !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-entry-body {
    display: block !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 20px 24px !important;
    overflow: auto !important;
    scrollbar-gutter: stable;
    scroll-padding: 12px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(.order-base-grid, .order-compact-more .form-grid, .order-invoice-grid) {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px 16px !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(label, .order-customer-field) {
    min-width: 0 !important;
    gap: 6px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    color: var(--order-compact-ink) !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-customer-field {
    grid-column: auto !important;
    order: initial !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-customer-field > label {
    margin: 0 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-customer-input-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 6px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(input, select, textarea):where(:not([type="hidden"]):not([type="file"]):not([type="checkbox"]):not([type="radio"])) {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 36px !important;
    margin: 0 !important;
    padding: 7px 10px !important;
    border: 1px solid #cad9e3 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: var(--order-compact-ink) !important;
    box-shadow: none !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    caret-color: var(--order-compact-accent);
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(input, textarea)::placeholder {
    color: var(--order-compact-muted) !important;
    opacity: 1;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(input[readonly], select:disabled, textarea[readonly]) {
    background: #f5f8fa !important;
    color: #566e80 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #566e80;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(input, select, textarea):focus {
    border-color: var(--order-compact-accent) !important;
    outline: 2px solid #a9ddd1 !important;
    outline-offset: 1px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(button, summary):focus-visible {
    outline: 2px solid var(--order-compact-accent) !important;
    outline-offset: 2px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-new-customer-button {
    min-width: 0 !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    border: 1px solid #ccdae6 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: #1677bf !important;
    font-size: 12px !important;
    font-weight: 500 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-compact-more {
    margin: 12px 0 0 !important;
    padding: 0 0 12px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--order-compact-line) !important;
    border-radius: 0 !important;
    background: #fff !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-compact-more > summary {
    width: fit-content;
    padding: 4px 0 !important;
    color: #007568 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-compact-more[open] > summary {
    margin-bottom: 12px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-delivery-invoice-row {
    display: contents !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-free-shipping-hint:empty {
    display: none !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(.order-invoice-section, .order-fulfillment-section, .order-process-section) {
    margin: 16px 0 !important;
    padding: 16px !important;
    border: 1px solid var(--order-compact-line) !important;
    border-radius: 4px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-detail-section {
    min-width: 0 !important;
    margin: 18px 0 16px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-detail-section .dialog-subheader {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 8px 12px !important;
    min-height: 36px !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    border: 0 !important;
    background: #fff !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(.order-detail-section, .order-invoice-section, .order-process-section) h3 {
    margin: 0 !important;
    color: var(--order-compact-ink) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-detail-toolbar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-detail-toolbar::before {
    content: none !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(.order-detail-toolbar, .order-compact-table-nav) button {
    min-height: 32px !important;
    padding: 6px 10px !important;
    border: 1px solid #ccdae6 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: var(--order-compact-ink) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-compact-table-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin: 0 0 8px;
    color: var(--order-compact-muted);
    font-size: 12px;
    line-height: 1.5;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-compact-table-nav > div {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* One horizontal viewport; rows grow in the form's existing scroll body. */
  body.erp-operate-ui #orderForm.order-entry-compact .order-detail-table.compact-order-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0 0 8px !important;
    border: 1px solid var(--order-compact-line) !important;
    border-radius: 4px !important;
    background: #fff !important;
    overscroll-behavior-x: contain;
    scrollbar-color: #aabecb #eef3f6;
    scrollbar-width: auto;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table #orderDetailRows {
    display: block !important;
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    gap: 0 !important;
    padding: 0 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(.order-detail-head, .order-detail-row) {
    display: grid !important;
    grid-template-columns: var(--order-detail-columns) !important;
    grid-template-rows: auto !important;
    grid-auto-flow: row !important;
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    align-items: stretch !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-head {
    position: sticky;
    top: 0;
    z-index: 5;
    min-height: 40px !important;
    background: var(--order-compact-pale) !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-head > span {
    display: flex !important;
    align-items: center !important;
    min-width: 0 !important;
    min-height: 40px !important;
    padding: 8px !important;
    border-right: 1px solid #e8eef2 !important;
    border-bottom: 1px solid var(--order-compact-line) !important;
    background: var(--order-compact-pale) !important;
    color: #4f6577 !important;
    font-size: 12px !important;
    font-weight: 550 !important;
    white-space: nowrap;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row {
    min-height: 73px !important;
    border-bottom: 1px solid var(--order-compact-line) !important;
    background: #fff !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row > * {
    box-sizing: border-box !important;
    grid-column: auto !important;
    grid-row: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 8px !important;
    border: 0 !important;
    border-right: 1px solid #e8eef2 !important;
    background: #fff !important;
    color: var(--order-compact-ink) !important;
    font-size: 12px !important;
    font-weight: 400 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row :is(input, select):where(:not([type="hidden"]):not([type="file"])) {
    display: block !important;
    align-self: center !important;
    width: 100% !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 6px 8px !important;
    border: 1px solid #cad9e3 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: var(--order-compact-ink) !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    line-height: 18px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row > :is(input, select):not([type="hidden"]):not([type="file"]) {
    width: calc(100% - 16px) !important;
    margin-inline: 8px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table input[type="number"] {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row > input[type="hidden"] {
    display: none !important;
  }

  /* Fixed identity columns retain context while parameters scroll right. */
  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(.detail-index, .order-detail-head > span:first-child) {
    position: sticky !important;
    left: 0 !important;
    z-index: 3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--order-sequence-column, 44px) !important;
    min-height: 100% !important;
    background: var(--order-compact-pale) !important;
    color: #4f6577 !important;
    text-align: center !important;
    white-space: nowrap;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(.detail-product-cell, .detail-product-heading) {
    position: sticky !important;
    left: var(--order-sequence-column, 44px) !important;
    z-index: 3 !important;
    width: var(--order-name-column, 240px) !important;
    border-right: 1px solid #bdcfdc !important;
    background: #fff !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-head :is(span:first-child, .detail-product-heading) {
    z-index: 6 !important;
    background: var(--order-compact-pale) !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-product-cell {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-content: center !important;
    gap: 4px !important;
    min-height: 72px !important;
    padding: 6px 8px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-product-cell select[name="detailCategory"] {
    height: 24px !important;
    min-height: 24px !important;
    padding: 2px 6px !important;
    color: var(--order-compact-muted) !important;
    font-size: 11px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(.detail-image-cell, .detail-warehouse-cell) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    min-height: 72px !important;
    padding: 6px 8px !important;
    line-height: 1.5 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-warehouse-cell {
    justify-content: flex-start !important;
    overflow-wrap: anywhere;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-image-cell :is(button, img) {
    flex: 0 0 32px !important;
    box-sizing: border-box !important;
    width: 32px !important;
    min-width: 0 !important;
    height: 32px !important;
    min-height: 32px !important;
    margin: 0 !important;
    padding: 2px !important;
    border: 1px dashed #bbcdd8 !important;
    border-radius: 4px !important;
    background: #fff !important;
    color: #536c7d !important;
    font-size: 11px !important;
    font-weight: 400 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-image-cell img {
    object-fit: cover;
    padding: 0 !important;
    border-style: solid !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-image-cell > :is(span, small) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
  }

  /* These wrappers are structural only: each parameter stays in the row. */
  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(.detail-parameters-cell, [data-order-parameter-container], .detail-parameter-grid) {
    display: contents !important;
    grid-column: auto !important;
    grid-row: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-parameters-heading,
  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-parameters-cell:empty::before {
    display: none !important;
    content: none !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-parameter-field {
    position: relative;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
    min-height: 72px !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 8px !important;
    border-right: 1px solid #e8eef2 !important;
    background: #fff !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-parameter-field > span {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .detail-parameters-empty {
    display: flex !important;
    grid-column: span var(--order-parameter-count, 1) !important;
    align-items: center !important;
    min-height: 72px !important;
    padding: 8px 12px !important;
    border-right: 1px solid #e8eef2 !important;
    background: #f8fafb !important;
    color: var(--order-compact-muted) !important;
    font-size: 12px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row :is(input[readonly], select:disabled) {
    background: #f5f8fa !important;
    color: #566e80 !important;
    opacity: 1 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row :is(input, select):focus {
    border-color: var(--order-compact-accent) !important;
    outline: 2px solid #a9ddd1 !important;
    outline-offset: 1px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(.order-parameter-field.is-missing, [data-order-parameter-missing="true"]) :is(input, select),
  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table :is(input, select)[aria-invalid="true"] {
    border-color: #b97c35 !important;
    background: #fffcf3 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row > button[data-action="removeOrderDetail"] {
    align-self: center !important;
    justify-self: center !important;
    min-width: 0 !important;
    min-height: 32px !important;
    height: 32px !important;
    padding: 6px 8px !important;
    border: 0 !important;
    border-radius: 4px !important;
    background: transparent !important;
    color: #8b4557 !important;
    font-size: 12px !important;
    font-weight: 400 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row > button[data-action="removeOrderDetail"]:hover {
    background: #fff0f1 !important;
    color: #8a2b40 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-entry-actions {
    position: static !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    min-height: 60px !important;
    margin: 0 !important;
    padding: 12px 24px !important;
    border-top: 1px solid var(--order-compact-line) !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-entry-actions button {
    min-height: 36px !important;
    padding: 7px 14px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-continue-submit {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 7px !important;
    margin: 0 auto 0 0 !important;
    color: var(--order-compact-muted) !important;
    font-size: 12px !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-continue-submit input {
    width: 16px !important;
    height: 16px !important;
    min-height: 16px !important;
    padding: 0 !important;
    accent-color: var(--order-compact-accent);
  }

  body.erp-operate-ui #orderForm.order-entry-compact ::selection,
  #ordersView ::selection {
    background: #c8eee4;
    color: #15392f;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table::-webkit-scrollbar {
    height: 10px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table::-webkit-scrollbar-track {
    background: #eef3f6;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table::-webkit-scrollbar-thumb {
    border: 2px solid #eef3f6;
    border-radius: 6px;
    background: #aabecb;
  }

  /* The legacy shell clips a viewport-height app. Release the whole orders
     scroll chain: hidden overflow can move through AX/script, but not wheel. */
  html:has(> body.erp-operate-ui[data-active-view="orders"]) {
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.erp-operate-ui[data-active-view="orders"] {
    height: auto !important;
    overflow: visible !important;
  }

  body.erp-operate-ui[data-active-view="orders"] .app-shell {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* Sales list: the page owns vertical scrolling; only column titles stick. */
  body.erp-operate-ui[data-active-view="orders"] .workspace {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.erp-operate-ui[data-active-view="orders"] :is(.topbar, .module-subnav, .vi-subnav) {
    position: static !important;
    top: auto !important;
  }

  body.erp-operate-ui #ordersView,
  body.erp-operate-ui #ordersView :is(.orders-master-detail, .orders-master-pane, #ordersListPanel, .eb-workspace) {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.erp-operate-ui #ordersView :is(#ordersListPanel, .eb-workspace) {
    display: block !important;
    grid-template-rows: none !important;
  }

  body.erp-operate-ui #ordersView :is(.order-section-bar, .order-filter-navigation, .order-status-navigation, .orders-list-header, .eb-bar, .orders-pagination) {
    position: static !important;
    inset: auto !important;
  }

  body.erp-operate-ui #ordersView #ordersListPanel .orders-table-wrap {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    overscroll-behavior-y: auto !important;
    padding: 0 !important;
  }

  body.erp-operate-ui #ordersView #ordersListPanel .clean-orders-table {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Percentage columns let the normal list fit the desktop page width. */
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(1) { width: 4% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(2) { width: 8% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(3) { width: 24% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(4) { width: 16% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(5) { width: 9% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(7) { width: 12% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(8) { width: 13% !important; }
  body.erp-operate-ui #ordersView #ordersListPanel.clean-orders-simple-fields .clean-orders-table col:nth-child(9) { width: 14% !important; }

  body.erp-operate-ui #ordersView #ordersListPanel:not(.clean-orders-simple-fields) .orders-table-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
  }

  body.erp-operate-ui #ordersView #ordersListPanel:not(.clean-orders-simple-fields) .clean-orders-table {
    min-width: 1390px !important;
  }

  body.erp-operate-ui #ordersView #ordersListPanel .clean-orders-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: #eef5f8 !important;
  }

  body.erp-operate-ui #ordersView .eb-layout {
    overflow: visible !important;
  }

  body.erp-operate-ui #ordersView .eb-rail {
    position: static !important;
  }

  body.erp-operate-ui #ordersView .eb-rail-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 11 !important;
    background: #eef5f8 !important;
  }

  body.erp-operate-ui #ordersView .eb-bar {
    min-height: 44px;
    gap: 8px 12px;
    margin: 0 0 8px !important;
    padding: 6px 12px !important;
    border: 1px solid #c8e4dc !important;
    border-radius: 4px !important;
    background: #e7f5f1 !important;
    font-size: 12px;
  }

  body.erp-operate-ui #ordersView .eb-bar :is(button, strong, label) {
    min-height: 30px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
  }

  body.erp-operate-ui #ordersView .eb-bar button {
    padding: 4px 9px !important;
  }

  body.erp-operate-ui #ordersView .eb-note {
    margin: 0 0 8px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: #586e80 !important;
    font-size: 11px !important;
    line-height: 1.5;
  }

  body.erp-operate-ui #ordersView .eb-bar[hidden] + .eb-note {
    display: none !important;
  }

  @media (max-width: 1100px) {
    /* An unconstrained horizontal scroller grows with all list rows. */
    body.erp-operate-ui #ordersView #ordersListPanel .orders-table-wrap {
      overflow-x: auto !important;
      overflow-y: visible !important;
    }

    body.erp-operate-ui #ordersView #ordersListPanel .clean-orders-table {
      min-width: 840px !important;
    }
  }

  body.erp-operate-ui #orderForm.order-entry-compact [data-order-stock-product] {
    grid-column: 1 / -1 !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    gap: 6px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact #orderProductSelect,
  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-picker [type="hidden"],
  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-options[hidden] {
    display: none !important;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-combobox {
    position: relative;
    min-width: 0;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-options {
    position: absolute;
    z-index: 15;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: min(320px, 40vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: #a8b9c5 #f2f6f8;
    border: 1px solid var(--order-compact-line);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 6px 16px rgb(27 41 60 / 12%);
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option {
    padding: 10px 12px;
    border-bottom: 1px solid var(--order-compact-line);
    cursor: pointer;
    overflow-wrap: anywhere;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option:last-child {
    border-bottom: 0;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option:is(:hover, .is-active, [aria-selected="true"]) {
    background: var(--order-compact-pale);
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option.is-active {
    outline: 2px solid var(--order-compact-accent);
    outline-offset: -2px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option-main {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 13px;
    line-height: 1.5;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option-main strong {
    font-weight: 600;
  }

  body.erp-operate-ui #orderForm.order-entry-compact :is(.order-stock-option-meta, .order-stock-empty) {
    color: var(--order-compact-muted);
    font-size: 12px;
    line-height: 1.5;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-option-meta {
    margin-top: 3px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-empty {
    padding: 12px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-search button:focus-visible {
    outline: 2px solid var(--order-compact-accent);
    outline-offset: 2px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-search button:disabled {
    color: var(--order-compact-muted);
    background: #f2f6f8;
    cursor: default;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-search button {
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid #cad9e3;
    border-radius: 4px;
    background: #fff;
    color: var(--order-compact-ink);
    font: inherit;
    cursor: pointer;
  }

  body.erp-operate-ui #orderForm.order-entry-compact .order-stock-picker small {
    grid-column: 1 / -1;
    color: var(--order-compact-muted);
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  body.erp-operate-ui #ordersView .clean-order-payment-heading,
  body.erp-operate-ui #ordersView .clean-order-payment-cell,
  body.erp-operate-ui #ordersView .clean-order-payment-state,
  body.erp-operate-ui #ordersView td:has(.clean-order-payment-state) {
    text-align: center !important;
  }

  body.erp-operate-ui #ordersView #ordersTable .clean-order-payment-cell .clean-order-payment-state {
    display: flex;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: wrap;
    gap: 6px;
    text-align: center !important;
  }

  body.erp-operate-ui #ordersView #ordersTable .clean-order-payment-cell :is(strong, small) {
    display: block;
    text-align: center !important;
  }

  body.erp-operate-ui #ordersView #ordersTable .clean-order-payment-cell .clean-order-payment-button {
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 30px !important;
    min-width: 62px !important;
    margin: 0 !important;
    padding: 4px 10px !important;
    border: 1px solid var(--erp-jade-600, #008575) !important;
    border-radius: 4px !important;
    background: var(--erp-jade-600, #008575) !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 550 !important;
    line-height: 20px !important;
    text-align: center !important;
    white-space: nowrap;
  }

  body.erp-operate-ui #ordersView #ordersTable .clean-order-payment-cell .clean-order-payment-button:hover:not(:disabled) {
    background: var(--erp-jade-700, #007568) !important;
    border-color: var(--erp-jade-700, #007568) !important;
  }

  body.erp-operate-ui #ordersView #ordersTable .clean-order-payment-cell .clean-order-payment-button.is-review {
    background: var(--erp-surface, #fff) !important;
    border-color: var(--erp-line-strong, #ccdae6) !important;
    color: var(--erp-text-secondary, #66768c) !important;
  }

  body.erp-operate-ui #ordersView #ordersTable .clean-order-payment-cell .clean-order-payment-button:focus-visible {
    outline: 2px solid var(--erp-jade-600, #008575) !important;
    outline-offset: 3px;
  }

  @media (max-width: 820px) {
    body.erp-operate-ui #orderForm.order-entry-compact .order-stock-picker {
      grid-template-columns: minmax(0, 1fr);
    }

    body.erp-operate-ui #orderForm.order-entry-compact :is(.order-base-grid, .order-compact-more .form-grid, .order-invoice-grid) {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    body.erp-operate-ui #orderForm.order-entry-compact :is(.order-entry-header, .order-entry-body, .order-entry-actions) {
      padding-left: 16px !important;
      padding-right: 16px !important;
    }
  }

  @media (max-width: 560px) {
    body.erp-operate-ui #orderForm.order-entry-compact {
      --order-sequence-column: 32px;
      --order-name-column: 150px;
    }

    body.erp-operate-ui #orderForm.order-entry-compact :is(.order-base-grid, .order-compact-more .form-grid, .order-invoice-grid) {
      grid-template-columns: minmax(0, 1fr) !important;
    }

    body.erp-operate-ui #orderForm.order-entry-compact :is(.order-entry-header, .order-entry-body, .order-entry-actions) {
      padding-left: 12px !important;
      padding-right: 12px !important;
    }

    body.erp-operate-ui #orderForm.order-entry-compact :is(input, select, textarea):not([type="hidden"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]),
    body.erp-operate-ui #orderForm.order-entry-compact .compact-order-table .order-detail-row :is(input, select):not([type="hidden"]):not([type="file"]) {
      font-size: 16px !important;
    }

    body.erp-operate-ui #orderForm.order-entry-compact :is(.order-entry-actions, .order-detail-toolbar, .order-compact-table-nav) button,
    body.erp-operate-ui #orderForm.order-entry-compact .order-new-customer-button {
      min-height: 40px !important;
    }

    body.erp-operate-ui #orderForm.order-entry-compact .order-field-span-2 {
      grid-column: auto !important;
    }

    body.erp-operate-ui #orderForm.order-entry-compact .order-entry-actions {
      padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
  }
}

/* Each stock product is searched and selected inside its own order row. */
@layer plan01 {
  #orderForm.stock-inline-ready [data-order-stock-product],
  #orderForm.stock-inline-ready .order-stock-picker[hidden],
  #orderForm.stock-inline-ready .order-stock-picker [data-order-stock-search] {
    display: none !important;
  }
  #orderForm.stock-inline-ready .detail-product-cell .order-stock-picker {
    width: 100%; min-width: 0; grid-column: 1;
  }
  #orderForm.stock-inline-ready .detail-product-cell .order-stock-options {
    position: static !important; max-height: 240px; overflow-y: auto;
    width: 100%; min-width: 0;
  }
  #orderForm.stock-inline-ready .detail-product-cell .order-stock-search {
    display: flex; justify-content: flex-end;
  }
  #orderForm.stock-inline-ready [data-line-stock-search] {
    width: 100%; min-width: 0; background: white !important; cursor: text;
  }
}

/* Stock orders inherit inventory specifications; no parameter columns. */
@layer plan01 {
body.erp-operate-ui #orderForm.order-entry-compact.stock-parameters-hidden .compact-order-table .detail-parameters-cell,
#orderForm.stock-parameters-hidden .detail-parameters-cell,
body.erp-operate-ui #orderForm.order-entry-compact.stock-parameters-hidden .order-compact-table-nav,
#orderForm.stock-parameters-hidden .order-compact-table-nav { display: none !important; }
}

/* Sales order actions remain visible at desktop and narrow widths. */
@layer plan01 {
html body.erp-operate-ui #ordersView .clean-order-operation > .simple-row-actions.order-visible-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  width: 100% !important;
}
html body.erp-operate-ui #ordersView .clean-order-operation > .simple-row-actions.order-visible-actions > button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  margin: 0;
  min-height: 30px;
}

}

/* Shared inbound / outbound review form, isolated from business page layouts. */
html body dialog.inventory-review-dialog {
  width: min(560px, calc(100vw - 32px)); max-width: 560px; max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 1px solid #dce7e8; border-radius: 18px;
  background: #fff; color: #203443; box-shadow: 0 24px 80px #173f4933; overflow: auto;
}
html body dialog.inventory-review-dialog::backdrop { background: #18343e70; backdrop-filter: blur(3px); }
.inventory-review-dialog *, .inventory-review-dialog *::before { box-sizing: border-box; }
html body .inventory-review-form { display: block; margin: 0; padding: 0; }
html body .inventory-review-header { display: flex; gap: 14px; align-items: center; padding: 24px 26px 20px; border-bottom: 1px solid #edf1f2; }
.inventory-review-symbol { flex: 0 0 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: #fff2e2; color: #a96020; font-size: 28px; }
html body .inventory-review-header h2 { margin: 0 0 5px; font-size: 21px; line-height: 1.4; }
html body .inventory-review-header p { margin: 0; color: #6c7f8c; font-size: 13px; line-height: 1.5; }
html body .inventory-review-close { margin-left: auto; flex: 0 0 32px; height: 32px; min-height: 32px; padding: 0; border: 0; border-radius: 8px; color: #647784; background: #f3f6f7; font-size: 24px; cursor: pointer; }
.inventory-review-body { padding: 22px 26px 10px; }
.inventory-review-summary { margin: 0 0 16px; padding: 14px 16px; background: #f3f8f8; border: 1px solid #e2eeee; border-radius: 10px; display: grid; gap: 10px; }
.inventory-review-summary > div { display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 12px; align-items: baseline; }
.inventory-review-summary dt { color: #71838c; font-size: 13px; }
.inventory-review-summary dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.inventory-review-notice { margin-bottom: 20px; color: #677d80; font-size: 13px; line-height: 1.7; }
html body .inventory-review-label { display: flex; align-items: center; gap: 8px; margin: 0 0 9px; font-size: 14px; font-weight: 600; }
.inventory-review-label span { color: #a75d31; background: #fff4e9; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 400; }
html body .inventory-review-form textarea { display: block; width: 100%; min-height: 124px; margin: 0; padding: 12px 14px; resize: vertical; border: 1px solid #cddce0; border-radius: 9px; background: #fff; color: #203443; font: inherit; font-size: 14px; line-height: 1.7; }
html body .inventory-review-form textarea:focus { outline: 2px solid #0c8d8030; border-color: #00897b; outline-offset: 2px; }
html body .inventory-review-form textarea[aria-invalid="true"] { border-color: #c25643; }
.inventory-review-input-footer { min-height: 32px; display: flex; gap: 12px; justify-content: space-between; padding-top: 8px; font-size: 12px; }
#inventoryReviewError { color: #b54837; line-height: 1.5; }
#inventoryReviewCounter { color: #89979f; white-space: nowrap; margin-left: auto; }
html body .inventory-review-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 26px 22px; border-top: 1px solid #edf1f2; }
html body .inventory-review-footer button { min-height: 40px; min-width: 88px; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
html body .inventory-review-cancel { border: 1px solid #d5e1e4; color: #425762; background: #fff; }
html body .inventory-review-submit { border: 1px solid #00897b; color: #fff; background: #00897b; }
.inventory-review-dialog button:disabled { opacity: .6; cursor: wait; }
@media(max-width:480px) { html body .inventory-review-header { padding: 20px 18px 16px; }.inventory-review-body { padding: 18px 18px 8px; } html body .inventory-review-footer { padding: 16px 18px 18px; } }
