:root {
  --sidebar-wide: 220px;
  --sidebar-compact: 76px;
  --sidebar-surface: oklch(98.5% 0.012 230);
  --sidebar-surface-active: oklch(93% 0.055 232);
  --sidebar-line: oklch(85% 0.034 232);
  --sidebar-ink: var(--ink, oklch(22% 0.04 248));
  --sidebar-muted: var(--muted, oklch(54% 0.03 242));
  --sidebar-accent: var(--sky-strong, oklch(52% 0.21 244));
  --sidebar-motion: var(--fast, 180ms cubic-bezier(0.22, 1, 0.36, 1));
}

.app-layout {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: var(--sidebar-wide) minmax(0, 1fr);
  overflow-x: clip;
}

.app-layout > .app-shell {
  width: min(1760px, calc(100% - 24px));
  min-width: 0;
  max-width: 1760px;
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-wide);
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  align-self: start;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-line);
  background:
    linear-gradient(90deg, oklch(66% 0.08 235 / 7%) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(0deg, oklch(66% 0.08 235 / 6%) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--sidebar-surface);
  padding:
    max(14px, env(safe-area-inset-top))
    12px
    max(14px, env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-line) transparent;
}

.sidebar-brand {
  display: flex;
  min-height: 58px;
  min-width: 0;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-line);
  color: var(--sidebar-ink);
  padding: 4px 6px 12px;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-brand > * {
  min-width: 0;
}

.sidebar-brand :is(.brand-mark, svg, img) {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.sidebar-brand .brand-mark span {
  width: 20px;
  height: 20px;
  font-size: 0.82rem;
}

.sidebar-brand > div:last-child {
  display: grid;
  gap: 2px;
}

.sidebar-brand > div:last-child > span {
  overflow: hidden;
  color: var(--sidebar-muted);
  font-size: 0.7rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  display: flex;
  min-width: 0;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 2px 0;
  list-style: none;
}

.sidebar-nav-item {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--sidebar-muted);
  background: transparent;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--sidebar-motion),
    border-color var(--sidebar-motion),
    background-color var(--sidebar-motion),
    box-shadow var(--sidebar-motion);
}

.sidebar-nav-item :is(svg, i) {
  width: 17px;
  height: 17px;
  min-width: 17px;
  flex: 0 0 auto;
}

.sidebar-nav-item > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav-item:hover,
.sidebar-nav-item:focus-visible {
  border-color: oklch(75% 0.095 234);
  color: var(--sidebar-accent);
  background: oklch(95% 0.038 232);
  box-shadow: inset 0 0 0 1px oklch(67% 0.16 235 / 22%);
  outline: none;
}

.sidebar-nav-item:is(.active, .is-active),
.sidebar-nav-item[aria-current="page"],
.sidebar-nav-item[aria-pressed="true"],
.sidebar-nav-item[aria-expanded="true"] {
  border-color: oklch(72% 0.12 235);
  color: var(--sidebar-accent);
  background: var(--sidebar-surface-active);
  box-shadow:
    inset 0 0 0 1px oklch(58% 0.17 240 / 24%),
    0 4px 12px oklch(48% 0.1 240 / 8%);
}

.sidebar-mobile-toggle,
.sidebar-backdrop {
  display: none;
}

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

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  align-items: center;
  justify-items: center;
  overflow: hidden;
  background: oklch(20% 0.035 248 / 42%);
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    calc(var(--sidebar-wide) + 20px);
}

.help-overlay[hidden],
.help-view[hidden] {
  display: none;
}

.help-dialog {
  display: grid;
  width: min(760px, 100%);
  min-width: 0;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid oklch(76% 0.07 233);
  border-radius: 8px;
  background: var(--surface, oklch(99% 0.006 225));
  box-shadow: 0 26px 70px oklch(20% 0.05 248 / 26%);
}

.help-dialog:has([data-help-view="product-intro"]:not([hidden])) {
  width: min(1040px, 100%);
}

.help-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--sidebar-line);
  background:
    linear-gradient(90deg, oklch(64% 0.1 236 / 7%) 1px, transparent 1px) 0 0 / 22px 22px,
    oklch(97% 0.022 230);
  padding: 16px 18px;
}

.help-head > * {
  min-width: 0;
}

.help-head :is(h1, h2, h3, p) {
  margin: 0;
}

.help-head :is(h1, h2, h3) {
  color: var(--sidebar-ink);
  font-size: 1.05rem;
  line-height: 1.3;
}

