/* shared/app-shell.css - the design system's SHELL layer, on the app's own state carriers.

   Loaded by all three shells (authenticated, manage, public) after shared/common.css: the app
   bar, the side nav, the admin header menus, the identity menu, the page layout and its
   breakpoints. The 58px bar, the 232px rail and the 1279/1280 rail breakpoint are the system's
   own values and the app's LOCKED CO-PAIRS (UI_CONTRACTS.md), so they are written exactly once
   each in this layer.

   THE VALUES ARE THE SYSTEM'S; THE STATE SELECTORS ARE THE APP'S. The system keys open/closed
   on what a script writes (aria-expanded, .is-open, body.nav-collapsed, [hidden] on the user
   menu). This application holds that state in markup the browser owns - one checkbox per
   nav-edge presentation (#nav-edge below 1280px, #nav-collapse at 1280px and up), a <details>
   per identity menu, the `hidden` attribute on the admin popups - so navigation works with
   scripting DISABLED (owner decision O6, EN 301 549). js/shared/app-nav.js only presses the
   same controls: it adds no class, sets no `hidden` and writes no `aria-expanded`. Every state
   rule below reads one of those carriers, and each substitution is marked `APP:`.

   After the system's layer come the APP-OWNED rules: what the system does not define and a
   shell, or a surface two shells render, still needs - each with its reason. */


/* == THE SYSTEM'S SHELL LAYER (state selectors re-keyed onto the app's carriers) == */

/* ---- App bar ------------------------------------------------------------- */
/* APP: z-index 50, not the system's 30. With scripting off nothing closes one panel when the
   other opens, so the identity menu can be open over the nav overlay. `.appbar` is a stacking
   context (sticky + z-index), so at 30 the menu's 46 is scoped BENEATH the scrim (44): the rows
   render and none of them can be pressed. Above the scrim and the overlay (45), they can. */
.appbar { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-page) 85%, transparent); backdrop-filter: blur(12px); }
.appbar .inner { display: flex; align-items: center; gap: var(--space-5); height: 58px;
  max-width: var(--shell-max); margin-inline: auto; padding-inline: var(--edge); }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--text-strong);
  font-family: var(--font-heading); font-weight: var(--font-strong-weight); letter-spacing: -0.02em; font-size: var(--size-lg); }
.brand:hover { color: var(--text-strong); }
/* APP: `flex: 0 0 auto`. The mark is a flex item of `.brand`, and once the bar also holds the
   language chooser it was squeezed under its own 26px at 360px; the wordmark gives way instead. */
.brand .logo { width: 26px; height: 26px; flex: 0 0 auto; }
.spacer { flex: 1 1 auto; }
/* the public shell's conversion actions, at rail width and up */
.bar-controls { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.appbar .select { width: auto; font-size: var(--size-sm); padding-block: 6px; }
.site-foot .select { width: auto; font-size: var(--size-xs); padding-block: 4px; background-color: transparent; border-color: var(--line); color: var(--text-muted); }
.appbar-id { white-space: nowrap; }
/* marks the admin shell apart from the customer shell */
.admin-chip { font-size: var(--size-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-text);
  border: 1px solid var(--accent-line-subtle); border-radius: var(--radius-pill); padding: 2px 9px; }
.avatar { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent-text); border: 1px solid var(--accent-line-subtle);
  font-size: var(--size-xs); font-weight: var(--font-strong-weight); }

/* ---- Left-edge trigger: the side nav's visible origin -------------------- */
/* APP: `position: relative`. This trigger is a <label> that CONTAINS the checkbox holding its
   state, parked out of sight but still focusable; without a positioned ancestor the input would
   anchor to `.appbar`, and focusing it could scroll the bar. */
.nav-edge { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); height: 34px;
  padding: 0 var(--space-3) 0 var(--space-2); font: inherit; color: var(--text-muted);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; }
.nav-edge:hover { color: var(--text); background: var(--surface-hover); }
/* APP: the system's `[aria-expanded="true"]` means "the panel is out". The two presentations'
   checkboxes mean that OPPOSITELY - checked below 1280px (the overlay is open), UNchecked at
   1280px and up (the rail column is expanded) - so the pressed ground and the chevron are keyed
   per presentation and always agree with each other and with the panel. Each label is
   display:none outside its own width, so no media query is needed here. */
