/* Story demo: Excel order entry form (page-specific pieces) */

/* ---------- Sheet details ---------- */

.sfp-fx {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 26px;
    padding: 0 10px;
    border-bottom: 1px solid #edf1f5;
    font-size: 11.5px;
    color: #334155;
}

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

.sfp-fx em {
    font-style: normal;
    padding: 1px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    color: #64748b;
    font-size: 10.5px;
}

.sfp-sheet td { text-align: left; white-space: nowrap; }
.sfp-sheet td.n { text-align: right; }
.sfp-sheet td.err, .sfp-sheet td.warn { text-align: left; }
.sfp-sheet td.n.err { text-align: right; }

.sfp-sel {
    position: relative;
    outline: 2px solid #16a34a;
    outline-offset: -2px;
    background: #fff;
}

.sfp-sel::after {
    content: "";
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 6px;
    height: 6px;
    background: #16a34a;
    border: 1px solid #fff;
}

.sfp-caret {
    display: inline-block;
    width: 1.5px;
    height: 12px;
    margin-left: 1px;
    vertical-align: -2px;
    background: #0f172a;
}

/* Paper order slip */
.sfp-slip-item {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: #475569;
    padding: 5px 0;
    border-bottom: 1px dashed #e2e8f0;
}

.sfp-slip-item b { color: #0f172a; font-weight: 600; }

/* Short arrow note pointing at a bad row */
.sfp-note {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 8px 20px -8px rgba(15, 23, 42, 0.35);
}

.sfp-note-red { background: #ef4444; color: #fff; }
.sfp-note-amber { background: #f59e0b; color: #fff; }

/* ---------- Toolbar + add button on the sheet ---------- */

.sfp-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid #edf1f5;
    background: #fbfcfd;
}

.sfp-tools .sfx-run {
    display: inline-block;
    padding: 7px 14px;
    font-size: 12.5px;
    border-radius: 8px;
}

.sfp-tool-ghost {
    width: 54px;
    height: 10px;
    border-radius: 5px;
    background: #e9eef4;
}

/* ---------- The UserForm ---------- */

.sfp-form-body { padding: 14px 16px 16px; }

.sfp-field {
    position: relative;
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}

.sfp-form-v .sfp-field { grid-template-columns: 64px 1fr 112px; }

.sfp-field > label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.sfp-field > label i { font-style: normal; color: #ef4444; margin-left: 2px; }

.sfp-in {
    position: relative;
    display: flex;
    align-items: center;
    height: 30px;
    padding: 0 10px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    font-size: 12.5px;
    color: #0f172a;
    white-space: nowrap;
    overflow: visible;
}

.sfp-in.dd { padding-right: 26px; }

.sfp-in.dd::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 11px;
    width: 6px;
    height: 6px;
    border-right: 1.6px solid #64748b;
    border-bottom: 1.6px solid #64748b;
    transform: rotate(45deg);
}

.sfp-in .u { margin-left: auto; font-size: 11px; color: #94a3b8; }
.sfp-in .ph { color: #cbd5e1; }

.sfp-cal {
    margin-left: auto;
    width: 14px;
    height: 13px;
    border: 1.5px solid #94a3b8;
    border-top-width: 3.5px;
    border-radius: 3px;
}

.sfp-val { display: inline-block; white-space: nowrap; }

.sfp-radios { display: flex; gap: 12px; font-size: 12px; color: #334155; }
.sfp-radios span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

.sfp-radios span::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid #94a3b8;
    background: #fff;
    box-sizing: border-box;
}

.sfp-radios span.on::before { border: 4px solid #2563eb; }

.sfp-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.sfp-btn {
    display: inline-block;
    padding: 7px 18px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 700;
    border: 1px solid #e2e8f0;
    color: #475569;
    background: #fff;
}

.sfp-btn.primary {
    border-color: #1d4ed8;
    background: linear-gradient(#3b82f6, #2563eb);
    color: #fff;
}

.sfp-btn.locked {
    border-color: #e2e8f0;
    background: #f1f5f9;
    color: #94a3b8;
}

/* Dropdown list that opens over the customer field */
.sfp-list {
    position: absolute;
    left: 74px;
    right: 0;
    top: 33px;
    z-index: 4;
    padding: 4px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 16px 30px -10px rgba(15, 23, 42, 0.35);
    font-size: 12px;
    color: #334155;
}

.sfp-list span { display: block; padding: 5px 8px; border-radius: 6px; }
.sfp-list span.hl { background: #eff6ff; color: #1d4ed8; font-weight: 600; }

/* Validation status column */
.sfp-st { position: relative; height: 22px; }

.sfp-st em, .sfp-st b {
    position: absolute;
    left: 0;
    top: 1px;
    font-style: normal;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.sfp-st em { color: #94a3b8; background: #f1f5f9; }
.sfp-st b { opacity: 0; transform: scale(0.6); }
.sfp-st b.ok { background: #dcfce7; color: #15803d; }
.sfp-st b.bad { background: #fee2e2; color: #dc2626; }

.sfp-scanf {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 44px;
    height: 36px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.07);
    border: 1px solid rgba(59, 130, 246, 0.35);
    opacity: 0;
    pointer-events: none;
}

/* Rule pills card */
.sfp-rules {
    position: absolute;
    width: 196px;
    padding: 12px 14px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
}

.sfp-rules > b { display: block; font-size: 12px; color: #64748b; margin-bottom: 8px; }
.sfp-rules span {
    display: inline-block;
    margin: 0 4px 6px 0;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 600;
}

/* ---------- Main order table (Excel Table style) ---------- */

.sfp-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.sfp-tbl th {
    position: relative;
    padding: 7px 20px 7px 8px;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    font-size: 11px;
    text-align: left;
    white-space: nowrap;
}

.sfp-tbl th::after {
    content: "";
    position: absolute;
    right: 5px;
    top: 8px;
    width: 11px;
    height: 11px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.22) linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.9) 50%) no-repeat 3px 2px / 5px 5px;
}

.sfp-tbl td {
    padding: 7px 8px;
    color: #334155;
    white-space: nowrap;
    border-bottom: 1px solid #eef2f7;
}

.sfp-tbl tr:nth-child(odd) td { background: #f5f8ff; }
.sfp-tbl td.n { text-align: right; }
.sfp-tbl td.id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; color: #64748b; }
.sfp-tbl tr.sfp-new td { background: #ecfdf5; color: #065f46; font-weight: 600; }
.sfp-tbl tr.sfp-new td.id { color: #047857; }

.sfp-newtag {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #16a34a;
    color: #fff;
    font-family: 'Prompt', sans-serif;
    font-size: 9.5px;
    font-weight: 700;
}

/* KPI tiles */
.sfp-kpi {
    position: absolute;
    width: 168px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    transform: translateZ(var(--z, 0));
}

.sfp-kpi span { display: block; font-size: 11.5px; color: #64748b; }
.sfp-kpi b { display: block; font-size: 26px; line-height: 1.2; font-weight: 700; color: #0f172a; }
.sfp-kpi b small { font-size: 12px; font-weight: 600; color: #94a3b8; margin-left: 3px; }
.sfp-kpi .ok { color: #16a34a; }

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

.is-active .sfp-caret { animation: sfp-blink 1s steps(1) infinite; }
.is-active .sfp-note { opacity: 0; animation: sfp-note 0.5s cubic-bezier(.2, 1.3, .4, 1) forwards; animation-delay: var(--d, 0s); }

.is-active .sfp-pop { opacity: 0; animation: sfp-pop 0.55s cubic-bezier(.2, 1.25, .4, 1) forwards 0.85s; }
.is-active .sfp-type { clip-path: inset(0 100% 0 0); animation: sfp-type 0.45s steps(10, end) forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-hide { animation: sfx-out 0.15s ease forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-list { opacity: 0; animation: sfp-list 0.9s ease forwards 1.3s; }
.is-active .sfp-radios span.on::before { animation: sfp-radio 0.3s ease both 2.7s; }

.is-active .sfp-scanf { animation: sfp-scanf 2.4s ease-in-out forwards 0.2s; }
.is-active .sfp-st em { animation: sfx-out 0.2s ease forwards; animation-delay: calc(var(--d) + 0.25s); }
.is-active .sfp-st b { animation: sfx-pop 0.35s cubic-bezier(.2, 1.5, .4, 1) forwards; animation-delay: calc(var(--d) + 0.3s); }
.is-active .sfp-in.ok { animation: sfp-ok 0.3s ease forwards; animation-delay: calc(var(--d) + 0.3s); }
.is-active .sfp-in.bad { animation: sfp-bad 0.3s ease forwards; animation-delay: calc(var(--d) + 0.3s); }
.is-active .sfp-rules { opacity: 0; animation: sfp-note 0.5s ease forwards 0.2s; }

.is-active .sfp-new td { animation: sfp-newrow 1.4s ease both 0.5s; }
.is-active .sfp-kpi { opacity: 0; animation: sfp-deal 0.6s cubic-bezier(.2, 1.2, .4, 1) forwards; animation-delay: var(--d, 0s); }

@keyframes sfp-blink { 50% { opacity: 0; } }

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

@keyframes sfp-pop {
    from { opacity: 0; transform: translateZ(var(--z, 0)) translate(-60px, 30px) scale(0.7); }
    to { opacity: 1; transform: translateZ(var(--z, 0)); }
}

@keyframes sfp-type { to { clip-path: inset(0 0 0 0); } }

@keyframes sfp-list {
    0% { opacity: 0; transform: translateY(-6px); }
    18%, 72% { opacity: 1; transform: none; }
    100% { opacity: 0; transform: none; }
}

@keyframes sfp-radio { from { border-width: 1.5px; border-color: #94a3b8; } }

@keyframes sfp-scanf {
    0% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(160px); }
    100% { opacity: 0; transform: translateY(160px); }
}

@keyframes sfp-ok { to { border-color: #22c55e; background: #f0fdf4; } }
@keyframes sfp-bad { to { border-color: #ef4444; background: #fef2f2; color: #b91c1c; } }

@keyframes sfp-newrow {
    0% { opacity: 0; background: #86efac; }
    25% { opacity: 1; background: #86efac; }
    100% { opacity: 1; background: #ecfdf5; }
}

@keyframes sfp-deal {
    from { opacity: 0; transform: translateZ(var(--z, 0)) translateY(24px); }
    to { opacity: 1; transform: translateZ(var(--z, 0)); }
}

@media (prefers-reduced-motion: reduce) {
    .sfp-scanf, .sfp-list, .sfp-caret { display: none; }
}
