/* ==========================================================================
   Shared storefront components. One class family per job; pages compose
   these and only add layout in their own sp/pages/*.css file.
   PHP side: app/Cells/* and app/Views/components/*.
   ========================================================================== */

/* --- Search field: header, catalog, section list, car picker ------------- */
.sp-search {
    position: relative; display: flex; align-items: center; gap: 6px; min-width: 0;
    height: 56px; padding: 0 12px;
    background: var(--sp-paper); color: var(--sp-ink);
    border: 1px solid var(--sp-line-strong); border-radius: var(--sp-r-pill);
}
.sp-search:focus-within { outline: 2px solid var(--sp-focus); outline-offset: 2px; }
.sp-search > svg { flex: none; width: 22px; height: 22px; margin: 0 5px; color: var(--sp-ink-soft); }
.sp-search input {
    flex: 1; min-width: 0; height: 100%; margin: 0; padding: 0;
    border: 0; outline: 0; background: transparent; box-shadow: none;
    font: 400 16px/1.4 var(--sp-font); color: inherit;
}
.sp-search input::placeholder { color: var(--sp-ink-soft); opacity: 1; }
body.sp .sp-search input:focus-visible { outline: none; }
.sp-search input::-webkit-search-cancel-button { cursor: pointer; }
@media (max-width: 700px) { .sp-search { padding: 0 10px; } }

/* --- Form fields: login, register, contact, account, checkout ------------
   Same field as the plate in the car dialog: grey fill, hairline, inset ring
   on focus. The body.sp .form-group / .form-check rules carry the look to
   forms whose markup still uses the older classes. */
.sp-field { display: grid; gap: 7px; min-width: 0; margin: 0 0 18px; }
.sp-field > label, body.sp .form-group label {
    display: block; margin: 0; font-size: var(--sp-fs-sm); font-weight: 600; line-height: 1.3; color: var(--sp-ink);
}
.sp-field-opt { font-weight: 400; color: var(--sp-ink-soft); }
.sp-field-hint, body.sp .form-hint { margin: 0; font-size: var(--sp-fs-sm); line-height: 1.4; color: var(--sp-ink-soft); }
.sp-field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 459px) { .sp-field-row { grid-template-columns: 1fr; } }

.sp-input,
body.sp .form-group :is(input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea) {
    display: block; width: 100%; min-width: 0; min-height: 52px; margin: 0; padding: 0 16px;
    border: 0; border-radius: var(--sp-r-sm);
    background: var(--sp-surface); color: var(--sp-ink);
    box-shadow: inset 0 0 0 1px var(--sp-line-strong);
    font: 400 16px/1.4 var(--sp-font);
    transition: box-shadow var(--sp-fast);
}
.sp-input::placeholder, body.sp .form-group :is(input, textarea)::placeholder { color: var(--sp-ink-faint); opacity: 1; }
body.sp .sp-input:focus,
body.sp .form-group :is(input, select, textarea):focus { outline: none; box-shadow: inset 0 0 0 2px var(--sp-t3); }
body.sp .sp-input:user-invalid,
body.sp .form-group :is(input, select, textarea):user-invalid { box-shadow: inset 0 0 0 2px var(--sp-bad); }
.sp-input:disabled, body.sp .form-group :is(input, select, textarea):disabled {
    background: var(--sp-surface-2); color: var(--sp-ink-soft); box-shadow: none; cursor: not-allowed;
}
textarea.sp-input, body.sp .form-group textarea { min-height: 148px; padding: 14px 16px; line-height: 1.5; resize: vertical; }
/* Native arrow swapped for a chevron drawn in tokens, so every browser shows the same one */
select.sp-input, body.sp .form-group select {
    appearance: none; padding-right: 44px; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--sp-ink-soft) 50%), linear-gradient(135deg, var(--sp-ink-soft) 50%, transparent 50%);
    background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
    background-size: 6px 6px; background-repeat: no-repeat;
}
/* Compact field beside a small button, e.g. renaming a list or a car */
.sp-input--sm { min-height: 36px; padding: 0 12px; font-size: var(--sp-fs-ui); }
body.sp .form-check input[type="checkbox"] { accent-color: var(--sp-action); }

/* --- Registration plate --------------------------------------------------
   .sp-plate is the big input on the home page and in the car dialog.
   .sp-plate-badge is the small read-only plate in the vehicle bar. */
