/* ClinicOS Shell — Background Activity panel (Stage 6). Scoped to #cos-activity and the two body state classes; nothing else is restyled. A restrained floating panel
   near the middle of the workspace; the existing small top status (#ws-loading-label) is its minimized form. Tokens follow Shell 2 (Light + Dark); subtle motion only. */
#cos-activity {
  --act-ink: var(--cos-color-text-primary, var(--ink, #14202b));
  --act-ink-2: var(--cos-color-text-secondary, var(--ink-3, #4a5a68));
  --act-muted: var(--cos-color-text-muted, var(--ink-3, #6b7a88));
  --act-surface: var(--cos-color-bg-surface, var(--bg2, #fff));
  --act-line: var(--cos-color-border, rgba(127, 140, 152, .38));
  --act-brand: var(--cos-color-brand-primary, var(--teal, #0f766e));
  --act-danger: var(--cos-color-danger, #c0392b);
  --act-warn: var(--cos-tone-amber, #d99a1e);
  --act-focus: var(--cos-color-focus, #2563eb);
  position: fixed; z-index: 850; top: 38%; left: calc(50% + var(--cos-sidebar-w, 0px) / 2); transform: translate(-50%, -50%);
  width: clamp(380px, 32vw, 460px); max-width: calc(100vw - 32px); pointer-events: none;
}
#cos-activity[hidden] { display: none; }
#cos-activity .cos-act-card { pointer-events: auto; padding: 18px 20px 16px; border: 1px solid var(--act-line); border-radius: 14px; background: var(--act-surface); box-shadow: 0 18px 48px rgba(10, 20, 30, .22); animation: cos-act-in .18s ease-out; }
#cos-activity .cos-act-title { font: 700 0.6875rem/1.2 inherit; font-family: inherit; letter-spacing: .1em; text-transform: uppercase; color: var(--act-brand); }
#cos-activity .cos-act-label { margin: 6px 0 0; font: 700 1.0625rem/1.35 inherit; font-family: inherit; color: var(--act-ink); overflow-wrap: anywhere; }
#cos-activity .cos-act-detail { margin: 4px 0 0; font-size: 0.8125rem; line-height: 1.45; color: var(--act-ink-2); overflow-wrap: anywhere; }
#cos-activity .cos-act-detail:empty { display: none; }
#cos-activity .cos-act-bar { position: relative; height: 4px; margin: 14px 0 0; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--act-brand) 16%, transparent); }
#cos-activity .cos-act-bar i { position: absolute; inset: 0 auto 0 0; width: 38%; border-radius: inherit; background: var(--act-brand); animation: cos-act-slide 1.6s ease-in-out infinite; }
#cos-activity .cos-act-bar.is-determinate i { animation: none; transition: width .25s ease; }
#cos-activity .cos-act-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 14px 0 0; }
#cos-activity .cos-act-actions:not(:has(button:not([hidden]))) { display: none; }
#cos-activity .cos-act-btn { min-height: 34px; padding: 0 14px; border: 1px solid var(--act-line); border-radius: 8px; background: transparent; color: var(--act-ink); font: 600 0.8125rem/1 inherit; font-family: inherit; cursor: pointer; }
#cos-activity .cos-act-btn:hover { background: color-mix(in srgb, var(--act-brand) 8%, var(--act-surface)); }
#cos-activity .cos-act-btn:focus-visible { outline: 2px solid var(--act-focus); outline-offset: 2px; }
#cos-activity .cos-act-btn[hidden] { display: none; }
#cos-activity .cos-act-btn--primary { border-color: var(--act-brand); background: var(--act-brand); color: #fff; }
/* phases: working (brand) · success (brand, static bar) · failure (danger, persistent) · attention (amber, needs the user) */
#cos-activity [data-phase="success"] .cos-act-bar i { animation: none; width: 100%; }
#cos-activity [data-phase="failure"] { border-color: color-mix(in srgb, var(--act-danger) 55%, var(--act-line)); }
#cos-activity [data-phase="failure"] .cos-act-title { color: var(--act-danger); } #cos-activity [data-phase="failure"] .cos-act-bar { display: none; }
#cos-activity [data-phase="attention"] { border-color: color-mix(in srgb, var(--act-warn) 60%, var(--act-line)); }
#cos-activity [data-phase="attention"] .cos-act-title { color: var(--cos-color-warning, #9a6700); } #cos-activity [data-phase="attention"] .cos-act-bar { display: none; }
/* while the panel is up the small top status would repeat it; hidden = minimized, so the small status is the minimized form and can reopen the panel */
body.cos-activity-expanded #ws-loading-label { opacity: 0 !important; }
body.cos-activity-min #ws-loading-label { pointer-events: auto; cursor: pointer; }
body.cos-activity-min #ws-loading-label::after { content: "Show details"; grid-column: 1 / -1; font-size: 9px; color: var(--cos-color-brand-primary, var(--teal)); }
@keyframes cos-act-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cos-act-slide { 0% { left: -40%; } 100% { left: 102%; } }
@media (max-width: 1024px) { #cos-activity { left: calc(50% + 36px); } }
@media (max-width: 768px) { #cos-activity { left: 50%; top: 42%; width: calc(100vw - 32px); } #cos-activity .cos-act-card { padding: 16px 16px 14px; } }
@media (prefers-reduced-motion: reduce) { #cos-activity .cos-act-card { animation: none; } #cos-activity .cos-act-bar i { animation: none; width: 100%; opacity: .55; } #cos-activity .cos-act-bar.is-determinate i { opacity: 1; transition: none; } }
