/* Story demo: Excel report recovery (page-specific pieces) */

.sfp-sheet td { white-space: nowrap; }
.sfp-sheet td.l { text-align: left; }
.sfp-sheet td.sel { outline: 2px solid #2563eb; outline-offset: -2px; }

/* Excel alert dialog */
.sfp-alert {
    position: absolute;
    width: 250px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    overflow: hidden;
    transform: translateZ(var(--z, 0));
}

.sfp-alert-body { display: flex; gap: 10px; padding: 14px 14px 10px; }

.sfp-alert-body .sfp-alert-ico {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fef3c7;
    color: #b45309;
    font-weight: 800;
    font-size: 15px;
}

.sfp-alert-body b { display: block; font-size: 12.5px; color: #0f172a; }
.sfp-alert-body span { display: block; font-size: 11px; color: #64748b; margin-top: 2px; }

.sfp-alert-foot { display: flex; justify-content: flex-end; padding: 0 14px 12px; }

.sfp-alert-foot span {
    padding: 4px 18px;
    border-radius: 6px;
    background: linear-gradient(#3b82f6, #2563eb);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
}

/* Deadline clock card */
.sfp-clock {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 12px 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
}

.sfp-clock .sfp-dial {
    position: relative;
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid #ef4444;
    background:
        radial-gradient(circle, #0f172a 0 2.5px, transparent 3px),
        repeating-conic-gradient(from -1deg, #cbd5e1 0 2deg, transparent 2deg 30deg) content-box;
    box-sizing: border-box;
}

.sfp-dial::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: #fff;
}

.sfp-dial i {
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 2.5px;
    margin-left: -1.25px;
    border-radius: 2px;
    background: #0f172a;
    transform-origin: 50% 100%;
    transform: rotate(var(--a));
}

.sfp-dial i.h { height: 12px; }
.sfp-dial i.m { height: 17px; width: 2px; margin-left: -1px; background: #ef4444; }

.sfp-dial::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: #0f172a;
}

.sfp-clock span { display: block; font-size: 11px; color: #64748b; }
.sfp-clock b { display: block; font-size: 19px; line-height: 1.2; font-weight: 700; color: #0f172a; }
.sfp-clock em { font-style: normal; display: inline-block; margin-top: 3px; padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; background: #fee2e2; color: #dc2626; }

.sfp-clock.ok .sfp-dial { border-color: #16a34a; }
.sfp-clock.ok .sfp-dial i.m { background: #16a34a; }
.sfp-clock.ok em { background: #dcfce7; color: #15803d; }

/* Formula bar */
.sfp-fxbar {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    font-size: 15px;
    white-space: nowrap;
    transform: translateZ(var(--z, 0));
}

.sfp-fxbar .ref {
    padding: 3px 9px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
}

.sfp-fxbar .fx { font-style: italic; font-weight: 600; color: #94a3b8; padding-right: 10px; border-right: 1px solid #e2e8f0; }
.sfp-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; color: #334155; }
.sfp-code .fn { color: #7c3aed; }
.sfp-code .rg { color: #2563eb; }
.sfp-code .bad { position: relative; color: #dc2626; font-weight: 700; padding: 0 3px; border-radius: 4px; background: #fee2e2; }

/* Deleted column ghost */
.sfp-sheet th.gone, .sfp-sheet td.gone {
    background: repeating-linear-gradient(-45deg, #fef2f2 0 6px, #fee2e2 6px 12px);
    border: 1.5px dashed #f87171;
    color: #dc2626;
}

.sfp-sheet td.gone { text-align: center; font-weight: 700; font-size: 10.5px; }

/* Trace arrows (precedent tracing) */
.sfp-trace { position: absolute; left: 0; top: 0; width: 800px; height: 440px; overflow: visible; transform: translateZ(30px); pointer-events: none; }
.sfp-trace path { fill: none; stroke: #2563eb; stroke-width: 2.5; stroke-dasharray: 7 6; }
.sfp-trace .tip { fill: #2563eb; }
.sfp-trace .dot { fill: #2563eb; }

.sfp-tag {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 10px 22px -8px rgba(220, 38, 38, 0.55);
}

/* Formula fix card */
.sfp-diff {
    position: absolute;
    width: 318px;
    padding: 12px 14px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    transform: rotate(-3deg);
    z-index: 2;
}

.sfp-diff-head { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: #64748b; margin-bottom: 8px; }
.sfp-diff-head b { color: #0f172a; font-size: 12.5px; }

.sfp-dl {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 7px 9px;
    border-radius: 8px;
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
}

.sfp-dl .sfp-code { font-size: 11.5px; }
.sfp-dl i { flex: none; font-style: normal; font-weight: 800; font-size: 13px; width: 12px; text-align: center; }
.sfp-dl.del { background: #fef2f2; }
.sfp-dl.del i { color: #dc2626; }
.sfp-dl.del .sfp-code { color: #b91c1c; text-decoration: line-through; text-decoration-color: rgba(185, 28, 28, 0.6); }
.sfp-dl.add { background: #f0fdf4; }
.sfp-dl.add i { color: #16a34a; }
.sfp-dl.add .sfp-code { color: #166534; }

.sfp-refresh {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
}

.sfp-refresh .spin {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #eff6ff;
    font-size: 13px;
}

.sfp-refresh .sfx-progress { flex: 1; margin-top: 0; }

/* Status flip colours: errors turning into numbers */
.sfp-fix .sfx-row { grid-template-columns: 1.15fr 1fr 1.1fr 0.9fr; }
.sfp-fix .sfx-row span:first-child { font-family: inherit; font-size: 12px; }
.sfp-fix .sfx-st em { color: #dc2626; background: #fee2e2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; }
.sfp-fix .sfx-st b.ok { background: transparent; color: #0f172a; padding-left: 0; font-size: 12px; }
.sfp-fix .sfx-st b.pct { background: #dcfce7; color: #15803d; }
.sfp-fix .sfx-st b.low { background: #fef3c7; color: #b45309; }

/* Report dashboard */
.sfp-dash { padding: 14px 16px 16px; }

.sfp-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.sfp-kpi {
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid #eef2f6;
    background: #fbfdff;
}

.sfp-kpi span { display: block; font-size: 10.5px; color: #64748b; }
.sfp-kpi b { display: block; font-size: 19px; line-height: 1.25; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.sfp-kpi b.up { color: #16a34a; }

.sfp-chart {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    height: 140px;
    margin-top: 14px;
    padding: 0 10px 0 36px;
    border-bottom: 1px solid #e2e8f0;
    background: repeating-linear-gradient(to top, transparent 0 34px, #f1f5f9 34px 35px);
}

.sfp-chart .bar {
    position: relative;
    flex: 1;
    height: var(--h);
    border-radius: 5px 5px 0 0;
    background: linear-gradient(#60a5fa, #2563eb);
}

.sfp-chart .bar.hi { background: linear-gradient(#34d399, #059669); }

.sfp-chart .bar em {
    position: absolute;
    left: 50%;
    top: -18px;
    transform: translateX(-50%);
    font-style: normal;
    font-size: 10px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.sfp-target {
    position: absolute;
    left: 30px;
    right: 6px;
    bottom: 96px;
    border-top: 1.5px dashed #f59e0b;
}

.sfp-target span {
    position: absolute;
    left: -30px;
    top: -8px;
    font-size: 9.5px;
    font-weight: 700;
    color: #b45309;
}

.sfp-axis { display: flex; gap: 16px; padding: 5px 10px 0 36px; }
.sfp-axis span { flex: 1; text-align: center; font-size: 10.5px; color: #64748b; white-space: nowrap; }

/* ---------- Motion ---------- */

.is-active .sfp-clock:not(.ok) .sfp-dial i.m { animation: sfp-tick 4s linear infinite; }
.is-active .sfp-alert { opacity: 0; animation: sfp-pop 0.5s cubic-bezier(.2, 1.3, .4, 1) forwards 0.7s; }
.is-active .sfp-trace path { stroke-dashoffset: 0; animation: sfp-dash 1s linear infinite; }
.is-active .sfp-trace .draw { opacity: 0; animation: sfx-in 0.4s ease forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-tag { opacity: 0; animation: sfp-tag 0.5s cubic-bezier(.2, 1.4, .4, 1) forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-code .bad { animation: sfp-flash 0.9s ease 2 0.4s; }
.is-active .sfp-dl.add { opacity: 0; animation: sfp-slide 0.45s ease forwards 0.5s; }
.is-active .sfp-refresh .spin { animation: sfp-spin 1.2s linear infinite; }
.is-active .sfp-refresh .sfx-progress span { animation: sfp-fill 2.4s ease forwards 0.6s; }
.is-active .sfp-chart .bar { transform-origin: bottom; animation: sfx-grow 0.8s cubic-bezier(.2, .9, .3, 1) both; animation-delay: var(--d, 0.4s); }
.is-active .sfp-chart .bar em { opacity: 0; animation: sfx-in 0.3s ease forwards; animation-delay: calc(var(--d, 0.4s) + 0.7s); }
.is-active .sfp-kpi { opacity: 0; animation: sfp-slide 0.45s ease forwards; animation-delay: var(--d, 0s); }

@keyframes sfp-tick { to { transform: rotate(calc(var(--a) + 360deg)); } }

@keyframes sfp-pop {
    from { opacity: 0; transform: translateZ(var(--z, 0)) scale(0.85); }
    to { opacity: 1; transform: translateZ(var(--z, 0)); }
}

@keyframes sfp-dash { to { stroke-dashoffset: -26; } }

@keyframes sfp-tag {
    from { opacity: 0; transform: translateY(8px) scale(0.9); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-flash {
    50% { background: #fecaca; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
}

@keyframes sfp-slide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-spin { to { transform: rotate(360deg); } }
@keyframes sfp-fill { from { width: 0; } to { width: 100%; } }

@media (prefers-reduced-motion: reduce) {
    .sfp-refresh .sfx-progress span { width: 100%; }
}