.sp-plate {
    display: flex; height: 68px; overflow: hidden;
    background: var(--sp-paper); border-radius: var(--sp-r-card);
}
.sp-plate-eu {
    flex: none; width: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: var(--sp-plate-blue); color: var(--sp-paper); font-weight: 600; font-size: 15px;
}
.sp-plate-eu svg { width: 18px; height: 18px; }
.sp-plate input {
    flex: 1; min-width: 0; padding: 0 12px; border: 0; outline: 0; background: transparent;
    font: 600 36px/1 var(--sp-font-plate); letter-spacing: .1em; text-transform: uppercase; text-align: center;
    color: var(--sp-plate-ink);
}
.sp-plate input::placeholder { color: var(--sp-ink-faint); opacity: .6; letter-spacing: .1em; }
.sp-plate--ring { box-shadow: 0 0 0 2px var(--sp-t3), 0 0 0 4px rgba(46, 106, 98, .22); }

/* Stands in for the plate when a car was chosen without one */
.sp-car-glyph {
    display: inline-grid; place-items: center; flex: none; width: 40px; height: 30px;
    border-radius: 6px; background: var(--sp-t1); color: var(--sp-t4);
}
.sp-car-glyph svg { width: 20px; height: 20px; }

.sp-plate-badge {
    display: inline-flex; align-items: center; flex: none; gap: 6px; overflow: hidden;
    padding: 0 7px 0 0; border: 1px solid var(--sp-line-strong); border-radius: 4px;
    background: var(--sp-paper); color: var(--sp-ink);
    font: 600 18px/28px var(--sp-font-plate); letter-spacing: .045em; white-space: nowrap;
}
.sp-plate-badge > span { align-self: stretch; display: grid; place-items: center; width: 16px; background: var(--sp-plate-blue); color: var(--sp-paper); font: 9px var(--sp-font); letter-spacing: 0; }
@media (max-width: 700px) {
    .sp-plate-badge { font-size: 15px; line-height: 25px; gap: 4px; padding-right: 5px; }
    .sp-plate-badge > span { width: 13px; font-size: 8px; }
}

/* --- Pills: filter chips, quick model links, toggles --------------------- */
.sp-pill {
    display: inline-flex; align-items: center; gap: 7px; flex: none;
    min-height: 36px; padding: 0 13px;
    border: 0; border-radius: var(--sp-r-pill);
    background: var(--sp-surface); color: var(--sp-ink);
    font: 500 var(--sp-fs-ui)/1.2 var(--sp-font); white-space: nowrap; cursor: pointer;
    transition: background var(--sp-fast);
}
body.sp .sp-pill:hover { background: var(--sp-t1); color: var(--sp-ink); }
.sp-pill svg { width: 18px; height: 18px; flex: none; }
.sp-pill--action { background: var(--sp-t1); color: var(--sp-action); font-weight: 600; }
body.sp .sp-pill--action:hover { background: var(--sp-t2); color: var(--sp-action); }
.sp-pill[aria-pressed="true"], .sp-pill.is-active { background: var(--sp-paper); box-shadow: inset 0 0 0 1px var(--sp-t3); }
.sp-pill small { color: var(--sp-ink-soft); font-size: var(--sp-fs-xs); }

