/* Cart and checkout share a compact, light working surface. */

.order-flow {
    --line-cols: 64px minmax(0, 1fr) 112px 124px 116px 36px;
    max-width: 1360px;
    margin: 0 auto;
}

.order-flow-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin: 0 0 1rem;
}
.order-flow-intro {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.order-flow-head h1 {
    margin: 0;
    font-size: clamp(1.6rem, 2.6vw, 2.125rem);
    letter-spacing: -0.025em;
    line-height: 1.1;
}
.order-flow-sub {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.order-flow-sub strong {
    color: var(--text-main);
    font-weight: 600;
}

.order-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.125rem;
    align-items: start;
}

.order-progress {
    margin: 0 0 1.15rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-light);
}
.order-progress ol {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 620px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}
.order-progress li {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.order-progress li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 50%;
    left: calc(50% + 54px);
    width: calc(100% - 108px);
    height: 1px;
    background: var(--border);
}
.order-progress li span {
    display: inline-flex;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #eef2f7;
    color: #64748b;
    font-weight: 700;
}
.order-progress li strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.order-progress li.active {
    color: var(--text-main);
}
.order-progress li.active span {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* ---------- Line items ---------- */

.line-items {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.line-items-head {
    display: grid;
    grid-template-columns: var(--line-cols);
    gap: 1rem;
    align-items: center;
    padding: 0.72rem 1rem;
    background: #fbfcfe;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.line-items-head .num {
    text-align: right;
}

.line-item {
    display: grid;
    grid-template-columns: var(--line-cols);
    gap: 1rem;
    align-items: center;
    padding: 0.78rem 1rem;
    border-top: 1px solid var(--border-light);
}
.line-item:first-child {
    border-top: 0;
}
.line-item:hover {
    background: #fcfdff;
}

.line-item-thumb {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-surface);
    overflow: hidden;
}
.line-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.line-item-thumb .img-placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.line-item-body {
    min-width: 0;
}
.line-item-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--text-main);
    text-decoration: none;
}
.line-item-name:hover {
    color: var(--primary);
}
.line-item-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.35rem;
}
.line-item-sku {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
}
.line-item-min {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
}
.line-item-stock {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #15803d;
}
.line-item-stock::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 0.3rem;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 1px;
}
.line-item-stock.low {
    color: var(--warning);
}

.line-item-unit,
.line-item-total {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.line-item-unit {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: right;
}
.line-item-total {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: right;
}

.line-item-alert {
    grid-column: 2 / -1;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--danger);
}

/* Quantity stepper */
.stepper {
    display: inline-flex;
    align-items: center;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-surface);
    overflow: hidden;
}
.stepper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.stepper-btn {
    width: 34px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.stepper-btn:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}
.stepper-btn:focus-visible,
.line-item-remove:focus-visible,
.order-link:focus-visible,
.summary-cta:focus-visible {
    /* The pale primary tint was ~1.3:1 on white; #005fcc is the shared focus colour (>3:1). */
    outline: 3px solid var(--ft-focus-color, #005fcc);
    outline-offset: 2px;
}
.stepper-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.stepper-input {
    width: 40px;
    height: 36px;
    border: 0;
    border-inline: 1px solid var(--border-light);
    padding: 0;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
    background: transparent;
    appearance: textfield;
    -moz-appearance: textfield;
}
.stepper-input:focus {
    outline: none;
}
.stepper-input:focus-visible {
    background: var(--primary-light);
    color: var(--primary);
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.line-item-remove {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #f8fafc;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.line-item-remove:hover {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

.order-main-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
}
.order-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--ft-radius-md, 10px);
    background: var(--bg-surface);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.order-link:hover {
    border-color: var(--text-main);
}
.order-link.danger,
body:not(:has(.admin-shell)) a.order-link.danger {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}
.order-link.danger:hover,
body:not(:has(.admin-shell)) a.order-link.danger:hover {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---------- Summary rail ---------- */

.order-rail {
    position: sticky;
    top: 88px;
    display: grid;
    gap: 0.75rem;
}

.summary-panel {
    position: relative;
    padding: 1.4rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-main);
    background: var(--bg-surface);
    box-shadow: none;
    overflow: hidden;
}
.summary-panel > * {
    position: relative;
    z-index: 1;
}

/* The storefront layer paints every heading and link with a body-level
   :has() rule, which outranks a single class. The dark panel and the ink-dark
   product links therefore repeat that prefix instead of fighting it. */
body:not(:has(.admin-shell)) .summary-panel .summary-title {
    margin: 0 0 1.15rem;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-main);
}
body:not(:has(.admin-shell)) a.summary-cta {
    color: #fff;
}
body:not(:has(.admin-shell)) a.summary-cta:hover {
    color: #fff;
}
body:not(:has(.admin-shell)) a.line-item-name {
    color: var(--text-main);
}
body:not(:has(.admin-shell)) a.line-item-name:hover {
    color: var(--primary);
}
body:not(:has(.admin-shell)) a.order-link {
    color: var(--text-main);
}
body:not(:has(.admin-shell)) a.order-link:hover {
    color: var(--text-main);
}

