/* Step labels are mobile-only; desktop retains the side-by-side picker. */
.mobile-picker-step-heading, .mobile-picker-step-help { display: none; }
/* Mobile-only contract: business forms and API handlers are shared with desktop.
   Keep this after app.css; desktop begins at 901px. */
@media (max-width: 900px) {
  :root {
    --mobile-nav-height: calc(72px + env(safe-area-inset-bottom, 0px));
    --mobile-actions-height: 112px;
  }
  html { scroll-padding-top: 16px; scroll-padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-actions-height)); }
  body { -webkit-text-size-adjust: 100%; }
  .sidebar { position: static; background: #fff; }
  .main-panel::before { display: none; }
  #workspaceTabs:not(.hidden) { display: flex; }
  .main-panel { padding-bottom: calc(var(--mobile-nav-height) + 24px); }
  .main-nav { height: var(--mobile-nav-height); box-sizing: border-box; box-shadow: 0 -2px 12px #0f172a0a; }
  .main-nav .mobile-bottom-nav { min-height: 0; padding: 2px 4px; }
  .main-nav .mobile-bottom-nav .mobile-nav-icon { flex-shrink: 0; }
  .tab-panel, .card, .inbound-sheet, .form-block, .filter-grid,
  .product-main, .document-top-meta, .search-picker-field { min-width: 0; max-width: 100%; }
  /* A filtered ancestor traps position:fixed; both order types need the reset. */
  [data-panel="inbound"] > .card, [data-panel="sales"] > .card { backdrop-filter: none; -webkit-backdrop-filter: none; }
  [data-panel="inbound"], [data-panel="sales"] { padding-bottom: var(--mobile-actions-height); }
  [data-panel="sales"] #saleForm { padding-bottom: 0; }
  [data-panel="inbound"] .inbound-sheet > .form-block,
  [data-panel="sales"] .inbound-sheet > .form-block,
  [data-panel="sales"] .inbound-sheet > .form-block > .table-wrap { max-height: none; overflow: visible; }
  .document-top-meta { flex-wrap: wrap; gap: 8px 16px; padding: 12px 14px; }
  .document-meta-item { min-width: 0; flex-wrap: wrap; }
  .document-meta-item strong { overflow-wrap: anywhere; }
  [data-panel="inbound"] .inbound-sheet,
  [data-panel="sales"] .inbound-sheet { width: 100%; grid-template-columns: minmax(0, 1fr); }
  [data-panel="inbound"] .inbound-head-grid label,
  [data-panel="sales"] .inbound-head-grid label {
    grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 0;
  }
  [data-panel="inbound"] .inbound-head-grid label::after,
  [data-panel="sales"] .inbound-head-grid label::after { display: none; }
  [data-panel="inbound"] .inbound-head-grid label > span,
  [data-panel="sales"] .inbound-head-grid label > span { font-size: 13px; font-weight: 600; }
  [data-panel="inbound"] .inbound-head-grid input,
  [data-panel="sales"] .inbound-head-grid input,
  [data-panel="inbound"] .inbound-head-grid select,
  [data-panel="sales"] .inbound-head-grid select {
    width: 100%; min-width: 0; max-width: 100%; text-align: left;
    border: 1px solid #dce4e1; background: #f8fafc; padding: 10px 12px;
  }
  [data-panel="inbound"] .inbound-head-grid select,
  [data-panel="sales"] .inbound-head-grid select { appearance: auto; -webkit-appearance: menulist; }
  input, select, textarea { min-width: 0; max-width: 100%; }
  .search-picker-field { grid-template-columns: minmax(0, 1fr) auto; }
  [data-panel="inbound"] .inbound-sheet > .form-block > .table-wrap,
  [data-panel="sales"] .inbound-sheet > .form-block > .table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow: visible; }
  /* Reset table layout itself, not just tbody: anonymous table cells otherwise
     retain intrinsic desktop column sizes and force the cards off screen. */
  [data-panel="inbound"] .inbound-sheet > .form-block > .table-wrap > table,
  [data-panel="sales"] .inbound-sheet > .form-block > .table-wrap > table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  .inbound-sheet > .form-block > .table-wrap > table > colgroup { display: none; }
  #inboundLinesBody, #saleLinesBody { display: grid; width: 100%; min-width: 0; }
  #inboundLinesBody tr, #saleLinesBody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
  #inboundLinesBody td, #saleLinesBody td {
    min-width: 0; width: auto; max-width: 100%; white-space: normal; overflow-wrap: anywhere; align-content: start;
  }
  #inboundLinesBody td[data-label], #saleLinesBody td[data-label] { grid-column: auto; }
  #inboundLinesBody td:is([data-label="操作"], [data-label="商品"], [data-label="序列号"], [data-label="批次号"]),
  #saleLinesBody td:is([data-label="操作"], [data-label="商品"], [data-label="序列号"], [data-label="赠送原因"]) { grid-column: 1 / -1; }
  #inboundLinesBody td[data-label="操作"]::before,
  #saleLinesBody td[data-label="操作"]::before,
  #inboundLinesBody td[data-label="商品"]::before,
  #saleLinesBody td[data-label="商品"]::before { content: none; }
  .inbound-line-picker-btn { white-space: normal; overflow-wrap: anywhere; text-align: left; }
  .serial-input-wrap { min-width: 0; }
  .action-cell .table-action { min-height: 40px; min-width: 44px; }
  .sale-gift-toggle { width: fit-content; min-height: 36px; }
  .inbound-summary-bar strong { overflow-wrap: anywhere; }
  .inbound-foot, [data-panel="sales"] .inbound-foot,
  .document-saved-actions, [data-panel="sales"] .document-saved-actions {
    position: fixed; left: 0; right: 0; bottom: var(--mobile-nav-height); z-index: 70;
    margin: 0; padding: 10px 12px; border-radius: 0; background: #fff;
    box-shadow: 0 -2px 12px #0f172a0d; backdrop-filter: none;
  }
  .inbound-foot, [data-panel="sales"] .inbound-foot { grid-template-columns: minmax(0, .85fr) minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
  /* Editing is total + cancel + save; draft saving is only for new documents. */
  .inbound-foot:has(> #cancelInboundEditBtn:not(.hidden)) > .mobile-draft-btn,
  .inbound-foot:has(> #cancelSaleEditBtn:not(.hidden)) > .mobile-draft-btn { display: none; }
  .inbound-foot .document-submit-feedback { max-height: 80px; overflow-y: auto; text-align: left; }
  [data-panel="inbound"]:has(#inboundSubmitFeedback:not(.hidden)),
  [data-panel="sales"]:has(#saleSubmitFeedback:not(.hidden)) { --mobile-actions-height: 208px; }
  #toast {
    top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; left: 12px; right: 12px;
    max-width: none; max-height: 30vh; overflow-y: auto; font-size: 14px;
  }
  .inbound-foot > *, .document-saved-actions > * { min-width: 0; }
  .inbound-foot button { font-size: 14px; padding: 10px 6px; white-space: normal; }
  .mobile-foot-total strong { font-size: 18px; overflow-wrap: anywhere; }
  .document-saved-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .document-saved-actions .saved-doc-no { grid-column: 1 / -1; font-size: 12px; overflow-wrap: anywhere; }
  .document-saved .inbound-foot { display: none; }
  [data-panel="purchase-documents"] .filter-bar,
  [data-panel="sale-documents"] .filter-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 14px; }
  .purchase-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .purchase-filter-grid > :is(input, select) { width: 100%; }
  .purchase-filter-grid > :is(.search-input, [id$="StartDate"], [id$="EndDate"]) { grid-column: 1 / -1; }
  [data-panel="purchase-documents"] .filter-bar > .toolbar,
  [data-panel="sale-documents"] .filter-bar > .toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  [data-panel="purchase-documents"] .filter-bar .primary-btn,
  [data-panel="sale-documents"] .filter-bar .primary-btn { display: inline-flex; }
  .filter-bar .toolbar > button { min-width: 0; width: 100%; padding: 10px 6px; }
  #purchaseDocumentsMobileList, #saleDocumentsMobileList { padding: 12px; }
  .mobile-doc-card { min-width: 0; overflow: hidden; }
  .mobile-doc-card-head strong, .mobile-doc-meta > *, .mobile-doc-amount > * { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
  #purchaseDocumentsMobileList .mobile-doc-card-head,
  #saleDocumentsMobileList .mobile-doc-card-head { min-width: 0; flex-wrap: nowrap; overflow: hidden; }
  #purchaseDocumentsMobileList .document-list-mobile-title,
  #saleDocumentsMobileList .document-list-mobile-title {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    overflow-wrap: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-doc-card-head .status-chip { flex-shrink: 0; }
  .mobile-doc-meta, .mobile-doc-amount { flex-wrap: wrap; }
  .mobile-doc-meta > *, .mobile-doc-amount > * { flex: 1 1 130px; }
  .mobile-doc-amount { font-size: 15px; }
  [data-panel="inventory-query"] .segmented-control { display: flex; flex-wrap: wrap; margin: 0 14px; }
  [data-panel="inventory-query"] .segmented-btn { flex: 1; min-height: 44px; padding: 8px 4px; }
  [data-panel="inventory-query"] .inventory-filter-grid { grid-template-columns: minmax(0, 1fr); }
  /* Preserve serial/history queries without a second copy of inventory state. */
  #inventoryHistoryWrap:not(.hidden), #inventorySerialWrap:not(.hidden) { display: block !important; padding: 10px; overflow: visible; }
  #inventoryHistoryWrap table, #inventorySerialWrap table { display: block; min-width: 0; width: 100%; }
  #inventoryHistoryWrap thead, #inventorySerialWrap thead { display: none; }
  #inventoryHistoryBody, #inventorySerialBody { display: grid; gap: 12px; }
  #inventoryHistoryBody tr, #inventorySerialBody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  #inventoryHistoryBody td, #inventorySerialBody td { display: grid; min-width: 0; padding: 6px; border: 0; white-space: normal; overflow-wrap: anywhere; gap: 4px; }
  #inventoryHistoryBody td::before, #inventorySerialBody td::before { content: attr(data-label); font-size: 12px; color: var(--muted); }
  #inventoryHistoryBody td[colspan], #inventorySerialBody td[colspan] { grid-column: 1 / -1; }
  .modal-dialog { max-width: 100%; max-height: calc(100dvh - 18px); }
  #counterpartyPickerModal { z-index: 2200; padding: 8px; }
  /* 高度按内容走，**不能写死 100dvh**。
     mark 2026-10-07：搜出只有一条（比如「闲鱼」）时，弹窗被撑满整屏、
     下面一大片空白，看着像坏了。
     桌面端本来就是 max-height: min(56vh, 520px)，移动端不该另搞一套。
     现在：内容少就贴合内容，内容多就封顶 76dvh 并可滚动。
     max-height 用 dvh（动态视口）而不是 vh —— 移动端浏览器地址栏收起/展开时
     vh 不跟着变，会出现「底部按钮被地址栏盖住」。 */
  #counterpartyPickerModal .counterparty-picker-modal { display: flex; flex-direction: column; width: min(680px, 100%); max-height: 76dvh; margin: 0 auto; overflow: hidden; border-radius: 18px; }
  #counterpartyPickerModal .modal-head { flex: 0 0 auto; padding: 16px 18px 12px; }
  #counterpartyPickerModal .modal-head > div:first-child { min-width: 0; }
  #counterpartyPickerModal .modal-head p { font-size: 13px; line-height: 1.45; }
  #counterpartyPickerModal .modal-form { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; gap: 12px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); overflow: hidden; }
  #counterpartyPickerSearch { flex: 0 0 auto; width: 100%; min-height: 48px; font-size: 16px; background: #fff; }
  /* 列表按内容撑开、超出才滚。不写 flex:1 1 auto —— 那会让它在弹窗内被拉满，
     一条结果时又变成一大片空白（就是 mark 说的「强制占满」）。 */
  #counterpartyPickerOptions { flex: 0 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
  #counterpartyPickerModal .modal-foot { flex: 0 0 auto; padding: 10px 0 0; }
  .inbound-picker-modal, #purchaseDetailModal .purchase-detail-modal,
  #saleDetailModal .purchase-detail-modal, #inventoryPurchaseDocsModal .category-modal { height: 100dvh; max-height: 100dvh; width: 100%; }
  .modal-foot { flex-wrap: wrap; }
  .modal-dialog > .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .purchase-detail-content .mobile-detail-cards { display: grid; gap: 10px; }
  .mobile-detail-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-detail-card, .mobile-detail-card-grid > span { min-width: 0; overflow-wrap: anywhere; }
  #purchaseDetailModal .document-detail-summary .detail-grid,
  #saleDetailModal .document-detail-summary .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #purchaseDetailModal .document-detail-summary .detail-item,
  #saleDetailModal .document-detail-summary .detail-item { padding: 9px 10px; }
  #purchaseDetailModal .document-detail-summary .detail-item span,
  #saleDetailModal .document-detail-summary .detail-item span { margin-bottom: 4px; }
  #purchaseDetailModal .document-detail-summary .detail-item.wide,
  #saleDetailModal .document-detail-summary .detail-item.wide { grid-column: 1 / -1; }

  /* Show the same stock/SKU/service choices as desktop without a wide table. */
  .inbound-picker-modal table { display: block; width: 100%; min-width: 0; }
  .inbound-picker-modal .picker-selection-panel .table-wrap { max-height: none; overflow: visible; }
  .picker-selection-panel tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  .picker-selection-panel tbody tr.selected { border-color: #3f88ea; background: #eff6ff; }
  .picker-selection-panel td { display: grid; min-width: 0; padding: 4px; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .picker-selection-panel td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .picker-selection-panel td:is([data-label="操作"], [data-label="商品名称"], [data-label="序列号"], [colspan]) { grid-column: 1 / -1; }
  .picker-selection-panel td[data-label="操作"]::before { content: none; }
  .picker-selection-panel .table-action { min-height: 44px; }
  .picker-product-row { min-width: 0; grid-template-columns: minmax(0, 1fr) auto; }
  .picker-product-row::before { display: none; }
  .inbound-picker-modal .picker-product-row td { min-width: 0; grid-column: 1 / -1; grid-row: auto; white-space: normal; overflow-wrap: anywhere; }
  .inbound-picker-modal .picker-product-row td:nth-child(6) { grid-column: 2; }
  /* No decorative fake filter controls, and do not hide the service/product filter. */
  .inbound-picker-modal .filter-bar::after { display: none; }
  .inbound-picker-modal select { display: block; min-height: 44px; }
  #purchaseDocSupplier, #saleDocCustomer { grid-column: 1 / -1; }

  .inbound-picker-modal { display: flex; flex-direction: column; }
  .inbound-picker-modal > .modal-head { flex: 0 0 auto; }
  .inbound-picker-modal > .modal-form { display: block; flex: 1; min-height: 0; height: auto; max-height: none; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .inbound-picker-modal .picker-layout, .inbound-picker-modal .product-main { display: block; height: auto; overflow: visible; }
  .inbound-picker-modal .picker-product-row { gap: 5px 10px; min-height: 0; }
  .inbound-picker-modal .picker-product-row td:is(:nth-child(3), :nth-child(4)) { grid-column: auto; }
  .inbound-picker-modal .picker-product-row.selected td { background: transparent; box-shadow: none; }
  .inbound-picker-modal .picker-product-row.selected td:nth-child(6) { background: #3f88ea; }
  .inbound-picker-modal .inbound-picker-filters select { grid-column: 1 / -1; width: 100%; }

  /* Product management uses the same rows, filters, forms, and permission checks. */
  .main-nav { grid-template-columns: repeat(6, minmax(0, 1fr)); padding-left: 3px; padding-right: 3px; }
  .product-nav-desktop-label { display: none; }
  .product-nav-mobile-label { display: inline; }
  .mobile-bottom-products .mobile-nav-icon::before { width: 21px; height: 21px; border: 2px solid currentColor; border-radius: 4px; }
  .mobile-bottom-products .mobile-nav-icon::after { width: 9px; height: 7px; top: 4px; border: 2px solid currentColor; border-top: 0; }
  [data-panel="products"] .section-head { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 14px; }
  [data-panel="products"] .section-head .toolbar { display: flex; flex-wrap: wrap; width: 100%; gap: 8px; }
  [data-panel="products"] .toolbar > button { min-height: 44px; }
  [data-panel="products"] :is(#downloadTemplateBtn, #exportProductsBtn, #importProductsBtn, #bulkEditProductCategoriesBtn, #deleteSelectedProductsBtn, #toggleProductDetailBtn) { display: none; }
  [data-panel="products"] .filter-bar { padding-bottom: 14px; }
  [data-panel="products"] .filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  [data-panel="products"] .filter-grid :is(input, select) { min-width: 0; width: 100%; min-height: 44px; font-size: 16px; }
  [data-panel="products"] :is(#productSearchInput, #filterStore) { grid-column: 1 / -1; }
  [data-panel="products"].active { display: block !important; }
  #mobileProductCategory { display: block; }
  #productLayout { display: flex; flex-direction: column; height: auto; min-height: 0; overflow: visible; padding: 0 14px 14px; gap: 14px; }
  #productLayout :is(.pane-resizer, #productTreePanel) { display: none; }
  #productLayout .product-main { display: block; height: auto; overflow: visible; }
  #productLayout .product-table-wrap { height: auto; max-height: none; overflow: visible; border: 0; }
  #productLayout table { display: block; width: 100% !important; min-width: 0 !important; }
  #productLayout thead { display: none; }
  #productsBody { display: grid; gap: 12px; }
  #productsBody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
  #productsBody tr.selected { border-color: #3f88ea; background: #eff6ff; }
  #productsBody td { display: grid; width: auto !important; min-width: 0 !important; padding: 6px; border: 0; gap: 4px; white-space: normal; overflow-wrap: anywhere; }
  #productsBody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  #productsBody td:is([data-label="商品名称"], [data-label="分类"], [data-label="操作"], [colspan]) { grid-column: 1 / -1; }
  #productsBody td[data-label="商品名称"] { font-weight: 700; font-size: 16px; }
  #productsBody td[data-label="选择"], #productsBody :is([data-toggle-product], [data-delete-product]) { display: none; }
  #productsBody .action-cell { flex-wrap: wrap; }
  #productsBody .table-action { min-height: 44px; padding: 8px 14px; }
  #productLayout :is(.pagination-bar, .pagination-controls) { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
  #productLayout .pagination-controls :is(button, select) { min-height: 44px; }
  #productDetailPanel { height: auto; min-width: 0; width: 100%; scroll-margin-top: 12px; }
  #productLayout.detail-collapsed #productDetailPanel { display: none; }
  #productDetailPanel :is(h4, p, strong, .chip-list) { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
  #productDetailPanel .product-detail-grid { grid-template-columns: minmax(0, 1fr); }
  #productModal { padding: 0; z-index: 2100; }
  #productModal > .modal-dialog { width: 100%; height: 100dvh; max-height: 100dvh; max-width: 100%; margin: 0; border-radius: 0; display: flex; flex-direction: column; transform: none !important; top: auto !important; left: auto !important; }
  #productModal .modal-head { flex: 0 0 auto; padding: 14px; align-items: start; }
  #productModal .modal-head > div:first-child { min-width: 0; }
  #productModal .modal-head p { font-size: 12px; }
  #productForm { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0; }
  #productForm .form-block { padding: 14px; margin: 0 0 12px; }
  #productForm .product-form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
  #productForm .product-form-grid label { min-width: 0; }
  #productForm :is(input:not([type="checkbox"]), select) { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; font-size: 16px; }
  #productForm input[type="checkbox"] { width: 22px; height: 22px; }
  #productForm :is(.block-head, .sku-table-toolbar, .sku-attr-tabs, .sku-attr-sections, .rule-panel) { min-width: 0; flex-wrap: wrap; overflow-wrap: anywhere; }
  #productForm :is(#openRuleConfigInlineBtn, #gotoCustomFieldsBtn, #gotoRulesBtn, #openBrandManagerBtn) { display: none; }
  #productForm .modal-foot { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--line); }
  #productForm .modal-foot button { flex: 1 1 110px; min-height: 44px; }
  #productForm .sku-config-table-wrap { max-height: none; overflow: visible; }
  #productForm .sku-config-table { display: block; min-width: 0; width: 100%; }
  #productForm .sku-config-table thead { display: none; }
  #skuRowsBody { display: grid; gap: 12px; }
  #skuRowsBody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
  #skuRowsBody td { display: grid; min-width: 0; padding: 6px; gap: 6px; border: 0; white-space: normal; overflow-wrap: anywhere; }
  #skuRowsBody td::before { content: attr(data-label); font-size: 12px; color: var(--muted); }
  #skuRowsBody td:is([data-label="SKU编码"], [data-label="属性组合"], [data-label="条码"], [colspan]) { grid-column: 1 / -1; }
  /* Stacked repair fields must size their card, not overflow a desktop height cap. */
  #saleForm .settlement-panel { height: auto; max-height: none; min-width: 0; }
  #saleForm .settlement-panel-head { flex-wrap: wrap; align-items: flex-start; }
  #saleForm .settlement-panel-head > * { min-width: 0; overflow-wrap: anywhere; }
  #saleForm .compact-fee-grid { grid-template-columns: minmax(0, 1fr); }
  #saleEmployeeSearch { display: none; }
  #saleEmployeeSelect { display: block; min-height: 44px; font-size: 16px; }
  .inbound-picker-modal .catalog-tree :is(.tree-row, .tree-leaf) { min-height: 44px; font-size: 14px; }
  .inbound-picker-modal .picker-category-done { display: block; position: sticky; bottom: 0; background: #fff; padding: 10px 0; }
  .inbound-picker-modal .picker-category-done button { width: 100%; min-height: 44px; }
  /* Category paths are not quantities; the stock badge is the sixth cell. */
  #saleProductPickerModal .picker-product-row td:nth-child(5)::before { content: "分类 "; }
  .inbound-picker-modal .picker-layout .catalog-tree.mobile-open { display: flex; flex-direction: column; top: 66px; height: auto; max-height: min(68dvh, calc(100dvh - 170px)); padding: 0; }
  .inbound-picker-modal .catalog-tree .tree-search-input { flex: 0 0 auto; min-height: 44px; font-size: 16px; margin: 12px; width: calc(100% - 24px); }
  .inbound-picker-modal .catalog-tree .tree-scroll { display: block; flex: 1 1 auto; min-height: 0; height: auto; max-height: none; padding: 0 12px 12px; overflow-y: auto; }
  #saleForm .compact-payment-rows { max-height: none; overflow: visible; scrollbar-gutter: auto; }
  #saleForm .compact-payment-rows .icon-mini-btn { width: 44px; height: 44px; min-height: 44px; font-size: 16px; }

  #workspaceTabs { position: sticky; top: 0; z-index: 80; align-items: center; gap: 6px; padding: 7px 8px; margin: 0 -2px 10px; max-width: 100%; min-height: 58px; background: #f5f8fb; border: 0; overscroll-behavior-x: contain; scrollbar-width: none; }
  #workspaceTabs .workspace-tab-list { gap: 6px; scrollbar-width: none; }
  #workspaceTabs .workspace-tab { min-height: 44px; max-width: min(225px, calc(100vw - 145px)); border: 1px solid #e0e7ee; border-radius: 12px; background: #fff; color: #64748b; }
  #workspaceTabs .workspace-tab.active { border-color: #81cbb6; color: #12664e; background: #ebf8f2; }
  #workspaceTabs .workspace-tab-label { min-height: 44px; padding: 9px 4px 9px 12px; font-size: 13px; }
  #workspaceTabs .workspace-tab-close { flex-basis: 44px; width: 44px; height: 44px; font-size: 20px; }
  #workspaceTabs .workspace-new { position: static; min-height: 44px; padding: 8px 10px; margin: 0; font-size: 13px; box-shadow: none; }
  .document-saved .inbound-foot, [data-panel="sales"] .document-saved .inbound-foot { display: none !important; }
  .document-saved > .document-saved-actions { display: grid; z-index: 75; }
  .mobile-module-icon:has(svg)::before, .mobile-module-icon:has(svg)::after { content: none; }
  .mobile-module-icon:has(svg) { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: #eaf6f1; color: #187759; box-shadow: inset 0 0 0 1px #18775912; }
  .mobile-module-icon svg { width: 27px; height: 27px; }
  .mobile-module-icon-sale:has(svg) { color: #246ac5; background: #eaf2ff; }
  .mobile-module-icon-product:has(svg) { color: #7d51c7; background: #f2edfb; }
  .mobile-module-icon-document:has(svg) { color: #b77c22; background: #fcf3e1; }
  .mobile-module-icon-inventory:has(svg) { color: #267e93; background: #eaf6f9; }
  .mobile-module-card { border: 1px solid #e6edf0; box-shadow: 0 4px 16px #1e3a4c05; }
  [data-panel="inbound"] .inbound-sheet, [data-panel="sales"] .inbound-sheet { gap: 10px; }
  [data-panel="inbound"] .form-block, [data-panel="sales"] .form-block { padding: 12px; margin-bottom: 0; border-radius: 14px; }
  .document-top-meta { gap: 6px 12px; padding: 10px 12px; font-size: 12px; }
  [data-panel="inbound"] .inbound-head-grid, [data-panel="sales"] .inbound-head-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  [data-panel="inbound"] .inbound-head-grid label, [data-panel="sales"] .inbound-head-grid label { padding: 0; gap: 5px; }
  [data-panel="inbound"] .inbound-head-grid :is(input, select), [data-panel="sales"] .inbound-head-grid :is(input, select) { min-height: 44px; padding: 8px; font-size: 16px; }
  .inbound-head-grid label:has([name="summary"]), .inbound-head-grid label:has([name="note"]), .inbound-head-grid label:has(.search-picker-field) { grid-column: 1 / -1; }
  #inboundLinesBody, #saleLinesBody { gap: 10px; }
  #inboundLinesBody tr, #saleLinesBody tr { padding: 10px; gap: 6px 10px; border-radius: 12px; }
  #inboundLinesBody td, #saleLinesBody td { padding: 2px 0; }
  #saleLinesBody td[data-label="赠送原因"]:has(input[readonly]) { display: none; }
  #productSaveFeedback { max-height: 90px; overflow-y: auto; }
  /* Clearly separated mobile document cards; desktop keeps its dense table. */
  [data-panel="sales"] { --line-accent: #326bb0; --line-tint: #eef5ff; --line-border: #c5d5e9; --line-stage: #eaf0f7; }
  [data-panel="inbound"] { --line-accent: #217867; --line-tint: #edf8f4; --line-border: #bedbcf; --line-stage: #e9f1ee; }
  :is([data-panel="sales"], [data-panel="inbound"]) > .card { background: #f3f6fa; border: 0; box-shadow: none; }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-sheet { gap: 14px; }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-sheet > .form-block { border: 1px solid #e0e7ef; background: #fff; border-radius: 16px; }
  :is([data-panel="sales"], [data-panel="inbound"]) .document-top-meta { margin: 0 10px; padding: 12px; border: 1px solid #dce5ef; border-radius: 12px; background: #edf2f8; color: #5b6a7c; }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-sheet > .document-lines-block { padding: 14px 10px; border: 1px solid var(--line-border); background: var(--line-stage); border-radius: 16px; }
  :is([data-panel="sales"], [data-panel="inbound"]) .document-lines-block .block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; padding: 0 2px 12px; margin: 0; }
  .document-lines-block .block-head h4 { margin: 0; font-size: 16px; color: #263a51; }
  .document-lines-tip { display: inline; font-size: 11px; color: #64748b; }
  :is(#inboundLinesBody, #saleLinesBody) { gap: 18px; }
  :is(#inboundLinesBody, #saleLinesBody) tr.document-line-card { position: relative; padding: 12px; gap: 10px 12px; border: 1px solid var(--line-border); border-top: 4px solid var(--line-accent); border-radius: 14px; background: linear-gradient(var(--line-tint) 0 57px, #fff 57px); box-shadow: 0 4px 10px #26384c0d; scroll-margin-top: 76px; }
  :is(#inboundLinesBody, #saleLinesBody) tr.document-line-empty { border-top-color: #9eafbf; background: linear-gradient(#f1f5f9 0 57px, #fff 57px); }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="操作"],
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="操作"] .action-cell { display: contents; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-heading { display: flex; grid-column: 1 / -1; order: 0; min-height: 32px; align-items: center; gap: 8px; padding: 0 72px 10px 0; margin-bottom: 2px; color: #34465c; }
  .document-line-heading strong { font-size: 13px; white-space: nowrap; }
  .document-line-heading small { font-size: 11px; color: #738395; }
  .document-line-number { display: inline-grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; background: var(--line-accent); color: #fff; border-radius: 9px; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-delete { position: absolute; top: 5px; right: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: auto; min-width: 66px; min-height: 44px; margin: 0; padding: 8px 6px; color: #af4752; border: 0; background: transparent; box-shadow: none; border-radius: 8px; font-size: 12px; }
  .document-line-delete-icon { display: inline-flex; }
  .document-line-delete-icon svg { width: 16px; height: 16px; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-add { display: flex; grid-column: 1 / -1; order: 20; justify-content: center; align-items: center; gap: 6px; width: 100%; min-height: 44px; padding: 10px; margin: 4px 0 0; background: var(--line-tint); color: var(--line-accent); border: 1px dashed var(--line-border); border-radius: 10px; box-shadow: none; font-size: 13px; font-weight: 650; }
  .document-line-add-label { display: inline; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="商品"] { order: 3; }
  :is(#inboundLinesBody, #saleLinesBody) .inbound-line-picker-btn { display: flex; justify-content: flex-start; align-items: center; min-height: 46px; width: 100%; margin: 0; padding: 10px 12px; border: 1px solid var(--line-border); border-radius: 10px; background: #fff; color: #24364b; text-align: left; font-size: 15px; line-height: 1.5; box-shadow: none; }
  :is(#inboundLinesBody, #saleLinesBody) .inbound-line-picker-btn::after { content: "›"; margin-left: auto; padding-left: 6px; font-size: 20px; color: var(--line-accent); }
  #saleLinesBody td[data-label="赠品"] { display: flex; align-items: center; order: 4; grid-column: 1 / -1; justify-content: flex-start; gap: 8px; min-height: 36px; padding: 0; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="商品编号"] { order: 5; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="分类"] { order: 6; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="属性"] { order: 7; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="序列号"] { order: 8; }
  #inboundLinesBody td[data-label="批次号"] { order: 9; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="数量"] { order: 10; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="单位"] { order: 11; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="单价"] { order: 12; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="金额"] { order: 13; align-self: stretch; align-content: center; gap: 4px; padding: 8px 10px; background: var(--line-tint); color: var(--line-accent); border: 1px solid var(--line-border); border-radius: 10px; font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }
  #saleLinesBody td[data-label="赠送原因"] { order: 14; }
  :is(#inboundLinesBody, #saleLinesBody) td::before { font-weight: 500; color: #7a8898; font-size: 11px; line-height: 16px; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field { display: grid; grid-template-rows: 16px minmax(44px, auto); align-content: stretch; gap: 6px; min-width: 0; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--readonly { color: #59697a; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--readonly .document-line-value,
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--readonly:not(:has(.document-line-value)) { align-items: center; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-value { display: flex; align-items: center; min-height: 44px; width: 100%; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field > :is(input, button, .serial-input-wrap, .document-line-value) { min-width: 0; max-width: 100%; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--unit .document-line-value { padding: 9px 10px; border: 1px solid #e2e8f0; border-radius: 9px; background: #f1f4f7; color: #526171; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--computed { align-self: stretch; align-content: stretch; gap: 6px; padding: 0; background: transparent; border: 0; color: var(--line-accent); font-size: inherit; font-weight: inherit; }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--computed::before { color: var(--line-accent); }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-field--computed .document-line-value { padding: 9px 10px; border: 1px solid var(--line-border); border-radius: 9px; background: var(--line-tint); font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }
  :is(#inboundLinesBody, #saleLinesBody) input:not([type="checkbox"]) { min-height: 44px; padding: 9px 10px; background: #fff; border: 1px solid #cbd6e2; border-radius: 9px; font-size: 16px; box-shadow: inset 0 1px 2px #0f172a08; }
  :is(#inboundLinesBody, #saleLinesBody) input[readonly]:not([type="checkbox"]),
  :is(#inboundLinesBody, #saleLinesBody) input:disabled:not([type="checkbox"]) { background: #f1f4f7; border-color: #e2e8f0; color: #7a8794; box-shadow: none; }
  :is(#inboundLinesBody, #saleLinesBody) input:focus-visible, :is(#inboundLinesBody, #saleLinesBody) button:focus-visible { outline: 2px solid var(--line-accent); outline-offset: 2px; }
  .document-lines-block > .inbound-summary-bar { margin-top: 14px; padding: 12px; border: 1px solid var(--line-border); border-radius: 11px; background: #fff; gap: 6px; flex-wrap: wrap; }
  .document-lines-block > .inbound-summary-bar strong { color: var(--line-accent); }
  :is(#inboundLinesBody, #saleLinesBody) .document-line-add:disabled,
  :is(#inboundLinesBody, #saleLinesBody) .document-line-delete:disabled { display: none; }

  /* Unified mobile rhythm: generous BETWEEN modules, compact WITHIN modules. */
  :root { --mobile-section-gap: 24px; --mobile-card-gap: 16px; --mobile-field-gap: 12px; --mobile-surface: #fff; --mobile-canvas: #f1f4f8; }
  :is([data-panel="mobile-home"], [data-panel="mobile-documents"], [data-panel="products"], [data-panel="sale-documents"], [data-panel="purchase-documents"], [data-panel="inventory-query"], [data-panel="sales"], [data-panel="inbound"]) { background: var(--mobile-canvas); }
  .mobile-home-top { padding: 8px 14px 0; margin-bottom: 20px; }
  .mobile-module-grid { gap: var(--mobile-card-gap); padding: 0 12px 20px; }
  .mobile-module-card { min-width: 0; padding: 18px 12px; border-radius: 16px; }
  .mobile-module-card :is(strong, small) { white-space: normal; overflow-wrap: anywhere; }
  .mobile-page-head { margin-bottom: 18px; padding: 14px; }

  /* Reset the old first-section zero padding / separator borders explicitly. */
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-sheet { gap: var(--mobile-section-gap); }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-sheet > .form-block,
  :is([data-panel="sales"], [data-panel="inbound"]) .form-block:first-of-type { padding: 16px 12px; box-shadow: 0 2px 8px #26384c05; }
  :is([data-panel="sales"], [data-panel="inbound"]) .document-top-meta { margin: 0 10px; padding: 14px 12px; }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-head-grid { gap: var(--mobile-field-gap); }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-head-grid label { min-height: 0; border: 0; padding: 0; align-content: start; gap: 6px; }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid > label { grid-column: span 3; }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid > label:is(.full, :has(.search-picker-field)) { grid-column: 1 / -1; }
  :is(#saleForm, #inboundForm) .custom-doc-fields > label { grid-column: span 3; }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid > :is(#saleSummaryField, #inboundSummaryField) { grid-column: 1 / span 3; }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid > :is(#saleNoteField, #inboundNoteField) { grid-column: 4 / span 3; }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid:has(.custom-doc-fields > label input[type="number"]) > :is(#saleSummaryField, #inboundSummaryField) { grid-column: 1 / span 2; }
  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid:has(.custom-doc-fields > label input[type="number"]) > :is(#saleNoteField, #inboundNoteField) { grid-column: 3 / span 2; }
  :is(#saleForm, #inboundForm) .custom-doc-fields > label:has(input[type="number"]) { grid-column: span 2; }
  :is(#saleSummaryField, #saleNoteField, #inboundSummaryField, #inboundNoteField) input { text-overflow: ellipsis; }
  :is([data-panel="sales"], [data-panel="inbound"]) .block-head { min-height: 0; padding: 0 0 12px; margin: 0; gap: 10px; }
  :is([data-panel="sales"], [data-panel="inbound"]) .inbound-head-grid label.mobile-expandable-field { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
  .mobile-expandable-field > :is(input, textarea) { grid-column: 1 / -1; grid-row: 2; }
  .mobile-expandable-field > span { grid-column: 1; grid-row: 1; min-width: 0; }
  .mobile-field-expand { display: inline-flex; grid-column: 2; grid-row: 1; align-items: center; justify-content: center; min-width: 36px; min-height: 44px; padding: 0 3px; margin: -10px 0; border: 0; border-radius: 6px; background: transparent; color: #276aa8; font-size: 11px; white-space: nowrap; }
  .mobile-field-expand:focus-visible { outline: 2px solid #276aa8; outline-offset: 1px; }
  #saleForm .settlement-compact-grid { gap: var(--mobile-card-gap); }
  #saleForm .settlement-panel { padding: 14px 12px; border-radius: 14px; box-shadow: none; }
  #saleForm .settlement-panel-head { margin-bottom: 12px; gap: 6px; }
  #saleForm .compact-fee-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #saleRepairModeField { grid-column: 1 / -1; }
  :is(#saleForm, #inboundForm) .payment-rows { gap: 14px; }
  :is(#saleForm, #inboundForm) .payment-row { margin-top: 0; border-radius: 12px; box-shadow: none; }
  :is(#saleForm, #inboundForm) .inbound-summary-bar { margin-top: 12px; }

  /* Query filters and results share one spacing system across all list pages. */
  :is([data-panel="products"], [data-panel="sale-documents"], [data-panel="purchase-documents"], [data-panel="inventory-query"]) .section-head { margin-bottom: 16px; border-bottom: 0; padding: 16px 14px; }
  :is([data-panel="products"], [data-panel="sale-documents"], [data-panel="purchase-documents"], [data-panel="inventory-query"]) .filter-bar { margin: 0 10px var(--mobile-section-gap); padding: 14px 12px; border: 1px solid #e0e7ef; border-radius: 14px; background: #fff; }
  :is(.purchase-filter-grid, .inventory-filter-grid, [data-panel="products"] .filter-grid) { gap: var(--mobile-field-gap); }
  :is([data-panel="products"], [data-panel="sale-documents"], [data-panel="purchase-documents"], [data-panel="inventory-query"]) .filter-bar :is(input, select) { min-height: 44px; font-size: 16px; }
  [data-panel="inventory-query"] .segmented-control { margin: 0 10px 18px; gap: 6px; }
  :is(#purchaseDocumentsMobileList, #saleDocumentsMobileList, #inventorySummaryMobileList) { display: grid; gap: var(--mobile-card-gap); padding: 0 10px 20px; }
  :is(.mobile-doc-card, .mobile-detail-card) { border: 1px solid #dce4ed; border-radius: 14px; padding: 14px; background: #fff; box-shadow: 0 3px 10px #26384c05; }
  .mobile-doc-card :is(.mobile-doc-meta, .mobile-doc-amount) { gap: 8px 12px; }
  :is(#productsBody, #inventoryHistoryBody, #inventorySerialBody, #skuRowsBody) { gap: var(--mobile-card-gap); }
  :is(#productsBody, #inventoryHistoryBody, #inventorySerialBody) tr { border-radius: 14px; border-color: #dce4ed; }
  :is(.pagination-bar, .picker-pagination) { margin-top: 14px; gap: 8px; }

  /* Product editing and detail/picker dialogs: never squeeze sections together. */
  #productForm { background: var(--mobile-canvas); padding: 0 10px; }
  #productForm .form-block { margin: 0 0 var(--mobile-section-gap); padding: 16px 12px; border: 1px solid #e0e7ef; border-radius: 14px; }
  #productForm .block-head { min-height: 0; padding: 0 0 14px; }
  #productForm .product-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
  #productForm .product-form-grid > :is(.wide, .full), #productForm .product-form-grid > label:has([name="product_name"], [name="note"], #namePreview, .search-picker-field) { grid-column: 1 / -1; }
  #productForm .mobile-expandable-field { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
  .purchase-detail-content { background: var(--mobile-canvas); }
  .purchase-detail-content > .form-block { margin-bottom: var(--mobile-section-gap); padding: 16px 12px; border: 1px solid #e0e7ef; border-radius: 14px; }
  .purchase-detail-content .mobile-detail-cards { gap: var(--mobile-card-gap); }
  .purchase-detail-content .detail-grid { gap: 14px; }
  .purchase-detail-content :is(.detail-item, .detail-item strong) { min-width: 0; overflow-wrap: anywhere; }
  .inbound-picker-modal .product-main > :is(.picker-query-panel, .picker-list-panel, .picker-attribute-section) { margin-bottom: var(--mobile-section-gap); }
  .inbound-picker-modal .picker-module-head { gap: 8px; padding: 12px 10px; }
  .inbound-picker-modal .picker-product-row { margin-bottom: 12px; border-radius: 12px; }
  .modal-foot { gap: 10px; }
  .modal-foot button { min-height: 44px; }

  #mobileTextEditor { width: calc(100% - 24px); max-width: 600px; max-height: calc(100dvh - 32px); padding: 18px; border: 1px solid #dce4ed; border-radius: 18px; background: #fff; color: #24364b; overflow-y: auto; box-shadow: 0 16px 60px #142b4933; }
  #mobileTextEditor::backdrop { background: #15283b70; }
  .mobile-text-editor-head, .mobile-text-editor-foot { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
  .mobile-text-editor-head h3 { margin: 0; font-size: 18px; }
  #mobileTextEditorClose { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 10px; font-size: 24px; background: #f1f4f8; }
  #mobileTextEditorHint { margin: 10px 0 14px; color: #64748b; font-size: 13px; }
  #mobileTextEditorValue { width: 100%; min-height: 140px; max-height: 40dvh; resize: vertical; padding: 12px; border: 1px solid #dce4ed; border-radius: 10px; background: #f8fafc; font-size: 16px; line-height: 1.6; }
  .mobile-text-editor-foot { margin-top: 16px; }
  .mobile-text-editor-foot button { flex: 1; min-height: 44px; }

  #saleForm .sale-line-fees { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px 8px; }
  #saleForm .sale-line-fees label { min-width: 0; border: 0; padding: 0; }
  #saleForm .sale-line-fees input { min-width: 0; min-height: 44px; font-size: 16px; padding: 8px 6px; }
  #productForm label:has(#productBarcodeInput) { grid-column: 1 / -1; }
  .mobile-category-select { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 44px; padding: 10px 12px; text-align: left; white-space: normal; overflow-wrap: anywhere; border: 1px solid #dce4ed; border-radius: 10px; background: #fff; color: #24364b; font-size: 15px; }
  .mobile-category-select::after { content: "›"; flex-shrink: 0; font-size: 22px; color: #64748b; }
  .mobile-category-select.active { border-color: #58a999; background: #f2fbf8; }
  #productForm .mobile-product-category-field { display: grid; grid-column: 1 / -1; gap: 6px; }
  #productForm .mobile-product-category-field small { font-size: 12px; color: #64748b; }
  #productForm label:has(#productCategory, #productSubcategory, #productThirdCategory) { display: none; }
  :is(#mobileCategoryDialog, #mobileTextEditor) { overscroll-behavior: contain; }
  #mobileCategoryDialog { width: calc(100% - 24px); max-width: 600px; max-height: calc(100dvh - 32px); padding: 18px; border: 1px solid #dce4ed; border-radius: 18px; background: #fff; color: #24364b; overflow-y: auto; box-shadow: 0 16px 60px #142b4933; }
  #mobileCategoryDialog::backdrop { background: #15283b70; }
  #mobileCategoryClose { width: 44px; height: 44px; border: 0; border-radius: 10px; font-size: 24px; background: #f1f4f8; }
  #mobileCategoryHint { margin: 12px 0; font-size: 13px; color: #64748b; overflow-wrap: anywhere; }
  #mobileCategoryBreadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding: 8px; background: #f1f5f9; border-radius: 10px; }
  #mobileCategoryBreadcrumb button { min-height: 44px; border: 0; padding: 6px; background: transparent; color: #286c83; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  #mobileCategoryBreadcrumb [aria-current] { font-weight: 700; }
  #mobileCategoryBack { min-height: 44px; margin: 12px 0; }
  #mobileCategoryOptions { display: grid; gap: 10px; max-height: 36dvh; overflow-y: auto; overscroll-behavior: contain; }
  .mobile-category-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px; padding: 12px; border: 1px solid #dce4ed; border-radius: 12px; background: #fafcfe; color: #24364b; text-align: left; }
  .mobile-category-option span { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
  .mobile-category-option small { flex-shrink: 0; color: #64748b; font-size: 12px; }
  .mobile-category-empty { padding: 12px; color: #64748b; font-size: 14px; }
  .inbound-picker-modal .mobile-category-trigger { white-space: normal; overflow-wrap: anywhere; text-align: left; }

  :is(#saleForm, #inboundForm) > .form-block:first-of-type .inbound-head-grid:has(.custom-doc-fields input[type="number"]) > :is(#saleSummaryField, #saleNoteField, #inboundSummaryField, #inboundNoteField),
  :is(#saleForm, #inboundForm) .custom-doc-fields > label:has(input[type="number"]) { grid-template-rows: minmax(36px, auto) 44px; gap: 6px; }
  :is(#saleForm, #inboundForm) .mobile-field-expand { min-width: 28px; padding: 0; }

  /* Shared search tools and bottom sheets: products, inventory, pickers and documents. */
  .mobile-query-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 10px !important; }
  .mobile-query-grid > .mobile-query-search { grid-column: 1 / -1; width: 100%; min-height: 46px; }
  .mobile-query-grid > .mobile-query-original, #inboundPickerTypeFilter { display: none !important; }
  .mobile-query-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-column: 1 / -1; gap: 0; padding: 4px 0; background: #fff; border: 1px solid #e1e8ed; border-radius: 12px; }
  .mobile-query-tools > button { display: flex; align-items: center; justify-content: center; width: 100%; min-width: 0; min-height: 44px; padding: 6px 8px; border: 0; border-right: 1px solid #e5ebef; border-radius: 0; background: transparent; font-size: 13px; color: #475569; white-space: normal; overflow-wrap: anywhere; text-align: center; }
  .mobile-query-tools > button:last-child { border-right: 0; }
  .mobile-query-tools > button.active { color: #087d70; background: #f1faf7; font-weight: 600; }
  .mobile-query-tools .mobile-category-select::after { content: "⌄"; font-size: 15px; }
  dialog.mobile-control-sheet { position: fixed; inset: auto 0 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: min(85dvh, 760px); padding: 0 0 env(safe-area-inset-bottom); border: 0; border-radius: 22px 22px 0 0; background: #fff; color: #24364b; box-shadow: 0 -12px 60px #142b4929; overflow: hidden; overscroll-behavior: contain; }
  dialog.mobile-control-sheet[open] { display: flex; flex-direction: column; }
  dialog.mobile-control-sheet::backdrop { background: #14283c70; }
  .mobile-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #edf1f5; flex-shrink: 0; }
  .mobile-sheet-head h3 { margin: 0; font-size: 18px; }
  .mobile-sheet-head > button { width: 44px; height: 44px; border: 0; border-radius: 12px; background: #f2f5f8; font-size: 24px; }
  .mobile-sheet-body { padding: 16px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .mobile-sheet-foot { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid #e9eef3; flex-shrink: 0; }
  .mobile-sheet-foot > button { flex: 1; min-height: 46px; }
  #mobileFilterFields, .mobile-filter-extra { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .mobile-filter-extra { grid-column: 1 / -1; }
  #mobileFilterFields label { display: grid; gap: 8px; min-width: 0; font-size: 13px; color: #64748b; }
  #mobileFilterFields label:has([data-mobile-extra="stock"], [data-mobile-filter-source$="Date"]) { grid-column: 1 / -1; }
  #mobileFilterFields :is(input, select) { width: 100%; min-width: 0; min-height: 46px; padding: 10px; border: 1px solid #dbe4ec; border-radius: 10px; background: #f8fafc; color: #24364b; font-size: 16px; }
  #mobileFilterError { color: #b42318; font-size: 13px; margin: 12px 0 0; }
  #mobileSortOptions { padding: 4px 16px 16px; }
  #mobileSortOptions > button { display: flex; justify-content: space-between; align-items: center; min-height: 54px; width: 100%; padding: 12px; border: 0; border-bottom: 1px solid #edf1f5; background: #fff; color: #475569; font-size: 15px; text-align: left; }
  #mobileSortOptions > button[aria-pressed="true"] { color: #087d70; background: #f1faf7; font-weight: 600; border-radius: 10px; }
  #mobileCategoryDialog { width: 100%; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 85dvh; border: 0; border-radius: 22px 22px 0 0; }
  #mobileCategoryOptions { display: block; min-height: 0; max-height: 44dvh; margin-top: 12px; border: 1px solid #e2e8ef; border-radius: 12px; flex: 1 1 auto; }
  #mobileCategoryBack { display: none; }
  #mobileCategoryBreadcrumb { max-height: 112px; flex-shrink: 0; overflow-y: auto; }
  #mobileCategoryHint { margin: 10px 0 0; }
  #mobileCategoryDialog .mobile-text-editor-head, #mobileCategoryDialog .mobile-text-editor-foot { flex-shrink: 0; }
  .mobile-category-row { display: flex; align-items: center; padding-left: calc(var(--category-depth) * 18px); min-height: 52px; border-bottom: 1px solid #edf1f5; background: #fff; }
  .mobile-category-row.selected { background: #eef9f5; }
  .mobile-category-caret, .mobile-category-leaf { display: grid; place-items: center; flex: 0 0 44px; width: 44px; min-height: 48px; border: 0; background: transparent; color: #52677a; font-size: 22px; }
  .mobile-category-choice { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1; min-width: 0; min-height: 52px; padding: 10px 12px 10px 0; border: 0; background: transparent; color: #33485d; text-align: left; font-size: 15px; }
  .mobile-category-choice > span { overflow-wrap: anywhere; }
  .mobile-category-choice small { flex-shrink: 0; color: #718096; font-size: 11px; }
  .mobile-category-choice[aria-pressed="true"], .mobile-category-choice[aria-pressed="true"] small { color: #087d70; font-weight: 600; }
  .mobile-date-tabs { display: flex; flex-shrink: 0; margin: 12px 16px 8px; border-bottom: 1px solid #e9eef3; }
  .mobile-date-tabs button { flex: 1; min-height: 46px; border: 0; border-bottom: 3px solid transparent; background: #fff; color: #718096; font-size: 16px; }
  .mobile-date-tabs [aria-selected="true"] { color: #087d70; border-bottom-color: #087d70; font-weight: 700; }
  .mobile-date-wheels { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: 220px; min-height: 220px; margin: 8px 16px; }
  .mobile-date-wheels::after { content: ""; position: absolute; top: 88px; height: 44px; left: 0; right: 0; border-top: 1px solid #b9dcd3; border-bottom: 1px solid #b9dcd3; border-radius: 8px; background: #0b9b7810; pointer-events: none; }
  .mobile-date-wheel { height: 220px; overflow-y: auto; padding: 88px 0; box-sizing: border-box; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; touch-action: pan-y; }
  .mobile-date-wheel::-webkit-scrollbar { display: none; }
  .mobile-date-wheel > div { display: grid; place-items: center; height: 44px; min-height: 44px; scroll-snap-align: center; font-size: 18px; color: #82909f; cursor: pointer; }
  .mobile-date-wheel > [aria-selected="true"] { color: #087d70; font-size: 21px; font-weight: 700; }
  .mobile-date-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px 16px; font-size: 14px; color: #53677c; }
  #mobileDateNow { min-height: 44px; }
  .mobile-query-tools > :is(.mobile-category-select, .mobile-category-trigger) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-query-tools .mobile-category-select::after { content: none; }
  .mobile-filter-hint { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.6; color: #718096; }
  #mobileDateDialog { overflow-y: auto; }
  .mobile-date-summary { flex-shrink: 0; }

  /* Compact document rows: keep DOM/data bindings and desktop tables unchanged. */
  :is(#inboundLinesBody, #saleLinesBody) tr.document-line-card {
    grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 6px;
  }
  :is(#inboundLinesBody, #saleLinesBody) td:is([data-label="商品编号"], [data-label="分类"], [data-label="属性"]) {
    grid-column: span 4; font-size: 12px; line-height: 1.5;
  }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="序列号"] { grid-column: span 8; }
  #inboundLinesBody td[data-label="批次号"] { grid-column: span 4; }
  #saleLinesBody td[data-label="赠品"] {
    grid-column: span 4; order: 9; display: grid; align-content: start;
    justify-content: stretch; gap: 4px; padding: 2px 0;
  }
  #saleLinesBody .sale-gift-toggle { min-height: 44px; width: 100%; justify-content: center; border-radius: 9px; background: #f8fafc; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="数量"] { grid-column: span 3; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="单位"] { grid-column: span 2; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="单价"] { grid-column: span 3; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="金额"] {
    grid-column: span 4; padding: 2px 5px; font-size: 14px; align-content: start; line-height: 1.5;
  }
  :is(#inboundLinesBody, #saleLinesBody) input:not([type="checkbox"]) { padding: 9px 4px; }
  :is(#inboundLinesBody, #saleLinesBody) td[data-label="单位"] { font-size: 14px; }
  :is(#inboundLinesBody, #saleLinesBody) .serial-input-wrap { grid-template-columns: minmax(0, 1fr) 44px; }
  :is(#inboundLinesBody, #saleLinesBody) .serial-voice-btn { width: 44px; min-width: 44px; min-height: 44px; }
  :is(#saleForm, #inboundForm) .inbound-head-grid > :is(#inboundSupplierField, #saleCustomerField) { grid-column: span 3; }
  :is(#inboundSupplierField, #saleCustomerField) .search-picker-field { gap: 0; position: relative; }
  :is(#inboundSupplierField, #saleCustomerField) .search-picker-btn { min-width: 44px; width: 44px; min-height: 44px; padding: 0; font-size: 12px; }

  /* Reset legacy full-row category placement after moving it into shared tools. */
  .mobile-query-tools > button { grid-column: auto; grid-row: auto; height: 46px; min-height: 46px; margin: 0; align-self: stretch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-query-tools { padding: 0; align-items: stretch; overflow: hidden; }
  .mobile-query-tools > :is(.mobile-category-select, .mobile-category-trigger) { display: block; padding: 6px 8px; font-size: 13px; text-align: center; }
  .mobile-query-tools > button.active { background: #eef8f4; color: #087d70; }

  /* Quiet bottom sheets: one path, no leaf bullets or repeated action text. */
  #mobileCategoryDialog { padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  #mobileCategoryHint { font-size: 12px; line-height: 1.6; color: #82909f; }
  #mobileCategoryBreadcrumb { margin-top: 12px; padding: 4px 8px; background: #f5f8fa; border: 0; }
  #mobileCategoryOptions { margin-top: 12px; border: 0; border-radius: 0; }
  .mobile-category-row { border-bottom-color: #f0f3f6; border-radius: 8px; }
  .mobile-category-row[style="--category-depth:0"] .mobile-category-choice > span { font-weight: 600; }
  .mobile-category-row.selected { background: #edf8f3; }
  .mobile-category-choice small:empty { display: none; }
  .mobile-category-choice small { font-size: 14px; }
  #mobileSortOptions { display: grid; gap: 6px; }
  #mobileSortOptions > button { border-bottom: 0; border-radius: 10px; background: #f7f9fb; }
  #mobileFilterFields label { gap: 6px; }

/* Mobile login: explicit module loading/retry, separate from document content. */
  .mobile-load-status { padding: 16px; margin: 12px 0; border: 1px solid #dbe5f2; border-radius: 12px; background: #f1f6fc; color: #334b68; font-size: 14px; }
  .mobile-load-status button { margin-left: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid #b7cde6; background: white; color: #2457a1; }
  .tab-panel > [inert] { opacity: .55; pointer-events: none; }
  /* Mobile product selection is two distinct screens, not a list above hidden specs. */
  :is(#inboundProductPickerModal, #saleProductPickerModal):not(.mobile-spec-step) .picker-attribute-section { display: none; }
  :is(#inboundProductPickerModal, #saleProductPickerModal).mobile-spec-step :is(.picker-query-panel, .picker-list-panel, .catalog-tree) { display: none; }
  :is(#inboundProductPickerModal, #saleProductPickerModal).mobile-spec-step .picker-attribute-section { display: block; margin: 0; padding: 16px; border: 1px solid #dce7ed; border-radius: 16px; background: #f8fafc; }
  .mobile-spec-step .mobile-picker-step-heading { display: block; margin: 0 0 8px; font-size: 19px; color: #183b46; outline: none; }
  .mobile-spec-step .mobile-picker-step-help { display: block; margin: 0 0 16px; font-size: 13px; color: #667b8b; line-height: 1.6; }
  .mobile-spec-step .picker-attribute-section > .picker-module-head { display: none; }
  .mobile-spec-step .picker-variant-summary { padding: 14px; border-radius: 12px; background: #eaf5f2; }
  .mobile-spec-step .variant-attr-block { padding: 12px; margin-top: 12px; border: 1px solid #e1e9ef; border-radius: 12px; background: #fff; }
  .mobile-spec-step .variant-option-chip { min-height: 44px; }
  :is(#inboundProductPickerModal, #saleProductPickerModal) [data-picker-step-back][hidden] { display: none; }
  :is(#inboundProductPickerModal, #saleProductPickerModal).mobile-spec-step .modal-foot > [data-close-inbound-picker-modal],
  :is(#inboundProductPickerModal, #saleProductPickerModal).mobile-spec-step .modal-foot > [data-close-sale-picker-modal] { display: none; }
  .mobile-spec-step #openProductModalFromInboundPickerBtn { display: none; }
  .mobile-category-search { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 0 10px; border: 1px solid #dbe5eb; border-radius: 12px; background: #f6f9fb; flex-shrink: 0; }
  .mobile-category-search input { flex: 1; width: 0; min-width: 0; min-height: 46px; padding: 10px 0; border: 0; outline-offset: 2px; background: transparent; font-size: 16px; }
  .mobile-category-search button { min-height: 44px; border: 0; background: transparent; color: #087d70; }
  .mobile-category-result { padding: 0 14px; }
  .mobile-category-result .mobile-category-choice > span { display: grid; gap: 6px; }
  .mobile-category-result .mobile-category-choice strong { font-weight: 600; }
  .mobile-category-result .mobile-category-choice span small { color: #738494; font-size: 12px; line-height: 1.5; }

  .mobile-spec-step .variant-attr-grid { display: grid; grid-template-columns: minmax(0, 1fr); overflow: visible; gap: 0; padding: 0; }
  .mobile-spec-step .variant-attr-block { min-width: 0; }
  .mobile-spec-step .variant-option-row { flex-wrap: wrap; }
  .mobile-spec-step .variant-option-chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .mobile-spec-step .picker-selection-panel td[data-label="商品名称"] { display: none; }
  .mobile-spec-step .picker-pagination { flex-direction: column; align-items: stretch; gap: 8px; }
  .mobile-spec-step .picker-pagination-actions { justify-content: space-between; }
  .mobile-spec-step .picker-pagination-actions :is(button, strong) { white-space: nowrap; }
  .mobile-spec-step .picker-pagination:has(button:disabled + strong + button:disabled) .picker-pagination-actions { display: none; }

  :is(#inboundProductPickerModal, #saleProductPickerModal) .modal-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  :is(#inboundProductPickerModal, #saleProductPickerModal) .modal-foot > button { min-width: 0; min-height: 52px; width: 100%; padding: 10px 6px; font-size: 13px; white-space: normal; }


  /* Inventory uses document scrolling on phones, not the fixed-height desktop pane.
   Reset both clipping ancestors so every card and the final row remain reachable. */

  [data-panel="inventory-query"] #inventoryQueryLayout,
  [data-panel="inventory-query"] #inventoryQueryLayout > .product-main {
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }
  [data-panel="inventory-query"] #inventorySummaryMobileList {
    height: auto;
    max-height: none;
    overflow: visible;
    flex: 0 0 auto;
    padding-bottom: 24px;
  }
  [data-panel="inventory-query"] :is(#inventorySerialWrap, #inventoryHistoryWrap):not(.hidden) {
    height: auto;
    max-height: none;
    overflow: visible;
    flex: 0 0 auto;
  }

}