/* Segmented control: diagram / list switch and similar two-way choices */
.sp-segment { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--sp-r-pill); background: var(--sp-surface); box-shadow: inset 0 0 0 1px var(--sp-line); }
.sp-segment > a, .sp-segment > button {
    display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
    border: 0; border-radius: var(--sp-r-pill); background: none; color: var(--sp-ink-soft);
    font: 500 var(--sp-fs-ui) var(--sp-font); cursor: pointer;
}
.sp-segment > [aria-current="true"], .sp-segment > [aria-pressed="true"] { background: var(--sp-paper); color: var(--sp-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.sp-segment small { font-size: var(--sp-fs-xs); color: var(--sp-ink-faint); }

/* --- Status: stock and fit ------------------------------------------------
   Rendered by App\Cells\StockStatusCell and App\Cells\FitStatusCell. */
.sp-stock {
    display: inline-flex; align-items: flex-start; gap: 6px;
    font-size: var(--sp-fs-sm); font-weight: 500; line-height: 1.3; white-space: nowrap;
}
.sp-stock::before { content: ""; width: 7px; height: 7px; margin-top: calc((1.3em - 7px) / 2); border-radius: 50%; background: currentColor; flex: none; }
.sp-stock:empty { display: none; }
.sp-stock--in { color: var(--sp-ok); }
.sp-stock--order { color: var(--sp-warn); }
.sp-stock--out, .sp-stock--expired, .sp-stock--unknown, .sp-stock--digital { color: var(--sp-ink-soft); }
/* Wrapped text stays next to its dot. */
.sp-stock--wrap { white-space: normal; text-align: left; }
/* In right-aligned price columns the text right-aligns too; the dot flows with the first line. */
:is(.sp-prow-buy, .sp-section-product-buy, .pp-quality-price) > .sp-stock--wrap { display: block; text-align: right; }
:is(.sp-prow-buy, .sp-section-product-buy, .pp-quality-price) > .sp-stock--wrap::before { display: inline-block; margin: 0 6px 0 0; vertical-align: 0.1em; }
/* The stock reads as part of the price: tight line, small gap. */
:is(.sp-prow-buy, .sp-section-product-buy, .pp-quality-price) .sp-price { line-height: 1.2; }

.sp-fit { display: inline-flex; align-items: flex-start; gap: 6px; font-size: var(--sp-fs-sm); font-weight: 600; line-height: 1.35; }
.sp-fit svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.sp-fit--yes { color: var(--sp-ok); }
.sp-fit--no { color: var(--sp-bad); }
.sp-fit--check { color: var(--sp-warn); }

/* --- Price ---------------------------------------------------------------- */
.sp-price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-deal { padding: 2px 8px; border-radius: var(--sp-r-pill); background: var(--sp-bad-bg); color: var(--sp-bad); font-weight: 600; font-size: var(--sp-fs-xs); }
.sp-section-product-hidden {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 3px;
    background: #fde68a; color: #78350f; font-size: var(--sp-fs-xs); font-weight: 600; line-height: 1.3;
}
.sp-sale { display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.sp-sale .sp-price-was { margin-left: 0; font-size: var(--sp-fs-xs); }
.sp-price-unit { font-weight: 400; color: var(--sp-ink-soft); font-size: .8em; margin-left: 2px; }
.sp-price-was { font-weight: 400; color: var(--sp-ink-soft); text-decoration: line-through; margin-left: 6px; font-size: .85em; }
.sp-price--sale { color: var(--sp-bad); }

/* --- Section heading with a quiet "all" link on the right ----------------- */
.sp-section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.sp-section-head > a { flex: none; font-size: var(--sp-fs-ui); color: var(--sp-ink-soft); border-bottom: 1px solid var(--sp-t2); }
body.sp .sp-section-head > a:hover { color: var(--sp-ink); }
@media (max-width: 899px) { .sp-section-head > a { display: none; } }

/* --- Product teaser card (home rows and "Se även" only; never in lists) --- */
.sp-teasers {
    display: grid; grid-auto-flow: column; grid-auto-columns: 46%; gap: var(--sp-gap);
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin: 0 calc(var(--sp-gutter) * -1); padding: 0 var(--sp-gutter); scroll-padding: 0 var(--sp-gutter);
}
.sp-teasers::-webkit-scrollbar { display: none; }
@media (min-width: 900px) {
    .sp-teasers { grid-auto-flow: row; grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: visible; margin: 0; padding: 0; }
    .sp-teasers--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.sp-teaser {
    scroll-snap-align: start; display: flex; flex-direction: column;
    background: var(--sp-paper); border-radius: 22px; padding: 10px 10px 16px;
    transition: box-shadow var(--sp-fast);
}
.sp-teaser:hover { box-shadow: inset 0 0 0 1px var(--sp-line); }
.sp-teaser-img { aspect-ratio: 1; border-radius: var(--sp-r-tile); background: var(--sp-surface); display: grid; place-items: center; padding: 14px; overflow: hidden; }
.sp-teaser-img img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; transition: transform var(--sp-slow) var(--sp-ease); }
.sp-teaser:hover .sp-teaser-img img { transform: scale(1.04); }
.sp-teaser-img svg { width: 44%; height: 44%; color: var(--sp-ink-faint); }
.sp-teaser-meta { margin: 12px 6px 0; font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); }
.sp-teaser h3 { margin: 4px 6px 0; font-weight: 500; font-size: var(--sp-fs-ui); line-height: 1.3; }
.sp-teaser .sp-teaser-fits { margin: 2px 6px 0; font-size: 13px; color: var(--sp-ink-soft); line-height: 1.3; }
.sp-teaser .sp-price { margin: auto 6px 0; padding-top: 6px; }
.sp-teaser .sp-fit { margin: 4px 6px 0; }
.sp-teasers--on-surface .sp-teaser { background: var(--sp-surface); }
@media (hover: none) { .sp-teaser:hover .sp-teaser-img img { transform: none; } }

/* An image attached to this exact product/variant, never a category or part illustration. */
.sp-product-thumb { display: grid; place-items: center; flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: var(--sp-r-sm); background: var(--sp-surface); }
.sp-product-thumb[hidden] { display: none; }
.sp-product-thumb img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }

/* --- Quality group: a closed row per quality that opens to its articles. ---
   Product page quality choices and section lists. Summary: partials/_quality_summary.php. */
.sp-qgroup { min-width: 0; border: 1px solid var(--sp-line-strong); border-radius: var(--sp-r-sm); background: var(--sp-paper); overflow: hidden; }
.sp-qgroup-summary { display: flex; align-items: center; gap: 12px; min-height: var(--sp-hit); padding: 6px 12px; color: var(--sp-ink); cursor: pointer; list-style: none; }
.sp-qgroup-summary::-webkit-details-marker { display: none; }
body.sp .sp-qgroup-summary:hover { background: var(--sp-surface); color: var(--sp-ink); }
.sp-qgroup-summary:focus-visible { outline: 2px solid var(--sp-action); outline-offset: -3px; }
.sp-qgroup-name { min-width: 0; flex: 1; font-size: var(--sp-fs-ui); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.sp-qgroup-name small { margin-left: 8px; font-size: var(--sp-fs-xs); font-weight: 500; color: var(--sp-action); }
.sp-qgroup-sub { display: block; margin-top: 2px; font-size: var(--sp-fs-xs); font-weight: 400; color: var(--sp-ink-soft); }
.sp-qgroup-sub .sp-section-line { display: inline; }
.sp-qgroup-sub .sp-section-line + .sp-section-line::before { content: " · "; content: " · " / ""; }
.sp-qgroup-meta { flex: none; font-size: var(--sp-fs-ui); white-space: nowrap; }
.sp-qgroup-chevron { width: 16px; height: 16px; flex: none; color: var(--sp-ink-soft); transition: transform var(--sp-open) var(--sp-ease-open); }
.sp-qgroup[open]:not(.is-closing) > .sp-qgroup-summary .sp-qgroup-chevron { transform: rotate(180deg); }
.sp-qgroup-body { border-top: 1px solid var(--sp-line); }
/* Height animation from disclosure.js, as .sp-disclosure-body. */
.sp-qgroup > .is-animating { overflow: hidden; transition: height var(--sp-open) var(--sp-ease-open); }
@media (prefers-reduced-motion: reduce) { .sp-qgroup-chevron { transition: none; } }
/* Shared quality card in section lists and product choices (side marks off).
   Expandable: .sp-qrow > button.sp-qrow-head[data-sp-disclosure] + .sp-disclosure-body > .sp-qrow-body
   Static single-article section heading: .sp-qrow > div.sp-qrow-head + .sp-qrow-body
   Product choices always expand/collapse. Section qualities start open; product choices open only
   the selected quality. disclosure.js animates height. Article rows are split by a line. */
.sp-qrow { min-width: 0; overflow: hidden; border: 1px solid var(--sp-line-strong); border-radius: var(--sp-r-sm); background: var(--sp-paper); }
.sp-qrow-head {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--sp-hit); padding: 8px 14px 8px 16px;
    border: 0; background: none; color: var(--sp-ink); font: inherit; text-align: left; cursor: pointer;
}
.sp-qrow-head:not(button) { cursor: default; }
body.sp button.sp-qrow-head:hover { background: var(--sp-surface); }
.sp-qrow-head:focus-visible { outline: 3px solid var(--sp-focus); outline-offset: -3px; }
.sp-qrow-name { flex: 1; min-width: 0; font-size: var(--sp-fs-body); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.sp-qrow-name small { margin-left: 8px; font-size: var(--sp-fs-xs); font-weight: 500; color: var(--sp-action); }
.sp-qrow-name .sp-qgroup-sub { font-weight: 400; }
.sp-qrow-head > svg { width: 18px; height: 18px; flex: none; }
.sp-qrow-head[aria-expanded="true"] .sp-qrow-plus, .sp-qrow-head[aria-expanded="false"] .sp-qrow-minus { display: none; }
.sp-qrow-body { border-top: 1px solid var(--sp-line); }
.sp-qrow .sp-qrow-body > * { border-radius: 0; }
.sp-qrow-body > * + * { border-top: 1px solid var(--sp-line); }
/* Rows inside take the head's hover; a chosen or in-cart row keeps its own mark. */
body.sp .sp-qrow-body > a:not(.is-in-cart):not([aria-current]):hover { background: var(--sp-surface); box-shadow: none; }

/* --- Product row. App\Cells\ProductRowCell. --- */
.sp-prows { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sp-prow {
    display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; align-items: center; gap: 10px 16px;
    min-height: 60px; padding: 10px 16px; border-radius: var(--sp-r-sm);
    background: var(--sp-surface); color: var(--sp-ink); text-decoration: none; transition: box-shadow var(--sp-fast);
}
body.sp .sp-prow:hover { box-shadow: inset 0 0 0 1px var(--sp-line-strong); color: var(--sp-ink); }
.sp-prow-id { min-width: 0; }
/* Same look as section lines and the product page's quality choices. */
.sp-prow-name { display: block; font-size: var(--sp-fs-body); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.sp-prow-meta { display: block; margin-top: 3px; font-size: var(--sp-fs-xs); line-height: 1.4; color: var(--sp-ink-soft); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sp-prow-buy { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 240px; text-align: right; }
.sp-prow-buy .sp-price { font-size: var(--sp-fs-lg); }
.sp-prow-buy .product-hedin-admin-inline { font-size: var(--sp-fs-xs); }
.sp-prow-arrow { grid-column: 3; width: 18px; height: 18px; color: var(--sp-action); }
.sp-prow.is-expired .sp-prow-name { color: var(--sp-ink-soft); }
.sp-prow-fit { display: block; margin-top: 6px; }
.sp-prow-fit .sp-fit { font-size: var(--sp-fs-xs); }
.sp-prow:has(> .sp-product-thumb:not([hidden])) { grid-template-columns: 40px minmax(0, 1fr) auto 18px; }
.sp-prow:has(> .sp-product-thumb:not([hidden])) .sp-prow-arrow { grid-column: 4; }

@media (max-width: 700px) {
    .sp-prow { grid-template-columns: minmax(0, 1fr) auto; min-height: 0; padding: 12px; gap: 10px; }
    .sp-prow-arrow { display: none; }
    .sp-prow-buy { max-width: 27vw; }
    .sp-prow:has(> .sp-product-thumb:not([hidden])) { grid-template-columns: 32px minmax(0, 1fr) auto; }
    /* Mobile rows read from the top: thumbnail and price line up with the name. */
    .sp-prow { align-items: start; }
    .sp-product-thumb { width: 32px; height: 32px; }
}

/* --- Disclosure rows: catalog groups, section part rows, product facts ----
   Markup: .sp-disclosure > button.sp-disclosure-head[aria-expanded] + .sp-disclosure-body
   Height animation is handled by assets/js/sp/disclosure.js. */
.sp-disclosure { background: var(--sp-surface); border-radius: var(--sp-r-ctl); }
.sp-disclosure + .sp-disclosure { margin-top: 6px; }
.sp-disclosure-head {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 16px;
    border: 0; background: none; text-align: left; color: inherit; cursor: pointer; font: inherit;
}
.sp-disclosure-head .sp-chev { margin-left: auto; width: 18px; height: 18px; flex: none; color: var(--sp-ink-soft); transition: transform var(--sp-open) var(--sp-ease-open); }
.sp-disclosure-head[aria-expanded="true"] .sp-chev { transform: rotate(180deg); }
.sp-disclosure-body { overflow: hidden; }
.sp-disclosure-body[hidden] { display: none; }
.sp-disclosure-body.is-animating { transition: height var(--sp-open) var(--sp-ease-open); }

/* A clickable list row with a trailing chevron */
.sp-row {
    display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 10px 12px;
    background: var(--sp-paper); border-radius: var(--sp-r-sm);
    transition: box-shadow var(--sp-fast);
}
.sp-row:hover { box-shadow: inset 0 0 0 1px var(--sp-line-strong); }
.sp-row > svg:last-child { width: 16px; height: 16px; flex: none; color: var(--sp-ink-soft); margin-left: auto; }

/* Position number on diagrams and in part lists */
.sp-callout {
    display: inline-grid; place-items: center; flex: none;
    min-width: 36px; height: 36px; padding: 0 6px; border-radius: var(--sp-r-sm);
    background: var(--sp-surface-2); font-weight: 600; font-size: var(--sp-fs-ui); font-variant-numeric: tabular-nums;
}

/* --- Dialog --------------------------------------------------------------- */
.sp-dialog {
    width: min(570px, calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 28px;
    border: 0; border-radius: 22px; background: var(--sp-paper); color: var(--sp-ink);
    box-shadow: var(--sp-shadow-pop); overflow: auto;
}
.sp-dialog::backdrop { background: var(--sp-scrim); backdrop-filter: blur(3px); }
/* Every dialog rises in from just below and settles fast; it drops away quicker than it came.
   overlay/display keep a closing dialog in the top layer until its fade ends. It has lost [open]
   and :modal by then, so its place and layout must not depend on either. */
.sp-dialog { position: fixed; inset: 0; }
.sp-dialog, .sp-dialog::backdrop {
    opacity: 0;
    transition-property: opacity, transform, overlay, display;
    transition-duration: 160ms;
    transition-timing-function: cubic-bezier(.4, 0, 1, 1);
    transition-behavior: allow-discrete;
}
.sp-dialog { transform: translateY(8px) scale(.985); }
.sp-dialog[open], .sp-dialog[open]::backdrop {
    opacity: 1;
    transition-duration: 200ms, 460ms, 0s, 0s;
    transition-timing-function: ease-out, var(--sp-ease);
}
.sp-dialog[open] { transform: none; }
@starting-style {
    .sp-dialog[open], .sp-dialog[open]::backdrop { opacity: 0; }
    .sp-dialog[open] { transform: translateY(18px) scale(.97); }
}
.sp-dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.sp-dialog-head h2 { flex: 1; font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -.035em; }
.sp-dialog-x {
    display: grid; place-items: center; flex: none; width: 40px; height: 40px;
    border: 0; border-radius: 50%; background: var(--sp-surface); color: var(--sp-ink); cursor: pointer;
}
.sp-dialog-x svg { width: 20px; height: 20px; }
body.sp:has(.sp-dialog[open]) { overflow: hidden; }
@media (max-width: 700px) {
    .sp-dialog { padding: 20px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); border-radius: 18px; }
    .sp-dialog-head h2 { font-size: 23px; }
}

/* --- Filter button and filter dialog: catalog and section page ----------- */
.sp-filter-btn {
    display: inline-flex; align-items: center; gap: 8px; flex: none;
    min-height: 52px; padding: 0 16px; border: 0; border-radius: var(--sp-r-ctl);
    background: var(--sp-t1); color: var(--sp-ink); font: 600 var(--sp-fs-body) var(--sp-font); cursor: pointer;
    transition: background var(--sp-fast);
}
.sp-filter-btn:hover { background: var(--sp-t2); }
.sp-filter-count {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: var(--sp-r-pill); background: var(--sp-paper); font-size: var(--sp-fs-xs); font-variant-numeric: tabular-nums;
}
.sp-filter-dialog { width: min(480px, calc(100% - 32px)); }
.sp-check-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 0; border-bottom: 1px solid var(--sp-line); cursor: pointer;
}
.sp-check-row > span { display: grid; gap: 4px; }
.sp-check-row strong { font-weight: 600; }
.sp-check-row small { font-size: var(--sp-fs-sm); color: var(--sp-ink-soft); }
.sp-check-row input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--sp-action); cursor: pointer; }
.sp-filter-done { margin-top: 24px; }
/* Reopened after the filters reload: no entrance motion */
.sp-dialog.is-instant, .sp-dialog.is-instant::backdrop { transition: none; }
@media (max-width: 700px) {
    .sp-filter-btn { min-height: 48px; padding: 0 12px; font-size: var(--sp-fs-ui); }
}

/* --- Empty and notice states --------------------------------------------- */
.sp-empty { padding: 28px 20px; border-radius: var(--sp-r-ctl); background: var(--sp-surface); color: var(--sp-ink-soft); text-align: center; }
.sp-notice { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--sp-r-ctl); background: var(--sp-surface); font-size: var(--sp-fs-ui); }
.sp-notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--sp-ink-soft); }
.sp-notice--warn { background: var(--sp-warn-bg); }
.sp-notice--warn svg { color: var(--sp-warn); }

