body {
    overflow: hidden;
    height: 100vh;
}

.container-fluid {
    width: 100%;
    max-width: none;
    height: 100vh;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* Ensure main card doesn't scroll */
.card {
    /*height: 100vh;*/
    overflow: hidden;
}

.mi-card-body {
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* Steps 1, 3, 4: allow scroll so Fabric list, Fit, Details are reachable on mobile */
#step_fabric .col-12,
#step_fittings .col-12,
#step_details .col-12 {
    overflow-y: auto;
    max-height: calc(100vh - 120px);
    padding-bottom: 24px;
    -webkit-overflow-scrolling: touch;
}

/* Review step: column sizes to content so no big empty gap above Place Order */
#step_review.row {
    align-items: flex-start;
}

#step_review .col-12 {
    align-self: flex-start;
    width: 100%;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-bottom: 24px;
    -webkit-overflow-scrolling: touch;
}

.mi_sidebar {
    height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: visible;
    padding-right: 10px;
    padding-bottom: 20px;
    /* Extra space for last items */
    max-height: calc(100vh - 120px);
    position: relative;
}

/* Custom scrollbar for sidebar */
.mi_sidebar::-webkit-scrollbar {
    width: 8px;
}

.mi_sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.mi_sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.mi_sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Shirt canvas background – change ONLY the value below; then hard-refresh (Ctrl+Shift+R / Cmd+Shift+R) if it doesn’t update */
:root {
    --shirt-canvas-bg: #e8e8e858;
}

/* Force canvas background so it overrides Bootstrap card/card-body and any other white background */
#step_customize .col-lg-8.col-md-7.col-sm-12.mi-shirt-containers,
#step_customize .mi-shirt-containers {
    background-color: var(--shirt-canvas-bg, #e8e8e858) !important;
}

.mi_container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    min-width: 400px;
    background-color: var(--shirt-canvas-bg, #e8e8e858);
}

#step_customize .mi_container {
    background-color: var(--shirt-canvas-bg, #e8e8e858) !important;
}

/* Ensure front/back/cuff view containers always use canvas background */
#step_customize .mi_container.mi_shirt_front,
#step_customize .mi_container.mi_shirt_back,
#step_customize .mi_container.mi_shirt_cuff {
    background-color: var(--shirt-canvas-bg, #e8e8e858) !important;
}

