/* Global loading overlay — one sofa, built then taken apart, looping
   until the next page paints over it. Shared by both shells: the --lo-*
   tokens fall back from the ERP's --color-* names to the CRM's --crm-*
   names so one stylesheet tracks whichever theme is active. */
.loading-overlay{
  position:fixed;
  /* Left edge sits at the rail's own width (collapsed or expanded, ERP
     or CRM) so the sidebar stays visible and clickable while this is up. */
  left:var(--rail-w, var(--sidebar-w, var(--crm-sidebar-w, 232px)));
  top:0; right:0; bottom:0;
  z-index:9999;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:22px;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:opacity .15s ease;
  --lo-bg: var(--color-bg, var(--crm-bg, #f6f4f0));
  --lo-ink: var(--color-ink, var(--crm-ink, #1c1a17));
  --lo-ink-light: var(--color-ink-light, var(--crm-body, #35312b));
  --lo-surface: var(--color-surface, var(--crm-surface, #ffffff));
  --lo-border: var(--color-border, var(--crm-rule, #e4e0d7));
  background:var(--lo-bg);
}
.loading-overlay.is-active{
  opacity:1;
  visibility:visible;
}
.loading-overlay .rig{
  width:160px;
  height:109px;
  position:relative;
}
.loading-overlay .rig svg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  overflow:visible;
}
.loading-overlay .piece{
  animation: lo-piece-fly 2.42s cubic-bezier(.22,.9,.3,1) infinite;
  transform-origin:center;
}
.loading-overlay .load-label{
  font-family:"Helvetica Neue",HelveticaNeue,Helvetica,"Segoe UI",Arial,sans-serif;
  font-size:13px;
  letter-spacing:.02em;
  font-weight:600;
  color:var(--lo-ink);
}

/* Build, hold briefly, then take apart the same way it arrived. */
@keyframes lo-piece-fly{
  0%   { transform:translate(var(--fx), var(--fy)) rotate(var(--rot)); opacity:0; }
  18%  { opacity:1; }
  36%  { transform:translate(0,0) rotate(0deg); opacity:1; }
  54%  { transform:translate(0,0) rotate(0deg); opacity:1; }
  90%  { opacity:0; }
  100% { transform:translate(var(--fx), var(--fy)) rotate(var(--rot)); opacity:0; }
}

@media (prefers-reduced-motion: reduce){
  .loading-overlay .piece{ animation:none !important; opacity:1 !important; transform:none !important; }
}
