/* Mobile sales reuse the original controls, data and authorization. */
@media (max-width: 600px) {
  dialog:is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
  }
  dialog:is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm)[open] {
    display: flex;
    flex-direction: column;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-head {
    flex-shrink: 0;
    padding: 12px 14px;
    gap: 10px;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-head > div:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-head h2 {
    font-size: calc(20px * var(--ui-type-scale, 1));
    line-height: 1.4;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-head p {
    font-size: calc(12px * var(--ui-type-scale, 1));
    line-height: 1.5;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .close-btn {
    flex-shrink: 0;
    width: 44px;
    min-height: 44px;
    margin: -5px -5px -5px 0;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 14px;
    overflow: auto;
    overscroll-behavior: contain;
    scroll-padding: 12px;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-footer {
    flex-shrink: 0;
    gap: 8px;
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-footer > .small-copy {
    flex-basis: 100%;
    font-size: calc(12px * var(--ui-type-scale, 1));
    line-height: 1.5;
  }
  :is(.mobile-sales-editor, .mobile-sales-detail, .mobile-outbound-confirm) .modal-footer .btn {
    flex: 1 1 110px;
    min-height: 44px;
    font-size: calc(14px * var(--ui-type-scale, 1));
    padding: 10px 12px;
  }
  .mobile-sales-detail .modal-footer > .actions {
    flex: 1 1 100%;
    gap: 8px;
  }
  .mobile-sales-detail .modal-footer > .actions:empty { display: none; }
  :is(.mobile-sales-editor, .mobile-outbound-confirm) :is(input, select, textarea):not([type="hidden"]):not([type="checkbox"]) {
    min-width: 0;
    min-height: 44px;
    padding: 10px;
    font-size: calc(16px * var(--ui-type-scale, 1));
    line-height: 1.4;
  }
  .mobile-sales-editor input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }
  :is(.mobile-sales-editor, .mobile-outbound-confirm) .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .mobile-sales-editor .field label,
  .mobile-sales-editor .invoice-paid-label,
  .mobile-outbound-confirm .field label { font-size: calc(13px * var(--ui-type-scale, 1)); }
  .mobile-sales-editor .field small,
  .mobile-outbound-confirm .field small { font-size: calc(12px * var(--ui-type-scale, 1)); line-height: 1.5; }
  .mobile-sales-editor .document-form-section > summary {
    min-height: 44px;
    padding: 10px;
    font-size: calc(15px * var(--ui-type-scale, 1));
  }
  .mobile-sales-editor .document-section-caption { display: none; }
  .mobile-sales-editor .document-section-body,
  .mobile-sales-editor .document-form-section > .invoice-section-body { padding: 12px 0; }
  .mobile-sales-editor .document-line-actions .actions { width: 100%; }
  .mobile-sales-editor .document-line-actions .btn {
    flex: 1 1 110px;
    min-height: 44px;
    font-size: calc(13px * var(--ui-type-scale, 1));
  }
  .mobile-sales-editor #document-items-section .table-wrap { overflow: visible; }
  .mobile-sales-editor #document-items-section .line-table {
    display: block;
    min-width: 0;
    width: 100%;
    white-space: normal;
  }
  .mobile-sales-editor #document-items-section .line-table thead { display: none; }
  .mobile-sales-editor #document-lines { display: grid; gap: 14px; }
  .mobile-sales-editor #document-lines > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    min-width: 0;
  }
  .mobile-sales-editor #document-lines > tr > td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .mobile-sales-editor #document-lines > tr > td::before {
    display: block;
    margin-bottom: 6px;
    font-size: calc(12px * var(--ui-type-scale, 1));
    font-weight: 550;
    color: var(--muted);
    line-height: 1.5;
  }
  .mobile-sales-editor #document-lines .product-cell { grid-column: 1 / -1; }
  .mobile-sales-editor #document-lines .product-cell::before { content: '商品 *'; }
  .mobile-sales-editor #document-lines .location-cell::before { content: '库位 *'; }
  .mobile-sales-editor #document-lines .unit-cell::before { content: '输入单位 *'; }
  .mobile-sales-editor #document-lines .condition-cell::before { content: '库存状态'; }
  .mobile-sales-editor #document-lines .quantity-cell::before { content: '数量 *'; }
  .mobile-sales-editor #document-lines .price-cell::before { content: '未税成交单价 *'; }
  .mobile-sales-editor #document-lines :is(.quantity-cell, .price-cell) input { text-align: right; }
  .mobile-sales-editor #document-lines .sub-text {
    font-size: calc(12px * var(--ui-type-scale, 1));
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .mobile-sales-editor #document-lines .erp-product-picker-trigger {
    min-height: 48px;
    padding: 10px;
    font-size: calc(16px * var(--ui-type-scale, 1));
  }
  .mobile-sales-editor #document-lines .erp-product-picker-caption {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.5;
  }
  .mobile-sales-editor #document-lines > tr > td:last-child {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
  }
  .mobile-sales-editor .remove-line { width: 44px; height: 44px; font-size: calc(24px * var(--ui-type-scale, 1)); }
  .mobile-sales-editor :is(.config-note, .small-copy) { font-size: calc(12px * var(--ui-type-scale, 1)); line-height: 1.6; }
  .mobile-sales-editor :is(.invoice-address-grid, .invoice-payment-grid, .sales-pricing-layout) {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .mobile-sales-editor .sales-pricing-preview { padding: 12px; }
  .mobile-sales-editor .invoice-address-heading { flex-wrap: wrap; }
  .mobile-sales-editor :is(.invoice-address-heading, .invoice-payment-label) .link-btn {
    min-height: 44px;
    padding: 8px 0;
    font-size: calc(13px * var(--ui-type-scale, 1));
  }
  .mobile-sales-editor .invoice-calculated-value { min-height: 44px; font-size: calc(16px * var(--ui-type-scale, 1)); }
  .mobile-sales-detail .document-detail-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 6px;
    gap: 0 4px;
  }
  .mobile-sales-detail .document-detail-tabs > [role="tab"] { flex-shrink: 0; }
  .mobile-sales-detail .document-meta { gap: 12px; }
  .mobile-sales-detail .document-meta dd { font-size: calc(14px * var(--ui-type-scale, 1)); }
  .mobile-sales-detail .document-history-button { min-height: 44px; }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) .table-wrap:has(> :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components)) {
    overflow: visible;
  }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) {
    display: block;
    min-width: 0;
    width: 100%;
    white-space: normal;
    font-size: calc(14px * var(--ui-type-scale, 1));
  }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) thead { display: none; }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) tbody { display: grid; gap: 12px; }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 0;
  }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) tbody > tr > td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) tbody > tr > td:first-child {
    grid-column: 1 / -1;
    font-weight: 600;
  }
  :is(.mobile-sales-detail, .mobile-outbound-confirm) :is(.mobile-sale-items, .mobile-outbound-items, .mobile-shipment-progress, .mobile-partial-items, .mobile-shipment-components) tbody > tr > td:not(:first-child)::before {
    display: block;
    color: var(--muted);
    font-size: calc(12px * var(--ui-type-scale, 1));
    font-weight: 400;
    margin-bottom: 4px;
  }
  .mobile-sales-detail .mobile-sale-items td:nth-child(2)::before { content: '库位 / 状态'; }
  .mobile-sales-detail .mobile-sale-items td:nth-child(3)::before { content: '数量'; }
  .mobile-sales-detail .mobile-sale-items td:nth-child(4)::before { content: '未税成交单价'; }
  .mobile-sales-detail .mobile-sale-items td:nth-child(5)::before { content: '折扣前金额'; }
  .mobile-outbound-confirm .mobile-outbound-items td:nth-child(2)::before { content: '本次出库数量'; }
  .mobile-outbound-confirm .mobile-outbound-items td:nth-child(3)::before { content: '单位'; }
  .mobile-sales-detail .mobile-shipment-progress td:nth-child(2)::before { content: '订单基本数量'; }
  .mobile-sales-detail .mobile-shipment-progress td:nth-child(3)::before { content: '已实际发出'; }
  .mobile-sales-detail .mobile-shipment-progress td:nth-child(4)::before { content: '已取消未发'; }
  .mobile-sales-detail .mobile-shipment-progress td:nth-child(5)::before { content: '尚未发出'; }
  .mobile-outbound-confirm .mobile-partial-items td:nth-child(2)::before { content: '剩余'; }
  .mobile-outbound-confirm .mobile-partial-items td:nth-child(3)::before { content: '本次实发'; }
  .mobile-sales-detail .mobile-shipment-components td:nth-child(2) { grid-column: 1 / -1; }
  .mobile-sales-detail .mobile-shipment-components td:nth-child(2)::before { content: '实物组件'; }
  .mobile-sales-detail .mobile-shipment-components td:nth-child(3)::before { content: '库位'; }
  .mobile-sales-detail .mobile-shipment-components td:nth-child(4)::before { content: '已发基本数量'; }
  /* The picker is a sibling dialog, and only inherits this treatment from an open sales editor. */
  body:has(.mobile-sales-editor[open]) > .erp-product-picker-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  body:has(.mobile-sales-editor[open]) > .erp-product-picker-dialog :is(input, select) {
    min-height: 44px;
    font-size: calc(16px * var(--ui-type-scale, 1));
  }
  body:has(.mobile-sales-editor[open]) > .erp-product-picker-dialog :is(.erp-product-picker-secondary, .erp-product-picker-english-toggle) {
    min-height: 44px;
    font-size: calc(13px * var(--ui-type-scale, 1));
  }
  body:has(.mobile-sales-editor[open]) > .erp-product-picker-dialog .erp-product-picker-close {
    width: 44px;
    min-height: 44px;
  }
  body:has(.mobile-sales-editor[open]) > .erp-product-picker-dialog .erp-product-picker-name { font-size: calc(14px * var(--ui-type-scale, 1)); }
}
