/* ============================================================================
   Page shell — the chrome stays, only the rows move.
   ============================================================================

   Reported from the running app 2026-10-27: scrolling a gateway tab scrolled
   the whole document, so the title, the tab bar and the search/pager toolbar
   all left the screen, and the pager at the foot of a 15-row table was never
   seen at all.

   The shape, and the nesting IS the idea:

     .page-shell              fixed height, flex column
       hero / tab bars          flex: 0 0 auto      <- stay
       .dd-stage                flex: 1; min-height: 0
         .dd-stage-main         flex column; min-height: 0
           toolbar                flex: 0 0 auto    <- STAYS
           .page-scroll           flex: 1; min-height: 0; overflow-y: auto
         .dd-stage-rail         min-height: 0; overflow-y: auto  <- own scroller

   One level of tabs or two makes no difference: whatever chrome sits above
   the scroll region stays put, so a third level would cost nothing. There is
   no "two-level mode" to get wrong.

   ⚠️ **Everything here is scoped INSIDE `.page-shell`.** `.dd-stage` and its
   children are shared with thirteen other templates that still scroll the
   document, and they must not change. A page opts in by wearing the shell.

   ⚠️ **`min-height: 0` on every flex child is load-bearing, not belt-and-
   braces.** A flex item will not shrink below its content, so without it the
   scroll region never gets a bounded height and the column grows instead of
   scrolling — the failure looks exactly like the bug this fixes.

   ⚠️ **The scroller is `#content`, never `body`.** Eight places set
   `document.body.style.overflow` and every restore writes `""` — base.html,
   htmx_events.js, modal-cleanup.js, modal-handlers.js. A shell resting on
   `body { overflow: hidden }` breaks the first time a modal closes.
   ========================================================================= */

/* ── Bounding the chain ─────────────────────────────────────────────────
   ⚠️ **The shell cannot simply be `height: 100vh`, and that was the first
   attempt's bug.** It sits four elements below `#content`, which carries
   `padding: 20px` and `min-height: 100vh` — so a 100vh child overflows its
   padded box by 40px and the DOCUMENT keeps its scrollbar. Reported from the
   running app: "the outer scrollbar is still there".

   The chain from the viewport down is:

     body
       div.wrapper
         div#content              padding 20px, beside the fixed sidebar
           [tenant banner]        chrome, optional
           div (breadcrumb row)   chrome
           main#main_target
             div#content-target
               div.page-shell

   Every link has to be a bounded flex column or the height never arrives.

   ⚠️ **Opted into by ONE class: `.page-shell` on the page's own container.**
   This started as a body_class block, which worked but needed TWO edits per
   page and silently did nothing if you forgot the second. With fourteen
   surfaces to convert that is a bug waiting to happen, so the body rules key
   off `:has(.page-shell)` instead and the single class is the whole opt-in. */
body:has(.page-shell) #content {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* The banner and the breadcrumb row are chrome: they keep their height and
   never shrink. `flex: 0 1 auto` is the default and WOULD let them squash. */
body:has(.page-shell) #content > *:not(#main_target) {
    flex: 0 0 auto;
}

body:has(.page-shell) #main_target {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ⚠️ **`display: flex !important` — an escalation, stated rather than hidden.**
   `section-improvements.css` sets `#content-target { display: block !important }`
   for HTMX swaps, and !important beats any specificity available here.

   An earlier version worked around it: `#content-target` keeps a definite
   HEIGHT (it is a flex item of #main_target), so the shell took `height: 100%`
   and the block in the middle stopped mattering. That holds only while the
   shell is the ONLY child. It is not: four of the five list pages include
   `components/tenants/tenant_selector.html` as a sibling above it, which
   renders a ~60px bar whenever an org admin is not scoped to a tenant. A
   percentage height then overflows its parent by exactly the sibling's height
   and the bottom of the list is clipped unreachable — the same failure the
   shell exists to remove. /devices worked only because it has no sibling.

   So the parent becomes a real flex column. The override is scoped to
   `body:has(.page-shell)`, so a page that has not opted in is untouched and
   the HTMX behaviour that rule protects is unchanged everywhere else. */
body:has(.page-shell) #content-target {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Anything above the shell — the tenant selector, a banner — is chrome: it
   keeps its height. The flex default `0 1 auto` would let it squash. */
body:has(.page-shell) #content-target > *:not(.page-shell) {
    flex: 0 0 auto;
}

