/* Existing controls stay in place; only layout changes at each breakpoint. */
.rw-toggle-cell{display:none}
@media(min-width:651px) and (max-width:1050px){
 #stockModule .topbar,#stockModule .top-actions,#stockModule .data-toolbar{flex-wrap:wrap;gap:10px}
 #stockModule .top-actions>*,#stockModule .data-toolbar>*{min-width:0}
 #stockReceiptForm .rcv-fields,#stockReceiptForm .rcv-document-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
 #stockReceiptForm .rcv-header-grid,#stockReceiptForm .rcv-bottom-grid{grid-template-columns:1fr}
 .rw-surface button,.rw-surface select,.rw-surface input:not([type=hidden]):not([type=checkbox]):not([type=radio]){min-height:44px!important}
 .rw-surface .top-actions,.rw-surface .rs-actions{flex-wrap:wrap;gap:8px}
}
@media(max-width:650px){
 .app-layout{grid-template-columns:minmax(0,1fr)!important;max-width:100%}
 .app-layout>main{min-width:0;width:100%;padding-left:8px!important;padding-right:8px!important}
 #stockModule{min-width:0;width:100%;max-width:100%}
 #stockModule .topbar,#stockModule .top-actions,#stockModule .data-toolbar,.stock-receipt-dashboard-head,.rcv-page-heading{display:flex;flex-wrap:wrap;gap:8px;min-width:0}
 #stockModule .topbar>*,#stockModule .data-toolbar>*,#stockModule .top-actions>*{min-width:0;max-width:100%}
 #stockModule .data-card{padding:10px;min-width:0;max-width:100%}
 #stockModule .stock-tabs-row{position:static;width:100%;margin:0}
 #stockTabs{display:grid!important;grid-template-columns:1fr 1fr!important;width:100%;gap:6px;overflow:visible;min-width:0}
 #stockTabs button{white-space:normal!important;width:100%;margin:0;padding:8px!important}
 .rw-surface,.rw-surface *{box-sizing:border-box}
 .rw-surface button,.rw-surface select,.rw-surface textarea,.rw-surface input:not([type=hidden]):not([type=checkbox]):not([type=radio]),.rw-surface .stock-photo-upload-btn{min-height:44px!important;height:auto;max-width:100%}
 .rw-surface input:not([type=hidden]),.rw-surface select,.rw-surface textarea{font-size:16px!important}
 .rw-surface input[type=checkbox],.rw-surface input[type=radio]{width:22px!important;height:22px!important;min-height:22px!important;margin:11px!important;flex-shrink:0}
 .rw-surface button{white-space:normal!important;line-height:1.35;touch-action:manipulation}
 #stockModule .form-grid,.rw-surface .rcv-fields,.rw-surface .rcv-document-fields,.rw-surface .rcv-header-grid,.rw-surface .rcv-bottom-grid,.stock-receipt-dashboard-grid,.stock-issue-audit-filters{grid-template-columns:minmax(0,1fr)!important;min-width:0}
 .rw-surface .form-grid-field,.rw-surface label,.rw-surface .stock-receipt-item-search-field{min-width:0;max-width:100%}
 .rw-surface .billing-tabs:not(#stockTabs){display:flex;flex-wrap:wrap;gap:4px;max-width:100%}
 .rw-surface .billing-tabs:not(#stockTabs)>button{flex:1 1 110px}
 .rw-surface .rw-table-container{overflow:visible!important;min-width:0!important;width:100%!important;max-width:100%!important}
 .rw-surface table.rw-table{display:block!important;min-width:0!important;width:100%!important;max-width:100%!important;border:0!important;margin:8px 0!important;table-layout:auto}
 .rw-table>thead{position:absolute!important;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
 .rw-table>tbody{display:grid!important;gap:12px;width:100%!important}
 .rw-table>tbody>tr.rw-record{display:grid!important;grid-template-columns:minmax(0,1fr)!important;min-width:0!important;border:1px solid #decfb6!important;border-radius:10px;background:#fffdfa;overflow:visible;padding:8px!important}
 .rw-surface .rw-table>tbody>tr.rw-record>td{display:grid!important;grid-template-columns:minmax(80px,.65fr) minmax(0,1.35fr);align-items:center;gap:8px;width:auto!important;min-width:0!important;max-width:100%!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere;padding:8px 4px!important;border:0!important;border-bottom:1px solid #f0e7d7!important}
 .rw-table>tbody>tr.rw-record>td::before{content:attr(data-rw-label);font-size:12px;font-weight:600;color:#76664f;align-self:start;padding-top:8px;grid-column:1;grid-row:1 / span 12}
 .rw-table>tbody>tr.rw-record>td>*{min-width:0;max-width:100%;grid-column:2}
 .rw-surface .rw-table>tbody>tr.rw-record:not(.rw-expanded)>.rw-secondary{display:none!important}
 .rw-surface .rw-table>tbody>tr.rw-record>.rw-toggle-cell{display:block!important;text-align:right!important;border-bottom:0!important}
 .rw-table>tbody>tr.rw-record>.rw-toggle-cell::before{display:none}
 .rw-toggle{background:#fff4da;border:1px solid #c9952f;border-radius:7px;color:#845c13;padding:8px 16px;min-width:130px}
 .rw-surface .rw-table>tbody>tr.rw-wide-row>td{display:block!important}
 .rw-table>tbody>tr.rw-wide-row>td::before{display:none}
 .rw-surface .rw-table input:not([type=checkbox]):not([type=radio]),.rw-surface .rw-table select{width:100%!important;min-width:0!important}
 #stockReceiptForm .stock-receipt-discount-row{flex-wrap:wrap;min-width:0}
 #stockReceiptForm .stock-receipt-cost-note-wrap{position:static;margin-top:4px;flex-basis:100%}
 #stockReceiptForm .stock-receipt-cost-note{white-space:normal}
 #stockReceiptForm .rcv-footer{position:fixed!important;left:0;right:0;bottom:0;z-index:25;margin:0;padding:8px 10px calc(8px + env(safe-area-inset-bottom));display:grid!important;grid-template-columns:1fr 1fr;gap:6px;background:#fffaf1;border-top:1px solid #d6c4a3;box-shadow:0 -4px 14px #0001}
 #stockReceiptForm{padding-bottom:160px!important}
 #stockReceiptForm .rcv-footer button{margin:0;width:100%;font-size:12px!important}
 #stockReceiptForm .rcv-footer #stockReceiptConfirm{grid-column:1/-1;grid-row:1;min-height:52px!important;font-size:15px!important;font-weight:800;box-shadow:0 4px 12px rgba(164,102,0,.18)}
 #stockReceiptForm .rcv-footer #stockReceiptFormBack,#stockReceiptForm .rcv-footer #stockReceiptSaveDraft,#stockReceiptForm .rcv-footer #stockReceiptCancelDraft{grid-row:2}
 #stockModule .stock-purchase-actions,#stockModule form>footer{position:sticky;bottom:0;background:#fffaf1;padding:8px;display:flex;flex-wrap:wrap;gap:8px;z-index:5}
 .modal.rw-surface:not([hidden]),.rs-modal.rw-surface,.ql-editor.rw-surface{padding:0!important;align-items:stretch!important;justify-content:stretch!important;inset:0!important}
 .modal.rw-surface>.modal-card,.rs-modal.rw-surface>.rs-dialog,.ql-editor.rw-surface>section{width:100%!important;min-width:0!important;max-width:100%!important;height:100dvh!important;max-height:100dvh!important;border-radius:0!important;margin:0!important;display:flex!important;flex-direction:column!important;overflow:hidden!important}
 .modal.rw-surface .modal-card>header,.rs-modal .rs-header,.ql-editor>section>header{flex-shrink:0;padding:10px!important;flex-wrap:wrap;min-width:0}
 .modal.rw-surface .modal-card>header h2{font-size:18px!important;overflow-wrap:anywhere}
 .modal.rw-surface .modal-card>form{min-height:0;overflow:auto;display:flex;flex-direction:column}
 .modal.rw-surface .modal-card>div:not(.modal-backdrop),.rs-modal .rs-scroll,.ql-editor .ql-edit-scroll{min-height:0;overflow:auto;max-width:100%}
 .modal.rw-surface .modal-card>footer,.modal.rw-surface .modal-card>form>footer,.rs-modal .rs-dialog>footer,.ql-editor>section>footer{flex-shrink:0;position:sticky!important;bottom:0;z-index:10;display:flex;flex-wrap:wrap;gap:6px;background:#fffaf1;padding:8px 10px calc(8px + env(safe-area-inset-bottom))!important;margin:0!important}
 .modal.rw-surface footer>button,.rs-modal footer>button,.ql-editor footer button{flex:1 1 110px;min-height:44px!important}
 #stockReceiptConfirmModal .rr-footer #stockReceiptConfirmSubmit{order:-2;flex:1 0 100%;min-height:52px!important;font-size:15px!important;font-weight:800}
 #stockReceiptConfirmModal .rr-footer>div{order:-1;flex-basis:100%}
 .rw-surface .rr-layout,.rw-surface .rs-layout,.rw-surface .pd-overview,.rw-surface .stock-detail-layout{grid-template-columns:minmax(0,1fr)!important}
 .rw-surface .rr-layout>*,.rw-surface .rs-layout>*,.rw-surface .pd-overview>*{min-width:0}
 .rw-surface .ql-edit-scroll article{grid-template-columns:minmax(0,1fr)!important}
 .rw-surface .ql-fields{grid-template-columns:minmax(0,1fr)!important}
 .rw-surface .ql-preview{justify-self:center;max-width:100%}
 .rw-surface .rs-info{grid-template-columns:1fr 1fr;gap:12px}
 .rw-surface .rs-actions{width:100%;display:flex;flex-wrap:wrap}
 .rw-surface .rs-actions button{flex:1 1 110px}
 .rw-surface .stock-detail-head-actions{flex-wrap:wrap}
 .rw-surface .stock-detail-head-actions button{min-width:44px}
 .rw-surface .ni-grid.two,.rw-surface .ni-grid.three,.rw-surface .stock-new-item-layout{grid-template-columns:minmax(0,1fr)!important}
 .rw-surface .stock-new-item-layout{overflow:visible}
}
@media print{.rw-toggle-cell{display:none!important}}
.rw-nav-toggle{display:none}
@media(max-width:650px){
 body:has(.app-layout:not([hidden])) .app-layout>.sidebar{position:fixed!important;inset:0 auto 0 0!important;width:min(320px,90vw)!important;height:100dvh!important;max-height:100dvh!important;z-index:80;transform:translateX(-105%);overflow:auto!important;transition:transform .15s;padding-top:58px!important}
 body.rw-nav-open:has(.app-layout:not([hidden])) .app-layout>.sidebar{transform:translateX(0)}
 body:has(.app-layout:not([hidden])) .rw-nav-toggle{display:block;position:fixed;top:8px;left:8px;z-index:90;min-height:44px;padding:8px 15px;border:1px solid #b68a31;border-radius:7px;background:#fff8e7;color:#64440c}
 body:has(.app-layout:not([hidden])) .app-layout>main{margin-left:0!important;padding-top:60px!important}
 body:has(.modal:not([hidden]),.rs-modal,.ql-editor) .rw-nav-toggle{display:none}
}
@media(max-width:650px){
 .rw-table>tbody>tr.rw-record>td::before{grid-row:1!important}
 body:has(.modal:not([hidden]),.rs-modal,.ql-editor) .rw-nav-toggle{display:none!important}
 body:has(.app-layout:not([hidden])) .app-layout>.workspace{min-width:0;width:100%;margin-left:0!important;padding:60px 8px 24px!important}
 .rw-surface .rw-table>tbody>tr.rw-record>td{background:transparent!important}
 #stockModule .stock-tab-panel{padding:4px}
 #stockReceiptForm .rcv-card{padding:10px}
}
@media(max-width:650px){
 .rw-surface .rw-table>tbody>tr.rw-record>td[hidden]{display:none!important}
 .rw-surface input[type=checkbox],.rw-surface input[type=radio]{width:44px!important;height:44px!important;min-height:44px!important;margin:0!important}
 .rw-surface :is(input,select,textarea,button){scroll-margin-top:68px;scroll-margin-bottom:170px}
 .rw-toggle:focus-visible,.rw-nav-toggle:focus-visible{outline:3px solid #b58520;outline-offset:2px}
}

/* The navigation drawer belongs to the application shell, including the home page. */
@media(max-width:650px){
 .app-layout>.sidebar nav{display:flex!important;flex-direction:column;align-items:stretch;overflow-x:hidden;overflow-y:auto;min-height:0}
 .app-layout>.sidebar nav>*{flex:0 0 auto;max-width:100%;white-space:normal}
 .app-layout>.sidebar .nav-item{width:100%;min-height:44px;white-space:normal;text-align:left}
 .app-layout>.sidebar .sidebar-brand{flex-shrink:0}
 .app-layout>.sidebar .nav-label{display:block!important}
 .app-layout>.workspace{max-width:100%;min-width:0}
 .app-layout>.workspace .topbar,.app-layout>.workspace .top-actions{flex-wrap:wrap;max-width:100%}
 .app-layout>.workspace .top-actions>*{min-width:0;max-width:100%}
 .rw-nav-backdrop{position:fixed;inset:0;background:#0007;z-index:79;border:0;border-radius:0;padding:0}
 .rw-nav-backdrop[hidden]{display:none!important}
 body.rw-nav-open{overflow:hidden}
}
@media(min-width:651px){.rw-nav-backdrop{display:none!important}}
