.mfs-ar15-builder {
    --mfs-ar15-accent: #b22222;
    --mfs-ar15-bg: #0e0e0e;
    --mfs-ar15-card: #ffffff;
    --mfs-ar15-border: #e2e2e2;
    --mfs-ar15-muted: #6b7280;
    --mfs-ar15-row-hover: #f8f8f8;
    --mfs-ar15-row-selected: #fff5f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1f2937;
    max-width: 1280px;
    margin: 0 auto;
    position: relative;
}

.mfs-ar15__title { font-size: 1.8rem; margin: 0 0 0.5rem; }
.mfs-ar15__intro { color: var(--mfs-ar15-muted); margin-bottom: 1.5rem; }

.mfs-ar15__stepnav {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--mfs-ar15-border);
}

.mfs-ar15__stepnav li {
    padding: 0.75rem 1.25rem;
    background: #f5f5f5;
    color: var(--mfs-ar15-muted);
    font-size: 0.95rem;
    font-weight: 600;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    margin-bottom: -1px;
}

.mfs-ar15__stepnav li.is-active {
    background: var(--mfs-ar15-card);
    border: 1px solid var(--mfs-ar15-border);
    border-bottom-color: var(--mfs-ar15-card);
    color: var(--mfs-ar15-bg);
}

.mfs-ar15__step { padding: 1.25rem 0; }
.mfs-ar15__step:not(.is-active) { display: none; }

.mfs-ar15__intake {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    max-width: 800px;
}

.mfs-ar15__field { display: flex; flex-direction: column; gap: 0.35rem; }
.mfs-ar15__field label { font-weight: 600; font-size: 0.92rem; }
.mfs-ar15__field input, .mfs-ar15__field select, .mfs-ar15__field textarea {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 4px;
    font: inherit;
}
.mfs-ar15__req { color: var(--mfs-ar15-accent); margin-left: 2px; }