.summary-items {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 1.1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--border-light);
    max-height: 232px;
    overflow-y: auto;
}
.summary-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.8125rem;
    line-height: 1.4;
}
.summary-item-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-muted);
}
.summary-item-qty {
    display: inline-block;
    min-width: 1.6em;
    margin-right: 0.3rem;
    font-weight: 700;
    color: var(--text-main);
}
.summary-item-value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text-main);
}

.summary-lines {
    display: grid;
    gap: 0.6rem;
    margin: 0;
}
.summary-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.875rem;
}
.summary-line dt {
    color: var(--text-muted);
}
.summary-line dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text-main);
}
.summary-line dd.is-free {
    color: #6ee7a8;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
}
.summary-line.discount dd {
    color: #15803d;
}


.summary-rule {
    height: 1px;
    margin: 1.1rem 0;
    background: var(--border-light);
}

.summary-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}
.summary-total span {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
}
.summary-total strong {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text-main);
}

.summary-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    height: 50px;
    margin-top: 1.15rem;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(180deg, #3b86ff 0%, #1f6bf0 100%);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(31, 107, 240, 0.24);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.summary-cta:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(31, 107, 240, 0.42);
}
.summary-cta:disabled {
    filter: grayscale(0.5);
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.summary-panel .currency-context-note {
    margin: 0.85rem 0 0;
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-muted);
}
.summary-panel .currency-context-note.error {
    color: #fca5a5;
}
.summary-status {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: -0.35rem 0 1.1rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-body);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.summary-status.error {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
}

.rail-notes {
    display: grid;
    gap: 0.55rem;
    margin: 1rem 0 0;
    padding: 0.9rem 0 0;
    list-style: none;
    border: 0;
    border-top: 1px solid var(--border-light);
    border-radius: 0;
    background: transparent;
}
.rail-notes li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.rail-notes svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--primary);
}

/* ---------- Checkout steps ----------
   The storefront redesign styles these at showroom scale (3rem padding, 32px
   radius). Checkout is a working surface, so it is compacted here; the
   selectors mirror that file's prefix so the later load order wins. */

.checkout-steps {
    display: grid;
    gap: 1rem;
}

body:not(:has(.admin-shell)) .order-flow .checkout-step {
    padding: 1.35rem 1.5rem;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: none;
}
body:not(:has(.admin-shell)) .order-flow .step-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1.1rem;
}
body:not(:has(.admin-shell)) .order-flow .step-number {
    width: 26px;
    height: 26px;
    min-width: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: none;
}
body:not(:has(.admin-shell)) .order-flow .step-header :is(h2, h3) {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
body:not(:has(.admin-shell)) .order-flow .address-card,
body:not(:has(.admin-shell)) .order-flow .payment-card {
    display: block;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    box-shadow: none;
}
body:not(:has(.admin-shell)) .order-flow .address-card.selected,
body:not(:has(.admin-shell)) .order-flow .payment-card.selected {
    box-shadow: 0 0 0 1px var(--primary) inset;
}
body:not(:has(.admin-shell)) .order-flow .address-card:focus-within,
body:not(:has(.admin-shell)) .order-flow .payment-card:focus-within {
    outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent);
    outline-offset: 2px;
}
body:not(:has(.admin-shell)) .order-flow .address-card.selected {
    border-color: var(--success);
    background: var(--success-bg);
    box-shadow: 0 0 0 1px var(--success) inset;
}
body:not(:has(.admin-shell)) .order-flow .address-card.selected .address-header,
body:not(:has(.admin-shell)) .order-flow .address-card.selected .check-icon {
    color: var(--success);
}

