/* PEM SySO C20.3 LAB. Replaces only C20.2 persistent_navigation.css. */
:root { --pem-persistent-bar: 76px; --pem-persistent-stack: 180px; }
html { scroll-padding-top: calc(var(--pem-persistent-stack) + 12px); }
html body .main > .topbar { position: fixed !important; top: 0 !important; left: var(--pem-root-bar-left, 252px) !important; right: 0 !important; z-index: 1150 !important; }
html body .main { padding-top: var(--pem-persistent-bar, 76px) !important; }
html body .platform-bar { position: sticky !important; top: 0 !important; z-index: 1150 !important; }
html body > .pem-global-topbar { position: fixed !important; top: 0 !important; z-index: 1150 !important; }
html body .sidebar { position: sticky !important; top: 0 !important; height: 100dvh !important; align-self: start; }
/* Fixed coordinates are assigned on activation or when the layout changes,
   NEVER in a scroll callback. Placeholder retains the document's original flow. */
html body .pem-persistent-block { position: fixed !important; isolation: isolate; transform: none !important; transition: none !important; box-shadow: 0 6px 0 var(--pem-color-canvas,#f3f6fa); }
html body .pem-persistent-block h1 { position: static !important; top: auto !important; transform: none !important; padding-top: 0 !important; padding-bottom: 0 !important; box-shadow: none !important; }
html body .pem-persistent-placeholder { pointer-events: none !important; visibility: hidden !important; flex-shrink: 0 !important; }
html body .pem-persistent-backplate { display: block; }
html body .pem-persistent-block.pem-record-summary, html body .pem-persistent-block.kpis, html body .pem-persistent-block.metrics { background: var(--pem-color-canvas,#f3f6fa) !important; }
html body summary.pem-persistent-block { display: list-item; background: var(--pem-color-surface,#fff) !important; }
html body .modal-backdrop:not([hidden]), html body .dialog:not([hidden]), html body dialog[open] { z-index: var(--pem-z-overlay,3000) !important; }
@media print {
  html body .pem-persistent-backplate, html body .pem-persistent-placeholder { display: none !important; }
  html body .main { padding-top: 0 !important; }
  html body .pem-persistent-block, html body .main > .topbar, html body > .pem-global-topbar, html body .platform-bar, html body .sidebar { position: static !important; top: auto !important; box-shadow: none !important; }
  html { scroll-padding-top: 0; }
}

/* C20.4 scoped corrections — generated from the approved C20.3 baseline. */
@media(min-width:1451px) {
 html.pem-enterprise-ui .pem-dashboard-view .pem-release-pyramid-card {
   height:160px!important;min-height:160px!important;max-height:160px!important;
   align-self:stretch!important;overflow:hidden!important;
 }
}
/* Findings: summary must retain four equal columns when fixed. */
html body .pem-persistent-block#summary.grid {
 display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;
 gap:12px!important;box-sizing:border-box!important;
}
html body .pem-persistent-block#summary.grid > .metric {min-width:0!important;}
/* EPP: do not detach nested grid children; keep selectors and cards in natural layout. */
@media(min-width:901px) {
 html body.pem-route-ppe-deliveries .grid > aside,
 html body:has(#deliveryForm) .grid > aside {
   position:sticky!important;top:calc(var(--pem-persistent-stack,150px) + 8px)!important;
   align-self:start!important;z-index:1034!important;
 }
 html body.pem-route-ppe-deliveries #metrics,
 html body:has(#deliveryForm) #metrics {
   position:sticky!important;top:calc(var(--pem-persistent-stack,150px) + 8px)!important;
   z-index:1035!important;background:var(--pem-color-canvas,#f3f6fa)!important;
 }
}
@media(max-width:900px){
 html body:has(#deliveryForm) .grid > aside,html body:has(#deliveryForm) #metrics {
  position:static!important;
 }
}

/* C20.4: counters of audit validity are filters */
html body [data-audit-validity-monitor] .three .kv[data-audit-validity-filter] {
 width:100%!important;cursor:pointer!important;display:flex!important;flex-direction:column!important;
 align-items:flex-start!important;font:inherit!important;color:inherit!important;text-align:left!important;
 background:#fff!important;
}
html body [data-audit-validity-monitor] .kv[aria-pressed="true"]{outline:2px solid #2262a7!important}
html body [data-audit-validity-monitor] .kv:focus-visible{outline:3px solid #2262a7!important}
html body [data-audit-validity-monitor] [data-open-audit][hidden]{display:none!important}
html body [data-audit-validity-monitor]{height:auto!important;min-height:0!important}

/* Audits: secondary summary stays visible below the fixed primary indicators. */
html body [data-audit-validity-monitor] [data-audit-validity-body] > .three{
 position:sticky!important;
 top:calc(var(--pem-persistent-stack,310px) + 4px)!important;
 z-index:1037!important;
 background:var(--pem-color-canvas,#f3f6fa)!important;
 border-radius:10px!important;padding:6px!important;
}
html body [data-audit-validity-monitor] {
 margin-bottom:14px!important;
}
/* Responsive summary cards; avoid forcing four across on narrow viewports. */
@media(max-width:900px) {
 html body .pem-persistent-block#summary.grid {grid-template-columns:repeat(2,minmax(0,1fr))!important;}
}
@media(max-width:520px) {
 html body .pem-persistent-block#summary.grid {grid-template-columns:1fr!important;}
}

/* C20.4.1: fit all five preventive pyramid layers within 160px KPI band. */
@media (min-width:1451px) {
 html.pem-enterprise-ui .pem-dashboard-view .pem-release-pyramid-card {
   height:160px!important;min-height:160px!important;max-height:160px!important;
   padding:5px 9px!important;overflow:visible!important;align-self:stretch!important;
 }
 html.pem-enterprise-ui .pem-dashboard-view .pem-release-pyramid-head {
   margin-bottom:2px!important;
 }
 html.pem-enterprise-ui .pem-dashboard-view .pem-release-pyramid {
   gap:2px!important;
 }
 html.pem-enterprise-ui .pem-dashboard-view .pem-release-pyramid-tier {
   min-height:18px!important;padding:2px 7px!important;
 }
}

/* C20.4.2: validity controls form one separate fixed group, not a part of the long audit list. */
html body [data-audit-validity-monitor] [data-audit-validity-body] > .three.pem-persistent-block {
 position:fixed!important;
 display:grid!important;
 grid-template-columns:repeat(3,minmax(0,1fr))!important;
 box-sizing:border-box!important;
 padding:6px!important;gap:8px!important;
 background:var(--pem-color-canvas,#f3f6fa)!important;
 border-radius:10px!important;
}
/* Avoid additional accidental spacing before the program forms. */
html body .audit-shell > [data-audit-validity-monitor] + .grid {
 margin-top:12px!important;
}
@media(max-width:700px) {
 html body [data-audit-validity-monitor] [data-audit-validity-body] > .three.pem-persistent-block {
  grid-template-columns:1fr!important;
 }
}

/* PEM SySO C20.5: local layout polish, safe against C20.4.2 overrides. */
/* The statuses remain in DOM for real messages/errors; when empty they use no space. */
html body:has(.pem-report-filter-head) #status:empty,
html body:has(#deliveryForm) #status:empty {
  display:none!important;height:0!important;min-height:0!important;
  margin:0!important;padding:0!important;border:0!important;
}
/* EPP: person/context, indicators and form all share natural scroll, no detached cards. */
html body:has(#deliveryForm) .grid > aside,
html body:has(#deliveryForm) .grid > section > #metrics,
html body:has(#deliveryForm) #metrics {
  position:static!important;top:auto!important;bottom:auto!important;
  transform:none!important;z-index:auto!important;
}
html body:has(#deliveryForm) .grid > section > #metrics {
  margin-top:0!important;margin-bottom:10px!important;
}
html body:has(#deliveryForm) .grid > aside {
  align-self:start!important;margin-top:0!important;
}
html body:has(#deliveryForm) .shell > .notice + #status:empty + .grid {
  margin-top:8px!important;
}
/* Audit validity counts: when meaningful, keep three equal columns in the card. */
html body [data-audit-validity-monitor] [data-audit-validity-body] > .three {
  position:static!important;top:auto!important;transform:none!important;
  z-index:auto!important;
  display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:8px!important;
}
html body [data-audit-validity-monitor] {
  margin-top:10px!important;margin-bottom:10px!important;
  padding:12px!important;
}
html body .audit-shell > [data-audit-validity-monitor] + .grid {
  margin-top:10px!important;
}
@media(max-width:700px) {
 html body [data-audit-validity-monitor] [data-audit-validity-body] > .three {
  grid-template-columns:1fr!important;
 }
}

/* C20.6 surgically scoped closing corrections */
html body:has(#legalSummary) #legalSummary.pem-persistent-block {
  display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:9px!important;box-sizing:border-box!important;
}
html body:has(#legalSummary) #legalSummary.pem-persistent-block > .metric {
  min-width:0!important;
}
@media(max-width:800px) {
  html body:has(#legalSummary) #legalSummary.pem-persistent-block {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
@media(max-width:440px) {
  html body:has(#legalSummary) #legalSummary.pem-persistent-block {
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
html body:has(#tableWrap) #status:empty {display:none!important;margin:0!important;padding:0!important;height:0!important}
html body:has(#tableWrap) #tableWrap.hidden {display:none!important}
html body:has(#tableWrap) #metrics {position:static!important;transform:none!important;top:auto!important;z-index:auto!important}
html body:has(#tableWrap) #metrics + .pem-persistent-placeholder {display:none!important;height:0!important}
html body:has(#deliveryForm) .pem-epp-section-nav {display:flex;gap:9px;flex-wrap:wrap;margin:8px 0 12px}
html body:has(#deliveryForm) .pem-epp-section-nav a {padding:8px 13px;border-radius:9px;background:#fff;border:1px solid #d7e2ef;color:#185286;font-weight:700;text-decoration:none}
html body:has(#deliveryForm) .pem-epp-section-nav a:focus-visible {outline:3px solid #2e65a5;outline-offset:2px}
html body:has(#deliveryForm) #pem-epp-new,html body:has(#deliveryForm) #pem-epp-history {scroll-margin-top:90px}
html body:has(#deliveryForm) .shell > .notice + #status:empty {display:none!important;height:0!important;margin:0!important;padding:0!important}

/* C21.1: No sticky audit counters; no hidden validity placeholders. */
html body:has(#gateBanner):has(#mPrograms) #metrics{position:static!important;top:auto!important;left:auto!important;transform:none!important;z-index:auto!important;margin-bottom:10px!important}
html body [data-audit-validity-monitor]{display:none!important;height:0!important;margin:0!important;padding:0!important;border:0!important}
html body:has(#legalSummary) #legalSummary.pem-persistent-block{width:100%!important;grid-template-columns:repeat(4,minmax(0,1fr))!important}

/* C21.3 LAB: audit KPI band is sticky below dynamic persistent header. */
@media(min-width:701px){
 html body:has(#gateBanner):has(#mPrograms) #metrics.metrics{
  position:sticky!important;top:calc(var(--pem-persistent-stack,180px) + 8px)!important;
  left:auto!important;transform:none!important;z-index:1036!important;
  background:var(--pem-color-canvas,#f4f6f8)!important;padding:7px 0!important;
  margin-top:8px!important;margin-bottom:12px!important;
 }
}
@media(max-width:700px){
 html body:has(#gateBanner):has(#mPrograms) #metrics.metrics{position:static!important}
}
html body:has(#deliveryForm) #metrics.metrics{position:static!important;top:auto!important;left:auto!important;transform:none!important;z-index:auto!important}

html body .pem-audit-origin-link{display:inline-block;margin-top:5px;color:#1d5d99!important;font-weight:750;text-decoration:underline;text-underline-offset:2px}
html body .pem-audit-origin-link:hover,html body .pem-audit-origin-link:focus-visible{color:#123e70!important;outline-offset:3px}