.mi_elements_container .element {
    border-bottom: 1px solid #e3e3e3;
    height: 100px;
    padding: 20px 15px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.mi_elements_container .element div img {
    width: 60%;
    max-width: 40px;
}

.mi_elements_container .element div.text-uppercase {
    font-size: 16px;
    line-height: 1.2;
    padding-top: 8px;
}

.mi_container .custom_shirt {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    height: auto;
    width: auto;
    object-fit: contain;
    object-position: center center;
    z-index: 2;
    transition: all 0.3s ease;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

/* Specific z-index for different shirt components */
.mi_container .custom_shirt.shirt_placket {
    z-index: 3;
    /* Placket on top */
}

.mi_container .custom_shirt.shirt_collar {
    z-index: 4;
    /* Collar on top of placket */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    object-position: center center;
}

.mi_container .custom_shirt.shirt_pocket {
    z-index: 3;
    /* Pocket same level as placket */
}

.mi_container .custom_shirt.shirt_sleeves {
    z-index: 2;
    /* Sleeves on base layer */
}

.mi_container .custom_shirt.shirt_cuff_all {
    z-index: 5;
    /* Cuff on top of everything */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    object-position: center center;
    display: block;
}

/* Ensure cuff image in cuff container is visible and properly displayed */
.mi_shirt_cuff .custom_shirt.shirt_cuff_all {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    object-fit: contain !important;
    object-position: center center !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
}

/* Base shirt images - provide body structure */
.mi_container .custom_shirt.shirt_base,
.mi_container .custom_shirt.shirt_base_back {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    height: auto;
    width: auto;
    object-fit: contain;
    z-index: 1;
    /* Base layer for body structure */
}

/* Back view components - fix layering issue */
.mi_container .custom_shirt.shirt_back_base {
    z-index: 1;
    /* Base layer for back pleats */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    object-position: center center;
}

.mi_container .custom_shirt.shirt_back_short {
    z-index: 2;
    /* Main back shirt layer */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    object-position: center center;
}

.mi_container .custom_shirt.shirt_back_tail {
    z-index: 3;
    /* Bottom hem layer - only show when needed */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    object-position: center center;
}

/* Hide back tail by default to prevent double shirt effect */
.mi_container .custom_shirt.shirt_back_tail.hide {
    display: none !important;
}

/* Hide shirt_base_back from back view */
.mi_shirt_back .custom_shirt.shirt_base_back {
    display: none !important;
}

/* Fix for long sleeves back view */
.mi_container .custom_shirt.shirt_back_short[src*="white-long.png"] {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    object-fit: contain !important;
    object-position: center center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    float: none !important;
    display: block !important;
    text-align: center !important;
    width: auto !important;
    height: auto !important;
}

/* Ensure sleeves display properly - match other components dimensions */
.mi_container .custom_shirt.shirt_sleeves {
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    object-position: center center;
    margin: 0;
    padding: 0;
}

/* Specific fix for short sleeves - ensure proper alignment with collar */
.mi_container .custom_shirt.shirt_sleeves[src*="short"] {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    object-fit: contain !important;
    object-position: center center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    float: none !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
}

/* Specific fix for long sleeves centering */
.mi_container .custom_shirt.shirt_sleeves[src*="long"] {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    object-position: center center;
    margin: 0 !important;
    padding: 0 !important;
}

/* Additional aggressive centering for long sleeves */
.mi_container .custom_shirt[src*="white-long.png"] {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    display: block !important;
}

/* Professional fix for long sleeves centering */
.mi_container .custom_shirt.shirt_sleeves.long-sleeves {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    object-fit: contain !important;
    object-position: center center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    float: none !important;
    display: block !important;
    text-align: center !important;
}

/* Ultra-aggressive centering for long sleeves - override everything */
.mi_container .custom_shirt[src*="white-long.png"] {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    float: none !important;
    display: block !important;
    text-align: center !important;
    object-fit: contain !important;
    object-position: center center !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    width: auto !important;
    height: auto !important;
}

/* Ensure container is properly centered for long sleeves */
.mi_shirt_front.has-long-sleeves {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

/* Ensure shirt fills the canvas properly */
.mi_shirt_front,
.mi_shirt_cuff,
.mi_shirt_back {
    width: 100%;
    height: 100%;
    background-color: var(--shirt-canvas-bg, #e8e8e858) !important;
}

/* Ensure containers are properly hidden when not active */
.mi_shirt_front.hide,
.mi_shirt_back.hide,
.mi_shirt_cuff.hide {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Ensure containers are visible when active */
.mi_shirt_front.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mi_shirt_back.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mi_shirt_cuff.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Ensure cuff container image is always visible when container is active */
.mi_shirt_cuff.active .custom_shirt.shirt_cuff_all {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    object-fit: contain !important;
    object-position: center center !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    z-index: 10 !important;
}

/* Hide main shirt views when cuff view is active */
.mi_shirt_cuff.active~.mi_shirt_front,
.mi_shirt_cuff:not(.hide)~.mi_shirt_front {
    display: none !important;
}

.mi_shirt_cuff.active~.mi_shirt_back,
.mi_shirt_cuff:not(.hide)~.mi_shirt_back {
    display: none !important;
}

/* Hide back view container when front view is active (front comes before back in DOM) */
.mi_shirt_front.active~.mi_shirt_back {
    display: none !important;
}

/* Hide front view container when back view is active - works in all cases */
.mi_shirt_back.active~.mi_shirt_front,
.mi_shirt_back:not(.hide)~.mi_shirt_front {
    display: none !important;
}

/* Hide all front view assets when front container is hidden or not active */
.mi_shirt_front.hide .custom_shirt,
.mi_shirt_front:not(.active) .custom_shirt {
    display: none !important;
}

/* Hide all back view assets when back container is hidden or not active */
.mi_shirt_back.hide .custom_shirt,
.mi_shirt_back:not(.active) .custom_shirt {
    display: none !important;
}

/* Additional safety: hide front assets when back is active (works regardless of DOM order via parent) */
.mi-shirt-containers .mi_shirt_back.active~.mi_shirt_front .custom_shirt,
.mi-shirt-containers .mi_shirt_back:not(.hide)~.mi_shirt_front .custom_shirt {
    display: none !important;
}

/* Additional safety: hide back assets when front is active */
.mi-shirt-containers .mi_shirt_front.active~.mi_shirt_back .custom_shirt,
.mi-shirt-containers .mi_shirt_front:not(.hide)~.mi_shirt_back .custom_shirt {
    display: none !important;
}

/* Hide cuff when no image is set */
.custom_shirt.shirt_cuff_all[src=""] {
    display: none !important;
}

/* Ensure cuff is hidden in front view when switching from back view - only show if properly configured */
.mi_shirt_front.active .custom_shirt.shirt_cuff_all.hide {
    display: none !important;
}

/* Hide cuff in front view by default when front view becomes active (will be shown by JS if needed) */
.mi_shirt_front:not(.hide) .custom_shirt.shirt_cuff_all:not(.show-cuff) {
    display: none !important;
}

.hide {
    display: none !important;
}

.active {
    display: flex
}

.mi_elements_container .element .mi_dropdown {
    position: fixed;
    width: 200px;
    min-height: 120px;
    padding: 15px 20px;
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-align: center;
    z-index: 99999999;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: visible;
    display: none;
    visibility: visible;
}

.mi_elements_container .element .mi_dropdown:not(.hide) {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide class for dropdowns */
.mi_elements_container .element .mi_dropdown.hide {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Arrow removed since dropdowns are positioned outside sidebar */

/* Dropdown backdrop - not needed for sidebar positioning */
.mi_dropdown_backdrop {
    display: none;
}

.mi_elements_container .element .element_container_parent {
    width: 100%;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.mi_elements_container .element .mi_dropdown .head {
    border-bottom: 1px solid #e3e3e3;
    text-align: left
}

.mi_elements_container .element .mi_dropdown .mi_dropdown_item {
    padding: 12px 8px;
    border-bottom: 1px solid #f0f0f0;
    margin: 8px 0;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.mi_elements_container .element .mi_dropdown .mi_dropdown_item:last-child {
    border: none
}

.mi_elements_container .element .mi_dropdown .mi_dropdown_item:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.mi_elements_container .element .mi_dropdown .mi_dropdown_dismiss {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 999999;
    border: 1px solid #e3e3e3;
    padding: 6.5px 6px;
    border-radius: 0px !important
}

.mi_sidebar_toggle_dismiss {
    display: none
}

/* Step 1: remove empty space between Category/Search and fabric list */
.mi_fabric_filters {
    margin-bottom: 0.5rem !important;
}

.mi_fabric_filters+.cloth_container {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.cloth_container {
    overflow: visible;
    padding: 8px 5px 15px 5px;
}

.cloth_container .cloth_elements {
    margin-top: 0 !important;
}

.cloth_container .cloth_elements {
    list-style: none;
    padding-left: 0
}

.cloth_container .cloth_elements .cloth_el {
    display: inline-block;
    width: 110px;
    margin: 0 5px;
    text-align: center;
    padding: 5px;
    margin-bottom: 10px;
    border: 1px solid #f0f0f0
}

.cloth_container .cloth_elements .cloth_el:hover {
    border: #444;
    box-shadow: 0 0 4px 0 #969696
}

.cloth_container .cloth_elements .cloth_el {
    position: relative;
}

.cloth_container .cloth_elements .cloth_el .cloth_el_detail_icon {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    cursor: pointer;
    color: #0d6efd;
    font-size: 1.1rem;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
}

.cloth_container .cloth_elements .cloth_el .cloth_el_detail_icon:hover {
    color: #0a58ca;
}

.cloth_container .cloth_elements .cloth_el img {
    width: 100%
}

.fits_container {
    overflow: auto;
    padding: 15px 5px
}

.fits_container .fits_elements {
    list-style: none;
    padding-left: 0;
    text-align: center
}

.fits_container .fits_elements .fit_el img {
    border: 1px solid #f0f0f0;
    padding: 10px
}

.fits_container .fits_elements .fit_el {
    display: inline-block;
    width: 40%;
    max-width: 250px;
    margin: 0 5px;
    text-align: center;
    padding: 5px;
    margin-bottom: 10px
}

.fits_container .fits_elements .fit_el img:hover {
    border: #444;
    box-shadow: 0 0 4px 0 #969696
}

.fits_container .fits_elements .fit_el img {
    width: 100%
}

.mi_fabric_previewer img {
    margin-top: 35%
}

.mi_right_sidebar {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 0;
    position: relative;
}

.mi_fabric_previewer button {
    text-align: center;
    width: 49%
}

/* Ensure Next button is always visible */
#mi_next_to_choose_cloth_and_sizes {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
}

li.mi_selected_option {
    position: relative;
}

li.mi_selected_option:before {
    content: "";
    width: 14px;
    height: 8px;
    position: absolute;
    border-left: 2px solid #28a745;
    border-bottom: 2px solid #28a745;
    transform: rotate(-45deg);
    margin-left: 90px;
    margin-top: -10px;
}

li.mi_selected_option.fit_el:before {
    margin-left: 20px !important;
    margin-top: 15px !important;
}

.mi_selection_overview li {
    padding: 10px 5px;
    border-bottom: 1px solid #e3e3e3
}

.mi-card-body {
    height: 100vh;
    overflow: hidden;
    padding-bottom: 20px;
}

.mi_sidebar_toggle_dismiss {
    position: absolute;
    top: 4px;
    right: -40px
}

.mi-shirt-containers {
    height: calc(100vh - 120px);
    overflow: visible;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background-color: var(--shirt-canvas-bg);
}

/* View Controls */
.mi_view_controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.mi_view_btn,
.mi_zoom_btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    color: #333;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    transition: all 0.3s ease;
}

.mi_view_btn:hover,
.mi_zoom_btn:hover {
    background: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
}

.mi_view_btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.mi_zoom_btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.mi_view_btn i,
.mi_zoom_btn i {
    margin-right: 5px;
}

/* Zoom functionality */
.mi-shirt-containers.zoomed {
    overflow: hidden !important;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mi_container.zoomed {
    transform: scale(1.5) !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    position: relative !important;
    z-index: 10;
    cursor: grab;
    will-change: transform;
}

.mi_container.zoomed .custom_shirt {
    cursor: grab;
    pointer-events: auto;
    transition: none;
}

.mi_container.zoomed .custom_shirt:active {
    cursor: grabbing;
}

.mi_container.zoomed:active {
    cursor: grabbing;
}

/* Ensure all shirt images maintain proper positioning when zoomed - don't override their transforms */
.mi_container.zoomed .custom_shirt.shirt_base,
.mi_container.zoomed .custom_shirt.shirt_base_back,
.mi_container.zoomed .custom_shirt.shirt_collar,
.mi_container.zoomed .custom_shirt.shirt_placket,
.mi_container.zoomed .custom_shirt.shirt_sleeves,
.mi_container.zoomed .custom_shirt.shirt_cuff_all,
.mi_container.zoomed .custom_shirt.shirt_pocket,
.mi_container.zoomed .custom_shirt.shirt_back_base,
.mi_container.zoomed .custom_shirt.shirt_back_short,
.mi_container.zoomed .custom_shirt.shirt_back_tail {
    /* Keep existing positioning - don't override transforms */
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    object-fit: contain !important;
    object-position: center center !important;
}

/*
 * Tablet / narrow viewport: use container-relative shirt sizing (up to 1024px).
 * Covers iPad Mini (768), iPad Air (820), Surface Pro 7 (912), Surface Duo (540), etc.
 */
@media only screen and (max-width: 1024px) {
    #step_customize .col-lg-8.col-md-7.col-sm-12 {
        height: calc(100vh - 320px);
        height: calc(100dvh - 320px);
        min-height: 260px;
        min-height: max(260px, 45dvh);
    }

    .mi-shirt-containers {
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .mi-shirt-containers .mi_container {
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0;
        min-width: 0;
        /* Prevent collapse on Safari/iOS (iPhone SE, iPad) */
        min-height: max(200px, 40dvh);
    }

    .mi_container {
        width: 100%;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
    }

    .mi_container .custom_shirt,
    .mi_container .custom_shirt.shirt_base,
    .mi_container .custom_shirt.shirt_base_back,
    .mi_container .custom_shirt.shirt_sleeves,
    .mi_container .custom_shirt.shirt_collar,
    .mi_container .custom_shirt.shirt_placket,
    .mi_container .custom_shirt.shirt_pocket,
    .mi_container .custom_shirt.shirt_cuff_all,
    .mi_container .custom_shirt.shirt_back_base,
    .mi_container .custom_shirt.shirt_back_short,
    .mi_container .custom_shirt.shirt_back_tail {
        max-height: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        object-position: center center !important;
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}

/* Mobile Responsive Styles */
@media only screen and (max-width: 768px) {

    /* Full-width layout - no narrow column */
    body,
    html {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .container-fluid {
        width: 100%;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .card,
    .card.w-100,
    .card-body,
    .mi-card-body {
        width: 100%;
        max-width: 100%;
    }

    .card-header {
        flex-wrap: wrap;
        padding: 10px 15px;
    }

    .card-header .mi_step_indicator {
        width: 100%;
        margin-top: 8px;
        display: flex !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .card-header h3 {
        font-size: 1.1rem;
        width: 100%;
        text-align: center;
    }

    /* Step rows full width - avoid narrow column / side gap */
    .mi_step {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding-left: 10px;
        padding-right: 10px;
    }

    .mi_step .row {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 100%;
    }

    .mi_step .col-12,
    .mi_step [class*="col-"] {
        padding-left: 8px;
        padding-right: 8px;
    }

    #step_customize .mi_sidebar_floating {
        display: none !important;
        width: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    /* Step + row height chain so column height resolves on Safari/iOS (iPhone SE, iPad, etc.) */
    #step_customize.row {
        flex: 1 1 0;
        min-height: 0;
        display: flex;
        flex-wrap: wrap;
        align-content: stretch;
    }

    #step_customize .mi-shirt-containers,
    #step_customize .col-lg-8.col-md-7.col-sm-12 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }

    #step_customize .mi_right_sidebar,
    #step_customize .col-lg-2.col-md-2.col-sm-12 {
        display: none !important;
    }

    /* Hide desktop sidebar in mobile */
    .mi_sidebar {
        display: none !important;
    }

    /*
     * Shirt column: fixed height so it NEVER goes under the fixed bottom bar.
     * Use dvh so mobile browser chrome (URL bar) doesn't break layout (iOS/Safari).
     * Header ~120px + fixed bar ~200px = 320px reserved. Shirt gets the rest.
     */
    #step_customize .col-lg-8.col-md-7.col-sm-12 {
        height: calc(100vh - 320px);
        height: calc(100dvh - 320px);
        min-height: 280px;
        min-height: max(280px, 50dvh);
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
    }

    .mi-shirt-containers {
        width: 100%;
        max-width: 100%;
        height: 100%;
        min-height: 0;
        padding: 0 10px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    /* View controls (Front, Back, Zoom) – compact, no overlay */
    .mi-shirt-containers .mi_view_controls {
        position: static;
        transform: none;
        left: auto;
        top: auto;
        flex-shrink: 0;
        justify-content: center;
        padding: 6px 0 6px;
        margin: 0 0 4px 0;
        border-bottom: 1px solid #e9ecef;
        background: #fff;
    }

    /* Shirt container: all remaining space, centered content */
    .mi-shirt-containers .mi_container {
        flex: 1;
        min-height: 0;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        /* Safari/iOS: prevent collapse (iPhone SE, Galaxy S8+, etc.) */
        min-height: max(200px, 40dvh);
    }

    .mi_container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        position: relative;
    }

    /* Shirt as big as possible within container, centered – single rule for all parts */
    .mi_container .custom_shirt,
    .mi_container .custom_shirt.shirt_base,
    .mi_container .custom_shirt.shirt_base_back,
    .mi_container .custom_shirt.shirt_sleeves,
    .mi_container .custom_shirt.shirt_collar,
    .mi_container .custom_shirt.shirt_placket,
    .mi_container .custom_shirt.shirt_pocket,
    .mi_container .custom_shirt.shirt_cuff_all,
    .mi_container .custom_shirt.shirt_back_base,
    .mi_container .custom_shirt.shirt_back_short,
    .mi_container .custom_shirt.shirt_back_tail {
        max-height: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        object-position: center center !important;
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        /* Reduce rendering issues on iOS/Android (iPhone SE, Galaxy S8+, etc.) */
        backface-visibility: hidden;
    }

    /* Very small screens (e.g. iPhone SE 320px, Galaxy S8+ 360px): ensure shirt area height */
    @media (max-width: 480px) {
        #step_customize .col-lg-8.col-md-7.col-sm-12 {
            min-height: 240px;
            min-height: max(240px, 45dvh);
        }
    }

    /* Short viewport (landscape phones): keep shirt area usable */
    @media (max-height: 500px) {
        #step_customize .col-lg-8.col-md-7.col-sm-12 {
            min-height: 220px;
            min-height: max(220px, 70dvh);
        }
    }

    /* Mobile: Ensure front view assets are hidden when back view is active */
    .mi_shirt_back.active~.mi_shirt_front,
    .mi_shirt_back:not(.hide)~.mi_shirt_front {
        display: none !important;
    }

    /* Mobile: Ensure back view assets are hidden when front view is active */
    .mi_shirt_front.active~.mi_shirt_back,
    .mi_shirt_front:not(.hide)~.mi_shirt_back {
        display: none !important;
    }

    /* Mobile: Hide all front view assets when front container is hidden or not active */
    .mi_shirt_front.hide .custom_shirt,
    .mi_shirt_front:not(.active) .custom_shirt {
        display: none !important;
    }

    /* Mobile: Hide all back view assets when back container is hidden or not active */
    .mi_shirt_back.hide .custom_shirt,
    .mi_shirt_back:not(.active) .custom_shirt {
        display: none !important;
    }

    /* Mobile: Hide shirt_base_back from back view */
    .mi_shirt_back .custom_shirt.shirt_base_back {
        display: none !important;
    }

    /* Center the view control buttons in mobile */
    .mi_view_btn,
    .mi_zoom_btn {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 8px;
        background: #fff;
        border: 1px solid #dee2e6;
        color: #495057;
        cursor: pointer;
    }

    .mi_view_btn.active {
        background: #0d6efd;
        border-color: #0d6efd;
        color: #fff;
    }

    /* Step 1 Fabric: ensure scroll works on mobile */
    #step_fabric .col-12 {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
        max-height: calc(100vh - 120px);
    }

    /* Fabric / cloth list full width */
    .cloth_container {
        padding: 0 0 10px 0;
        width: 100%;
    }

    .mi_fabric_filters+.cloth_container {
        padding-top: 0 !important;
    }

    .cloth_container .cloth_elements {
        justify-content: center;
    }

    .cloth_container .cloth_elements .cloth_el {
        width: 100px;
    }

    /* Fittings full width */
    .fits_container .fits_elements {
        justify-content: center;
    }

    .fits_container .fits_elements .fit_el {
        width: 45%;
        max-width: 200px;
    }

    /* Step 3: Fit nav buttons wrap on small screens */
    #step_fittings .fits_container .fits_elements:last-of-type {
        flex-wrap: wrap;
        gap: 10px;
    }

    #step_fittings .fit_el .btn {
        width: 100%;
        max-width: 160px;
    }

    /* Step 4: Details - stack and spacing */
    #step_details .form-control.w-25 {
        min-width: 60px;
    }

    #step_details .btn-lg {
        margin-top: 4px;
    }

    #step_details .mt-4 .btn {
        margin-bottom: 8px;
    }

    /* Step 5: Review - table and Place Order visible */
    #step_review .table {
        font-size: 0.9rem;
    }

    #step_review .table th,
    #step_review .table td {
        padding: 0.5rem;
    }

    #step_review .card-body .row .form-group {
        margin-bottom: 0.75rem;
    }

    #step_review #complete_order {
        width: 100%;
        max-width: 280px;
    }

    /* Mobile bottom slider (when used) */
    .mi_mobile_slider {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #e3e3e3;
        padding: 0;
        z-index: 1000;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
        display: flex;
        flex-direction: column;
    }

    .mi_mobile_slider_next_bar {
        padding: 8px 12px 8px;
        border-bottom: 1px solid #eee;
        background: #f8f9fa;
    }

    .mi_mobile_slider_next_bar .mi_mobile_price_label {
        font-size: 11px;
        color: #6c757d;
        display: block;
        margin-bottom: 0;
    }

    .mi_mobile_slider_next_bar .mi_mobile_price_value {
        font-size: 16px;
        font-weight: 700;
        color: #0d6efd;
        display: block;
        margin-bottom: 6px;
    }

    .mi_mobile_slider_next_bar .mi_mobile_next_btn {
        width: 100%;
        padding: 10px 16px;
        font-size: 15px;
        font-weight: 600;
        border-radius: 8px;
    }

    .mi_mobile_slider_items {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding: 8px 12px 10px;
        -webkit-overflow-scrolling: touch;
    }

    .mi_mobile_slider_item {
        flex-shrink: 0;
        text-align: center;
        padding: 8px 10px;
        border-radius: 8px;
        background: #f8f9fa;
        border: 1px solid #e3e3e3;
        cursor: pointer;
        min-width: 72px;
        width: 72px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }

    .mi_mobile_slider_item img {
        width: 44px;
        height: 44px;
        object-fit: contain;
        object-position: center;
        display: block;
        margin: 0;
        flex-shrink: 0;
    }

    .mi_mobile_slider_item .text-uppercase {
        font-size: 11px;
        line-height: 1.2;
        margin: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mi_mobile_popup {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 2000;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .mi_mobile_popup_content {
        background: white;
        border-radius: 15px;
        padding: 20px;
        max-width: 90%;
        max-height: 80%;
        overflow-y: auto;
        position: relative;
    }

    .mi_mobile_popup_close {
        position: absolute;
        top: 10px;
        right: 15px;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #666;
    }

    .mi_mobile_popup_options {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .mi_mobile_popup_option {
        text-align: center;
        padding: 15px;
        border: 1px solid #e3e3e3;
        border-radius: 10px;
        cursor: pointer;
    }

    .mi_mobile_popup_option.selected {
        background: #007bff;
        color: white;
        border-color: #007bff;
    }

    .mi_mobile_popup_option img {
        width: 50px;
        height: 50px;
        margin-bottom: 8px;
        object-fit: contain;
    }

    .mi_mobile_popup_option small {
        display: block;
        font-size: 12px;
        margin-top: 5px;
    }

    .mi_right_sidebar {
        display: none !important;
    }
}

@media only screen and (max-width: 900px) {
    .mi_sidebar_floating {
        display: none !important;
        position: absolute;
        top: -50px;
        left: -15px;
        z-index: 99999999;
        background: #fff;
        max-width: 300px;
        height: calc(100vh - 120px);
        overflow-y: auto;
        max-height: calc(100vh - 120px);
        width: 0;
        min-width: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }

    /* Let shirt + right sidebar take full row on tablet */
    #step_customize .col-lg-8.col-md-7 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    #step_customize .col-lg-2.col-md-2 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .mi_toggler {
        display: block;
    }

    .mi_sidebar_toggle_dismiss {
        display: block;
    }

    .mi_elements_container .element {
        height: 80px;
        padding: 15px 10px;
    }

    .mi_elements_container .element .mi_dropdown {
        top: 125px;
    }
}

/* Step flow */
.mi_step {
    display: flex;
    flex-wrap: wrap;
}

.mi_step.hide {
    display: none !important;
}

.mi_step_indicator .badge {
    font-size: 0.85rem;
}

/* Review step: attractive card layout, no extra empty space */
#step_review .mi_review_summary,
#step_review .mi_review_customer_card {
    width: 100%;
}

