* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

/* Prevent horizontal overflow globally */
html,body{max-width:100%;overflow-x:hidden;-webkit-text-size-adjust:100%}

body {
    font-family: 'Montserrat', Arial, sans-serif;
    background: #f0f4ed;
    color: #222;
    min-height: 100vh;
    /* responsive base font */
    font-size: clamp(13px, 3.5vw, 16px);
    line-height: 1.35;
}

header {
    background: #556F53;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap
}

.logo-wrap {
    height: 64px;
    width: 64px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 3px solid #f6bd04
}

.logo-wrap img {
    height: 68px;
    width: 68px;
    object-fit: contain
}

.header-text {
    flex: 1
}

.header-text h1 {
    color: #f6bd04;
    font-size: clamp(16px, 3.6vw, 20px);
    font-weight: 800;
    letter-spacing: 1px;
    line-height: 1.2
}

.header-text p {
    color: #d4e8c2;
    font-size: 11px;
    margin-top: 3px;
    font-weight: 400
}

.header-badge {
    background: #f6bd04;
    color: #2a3d29;
    font-size: 17px;
    font-weight: 800;
    padding: 10px 20px;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: .5px;
    text-align: center
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: clamp(12px,2.6vw,20px) 12px clamp(20px,4vw,40px);
}

.step {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #c8dab8;
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(85, 111, 83, .06)
}

.step-header {
    background: #556F53;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px
}

.step-num {
    background: #f6bd04;
    color: #2a3d29;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0
}

.step-title {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .3px
}

.step-body {
    padding: 20px
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(8px,2vw,14px);
    margin-bottom: 12px
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px
}

.form-group.full {
    grid-column: 1/-1
}

label {
    font-size: 11px;
    color: #556F53;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px
}

input[type=text],
input[type=tel],
input[type=email],
select,
textarea {
    border: 1.5px solid #c8dab8;
    border-radius: 7px;
    padding: 10px 12px;
    font-size: clamp(13px,2.5vw,15px);
    width: 100%;
    outline: none;
    transition: border .2s;
    background: #fff;
    font-family: 'Montserrat', Arial, sans-serif
}

input:focus,
select:focus,
textarea:focus {
    border-color: #556F53
}

textarea {
    resize: vertical;
    min-height: 80px
}

.required {
    color: #c0392b
}

.familia-header {
    background: #556F53;
    color: #fff;
    padding: 10px 12px;
    font-size: clamp(14px,3vw,16px);
    font-weight: 800;
    letter-spacing: .5px;
    margin: 14px 0 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 5px solid #f6bd04
}

.familia-header:first-child {
    margin-top: 0
}

.prod-col-header {
    display: grid;
    grid-template-columns: 1fr 100px 110px;
    gap: 8px;
    padding: 6px 6px 8px;
    border-bottom: 2px solid #eaf3de;
    margin-bottom: 6px;
    align-items: center;
}

.col-lbl {
    font-size: 10px;
    color: #888;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px
}

.col-lbl.right {
    text-align: right
}

.col-lbl.center {
    text-align: center
}

.product-row {
    display: grid;
    grid-template-columns: 1fr 100px 110px;
    gap: 8px;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px solid #f4f4f4;
    word-break: break-word;
}

.product-row:last-child {
    border-bottom: none
}

.sku { display: none }
.product-name { word-break: break-word; }

.product-name {
    font-size: 13px;
    color: #333;
    font-weight: 500;
    line-height: 1.3
}

.product-price {
    font-size: 13px;
    color: #556F53;
    font-weight: 700;
    text-align: right
}

.qty-ctrl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px
}

.qty-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #74bc21;
    border-radius: 6px;
    background: #fff;
    color: #556F53;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .12s
}

.qty-btn:hover {
    background: #eaf3de
}

.qty-val {
    width: 52px;
    height: 36px;
    border: 1.5px solid #c8dab8;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #222;
    background: #fff;
    outline: none;
    font-family: 'Montserrat', Arial, sans-serif
}

.qty-val:focus {
    border-color: #556F53
}

.total-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px solid #eaf3de
}

.total-label {
    font-size: 14px;
    color: #556F53;
    font-weight: 700
}

.total-val {
    font-size: 22px;
    font-weight: 800;
    color: #556F53
}

.pago-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 4px
}

.pago-opt {
    border: 1.5px solid #c8dab8;
    border-radius: 8px;
    padding: 11px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    transition: border .15s, background .15s;
    font-family: 'Montserrat', Arial, sans-serif
}

.pago-opt:hover {
    background: #eaf3de;
    border-color: #556F53
}

.pago-opt input[type=radio] {
    accent-color: #556F53;
    width: 16px;
    height: 16px
}

.pago-opt.selected {
    border-color: #74bc21;
    background: #eaf3de;
    font-weight: 700
}

.summary-box {
    background: #eaf3de;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #c8dab8
}

/* Mobile-first: stacked product rows to avoid horizontal overflow */
@media (max-width: 640px){
    .prod-col-header{grid-template-columns: 1fr;display:none}
    .product-row{grid-template-columns: 1fr;gap:6px;padding:10px 6px}
    .product-row .sku{order:1;font-size:12px}
    .product-row .product-name{order:2}
    .product-row .product-price{order:3;text-align:left}
    .product-row .qty-ctrl{order:4;justify-content:flex-start}
    .qty-btn{width:40px;height:40px}
    .qty-val{width:64px}
    .search-wrapper{flex-direction:column;align-items:stretch}
    .search-left{width:100%}
    .search-right{display:flex;gap:8px;align-items:center;justify-content:flex-start;margin-top:8px}
    .small-btn{padding:8px 12px}
}