.nav-edge--open:has(.shell-toggle:checked),
.nav-edge--collapse:not(:has(.shell-toggle:checked)) { color: var(--text-strong); background: var(--surface-overlay); border-color: var(--line-strong); }
.nav-edge-grip { width: 3px; height: 17px; border-radius: 2px; background: var(--accent); }
.nav-edge-chev { width: 16px; height: 16px; transition: transform .16s; }
.nav-edge--open:has(.shell-toggle:checked) .nav-edge-chev,
.nav-edge--collapse:not(:has(.shell-toggle:checked)) .nav-edge-chev { transform: rotate(180deg); }

/* ---- Identity trigger + user menu ---------------------------------------- */
/* APP: `list-style: none` and the WebKit marker reset below. The trigger is a <summary>, whose
   UA disclosure triangle the system's <button> never had; each line silences one engine family. */
.user-btn { display: inline-flex; align-items: center; gap: var(--space-3); padding: 3px 10px 3px 3px;
  font: inherit; font-size: var(--size-sm); white-space: nowrap; color: var(--text-secondary);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-pill); cursor: pointer;
  list-style: none; }
.user-btn::-webkit-details-marker { display: none; }
.user-btn:hover { color: var(--text-strong); background: var(--surface-hover); border-color: var(--line-strong); }
/* APP: `[aria-expanded="true"]` re-keyed to the <details> the browser opens itself. */
.user-nav[open] > .user-btn { color: var(--text-strong); background: var(--surface-overlay); border-color: var(--line-strong); }
.user-btn-hint { color: var(--text-faint); font-size: var(--size-xs); }
/* APP: `display: inline-block` and the transition. A transform on an inline box is ignored, and
   the rotation below is the app's open cue; the system's caret does not turn. */
.user-btn-caret { color: var(--text-muted); font-size: 11px; line-height: 1; display: inline-block; transition: transform .16s; }
.user-nav[open] > .user-btn .user-btn-caret { transform: rotate(180deg); }
/* APP: the anonymous (public) trigger shows only below rail width. The system hides the trigger
   itself; here it is the <summary> of a <details>, and hiding only the summary would strand an
   already-open menu with no control once a window is widened past 1280px (the public shell
   loads no script that could close it). So the whole <details> is what hides. */
.user-nav:has(> .user-btn--anon) { display: none; }

/* anchored to the sticky app bar, so it hangs under the bar's right edge. No `[hidden]` rule:
   the <details> around it hides it natively, and nothing here ever writes `hidden` on it. */
.user-menu { position: absolute; top: calc(100% + 6px); right: var(--edge); z-index: 46;
  min-width: 254px; max-width: calc(100vw - var(--edge) * 2); padding: var(--space-4);
  background: var(--surface-overlay); border: 1px solid var(--line-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.user-menu-head { display: flex; align-items: center; gap: var(--space-3); min-width: 0;
  padding-bottom: var(--space-4); margin-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.user-menu-id { display: flex; flex-direction: column; min-width: 0; }
.user-menu-name { color: var(--text-strong); font-weight: var(--font-strong-weight); font-size: var(--size-sm); }
.user-menu-mail { color: var(--text-muted); font-size: var(--size-xs); overflow: hidden; text-overflow: ellipsis; }
/* The system's labelled configuration row is NOT carried: its one member is a language chooser,
   and the owner ruled on 2026-08-15 that the language control is part of the header bar at every
   width and never sits inside a menu. A rule with no markup would invite the row back. */
.user-menu-item { display: flex; align-items: center; gap: var(--space-3); padding: 8px 9px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--size-sm); }
.user-menu-item:hover { color: var(--text-strong); background: var(--surface-hover); }
.user-menu-item .i { width: 17px; height: 17px; color: var(--text-muted); }

/* ---- Side navigation ----------------------------------------------------- */
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav .group { font-size: var(--size-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint);
  padding: var(--space-4) var(--space-3) var(--space-2); }
.sidenav a { display: flex; align-items: center; gap: var(--space-3); padding: 8px 11px; border-radius: var(--radius-md);
  color: var(--text-muted); font-size: var(--size-sm); border-left: 2px solid transparent; transition: color .14s, background .14s; }
.sidenav a .i { width: 18px; height: 18px; color: var(--text-muted); }
.sidenav a:hover { color: var(--text); background: var(--surface-hover); }
.sidenav a[aria-current] { color: var(--text-strong); background: var(--accent-tint); border-left-color: var(--accent); }
.sidenav a[aria-current] .i { color: var(--accent-strong); }

/* ---- Admin header category menus (wide viewports) ------------------------
   Open/closed is the popup's `hidden` attribute and nothing else - js/manage/shell.js reads and
   writes it, and no rule below may give `.appnav-pop` an unconditional `display`. */
.appnav { min-width: 0; }
.appnav-bar { display: flex; align-items: center; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.appnav-bar > li { position: relative; }
.appnav-top { display: inline-flex; align-items: center; gap: var(--space-2); padding: 6px 10px; white-space: nowrap;
  font: inherit; font-weight: 500; font-size: var(--size-sm); color: var(--text-muted);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer;
  transition: color .14s, background .14s, border-color .14s; }
.appnav-top:hover { color: var(--text); background: var(--surface-hover); }
.appnav-top[aria-expanded="true"] { color: var(--text-strong); background: var(--surface-overlay); }
.appnav-top[aria-current] { color: var(--text-strong); border-color: var(--accent-line-subtle); box-shadow: 0 0 0 1px var(--accent-glow-soft); }
.appnav-top .caret { width: 15px; height: 15px; color: var(--text-faint); transition: transform .14s, color .14s; }
.appnav-top:hover .caret { color: var(--text-secondary); }
.appnav-top[aria-expanded="true"] .caret { color: var(--text-secondary); transform: rotate(180deg); }
.appnav-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 214px; margin: 0;
  padding: var(--space-3); list-style: none; background: var(--surface-overlay); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.appnav-pop:not([hidden]) { display: flex; flex-direction: column; gap: 1px; }
/* destinations are text only: the rail carries icons, the header carries categories */
.appnav-pop a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); white-space: nowrap;
  color: var(--text-secondary); font-size: var(--size-sm); border-left: 2px solid transparent; transition: color .14s, background .14s; }
.appnav-pop a:hover { color: var(--text-strong); background: var(--surface-hover); }
.appnav-pop a[aria-current] { color: var(--text-strong); background: var(--accent-tint); border-left-color: var(--accent); }

/* ---- Layout -------------------------------------------------------------- */
.app-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); max-width: var(--shell-max); margin-inline: auto; }
.app-aside { position: sticky; top: 58px; align-self: start; min-height: calc(100vh - 58px);
  padding: var(--space-6) var(--space-5); border-right: 1px solid var(--line); }
