/* Shared screen adaptation. Printed invoices and reports keep their document sizing. */
@media screen {
 :root{--screen-text:clamp(12px,.72vw + 5px,14px);--screen-label:clamp(11px,.6vw + 5px,13px);--screen-heading:clamp(17px,1.25vw + 4px,24px);--screen-gap:clamp(6px,.7vw,12px);--screen-pad:clamp(8px,.9vw,16px);--screen-control:clamp(34px,2.7vw + 6px,42px)}
 :where(#appScreen,.admin-main,.master-main,.stocktake-shell,#supportApp,dialog) :where(form,fieldset,section,.form-grid,.suite-grid,.admin-tab-panel,.table-wrap){min-width:0}
 :where(#appScreen,.admin-main,.master-main,.stocktake-shell,#supportApp,dialog) :where(input,select,textarea){max-width:100%;min-width:0}
 :where(#appScreen,.admin-main,.master-main,.stocktake-shell,#supportApp,dialog) :where(img){max-width:100%}
 #appScreen.workspace-shell>main{min-width:0;max-width:100%}
 #appScreen.workspace-shell .view:not(#orderView){min-width:0;max-width:100%;font-size:var(--screen-text)}
 #appScreen.workspace-shell .view:not(#orderView) :is(.section-header,.workspace-page-heading){gap:var(--screen-gap);padding:var(--screen-pad);flex-wrap:wrap;align-items:center}
 #appScreen.workspace-shell .view:not(#orderView) :is(.section-header,.workspace-page-heading) h2{font-size:var(--screen-heading);margin:0;line-height:1.25}
 #appScreen.workspace-shell .view:not(#orderView) :is(.section-header,.workspace-page-heading) p{font-size:var(--screen-label);margin:4px 0 0}
 #appScreen.workspace-shell .view:not(#orderView) :is(.ops-form,.suite-card,.report-panel,.workspace-report-centre){padding:var(--screen-pad);gap:var(--screen-gap);min-width:0}
 #appScreen.workspace-shell .view:not(#orderView) :is(label,.muted,.report-status){font-size:var(--screen-label);line-height:1.4}
 #appScreen.workspace-shell .view:not(#orderView) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea,button){font-size:var(--screen-text)}
 #appScreen.workspace-shell .view:not(#orderView) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,button){min-height:var(--screen-control);padding:6px 9px}
 #appScreen.workspace-shell :is(.report-filters,.inventory-filters,.workspace-product-toolbar){display:flex;flex-wrap:wrap;gap:var(--screen-gap);align-items:end;min-width:0;padding:var(--screen-pad)}
 #appScreen.workspace-shell :is(.report-filters,.inventory-filters,.workspace-product-toolbar)>label{flex:1 1 180px;min-width:0;max-width:100%}
 #appScreen.workspace-shell :is(.report-filter-actions,.operation-form-actions,.suite-actions,.suite-toolbar,.service-invoice-actions){display:flex;flex-wrap:wrap;gap:var(--screen-gap);align-items:center}
 #appScreen.workspace-shell :is(.ops-form>.form-grid,#suiteBody .suite-grid){grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr));gap:var(--screen-gap)}
 :is(#appScreen,.admin-main,.master-main,.stocktake-shell,#supportApp) :is(.table-wrap,.report-table-wrap,.suite-table,.workspace-product-table,.manage-product-grid,.service-grid-wrap,.po-line-grid,.table-scroll,.role-access-table-wrap){min-width:0;max-width:100%;overflow:auto;overscroll-behavior-x:contain}
 :is(#appScreen,.admin-main,.master-main,.stocktake-shell,#supportApp) :is(.table-wrap,.report-table-wrap,.suite-table,.workspace-product-table,.manage-product-grid,.service-grid-wrap,.po-line-grid,.table-scroll) :is(th,td){font-size:var(--screen-text);padding:6px 8px}
 :is(.admin-main,.master-main,.stocktake-shell){width:100%;max-width:1600px;padding:var(--screen-pad);font-size:var(--screen-text)}
 :is(.admin-main,.master-main,.stocktake-shell) :is(.admin-card,.master-card,.suite-card){padding:var(--screen-pad);min-width:0}
 :is(.admin-main,.master-main,.stocktake-shell) :is(.company-fields,.company-addresses,.master-form,.form-grid){gap:var(--screen-gap)}
 :is(.admin-main,.master-main,.stocktake-shell) :is(h2,h3){font-size:var(--screen-heading);line-height:1.3}
 :is(.admin-main,.master-main,.stocktake-shell) :is(label,.muted){font-size:var(--screen-label)}
 :is(.admin-main,.master-main,.stocktake-shell) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea,button){font-size:var(--screen-text)}
 :is(.admin-main,.master-main,.stocktake-shell) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,button){min-height:var(--screen-control);padding:6px 9px}
 :is(.admin-tabs,.support-tabs,.ops-subtabs,.product-form-tabs){max-width:100%;overflow-x:auto;gap:var(--screen-gap)}
 :is(.admin-tabs,.support-tabs,.ops-subtabs,.product-form-tabs)>button{flex-shrink:0}
 dialog:not(#mobileMoreDialog){max-width:calc(100dvw - 20px);max-height:calc(100dvh - 20px);overflow:auto;overscroll-behavior:contain}
 dialog:not(#mobileMoreDialog)>.dialog-card{min-width:0}
 #workspaceProductDrawer{width:min(94vw,1080px);max-height:calc(100dvh - 16px)}
 #workspaceProductDrawerBody{min-height:0;overflow:auto}
 #workspaceProductDrawerBody .arranged-product-form :is(label,input,select,button){font-size:var(--screen-text)}
 #workspaceProductDrawerBody .arranged-product-form .form-grid{gap:var(--screen-gap)}
 #serviceSalesView :is(.service-invoice-header,.service-entry,.service-invoice-bottom,.service-invoice-actions){padding:var(--screen-pad);gap:var(--screen-gap)}
 #serviceSalesView .service-customer-actions{gap:var(--screen-gap);flex-wrap:wrap}
 #serviceSalesView .service-invoice-header strong{font-size:var(--screen-text)}
 #serviceSalesView .service-invoice-bottom{grid-template-columns:minmax(0,1fr) minmax(240px,.55fr)}
 #serviceSalesView .service-entry-top{flex-wrap:wrap;gap:var(--screen-gap)}
 #serviceSalesView .service-reference{min-width:0}
 #supportApp{font-size:var(--screen-text)}
 #supportApp :is(.panel-heading,.staff-form){gap:var(--screen-gap);padding:var(--screen-pad)}
 #supportApp :is(label,button,input,select){font-size:var(--screen-text)}
 #supportApp :is(.page-heading,.panel-heading,.summary-row){flex-wrap:wrap}
}
@media screen and (min-width:960px){
 #appScreen.workspace-shell>.topbar{display:flex;flex-wrap:nowrap;align-items:center;gap:10px;min-height:62px;padding:5px 10px}
 #appScreen.workspace-shell>.topbar .header-brand{flex:0 1 240px;min-width:0;gap:8px}
 #appScreen.workspace-shell>.topbar .header-logo{width:48px;height:48px;max-width:none}
 #appScreen.workspace-shell>.topbar .top-actions{display:flex;flex:1;min-width:0;flex-wrap:nowrap;gap:8px;margin:0}
 #appScreen.workspace-shell>.topbar .top-actions .shop-label{flex:1;min-width:0;max-width:100%}
 #appScreen.workspace-shell>.topbar .top-actions .shop-label select{width:100%;min-width:100px;max-width:100%;font-size:var(--screen-text)}
 #appScreen.workspace-shell>.topbar .account-menu{min-width:0;max-width:280px}
 #appScreen.workspace-shell>.topbar .user-chip{min-width:0}
 #appScreen.workspace-shell>.topbar .user-chip>div{min-width:0}
 #appScreen.workspace-shell>.topbar #userName{display:block;max-width:210px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--screen-text)}
 #appScreen.workspace-shell{--workspace-panel:clamp(176px,16vw,220px)}
 #appScreen.workspace-shell .workspace-panel-pages button{font-size:var(--screen-text);line-height:1.3}
}
@media screen and (min-width:601px) and (max-width:959px){
 #appScreen.workspace-shell>.topbar{display:flex;flex-wrap:wrap;align-items:center;gap:5px 10px;min-height:0;padding:6px 10px}
 #appScreen.workspace-shell>.topbar .header-logo{width:40px;height:40px}
 #appScreen.workspace-shell>.topbar .top-actions{display:flex;flex:1 1 100%;min-width:0;flex-wrap:nowrap;gap:8px;margin:0}
 #appScreen.workspace-shell>.topbar .top-actions .shop-label{flex:1;min-width:0}
 #appScreen.workspace-shell>.topbar .top-actions .shop-label select{width:100%;min-width:100px;max-width:100%;font-size:12px}
 #appScreen.workspace-shell>.topbar .account-menu{max-width:220px;min-width:0}
 #appScreen.workspace-shell>.topbar .user-chip>div{min-width:0}
 #appScreen.workspace-shell>.topbar #userName{display:block;max-width:155px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
 #appScreen.workspace-shell #stockView :is(.purchase-document-header,.purchase-receive-header,#poCreate>.purchase-document-header){grid-template-columns:minmax(0,1fr)}
 #appScreen.workspace-shell #stockView #poReceive{grid-template-columns:minmax(0,1fr)}
 #appScreen.workspace-shell .ops-form>.form-grid>*{grid-column:auto}
 #serviceSalesView .service-invoice-header{grid-template-columns:repeat(2,minmax(0,1fr))}
 #serviceSalesView .service-invoice-bottom{grid-template-columns:minmax(0,1fr)}
 #serviceSalesView .service-customer-actions{padding-left:0}
 #appScreen.workspace-shell .workspace-report-cards{grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr))}
 .master-stats{grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr))}
}
@media screen and (min-width:601px) and (max-height:800px){
 :root{--screen-control:34px;--screen-gap:7px;--screen-pad:9px}
 #appScreen.workspace-shell .view:not(#orderView) :is(.section-header,.workspace-page-heading){padding:7px 10px}
 #appScreen.workspace-shell .workspace-breadcrumb{padding-bottom:5px;font-size:11px}
 #appScreen.workspace-shell .view:not(#orderView) :is(.report-status,.ops-result):empty{display:none}
 #workspaceProductDrawer .workspace-drawer-heading{padding:10px 14px}
 #workspaceProductDrawerBody .arranged-product-form :is(input:not([type=checkbox]):not([type=radio]),select,button){min-height:34px;padding:6px 8px}
 dialog:not(#mobileMoreDialog):not(#workspaceProductDrawer)>.dialog-card{padding:12px;gap:9px}
 dialog:not(#mobileMoreDialog) .dialog-head h2{font-size:var(--screen-heading)}
 #serviceLineDialog textarea{min-height:110px}
}
@media screen and (max-width:600px){
 #appScreen.workspace-shell .view:not(#orderView) :is(.form-grid,#suiteBody .suite-grid){grid-template-columns:minmax(0,1fr)}
 #appScreen.workspace-shell .view:not(#orderView) .form-grid>*{grid-column:auto}
 #appScreen.workspace-shell :is(.report-filters,.inventory-filters,.workspace-product-toolbar)>label{flex-basis:100%}
 #appScreen.workspace-shell .view:not(#orderView) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea){font-size:16px}
 #appScreen.workspace-shell .view:not(#orderView) :is(button,input:not([type=checkbox]):not([type=radio]),select){min-height:40px}
 #appScreen.workspace-shell #stockView :is(#poCreate>.purchase-document-header,.purchase-document-header,.purchase-receive-header,#poReceive){grid-template-columns:minmax(0,1fr)}
 #serviceSalesView :is(.service-invoice-header,.service-invoice-bottom){grid-template-columns:minmax(0,1fr)}
 #serviceSalesView .service-invoice-header>*{grid-column:auto}
 #serviceSalesView .service-reference{grid-template-columns:minmax(0,1fr)}
 #workspaceProductDrawer{width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;border-radius:0}
 #workspaceProductDrawerBody .arranged-product-form .form-grid{grid-template-columns:minmax(0,1fr)}
 #workspaceProductDrawerBody .arranged-product-form .form-grid>*{grid-column:auto}
 :is(.admin-main,.master-main,.stocktake-shell){padding:10px}
 :is(.admin-main,.master-main,.stocktake-shell) :is(.company-fields,.company-addresses,.master-form,.form-grid){grid-template-columns:minmax(0,1fr)}
 :is(.admin-main,.master-main,.stocktake-shell) :is(input:not([type=checkbox]):not([type=radio]),select,textarea){font-size:16px}
 :is(.admin-main,.master-main,.stocktake-shell) :is(button,select,input:not([type=checkbox]):not([type=radio])){min-height:40px}
 .master-header-actions{flex-wrap:wrap;gap:5px}
 .master-intro{flex-wrap:wrap}
 .master-stats{grid-template-columns:minmax(0,1fr)}
 .login-shell:not(#loginScreen){padding:12px;min-height:100dvh}
 .login-shell:not(#loginScreen) .login-card{width:100%;max-width:420px;min-width:0;padding:20px}
 #supportApp .staff-form{grid-template-columns:minmax(0,1fr)}
}
@media screen and (pointer:coarse){
 :is(.admin-main,.master-main,.stocktake-shell,#supportApp) :is(button,input:not([type=checkbox]):not([type=radio]),select),#appScreen.workspace-shell .view:not(#orderView) :is(button,input:not([type=checkbox]):not([type=radio]),select){min-height:42px}
}
/* Keep the selected shop readable without stretching it across the header. */
@media screen and (min-width:601px){
 #appScreen.workspace-shell>.topbar .top-actions .shop-label{flex:0 1 auto;width:auto;max-width:340px;min-width:0;margin-right:0}
 #appScreen.workspace-shell>.topbar .top-actions .shop-label select{flex:0 1 auto;width:clamp(180px,24vw,300px);min-width:0;max-width:100%;min-height:34px;padding:5px 28px 5px 9px}
}
/* Give the company title its natural width and keep the header on a single text line. */
@media screen{
 #appScreen.workspace-shell>.topbar .header-brand{flex:0 1 auto;max-width:100%;min-width:0}
 #appScreen.workspace-shell>.topbar .header-brand>div{min-width:0}
 #appScreen.workspace-shell>.topbar #companyName{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;overflow-wrap:normal}
}
@media screen and (min-width:960px){
 #appScreen.workspace-shell>.topbar .header-brand{max-width:45%}
}
