/* Systems descendants share shell geometry, not data or page ownership.
 * Loaded after legacy projections; KGRID IDs and real routes stay unchanged. */
html:has(body[data-systems-subpage="true"]),
html body[data-template][data-systems-subpage="true"] {
  height: auto !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] {
  display: block !important;
  --home-text: var(--text);
  --home-muted: var(--muted);
  --home-line: var(--line);
  --home-card: var(--panel);
  --home-link: var(--system);
  --home-action: var(--action);
  --home-guard: var(--guard);
}
html body[data-template][data-systems-subpage="true"] > header.site {
  position: relative !important;
  height: auto !important;
  min-height: var(--aenet-global-header-height, 72px);
}
html body[data-template][data-systems-subpage="true"] > .wrap {
  display: block !important;
  width: 100%;
  max-width: none !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 clamp(12px, 2vw, 32px);
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] .context-bar {
  position: relative !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  height: auto !important;
  min-height: 0 !important;
  gap: 8px;
  padding-block: 8px;
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] .route-context {
  position: static !important;
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  height: auto !important;
  min-height: 0;
  padding: 8px 12px;
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] .route-context :is(.breadcrumb, .route-context-meta) {
  min-width: 0;
  height: auto;
  flex-wrap: wrap;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}
html body[data-template][data-systems-subpage="true"] .route-context .breadcrumb {
  flex: 1 1 440px !important;
  width: auto !important;
  max-width: none !important;
}
html body[data-template][data-systems-subpage="true"] .route-context-meta {
  flex: 0 1 auto !important;
  width: auto !important;
}
html body[data-template][data-systems-subpage="true"] .context-local-nav {
  position: static !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)) !important;
  gap: 8px;
  height: auto !important;
  min-height: 0;
  padding: 0;
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] .context-local-nav::before {
  content: none !important;
  display: none !important;
}
html body[data-template][data-systems-subpage="true"] .local-nav-link {
  min-width: 0;
  min-height: 44px;
  height: auto;
  padding: 10px 14px;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: anywhere;
}
html body[data-template][data-systems-subpage="true"] main.content-field {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 16px 0 24px !important;
}
html body[data-template][data-systems-subpage="true"] main.content-field > :is(.page-head, .system-workspace, .domain-workspace, .wallet-workspace, .wallet-related) {
  width: 100%;
  max-width: 100% !important;
  box-sizing: border-box !important;
  min-width: 0;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 0 20px;
  padding: clamp(16px, 2vw, 28px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] .page-head :is(.lede, .meta-row) {
  display: block !important;
  -webkit-line-clamp: unset;
  max-height: none;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}
html body[data-template][data-systems-subpage="true"] .page-head .meta-row {
  display: flex !important;
  flex-wrap: wrap;
  gap: 12px 24px;
}
/* Retain the declared KAP-GRID element owner and keyboard controls. */
html body[data-template][data-systems-subpage="true"] #system-detail-kap-grid {
  display: flex !important;
  flex-direction: column;
  gap: 16px;
  height: 70dvh !important;
  min-height: 320px !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-width: thin;
}
html body[data-template][data-systems-subpage="true"] #system-detail-kap-grid > * {
  flex: 0 0 auto !important;
}
html body[data-template][data-systems-subpage="true"] .system-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 16px;
}
html body[data-template][data-systems-subpage="true"] .system-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
html body[data-template][data-systems-subpage="true"] .domain-system-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  gap: 16px;
}
html body[data-template][data-systems-subpage="true"] :is(.domain-system-row-main, .domain-system-row-meta) {
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere;
}
html body[data-template][data-systems-subpage="true"] :is(.system-detail-section, .system-facts .cell) {
  min-width: 0;
  padding: 16px;
  overflow-wrap: anywhere;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible !important;
}
html body[data-template][data-systems-subpage="true"] .system-facts .cell :is(h3, p, ul, li),
html body[data-template][data-systems-subpage="true"] .page-head .meta-row span {
  display: block !important;
  max-height: none !important;
  -webkit-line-clamp: unset !important;
  white-space: normal !important;
  overflow: visible !important;
  overflow-wrap: anywhere;
}
html body[data-template][data-systems-subpage="true"] > footer.product-footer {
  position: relative !important;
  display: block !important;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  padding: 24px clamp(12px, 2vw, 32px) !important;
  overflow: visible !important;
}
/* Financial keeps its existing main-owned KAP-GRID, separate from footer. */
/* D01 domain and Wallet overview: one KAP viewport includes content and footer. */
html:has(#financial-domain-kap-viewport, #wallet-kap-viewport) {
  height: 100dvh !important;
  overflow: hidden !important;
}
html body[data-template]:has(#financial-domain-kap-viewport, #wallet-kap-viewport) {
  display: flex !important;
  flex-direction: column;
  height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
html body[data-template]:has(#financial-domain-kap-viewport, #wallet-kap-viewport) > header.site {
  flex: 0 0 auto;
}
html body[data-template]:has(#financial-domain-kap-viewport, #wallet-kap-viewport) > .wrap {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0 !important;
  overflow: hidden !important;
}
html body[data-template]:has(#financial-domain-kap-viewport, #wallet-kap-viewport) .context-bar {
  flex: 0 0 auto;
}
html body[data-template][data-systems-subpage="true"] main:is(#financial-domain-kap-viewport, #wallet-kap-viewport) {
  flex: 1 1 auto;
  min-height: 0 !important;
  height: auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-width: none !important;
  scrollbar-gutter: auto !important;
}
main:is(#financial-domain-kap-viewport, #wallet-kap-viewport)::-webkit-scrollbar { display: none; }

html body[data-template][data-page="financial"][data-systems-subpage="true"] main.content-field {
  height: 75dvh !important;
  min-height: 360px !important;
  overflow-y: auto !important;
}
@media (max-width: 600px) {
  html body[data-template][data-systems-subpage="true"] .context-local-nav,
  html body[data-template][data-systems-subpage="true"] .system-detail-grid,
  html body[data-template][data-systems-subpage="true"] .domain-system-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