/* --- Spinner -------------------------------------------------------------- */
.sp-loading-icon { display: inline-flex; align-items: center; }
.sp-spinner { display: inline-block; flex: none; width: 22px; height: 22px; vertical-align: middle; overflow: visible; }
.sp-btn .sp-spinner { width: 22px; height: 22px; }
.sp-spinner--lg g { stroke-width: 240; }
.sp-spinner--lg { width: 44px; height: 44px; }
.sp-spinner-track { opacity: .35; }
.sp-spinner-sweep { animation: sp-logo-sweep 1.3s linear infinite; }
@keyframes sp-logo-sweep { to { transform: translateX(7900px); } }
@media (prefers-reduced-motion: reduce) {
    .sp-spinner-sweep { animation: none; }
    .sp-spinner-head { display: none; }
    .sp-spinner-track { opacity: 1; }
}

/* --- Side of the car (LH/RH): top view, nose up, the part's half dark ---- */
.sp-side-car { flex: none; overflow: visible; }
.sp-side-car-body { fill: var(--sp-line-strong); }
.sp-side-car .is-on .sp-side-car-body { fill: var(--sp-header); }
.sp-side-car-cabin { fill: none; stroke: var(--sp-paper); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
/* Manual side marks: the slot an admin save swaps; it takes no box of its own. */
.sp-side-mark-slot { display: contents; }

/* --- Quantity stepper: minus, number, plus. Cart lines. ------------------ */
.sp-qty {
    display: inline-flex; align-items: center; flex: none; height: var(--sp-hit); overflow: hidden;
    border-radius: var(--sp-r-ctl); box-shadow: inset 0 0 0 1px var(--sp-line-strong); background: var(--sp-paper);
}
.sp-qty button {
    display: grid; place-items: center; width: var(--sp-hit); height: 100%; padding: 0;
    border: 0; background: none; color: var(--sp-ink); cursor: pointer;
}
.sp-qty button svg { width: 16px; height: 16px; }
.sp-qty button:disabled { color: var(--sp-ink-faint); cursor: not-allowed; }
.sp-qty input {
    width: 32px; height: 100%; padding: 0; border: 0; background: transparent; color: var(--sp-ink); text-align: center;
    font: 600 var(--sp-fs-body) var(--sp-font); font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield;
}
.sp-qty input::-webkit-inner-spin-button, .sp-qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sp-qty.htmx-request, .sp-qty:has(.htmx-request) { opacity: .55; }

/* --- Full-screen zoom viewer: section diagram and product gallery ----------
   Markup: app/Views/partials/_zoom_viewer.php · JS: assets/js/sp/zoom-viewer.js */
.sp-viewer { position: fixed; inset: 0; z-index: 70; overflow: hidden; color: var(--sp-ink); }
.sp-viewer[hidden] { display: none; }
body.sp-viewer-open { overflow: hidden; }
.sp-viewer-backdrop { position: absolute; inset: 0; background: var(--sp-diagram-deep); pointer-events: none; }
.sp-viewer-viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; overscroll-behavior: none; }
.sp-viewer-viewport.can-pan { cursor: grab; }
.sp-viewer-viewport.is-dragging { cursor: grabbing; }
.sp-viewer .sp-viewer-content { position: absolute; left: 50%; top: 50%; width: 80vw; cursor: zoom-in; will-change: transform; }
.sp-viewer-viewport.at-max .sp-viewer-content { cursor: zoom-out; }
.sp-viewer-viewport.is-dragging .sp-viewer-content { cursor: grabbing; }
.sp-viewer-content > img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.sp-viewer-back {
    position: absolute; top: max(20px, env(safe-area-inset-top)); left: 20px; z-index: 10;
    display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px;
    border: 0; border-radius: var(--sp-r-pill); background: var(--sp-paper); color: var(--sp-ink);
    font: 600 var(--sp-fs-body) var(--sp-font); cursor: pointer;
}
.sp-viewer-back svg { width: 20px; height: 20px; }
.sp-viewer-tools {
    position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 10; transform: translateX(-50%);
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    border-radius: var(--sp-r-pill); background: var(--sp-paper); white-space: nowrap;
}
.sp-viewer-tools button {
    display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: var(--sp-r-pill); background: none; color: var(--sp-ink); cursor: pointer;
}
.sp-viewer-tools button:hover:not(:disabled) { background: var(--sp-t1); }
.sp-viewer-tools button:disabled { opacity: .35; cursor: default; }
.sp-viewer-tools button svg { width: 20px; height: 20px; }
.sp-viewer-tools [data-sp-zoom="reset"] { padding: 0 12px; font: 600 var(--sp-fs-sm) var(--sp-font); }
.sp-viewer-tools output { min-width: 48px; text-align: center; font-size: var(--sp-fs-sm); font-variant-numeric: tabular-nums; }
.sp-viewer-divider { width: 1px; height: 24px; background: var(--sp-line); }
/* Stepping through several images: arrows at the sides, a counter top right. */
.sp-viewer-count {
    position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px; z-index: 10;
    display: grid; place-items: center; min-width: 64px; min-height: 48px; padding: 0 16px;
    border-radius: var(--sp-r-pill); background: var(--sp-paper);
    font: 600 var(--sp-fs-sm) var(--sp-font); font-variant-numeric: tabular-nums;
}
.sp-viewer-step {
    position: absolute; top: 50%; z-index: 10; transform: translateY(-50%);
    display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
    border: 0; border-radius: 50%; background: var(--sp-paper); color: var(--sp-ink); cursor: pointer;
}
.sp-viewer-step:hover { background: var(--sp-t1); }
.sp-viewer-step svg { width: 22px; height: 22px; }
.sp-viewer-step--prev { left: 20px; }
.sp-viewer-step--next { right: 20px; }
/* Light: the product photo fills the screen on white, as shot, and the controls sit
   on it as grey pills without outlines. */