.mi_review_header h4 {
    font-weight: 600;
    color: #333;
}

.mi_review_summary {
    border-radius: 12px;
    overflow: hidden;
}

.mi_review_summary .card-body {
    background: #fafbfc;
}

.mi_review_block {
    background: #fff;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    height: 100%;
    border: 1px solid #e9ecef;
}

.mi_review_label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.mi_review_value {
    font-size: 0.95rem;
    color: #333;
    line-height: 1.5;
}

.mi_review_value p {
    margin-bottom: 0.25rem;
}

.mi_review_value p:last-child {
    margin-bottom: 0;
}

.mi_review_measurements .mi_review_value {
    font-size: 0.9rem;
}

.mi_review_measurements .mi_review_value p {
    display: inline-block;
    margin-right: 1rem;
    margin-bottom: 0.35rem;
}

.mi_review_total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.mi_review_total_label {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.mi_review_total_price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0d6efd;
}

.mi_review_customer_card {
    border-radius: 12px;
    overflow: hidden;
}

.mi_review_customer_title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.mi_review_input_label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.35rem;
    display: block;
}

.mi_review_input {
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.mi_review_input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.mi_review_actions #complete_order {
    min-width: 220px;
    border-radius: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mi_review_actions #complete_order:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35);
}

.mi_review_actions #btn_back_to_design {
    text-decoration: none;
    font-size: 0.95rem;
}

