/* Billing responsive layer. Screen-only rules preserve invoice/PDF dimensions. */
.erp-mobile-menu-button,.erp-mobile-menu-close,.erp-mobile-backdrop{display:none}
@media screen {
  body.erp-responsive .main-content{min-width:0}
  body.erp-responsive .sidebar{flex-shrink:0}
  body.erp-responsive .erp-table-scroll{max-width:100%;min-width:0;overflow-x:auto;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
  body.erp-responsive .erp-table-scroll:focus-visible{outline:2px solid #0f766e;outline-offset:2px}
}
@media screen and (max-width:1024px) {
  html{height:100%}
  body.erp-responsive{height:100vh;height:100dvh;width:100%;overflow:hidden}
  body.erp-responsive .main-content{width:100%;max-width:100%;height:100%;flex:1 1 100%;overscroll-behavior-y:contain}
  body.erp-responsive .sidebar{position:fixed!important;left:0!important;top:0!important;bottom:0!important;width:min(300px,88vw)!important;max-width:88vw;height:100vh;height:100dvh;z-index:1801!important;transform:translateX(-101%);visibility:hidden;transition:transform .2s ease,visibility .2s;overflow-y:auto;overscroll-behavior:contain;padding-bottom:env(safe-area-inset-bottom)}
  body.erp-responsive.erp-menu-open .sidebar{transform:translateX(0);visibility:visible;box-shadow:12px 0 35px #0f172a33}
  body.erp-responsive .erp-mobile-menu-button,body.erp-responsive .erp-mobile-menu-close{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;border:1px solid #d8e2e9;border-radius:9px;background:#fff;color:#0f766e;cursor:pointer;font:700 22px/1 system-ui;flex:0 0 auto}
  body.erp-responsive .erp-mobile-menu-close{align-self:flex-end;margin:8px 10px 0}
  body.erp-responsive .erp-mobile-backdrop{position:fixed;inset:0;z-index:1800;background:#0f172a80;border:0;width:100%;height:100%;padding:0}
  body.erp-responsive.erp-menu-open .erp-mobile-backdrop{display:block}
  body.erp-responsive .erp-app-header{flex-wrap:wrap!important;padding:10px 14px!important;gap:10px!important;flex-shrink:0}
  body.erp-responsive .erp-app-title{flex:1 1 180px;min-width:0;overflow-wrap:anywhere;font-size:15px;line-height:1.4}
  body.erp-responsive .erp-header-controls{flex:1 1 100%;width:100%;min-width:0;flex-wrap:wrap!important;gap:8px!important}
  body.erp-responsive .erp-header-controls .tenant-search-form{flex:1 1 180px;min-width:0;max-width:100%}
  body.erp-responsive .tenant-combobox,body.erp-responsive .tenant-combobox.location{min-width:0!important;width:100%}
  body.erp-responsive .tenant-options{left:0;right:auto;width:100%;min-width:0;max-height:35vh}
  body.erp-responsive .tenant-option{white-space:normal;overflow-wrap:anywhere;min-height:44px}
  body.erp-responsive .container{padding:16px!important;min-width:0;max-width:100%}
  body.erp-responsive .card,body.erp-responsive .tab-content{min-width:0;max-width:100%}
  body.erp-responsive .erp-wrap-toolbar{flex-wrap:wrap!important;gap:10px!important;min-width:0}
  body.erp-responsive .erp-wrap-toolbar>*{min-width:0;max-width:100%}
  body.erp-responsive .sales-toolbar,body.erp-responsive .sales-toolbar-actions,body.erp-responsive .purchase-toolbar,body.erp-responsive .purchase-toolbar-actions{flex-wrap:wrap!important;min-width:0;gap:8px}
  body.erp-responsive .sales-search-box{min-width:0!important;max-width:100%;flex:1 1 250px}
  body.erp-responsive .sales-totals-strip,body.erp-responsive .purchase-totals-strip{flex-wrap:wrap!important;gap:10px;max-width:100%}
  body.erp-responsive .sales-totals-values,body.erp-responsive .purchase-totals-values{min-width:0;flex-wrap:wrap;gap:8px}
  body.erp-responsive .erp-table-scroll>table{min-width:640px}
  body.erp-responsive .erp-table-scroll .btn{min-height:40px}
  body.erp-responsive .erp-table-scroll input:not([type=checkbox]):not([type=radio]):not([type=hidden]),body.erp-responsive .erp-table-scroll select{min-height:42px}
  body.erp-responsive .modal-overlay,body.erp-responsive #createInvoiceModal,body.erp-responsive #purchaseModalOverlay{height:100vh!important;height:100dvh!important;max-height:100dvh;box-sizing:border-box;overscroll-behavior:contain}
  body.erp-responsive .modal-content:not(.invoice-viewer-modal){max-width:calc(100vw - 24px)!important;max-height:calc(100dvh - 24px)!important;min-width:0;overscroll-behavior:contain}
  body.erp-responsive .modal-close{min-width:44px;min-height:44px;z-index:5}
  body.erp-responsive .invoice-create-card,body.erp-responsive .purchase-create-card{min-width:0}
  body.erp-responsive .billing-add-toolbar{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.erp-responsive .form-grid,body.erp-responsive .purchase-input-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.erp-responsive .form-grid>*,body.erp-responsive .purchase-input-grid>*{min-width:0}
  body.erp-responsive .invoice-payment-gst-row{grid-template-columns:repeat(2,minmax(0,1fr))!important;overflow:visible}
  body.erp-responsive .invoice-payment-gst-row .form-group{min-width:0!important}
  body.erp-responsive .invoice-floating-actions{flex-wrap:wrap;min-width:0;flex-shrink:1}
  body.erp-responsive .invoice-viewer-actions,body.erp-responsive .invoice-viewer-action-left,body.erp-responsive .invoice-viewer-action-right{flex-wrap:wrap;gap:6px}
  body.erp-responsive .erp-login-shell{height:100vh!important;height:100dvh!important;overflow-y:auto;padding:18px;align-items:safe center!important}
  body.erp-responsive .erp-login-shell>.card{padding:24px!important;margin:auto}
  body.erp-responsive .main-content>footer{padding:16px!important;gap:10px;overflow-wrap:anywhere}
}
@media screen and (max-width:640px) {
  body.erp-responsive .container{padding:10px!important}
  body.erp-responsive .card{padding:16px!important;border-radius:10px}
  body.erp-responsive .form-grid,body.erp-responsive .purchase-input-grid,body.erp-responsive .erp-stack-grid,body.erp-responsive .billing-add-toolbar,body.erp-responsive .invoice-payment-gst-row{grid-template-columns:minmax(0,1fr)!important}
  body.erp-responsive .form-grid>*,body.erp-responsive .purchase-input-grid>*,body.erp-responsive .erp-stack-grid>*{min-width:0!important;grid-column:auto!important}
  body.erp-responsive .form-group{min-width:0;max-width:100%}
  body.erp-responsive input:not([type=checkbox]):not([type=radio]):not([type=hidden]),body.erp-responsive select,body.erp-responsive textarea{font-size:16px!important;max-width:100%;box-sizing:border-box}
  body.erp-responsive .form-group input:not([type=checkbox]):not([type=radio]),body.erp-responsive .form-group select,body.erp-responsive .tenant-combobox input{min-height:44px}
  body.erp-responsive .btn,body.erp-responsive .btn-sm,body.erp-responsive .sales-pagination button{min-height:44px;white-space:normal;line-height:1.35;text-align:center}
  body.erp-responsive .sidebar a{min-height:44px;display:flex;align-items:center;flex-wrap:wrap}
  body.erp-responsive .metric-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  body.erp-responsive .metric-card{padding:14px;min-width:0}
  body.erp-responsive .metric-value{overflow-wrap:anywhere}
  body.erp-responsive #dashboardTab .da-plot>svg{min-width:0!important}
  body.erp-responsive #reportsTab>.card.no-print>div{display:grid!important;grid-template-columns:minmax(0,1fr)}
  body.erp-responsive #reportsTab>.card.no-print .btn{width:100%}
  body.erp-responsive #printableReportSection>.erp-wrap-toolbar>div{width:100%;flex-wrap:wrap}
  body.erp-responsive #printableReportSection>.erp-wrap-toolbar .btn{flex:1 1 140px}
  body.erp-responsive #reportTableContainer .no-print label{display:flex;flex-direction:column;gap:6px;width:100%}
  body.erp-responsive #gstMonthlyFields,body.erp-responsive #gstQuarterlyFields,body.erp-responsive #gstEndMonthField{width:100%}
  body.erp-responsive #gstMonthlyFields[hidden],body.erp-responsive #gstQuarterlyFields[hidden],body.erp-responsive #gstEndMonthField[hidden]{display:none!important}
  body.erp-responsive .modal-overlay{padding:8px!important}
  body.erp-responsive .modal-content:not(.invoice-viewer-modal){padding:20px 14px!important;max-width:calc(100vw - 16px)!important;max-height:calc(100dvh - 16px)!important;border-radius:12px!important}
  body.erp-responsive .modal-content:not(.invoice-viewer-modal)>h2,body.erp-responsive .modal-content:not(.invoice-viewer-modal)>h3{padding-right:44px;overflow-wrap:anywhere}
  body.erp-responsive #createInvoiceModal{padding:8px!important}
  body.erp-responsive .invoice-create-card{margin:0 auto!important;padding:20px 14px!important}
  body.erp-responsive .invoice-create-card h3{padding-right:34px;font-size:18px;overflow-wrap:anywhere}
  body.erp-responsive .invoice-floating-footer{margin-left:-14px!important;margin-right:-14px!important;margin-bottom:-20px!important;padding:12px 14px!important;gap:8px;flex-direction:column;align-items:stretch;padding-bottom:max(12px,env(safe-area-inset-bottom))!important}
  body.erp-responsive .invoice-floating-actions{width:100%;justify-content:stretch}
  body.erp-responsive .invoice-floating-actions>.btn{flex:1 1 130px}
  body.erp-responsive .sales-totals-strip,body.erp-responsive .purchase-totals-strip{position:static!important;padding:12px!important;margin:12px 0!important}
  body.erp-responsive .sales-total-chip,body.erp-responsive .purchase-total-chip{min-width:0;flex:1 1 85px}
  body.erp-responsive .sales-pagination{margin-left:auto}
  body.erp-responsive .access-summary,body.erp-responsive .stats{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.erp-responsive .setup-grid,body.erp-responsive .access-edit-body .form-grid{grid-template-columns:minmax(0,1fr)!important}
  body.erp-responsive .invoice-viewer-overlay{padding:0!important}
  body.erp-responsive .invoice-viewer-modal{width:100vw!important;height:100dvh!important;max-width:100vw!important;max-height:100dvh!important;border-radius:0!important}
}
@media screen and (max-width:360px) {
  body.erp-responsive .metric-grid,body.erp-responsive .access-summary{grid-template-columns:minmax(0,1fr)!important}
}
@media screen and (prefers-reduced-motion:reduce) {
  body.erp-responsive .sidebar{transition:none}
}
@media print {
  .erp-mobile-menu-button,.erp-mobile-menu-close,.erp-mobile-backdrop{display:none!important}
  .erp-table-scroll{overflow:visible!important;max-height:none!important}
}