.address-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}
.address-grid.address-grid-single {
    grid-template-columns: minmax(360px, 2fr) minmax(220px, .8fr);
    align-items: stretch;
}
.checkout-postal-address {
    margin: 0;
    color: var(--text-main);
    font-size: .875rem;
    font-style: normal;
    line-height: 1.55;
}
.checkout-address-company,
.checkout-address-person {
    font-weight: 650;
}
body:not(:has(.admin-shell)) .order-flow .address-card-new-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
@media (max-width: 760px) {
    .address-grid.address-grid-single { grid-template-columns: 1fr; }
    body:not(:has(.admin-shell)) .order-flow .address-card-new-inline {
        justify-content: flex-start;
    }
}
.payment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}
.step-optional {
    margin-left: 0.4rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
body:not(:has(.admin-shell)) .order-flow .address-card-new {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--text-muted) 30%, var(--border));
    background: color-mix(in srgb, var(--bg-body) 72%, var(--bg-surface));
    color: var(--text-muted);
}
body:not(:has(.admin-shell)) .order-flow .address-card-new:hover,
body:not(:has(.admin-shell)) .order-flow .address-card-new:focus-within {
    border-color: var(--primary);
    color: var(--text-main);
}
.checkout-step .form-group {
    margin-bottom: 0.75rem;
}
.checkout-step .form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.payment-card.disabled {
    opacity: .6;
    cursor: not-allowed;
    background: var(--bg-body);
}
.payment-card.disabled input { cursor: not-allowed; }

/* Buyer order history is deliberately card-based rather than an admin table. */
.buyer-order-list { display: grid; gap: .75rem; }
.buyer-order-card {
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
}
.buyer-order-card-head { display:flex; justify-content:space-between; gap:1rem; align-items:start; }
.buyer-order-number { display:block; font-weight:700; color:var(--text-main); text-decoration:none; }
.buyer-order-number:hover { color:var(--primary); }
.buyer-order-card-head small { display:block; margin-top:.2rem; color:var(--text-muted); font-size:.75rem; }
.buyer-order-card-head strong { white-space:nowrap; font-variant-numeric:tabular-nums; }
.buyer-order-states { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.75rem; margin:1rem 0; }
.buyer-order-states div { min-width:0; }
.buyer-order-states dt { margin-bottom:.3rem; color:var(--text-muted); font-size:.6875rem; font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.buyer-order-states dd { margin:0; font-size:.8125rem; overflow:hidden; text-overflow:ellipsis; }
.invoice-overview { margin:0 0 1.5rem; }
.invoice-overview p { color:var(--wb-text-muted); font-size:.875rem; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
    .order-grid {
        grid-template-columns: minmax(0, 1fr) 312px;
    }
    .order-flow {
        --line-cols: 56px minmax(0, 1fr) 92px 116px 100px 32px;
    }
}

@media (max-width: 900px) {
    .order-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .order-rail {
        position: static;
    }
    .summary-panel {
        padding: 1.35rem;
    }
}

@media (max-width: 640px) {
    .address-grid.address-grid-single {
        grid-template-columns: minmax(0, 1fr);
    }
    body:not(:has(.admin-shell)) .order-flow .address-card-compact {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
    .compact-address-line {
        white-space: normal;
    }
    body:not(:has(.admin-shell)) .order-flow .address-card-new-inline {
        min-width: 0;
    }
}
@media (max-width: 640px) {
    .buyer-order-states { grid-template-columns:1fr 1fr; }
}

@media (max-width: 640px) {
    .order-progress {
        margin-bottom: 1rem;
        padding: 0.65rem 0;
    }
    .order-progress li {
        gap: 0.3rem;
        font-size: 0.6875rem;
    }
    .order-progress li:not(:last-child)::after {
        left: calc(50% + 32px);
        width: calc(100% - 64px);
    }
    .order-progress li strong {
        max-width: 88px;
        overflow: visible;
        line-height: 1.15;
        text-align: center;
        text-overflow: clip;
        white-space: normal;
    }
    .order-flow-head {
        display: block;
    }
    .order-flow-sub {
        margin-top: 0.65rem;
    }
    .line-items-head {
        display: none;
    }
    .line-item {
        grid-template-columns: 56px minmax(0, 1fr) auto;
        grid-template-areas:
            "thumb body remove"
            "qty qty total";
        gap: 0.5rem 0.75rem;
        padding: 1rem;
    }
    .line-item-thumb {
        grid-area: thumb;
        width: 56px;
        height: 56px;
    }
    .line-item-body {
        grid-area: body;
    }
    .line-item-remove {
        grid-area: remove;
        align-self: start;
    }
    .line-item-unit {
        display: none;
    }
    .line-item-qty {
        grid-area: qty;
        margin-top: 0.35rem;
    }
    .line-item-total {
        grid-area: total;
        align-self: center;
        margin-top: 0.35rem;
        font-size: 1rem;
    }
    .line-item-alert {
        grid-column: 1 / -1;
    }
    .order-main-foot {
        justify-content: space-between;
    }
}