.mi_review_actions #btn_back_to_design:hover {
    text-decoration: underline;
    color: #333 !important;
}

#step_review .text-center {
    padding-top: 0;
    padding-bottom: 0;
}

@media (max-width: 768px) {
    .mi_review_summary .card-body {
        padding: 1.25rem !important;
    }

    .mi_review_block {
        padding: 0.875rem 1rem;
    }

    .mi_review_total_price {
        font-size: 1.35rem;
    }

    .mi_review_actions #complete_order {
        width: 100%;
        max-width: none;
    }
}

/* Step 4: Measurements form - attractive & user-friendly */
.mi_measurements_header h4 {
    font-weight: 600;
    color: #333;
}

.mi_measure_card {
    border-radius: 12px;
    overflow: hidden;
}

.mi_measure_card_header {
    font-weight: 600;
    color: #333;
    border-radius: 0;
}

.mi_measure_card_header h5 {
    font-size: 1.05rem;
}

.mi_measure_card .card-body {
    padding: 1.25rem 1.5rem;
}

.mi_measure_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.mi_measure_row:last-child {
    border-bottom: none;
}

.mi_measure_row label {
    margin: 0;
    font-weight: 500;
    color: #444;
    flex: 1 1 50%;
    min-width: 120px;
}

.mi_measure_row label small {
    font-weight: 400;
}

