/* The Zeus app shell (base.html), drawn the same as the React shell (frontend/src/shell/):
   dark NavRail 184px, the three-band page header, body on --canvas with 20px gutters.
   Rail: disclosure group headings, the Auto-hide / Pinned open mode button, tenant footer. From
   761px to 1100px the rail shows icons only and peeks open on hover or keyboard focus (shell.js);
   below 761px it is an overlay drawer. Plus the standalone (signed-out) layouts. */

.app { display: flex; min-height: 100vh; }
.app-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }

/* ---- NavRail ---- */
.rail {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: 100vh;
  height: 100dvh;
  color: var(--shell-ink-body);
  font-family: var(--font-sans);
  transition: width var(--duration-layout) var(--ease), flex-basis var(--duration-layout) var(--ease);
}
/* The panel fills the rail; a peek widens it over the page. */
.rail-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border-right: 1px solid var(--shell-line);
  background: var(--shell-bg);
  transition: width var(--duration-layout) var(--ease);
}
.rail :focus-visible { outline: none; box-shadow: 0 0 0 2px var(--shell-bg), 0 0 0 4px var(--focus-ring-dark); }
.rail-top {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  min-height: var(--rail-top-h);
  padding: 16px 12px 14px;
}
.rail-brand {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border-radius: var(--rail-row-radius);
  text-decoration: none;
}
.rail-brand-text { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; height: 28px; overflow: hidden; }
.rail-brand-name,
.rail-landing { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-brand-name { font: var(--weight-heading) var(--text-row)/1.25 var(--font-sans); color: var(--shell-ink-title); }
.rail-landing { font: var(--weight-body) var(--text-meta)/1 var(--font-sans); color: var(--rail-home-ink); }
.rail-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-control);
  color: var(--shell-ink-body);
}
.rail-groups {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 8px 8px;
  scrollbar-color: var(--rail-scroll-thumb) transparent;
  scrollbar-width: thin;
}
.rail-group { margin-bottom: 14px; }
/* Group heading: a disclosure. The group holding the current page can't be shut. */
.rail-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 1px;
  padding: 2px 8px 4px;
  border: 0;
  border-radius: var(--rail-row-radius);
  background: transparent;
  font: var(--weight-heading) var(--text-rail-group)/14px var(--font-sans);
  letter-spacing: var(--tracking-rail);
  text-align: left;
  text-transform: uppercase;
  color: var(--rail-group-head-ink);
  cursor: pointer;
}
.rail-group-head[aria-disabled="true"] { cursor: default; }
.rail-group-name { flex: 1; min-width: 0; }
.rail-chevron { transition: transform var(--duration-tint) var(--ease); }
.rail-group-head[aria-expanded="false"] .rail-chevron { transform: rotate(-90deg); }
.rail-group[data-shut] .rail-list { display: none; }
.no-js .rail-group-head { pointer-events: none; }
.no-js .rail-chevron { display: none; }
.rail-list { display: flex; flex-direction: column; gap: var(--rail-row-step); margin: 0; padding: 0; list-style: none; }
.rail-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--rail-row-h);
  padding: 0 8px;
  border-radius: var(--rail-row-radius);
  font: var(--weight-body) var(--text-row)/18px var(--font-sans);
  color: var(--shell-ink-body);
  text-decoration: none;
  transition: background-color var(--duration-tint) var(--ease), color var(--duration-tint) var(--ease);
}
.rail-link .icon { opacity: 0.85; }
.rail-link:hover { background: var(--shell-hover-bg); color: var(--shell-hover-ink); }
.rail-link[aria-current="page"] {
  background: var(--shell-active-bg);
  box-shadow: var(--ring-active-edge);
  color: var(--shell-ink-title);
  font-weight: var(--weight-control);
}
.rail-link[aria-current="page"]:focus-visible { box-shadow: var(--ring-active-edge), 0 0 0 2px var(--shell-bg), 0 0 0 4px var(--focus-ring-dark); }
.rail-link[aria-current="page"] .icon { stroke-width: 2.2; }
.rail-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The kit's row badge, a red count pill (React NavRail.module.css .badge); open rail only. */
.rail-badge {
  flex-shrink: 0;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--rail-badge-bg);
  color: var(--rail-badge-ink);
  font: 700 10px/16px var(--font-sans);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