.app-main { min-width: 0; padding: var(--space-12) var(--edge) var(--space-24); }
/* marketing shells own their rhythm (.section, .band) and gutters (.shell) */
.app-main--flush { padding: 0; }
.page-head { margin-bottom: var(--space-12); }
.page-head .crumb { font-size: var(--size-xs); color: var(--text-muted); letter-spacing: 0.04em; }
.nav-scrim { display: none; }

/* Below 1280px the side nav is an off-canvas popout over the content. */
@media (max-width: 1279px) {
  .app-layout { grid-template-columns: minmax(0, 1fr); }
  .app-aside { position: fixed; top: 58px; left: 0; bottom: 0; z-index: 45; width: min(300px, 84vw);
    min-height: 0; align-self: auto; padding: var(--space-6) var(--space-5) var(--space-8);
    background: var(--surface-page); border-right: 1px solid var(--line); box-shadow: var(--shadow-lg);
    overflow-y: auto; overscroll-behavior: contain;
    /* closed: hidden from focus as well as from view */
    transform: translateX(-100%); visibility: hidden; transition: transform .18s ease, visibility 0s linear .18s; }
  /* APP: `.app-aside.is-open` and `.nav-scrim.is-open` re-keyed to the overlay's checkbox. The
     trigger is in `.appbar` and the panel in `.app-layout` - their only common ancestor is
     <body> - so the panel, the dimmer and the scroll lock below all read the same one bit. */
  body:has(#nav-edge:checked) .app-aside { transform: none; visibility: visible; transition: transform .18s ease, visibility 0s; }
  body:has(#nav-edge:checked) .nav-scrim { display: block; position: fixed; inset: 58px 0 0; z-index: 44;
    background: oklch(0.10 0.02 275 / 0.62); backdrop-filter: blur(2px); }
  .admin-chip { display: none; }
  .bar-controls { display: none; }
  .user-nav:has(> .user-btn--anon) { display: inline-flex; }
  .appbar .appnav { display: none; }
}
/* At 1280px and up the side nav is a column of the page, collapsible in place. A shell with a
   rail spans the viewport so the rail sits flush at the left edge under its trigger; the content
   keeps its own readable cap inside the column. */
@media (min-width: 1280px) {
  .app-layout, body:has(.app-layout) .appbar .inner { max-width: none; margin-inline: 0; }
  body:has(.app-layout) .appbar .inner { padding-inline: var(--space-5); }
  .app-main:not(.app-main--flush) > * { max-width: var(--content-max); margin-inline: auto; }
  /* APP: `body.nav-collapsed` re-keyed to the collapse checkbox. */
  body:has(#nav-collapse:checked) .app-layout { grid-template-columns: minmax(0, 1fr); }
  body:has(#nav-collapse:checked) .app-aside { display: none; }
}
@media (max-width: 1080px) { .appbar-id { display: none; } }
@media (max-width: 900px) { .user-btn-hint, .bar-back { display: none; } }
@media (max-width: 620px) { .user-btn-label { display: none; } }


/* == APP-OWNED ADDITIONS (no system counterpart) ========================== */

/* ---- The CSS-only state carriers ----------------------------------------- */
/* The checkbox is parked out of sight but stays FOCUSABLE and Space-operable: `display: none`
   or `visibility: hidden` would take it out of the focus order and the control with it. */
.shell-toggle { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap; -webkit-appearance: none; appearance: none; }
/* ONE edge per width: below 1280px the overlay's, at 1280px and up the column's. Hiding the
   label hides its input too, because the input sits inside it - no phantom tab stop. */
.nav-edge--collapse { display: none; }
@media (min-width: 1280px) {
  .nav-edge--open { display: none; }
  .nav-edge--collapse { display: inline-flex; }
}
/* The focus ring for a picker sits on the label the user sees, not on its hidden input; the
   system's floor rings buttons, summaries and links, never a <label>. */
.nav-edge:has(.shell-toggle:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The <details> owns open/closed and must add no box of its own between the bar's row and the
   trigger. `position: static` is load-bearing: `.user-menu` anchors to the sticky `.appbar`, and
   a positioned wrapper here would re-anchor the menu to a 34px chip. */
.user-nav { display: inline-flex; position: static; }
/* The scroll lock: the third face of the overlay's open state, beside the panel and the scrim,
   read off the same checkbox. It MUST stay inside this media query - at 1280px and up the same
   checkbox can be checked with the rail rendered as a column and nothing covering the page. */
@media (max-width: 1279px) {
  body:has(#nav-edge:checked) { overflow: hidden; }
}
/* The identity menu's ACTION rows (Cookie settings, Sign out) are real <button>s, because they
   are actions, not destinations. This cancels the UA's button chrome and states nothing else:
   ground, padding, colour, hover and focus still come from `.user-menu-item`. The name is read by
   js/shared/app-nav.js, which closes the menu after a click on one. */
.user-menu-item--button { appearance: none; -webkit-appearance: none;
  margin: 0; border: 0; background: transparent;
  font-family: inherit; font-weight: inherit; line-height: inherit;
  text-align: left; cursor: pointer; }

/* ---- The admin menubar with no JavaScript ---------------------------------
   Owner decision O6. js/manage/shell.js stamps `data-appnav-js` on the menubar it wires; until it
   does, hover and focus-within open a popup, so the destinations stay reachable with scripting
   off. Guarded on that marker, never on `.no-js`, so the two mechanisms can never fight. The
   `::after` strip bridges the 6px gap between a trigger and its popup for a pointer. */
.appnav:not([data-appnav-js]) li:hover > .appnav-pop[hidden],
.appnav:not([data-appnav-js]) li:focus-within > .appnav-pop[hidden] {
  display: flex; flex-direction: column; gap: 1px; }
.appnav:not([data-appnav-js]) li:hover > .appnav-top,
.appnav:not([data-appnav-js]) li:focus-within > .appnav-top {
  color: var(--text-strong); background: var(--surface-overlay); }
.appnav:not([data-appnav-js]) li:hover > .appnav-top .caret,
.appnav:not([data-appnav-js]) li:focus-within > .appnav-top .caret {
  color: var(--text-secondary); transform: rotate(180deg); }
.appnav:not([data-appnav-js]) li:hover::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 8px; }

/* ---- The bar at narrow widths --------------------------------------------- */
/* The language chooser is part of the header bar at EVERY width (owner ruling 2026-08-15), so a
   phone bar holds the nav edge, the brand, the chooser and the identity trigger at once. The
   three controls never shrink; the wordmark is the one item that gives way, so it is the one
   item allowed to (`min-width: 0` on every bar item, because a flex item otherwise refuses to
   shrink below its own content). Keyed on `.inner >` so it governs the bar's own row only. */
.appbar .inner > * { min-width: 0; }
.appbar .inner > .nav-edge,
.appbar .inner > .selector-form,
.appbar .inner > .user-nav { flex: 0 0 auto; }
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the wordmark stands down before it starts losing letters - an ellipsis only reads as a brand
   while it still shows a word; below this width the mark carries the brand alone */
@media (max-width: 480px) {
  .appbar .brand-name { display: none; }
}
/* the chooser goes compact instead of going away: a closed <select> is as wide as its longest
   option, and the options and the no-script Apply are translated strings; the bar's own gaps
   tighten with it */
@media (max-width: 620px) {
  .appbar .select { width: 68px; }
  .appbar .inner { gap: var(--space-3); }
}

/* ---- Layout variants and page regions ------------------------------------ */
/* A layout with no rail (the manage sign-in and error pages, and the public auth stage) would
   auto-place <main> into the 232px rail column at 1280px and up and render the whole page 232px
   wide with nothing overflowing. Keyed to the variant, so a future rail-less page cannot forget. */
.app-layout:not(:has(.app-aside)) { grid-template-columns: minmax(0, 1fr); }
/* The rail row's label: a flex item defaults to `min-width: auto` and refuses to shrink below its
   longest word, and translated labels are longer than English ones. This lets it wrap in place. */
.sidenav__label { min-width: 0; }
/* The gap between two page regions the shell stacks in `.app-main` (the flash region, the page).
   `:not([hidden])` is load-bearing: an empty flash region carries `hidden`, and an adjacent-
   sibling combinator still matches across it. */
.app-page:not([hidden]) + .app-page { margin-top: var(--space-12); }
/* Single-card and state-column measures. The combinator is the fix: a bare class (0,1,0) loses
   to `.app-main:not(.app-main--flush) > *` (0,2,0), and these come after that rule. */
.app-main > .status-card { max-width: var(--prose-max); margin-inline: auto; }
.app-main > .state-col { max-width: var(--prose-max); margin-inline: auto; }

/* ---- Two-column value lists (`.dl`, the system's) ------------------------- */
/* The value column of a `.dl` breaks an unbroken word rather than spilling past its card: a
   hostname or a single translated compound is routinely wider than a narrow column, and only
   `anywhere` lets the item's minimum size shrink with it. */
.dl dd { overflow-wrap: anywhere; }
/* The money breakdown's total row and its rule (macros/pricing.html `price_tax_line`, the deploy
   summary). `grid-column: 1 / -1` makes the rule span both tracks. */
.dl .rule { grid-column: 1 / -1; margin-block: var(--space-3); }
.dl .t { color: var(--text-strong); font-weight: var(--font-strong-weight); }

/* ---- The server card's top row (dashboard and server list) --------------- */
/* `flex-wrap` changes what yields when the row is short of room: the chip moves to the next line
   at its own width instead of being crushed beside a long server name. */
.srv-card .top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
/* The trailing chip sits at the right edge - but only a chip: a server with no plan makes the
   NAME the last child, and it must not be flung across the card. */
.srv-card .top > :last-child:not(strong):not(.name) { margin-left: auto; }
.dot-power.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-power.off { background: var(--text-muted); }

/* ---- MFA enrolment QR (the customer and the admin enrolment pages) -------
   Owned here because this is the one sheet both enrolment pages' shells load. The plate is a
   literal white and must stay one: a QR needs a light quiet zone to decode (the app's codes are
   dark strokes on transparency). The literal is allowlisted for these two selectors. */
.mfa-qr { display: flex; flex-direction: column; margin: 0; min-width: 0; }
.mfa-qr__code {
  display: inline-flex; padding: var(--space-5); width: 100%;
  background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  line-height: 0; margin: 0; appearance: none; -webkit-appearance: none;
  font: inherit; color: inherit; cursor: zoom-in;
}
.mfa-qr__code svg { display: block; width: 100%; height: auto; }
.mfa-qr__caption { font-size: var(--size-xs); color: var(--text-muted); margin: 0; }
@media (max-width: 720px) {
  /* the width at which both enrolment grids collapse to one column */
  .mfa-qr__code { max-width: 260px; }
}
/* the enlarged code's plate inside the dialog (the overlay itself is `.mfa-qr-modal`, in
   shared/common.css) */
.mfa-qr-modal__inner { display: flex; flex-direction: column; align-items: center;
  gap: var(--space-6); max-width: 100%; }
.mfa-qr-modal__fig {
  display: inline-flex; padding: var(--space-6);
  background: #fff;
  border-radius: var(--radius-md); line-height: 0;
}
.mfa-qr-modal__fig svg { display: block; width: 400px; max-width: 80vw; height: auto; }
.mfa-qr-modal__close { color: var(--text-strong); font-size: var(--size-md);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