.mi_measure_controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mi_measure_input {
    width: 64px;
    padding: 8px 10px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    -moz-appearance: textfield;
    appearance: textfield;
}

.mi_measure_input::-webkit-outer-spin-button,
.mi_measure_input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mi_measure_input:focus {
    border-color: #0d6efd;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.mi_measure_unit {
    font-size: 0.8rem;
    color: #6c757d;
    min-width: 20px;
}

.mi_measure_btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mi_measure_btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}

.mi_measure_btn.mi_minus,
.mi_measure_btn.mi_minus2 {
    color: #dc3545;
    border-color: #f5c6cb;
}

.mi_measure_btn.mi_minus:hover,
.mi_measure_btn.mi_minus2:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.mi_measure_btn.mi_plus,
.mi_measure_btn.mi_plus2 {
    color: #0d6efd;
    border-color: #b6d4fe;
}

.mi_measure_btn.mi_plus:hover,
.mi_measure_btn.mi_plus2:hover {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

.mi_measurements_actions .btn-primary {
    font-weight: 600;
}

.mi_measure_label_extra {
    font-weight: 400;
    color: #6c757d;
}

@media (max-width: 576px) {
    .mi_measure_row {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.75rem 0;
    }

    .mi_measure_row label {
        margin-bottom: 6px;
    }

    .mi_measure_card .card-body {
        padding: 1rem;
    }
}

/* Loading overlay */
.mi_loading_overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    visibility: visible;
    opacity: 1;
}

