/* 3lroof breakpoints (P08 DS-01): the layout tokens of tokens.css per viewport width, and what the
   shells do at each. Load last (after tokens.css, rf.css and rf-app.css). Logical properties only.

   | Width         | Sidebar                                   | Top bar | Navigation          |
   |---------------|-------------------------------------------|---------|---------------------|
   | ≥ 1600 px     | 300 px                                    | 96 px   | sidebar             |
   | 1280–1599 px  | 248 px, collapsible to an 88 px rail      | 72 px   | sidebar or rail     |
   | 768–1279 px   | the 88 px rail (between the four targets) | 72 px   | rail                |
   | < 768 px      | none                                      | 56 px   | bottom navigation   |

   The four target sizes — 1920×1080, 1366×768, 1280×800, 390×844 — have no horizontal page
   scroll: every grid track is minmax(0, …), wide content (tables) scrolls inside its wrapper. */

:root {
  --rail-width: 88px;
  --bottomnav-height: 64px;
}

/* ≥ 1600 px: the design system's own values (tokens.json). */
@media (min-width: 1600px) {
  :root { --sidebar-width: 300px; --topbar-height: 96px; }
}

/* 1280–1599 px: narrower sidebar, collapsible; shorter top bar. */
@media (max-width: 1599.98px) {
  :root { --sidebar-width: 248px; --topbar-height: 72px; }
  .rf-topbar { gap: var(--space-4); padding-inline: var(--space-6); }
  .rf-topbar h1 { font-size: 22px; line-height: 30px; }
  .rf-topbar .rf-sub { font-size: 13px; line-height: 18px; }
  .rf-search { flex-basis: 300px; }
  .rf-content { padding-inline: var(--space-6); }
  .rf-banners { padding-inline: var(--space-6); }
  .rf-sidebar { padding: var(--space-5) var(--space-4); }
  .rf-nav-item { padding-inline: var(--space-4); font-size: 16px; }
  .rf-sidebar-toggle, .rf-rail-label { display: grid; }
  .rf-kpi .rf-kpi-value { font-size: 30px; line-height: 40px; }
}

/* Rail (88 px): labels hidden, icons centred. JS shells set .is-rail on the sidebar; PHP shells
   use the rf-rail-toggle checkbox (no script needed). Only in this band; 768–1279 px below forces the rail. */