/* Auto-hide / Pinned open (Zeus NavRail mode). shell.js keeps the label and aria-pressed. */
.rail-mode {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  height: 32px;
  margin: 0 8px 6px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--rail-row-radius);
  background: transparent;
  color: var(--rail-group-head-ink);
  font: var(--weight-control) var(--text-row)/1 var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-tint) var(--ease), color var(--duration-tint) var(--ease);
}
.rail-mode:hover { background: var(--shell-hover-bg); color: var(--shell-hover-ink); }
.rail-mode[aria-pressed="true"] { background: var(--shell-pill-bg); color: var(--shell-ink-title); }
.rail-mode[aria-pressed="true"] .icon { stroke-width: 2.2; }
.rail-mode .icon-pinned,
.rail-mode[aria-pressed="true"] .icon-auto { display: none; }
.rail-mode[aria-pressed="true"] .icon-pinned { display: inline-block; }
.no-js .rail-mode { display: none; }
.rail-tenant {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--shell-line);
  font: var(--weight-control) var(--text-row)/1.3 var(--font-sans);
}
.tenant-tile {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-shell-control);
  background: var(--shell-pill-bg);
  font: var(--weight-heading) var(--text-meta)/1 var(--font-sans);
}
.rail-tenant-text { display: flex; flex-direction: column; }
.rail-tenant-name,
.rail-tenant-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-tenant-line { font: var(--weight-body) 10.5px/1.3 var(--font-sans); color: var(--rail-tenant-sub-ink); }

/* The Zeus mid width at or below 1439px (kit NavRail.jsx; React's AppShell `MID`). */
@media (min-width: 1101px) and (max-width: 1439px) {
  .rail { flex-basis: var(--rail-w-md); width: var(--rail-w-md); }
}

/* Icons only from 761px to 1100px (as React's NavRail): no headings, a rule between groups,
   names kept for assistive tech and in each row's title. A peek (shell.js) opens it over the page. */
@media (min-width: 761px) and (max-width: 1100px) {
  .rail { flex-basis: var(--rail-w-collapsed); width: var(--rail-w-collapsed); }
  .rail.is-peek .rail-panel { z-index: 30; width: var(--rail-w); box-shadow: var(--rail-peek-shadow); }
  .rail:not(.is-peek) .rail-top { justify-content: center; padding-inline: 0; }
  .rail:not(.is-peek) .rail-brand { flex: none; }
  .rail:not(.is-peek) .rail-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .rail:not(.is-peek) .rail-group-head { display: none; }
  .rail:not(.is-peek) .rail-group { margin-bottom: 0; }
  .rail:not(.is-peek) .rail-group + .rail-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rail-separator); }
  .rail:not(.is-peek) .rail-group[data-shut] .rail-list { display: flex; }
  .rail:not(.is-peek) .rail-link { justify-content: center; padding: 0; }
  .rail:not(.is-peek) .rail-badge { display: none; }
  .rail:not(.is-peek) .rail-tenant { justify-content: center; padding-inline: 0; }
  /* The mode button is for wide screens, as in React. */
  .rail-mode { display: none; }
}

/* ---- The three-band page header (sticky on wide screens; shell.js publishes its height as
   --app-header-h). Band 1: menu button (narrow), the page's title (ui.page_header), the account
   menu; bands 2 and 3 span the full width below it. ---- */
/* The strip and the header stick together (base.html .app-top): the strip stays pinned above the
   page, as in the kit's ShellFrame.jsx. */
.app-top {
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header {
  position: relative;
  display: grid;
  grid-template-columns: var(--gutter-page) auto minmax(0, 1fr) auto auto var(--gutter-page);
  grid-template-rows: minmax(var(--band-1-h), auto);
  align-items: center;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--surface);
}
.topbar-menu {
  grid-row: 1;
  grid-column: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0 6px 0 -6px;
  border-radius: var(--radius-control);
  color: var(--ink-secondary);
}
.topbar-menu:hover { background: var(--surface-track); color: var(--ink-primary); }
.band-identity { grid-row: 1; grid-column: 3; min-width: 0; padding-right: 12px; }
.band-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; min-width: 0; }
.band-title-line h1 { min-width: 0; overflow-wrap: anywhere; }
.band-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.band { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; padding: 0 var(--gutter-page); border-top: 1px solid var(--line-faint); }
.band-2 { gap: 6px 14px; min-height: var(--band-2-h); }
.band-axis { display: flex; flex: 1 1 auto; align-items: center; min-width: 0; }
.band-actions { display: flex; flex-shrink: 0; flex-wrap: wrap; align-items: center; gap: 7px; max-width: 100%; padding: 7px 0; }
.band-3 { gap: 9px; min-height: var(--band-3-h); padding-block: 6px; background: var(--surface-band); }
.band-note { min-width: 0; font: var(--weight-body) var(--text-body)/17px var(--font-sans); color: var(--ink-muted); }

/* A tabbed section's tabs in band 2 (the Configuration section, templates/_configuration.html):
   real links, drawn as React PageHeader's underline axis (PageHeader.module.css .axisUnderline). */