.mi_loading_overlay.hide {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.mi_loading_overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
    animation: spinner-border 0.75s linear infinite;
}

.mi_loading_overlay p {
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Loading overlay animation */
@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Shirt image loading state */
.mi_container .custom_shirt[src=""] {
    opacity: 0;
    visibility: hidden;
}

.mi_container .custom_shirt:not([src=""]) {
    transition: opacity 0.3s ease;
}

/* Loading indicator for individual images */
.mi_container .custom_shirt.loading {
    opacity: 0.3;
    position: relative;
}

.mi_container .custom_shirt.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
    z-index: 1000;
}

/* Notification system */
.mi_notification_container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999998;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    pointer-events: none;
}

.mi_notification {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 350px;
    pointer-events: auto;
    border-left: 4px solid #007bff;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.mi_notification.success {
    border-left-color: #28a745;
}

.mi_notification.info {
    border-left-color: #17a2b8;
}

.mi_notification.warning {
    border-left-color: #ffc107;
}

.mi_notification.error {
    border-left-color: #dc3545;
}

.mi_notification.show {
    opacity: 1;
    transform: translateX(0);
}

.mi_notification.hide {
    opacity: 0;
    transform: translateX(100%);
}

.mi_notification_icon {
    font-size: 20px;
    flex-shrink: 0;
}

