/* ===================== Data readiness (cards wait for their first real data) ===================== */
body[data-ilp-boot="1"] .pageShell,
body[data-ilp-boot="1"] #adminContentRoot,
body[data-ilp-boot="1"] .adminTopbar{ visibility: hidden !important; }

[data-admin-data]{ position: relative; }
[data-admin-data] > .adminDataStatus{
  color: var(--text-3);
  font-size: var(--fs-12);
}
[data-admin-data] > .adminDataStatus[hidden]{ display: none !important; }
[data-admin-load="pending"] .homeStatValue,
[data-admin-load="pending"] .homeKpiValue,
[data-admin-load="pending"] .uiStatValue,
[data-admin-load="pending"] .homeBig,
[data-admin-load="pending"] .homePresenceList{
  color: transparent !important;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-muted) 0, var(--bg-subtle) 60px, var(--bg-muted) 120px) var(--bg-muted);
  background-size: 480px 100%;
  animation: uiShimmer 1.3s linear infinite;
}
[data-admin-load="pending"] .homeBig{ display: inline-block; min-width: 64px; }
[data-admin-load="pending"] .homeStatValue,
[data-admin-load="pending"] .homeKpiValue,
[data-admin-load="pending"] .uiStatValue{ justify-self: start; align-self: flex-start; min-width: 72px; }
[data-admin-load="pending"] .homePresenceList > *{ visibility: hidden; }
[data-admin-load="pending"] > .adminDataStatus,
[data-admin-load="ready"] > .adminDataStatus{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[data-admin-load="error"] > .adminDataStatus{
  margin-top: 6px;
  color: var(--warning);
}

/* Unknown data must never be presented as a successful zero. Keep card geometry. */
[data-admin-load="error"] .homeStatValue,
[data-admin-load="error"] .homeKpiValue,
[data-admin-load="error"] .uiStatValue,
[data-admin-load="error"] .homeBig,
[data-admin-load="error"] .homePresenceList{ visibility: hidden !important; }
.adminDataRetry{
  border: 0; padding: 2px 0; background: none; color: var(--text-1);
  font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer;
}
.adminDataRetry:focus-visible{ outline: 2px solid currentColor; outline-offset: 3px; }

[data-admin-load]:not([data-admin-load="ready"]) :is(
  .homeHeroUpdated,.homeHeroOf,.homeHeroGrid,.homeHeroCoverage,.homeHeroFootValue,
  .homeKpiNote,.homePendingList,.homeSplit,.homeKpiRow,.dashPayrollTrend,
  .homeModesList,.homeSplitBar--modes
){ visibility: hidden !important; }

/* Keep the verified shell usable while individual tables are still loading. */
[data-admin-view-load]:not([data-admin-load="ready"]) > :not(.adminDataStatus){ visibility:hidden !important; }
[data-admin-view-load]:not([data-admin-load="ready"]) > .adminDataStatus{
  position:absolute; inset:24px; width:auto; height:auto; overflow:visible; clip:auto;
  display:flex; align-items:center; justify-content:center; gap:10px;
  min-height:200px; margin:0; color:var(--text-2); font-size:var(--fs-14);
}
[data-admin-view-load][data-admin-load="pending"] > .adminDataStatus::before{
  content:""; width:18px; height:18px; border:2px solid var(--border);
  border-top-color:var(--text-2); border-radius:50%; animation:ilpAccessSpin .8s linear infinite;
}
[data-admin-identity="pending"]{
  color:transparent !important; border-radius:6px; background:var(--bg-muted); min-width:100px;
}
#dashCompany[data-admin-identity="pending"]{ width:clamp(180px,30vw,320px); }
#sideCompanyAvatar[data-admin-identity="pending"]{ min-width:0; }
@media (prefers-reduced-motion: reduce){
  [data-admin-load="pending"] :is(.homeStatValue,.homeKpiValue,.uiStatValue,.homeBig,.homePresenceList),
  [data-admin-view-load][data-admin-load="pending"] > .adminDataStatus::before{ animation:none; }
}

/* Dark theme: the entry screen follows the saved theme from the first paint, so a dark
   dashboard never opens through a white page. The shared loader keeps its light look on
   access, onboarding and Premium, which have no theme attribute. */
html[data-theme="dark"] .pageLoadOverlay.ilpAccessLoading{
  background: var(--bg); color: var(--text); color-scheme: dark;
}
html[data-theme="dark"] .pageLoadOverlay.ilpAccessLoading .ilpAccessLoadingTitle{ color: var(--text); }
html[data-theme="dark"] .pageLoadOverlay.ilpAccessLoading .ilpAccessLoadingSpinner{
  border-color: var(--border-strong); border-top-color: var(--brand);
}

/* A section that is still loading keeps its title in place: the page is recognisable at once
   and nothing moves when the data arrives. Subtitles, toolbars, figures and tables stay hidden
   (and inert) until the real data is known; dynamic subtitles never show provisional values. */
[data-admin-view-load]:not([data-admin-load="ready"]) > .uiPage{ visibility: visible !important; }
[data-admin-view-load]:not([data-admin-load="ready"]) > .uiPage > :not(.uiPageHead),
[data-admin-view-load]:not([data-admin-load="ready"]) > .uiPage > .uiPageHead > :not(.uiPageHeadText),
[data-admin-view-load]:not([data-admin-load="ready"]) > .uiPage > .uiPageHead > .uiPageHeadText > :not(h1){
  visibility: hidden !important;
}

/* First data after a placeholder: a short fade instead of a hard swap. Applied only on the
   pending → ready transition (data-admin-reveal lasts a moment), never on live refreshes. */
@keyframes ilpDataReveal{ from{ opacity: 0; } to{ opacity: 1; } }
[data-admin-reveal] :is(
  .homeStatValue,.homeKpiValue,.uiStatValue,.homeBig,.homePresenceList,
  .homeHeroUpdated,.homeHeroOf,.homeHeroGrid,.homeHeroCoverage,.homeHeroFootValue,
  .homeKpiNote,.homePendingList,.homeSplit,.homeKpiRow,.dashPayrollTrend,
  .homeModesList,.homeSplitBar--modes
),
[data-admin-view-load][data-admin-reveal] > .uiPage > :not(.uiPageHead),
[data-admin-view-load][data-admin-reveal] > .uiPage > .uiPageHead > :not(.uiPageHeadText),
[data-admin-view-load][data-admin-reveal] > .uiPage > .uiPageHead > .uiPageHeadText > :not(h1){
  animation: ilpDataReveal .24s var(--ease-out) both;
}
@media (prefers-reduced-motion: reduce){
  [data-admin-reveal] :is(
    .homeStatValue,.homeKpiValue,.uiStatValue,.homeBig,.homePresenceList,
    .homeHeroUpdated,.homeHeroOf,.homeHeroGrid,.homeHeroCoverage,.homeHeroFootValue,
    .homeKpiNote,.homePendingList,.homeSplit,.homeKpiRow,.dashPayrollTrend,
    .homeModesList,.homeSplitBar--modes
  ),
  [data-admin-view-load][data-admin-reveal] .uiPage *{ animation: none !important; }
}

/* Waiting states without words: a spinner is enough. The status text stays in the live region
   for screen readers (font-size 0 keeps it in the accessibility tree). Errors keep their text. */
[data-admin-view-load][data-admin-load="pending"] > .adminDataStatus{ font-size: 0; }
.uiViewLoading{
  display: flex; justify-content: center; align-items: center;
  min-height: 240px; font-size: 0; color: transparent;
}
.uiViewLoading::before{
  content: ""; width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--text-2); border-radius: 50%; animation: ilpAccessSpin .8s linear infinite;
}
@media (prefers-reduced-motion: reduce){ .uiViewLoading::before{ animation: none; } }