.page-shell {
    /* `flex: 1` now that the parent above is a real flex column. An earlier
       version used `height: 100%` to cope with a block parent; that broke as
       soon as a sibling sat above the shell, because a percentage height
       cannot account for one. */
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    /* Belt for the shell itself: anything that escapes the scroll region is
       clipped rather than growing a second scrollbar on the document. */
    overflow: hidden;
}

/* Chrome: the hero and every tab bar hold their height. */
.page-shell > .dd-hero,
.page-shell > .patitur-tab-bar,
.page-shell > .tab-bar {
    flex: 0 0 auto;
}

/* A SECOND-level bar sits inside the panel, not beside the hero — the
   Configuration tab's sub-tabs are the live case. It is chrome too, so it
   holds its height and the panel below it does the scrolling. This one rule
   is the whole of "two levels"; there is no second component. */
.page-shell .dd-stage-main > .tab-bar,
.page-shell .dd-stage-main > .patitur-tab-bar {
    flex: 0 0 auto;
}

/* ⚠️ TWO LEVELS, measured on the running app rather than reasoned about.
   The rule above says "a second-level bar sits inside the panel" and then
   requires it to be a DIRECT CHILD of `.dd-stage-main`. Those are not the same
   thing, and the device detail page's Positioning tab is where the difference
   showed: its mode bar (Radial scatter / Clusters / Terrain / Computed cells)
   sits inside an `.item-row` wrapper, which sits inside a second
   `.dd-tab-content`, which sits inside `#pos-pane-map`, which holds a SECOND
   `.dd-stage`. The selector missed all of it and the bar scrolled away with
   the content.

   ⚠️ A first attempt pinned every non-stage child of an active panel. That was
   worse: it pinned the WRAPPERS that contain the stage, so the height bound
   stopped propagating two levels above the scroll region and nothing scrolled
   at all. Measured in the browser — the chain read 854px at the panel, then
   1967 and 1896 at the two pinned wrappers, then a 1820px `.page-scroll` with
   nothing to scroll.

   So the two cases are told apart by what an element CONTAINS, not by what it
   is:

     - chrome      a tab bar, or the wrapper holding one -> holds its height
     - pass-through  anything containing the stage or the scroll region
                     -> becomes a bounded flex column and hands the height on

   That is what makes a third tab level free: the rule is positional, and there
   is no list of components to extend. */
.page-shell .dd-tab-content.active > .patitur-tab-bar,
.page-shell .dd-tab-content.active > .tab-bar,
.page-shell .dd-tab-content.active > *:has(> .patitur-tab-bar),
.page-shell .dd-tab-content.active > *:has(> .tab-bar) {
    flex: 0 0 auto;
}

.page-shell
    .dd-tab-content.active
    > *:has(.page-scroll):not(.dd-stage):not([hidden]):not(
        .dd-tab-content:not(.active)
    ),
.page-shell
    .dd-tab-content.active
    > *:has(.dd-stage):not([hidden]):not(.dd-tab-content:not(.active)),
