
/* Why v191 failed: older per-tab rules use #id selectors + !important (one-screen height:100vh, overflow:hidden,
   fixed 5-column KPI grid, fixed-height headers). An ID beats the plain class rules in v191, so they never applied.
   This layer repeats the fixes with ID-level specificity. Desktop (>=1100px) is NOT touched. */
@media screen and (max-width:1099px){
  /* 1. the page itself must scroll */
  html body:has(:is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab,#backupTab).active) .main-content{overflow-x:hidden!important;overflow-y:auto!important;height:100dvh!important;-webkit-overflow-scrolling:touch!important;padding:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab).tab-content.active,
  html body #dashboardTab.tab-content.active{height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;padding:10px 10px 28px!important;box-sizing:border-box!important;width:100%!important;max-width:100%!important;}

  /* 2. headers, toolbars, filters: wrap, auto height */
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is([class*="-ui-head"],.ud-header,.mj-head,.mj-hero,.ph-head,.erp-center-header,[class*="-ui-toolbar"],[class*="-ui-filter"],[class*="-ui-info"],.ph-toolbar,.mj-toolbar,.mj-strip){height:auto!important;min-height:0!important;flex:0 0 auto!important;flex-wrap:wrap!important;gap:10px!important;align-items:center!important;box-sizing:border-box!important;max-width:100%!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is([class*="-ui-actions"],[class*="-ui-tools"],.ud-header-actions,.ph-head-actions,.ph-tools,.mj-hero-actions){display:flex!important;flex-wrap:wrap!important;gap:8px!important;width:100%!important;min-width:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is([class*="-ui-actions"],[class*="-ui-tools"],.ud-header-actions,.ph-head-actions,.mj-hero-actions) :is(.btn,button){flex:1 1 auto!important;min-height:40px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is([class*="-ui-search"],.ph-search,.mj-search){flex:1 1 100%!important;width:100%!important;min-width:0!important;max-width:100%!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(input,select,textarea){max-width:100%!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-date-box{width:100%!important;box-sizing:border-box!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .erp-report-filters{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .erp-report-filters .form-group{min-width:0!important;}

  /* 3. KPI cards */
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.ud-kpis,[class*="-ui-kpis"],.ph-kpis,.mj-kpis,.erp-ar-kpis){grid-template-columns:repeat(auto-fit,minmax(170px,1fr))!important;gap:8px!important;flex:0 0 auto!important;height:auto!important;min-height:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.ud-kpi,[class*="-ui-kpi"]:not([class*="kpis"]):not([class*="icon"]),.ph-kpi,.mj-card,.erp-ar-card){height:auto!important;min-height:64px!important;box-sizing:border-box!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-kpi strong{white-space:normal!important;overflow:visible!important;overflow-wrap:anywhere!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-kpi small{white-space:normal!important;}

  /* 4. panels, registers and tables: natural height, horizontal scroll inside the card */
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is([class*="-ui-panel"],.ph-panel,.mj-section,.mj-report){height:auto!important;min-height:0!important;max-height:none!important;flex:0 0 auto!important;overflow:visible!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.table-container,.table-responsive,.table-wrap,.ph-table-wrap,[class*="-ui-table-wrap"]){height:auto!important;min-height:0!important;max-height:none!important;flex:0 0 auto!important;width:100%!important;max-width:100%!important;overflow-x:auto!important;overflow-y:visible!important;-webkit-overflow-scrolling:touch!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.table-container,.table-responsive,.table-wrap,.ph-table-wrap,[class*="-ui-table-wrap"]) table{min-width:640px!important;width:max-content!important;max-width:none!important;table-layout:auto!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.table-container,.table-responsive,.table-wrap,.ph-table-wrap,[class*="-ui-table-wrap"]) :is(th,td){white-space:nowrap!important;width:auto!important;max-width:none!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is([class*="-ui-footer"],.ph-footer,.mj-footer,.vp-pagination,.mj-pagination){height:auto!important;min-height:0!important;flex:0 0 auto!important;flex-wrap:wrap!important;gap:8px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .vp-pagination .vp-info{white-space:normal!important;}
  #view-molder{height:auto!important;max-height:none!important;overflow:visible!important;}
  #view-molder .table-card{max-height:none!important;overflow:visible!important;}

  /* 5. dashboard */
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-charts{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(260px,1fr))!important;gap:10px!important;flex:0 0 auto!important;height:auto!important;min-height:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-charts .ud-panel{height:auto!important;min-height:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-panel-title{height:auto!important;min-height:36px!important;flex-wrap:wrap!important;gap:2px 8px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-chart-box{height:190px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-recent-grid{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(300px,1fr))!important;gap:10px!important;flex:0 0 auto!important;height:auto!important;min-height:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-recent{height:auto!important;min-height:0!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-recent .table-container{overflow-x:auto!important;overflow-y:visible!important;height:auto!important;min-height:0!important;flex:0 0 auto!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-recent .table-container table{min-width:420px!important;width:100%!important;table-layout:auto!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-recent :is(th,td){white-space:nowrap!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-asof-note{flex:0 0 auto!important;height:auto!important;min-height:0!important;line-height:1.3!important;margin:0 4px 6px!important;}
}
@media screen and (max-width:699px){
  /* room for the ☰ button so it never sits on top of a page header */
  html body:has(:is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab,#backupTab).active) .main-content{padding-top:54px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.ud-kpis,[class*="-ui-kpis"],.ph-kpis,.mj-kpis,.erp-ar-kpis){grid-template-columns:repeat(auto-fit,minmax(150px,1fr))!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-kpis-five .ud-kpi:last-child:nth-child(odd){grid-column:1/-1;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-charts,html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-recent-grid{grid-template-columns:minmax(0,1fr)!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) :is(.ud-title-wrap h1,[class*="-ui-title-wrap"] h1,.ph-title){font-size:19px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-date-box .pk-date-wrap input[type=text]{width:auto!important;min-width:0!important;flex:1 1 auto!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab) .ud-date-box>div{flex:1 1 auto!important;}
}
@media screen and (max-width:420px){
  html body:has(:is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab,#backupTab).active) .main-content{padding-top:52px!important;}
  html body :is(#dashboardTab,#partiesTab,#weightMasterTab,#openingStockTab,#challansTab,#danaTab,#molderJobsTab,#dispatchesTab,#billsTab,#paymentsTab,#ledgersTab,#erpReportsTab).tab-content.active{padding-left:8px!important;padding-right:8px!important;}
}
