/* JK ERP R8.82 fix192 — phone-first workspace and inventory usability */
.inventory-mobile-search{display:none;align-items:center;gap:8px;min-width:260px;height:38px;margin:0;padding:0 10px;border:1px solid #c9daec;border-radius:9px;background:#fff;color:#637a95}
.inventory-mobile-search input{flex:1;min-width:0;height:100%;border:0;outline:0;background:transparent;color:#17324f;font:inherit}
.inventory-mobile-search button{display:none;flex:0 0 28px;width:28px;height:28px;border:0;border-radius:7px;background:#edf3f9;color:#536a83;font-size:18px;line-height:1}
.inventory-mobile-search:focus-within{border-color:#1677ee;box-shadow:0 0 0 3px rgba(22,119,238,.1)}
.inventory-mobile-search:focus-within button,.inventory-mobile-search input:not(:placeholder-shown)+button{display:grid;place-items:center}

@media(max-width:760px){
  html,body{width:100%!important;max-width:100%!important;min-width:0!important;overflow-x:hidden!important;-webkit-text-size-adjust:100%;text-size-adjust:100%}
  body main,body header,body .page,body .panel,body .order-panel{min-width:0!important;max-width:100%!important;box-sizing:border-box!important}
  body header{padding-left:12px!important;padding-right:12px!important}
  body header>div:nth-child(2){min-width:0!important;flex:1!important}
  body header h1{overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important}
  body .workspace-tabs{max-width:100vw!important;overflow-x:auto!important;overscroll-behavior-x:contain!important;scrollbar-width:none}
  body .workspace-tabs::-webkit-scrollbar{display:none}
  body .page{padding:12px 10px calc(30px + env(safe-area-inset-bottom))!important}
  body input,body select,body textarea{font-size:16px!important}
  body button{touch-action:manipulation}
  body :is(.page-toolbar,.list-head,.filters,.invoice-toolbar,.report-filter-bar,.expense-list-toolbar){min-width:0!important;max-width:100%!important}

  /* Three dashboard quick actions share one mobile structure. */
  body #dashboard .quick-order,body #dashboard .dashboard-smart-card{min-height:0!important;width:100%!important;margin:0 0 12px!important;padding:16px 14px 14px 64px!important;border-radius:14px!important;box-sizing:border-box!important}
  body #dashboard .quick-order{position:relative!important;border-left:4px solid #12b974!important;background:#fff!important;color:#17283e!important}
  body #dashboard .quick-order .quick-head{display:block!important}
  body #dashboard .quick-order .spark{position:absolute!important;left:14px!important;top:16px!important;width:38px!important;height:38px!important;border-radius:50%!important;background:#e5f8ef!important;color:#079a5e!important}
  body #dashboard .dashboard-smart-card::before{left:14px!important;top:16px!important;width:38px!important;height:38px!important;border-radius:50%!important}
  body #dashboard .quick-head h2,body #dashboard .dashboard-smart-card h2{margin:0 0 4px!important;font-size:18px!important;line-height:1.25!important}
  body #dashboard .quick-head p,body #dashboard .dashboard-smart-card p{min-height:34px!important;margin:0!important;font-size:12px!important;line-height:1.45!important}
  body #dashboard .quick-box,body #dashboard .quick-box.compact{display:grid!important;grid-template-columns:48px minmax(0,1fr)!important;grid-template-rows:46px 44px!important;gap:9px!important;width:100%!important;margin:12px 0 0!important}
  body #dashboard .quick-box input{grid-column:1/-1!important;grid-row:1!important;width:100%!important;height:46px!important;margin:0!important;padding:0 12px!important}
  body #dashboard .quick-box .dashboard-voice-icon{grid-column:1!important;grid-row:2!important;display:grid!important;width:48px!important;min-width:48px!important;height:44px!important;margin:0!important;padding:0!important}
  body #dashboard .quick-box>button:not(.voice-input-btn){grid-column:2!important;grid-row:2!important;width:100%!important;height:44px!important;margin:0!important}

  /* Inventory command area stays in the viewport and adds an actual phone search. */
  body #inventory>.inventory-command-bar{display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:10px!important;width:100%!important;padding:10px!important;overflow:visible!important}
  body #inventory>.inventory-command-bar>div:first-child{display:none!important}
  body #inventory .inventory-primary-actions{order:1!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important;width:100%!important}
  body #inventory .inventory-primary-actions button,body #inventory .inventory-primary-actions #new-inventory-product{grid-column:auto!important;width:100%!important;min-width:0!important;min-height:46px!important;height:auto!important;padding:8px 5px!important;white-space:normal!important}
  body #inventory .inventory-mobile-search{order:2!important;display:flex!important;width:100%!important;min-width:0!important;height:48px!important;margin:0!important}
  body #inventory .inventory-quick-tabs{order:3!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;width:100%!important;gap:6px!important}
  body #inventory .inventory-quick-tabs button{min-width:0!important;min-height:42px!important;height:auto!important}
  body #inventory .inventory-toolbar-selects{order:4!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important;width:100%!important}
  body #inventory .inventory-toolbar-selects select{width:100%!important;min-width:0!important;height:46px!important}
  body #inventory .inventory-metrics{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
  body #inventory .inventory-metrics article{min-width:0!important;padding:15px 13px!important}
  body #inventory .inventory-metrics article:last-child{grid-column:1/-1!important}
  body #inventory .inventory-workspace-r817{display:block!important;width:100%!important;min-width:0!important}
  body #inventory .inventory-list-r817,body #inventory .contact-table-wrap{width:100%!important;min-width:0!important;max-width:100%!important;overflow:visible!important}
  body #inventory .contact-table-wrap table,body #inventory .contact-table-wrap tbody{display:block!important;width:100%!important;min-width:0!important}
  body #inventory .contact-table-wrap thead{display:none!important}
  body #inventory .contact-table-wrap tr.product-row{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:0 12px!important;width:calc(100% - 12px)!important;max-width:calc(100% - 12px)!important;min-width:0!important;margin:6px!important;padding:13px!important;border:1px solid #d7e4f2!important;border-radius:13px!important;background:#fff!important;box-shadow:0 4px 14px rgba(20,64,110,.07)!important;box-sizing:border-box!important}
  body #inventory .contact-table-wrap tr.product-row>td{display:block!important;width:auto!important;min-width:0!important;padding:8px 0!important;border:0!important;overflow-wrap:anywhere!important}
  body #inventory .contact-table-wrap tr.product-row>td:first-child{grid-column:1/-1!important;padding:0 0 11px!important;border-bottom:1px solid #e3ecf5!important}
  body #inventory .inventory-product-cell-r817,body #inventory .inventory-product-cell-r817>div:last-child{width:100%!important;min-width:0!important}
  body #inventory .inventory-product-cell-r817 :is(b,small){white-space:normal!important;overflow-wrap:anywhere!important}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(n+2):nth-child(-n+8)::before{display:block!important;margin-bottom:4px!important;color:#71849b!important;font-size:10px!important;font-weight:800!important}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(2)::before{content:"商品编号"}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(3)::before{content:"分类 / 品牌"}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(4)::before{content:"库存"}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(5)::before{content:"进货价"}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(6)::before{content:"批发价"}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(7)::before{content:"零售价"}
  body #inventory .contact-table-wrap tr.product-row>td:nth-child(8)::before{content:"状态"}
  body #inventory .contact-table-wrap tr.product-row>td:last-child{grid-column:1/-1!important;padding:11px 0 0!important;border-top:1px solid #e3ecf5!important}
  body #inventory .inventory-row-actions{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:8px!important;width:100%!important;white-space:normal!important}
  body #inventory .inventory-row-actions button{width:100%!important;min-width:0!important;min-height:42px!important;padding:6px 3px!important}
  body #inventory .customer-footer{height:auto!important;flex-wrap:wrap!important;gap:4px!important;padding:9px 12px!important}
  body #inventory .inventory-quick-count-r817{position:static!important;width:100%!important;margin-top:12px!important;padding-bottom:calc(14px + env(safe-area-inset-bottom))!important}
  body #inventory .inventory-quick-actual{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:8px!important}
  body #inventory .inventory-quick-actual button{width:100%!important;min-height:44px!important}
  body #inventory .inventory-quick-confirm{min-height:48px!important}

  /* Stocktake becomes a full-screen, scroll-safe phone workspace. */
  body #stocktake-modal{inset:0!important;width:100dvw!important;height:100dvh!important;padding:0!important;align-items:stretch!important;overflow:hidden!important}
  body #stocktake-modal .stocktake-card{display:flex!important;flex-direction:column!important;width:100%!important;max-width:100%!important;height:100dvh!important;max-height:100dvh!important;border-radius:0!important;overflow:hidden!important}
  body #stocktake-modal .modal-head{position:sticky!important;top:0!important;z-index:5!important;flex:0 0 auto!important;padding:13px 14px!important}
  body #stocktake-modal .stocktake-grid{display:block!important;flex:1 1 auto!important;min-height:0!important;width:100%!important;padding:14px 12px calc(86px + env(safe-area-inset-bottom))!important;overflow-y:auto!important;overflow-x:hidden!important}
  body #stocktake-modal .stocktake-grid>section{width:100%!important;min-width:0!important}
  body #stocktake-modal .stocktake-voice{display:grid!important;grid-template-columns:1fr!important;gap:6px!important}
  body #stocktake-modal .stocktake-voice button{width:100%!important;min-height:44px!important}
  body #stocktake-modal .stocktake-numbers{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:7px!important}
  body #stocktake-modal .stocktake-numbers>div{min-width:0!important;min-height:88px!important;padding:10px 7px!important}
  body #stocktake-modal .stocktake-numbers b,body #stocktake-modal .stocktake-numbers input{font-size:18px!important}
  body #stocktake-modal .modal-actions{position:sticky!important;bottom:0!important;z-index:6!important;display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important;margin:12px -12px 0!important;padding:10px 12px calc(10px + env(safe-area-inset-bottom))!important;border-top:1px solid #dbe5ef!important;background:rgba(255,255,255,.98)!important;box-shadow:0 -8px 22px rgba(15,50,88,.1)!important}
  body #stocktake-modal .modal-actions button{width:100%!important;min-width:0!important;min-height:46px!important}
  body #stocktake-modal .stocktake-history{margin-top:18px!important;padding-top:15px!important;border-top:1px solid #dbe5ef!important}
  body #stocktake-modal .stocktake-history .contact-table-wrap{overflow-x:auto!important}
  body #stocktake-modal .stocktake-history table{min-width:720px!important}

  /* Shared phone fallback for every main module. */
  body :is(#sales,#purchase,#delivery,#customers,#finance,#reports,#settings,#preorders,#mobile-topups) :is(.page-toolbar,.filters,.list-head){width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box!important}
  body :is(#sales,#purchase,#delivery,#customers,#finance,#reports,#settings,#preorders,#mobile-topups) :is(.page-toolbar,.filters){display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:9px!important}
  body :is(#sales,#purchase,#delivery,#customers,#finance,#reports,#settings,#preorders,#mobile-topups) :is(.page-toolbar,.filters)>*{width:100%!important;min-width:0!important;max-width:100%!important}
  body :is(.order-modal,.invoice-modal,.release-notes-overlay) :is(input,select,textarea){font-size:16px!important}
  body .order-modal .modal-card{max-width:100dvw!important}
  body .order-modal .modal-head button{min-width:42px!important;min-height:42px!important}
}

@media(max-width:390px){
  body #dashboard,body #inventory{padding-left:7px!important;padding-right:7px!important}
  body #dashboard .quick-order,body #dashboard .dashboard-smart-card{padding-left:58px!important;padding-right:10px!important}
  body #dashboard .quick-order .spark,body #dashboard .dashboard-smart-card::before{left:10px!important}
  body #inventory .inventory-metrics article{padding:13px 10px!important}
  body #inventory .inventory-row-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

/* R8.84: Sales products use a dialog field rather than a native dropdown. */
body #order-body .sales-product-dialog-field::after{content:"";display:none!important}
body #order-body .sales-product-dialog-field>select{display:none!important}
body #order-body .sales-product-dialog-field .searchable-select-input{cursor:pointer;padding-right:12px!important;touch-action:manipulation}
@media(max-width:760px){
  body .sales-expense-entry{width:100%!important;min-width:0!important;box-sizing:border-box!important}
  body .sales-expense-entry label{display:flex!important;flex-direction:column!important;gap:6px!important;min-width:0!important}
  body .sales-expense-entry :is(input,select){width:100%!important;min-width:0!important;min-height:44px!important;box-sizing:border-box!important}
  body #purchase-product-search-results .product-search-tools{display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important}
  body #purchase-product-search-results [data-purchase-dialog-query]{grid-column:1/-1!important;width:100%!important;min-width:0!important;min-height:44px!important}
  body #purchase-product-search-results .product-search-tools select{width:100%!important;min-width:0!important;min-height:44px!important}
  body #order-body .sales-product-dialog-field .searchable-select-input{min-height:44px!important}
}

/* R8.85 sales edit settlement fields */
.sales-edit-amounts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;padding:14px;border:1px solid #dbe5ef;border-radius:9px;background:#f5f9ff}.sales-edit-amounts label{display:flex;flex-direction:column;gap:6px;min-width:0}.sales-edit-amounts input,.sales-edit-amounts select{width:100%;min-width:0;box-sizing:border-box}.sales-edit-amounts small{grid-column:1/-1;color:#6c8099}
@media(max-width:760px){.sales-edit-amounts{grid-template-columns:1fr!important}.sales-edit-amounts :is(input,select){min-height:44px!important}}
