/* Shared application chrome and page shell. */

.app-shell {
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
}

.app-sidebar {
  background: var(--app-brand-700);
  color: var(--app-text-inverse);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: transform 0.2s ease;
}

.app-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.app-topbar {
  background: var(--app-surface-panel);
  min-height: 58px;
  padding: 0.65rem var(--space-5);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-4);
  border-bottom: 1px solid var(--app-border-default);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.sidebar-shell {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.sidebar-top {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.sidebar-brand {
  padding: var(--space-4) 0.8rem 0.8rem;
  border-bottom: 1px solid var(--alpha-white-14);
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.sidebar-brand-link {
  color: var(--app-text-inverse);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.sidebar-brand-link:hover {
  text-decoration: none;
}

.sidebar-brand-text {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sidebar-brand-group {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  color: var(--app-text-inverse);
}

.sidebar-brand-sep {
  opacity: 0.4;
}

.sidebar-brand-switch {
  color: var(--app-text-inverse);
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.75;
  text-decoration: none;
}

.sidebar-brand-switch:hover,
.sidebar-brand-switch:focus-visible {
  opacity: 1;
  text-decoration: underline;
}

.sidebar-nav {
  padding: 0.9rem var(--space-2) 1.1rem;
  overflow-y: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0.65rem;
  border-top: 1px solid var(--alpha-white-18);
  background: var(--alpha-black-42);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--app-brand-900);
  background: var(--app-brand-50);
  flex: 0 0 32px;
}

.sidebar-user-name {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--alpha-white-92);
}

.sidebar-user-logout-form {
  margin: 0;
}

.sidebar-user-logout {
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: transparent;
  color: var(--alpha-white-82);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-user-logout i {
  font-size: 1.2rem;
}

.sidebar-user-logout:hover {
  color: var(--app-text-inverse);
  background: var(--alpha-white-12);
}

.sidebar-section + .sidebar-section {
  margin-top: var(--space-4);
}

.sidebar-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;

  /* J04 (M-14): the OPERATIONS/TIME/SYSTEM labels were 68% white on the
     brand-700 sidebar = 4.20:1 (fails AA, axe "serious"). 82% = 5.31:1.
     Toggle + chevron raised to match for one consistent label tone. */
  color: var(--alpha-white-82);
  margin-bottom: 0.45rem;
  padding: 0 0.45rem;
}

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 0.45rem;
  margin-bottom: 0.45rem;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--alpha-white-82);
  font: inherit;
  text-align: left;
}

.sidebar-section-toggle:hover,
.sidebar-section-toggle:focus {
  color: var(--app-text-inverse);
  outline: none;
}

/* A keyboard user needs more than a white-82 -> white text change to see where
   they are (WCAG 2.4.7); a mouse click keeps the quiet look. */
.sidebar-section-toggle:focus-visible {
  outline: 2px solid var(--app-text-inverse);
  outline-offset: 2px;
}

.sidebar-section-toggle .sidebar-section-title {
  margin-bottom: 0;
  padding: 0;
}

.sidebar-section-chevron {
  font-size: 0.78rem;
  transition: transform 120ms ease-out;
  color: var(--alpha-white-82);
}

.sidebar-section-toggle[aria-expanded="true"] .sidebar-section-chevron {
  transform: rotate(180deg);
}

.sidebar-links {
  display: grid;
  gap: var(--space-1);
}

.sidebar-links[hidden] {
  display: none;
}

.sidebar-link {
  color: var(--alpha-white-85);
  padding: var(--space-2) 0.6rem;
  border-radius: var(--radius);
  font-size: 0.93rem;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-link-attention {
  margin-left: auto;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--app-danger-accent);
  color: var(--app-text-inverse);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.sidebar-link:hover {
  background: var(--alpha-white-12);
  color: var(--app-text-inverse);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--alpha-white-18);
  color: var(--app-text-inverse);
}

.app-sidebar .sidebar-toggle-sidebar {
  background: transparent;
  border: 0;
  color: var(--alpha-white-82);
  min-width: 28px;
  min-height: 28px;
  padding: 0.1rem;
  gap: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: none;
  border-radius: 8px;
}

.app-sidebar .sidebar-toggle-sidebar:hover {
  background: var(--alpha-white-08);
  color: var(--color-white);
}

.topbar-sidebar-toggle {
  display: none;
}

.sidebar-link-icon {
  font-size: 1rem;
  flex: 0 0 1rem;
  text-align: center;
}

.sidebar-toggle-icon-expand {
  display: none;
}

.sidebar-link-label,
.sidebar-brand-text {
  transition: opacity 0.15s ease;
}

.breadcrumbs {
  min-width: 0;
}

.breadcrumb-list {
  list-style: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--app-text-muted);
  font-size: 0.87rem;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb-item:not(:last-child)::after {
  content: "/";
  color: var(--app-text-subtle);
}

.breadcrumb-item span[aria-current="page"] {
  color: var(--app-text-strong);
  font-weight: 600;
}

.app-backdrop {
  display: none;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 68px minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar-brand {
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

body.sidebar-collapsed .sidebar-nav {
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

body.sidebar-collapsed .sidebar-section {
  position: relative;
}

body.sidebar-collapsed .sidebar-link-label,
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-user-name {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar-link-attention {
  display: none;
}

body.sidebar-collapsed .sidebar-user {
  justify-content: center;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

body.sidebar-collapsed .sidebar-user-name {
  display: none;
}

body.sidebar-collapsed .sidebar-user-logout-form {
  display: none;
}

/* Small and grey (owner, 2026-10-06): version + 4-character commit; the full
   value is the hover title. A neutral grey, not translucent white (72% white
   measured 4.49:1 under axe). Mixed from existing tokens because tokens.css is
   pinned for the kiosk (TR-099) and raw colours belong only there
   (staticcheck/01): 78% inverse text + 22% neutral fg is a grey of
   215/216/218, 4.9:1 on --app-brand-700. Browsers without color-mix() keep
   the inverse text. */
.sidebar-build {
  padding: 0.3rem var(--space-4) 0.5rem;
  font-size: 0.62rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--app-text-inverse);
  color: color-mix(in srgb, var(--app-text-inverse) 78%, var(--app-neutral-fg));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.sidebar-collapsed .sidebar-build {
  display: none;
}

body.sidebar-collapsed .sidebar-section + .sidebar-section {
  margin-top: var(--space-2);
  padding-top: var(--space-4);
}

body.sidebar-collapsed .sidebar-section + .sidebar-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 26px;
  height: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--alpha-white-32);
  box-shadow: 0 0 0 1px var(--alpha-white-08);
}

body.sidebar-collapsed .sidebar-section-title {
  opacity: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

body.sidebar-collapsed .sidebar-brand-row {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-brand-link,
body.sidebar-collapsed .sidebar-brand-group {
  display: none;
}

body.sidebar-collapsed .sidebar-links {
  justify-items: center;
}

body.sidebar-collapsed .sidebar-link {
  width: 42px;
  min-height: 42px;
  justify-content: center;
  padding: 0;
  margin: 0 auto;
  gap: 0;
}

body.sidebar-collapsed .sidebar-link-icon {
  flex: 0 0 auto;
}

body.sidebar-collapsed .app-sidebar .sidebar-toggle-sidebar {
  min-width: 30px;
  min-height: 30px;
  padding-left: 0.1rem;
  padding-right: 0.1rem;
}

body.sidebar-collapsed .sidebar-toggle-icon-collapse {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-icon-expand {
  display: inline-block;
}

body.manual-app-body.sidebar-collapsed .app-shell {
  grid-template-columns: 257px minmax(0, 1fr);
}

body.manual-app-body.sidebar-collapsed .sidebar-brand {
  padding-left: 0.8rem;
  padding-right: 0.8rem;
}

body.manual-app-body.sidebar-collapsed .sidebar-brand-row {
  justify-content: flex-start;
}

body.manual-app-body.sidebar-collapsed .sidebar-brand-link {
  display: inline-flex;
}

body.manual-app-body.sidebar-collapsed .sidebar-brand-text,
body.manual-app-body.sidebar-collapsed .sidebar-user-name {
  opacity: 1;
  width: auto;
  overflow: visible;
  pointer-events: auto;
}

body.manual-app-body.sidebar-collapsed .sidebar-user {
  justify-content: flex-start;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

body.manual-app-body.sidebar-collapsed .sidebar-user-name {
  display: block;
}

body.manual-app-body.sidebar-collapsed .sidebar-user-logout-form {
  display: block;
}

.container {
  width: 100%;
  max-width: 1600px;
  margin: 0;
  padding: var(--space-5) var(--space-4);
}

@media (width >= 1400px) {
  .container {
    padding: var(--space-5);
  }
}

@media (width <= 980px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-sidebar {
    position: fixed;
    left: 0;
    width: min(292px, 86vw);
    transform: translateX(-100%);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.sidebar-collapsed .sidebar-section-title,
  body.sidebar-collapsed .sidebar-link-label,
  body.sidebar-collapsed .sidebar-toggle-label,
  body.sidebar-collapsed .sidebar-brand-text {
    opacity: 1;
    width: auto;
    overflow: visible;
    pointer-events: auto;
  }

  body.sidebar-collapsed .sidebar-brand-group {
    display: inline-flex;
  }

  .sidebar-brand-switch {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--space-2);
    font-size: 0.9rem;
  }

  .app-backdrop {
    position: fixed;
    inset: 0;
    background: var(--alpha-black-35);
    z-index: 25;
  }

  body.sidebar-open .app-backdrop {
    display: block;
  }

  .app-topbar {
    padding: var(--space-3) var(--space-4);
  }

  .topbar-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 0.35rem;
  }

  .sidebar-toggle-sidebar {
    display: none;
  }

  .container {
    padding: var(--space-4);
  }
}

/* The name and avatar open My Account (HESS Field since v1.17.0, HESS Core
   since v1.20.0). */
.sidebar-user-account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

/* On the link, not the name: the underline reaches the name's text and skips
   the avatar (an inline-flex box), and stylelint's specificity order holds. */
.sidebar-user-account:hover,
.sidebar-user-account.active {
  text-decoration: underline;
}
