/* Sticky table headers. Loaded after the page stylesheets.
   A sticky header sticks to its nearest scrolling box, so every table scrolls inside its own box with a height limit
   (short tables are not affected). The box's own scrollbars are always on screen. */
:root { --table-max-height: max(320px, calc(100vh / 0.9 - 120px)); }

.bud-table-scroll, .mv-table-scroll, .mv-mgrtable-scroll, .tur-mw-scroll, .dp-table,
.qry-tablewrap, .ja-scroll, .pr-scroll, .mom-scroll, .cal-scroll, .itg-scroll {
    overflow: auto; max-height: var(--table-max-height);
    scrollbar-width: thin; scrollbar-color: #c9bfc3 transparent;
}

/* grid tables: the header row, or the header + filter rows wrapped together (bud-stick) because the header's height can vary.
   z-index 5 is above the frozen columns (2) and below the top bar (10). */
.bud-stick, .bud-table > .bud-tr--head, .mv-table > .mv-tr--head,
.cj-mgr__tr--head, .bm-row--head, .dp-row--head { position: sticky; top: 0; z-index: 5; }

/* real tables */
.qry-table thead, .ja-table thead, .pr-table thead, .mom-table thead, .cal-table thead, .itg-table thead { position: sticky; top: 0; z-index: 5; }

/* with border-collapse a stuck header leaves its borders behind on the rows, so they are drawn as shadows here */
.qry-table thead th, .ja-table thead th, .cal-table thead th, .itg-table thead th,
.pr-cols th, .mom-filters th, .mv-mgrtable thead th { box-shadow: inset 0 -1px 0 #ece6e2; }
.qry-table thead .qry-bl, .pr-cols .pr-bl { box-shadow: inset 1px 0 0 #ece6e2, inset 0 -1px 0 #ece6e2; }
.pr-group .pr-bl { box-shadow: inset 1px 0 0 #ece3e6; }

/* popups: the table fills the space between the popup's title and footer, and scrolls there */
.cj-modal__body, .mj-body { display: flex; flex-direction: column; overflow: hidden; }
.cj-modal__body > .bud-table-scroll, .mj-body > .bud-table-scroll { flex: 1 1 auto; min-height: 0; max-height: none; }