.band-axis:has(> .band-tabs) { align-self: stretch; align-items: flex-end; }
.band-tabs { display: flex; align-items: flex-end; gap: 2px; min-width: 0; max-width: 100%; overflow-x: auto; }
.band-tab {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 11px;
  border-bottom: 2px solid transparent;
  color: var(--ink-secondary);
  font: var(--weight-control) var(--text-row)/1 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
}
.band-tab:hover { color: var(--ink-primary); }
.band-tab[aria-current="page"] { border-bottom-color: var(--action-primary); color: var(--ink-brand); font-weight: var(--weight-emphasis); }
.band-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 17px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--tone-neutral-fill);
  color: var(--tone-neutral-ink);
  font: var(--weight-emphasis) 11px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.band-tab[aria-current="page"] .band-tab-count { background: var(--tone-info-fill); color: var(--ink-brand); }
/* A tab holding a problem: its count takes the tone, selected or not (the title says what). */
.band-tab-warning .band-tab-count,
.band-tab-warning[aria-current="page"] .band-tab-count { background: var(--tone-warning-fill); color: var(--tone-warning-ink); }

/* Under a tabbed section's header: the page's own title when it isn't its tab's, with the way
   back, then its note (kit KitHeader: 14px above, then the page's 20px). */
.cfg-subhead { display: flex; flex-direction: column; gap: 4px; margin: -6px 0 20px; }
.cfg-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cfg-back { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-brand); font: var(--weight-emphasis) 12.5px/18px var(--font-sans); text-decoration: none; }
.cfg-back:hover { color: var(--link-hover); text-decoration: underline; }
.cfg-sep { color: var(--ink-faint); } /* decorative: aria-hidden, never text that is read */
.cfg-title { margin: 0; color: var(--ink-primary); font: 700 17px/24px var(--font-sans); }
.cfg-note { margin: 0; color: var(--ink-muted); font-size: 12.5px; line-height: 18px; text-wrap: pretty; }

/* Band 2, right side: links out of the page, a hairline divider, then the actions (React
   PageHeader `links`). */
.band-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font: var(--weight-emphasis) 12.5px/18px var(--font-sans); }
.band-links a { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-brand); text-decoration: none; }
.band-links a:hover { color: var(--link-hover); text-decoration: underline; }
.band-divider { flex-shrink: 0; width: 1px; height: 20px; margin: 0 3px; background: var(--line-subtle); }

/* The global search (kit ShellFrame.jsx; React GlobalSearch.module.css draws the same):
   36px, 288px, shrinking. The answer is the results page, or the one record a VIN names. */
.global-search { grid-row: 1; grid-column: 4; position: relative; display: flex; align-items: center; width: 288px; min-width: 160px; margin: 0 0 0 12px; }
.global-search-icon { position: absolute; left: 11px; color: var(--ink-muted); pointer-events: none; }
.global-search-input {
  width: 100%;
  height: var(--control-h-band);
  padding: 0 12px 0 34px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-button);
  background: var(--surface);
  color: var(--ink-primary);
  font: var(--weight-body) 13px/1 var(--font-sans);
}
/* Placeholder is text: --ink-muted, never --ink-faint (2026-10-12 contrast rule). */
.global-search-input::placeholder { color: var(--ink-muted); opacity: 1; }
.global-search-input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.global-search-input[aria-busy="true"] { cursor: progress; }

/* Account menu: a divider, the 26px avatar, a 260px popover. */
.account-slot { grid-row: 1; grid-column: 5; display: flex; align-items: center; gap: 2px; }
.account-divider { width: 1px; height: 20px; margin: 0 5px; background: var(--line-subtle); }
.account { position: relative; }
.account-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--account-avatar-bg);
  color: var(--account-avatar-ink);
  font: var(--weight-heading) 10.5px/1 var(--font-sans);
  list-style: none;
  cursor: pointer;
}
.account-trigger::-webkit-details-marker { display: none; }
.account-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: var(--z-popover);
  width: min(260px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}
.account-head { padding: 11px 12px; border-bottom: 1px solid var(--line-faint); }
.account-name-full { font: var(--weight-emphasis) var(--text-body-lg)/18px var(--font-sans); overflow-wrap: anywhere; }
.account-sub { font: var(--weight-body) var(--text-meta)/16px var(--font-sans); color: var(--ink-muted); overflow-wrap: anywhere; }
.account-links { margin: 0; padding: 4px; list-style: none; }
.account-links form { margin: 0; }
.account-links a,
.account-signout {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-button);
  background: transparent;
  font: var(--weight-control) var(--text-body-lg)/18px var(--font-sans);
  color: var(--ink-primary);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.account-links a:hover,
