/* MBM Account V24 FINAL — universal width fit and natural page scrolling */
html{width:100%;max-width:100%;min-height:100%;height:auto;overflow-x:hidden;overflow-y:auto;scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{width:100%;max-width:100%;min-height:100vh;height:auto!important;overflow-x:hidden;overflow-y:visible!important;touch-action:pan-y pinch-zoom;overscroll-behavior-y:auto}
body,.shell,.main,main,.card,form,section,article,header,footer,nav,aside,div{min-width:0}
img,svg,video,canvas,iframe{max-width:100%;height:auto}
input,select,textarea,button{min-width:0;max-width:100%}
.shell,.main,main,.tally-report-page,.prime-workspace,.report-shell,.stock-create-page,.se,.iv,.mfg-entry{width:100%;max-width:100%}

/* Tables can move sideways when essential, but never create a second vertical scroll. */
.tablewrap,.tally-report-wrap,.scroll,.tabs,.month-chips,.voucher-type-tabs,.voucher-filter-pills,.ledger-tools,.actions{max-width:100%;overflow-x:auto;overflow-y:visible!important;-webkit-overflow-scrolling:touch;touch-action:pan-x pan-y}
.mbm-search-options,.mobile-drawer-panel,.desktop-global-actions{touch-action:pan-y;overscroll-behavior:contain}
.card,.tablewrap,.tally-report-wrap,.tally-report-page,.mobile-live-home,.mobile-voucher-page,.mobile-ledger-page,.mobile-items-page,.mobile-business-page{overscroll-behavior-y:auto}

@media(max-width:900px){
 html,body{font-size:14px}body{padding-left:0!important;padding-right:0!important}
 .shell,.shell>.main,.main,main{width:100%!important;max-width:100%!important;margin-left:0!important;margin-right:0!important;padding-left:0!important;padding-right:0!important}
 .card{width:calc(100% - 12px)!important;max-width:calc(100% - 12px)!important;margin-left:6px!important;margin-right:6px!important;padding-left:8px!important;padding-right:8px!important}
 .grid,.grid2,.row,.ledger-filter,.mfg-top,.stock-sections,.se-top,.se-bottom,.settings-v8-grid{max-width:100%;grid-template-columns:repeat(auto-fit,minmax(min(140px,100%),1fr))!important}
 .field,.tally-field,.mbiz-two,.opening,.bom-head,.mfg-cost>*{min-width:0}
 .pagehead,.tally-pagehead,.iv-head,.mobile-detail-head{max-width:100%;flex-wrap:wrap}
 h1{font-size:20px}h2{font-size:18px}h3{font-size:15px}.btn,button,input,select,textarea{font-size:12px}

 /* Keep complete report details in one screen row by using compact columns. */
 .tablewrap table,.tally-report-wrap table,.table,.tally-report-table,.ledger-table,.ledger-list,.mfg-preview,.bom-table{width:100%!important;min-width:0!important;max-width:100%!important;table-layout:auto}
 .table th,.table td,.tally-report-table th,.tally-report-table td,.ledger-table th,.ledger-table td,.ledger-list th,.ledger-list td,.mfg-preview th,.mfg-preview td,.bom-table th,.bom-table td{padding:5px 3px!important;font-size:clamp(7.5px,2.35vw,10.5px)!important;white-space:normal!important;overflow-wrap:anywhere;line-height:1.25}
 .table th.num,.table td.num,.num{white-space:nowrap!important}
 .hide-mobile,.desktop-global-actions{display:none!important}
 .live-kpis,.live-quick-reports,.report-favourites{grid-template-columns:repeat(auto-fit,minmax(min(125px,100%),1fr))!important}
 .se-item-head{display:none!important}.se-item{max-width:100%;grid-template-columns:minmax(0,1.6fr) minmax(45px,.55fr) minmax(55px,.7fr)!important}
 .inventory-grid-head,.inventory-grid-line,.inventory-grid-head.with-direction,.inventory-grid-line.with-direction{max-width:100%;grid-template-columns:minmax(82px,1.5fr) repeat(3,minmax(42px,.7fr)) 26px!important}
 .stock-create,.inventory-voucher-shell,.tally-voucher-layout,.tally-desktop{max-width:100%;overflow:visible!important}
 .mfg-cost{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto minmax(0,1fr)!important;gap:4px!important;padding:8px 5px!important}.mfg-cost small{font-size:8px}.mfg-cost b{font-size:10px!important}
}
@media(max-width:430px){
 html,body{font-size:13px}.mobile-appbar{padding-left:7px!important;padding-right:7px!important;gap:6px!important}.mobile-company strong{font-size:15px!important}
 .card{width:calc(100% - 8px)!important;max-width:calc(100% - 8px)!important;margin-left:4px!important;margin-right:4px!important}
 .grid,.grid2,.row,.ledger-filter,.mfg-top,.stock-sections,.se-top,.se-bottom{gap:6px!important}.mobile-bottom-nav a,.mobile-quick-actions .mq{font-size:9px!important}
}
@media(min-width:901px){
 html{overflow-y:auto!important}body{height:auto!important;min-height:100vh;overflow-y:visible!important}
 .shell,.shell>.main,.main,main{height:auto!important;min-height:calc(100vh - 90px);overflow:visible}.tablewrap,.tally-report-wrap{overflow-y:visible!important}
}

/* V31: keep searchable Party/Ledger dropdown directly below its own field on mobile too. */
@media(max-width:700px){
  .mbm-search-select{position:relative!important;overflow:visible!important}
  .mbm-search-select .mbm-search-options{position:absolute!important;left:0!important;right:0!important;top:calc(100% + 2px)!important;bottom:auto!important;width:100%!important;max-height:42vh!important;border-radius:6px!important;z-index:1200!important}
}


/* V44.42 entry search fix: every New/Edit searchable dropdown stays attached to its field. */
@media(max-width:700px){
  form .mbm-search-select{position:relative!important;overflow:visible!important}
  form .mbm-search-select:focus-within{z-index:1400!important}
  form .mbm-search-select .mbm-search-options{
    position:absolute!important;left:0!important;right:0!important;
    top:calc(100% + 2px)!important;bottom:auto!important;width:100%!important;
    max-height:min(260px,36dvh)!important;overflow:auto!important;
    border-radius:6px!important;z-index:1450!important;
    -webkit-overflow-scrolling:touch!important;touch-action:pan-y!important
  }
  form .mbm-search-select .mbm-search-options button{touch-action:manipulation!important}
}
