/* Final, unconditional shell/reflow contract. Keep this file unlayered and load it last. */
html[data-ui-version="v2"] body .ds-app-shell .legacy-functional-surface
  :is(.page-hero, .detail-hero, .dashboard-hero) > * {
  min-inline-size: 0;
  max-inline-size: 100%;
}

/* Risk categories render as semantic div rows (not buttons). Keep the
   existing button contract visually consistent without changing behavior. */
html[data-ui-version="v2"] body .ds-app-shell .ds-risk-categories > div {
  min-height: 3.5rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3);
  border: 1px solid transparent;
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-surface-subtle);
  color: var(--ds-color-text);
}

html[data-ui-version="v2"] body .ds-app-shell .ds-risk-categories > div:hover {
  border-color: var(--ds-color-brand-border);
}

html[data-ui-version="v2"] body .ds-app-shell .ds-risk-categories > div > span:nth-child(2) {
  min-inline-size: 0;
}

html[data-ui-version="v2"] body .ds-app-shell .ds-risk-categories > div > b {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 44rem) {
  html[data-ui-version="v2"] body .ds-app-shell :is(
    .ds-breadcrumbs,
    .ui4-management-context__links,
    .ui4-section-index,
    .ui5-inventory-context__nav,
    .ui6-field-context__nav,
    .ui7-procurement-context__nav,
    .ui8-finance-context__nav,
    .ui9-restaurant-context__links,
    .ui10-admin-context__nav,
    .ui11-internal-context__nav
  ) {
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }

  html[data-ui-version="v2"] body .ds-app-shell :is(
    .ds-breadcrumbs,
    .ui4-management-context__links,
    .ui4-section-index,
    .ui5-inventory-context__nav,
    .ui6-field-context__nav,
    .ui7-procurement-context__nav,
    .ui8-finance-context__nav,
    .ui9-restaurant-context__links,
    .ui10-admin-context__nav,
    .ui11-internal-context__nav
  )::-webkit-scrollbar {
    display: none;
  }

  html[data-ui-version="v2"] body[data-management-intelligence="true"]
    .ds-app-shell .ui4-section-index {
    position: static;
    top: auto;
  }

  html[data-ui-version="v2"] body .ds-app-shell .legacy-functional-surface
    :is(.page-hero, .detail-hero, .dashboard-hero) .page-context-rail {
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }

  html[data-ui-version="v2"] body .ds-app-shell .legacy-functional-surface
    :is(.page-hero, .detail-hero, .dashboard-hero) .page-context-rail::-webkit-scrollbar {
    display: none;
  }
}

/* MC045 canonical shell viewport/scroll contract.
   Absorbed from the retired shell-scroll-repair layer so the shared cascade
   has one fewer global stylesheet while preserving the same scroll target. */
:where(html[data-ui-version="v2"]) .ds-app-shell {
  block-size: 100dvh;
  max-block-size: 100dvh;
}

:where(html[data-ui-version="v2"]) .ds-shell-main {
  min-block-size: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: clip;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