@media (min-width: 1280px) and (max-width: 1599.98px) {
  .rf-sidebar.is-rail, .rf-shell:has(.rf-rail-toggle:checked) > .rf-sidebar { inline-size: var(--rail-width); padding-inline: var(--space-3); }
  .rf-shell:has(> .rf-sidebar.is-rail), .rf-shell:has(.rf-rail-toggle:checked) { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .rf-sidebar.is-rail .rf-nav-label, .rf-shell:has(.rf-rail-toggle:checked) .rf-nav-label,
  .rf-sidebar.is-rail .rf-usercard-text, .rf-shell:has(.rf-rail-toggle:checked) .rf-usercard-text { display: none; }
  .rf-sidebar.is-rail .rf-nav-item, .rf-shell:has(.rf-rail-toggle:checked) .rf-nav-item { justify-content: center; padding-inline: 0; }
  .rf-sidebar.is-rail .rf-nav-item:not(:has(svg)) .rf-nav-initial, .rf-shell:has(.rf-rail-toggle:checked) .rf-nav-item:not(:has(svg)) .rf-nav-initial { display: inline-block; }
  .rf-sidebar.is-rail .rf-logo, .rf-shell:has(.rf-rail-toggle:checked) .rf-logo { display: none; }
  .rf-sidebar.is-rail .rf-sidebar-head, .rf-shell:has(.rf-rail-toggle:checked) .rf-sidebar-head { flex-direction: column; }
  .rf-sidebar.is-rail .rf-usercard, .rf-shell:has(.rf-rail-toggle:checked) .rf-usercard { justify-content: center; padding: var(--space-2); }
  .rf-sidebar.is-rail .rf-nav-sep, .rf-shell:has(.rf-rail-toggle:checked) .rf-nav-sep { margin-inline: var(--space-2); }
  .rf-shell:has(.rf-rail-toggle:checked) .rf-rail-label .rf-icon--expand { display: block; }
  .rf-shell:has(.rf-rail-toggle:checked) .rf-rail-label .rf-icon--collapse { display: none; }
}

/* Office at 1280–1919 px (owner's request, 10 Nov 2026): the Canva deck's 1920 × 1080 frame scaled
   evenly, as Canva shows it. The page is laid out at the design's 1920 values and the root is
   zoomed to the window (32 px steps), so a 1920 screen at 125 % Windows scaling (1536 px wide)
   shows the deck at 80 %, and fonts and elements keep the deck's proportions. The narrower-window
   rules above do not apply to office pages in this band; tablets (< 1280) and phones keep theirs.
   The sticky sidebar divides its viewport height by the zoom so it still fills the window. */
@media (min-width: 1280px) and (max-width: 1919.98px) {
  @media (min-width: 1280px) and (max-width: 1311.98px) { html:has(> body.rf-app--office) { zoom: 0.6667; --rf-zoom: 0.6667; } }
  @media (min-width: 1312px) and (max-width: 1343.98px) { html:has(> body.rf-app--office) { zoom: 0.6833; --rf-zoom: 0.6833; } }
  @media (min-width: 1344px) and (max-width: 1375.98px) { html:has(> body.rf-app--office) { zoom: 0.7000; --rf-zoom: 0.7000; } }
  @media (min-width: 1376px) and (max-width: 1407.98px) { html:has(> body.rf-app--office) { zoom: 0.7167; --rf-zoom: 0.7167; } }
  @media (min-width: 1408px) and (max-width: 1439.98px) { html:has(> body.rf-app--office) { zoom: 0.7333; --rf-zoom: 0.7333; } }
  @media (min-width: 1440px) and (max-width: 1471.98px) { html:has(> body.rf-app--office) { zoom: 0.7500; --rf-zoom: 0.7500; } }
  @media (min-width: 1472px) and (max-width: 1503.98px) { html:has(> body.rf-app--office) { zoom: 0.7667; --rf-zoom: 0.7667; } }
  @media (min-width: 1504px) and (max-width: 1535.98px) { html:has(> body.rf-app--office) { zoom: 0.7833; --rf-zoom: 0.7833; } }
  @media (min-width: 1536px) and (max-width: 1567.98px) { html:has(> body.rf-app--office) { zoom: 0.8000; --rf-zoom: 0.8000; } }
  @media (min-width: 1568px) and (max-width: 1599.98px) { html:has(> body.rf-app--office) { zoom: 0.8167; --rf-zoom: 0.8167; } }
  @media (min-width: 1600px) and (max-width: 1631.98px) { html:has(> body.rf-app--office) { zoom: 0.8333; --rf-zoom: 0.8333; } }
  @media (min-width: 1632px) and (max-width: 1663.98px) { html:has(> body.rf-app--office) { zoom: 0.8500; --rf-zoom: 0.8500; } }
  @media (min-width: 1664px) and (max-width: 1695.98px) { html:has(> body.rf-app--office) { zoom: 0.8667; --rf-zoom: 0.8667; } }
  @media (min-width: 1696px) and (max-width: 1727.98px) { html:has(> body.rf-app--office) { zoom: 0.8833; --rf-zoom: 0.8833; } }
  @media (min-width: 1728px) and (max-width: 1759.98px) { html:has(> body.rf-app--office) { zoom: 0.9000; --rf-zoom: 0.9000; } }
  @media (min-width: 1760px) and (max-width: 1791.98px) { html:has(> body.rf-app--office) { zoom: 0.9167; --rf-zoom: 0.9167; } }
  @media (min-width: 1792px) and (max-width: 1823.98px) { html:has(> body.rf-app--office) { zoom: 0.9333; --rf-zoom: 0.9333; } }
  @media (min-width: 1824px) and (max-width: 1855.98px) { html:has(> body.rf-app--office) { zoom: 0.9500; --rf-zoom: 0.9500; } }
  @media (min-width: 1856px) and (max-width: 1887.98px) { html:has(> body.rf-app--office) { zoom: 0.9667; --rf-zoom: 0.9667; } }
  @media (min-width: 1888px) and (max-width: 1919.98px) { html:has(> body.rf-app--office) { zoom: 0.9833; --rf-zoom: 0.9833; } }
  html:has(> body.rf-app--office) { --sidebar-width: 300px; --topbar-height: 96px; }
  .rf-app--office .rf-topbar { gap: var(--space-5); padding-inline: 38px 30px; }
  .rf-app--office .rf-topbar h1 { font-size: 26px; line-height: 31px; }
  .rf-app--office .rf-topbar .rf-sub { font-size: 15px; line-height: 18px; }
  .rf-app--office .rf-search { flex-basis: 420px; }
  .rf-app--office .rf-content { padding-inline: 38px 30px; }
  .rf-app--office .rf-banners { padding-inline: 38px 30px; }
  .rf-app--office .rf-sidebar { padding: 28px 20px 24px; }
  .rf-app--office .rf-nav-item { padding-inline: 21px 20px; font-size: 17px; } /* icons at x 41, words at 74 (s29) */
  .rf-app--office .rf-sidebar-toggle, .rf-app--office .rf-rail-label { display: none; }
  .rf-app--office .rf-kpi .rf-kpi-value { font-size: 36px; line-height: 43px; }
  .rf-app--office .rf-shell > .rf-sidebar { block-size: calc(100dvh / var(--rf-zoom, 1)); }
}

/* Office from 1280 px: the deck draws the sidebar 300 wide and the top bar 96 tall with their 2 px
   lines outside them (s29, s65: the line at x 300–302 and y 96–98, the content from x 302 and
   y 98), so the boxes are 302 and 98 with the line inside (border-box). */
@media (min-width: 1280px) {
  html:has(> body.rf-app--office) { --sidebar-width: 302px; --topbar-height: 98px; }
}

/* Manager console (edge, PHP; body.rf-app--console) at 1280–1919 px: the same even zoom as the
   office above (slides 29 and 30, 11 Nov 2026). Console pages are built at the deck's 1920 values;
   tablets (< 1280) and phones keep the narrower-window rules. */
@media (min-width: 1280px) and (max-width: 1919.98px) {
  @media (min-width: 1280px) and (max-width: 1311.98px) { html:has(> body.rf-app--console) { zoom: 0.6667; --rf-zoom: 0.6667; } }
  @media (min-width: 1312px) and (max-width: 1343.98px) { html:has(> body.rf-app--console) { zoom: 0.6833; --rf-zoom: 0.6833; } }
  @media (min-width: 1344px) and (max-width: 1375.98px) { html:has(> body.rf-app--console) { zoom: 0.7000; --rf-zoom: 0.7000; } }
  @media (min-width: 1376px) and (max-width: 1407.98px) { html:has(> body.rf-app--console) { zoom: 0.7167; --rf-zoom: 0.7167; } }
  @media (min-width: 1408px) and (max-width: 1439.98px) { html:has(> body.rf-app--console) { zoom: 0.7333; --rf-zoom: 0.7333; } }
  @media (min-width: 1440px) and (max-width: 1471.98px) { html:has(> body.rf-app--console) { zoom: 0.7500; --rf-zoom: 0.7500; } }
  @media (min-width: 1472px) and (max-width: 1503.98px) { html:has(> body.rf-app--console) { zoom: 0.7667; --rf-zoom: 0.7667; } }
  @media (min-width: 1504px) and (max-width: 1535.98px) { html:has(> body.rf-app--console) { zoom: 0.7833; --rf-zoom: 0.7833; } }
  @media (min-width: 1536px) and (max-width: 1567.98px) { html:has(> body.rf-app--console) { zoom: 0.8000; --rf-zoom: 0.8000; } }
  @media (min-width: 1568px) and (max-width: 1599.98px) { html:has(> body.rf-app--console) { zoom: 0.8167; --rf-zoom: 0.8167; } }
  @media (min-width: 1600px) and (max-width: 1631.98px) { html:has(> body.rf-app--console) { zoom: 0.8333; --rf-zoom: 0.8333; } }
  @media (min-width: 1632px) and (max-width: 1663.98px) { html:has(> body.rf-app--console) { zoom: 0.8500; --rf-zoom: 0.8500; } }
  @media (min-width: 1664px) and (max-width: 1695.98px) { html:has(> body.rf-app--console) { zoom: 0.8667; --rf-zoom: 0.8667; } }
  @media (min-width: 1696px) and (max-width: 1727.98px) { html:has(> body.rf-app--console) { zoom: 0.8833; --rf-zoom: 0.8833; } }
  @media (min-width: 1728px) and (max-width: 1759.98px) { html:has(> body.rf-app--console) { zoom: 0.9000; --rf-zoom: 0.9000; } }
  @media (min-width: 1760px) and (max-width: 1791.98px) { html:has(> body.rf-app--console) { zoom: 0.9167; --rf-zoom: 0.9167; } }
  @media (min-width: 1792px) and (max-width: 1823.98px) { html:has(> body.rf-app--console) { zoom: 0.9333; --rf-zoom: 0.9333; } }
  @media (min-width: 1824px) and (max-width: 1855.98px) { html:has(> body.rf-app--console) { zoom: 0.9500; --rf-zoom: 0.9500; } }
  @media (min-width: 1856px) and (max-width: 1887.98px) { html:has(> body.rf-app--console) { zoom: 0.9667; --rf-zoom: 0.9667; } }
  @media (min-width: 1888px) and (max-width: 1919.98px) { html:has(> body.rf-app--console) { zoom: 0.9833; --rf-zoom: 0.9833; } }
  .rf-app--console .rf-topbar { gap: var(--space-5); padding-inline: 38px 30px; }
  .rf-app--console .rf-topbar h1 { font-size: 26px; line-height: 31px; }
  .rf-app--console .rf-topbar .rf-sub { font-size: 15px; line-height: 18px; }
  .rf-app--console .rf-search { flex-basis: 420px; }
  .rf-app--console .rf-content { padding-inline: 38px 30px; }
  .rf-app--console .rf-banners { padding-inline: 38px 30px; }
  .rf-app--console .rf-sidebar { padding: 28px 20px 24px; }
  .rf-app--console .rf-nav-item { padding-inline: 21px 20px; font-size: 17px; } /* icons at x 41, words at 74 (s29) */
  .rf-app--console .rf-sidebar-toggle, .rf-app--console .rf-rail-label { display: none; }
  .rf-app--console .rf-kpi .rf-kpi-value { font-size: 36px; line-height: 43px; }
  .rf-app--console .rf-shell > .rf-sidebar { block-size: calc(100dvh / var(--rf-zoom, 1)); }
}
/* ≥ 1280 px: the deck's sidebar is 300 px of white and then its 2 px line (x 300–302), the top bar
   96 px and then its line (y 96–98), so content starts at x 340 and y 126. The borders are inside
   the boxes (border-box), so the console's boxes are 302 and 98. */
@media (min-width: 1280px) {
  html:has(> body.rf-app--console) { --sidebar-width: 302px; --topbar-height: 98px; }
}

/* 768–1279 px: the rail only (no toggle). */
@media (max-width: 1279.98px) {
  .rf-shell:not(.rf-shell--bare) { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .rf-shell > .rf-sidebar { inline-size: var(--rail-width); padding-inline: var(--space-3); }
  .rf-shell > .rf-sidebar .rf-nav-label, .rf-shell > .rf-sidebar .rf-usercard-text, .rf-shell > .rf-sidebar .rf-logo { display: none; }
  .rf-shell > .rf-sidebar .rf-nav-item { justify-content: center; padding-inline: 0; }
  .rf-shell > .rf-sidebar .rf-nav-item:not(:has(svg)) .rf-nav-initial { display: inline-block; }
  .rf-shell > .rf-sidebar .rf-usercard { justify-content: center; padding: var(--space-2); }
  .rf-sidebar-toggle, .rf-rail-label { display: none; }
  .rf-search { flex-basis: 220px; min-inline-size: 140px; }
  .rf-content { padding-inline: var(--space-5); }
  .rf-banners { padding-inline: var(--space-5); }
}

/* < 1024 px: the search field is dropped (no room next to the pill, the switch and the bell). */
@media (max-width: 1023.98px) {
  .rf-search { display: none; }
}

/* < 768 px (phones): no sidebar, bottom navigation, 56 px top bar. */
@media (max-width: 767.98px) {
  :root { --sidebar-width: 0px; --topbar-height: 56px; }
  .rf-shell, .rf-shell:not(.rf-shell--bare) { grid-template-columns: minmax(0, 1fr); }
  .rf-shell > .rf-sidebar { display: none; }
  .rf-bottomnav { display: flex; }
  .rf-shell--bare ~ .rf-bottomnav, .rf-shell--bare .rf-bottomnav { display: none; }
  .rf-topbar { gap: var(--space-2); padding-inline: var(--space-4); }
  .rf-topbar h1 { font-size: 18px; line-height: 24px; }
  .rf-topbar .rf-sub { display: none; }
  .rf-topbar-logo { block-size: 36px; }
  .rf-topbar-tools { gap: var(--space-2); }
  .rf-topbar-menu { display: grid; }
  /* The pill keeps its dot; the words stay for screen readers. */
  .rf-sync { inline-size: 36px; min-inline-size: 0; padding: 0; justify-content: center; }
  .rf-sync-text { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .rf-lang-item { min-inline-size: 28px; padding: 0 var(--space-1); }
  /* The deck's 170 px pill and 80 px switch box (rf-app.css) are desktop sizes: on a phone the
     tools are the dot, the two letters and the bell, so the top bar fits 390 px. */
  .rf-topbar .rf-lang { min-inline-size: 0; gap: 0; }
  .rf-content { padding: var(--space-4); padding-block-end: calc(var(--bottomnav-height) + var(--fab-size) + var(--space-6) + env(safe-area-inset-bottom)); gap: var(--space-4); }
  .rf-shell--bare .rf-content { padding-block-end: var(--space-5); }
  .rf-banners { padding: var(--space-2) var(--space-4) 0; }
  .rf-panel { padding: var(--space-5); border-radius: var(--radius-xl); }
  .rf-kpis { gap: var(--space-3); }
  .rf-kpi { padding: var(--space-4) var(--space-5); min-block-size: 120px; padding-inline-end: calc(44px + var(--space-5) * 2); }
  .rf-kpi .rf-kpi-value { font-size: 26px; line-height: 34px; }
  .rf-qa { inset-block-end: calc(var(--bottomnav-height) + var(--space-4) + env(safe-area-inset-bottom)); inset-inline-end: var(--space-4); }
  .rf-qa-menu { inline-size: min(296px, calc(100vw - 2 * var(--space-4))); }
  .rf-error-code { font-size: 48px; }
  .rf-ticket-grid { grid-template-columns: minmax(0, 1fr); }
  .rf-tray { position: fixed; inset-block-start: calc(var(--topbar-height) + var(--space-2)); inset-inline: var(--space-4); inline-size: auto; }
  .rf-tray-banner { inset-inline: var(--space-4); inset-block-end: calc(var(--bottomnav-height) + var(--space-3)); }
  .rf-station-head { padding-inline: var(--space-4); gap: var(--space-3); }
  .rf-station-head h1, .rf-station-clock { font-size: 20px; line-height: 28px; }
}

/* Every width: grids that would overflow a phone get a min() track. */
.rf-kpis { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
@media (min-width: 1600px) {
  .rf-kpis { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
}
.rf-floor { grid-template-columns: repeat(auto-fill, minmax(112px, 112px)); }