.page-shell div:has(> .dd-stage):not(.dd-stage-main):not([hidden]) {
    /* ⚠️ `!important` because `.page-shell .dd-tab-content.active` above sets
       `flex: 1` on the panel itself and a nested panel matches BOTH rules;
       without it the inner one keeps whichever the cascade happened to pick,
       which is what the measurement caught.

       ⚠️ `:not([hidden])` on every selector here, for the SAME reason the
       rail rule below needs it and it is the same bug twice. `display: flex`
       beats the browser's `[hidden] { display: none }`, and the positioning
       tab switches its panes by setting that attribute — so `#pos-pane-map`
       stayed laid out behind the History pane and its chart and map rendered
       on top of it. Measured: `hidden=true` with `display: flex` winning,
       `.pos-trail` visible at 721x121 while History was the open pane.

       Any `display` declared here lands on elements some script hides. Guard
       every one of them.

       ⚠️ **And an INACTIVE nested panel is excluded by name**, for the same
       reason a third time. A second-level panel under an active first-level
       one is a child that holds a scroll region, so this matched it and its
       `display: flex` outranked `.dd-tab-content:not(.active) { display:
       none }` — on the product models page both sub-panels of Devices
       rendered stacked, and both of Gateways (reported 2026-10-30, after a
       browser check that read the `.active` class and not the computed
       display). The active nested panel keeps its layout from the
       `.dd-tab-content.active` rule below; the inactive one stays hidden. */
    flex: 1 1 0% !important;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* A stage-main that delegates to a `.page-scroll` inside it must stop being
   the scroller itself, or it scrolls its whole subtree — the tab bar with it.
   ⚠️ Guarded by `:has()` so the many stage-mains that ARE the scroller, with
   no inner region, keep their own `overflow-y: auto`. */
.page-shell .dd-stage > .dd-stage-main:has(.page-scroll) {
    overflow: visible;
}

/* Its other children are pinned chrome, and chrome never scrolls vertically.
   ⚠️ device-detail.css gives every `.dd-stage-main > div` `overflow-x: auto`
   for wide tables, and a non-visible overflow on one axis turns the other to
   `auto` as well. A wrapping toolbar whose rows are a sub-pixel tall then
   scrolls by 1px and shows a scrollbar (the Terrain tab's toolbar: 78px of
   content in a 77px box, measured 2026-11-02). Horizontal scrolling is left
   alone, so a pinned row too wide for a narrow viewport still scrolls. */
.page-shell .dd-stage-main:has(> .page-scroll) > :not(.page-scroll) {
    overflow-y: hidden;
}

/* The ACTIVE tab panel is the flexible row. Only one is displayed at a time
   (`.dd-tab-content:not(.active) { display: none }`), so only the active one
   can take the remaining height.

   ⚠️ `display: flex` is set here rather than on `.dd-tab-content`, because
   that rule's off-state is `:not(.active)` precisely so it beats Tailwind's
   single-class `flex`/`block` utilities that callers put on the wrapper. A
   bare `.dd-tab-content { display: flex }` would re-show hidden panels. */
.page-shell .dd-tab-content.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* A panel whose only child is the stage-main wrapper (Devices, Alerts,
   Configuration — the tabs with no rail) passes the height straight down. */
.page-shell .dd-tab-content.active > .dd-stage-main {
    flex: 1;
    min-height: 0;
}

/* The stage becomes the flexible row. Grid columns and the rail-collapse
   transition are untouched — this only gives it a bounded height. */
.page-shell .dd-stage {
    flex: 1;
    min-height: 0;
}

.page-shell .dd-stage-main {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* The toolbar above a list is chrome. It was inside the scroller, which is
   why the search box and the pager scrolled away from the rows they act on. */
.page-shell .dd-stage-main > .table-header,
.page-shell .dd-stage-main > .alert-bulk-toolbar {
    flex: 0 0 auto;
}

/* The rail scrolls ITSELF when it is tall, and never with the list.
   ⚠️ **The ASIDE no longer scrolls — `.dd-rail-body` inside it does.** Until
   2026-10-29 `overflow-y: auto` sat here on a `display: block` aside, which
   made the collapse toggle scroll away with the cards: it was the first block
   child, so the `flex: 0 0 auto` meant for it had no flex context to apply in.
   Measured on the running app, 719px of box holding 1820px of cards, with the
   button riding along.

   `rail()` now wraps its caller in `.dd-rail-body`, so the aside can be the
   flex column and the toggle its pinned header — the same chrome/body split
   `scroll_region()` makes for a panel. `overflow: hidden` on the aside is what
   stops card text showing through the 44px gap when collapsed. */
.page-shell .dd-stage-rail:not([hidden]) {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Collapsed: the bodies go, the SPINE stays ─────────────────────────
   ⚠️ **Hiding the body alone was wrong and was reported as such.** A first
   pass set `display: none` on `.dd-rail-body` when collapsed, which did stop
   card text rendering one character per line inside the 44px gap — and also
   removed the section names, leaving a blank 44px strip that said nothing
   about what it held. "We lost the closed section names."

   So the body hides and a spine takes its place: one vertical label per card,
   set with `writing-mode` so the text runs down the strip instead of being
   squeezed into 44px of width, and each one clickable to reopen. Chosen from a
   mock (mocks/rail.html, frame C) over collapsing to a bare chevron, which is
   closer to the failure `ownToggle()` in rail-collapse.js was written for. */
.page-shell .dd-stage.rail-collapsed > .dd-stage-rail > .dd-rail-body {
    display: none;
}

.dd-rail-spine {
    display: none;
}

.page-shell .dd-stage.rail-collapsed > .dd-stage-rail > .dd-rail-spine {
    display: flex;
    flex: 1 1 0%;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

/* ⚠️ `writing-mode` rather than a narrow column of wrapped text: at 44px a
   horizontal label breaks to one character per line, which is exactly the
   rendering that was reported. Rotating keeps it one line and legible. */
.dd-rail-spine-item {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    background: var(--bg-card);
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
    color: var(--fg-3);
    cursor: pointer;
    /* `--fs-sm` + 0.04em: the same pair `.dd-rail-card-header` already uses,
       so a spine label and a card header read as one vocabulary. */
    font-size: var(--fs-sm);
    letter-spacing: 0.04em;
    overflow: hidden;
    padding: 10px 3px;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.dd-rail-spine-item:hover,
.dd-rail-spine-item:focus-visible {
    border-color: var(--color-brand-green);
    color: var(--color-brand-green);
}

/* The toggle row is the rail's header: it holds its height and stays put. */
.page-shell .dd-stage-rail > .dd-rail-toggle-row {
    flex: 0 0 auto;
}

/* …and the body is the only thing that moves. */
.page-shell .dd-stage-rail > .dd-rail-body {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
}

/* ── Lists: the toolbar is chrome, the table body is the mover ──────────
   The shape is identical on every list page because they all render the same
   two shared macros:

     div#<list container>          <- search_and_filter_section + the table
       div.table-header            <- chrome: search, filters, top pager
       div.table-body-scroll       <- the rows

   ⚠️ **Matched by what an element CONTAINS, not by where it sits.** The first
   version required the list container to be a direct child of
   `.dd-stage-main`. That held for /devices and failed on the gateway Devices
   tab, which legitimately wraps its table in a `.dd-rail-card` (header plus a
   total count), putting the container one level deeper so the height stopped
   at the card. Measured 2026-10-27: the table body came out 1134px tall with
   its bottom at 1694 in a 1000px viewport — clipped and UNREACHABLE, which is
   worse than the scrolling document it replaced.

   Pages are entitled to wrap a table in a card, so the rule tolerates any
   wrapper: `:has(.table-body-scroll)` names exactly the elements standing
   between the panel and the scroller, whatever they are. The container's own
   id differs per page (CONTAINER_ID_DEVICE_LIST, …), so there was never a
   class to match on.

   ⚠️ **`.dd-stage` is excluded, and must be.** It also contains the scroller,
   so the bare selector matched it and replaced its `display: grid` with
   `display: flex; flex-direction: column` — which silently discards
   `grid-template-columns: minmax(0, 1fr) var(--page-rail-width)`. The right
   rail stops being a 240px column and stacks under the table instead.
   Reported from the running app on /tenants/6/alerts as "the side bar got
   messed up". `.dd-stage` gets its height from its own rule below, which
   touches `flex` and `min-height` only and leaves the grid alone. */
.page-shell
    :has(.table-body-scroll):not(.dd-stage):not([hidden]):not(.dd-tab-content) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* A card's own header is chrome, like the toolbar below it. */
.page-shell .dd-rail-card-header {
    flex: 0 0 auto;
}

/* ⚠️ **Chrome rows inside the stage keep their NATURAL height.**
   `device-detail.css` gives every direct div child of `.dd-stage-main`
   `overflow-x: auto`, and per spec an axis that is not `visible` forces the
   other to `auto` — so each one is a vertical scroller too. That was
   invisible while nothing bounded their height. Once the shell bounds it the
   flex default (`0 1 auto`) lets them shrink below their content, and a
   button row and a KPI strip each sprout their own scrollbar. Reported from
   the running app on the Terrain tab, with a screenshot.

   `0 0 auto` stops the squashing, so they do not overflow and no bar
   appears. Two children must still flex, and both are excluded: the list
   container, matched above by `:has(.table-body-scroll)` at higher
   specificity, and anything explicitly marked `.page-scroll`.

   ⚠️ That second exclusion is not defensive. This selector is (0,2,1) and
   `.page-scroll` is (0,1,0), so without it this rule WINS and the designated
   scroll region stops flexing. Measured on the running app: the gateway
   Configuration panel grew to 1157px with its bottom at 1593 in a 1305
   viewport — clipped and unreachable, caused by the fix for the Terrain
   chrome rows. A panel whose rows then exceed the stage (Terrain) scrolls as
   ONE region on `.dd-stage-main`, which is the right answer there: it has no
   designated scroller of its own. */
.page-shell .dd-stage-main > div:not(.page-scroll) {
    flex: 0 0 auto;
}

.page-shell .table-header {
    flex: 0 0 auto;
}

.page-shell .table-body-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ── Stacked lists share the panel's height ───────────────────────────────
   A panel can hold more than one list: the device Activity tab stacks the
   live packets over the retained receptions (and, when those aged out, the
   hourly history). Each keeps its own `table-body-scroll` under its own
   pinned header, as a single list does (2026-11-14; the owner: "only the
   list should be scrolling, with the header set").

   ⚠️ **`flex-basis: 0`, not `auto`.** With the chain's `1 1 auto` each list
   card starts from its CONTENT height and shrinks in proportion to it, so a
   long list starves a short one — measured 2026-10-31 in a 900px viewport:
   the packets body 195px over 2800px of rows, the receptions body 0px and
   unreachable. That is why the Activity tab once sat in one scroll region.
   From a zero basis they split the free height evenly. Safe here because an
   active panel is always bounded (`.dd-tab-content.active` above); a zero
   basis under an unbounded parent would collapse. */
.page-shell
    .dd-tab-content.active
    > :has(.table-body-scroll):not(.dd-stage):not([hidden]):not(
        .dd-tab-content
    ) {
    flex: 1 1 0%;
}

/* ── Inside a designated scroll region, the region is the ONE mover ────────
   A panel that wraps several tables in a `scroll_region()` reads them as one
   page. The chain above does not know that, and would make each table body a
   scroller of its own sharing the region's height. Under a region, the
   wrappers keep their natural height and the table bodies do not scroll; the
   region does. (The device Activity tab used this until 2026-11-14; its lists
   now scroll on their own, above.)

   ⚠️ Same qualifiers as the chain rule, so this one outranks it by exactly
   the extra `.page-scroll` and nothing else changes. A list that wants the
   gateways shape (toolbar as chrome, table body as the mover) must not sit
   in a region at all; that is the page's choice, not this rule's. */
.page-shell
    .page-scroll
    :has(.table-body-scroll):not(.dd-stage):not([hidden]):not(.dd-tab-content) {
    flex: 0 0 auto;
    min-height: auto;
    display: block;
}

.page-shell .page-scroll .table-body-scroll {
    flex: 0 0 auto;
    min-height: auto;
    overflow-y: visible;
}

/* ── A panel splits into chrome and body, the way a table does ───────────
   A tab panel that is NOT a table had no way to say "this part holds still".
   Tables have had it all along: `.table-header` is chrome, `.table-body-scroll`
   moves. Everything else wrapped its whole self in one scroll region, so the
   panel's own header went with the content — reported on the gateway
   Configuration tab ("Gateway information" and its Set Product Model button
   scrolling away) and on Terrain (the mode and heading chips going with the
   render).

   The split is declared by CONTAINMENT, exactly like the table rule above: an
   element holding a `.page-scroll` child becomes a bounded flex column, and
   everything in it that is not that scroller is chrome. So a panel opts in by
   wrapping its body — nothing new to name, and one scrollbar by construction,
   because the scroller is the only flexing child.

   ⚠️ **The three exclusions are load-bearing and are the same three the table
   rule carries.** `.dd-stage` is excluded because it also contains the
   scroller and `display: flex` silently discards its
   `grid-template-columns`, stacking the right rail under the content.
   `[hidden]` and `.dd-tab-content` are excluded because this rule sets
   `display` at a specificity that beats both `[hidden]` and
   `.dd-tab-content:not(.active)` — which is precisely how an earlier version
   of the table rule forced hidden panels visible and made the Configuration
   sub-tabs stop responding to clicks. The gateway config panels use the
   `hidden` attribute, so this rule would re-break them without it. */
.page-shell
    :has(> .page-scroll):not(.dd-stage):not([hidden]):not(.dd-tab-content) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* The panel's chrome keeps its natural height, so only the body moves.
   ⚠️ Mirrors `.dd-stage-main > div:not(.page-scroll)` above, which already
   does this one level up. Without it a panel header shrinks below its content
   under flex's `0 1 auto` default and can sprout a scrollbar of its own. */
.page-shell :has(> .page-scroll) > *:not(.page-scroll) {
    flex: 0 0 auto;
}

/* ⚠️ **A panel header is NOT made sticky. Lifted out of the scroller instead.**
   Sticky was tried for the gateway Configuration tab, whose panel holds two
   cards so neither can own the scroller. It works, and it reads badly: the
   header lurches up by the card's 24px padding, clamps, and then the card's
   own frame and rounded top border slide under a floating title. Measured
   2026-10-28 — 25px of header travel against 323px of region — and rejected
   on sight.

   The panel renders its own header above the scroll region instead, with the
   card headerless (`info_panel(show_header=false)`) so nothing is said twice.
   See `components/layout/page_shell.html`'s `panel_header()` and the
   containment rule above, which needs no per-panel CSS at all. */

/* ── The one mover ──────────────────────────────────────────────────────── */
.page-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ── Quiet scrollbars ───────────────────────────────────────────────────
   Thin, thumb only, no track furniture.

   ⚠️ Deliberately NOT hidden. `scrollbar-width: none` still scrolls by wheel,
   trackpad and keyboard, so it is not an accessibility failure — but the bar
   is the only thing that says "there is more below" and the only thing a
   mouse user can drag. On a list that can run to 258 rows, both matter. */
/* ⚠️ **`scrollbar-width` does NOT inherit — only `scrollbar-color` does.**
   An earlier version set it on `.page-shell` alone on the assumption that
   both cascade; measured in a fixture, the computed value on the scroller
   inside was still `auto`, so the one bar left on the Terrain tab would have
   stayed fat. The descendant selector is what actually reaches it, and it is
   harmless on non-scrolling elements.

   Naming three classes was
   wrong twice over: it missed every other scroller inside the shell, and a
   bounded height creates more of them than you expect. `.dd-stage-main > div`
   carries `overflow-x: auto` (device-detail.css), and per spec an axis that
   is not `visible` forces the other to `auto` — so every direct div child of
   the stage becomes a vertical scroller the moment its height is bounded.
   Reported from the running app on the Terrain tab as fat scrollbars on the
   button row and the header. */
.page-shell,
.page-shell *,
.page-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--border-base) transparent;
}

.page-scroll::-webkit-scrollbar,
.page-shell ::-webkit-scrollbar,
.page-shell::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.page-scroll::-webkit-scrollbar-track,
.page-shell ::-webkit-scrollbar-track,
.page-shell::-webkit-scrollbar-track {
    background: transparent;
}

.page-scroll::-webkit-scrollbar-thumb,
.page-shell ::-webkit-scrollbar-thumb,
.page-shell::-webkit-scrollbar-thumb {
    background: var(--border-base);
    border-radius: 99px;
}

/* ── A table inside the scroller keeps its column names ─────────────────
   The header pins to the top of the SCROLL REGION, not the document, which
   only works because the region is the scroll container. */
.page-scroll table thead th,
.page-shell .table-body-scroll table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ── Compact viewports: the document scrolls again ──────────────────────
   The shell bounds the page to one screen and lets the rows take what is
   left after the chrome. That only works while the chrome leaves something.
   Measured on demo-1 (2026-11-20, p_frontend-290), /devices:

     1280x800   rail stacked under the table (≤1400px, device-detail.css):
                table body 68px — one row — and the rail cards cut off
     768x1024   table body 2px
     375x812    the KPI strip alone is 622px tall; the table and the rail
                got 0px each and the list was simply not there

   Nothing was scrollable, because the shell clips (`overflow: hidden`) so
   the document never grows a second bar. So below these sizes the bound is
   dropped: `#content` takes its natural height and the document scrolls,
   as it did before the shell. Every rule above still applies; with no
   definite height above them the flex rows size to their content, so the
   table shows its rows, the rail its cards, and nothing is clipped.

   ⚠️ Two conditions, and both are about the CHROME, not the device:
   narrow (≤1100px, where every `.dd-stage` stacks its rail and the hero
   and KPI strips wrap tall) and short (≤700px, a landscape phone or a
   small laptop window). The list pages whose rail stacks earlier, at
   1400px, opt in at that width below. */
@media (max-width: 1100px), (max-height: 700px) {
    body:has(.page-shell) #content {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .page-shell {
        overflow: visible;
    }
}

/* The devices and gateways lists stack their rail under the table at
   1400px (device-detail.css, the 800px table floor), so a laptop gets the
   one-row table there. Same release, from the width where they stack. */
@media (max-width: 1400px) {
    body:has(.devices-page.page-shell) #content,
    body:has(.gateways-page.page-shell) #content {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .devices-page.page-shell,
    .gateways-page.page-shell {
        overflow: visible;
    }
}