@media (min-width: 900px){
    .container{max-width:840px}
    .logo-wrap{height:72px;width:72px}
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 3px 0;
    color: #444;
    border-bottom: 1px dashed #c8dab8
}

.summary-line:last-of-type {
    border-bottom: none
}

.summary-total {
    font-weight: 800;
    font-size: 19px;
    color: #556F53;
    border-top: 2px solid #556F53;
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    justify-content: space-between
}

.btn-submit {
    background: #556F53;
    color: #fff;
    border: none;
    padding: 16px 30px;
    border-radius: 9px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    width: 100%;
    margin-top: 12px;
    letter-spacing: .5px;
    transition: background .15s;
    font-family: 'Montserrat', Arial, sans-serif
}

.btn-submit:hover {
    background: #3e5340
}

.notice {
    font-size: 18px;
    color: #888;
    margin-top: 10px;
    text-align: center;
    line-height: 1.7
}

.success-box {
    display: none;
    background: #eaf3de;
    border: 2px solid #556F53;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    margin-top: 10px
}

.success-box h2 {
    color: #556F53;
    font-size: 22px;
    margin-bottom: 8px;
    font-weight: 800
}

.success-box p {
    color: #444;
    font-size: 20px;
    line-height: 1.6
}

.resumen-items {
    margin-bottom: 6px;
    font-size: 15px;
    color: #666
}

/* Loader para la sección de productos */
.loading-products {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 26px 12px;
    background: linear-gradient(180deg, rgba(234,243,222,0.6), rgba(255,255,255,0.9));
    border-radius: 10px;
    border: 1px dashed rgba(85,111,83,0.08);
    color: #2a3d29;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 4px solid rgba(85,111,83,0.12);
    border-top-color: #74bc21;
    animation: spin 0.95s linear infinite;
    flex-shrink: 0;
}

.loading-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'Montserrat', Arial, sans-serif;
}

.loading-line {
    font-size: 13px;
    color: #2a3d29;
    opacity: 0.95;
}

.loading-line-strong {
    font-weight: 800;
    font-size: 15px;
}

.load-error {
    padding: 18px 14px;
    background: #fff4f4;
    border: 1px solid #f5c6c6;
    color: #a33;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
}

/* Fade-in rápido y moderno para los productos rendereados */
@keyframes prodFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fade-in > * {
    opacity: 0;
    transform: translateY(6px);
    animation: prodFadeIn .26s ease forwards;
}
.fade-in > *:nth-child(1){ animation-delay: 0s }
.fade-in > *:nth-child(2){ animation-delay: .02s }
.fade-in > *:nth-child(3){ animation-delay: .04s }
.fade-in > *:nth-child(4){ animation-delay: .06s }
.fade-in > *:nth-child(5){ animation-delay: .08s }
.fade-in > *:nth-child(6){ animation-delay: .10s }
.fade-in > *:nth-child(7){ animation-delay: .12s }
.fade-in > *:nth-child(8){ animation-delay: .14s }

/* Search bar styles */
.search-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 6px 18px;
}
.search-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
}
.product-search {
    flex: 1 1 auto;
    min-width: 160px;
    padding: 10px 12px 10px 40px;
    border-radius: 10px;
    border: 1.5px solid #d9e6cf;
    background: #fff;
    font-size: 14px;
    color: #233;
    transition: box-shadow .12s ease, border-color .12s ease, transform .08s ease;
}
.product-search:focus {
    outline: none;
    border-color: #74bc21;
    box-shadow: 0 6px 18px rgba(116,188,33,0.08);
    transform: translateY(-1px);
}
.search-icon {
    position: relative;
    left: 8px;
    margin-left: 4px;
    color: #74bc21;
    font-size: 16px;
}
.clear-search {
    margin-left: 6px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
}
.clear-search:hover { background: rgba(0,0,0,0.04); color: #333 }
.search-count {
    min-width: 140px;
    text-align: right;
    color: #556F53;
    font-weight: 700;
    font-size: 13px;
}

.small-btn{
    margin-left:8px;
    background:#74bc21;
    color:#fff;
    border:none;
    padding:6px 10px;
    border-radius:8px;
    font-size:13px;
    cursor:pointer;
}
.small-btn:hover{opacity:.95}

/* Accordion / Familia styles */
.familia-block{border-radius:8px;margin-bottom:8px;overflow:hidden;border:1px solid #e6eddc}
.familia-toggle{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:#f7fbf6;cursor:pointer;gap:12px}
.familia-toggle .familia-title{font-weight:800;color:#2a3d29}
.familia-chevron{transition:transform .22s ease;color:#556F53;font-size:14px}
.familia-content{max-height:0;overflow:hidden;transition:max-height .28s ease, opacity .22s ease, transform .22s ease;padding:0 12px;opacity:0;transform:translateY(-6px)}
.familia-content.open{opacity:1;transform:translateY(0);padding:10px 12px}
.familia-open .familia-chevron{transform:rotate(90deg)}

.product-row{padding:8px 0;border-bottom:1px solid #f4f4f4}


.no-results {
    padding: 22px 14px;
    border-radius: 10px;
    background: linear-gradient(180deg, #fff, #fff9f9);
    border: 1px solid #f2e6e6;
    color: #7a7a7a;
    text-align: center;
    font-weight: 700;
}

@media (max-width:600px){
    .search-wrapper{flex-direction:column;align-items:stretch}
    .search-count{width:100%;text-align:left;margin-top:8px}
}


@media(max-width:600px) {
    .form-row {
        grid-template-columns: 1fr
    }

    .product-row,
    .prod-col-header {
        grid-template-columns: 50px 1fr 80px 96px
    }

    .pago-grid {
        grid-template-columns: 1fr
    }

    .header-badge {
        font-size: 14px;
        padding: 8px 12px;
        width: 100%
    }
}