/* V1.8.4: visible bidirectional scrolling on all data tables at 100% browser zoom */
html,body,#application,.main,.page,.panel,.two{min-width:0;max-width:100%}
.main{width:100%;overflow-x:clip}
.page>.panel,.two>.panel{min-width:0}
:where(#vendorsTable,#buyersTable,#deptsTable,#itemsTable,#targetTable,#userTable,#deptConfigTable,#indentTable,#pursalReportsTable,#detailTable,#historyTable,#salesHistoryTable,#stockTable,#pursalTable,#monthlyTable,#yearlyTable){min-width:0;max-width:100%;width:100%}
:where(#vendorsTable,#buyersTable,#deptsTable,#itemsTable,#targetTable,#userTable,#deptConfigTable,#indentTable,#pursalReportsTable,#detailTable,#historyTable,#salesHistoryTable,#monthlyTable,#yearlyTable)>.table-scroll,
:where(#vendorsTable,#buyersTable,#deptsTable,#itemsTable,#targetTable,#userTable,#deptConfigTable,#indentTable,#pursalReportsTable,#detailTable,#historyTable,#salesHistoryTable,#monthlyTable,#yearlyTable)>.entity-table-scroll,
:where(#stockTable,#pursalTable)>.table-scroll,
:where(#stockTable,#pursalTable)>.hierarchy-table{display:block;max-width:100%;width:100%;max-height:min(76vh,820px);overflow-x:scroll!important;overflow-y:auto!important;scrollbar-gutter:stable both-edges;overscroll-behavior:contain}
:where(#stockTable,#pursalTable)>.hierarchy-table{display:block!important;}
:where(#stockTable,#pursalTable)>.hierarchy-table table{width:max-content;min-width:100%}
:where(#stockTable,#pursalTable)>.table-scroll table,
:where(#vendorsTable,#buyersTable,#deptsTable,#itemsTable,#targetTable,#userTable,#deptConfigTable,#indentTable,#detailTable,#historyTable,#salesHistoryTable,#monthlyTable,#yearlyTable)>.table-scroll table{width:max-content;min-width:100%;border-collapse:separate;border-spacing:0}
:where(.table-scroll,.entity-table-scroll,.hierarchy-table){scrollbar-width:auto;scrollbar-color:#7eaaa0 #e4eee9}
:where(.table-scroll,.entity-table-scroll,.hierarchy-table)::-webkit-scrollbar{width:12px;height:12px}
:where(.table-scroll,.entity-table-scroll,.hierarchy-table)::-webkit-scrollbar-thumb{background:#7eaaa0;border-radius:8px;border:2px solid #e4eee9}
:where(.table-scroll,.entity-table-scroll,.hierarchy-table)::-webkit-scrollbar-track{background:#e4eee9}
.table-scroll thead th,.entity-table-scroll thead th,.hierarchy-table thead th{position:sticky;top:0;z-index:6;background:#e8f2ec}
.scope-rule-list{display:grid;gap:10px;margin:12px 0}
.scope-rule-row{display:grid;grid-template-columns:minmax(170px,1fr) minmax(220px,2fr) auto;gap:10px;padding:10px;border:1px solid #d7e7dc;border-radius:10px;align-items:end}
.scope-rule-row textarea{width:100%;min-height:55px;border:1px solid #d8e1e5;border-radius:8px;padding:9px;font:inherit;resize:vertical}
@media(max-width:750px){.scope-rule-row{grid-template-columns:1fr}.scope-rule-row button{justify-self:start}}

/* Correct hierarchy table structure: scroll belongs to the viewport, not to <table>. */
#stockTable>.hierarchy-viewport,#pursalTable>.hierarchy-viewport{display:block!important;max-width:100%;max-height:min(76vh,820px);overflow:scroll!important}
#stockTable>.hierarchy-viewport>.hierarchy-table,#pursalTable>.hierarchy-viewport>.hierarchy-table{display:table!important;width:max-content!important;min-width:100%;overflow:visible!important;max-height:none!important}
#stockTable>.hierarchy-viewport thead th,#pursalTable>.hierarchy-viewport thead th{position:sticky;top:0;z-index:8}
#stockTable>.hierarchy-viewport td:first-child,#pursalTable>.hierarchy-viewport td:first-child{position:sticky;left:0;background:#fff;z-index:4}
#stockTable>.hierarchy-viewport th:first-child,#pursalTable>.hierarchy-viewport th:first-child{position:sticky;left:0;background:#e8f2ec;z-index:10}
#stockTable>.hierarchy-viewport td:nth-child(2),#stockTable>.hierarchy-viewport th:nth-child(2){position:sticky;left:42px;background:#fff;z-index:5}
#stockTable>.hierarchy-viewport th:nth-child(2){background:#e8f2ec;z-index:11}

/* V1.8.5: the OUTER #stockTable/#pursalTable was a second scrolling container.
   Its 72vh max-height clipped the nested table's bottom horizontal scrollbar.
   Only the inner .hierarchy-viewport scrolls. Pagination stays outside it. */
#stockTable.table-scroll,#pursalTable.table-scroll {
  display:block!important; width:100%!important; max-width:100%!important; min-width:0!important;
  max-height:none!important; height:auto!important; overflow:visible!important;
  scrollbar-gutter:auto!important; position:relative;
}
#stockTable > .hierarchy-viewport,#pursalTable > .hierarchy-viewport {
  box-sizing:border-box; display:block!important; position:relative;
  width:100%!important; min-width:0!important; max-width:100%!important;
  height:auto!important; max-height:clamp(280px,52vh,580px)!important;
  overflow-x:scroll!important; overflow-y:auto!important;
  overscroll-behavior:contain; scrollbar-gutter:stable!important;
  scrollbar-width:auto; scrollbar-color:#568f82 #dcece5;
  border:1px solid #d8e7df; border-radius:8px;
}
#stockTable > .hierarchy-viewport::-webkit-scrollbar,#pursalTable > .hierarchy-viewport::-webkit-scrollbar{width:14px;height:14px}
#stockTable > .hierarchy-viewport::-webkit-scrollbar-thumb,#pursalTable > .hierarchy-viewport::-webkit-scrollbar-thumb{background:#568f82;border-radius:7px;border:2px solid #dcece5}
#stockTable > .hierarchy-viewport::-webkit-scrollbar-track,#pursalTable > .hierarchy-viewport::-webkit-scrollbar-track{background:#dcece5}
#stockTable > .hierarchy-viewport > table.hierarchy-table,#pursalTable > .hierarchy-viewport > table.hierarchy-table {
  display:table!important; table-layout:auto; width:max-content!important; min-width:100%!important;
  max-width:none!important; max-height:none!important; overflow:visible!important;
  border-collapse:separate; border-spacing:0;
}
#stockTable > .hierarchy-viewport th,#stockTable > .hierarchy-viewport td,
#pursalTable > .hierarchy-viewport th,#pursalTable > .hierarchy-viewport td{white-space:nowrap}
#stockTable > .pagination,#pursalTable > .pagination{position:relative;max-width:100%;overflow:visible}
@media(max-height:650px){#stockTable > .hierarchy-viewport,#pursalTable > .hierarchy-viewport{max-height:clamp(220px,48vh,380px)!important}}