.help-close {
  display: grid;
  width: 44px;
  height: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--sidebar-line);
  border-radius: 6px;
  color: var(--sidebar-muted);
  background: var(--surface, oklch(99% 0.006 225));
  padding: 0;
  cursor: pointer;
  transition:
    color var(--sidebar-motion),
    border-color var(--sidebar-motion),
    background-color var(--sidebar-motion);
}

.help-close :is(svg, i) {
  width: 18px;
  height: 18px;
}

.help-close:hover,
.help-close:focus-visible {
  border-color: oklch(72% 0.12 235);
  color: var(--sidebar-accent);
  background: var(--sidebar-surface-active);
  outline: none;
}

.help-view {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 26px;
  color: var(--text, oklch(31% 0.034 250));
  font-size: 0.94rem;
  line-height: 1.75;
  scrollbar-gutter: stable;
}

.help-view > :first-child {
  margin-top: 0;
}

.help-view > :last-child {
  margin-bottom: 0;
}

.help-view :is(h2, h3, h4) {
  color: var(--sidebar-ink);
  line-height: 1.35;
}

.help-view h2 {
  font-size: 1.2rem;
}

.help-view h3,
.help-view h4 {
  font-size: 1rem;
}

.help-view :is(p, li) {
  max-width: 72ch;
  overflow-wrap: anywhere;
}

.help-view ol {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
  counter-reset: help-step;
}

.help-view ol > li {
  position: relative;
  min-width: 0;
  max-width: none;
  counter-increment: help-step;
  border: 1px solid var(--sidebar-line);
  border-radius: 6px;
  background: oklch(98% 0.012 230);
  padding: 13px 14px 13px 48px;
}

.help-view ol > li::before {
  content: counter(help-step, decimal-leading-zero);
  position: absolute;
  top: 13px;
  left: 12px;
  color: var(--sidebar-accent);
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.75;
}

.help-view ol > li > :last-child {
  margin-bottom: 0;
}

.help-intro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.help-intro-grid section {
  min-width: 0;
  border: 1px solid var(--sidebar-line);
  border-radius: 6px;
  background: oklch(98% 0.012 230);
  padding: 14px;
}

.help-intro-grid h3 {
  margin: 0 0 7px;
}

.help-intro-grid p {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.product-manual {
  display: grid;
  gap: 22px;
}

.manual-section {
  min-width: 0;
  border-top: 1px solid var(--sidebar-line);
  padding-top: 20px;
}

.manual-section.manual-lead {
  border-top: 0;
  padding-top: 0;
}

.manual-section h2 {
  margin: 0 0 12px;
  color: var(--sidebar-ink);
  font-size: 1.12rem;
}

.manual-section h3 {
  margin: 20px 0 8px;
  color: var(--sidebar-ink);
  font-size: 0.94rem;
}

.manual-section p {
  margin: 0 0 10px;
}

.manual-section ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 20px;
}

.manual-section li::marker {
  color: var(--sidebar-accent);
}

.private-deployment-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.65fr);
  gap: 22px;
  min-height: 100%;
}

.private-deployment-copy,
.private-deployment-contact {
  min-width: 0;
}

.private-deployment-copy > h2 {
  max-width: 18ch;
  margin: 4px 0 12px;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.25;
}

.private-deployment-copy > p:not(.eyebrow, .private-deployment-note) {
  margin: 0;
  color: var(--sidebar-muted);
}

.private-deployment-points {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.private-deployment-points section {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--sidebar-line);
  border-radius: 6px;
  background: oklch(98% 0.012 230);
  padding: 13px;
}

.private-deployment-points :is(svg, i) {
  width: 38px;
  height: 38px;
  border: 1px solid oklch(72% 0.12 235);
  border-radius: 6px;
  color: var(--sidebar-accent);
  background: var(--sidebar-surface-active);
  padding: 8px;
}

.private-deployment-points h3,
.private-deployment-points p {
  margin: 0;
}