.sp-viewer--light .sp-viewer-backdrop, .sp-viewer--light .sp-viewer-content { background: var(--sp-paper); }
.sp-viewer--light .sp-viewer-content > img { mix-blend-mode: multiply; }
.sp-viewer--light .sp-viewer-back, .sp-viewer--light .sp-viewer-tools,
.sp-viewer--light .sp-viewer-count, .sp-viewer--light .sp-viewer-step { background: var(--sp-surface); }
.sp-viewer--light .sp-viewer-step:hover { background: var(--sp-t1); }
@media (max-width: 700px) {
    .sp-viewer-back { left: 12px; }
    .sp-viewer-count { right: 12px; }
    .sp-viewer-step--prev { left: 8px; }
    .sp-viewer-step--next { right: 8px; }
}
@media (max-width: 359px) {
    .sp-viewer-tools { gap: 2px; padding: 5px; }
    .sp-viewer-tools [data-sp-zoom="reset"] { padding: 0 8px; }
}
.sp-line-choices { margin-top: 2px; font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); line-height: 1.35; }

/* The car above its lines in cart, checkout and order lists (partials/_line_car_head) */
ul > li.sp-line-car {
    display: flex; justify-content: flex-start; align-items: center; gap: 10px; min-width: 0;
    padding: 18px 0 6px; border: 0; background: none;
    font-size: var(--sp-fs-ui); font-weight: 600; line-height: 1.3; color: var(--sp-ink);
}
ul > li.sp-line-car--none { padding-top: 22px; font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); }
.sp-line-car-name { min-width: 0; }
.sp-plate-badge--sm { font-size: 14px; line-height: 22px; gap: 5px; padding-right: 6px; }
.sp-plate-badge--sm > span { width: 13px; font-size: 8px; }
.sp-car-glyph--sm { width: 30px; height: 22px; }
.sp-car-glyph--sm svg { width: 16px; height: 16px; }