.account-signout:hover { background: var(--accent-tint); color: var(--ink-primary); }
.account-links a:focus-visible,
.account-signout:focus-visible { background: var(--accent-tint); outline-offset: -2px; }
.account-links .icon { color: var(--ink-muted); }
.account-signout,
.account-signout:hover { color: var(--tone-critical-ink); }
.account-signout .icon { color: var(--tone-critical-dot); }
/* Theme (shell.js): an eyebrow and a three-way segmented choice, drawn the same as React's
   AccountMenu.module.css .theme. Without JS it can't apply, so it isn't offered. */
.account-theme { margin: 4px -4px; padding: 7px 10px 9px; border-top: 1px solid var(--line-faint); border-bottom: 1px solid var(--line-faint); }
.no-js .account-theme { display: none; }
.account-theme-label {
  margin-bottom: 6px;
  font: var(--type-eyebrow);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--ink-muted);
}
.theme-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-button);
  background: var(--surface-sunken);
}
.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--ink-secondary);
  font: var(--weight-control) var(--text-body)/1 var(--font-sans);
  cursor: pointer;
}
.theme-option:hover { background: var(--accent-tint); color: var(--ink-primary); }
.theme-option[aria-pressed="true"] { border-color: var(--line-control); background: var(--surface); color: var(--ink-brand); font-weight: var(--weight-emphasis); }
.theme-option:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

.page { flex: 1; min-width: 0; padding: var(--gutter-page); }

/* ---- vAuto connection (app/api/vauto_connection.py): the band-1 glyph after the title (wifi +
   a 7px state dot) and, when vAuto needs attention, the kit's warning strip above the header
   (ShellFrame.jsx). Drawn the same as React: PageHeader.module.css .connection and
   AppShell.module.css .vautoStrip. ---- */
.connection { position: relative; display: inline-flex; color: var(--ink-muted); }
.connection-dot {
  position: absolute;
  top: -1px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 1.5px var(--surface);
}
.connection-live .connection-dot { background: var(--state-live-dot); }
.connection-reconnecting .connection-dot { background: var(--state-reconnect-dot); }
.connection-offline .connection-dot { background: var(--state-offline-dot); }
.vauto-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px var(--gutter-page);
  border-bottom: 1px solid var(--tone-warning-border);
  background: var(--tone-warning-fill);
  color: var(--tone-warning-ink);
  font: var(--weight-body) 12.5px/18px var(--font-sans);
}
.vauto-strip-icon { flex-shrink: 0; color: var(--tone-warning-dot); }
.vauto-strip-text { flex: 1 1 16rem; min-width: 0; margin: 0; }
.vauto-strip .btn { flex-shrink: 0; }

/* ---- Signed-out layouts: sign in (the one gradient), standalone 403 ---- */
.auth-body { min-height: 100vh; background: var(--bg-auth); }
.brand-strip { padding: 16px 24px; }
.brand-strip .brand-tile { width: 32px; height: 32px; }
.standalone-main { padding: 0 16px 48px; }
/* Sign in and 403 (kit LoginScreen / ForbiddenScreen): their h1 is the Zeus heading (24/32/600,
   8px below), not the 21px page-header title; the sign-in refusal sits 16px under the button. */
.auth-card { max-width: var(--auth-card-max); margin: 48px auto 0; padding: 32px; }
.auth-card h1,
.forbidden h1 { margin-bottom: 8px; font: var(--weight-emphasis) var(--text-heading)/var(--lh-heading) var(--font-sans); letter-spacing: normal; }
.auth-card .alert { margin-top: 16px; }
.forbidden {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 60vh;
  text-align: center;
}
.forbidden p { max-width: 28rem; color: var(--ink-muted); }

/* ---- Narrow screens: the rail is an overlay drawer (CSS :target without JS) ---- */
.rail-scrim { display: none; }
@media (max-width: 760px) {
  :root { --gutter-page: 14px; }
  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-overlay);
    height: auto;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--duration-layout) var(--ease), visibility var(--duration-layout);
  }
  .rail:target,
  .rail-open .rail { transform: none; visibility: visible; box-shadow: var(--rail-peek-shadow); }
  .rail-open .rail-scrim { position: fixed; inset: 0; z-index: calc(var(--z-overlay) - 1); display: block; background: var(--scrim); }
  .rail-close,
  .topbar-menu { display: inline-flex; }
  .rail-mode { display: none; }
  .app-top { position: static; }
  /* The search takes its own line under the title (row 2); bands 2 and 3 flow below it. */
  .global-search { grid-row: 2; grid-column: 2 / -2; width: auto; min-width: 0; margin: 0 0 10px; }
}