.mi_notification.success .mi_notification_icon {
    color: #28a745;
}

.mi_notification.info .mi_notification_icon {
    color: #17a2b8;
}

.mi_notification.warning .mi_notification_icon {
    color: #ffc107;
}

.mi_notification.error .mi_notification_icon {
    color: #dc3545;
}

.mi_notification_content {
    flex: 1;
}

.mi_notification_title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin: 0 0 4px 0;
}

.mi_notification_message {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.mi_notification_close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.mi_notification_close:hover {
    color: #333;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Mobile responsive notifications */
@media only screen and (max-width: 768px) {
    .mi_notification_container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .mi_notification {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
}

/* ==========================================================================
   SHIRT CANVAS BACKGROUND - change the value below to change the canvas color.
   This rule is last so it overrides everything. No variable - edit this line.
   ========================================================================== */
#step_customize .col-lg-8.col-md-7.col-sm-12.mi-shirt-containers,
#step_customize .mi-shirt-containers,
#step_customize .mi_container,
#step_customize .mi_container.mi_shirt_front,
#step_customize .mi_container.mi_shirt_back,
#step_customize .mi_container.mi_shirt_cuff,
.mi_shirt_front,
.mi_shirt_cuff,
.mi_shirt_back {
    background-color: #cacacacd !important;
}