.mfs-ar15__actions {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Buttons */
.mfs-ar15__btn {
    padding: 0.55rem 1rem;
    border: 1px solid var(--mfs-ar15-border);
    background: #fff;
    border-radius: 4px;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    color: #1f2937;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.mfs-ar15__btn:hover { border-color: #999; }
.mfs-ar15__btn--primary { background: var(--mfs-ar15-accent); border-color: var(--mfs-ar15-accent); color: #fff; }
.mfs-ar15__btn--primary:hover { background: #8a1717; border-color: #8a1717; }
.mfs-ar15__btn--ghost { background: transparent; }
.mfs-ar15__btn--link {
    border: none; background: transparent; color: var(--mfs-ar15-muted);
    text-decoration: underline; padding: 0.5rem;
}
.mfs-ar15__btn--block { width: 100%; }
.mfs-ar15__btn--lg { padding: 0.85rem 1.5rem; font-size: 1.05rem; }
.mfs-ar15__btn--sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

/* Parts step — viewport-height workspace */
.mfs-ar15__parts-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.25rem;
    height: calc(100vh - 220px);
    min-height: 520px;
}
@media (max-width: 900px) {
    .mfs-ar15__parts-layout { grid-template-columns: 1fr; height: auto; }
}

.mfs-ar15__sidebar {
    background: #fafafa;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mfs-ar15__sidebar h3 { margin: 0 0 0.75rem; font-size: 1.1rem; }

.mfs-ar15__slot-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.mfs-ar15__slot-list li {
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 4px;
    background: #fff;
    margin-bottom: 0.35rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.mfs-ar15__slot-list li:hover { border-color: #999; }
.mfs-ar15__slot-list li.is-active {
    border-color: var(--mfs-ar15-accent);
    box-shadow: 0 0 0 2px rgba(178, 34, 34, 0.15);
}
.mfs-ar15__slot-list li.is-filled { background: #f3faf3; }
.mfs-ar15__slot-list li.is-skipped { opacity: 0.6; }
.mfs-ar15__slot-name { font-weight: 600; font-size: 0.92rem; }
.mfs-ar15__slot-meta {
    display: block;
    font-size: 0.78rem;
    color: var(--mfs-ar15-muted);
    margin-top: 2px;
}

.mfs-ar15__total {
    display: flex;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-top: 1px solid var(--mfs-ar15-border);
    margin-bottom: 0.65rem;
    font-size: 1rem;
}
.mfs-ar15__total--big { font-size: 1.3rem; padding: 1rem 0; }

/* Product workspace */
.mfs-ar15__products {
    background: #fff;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.mfs-ar15__hint {
    color: var(--mfs-ar15-muted);
    text-align: center;
    padding: 3rem 1rem;
    margin: auto;
}

.mfs-ar15__slot-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--mfs-ar15-border);
    background: #fafafa;
}
.mfs-ar15__slot-header h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.mfs-ar15__slot-desc { color: var(--mfs-ar15-muted); margin: 0 0 0.65rem; font-size: 0.88rem; }

.mfs-ar15__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.mfs-ar15__filters select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 4px;
    font: inherit;
    font-size: 0.85rem;
    background: #fff;
}
.mfs-ar15__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.55rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.mfs-ar15__chip button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}
.mfs-ar15__filter-spacer { flex: 1; }
.mfs-ar15__count { font-size: 0.82rem; color: var(--mfs-ar15-muted); }

/* Line-item list */
.mfs-ar15__product-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.mfs-ar15__product-row {
    display: grid;
    grid-template-columns: 56px 1fr 130px 110px 130px;
    gap: 0.85rem;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
}
@media (max-width: 780px) {
    .mfs-ar15__product-row {
        grid-template-columns: 48px 1fr auto;
        grid-template-rows: auto auto;
    }
    .mfs-ar15__row-brand, .mfs-ar15__row-caliber { display: none; }
    .mfs-ar15__row-action { grid-column: 1 / -1; justify-self: end; }
}

.mfs-ar15__product-row:hover { background: var(--mfs-ar15-row-hover); }
.mfs-ar15__product-row.is-selected { background: var(--mfs-ar15-row-selected); }
.mfs-ar15__product-row.is-selected::before {
    content: "✓";
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--mfs-ar15-accent);
    color: transparent;
}

.mfs-ar15__row-thumb {
    width: 56px;
    height: 56px;
    background: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mfs-ar15__row-thumb img { width: 100%; height: 100%; object-fit: cover; }

.mfs-ar15__row-name {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mfs-ar15__row-sub {
    color: var(--mfs-ar15-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}
.mfs-ar15__row-brand, .mfs-ar15__row-caliber {
    font-size: 0.82rem;
    color: #444;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mfs-ar15__row-price {
    font-weight: 700;
    color: var(--mfs-ar15-accent);
    font-size: 1rem;
    text-align: right;
}
.mfs-ar15__row-action {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-end;
}
.mfs-ar15__qty {
    width: 50px;
    padding: 0.3rem 0.35rem;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 3px;
    font: inherit;
    font-size: 0.85rem;
    text-align: center;
}

.mfs-ar15__pagination {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--mfs-ar15-border);
    background: #fafafa;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
}

.mfs-ar15__skip-row {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--mfs-ar15-border);
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.mfs-ar15__skip-row .mfs-ar15__btn--primary { margin-left: auto; }

/* Review */
.mfs-ar15__review {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 6px;
    overflow: hidden;
}
.mfs-ar15__review li {
    display: grid;
    grid-template-columns: 64px 1fr auto auto;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--mfs-ar15-border);
    align-items: center;
}
.mfs-ar15__review li:last-child { border-bottom: none; }
.mfs-ar15__review li.is-skipped { background: #fafafa; color: var(--mfs-ar15-muted); }
.mfs-ar15__review-img { width: 64px; height: 64px; background: #f5f5f5; border-radius: 4px; overflow: hidden; }
.mfs-ar15__review-img img { width: 100%; height: 100%; object-fit: cover; }
.mfs-ar15__review-meta { font-size: 0.85rem; color: var(--mfs-ar15-muted); }
.mfs-ar15__review-qty { font-size: 0.85rem; color: var(--mfs-ar15-muted); }

.mfs-ar15__notice {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}
.mfs-ar15__notice.is-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.mfs-ar15__loading { text-align: center; padding: 2rem; color: var(--mfs-ar15-muted); }

.mfs-ar15__field-error {
    grid-column: 1 / -1;
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.8rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 4px;
}

/* Hover image popover */
.mfs-ar15__hoverpop {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    background: #fff;
    border: 1px solid var(--mfs-ar15-border);
    border-radius: 6px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    padding: 6px;
    max-width: 320px;
}
.mfs-ar15__hoverpop img { display: block; width: 300px; height: auto; max-height: 300px; object-fit: contain; }

/* Progress modal */
.mfs-ar15__progress {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.mfs-ar15__progress[hidden] { display: none; }
.mfs-ar15__hoverpop[hidden] { display: none; }
.mfs-ar15__progress-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    text-align: center;
}
.mfs-ar15__progress-card h3 { margin: 0 0 0.5rem; }
.mfs-ar15__progress-card p { color: var(--mfs-ar15-muted); margin: 0 0 1rem; }
.mfs-ar15__progress-bar {
    height: 10px;
    background: #f1f1f1;
    border-radius: 6px;
    overflow: hidden;
}
.mfs-ar15__progress-bar span {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--mfs-ar15-accent);
    transition: width 0.3s ease;
}
