/* Sfera CRM · Company and Lead detail loading.
   Presentation only; official Sfera palette and existing API contracts. */
#detail-modal[data-entity-loading] #detail-state{
  position:absolute!important;width:1px!important;height:1px!important;
  margin:-1px!important;padding:0!important;overflow:hidden!important;
  clip:rect(0,0,0,0)!important;clip-path:inset(50%)!important;
  border:0!important;white-space:nowrap!important;
}
/* Preserve modal geometry and close action while loading. Never mix a stale
   left-hand identity column with the next record's loading state. */
#detail-modal[data-entity-loading] #detail-form > :is(.company-profile__sidebar,.lead-profile__sidebar){
  display:none!important;
}
#detail-modal[data-entity-loading] :is(.detail-hero,[data-lead-detail-tabs],[data-company-detail-tabs]){
  visibility:hidden!important;
}
#detail-modal.is-company:not(.is-lead)[data-entity-loading] #detail-form:not([hidden]),
#detail-modal.is-lead[data-entity-loading] #detail-form:not([hidden]){
  display:flex!important;flex-direction:column!important;align-items:stretch!important;
  min-width:0!important;min-height:100%!important;height:100%!important;
  overflow:auto!important;padding:0!important;margin:0!important;
}
#detail-modal[data-entity-loading] #detail-fields.entity-detail-loading-surface{
  display:grid!important;place-items:center!important;align-content:center!important;
  flex:1 1 auto!important;grid-column:1 / -1!important;
  width:100%!important;max-width:none!important;min-width:0!important;
  min-height:260px!important;margin:0!important;
  padding:clamp(18px,4vw,48px)!important;border:0!important;
  background:var(--co-page,#f3f6fb)!important;
}
/* Identical visual grammar to the Task results loader: icon + restrained
   typography, no panel, outline, progress border or gradient. */
#detail-modal .entity-detail-loading-card{
  box-sizing:border-box;display:flex;align-items:center;justify-content:center;
  gap:16px;max-width:min(100%,420px);min-height:72px;
  padding:14px 18px;border:0;border-radius:0;
  background:transparent;box-shadow:none;overflow:visible;
}
#detail-modal .entity-detail-loading-spinner{
  display:block;flex:0 0 34px;width:34px;height:34px;
  border:3px solid #e3ecf8;border-top-color:var(--dashboard-primary,#0b7ff0);
  border-radius:50%;animation:entity-detail-spin .72s linear infinite;
}
#detail-modal .entity-detail-loading-copy{
  display:grid;gap:5px;min-width:0;flex:1;
}
#detail-modal .entity-detail-loading-heading{
  color:var(--co-title,#0e2166);
  font:650 14px/1.3 Poppins,"Open Sans",sans-serif;
}
#detail-modal .entity-detail-loading-subtitle{
  color:#7486a0;font:400 12px/1.55 "Open Sans",sans-serif;
}
#detail-modal .entity-detail-loading-card--error{
  color:var(--dashboard-danger,#c43232);
}
#detail-modal .entity-detail-loading-card--error .entity-detail-loading-heading{
  color:#a32e3e;
}
#detail-modal .entity-detail-loading-error-icon{
  display:grid;place-items:center;flex:0 0 39px;
  height:39px;border-radius:12px;background:#fff1f2;color:#b83d4e;
  font:700 20px Poppins,"Open Sans",sans-serif;
}
#detail-modal[data-entity-ready="true"] #detail-fields:not(.entity-detail-loading-surface){
  animation:entity-detail-reveal .2s ease-out both;
}
@keyframes entity-detail-spin{to{transform:rotate(360deg)}}
@keyframes entity-detail-reveal{from{opacity:.76}to{opacity:1}}

/* Reserve actual two-column insight geometry before asynchronous Tier/Health
   modules mount; empty placeholders consume no Firestore reads. */
#detail-modal.is-company:not(.is-lead) .company-profile__insights{
  width:100%!important;min-width:0!important;
}
#detail-modal.is-company:not(.is-lead) .company-profile__insights > :is(.company-profile__health-mount,.company-profile__tier-mount){
  display:flex!important;flex-direction:column!important;
  width:100%!important;min-width:0!important;min-height:250px!important;
}
#detail-modal.is-company:not(.is-lead) .company-profile__insights > :is(.company-profile__health-mount,.company-profile__tier-mount):empty::before{
  box-sizing:border-box;
  display:flex;align-items:center;justify-content:center;
  flex:1;min-height:250px;padding:18px;
  border:1px solid #e1e9f4;border-radius:16px;
  background:#fff;color:#788aa3;
  font:500 12px/1.45 "Open Sans",sans-serif;
}
#detail-modal.is-company:not(.is-lead) .company-profile__health-mount:empty::before{
  content:"Customer Health · caricamento…";
}
#detail-modal.is-company:not(.is-lead) .company-profile__tier-mount:empty::before{
  content:"Customer Tier · caricamento…";
}
#detail-modal.is-company:not(.is-lead) .company-profile__insights > .company-profile__health-mount > .company-profile__health-summary,
#detail-modal.is-company:not(.is-lead) .company-profile__insights > .company-profile__tier-mount > .company-profile__tier-card{
  width:100%!important;min-width:0!important;min-height:250px!important;
}
/* Size is reserved while a specific live response is still pending. */
#detail-modal.is-company:not(.is-lead) .company-profile__insights .company-health__body:has(> .company-health__muted){
  min-height:144px!important;
}
@media(max-width:760px){
  #detail-modal .entity-detail-loading-card{
    max-width:100%;gap:13px;padding:12px;
  }
  #detail-modal .entity-detail-loading-spinner{flex-basis:33px;width:33px;height:33px}
  #detail-modal .entity-detail-loading-heading{font-size:14px}
  #detail-modal .entity-detail-loading-subtitle{font-size:11px}
  #detail-modal.is-company:not(.is-lead) .company-profile__insights > :is(.company-profile__health-mount,.company-profile__tier-mount){
    min-height:210px!important;
  }
  #detail-modal.is-company:not(.is-lead) .company-profile__insights > .company-profile__health-mount > .company-profile__health-summary,
  #detail-modal.is-company:not(.is-lead) .company-profile__insights > .company-profile__tier-mount > .company-profile__tier-card{
    min-height:210px!important;
  }
  #detail-modal.is-company:not(.is-lead) .company-profile__insights > :is(.company-profile__health-mount,.company-profile__tier-mount):empty::before{
    min-height:210px;
  }
}
@media(prefers-reduced-motion:reduce){
  #detail-modal .entity-detail-loading-spinner,
  #detail-modal[data-entity-ready="true"] #detail-fields{
    animation:none!important;
  }
}
