/* Cada vista conserva un área de desplazamiento accesible, sin recortar controles. */
:root{--scroll-thumb:#a8b6c7;--scroll-track:#f1f4f8}
:is(.table-wrap,.warehouse-scroll,.movement-scroll,.worker-table-wrap,.sr-history-wrap,.backup-table,#settingsSection,#backupInboxSection,.sr-reader,#shiftReportsScreen,.dialog-body,.layout>aside){scrollbar-width:auto;scrollbar-color:var(--scroll-thumb) var(--scroll-track);-webkit-overflow-scrolling:touch;scroll-behavior:auto;scroll-padding:16px}
:is(.table-wrap,.warehouse-scroll,.movement-scroll,.worker-table-wrap,.sr-history-wrap,.backup-table,#settingsSection,#backupInboxSection,.sr-reader,#shiftReportsScreen,.dialog-body,.layout>aside)::-webkit-scrollbar{width:11px;height:11px}
:is(.table-wrap,.warehouse-scroll,.movement-scroll,.worker-table-wrap,.sr-history-wrap,.backup-table,#settingsSection,#backupInboxSection,.sr-reader,#shiftReportsScreen,.dialog-body,.layout>aside)::-webkit-scrollbar-thumb{background:var(--scroll-thumb);border:2px solid var(--scroll-track);border-radius:10px}
:is(.table-wrap,.warehouse-scroll,.movement-scroll,.worker-table-wrap,.sr-history-wrap,.backup-table,#settingsSection,#backupInboxSection,.sr-reader,#shiftReportsScreen,.dialog-body,.layout>aside)::-webkit-scrollbar-track{background:var(--scroll-track)}
.layout>aside{min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;padding-bottom:max(18px,env(safe-area-inset-bottom))}
main,.workspace-section,.panel,.warehouse-body{min-width:0;min-height:0}
#settingsSection,#backupInboxSection{overflow-y:auto;overflow-x:hidden;flex:1 1 0;min-height:0;scrollbar-gutter:stable;overscroll-behavior-y:contain;padding-bottom:max(28px,env(safe-area-inset-bottom))}
/* Una pantalla baja puede desplazar sus herramientas sin perder el pie de tabla. */
#catalogSection,#warehouseSection,#movementSection{overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain}
:is(#catalogSection,#warehouseSection,#movementSection)>.title-row,:is(#catalogSection,#warehouseSection,#movementSection)>.stats,#movementSection>.movement-stats{flex-shrink:0}
#catalogSection>.panel,#movementSection>.movement-panel{flex:1 0 240px;min-height:240px;display:flex;flex-direction:column;overflow:hidden}
#warehouseSection .warehouse-body{flex:1 0 260px;min-height:260px;overflow-y:auto;overflow-x:hidden}
:is(.table-wrap,.warehouse-scroll,.movement-scroll,.worker-table-wrap){min-width:0;max-width:100%;overflow:auto;touch-action:pan-x pan-y;overscroll-behavior-x:contain;overscroll-behavior-y:auto;scrollbar-gutter:stable}
#movementSection .movement-scroll{flex:1 1 0;min-height:110px;max-height:none}
#catalogSection .table-wrap{flex:1 1 0;min-height:110px}
#warehouseSection .warehouse-scroll{flex:1 1 0;min-height:160px}
#movementSection .footer,.panel>.footer,.worker-footer{flex-shrink:0}
#movementSection .movement-toolbar{flex-shrink:0;max-height:32dvh;overflow:auto}
/* Historial y respaldo: el desplazamiento vertical continúa al llegar al borde. */
#shiftReportsScreen{overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;scroll-padding-bottom:32px}
.sr-reader{overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scroll-padding-bottom:32px;padding-bottom:max(32px,env(safe-area-inset-bottom))}
#srHistory .sr-history-wrap,#backupInboxSection .backup-table{max-width:100%;min-width:0;overscroll-behavior-x:contain;overscroll-behavior-y:auto;touch-action:pan-x pan-y}
#backupInboxSection .backup-table{min-height:0;max-height:min(65dvh,720px)}
/* Las ventanas estructuradas desplazan el contenido; sus acciones siguen visibles. */
dialog{box-sizing:border-box;max-height:calc(100dvh - 24px);max-width:calc(100vw - 24px);overflow:auto;overscroll-behavior:contain;scroll-padding:16px}
dialog:has(>form>.dialog-head):has(>form>.dialog-body):has(>form>.dialog-foot){padding:0;overflow:hidden}
dialog:has(>form>.dialog-head):has(>form>.dialog-body):has(>form>.dialog-foot)>form{display:flex;flex-direction:column;max-height:calc(100dvh - 28px);min-height:0;margin:0}
dialog:has(>form>.dialog-foot)>form>.dialog-head,dialog:has(>form>.dialog-foot)>form>.dialog-foot{flex:0 0 auto}
dialog:has(>form>.dialog-foot)>form>.dialog-body{flex:1 1 auto;min-height:0;max-height:none;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable;scroll-padding:18px}
dialog:not(:has(>form>.dialog-foot)) .dialog-body{max-height:none;overflow:visible}
dialog .dialog-foot{flex-wrap:wrap}
:is(.table-wrap,.warehouse-scroll,.movement-scroll,.worker-table-wrap,.sr-history-wrap,.backup-table)[tabindex]:focus-visible{outline:2px solid #687ad0;outline-offset:-3px}
@media(max-width:900px){
 #catalogSection>.panel,#movementSection>.movement-panel{flex-basis:300px;min-height:300px}
 #warehouseSection .warehouse-body{flex-basis:300px;min-height:300px}
 #workerScreen{overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain}
 #workerScreen .worker-header,#workerScreen .worker-toolbar,#workerScreen .worker-footer{flex-shrink:0}
 #workerScreen .worker-table-wrap{flex:1 0 180px;min-height:180px}
 body.mobile-worker-expanded #workerScreen .worker-table-wrap{flex:1 1 0;min-height:100px}
 #workerScreen .worker-column-filters{max-height:28dvh;flex-shrink:0;overscroll-behavior-y:auto}
 #shiftReportsScreen #srHistory .sr-history-wrap:has(table[data-mobile-cards]),#backupInboxSection .backup-table:has(table[data-mobile-cards]){overflow:visible;max-height:none;min-height:0}
 dialog .dialog-foot{gap:10px;padding-bottom:max(14px,env(safe-area-inset-bottom))}
}
@media(max-height:500px){
 dialog{max-height:calc(100dvh - 12px)}
 dialog:has(>form>.dialog-head):has(>form>.dialog-body):has(>form>.dialog-foot)>form{max-height:calc(100dvh - 16px)}
 dialog .dialog-head,dialog .dialog-foot{padding-top:10px!important;padding-bottom:10px!important}
 #movementSection .movement-stats>span{padding:10px 14px}
}
#catalogSection>.panel,#movementSection>.movement-panel{min-height:max(240px,var(--workspace-controls,240px))}
@media(max-width:900px){#catalogSection>.panel,#movementSection>.movement-panel{min-height:max(300px,var(--workspace-controls,300px))}}