.private-deployment-points p {
  margin-top: 3px;
  color: var(--sidebar-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.private-deployment-note {
  margin: 16px 0 0;
  border-left: 3px solid var(--sidebar-accent);
  color: var(--sidebar-ink);
  background: oklch(94% 0.035 230);
  padding: 11px 13px;
}

.private-deployment-contact {
  align-self: start;
  border: 1px solid oklch(72% 0.12 235);
  border-radius: 8px;
  background:
    linear-gradient(90deg, oklch(64% 0.1 236 / 7%) 1px, transparent 1px) 0 0 / 22px 22px,
    oklch(97% 0.022 230);
  padding: 18px;
  text-align: center;
}

.private-deployment-contact > span {
  color: var(--sidebar-accent);
  font-size: 0.76rem;
  font-weight: 800;
}

.private-deployment-contact h3 {
  margin: 4px 0 14px;
}

.private-deployment-contact img {
  display: block;
  width: min(100%, 240px);
  height: auto;
  aspect-ratio: 416 / 410;
  margin: 0 auto;
  border: 1px solid var(--sidebar-line);
  border-radius: 6px;
  background: white;
  object-fit: contain;
}

.private-deployment-contact p {
  margin: 12px auto 0;
  color: var(--sidebar-muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.manual-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--sidebar-line);
  border-radius: 6px;
  background: oklch(99% 0.006 225);
  scrollbar-width: thin;
}

.manual-table-wrap:focus-visible {
  outline: 2px solid oklch(62% 0.16 238);
  outline-offset: 2px;
}

.manual-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.55;
}

.manual-table th,
.manual-table td {
  border-right: 1px solid var(--sidebar-line);
  border-bottom: 1px solid var(--sidebar-line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.manual-table tr > :last-child {
  border-right: 0;
}

.manual-table tbody tr:last-child > * {
  border-bottom: 0;
}

.manual-table thead th {
  color: var(--sidebar-ink);
  background: oklch(94.5% 0.034 231);
  font-weight: 850;
}

.manual-table tbody th {
  width: 112px;
  color: var(--sidebar-ink);
  background: oklch(97.5% 0.014 230);
  white-space: nowrap;
}

.manual-table tbody td:last-child {
  background: oklch(97% 0.026 230);
}

.manual-steps {
  margin-bottom: 0;
}

@media (min-width: 721px) and (max-width: 1500px) {
  .app-layout {
    grid-template-columns: var(--sidebar-compact) minmax(0, 1fr);
  }

  .app-layout > .app-shell {
    width: min(1760px, calc(100% - 20px));
  }

  .app-sidebar {
    width: var(--sidebar-compact);
    gap: 10px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .sidebar-brand {
    min-height: 56px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 0 10px;
    font-size: 0.66rem;
    text-align: center;
  }

  .sidebar-brand :is(.brand-mark, svg, img) {
    width: 42px;
    height: 42px;
  }

  .sidebar-brand > div:last-child {
    display: none;
  }

  .sidebar-nav-item {
    min-height: 58px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 6px 2px;
    font-size: 0.65rem;
    line-height: 1.05;
    text-align: center;
  }

  .sidebar-nav-item :is(svg, i) {
    width: 18px;
    height: 18px;
    min-width: 18px;
  }

  .sidebar-nav-item > span {
    width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .sidebar-nav-item:hover,
  .sidebar-nav-item:focus-visible,
  .sidebar-nav-item:is(.active, .is-active),
  .sidebar-nav-item[aria-current="page"],
  .sidebar-nav-item[aria-pressed="true"],
  .sidebar-nav-item[aria-expanded="true"] {
    box-shadow: inset 0 3px 0 var(--sidebar-accent);
  }

  .help-overlay {
    padding-left: calc(var(--sidebar-compact) + 20px);
  }
}

@media (max-width: 720px) {
  .app-layout {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .app-layout > .app-shell {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
    padding-top: calc(max(8px, env(safe-area-inset-top)) + 52px);
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 910;
    width: min(86vw, 280px);
    max-width: calc(100vw - 44px - env(safe-area-inset-right));
    height: 100vh;
    height: 100dvh;
    gap: 12px;
    visibility: hidden;
    border-right-color: oklch(76% 0.06 233);
    padding:
      max(12px, env(safe-area-inset-top))
      12px
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    box-shadow: 18px 0 50px oklch(20% 0.05 248 / 22%);
    transform: translateX(calc(-100% - 12px));
    pointer-events: none;
    transition:
      transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
      visibility 220ms step-end;
  }

  body.sidebar-open .app-sidebar,
  .app-sidebar.is-open {
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    transition:
      transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0ms step-start;
  }

  .sidebar-brand {
    min-height: 52px;
    padding-right: 48px;
  }

  .sidebar-brand > div:last-child {
    display: grid;
  }

  .sidebar-nav-item {
    min-height: 48px;
    font-size: 0.88rem;
  }

  .sidebar-mobile-toggle {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    z-index: 920;
    display: grid;
    width: 44px;
    height: 44px;
    min-height: 44px;
    place-items: center;
    border: 1px solid oklch(72% 0.1 235);
    border-radius: 6px;
    color: var(--sidebar-accent);
    background: var(--surface, oklch(99% 0.006 225));
    padding: 0;
    box-shadow: 0 6px 18px oklch(45% 0.1 240 / 16%);
    cursor: pointer;
    transition:
      left 220ms cubic-bezier(0.22, 1, 0.36, 1),
      color var(--sidebar-motion),
      background-color var(--sidebar-motion);
  }

  .sidebar-mobile-toggle :is(svg, i) {
    display: none;
  }

  .sidebar-mobile-toggle::before,
  .sidebar-mobile-toggle::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease-out;
  }

  .sidebar-mobile-toggle::before {
    box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
  }

  .sidebar-mobile-toggle::after {
    opacity: 0;
  }

  .sidebar-mobile-toggle:hover,
  .sidebar-mobile-toggle:focus-visible {
    color: var(--sidebar-ink);
    background: var(--sidebar-surface-active);
    outline: 2px solid oklch(68% 0.14 235 / 44%);
    outline-offset: 2px;
  }

  body.sidebar-open .sidebar-mobile-toggle,
  .sidebar-mobile-toggle.is-open,
  body:has(.app-sidebar.is-open) .sidebar-mobile-toggle {
    left: calc(min(86vw, 280px) - 56px);
  }

  .sidebar-mobile-toggle.is-open::before {
    box-shadow: none;
    transform: rotate(45deg);
  }

  .sidebar-mobile-toggle.is-open::after {
    opacity: 1;
    transform: rotate(-45deg);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: block;
    visibility: hidden;
    border: 0;
    background: oklch(20% 0.035 248 / 42%);
    opacity: 0;
    padding: 0;
    pointer-events: none;
    transition:
      opacity 200ms ease-out,
      visibility 200ms step-end;
  }

  body.sidebar-open .sidebar-backdrop,
  .sidebar-backdrop.is-open,
  body:has(.app-sidebar.is-open) .sidebar-backdrop,
  .app-sidebar.is-open ~ .sidebar-backdrop,
  .sidebar-backdrop.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition:
      opacity 200ms ease-out,
      visibility 0ms step-start;
  }

  body.sidebar-open,
  body:has(.app-sidebar.is-open) {
    overflow: hidden;
  }

  .help-overlay {
    align-items: end;
    justify-items: stretch;
    padding:
      max(8px, env(safe-area-inset-top))
      env(safe-area-inset-right)
      0
      env(safe-area-inset-left);
  }

  .help-dialog {
    width: 100%;
    max-width: 100%;
    height: min(84vh, 720px);
    height: min(84dvh, 720px);
    max-height: calc(100vh - max(8px, env(safe-area-inset-top)));
    max-height: calc(100dvh - max(8px, env(safe-area-inset-top)));
    border-radius: 8px 8px 0 0;
  }

  .help-head {
    gap: 10px;
    padding: 12px;
  }

  .help-head :is(h1, h2, h3) {
    font-size: 1rem;
  }

  .help-view {
    padding: 16px 14px calc(18px + env(safe-area-inset-bottom));
    font-size: 0.9rem;
    line-height: 1.7;
    scrollbar-gutter: auto;
  }

  .help-view ol {
    gap: 8px;
    margin: 12px 0;
  }

  .help-view ol > li {
    padding: 12px 10px 12px 44px;
  }

  .help-view ol > li::before {
    top: 12px;
    left: 10px;
  }

  .help-intro-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .private-deployment-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .private-deployment-copy > h2 {
    max-width: none;
    font-size: 1.35rem;
  }

  .private-deployment-contact {
    padding: 16px;
  }
}

@media (min-width: 1241px) and (max-width: 1500px) {
  .app-layout .topbar {
    grid-template-columns: minmax(360px, 0.82fr) minmax(500px, 1.18fr);
  }

  .app-layout .pipeline {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .sidebar-nav-item,
  .sidebar-mobile-toggle,
  .sidebar-backdrop,
  .help-close {
    scroll-behavior: auto;
    transition: none;
  }
}
