/* Shared phone layouts. Desktop presentation and business rules stay unchanged. */
.mobile-nav-shade,.mobile-scroll-hint { display:none; }
@media (max-width:700px) {
  body [hidden] { display:none!important; }
  html { -webkit-text-size-adjust:100%; }
  body { overflow-wrap:break-word; }
  .app-shell,main,main>* { min-width:0; max-width:100%; }
  main { padding:18px 12px 0; }
  .topbar { gap:10px; min-height:56px; height:56px; padding:0 12px; }
  .topbar .breadcrumb { min-width:0; flex:1; margin:0; font-size:11px; }
  .topbar .topbar-right { display:none; }
  .topbar .history-back { flex:none; min-height:36px; padding:6px 9px; }
  .mobile-menu { min-width:36px; min-height:40px; padding:6px; }
  .sidebar { width:260px; max-width:calc(100vw - 52px); padding-top:20px; }
  body:has(.sidebar.open) .mobile-nav-shade { display:block; position:fixed; inset:0; z-index:25; width:100%; border:0; background:#172c3359; }
  .page-heading,.page-title { gap:12px; margin-bottom:18px; min-width:0; }
  .page-heading h1,.page-title h1 { font-size:23px; line-height:1.4; }
  .page-heading>div,.page-title>div,.heading-actions { min-width:0; max-width:100%; }
  .page-heading>.actions,.page-title>.actions,.heading-actions { flex-wrap:wrap; gap:8px; width:100%; justify-content:flex-start; }
  .page-heading .actions>.btn,.heading-actions>.button { flex:1 1 130px; }
  .page-heading p,.page-title p { font-size:12px; overflow-wrap:anywhere; }
  .btn,.button { min-height:44px; max-width:100%; white-space:normal; text-align:center; }
  .btn.small,.button.small { min-height:38px; }
  .actions,.form-footer,.expense-form-actions,.transfer-footer { flex-wrap:wrap; gap:8px; }
  .form-footer .btn,.expense-form-actions .btn { flex:1 1 130px; }
  .back-link,.text-link { overflow-wrap:anywhere; }
  .padded,.form-panel,.expense-form-panel { padding:16px; max-width:100%; }
  .panel-top { padding:14px 16px; gap:10px; }
  .panel-top>* { min-width:0; max-width:100%; }
  .tabs { padding-inline:14px; gap:20px; overscroll-behavior-x:contain; }
  .tabs>a { flex-shrink:0; }
  .pagination { padding:12px 14px; gap:10px; flex-wrap:wrap; }
  .footer { gap:8px; margin-top:24px; }
  .footer>span { max-width:100%; }

  /* Forms stay in their original form elements; larger type prevents iOS zoom. */
  body input:not([type=checkbox]):not([type=radio]):not([type=hidden]),body select,body textarea { max-width:100%; font-size:16px!important; }
  body input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]),body select { min-height:44px; }
  input[type=date],input[type=datetime-local] { min-width:0; width:100%; }
  input[type=file] { width:100%; padding:10px; }
  input[type=checkbox],input[type=radio] { flex:none; }
  label,.field,.django-form>* { min-width:0; max-width:100%; }
  .form-grid,.settings-grid,.detail-layout,.detail-side,.expense-fields,.member-account-fields,.api-meta,.shipment-fields,.fulfillment-choice,.event-snapshots,.transfer-warehouse-fields,.document-reference-grid,.return-panel .document-reference-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:16px; }
  .form-grid .full,.form-grid>label,.document-reference-wide { grid-column:1/-1; }
  .detail-layout>*,.settings-grid>*,.form-grid>*,.event-snapshots>* { min-width:0; }
  .form-panel .field input:not([type=checkbox]),.form-panel .field select,.form-panel .field textarea { width:100%; }
  .field.checkbox-field { grid-template-columns:20px minmax(0,1fr); }
  .checkbox-field label,.member-delete-option,.finance-check { flex-wrap:wrap; }
  .app-shell .product-picker { --picker-height:44px; max-width:100%; }
  .product-picker input[type=text] { min-height:0!important; }
  .product-picker-list { max-width:calc(100vw - 20px); }
  .filters,.filterbar,.shipping-review,.catalog-toolbar { min-width:0; flex-wrap:wrap; gap:10px; padding:14px; }
  .filters .filter-field { min-width:0; max-width:none; flex:1 1 140px; }
  .filters .filter-search { flex-basis:100%; }
  .search-field { min-width:0; max-width:100%; }
  .document-filter-grid,.inventory-movement-filters { grid-template-columns:minmax(0,1fr); padding:14px; gap:12px; }
  .document-filter-grid>* { grid-column:auto; min-width:0; }
  .filter-buttons { flex-wrap:wrap; gap:12px; }
  .supplier-filters { grid-template-columns:repeat(2,minmax(0,1fr)); padding:14px; gap:12px; }
  .supplier-filters>label:first-child,.supplier-filter-actions { grid-column:1/-1; }
  .supplier-filter-actions { grid-row:auto; }
  .inventory-page .inventory-filters { grid-template-columns:minmax(0,1fr); padding:14px; }
  .inventory-filters .filter-buttons { grid-column:auto; }
  .expenses-page .filterbar .field { min-width:0; flex-basis:100%; }
  .advanced>div,.order-filter-popover,.finance-workspace .picker-menu { max-width:calc(100vw - 48px); min-width:0; }

  /* Simple lists and editable item rows become labelled blocks, with no cloned controls. */
  body .app-shell .table-wrap.mobile-cards-wrap { overflow:visible; padding:0 12px 12px; background:#f6f8f7; }
  body .app-shell .table-wrap table.mobile-card-table { display:block; min-width:0; width:100%; table-layout:auto; }
  body .app-shell table.mobile-card-table>colgroup,body .app-shell table.mobile-card-table>thead { display:none; }
  body .app-shell table.mobile-card-table>tbody,body .app-shell table.mobile-card-table>tfoot { display:block; width:100%; }
  body .app-shell table.mobile-card-table>tbody>tr,body .app-shell table.mobile-card-table>tfoot>tr { display:block; width:100%; margin-top:12px; border:1px solid #e0e7e3; border-radius:8px; background:#fff; overflow:hidden; }
  body .app-shell table.mobile-card-table tr>td,body .app-shell table.mobile-card-table tr>th { display:block; position:relative; width:auto!important; min-width:0; max-width:none; min-height:40px; padding:10px 12px 10px 108px; border:0; border-top:1px solid #eef1ef; box-shadow:none; text-align:left!important; white-space:normal; overflow-wrap:anywhere; font-size:12px; line-height:1.6; background:transparent; }
  body .app-shell table.mobile-card-table tr>td::before,body .app-shell table.mobile-card-table tr>th::before { content:attr(data-mobile-label); position:absolute; left:12px; top:11px; width:84px; font-size:11px; line-height:1.6; font-weight:400; color:#748079; white-space:normal; }
  body .app-shell table.mobile-card-table tr>[data-mobile-wide],body .app-shell table.mobile-card-table tr>[data-mobile-primary] { padding:12px; }
  body .app-shell table.mobile-card-table tr>[data-mobile-wide]::before,body .app-shell table.mobile-card-table tr>[data-mobile-primary]::before { display:none; }
  body .app-shell table.mobile-card-table tr>[data-mobile-primary] { background:#f5f9f6; font-size:13px; }
  body .app-shell table.mobile-card-table tr>:first-child { border-top:0; }
  body .app-shell table.mobile-card-table td>.product-cell { min-width:0; }
  body .app-shell table.mobile-card-table td input:not([type=checkbox]):not([type=radio]),body .app-shell table.mobile-card-table td select,body .app-shell table.mobile-card-table td textarea { min-width:0; width:100%; max-width:100%; }
  body .app-shell table.mobile-card-table td .actions { gap:8px; }
  body .app-shell table.mobile-card-table td .btn,body .app-shell table.mobile-card-table td .button { min-height:40px; }
  body .app-shell table.mobile-card-table td .catalog-name,body .app-shell table.mobile-card-table td .catalog-code { min-width:0; max-width:100%; white-space:normal; }
  body .app-shell table.mobile-card-table td .catalog-row-actions { flex-direction:row; flex-wrap:wrap; white-space:normal; }
  body .app-shell table.mobile-card-table tfoot>tr { background:#edf5ef; }

  /* Running ledgers retain side-by-side numeric columns and scroll only inside the panel. */
  .table-wrap.mobile-scroll-wrap { position:relative; width:100%; min-width:0; overflow-x:auto; overscroll-behavior-x:contain; }
  .mobile-scroll-wrap>.mobile-scroll-hint { display:block; position:sticky; left:0; width:100%; padding:9px 14px; color:#728479; font-size:11px; background:#f4f8f5; }
  body .app-shell .table-wrap table.mobile-scroll-table { min-width:var(--mobile-table-min,920px); table-layout:auto; }
  .mobile-scroll-table th,.mobile-scroll-table td { padding:10px 12px; font-size:12px; }
  .mobile-scroll-table .numeric { white-space:nowrap; }
  .mobile-scroll-table .mono { overflow-wrap:normal; word-break:normal; }
  body .app-shell .table-wrap table.mobile-key-value-table { width:100%; min-width:0; table-layout:auto; }
  .mobile-key-value-table td { padding:12px; font-size:12px; }
  .mobile-key-value-table td:last-child { text-align:right; white-space:nowrap; }
  .mobile-key-value-table .ledger-label { white-space:normal; }
  .mobile-key-value-table .money-button { max-width:100%; font-size:14px; }

  .stats,.shipping-stats,.statement-metrics,.inventory-overview,.cancellation-counts { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
  .stat { padding:14px; min-width:0; }
  .stat>strong { font-size:24px; }
  .stat-label { flex-wrap:wrap; gap:6px; }
  .supplier-balance-card { display:block; padding:16px; }
  .supplier-balance-primary { min-width:0; padding:0 0 14px; margin-bottom:14px; border:0; border-bottom:1px solid #dce6df; }
  .supplier-breakdown { min-width:0; }
  .supplier-breakdown-values { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
  .supplier-breakdown-values>div { min-width:0; }
  .supplier-overview-totals>div { gap:8px 14px; }
  .supplier-book-caption { padding:10px 14px; }
  .supplier-book-caption>span { font-size:11px; }
  .inventory-value-summary,.expense-summary,.overview-strip,.balance-meta { padding:14px; gap:12px; flex-wrap:wrap; }
  .inventory-value-summary>*,.expense-summary>* { min-width:0; max-width:100%; }
  .inventory-value-note,.expense-summary .summary-help { margin-left:0; }
  .inventory-value-totals strong { font-size:24px; }
  .inventory-overview { padding:14px; }
  .inventory-overview>div { border:0; padding:0; }

  /* Preserve product grouping while showing each warehouse's quantity and value together. */
  body .app-shell .table-wrap .inventory-product-table { display:block; width:100%; min-width:0; table-layout:auto; }
  .inventory-product-table>thead { display:none; }
  .inventory-product-table .inventory-product-group { display:grid; grid-template-columns:minmax(0,1fr) 65px minmax(78px,.8fr); margin:12px; padding:12px; border:1px solid #e0e7e3; border-radius:8px; background:#fff; }
  .inventory-product-table .inventory-product-group>tr { display:contents; }
  .inventory-product-table .inventory-product-group td { display:block; width:auto; min-width:0; max-width:none; padding:9px 4px; border:0; text-align:left; }
  .inventory-product-table .inventory-product-group .inventory-product-cell { grid-column:1/-1; order:0; padding:0 0 5px; }
  .inventory-product-table .inventory-product-group .inventory-price { grid-column:1/-1; order:1; padding:0 0 10px; border-bottom:1px solid #edf1ef; font-size:12px; }
  .inventory-product-table .inventory-product-group .inventory-price::before { content:'单价：'; color:#748079; }
  .inventory-product-table .inventory-warehouse-cell,.inventory-product-table .inventory-quantity,.inventory-product-table .inventory-value { order:2; white-space:normal; }
  .inventory-product-table .inventory-warehouse-cell::before,.inventory-product-table .inventory-product-group .inventory-quantity::before,.inventory-product-table .inventory-product-group .inventory-value::before { display:block; margin-bottom:4px; color:#748079; font-size:10px; font-weight:400; }
  .inventory-product-table .inventory-warehouse-cell::before { content:'仓库'; }
  .inventory-product-table .inventory-product-group .inventory-quantity::before { content:'库存'; }
  .inventory-product-table .inventory-product-group .inventory-value::before { content:'金额'; }
  .inventory-product-table .inventory-product-subtotal>td { order:3; border-top:1px solid #edf1ef; padding-top:10px; }
  .inventory-product-table tfoot { display:block; margin:12px; padding:12px; border-radius:8px; background:#edf5ef; }
  .inventory-product-table tfoot>tr { display:flex; flex-wrap:wrap; gap:12px; align-items:center; }
  .inventory-product-table tfoot th,.inventory-product-table tfoot td { display:block; padding:0; border:0; }
  .inventory-product-table tfoot th { flex-basis:100%; }
  .inventory-product-table tfoot .inventory-price { display:none; }
  .inventory-product-table tfoot .inventory-quantity::before { content:'库存 '; }
  .inventory-product-table>tbody:not(.inventory-product-group) { display:block; }
  .inventory-product-table>tbody:not(.inventory-product-group)>tr,.inventory-product-table>tbody:not(.inventory-product-group)>tr>td { display:block; width:100%; max-width:none; }

  .document-orders-list { padding:12px 10px 0; }
  .document-order-heading { padding:12px; }
  .document-order-top,.document-order-identity { flex-wrap:wrap; gap:6px 10px; }
  .document-order-result { font-size:12px; }
  .document-record { grid-template-columns:64px minmax(0,1fr) 44px; padding:12px; gap:8px 10px; }
  .document-record-type { grid-column:1; grid-row:1; }
  .document-record-papers { grid-column:2; grid-row:1; }
  .document-record-actions { grid-column:3; grid-row:1; }
  .document-record-party { grid-column:1/3; grid-row:2; }
  .document-record-result { grid-column:1/-1; grid-row:3; }
  .document-record-reference { grid-column:1/-1; grid-row:4; }
  .document-record-goods { grid-column:1/-1; }
  .document-record>* { min-width:0; overflow-wrap:anywhere; }
  .app-shell .document-record-actions>.document-delete-action { min-width:44px; min-height:40px; padding:8px 4px; }
  .document-current-followup { flex-wrap:wrap; }
  .document-more-filters>div { grid-template-columns:minmax(0,1fr); }
  .finance-workspace .metrics { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .finance-workspace .metric { padding:14px; min-width:0; }
  .finance-workspace .metric-value { font-size:22px; overflow-wrap:anywhere; }
  .finance-workspace .view-tabs { overflow-x:auto; flex-wrap:nowrap; white-space:nowrap; }
  .finance-workspace .view-tabs>a { flex:none; }
  .finance-workspace .orders-tools { padding:12px; gap:8px; flex-wrap:wrap; }
  .finance-workspace .orders-tools input,.finance-workspace .orders-tools select { min-width:0; max-width:100%; }
  .finance-workspace .coverage-grid,.finance-workspace .offset-columns,.finance-workspace .payout-fields { grid-template-columns:minmax(0,1fr); }
  .finance-workspace .heading-actions form { max-width:100%; }
  .finance-workspace .single-grid>* { min-width:0; }
  dialog:not(.return-drawer) { width:calc(100vw - 20px); max-width:calc(100vw - 20px); max-height:calc(100dvh - 24px); padding:16px; }
  .finance-workspace dialog { padding:0; }
  .finance-workspace .dialog-top,.finance-workspace .dialog-footer { padding:14px; gap:10px; flex-wrap:wrap; }
  .finance-workspace [data-finance-content] { min-width:0; max-width:100%; }
  .return-drawer { width:100%; max-width:100vw; height:100dvh; max-height:100dvh; border-radius:0; }
  .return-drawer-header { padding:12px; gap:10px; flex-wrap:wrap; }
  .return-drawer-body { padding:14px 12px 0; }
  .return-flow-footer { padding-bottom:max(12px,env(safe-area-inset-bottom))!important; }
  .domestic-items .table-wrap { max-width:100%; }
  .auth-body .auth-layout { padding:0; max-width:100%; }
  .auth-story { min-height:160px; padding:24px; }
  .auth-story h1 { font-size:26px; }
  .auth-form { padding:26px 20px; }
  .auth-form input { width:100%; }
}
