/* Story demo: Excel pricing & margin control (page-specific pieces) */

/* ---------- Scene 1: many versions, broken formulas ---------- */
.sfp-fx {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 26px;
    padding: 0 10px;
    border-bottom: 1px solid #e8edf3;
    font-size: 11px;
    color: #334155;
    white-space: nowrap;
}

.sfp-fx em {
    font-style: italic;
    font-weight: 700;
    color: #94a3b8;
    padding-right: 8px;
    border-right: 1px solid #e2e8f0;
}

.sfp-fx code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fef2f2;
    color: #dc2626;
}

.sfx-sheet td.sel { outline: 2px solid #16a34a; outline-offset: -2px; background: #f0fdf4; }

.sfp-ghost-rows { padding: 8px 10px; }
.sfp-ghost-rows span {
    display: block;
    height: 16px;
    margin-bottom: 5px;
    border-radius: 3px;
    background: repeating-linear-gradient(90deg, #f1f5f9 0 30%, #fff 30% 31%);
}

.sfp-q {
    position: absolute;
    width: 172px;
    padding: 14px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 8px 16px -6px rgba(15, 23, 42, 0.12),
        0 30px 60px -18px rgba(15, 23, 42, 0.28);
    transform: translateZ(var(--z, 0));
}

.sfp-q span { display: block; font-size: 11px; color: #64748b; }
.sfp-q b { display: block; font-size: 30px; line-height: 1.2; margin: 2px 0 8px; color: #d97706; }
.sfp-q p {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-top: 1px dashed #e2e8f0;
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}
.sfp-q p s { color: #64748b; }

/* ---------- Scene 2: one input sheet + macro button ---------- */
.sfp-ribbon {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e8edf3;
}

.sfp-ribbon .sfx-run { padding: 7px 14px; font-size: 12.5px; border-radius: 8px; }

.sfp-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
}

.sfp-input { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; padding: 14px 14px 10px; }

.sfp-field {
    display: grid;
    grid-template-columns: 92px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    font-size: 11.5px;
    color: #64748b;
}

.sfp-cell {
    position: relative;
    height: 26px;
    padding: 0 9px;
    border: 1px solid #fde68a;
    border-radius: 6px;
    background: #fffbeb;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.sfp-cell b {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.sfp-cell.done { border-color: #bbf7d0; background: #f0fdf4; }

.sfp-logic {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 11px;
    color: #64748b;
}

.sfp-logic-h { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
.sfp-logic-h em { font-style: normal; margin-left: auto; font-size: 10px; padding: 1px 7px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; }

.sfp-logic code {
    display: block;
    margin: 5px 0;
    padding: 5px 7px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e8edf3;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    color: #334155;
    white-space: nowrap;
}

.sfp-tabs {
    display: flex;
    gap: 2px;
    padding: 0 12px;
    border-top: 1px solid #e8edf3;
    background: #f8fafc;
    font-size: 10.5px;
    color: #94a3b8;
}

.sfp-tabs span { padding: 5px 12px; }
.sfp-tabs span.on { background: #fff; color: #15803d; font-weight: 700; border-bottom: 2px solid #16a34a; }

.sfp-prog { padding: 0 14px 12px; }
.sfp-prog .sfx-progress { margin-top: 0; }

/* ---------- Scene 3: price-to-margin bridge + line checks ---------- */
.sfp-wf-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 0; font-size: 11px; color: #64748b; }
.sfp-wf-head b { font-size: 12px; color: #0f172a; margin-right: auto; }

.sfp-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: #dcfce7;
    color: #15803d;
    white-space: nowrap;
}

.sfp-wf {
    position: relative;
    height: 196px;
    margin: 22px 16px 0;
    border-bottom: 1px solid #e2e8f0;
}

.sfp-wf div {
    position: absolute;
    bottom: var(--b);
    left: var(--x);
    width: 54px;
    height: max(var(--h), 4px);
    border-radius: 4px;
    background: var(--c);
}

.sfp-wf div span {
    position: absolute;
    left: 50%;
    bottom: 100%;
    margin-bottom: 3px;
    transform: translateX(-50%);
    font-size: 10.5px;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.sfp-wf div.neg span { color: #dc2626; }
.sfp-wf div.pos span { color: #15803d; }

.sfp-wf-x { position: relative; height: 30px; margin: 0 16px; }
.sfp-wf-x span {
    position: absolute;
    top: 5px;
    left: var(--x);
    width: 54px;
    text-align: center;
    font-size: 10px;
    line-height: 1.25;
    color: #64748b;
}

.sfp-chk-row { grid-template-columns: 1fr 52px 72px; padding: 7px 4px; }
.sfp-chk-row span:first-child { font-family: inherit; font-size: 11.5px; }
.sfp-chk-row.total { border-top: 1px solid #e2e8f0; font-weight: 700; color: #0f172a; }

/* ---------- Scene 4: approved quotation ---------- */
.sfp-quote { width: 336px; padding: 18px 18px 16px; }

.sfp-quote-h { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.sfp-quote-h b { display: block; font-size: 16px; }
.sfp-quote-h span { font-size: 10.5px; color: #64748b; }
.sfp-quote-h em { font-style: normal; font-size: 10.5px; font-weight: 700; color: #1d4ed8; background: #eff6ff; padding: 2px 8px; border-radius: 6px; }

.sfp-quote table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.sfp-quote th { text-align: left; font-weight: 600; font-size: 10px; color: #94a3b8; padding: 5px 4px; border-bottom: 1px solid #e2e8f0; }
.sfp-quote td { padding: 6px 4px; border-bottom: 1px dashed #edf1f5; color: #334155; }
.sfp-quote th:last-child, .sfp-quote td:last-child { text-align: right; }
.sfp-quote th:nth-child(2), .sfp-quote td:nth-child(2) { text-align: center; }

.sfp-quote-t { margin-top: 8px; font-size: 11px; color: #64748b; font-variant-numeric: tabular-nums; }
.sfp-quote-t p { display: flex; justify-content: space-between; padding: 2px 4px; }
.sfp-quote-t p.net { margin-top: 4px; padding: 7px 8px; border-radius: 8px; background: #eff6ff; color: #1e3a8a; font-weight: 700; font-size: 12px; }
.sfp-quote-t p.net b { font-size: 15px; }

.sfp-approved {
    position: absolute;
    right: -30px;
    bottom: -18px;
    padding: 5px 12px;
    border: 2.5px solid #16a34a;
    border-radius: 8px;
    color: #16a34a;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
    background: #f0fdf4;
    box-shadow: 0 8px 18px -8px rgba(22, 163, 74, 0.45);
    transform: rotate(-10deg);
    white-space: nowrap;
}

.sfp-sum { padding: 6px 14px 12px; }
.sfp-sum div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 11.5px;
    color: #64748b;
}
.sfp-sum div:last-child { border-bottom: 0; }
.sfp-sum b { color: #0f172a; font-size: 12.5px; white-space: nowrap; }
.sfp-sum .ok { color: #15803d; }

/* ---------- Motion (active scene only) ---------- */
.is-active .sfp-q { animation: sfp-rise 0.6s ease both 0.5s; }

.is-active .sfp-cell b { max-width: 0; animation: sfp-type 0.55s steps(12) forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-late.sfx-press { animation-delay: 1.9s; animation-fill-mode: both; }
.is-active .sfp-late.sfx-cursor { animation-delay: 1.9s; animation-fill-mode: both; }
.is-active .sfp-late.sfx-progress span { animation-delay: 1.9s; animation-fill-mode: both; }
.is-active .sfp-logic { animation: sfp-rise 0.6s ease both 0.3s; }

.is-active .sfp-wf div { animation: sfp-bar 0.55s cubic-bezier(.3, 1, .4, 1) both; animation-delay: var(--d, 0s); transform-origin: top; }
.is-active .sfp-wf div.tot { transform-origin: bottom; }
.is-active .sfp-badge { animation: sfp-pop 0.45s cubic-bezier(.2, 1.6, .4, 1) both 2.4s; }

.is-active .sfp-quote { animation: sfp-rise 0.7s cubic-bezier(.2, 1.2, .4, 1) both 0.1s; }
.is-active .sfp-quote tbody tr { animation: sfx-row 0.35s ease both; animation-delay: var(--d, 0s); }
.is-active .sfp-approved { animation: sfp-stamp 0.45s cubic-bezier(.2, 1.6, .4, 1) both 1.3s; }
.is-active .sfp-sumwin { animation: sfp-slide-l 0.6s ease both 0.6s; }

@keyframes sfp-rise { from { opacity: 0; transform: translateZ(var(--z, 0)) translateY(18px); } to { opacity: 1; transform: translateZ(var(--z, 0)); } }
@keyframes sfp-type { from { max-width: 0; } to { max-width: 220px; } }
@keyframes sfp-bar { from { transform: scaleY(0); opacity: 0.4; } to { transform: scaleY(1); opacity: 1; } }
@keyframes sfp-pop { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: scale(1); } }
@keyframes sfp-stamp { from { opacity: 0; transform: rotate(-24deg) scale(2); } to { opacity: 1; transform: rotate(-10deg) scale(1); } }
@keyframes sfp-slide-l { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .is-active .sfp-cell b { max-width: none; }
}
