:root {
    --header-height: auto;
    --nav-height: 65px;
    --safe-padding: 16px;
    --primary: #D32F2F;
    /* Official Brand Red */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Skip link (a11y) — Fase 8: visible solo cuando recibe foco con teclado */
.skip-link {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 10100;
    background: var(--primary, #D32F2F);
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 8px 0;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}
.skip-link:focus {
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
    outline: 3px solid #fff;
    outline-offset: -3px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    /* Mobile Viewport Support */
    padding-bottom: calc(var(--nav-height) + 20px);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header & Categories */
.app-header {
    position: relative;
    z-index: 100;
    padding-top: var(--safe-padding);
    background: inherit;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 var(--safe-padding);
    margin-bottom: 24px;
}

.main-title {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.5px;
    color: #1e293b;
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    position: relative;
}

.cart-icon-container {
    position: relative;
}

.badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: #D32F2F;
    /* Brand */
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

.expanded-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #D32F2F;
    /* Brand */
    color: white;
    border-radius: 20px;
    padding: 0 8px;
    height: 100%;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
    /* Brand Shadow */
}

.category-nav {
    padding: 0 var(--safe-padding) 12px;
}

.category-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 15px;
    scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.category-pill {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 12px;
    margin-top: 5px;
}

.search-bar input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font-size: 15px;
    font-family: inherit;
}

/* Product Grid - 2 Columns Mobile First */
/* --- REFERENCE DESIGN (Compact Grid) --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    /* Tighter Grid */
    padding: 8px;
}

.product-card {
    border-radius: 12px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    /* Fixed Height Removed for Square Ratio */
    /* height: 160px; REMOVED */
    aspect-ratio: 1/1;
    cursor: pointer;
    /* Indicates clickable */
    transition: all 0.2s ease;
    border: 2px solid transparent;
    /* Prepare for border */
}

.product-card.in-cart {
    border: 2px solid #D32F2F;
    /* Brand Highlight */
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.15);
}

.product-img-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gradient Overlay */
.overlay-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85%;
    /* Increased from 70% */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Info Container */
.overlay-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px;
    /* Increased padding */
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.overlay-unit {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.95);
    display: block;
    margin-bottom: 2px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.overlay-title {
    font-size: 14px;
    /* Slightly larger */
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.25;
    color: #ffffff !important;
    /* Force White */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    /* Stronger shadow */

    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.overlay-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.overlay-price {
    font-size: 15px;
    font-weight: 700;
    color: white;
    /* Blanco Puro */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    /* Fuerte sombra */
}

/* Mini Inline Button */
/* Mini Inline Button */
/* --- STEPPER CONTROL (Morphing Button) --- */
.add-control-container {
    position: relative;
    height: 44px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.add-btn {
    background: white;
    color: #D32F2F;
    width: 44px;
    /* Touch target AAA: 44x44 min */
    height: 44px;
    border-radius: 50%;
    border: none;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
    overflow: hidden;
    position: absolute;
    right: 0;
}

/* State: Active (Expanded Stepper) */
.add-btn.expanded {
    width: 120px;
    border-radius: 22px;
    background: #D32F2F;
    /* Brand */
    color: white;
    justify-content: space-between;
    padding: 0 6px;
    box-shadow: 0 6px 15px rgba(211, 47, 47, 0.4);
}

/* Inner elements logic */
.btn-icon-plus {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transition: opacity 0.2s;
}

.stepper-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    transition: all 0.2s ease;
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
}

.add-btn.expanded .btn-icon-plus {
    opacity: 0;
    pointer-events: none;
}

.add-btn.expanded .stepper-content {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.stepper-btn {
    background: none;
    border: none;
    color: white;
    width: 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.stepper-btn:active {
    transform: scale(0.8);
}

.stepper-val {
    font-size: 13px;
    font-weight: 800;
    min-width: 20px;
    text-align: center;
}

/* SVG sizes */
.add-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 3px;
}

.stepper-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 3px;
}

/* --- NAV BADGE --- */
.nav-item {
    position: relative;
    min-width: 56px;
    min-height: 56px;
    /* Touch target AA (mín 44) con margen */
    padding: 6px 4px;
    color: #475569;
    /* Contraste suficiente sobre fondo claro (AAA ~10:1) */
    transition: color 0.15s ease;
}

/* Total visible dentro del tab Carrito cuando hay items (reemplaza la bubble roja) */
.nav-cart-total {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary, #D32F2F);
    line-height: 1;
    margin-top: 2px;
    white-space: nowrap;
}

.nav-cart-total.hidden {
    display: none;
}

.nav-badge {
    position: absolute;
    top: 2px;
    right: 20px;
    /* Adjust based on icon centering */
    background: #D32F2F;
    /* Brand */
    color: white;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: 1px solid white;
}

.nav-badge.hidden {
    display: none;
}

/* Ocultar elementos legacy */
#cart-btn-top,
.add-btn-fab,
.fab-cart,
.cart-badge-fab {
    display: none !important;
}

/* Ocultar botones viejos */
#cart-btn-top {
    display: none;
}

.add-btn-fab {
    display: none;
}

.product-info {
    padding: 0;
    background: none;
}

/* Reset */



/* Remove old stuff */
.product-footer,
.add-control,
.product-price {
    display: none;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-img:hover {
    transform: scale(1.05);
}

.product-icon {
    width: 100%;
    aspect-ratio: 1/1;
    background: #f1f5f9;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    cursor: pointer;
}

.product-icon svg {
    width: 48px;
    height: 48px;
}

.product-info {
    padding: 10px 4px;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 13px;
    font-weight: 400;
}

/* Expanding Add Button */
.add-control {
    position: relative;
    height: 32px;
    min-width: 32px;
    background: inherit;
    border-radius: 16px;
}

.add-btn-circle {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.expanded-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #FF4747;
    color: white;
    border-radius: 20px;
    padding: 0 8px;
    height: 100%;
    box-shadow: 0 2px 8px rgba(255, 71, 71, 0.3);
}

.product-card.in-cart .expanded-controls .icon-btn-small {
    color: white;
}

.icon-btn-small {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.quantity-text {
    font-size: 14px;
    font-weight: 700;
    min-width: 12px;
    text-align: center;
}

/* Floating Cart Bubble */
.cart-bubble {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: #D32F2F;
    /* Brand */
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(211, 47, 47, 0.4);
    z-index: 1100;
    transition: all 0.3s ease;
}

.cart-bubble.hidden {
    bottom: -100px;
    opacity: 0;
    pointer-events: none;
}

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

#bubble-total {
    font-weight: 700;
    font-size: 18px;
}

#checkout-btn {
    background: white;
    color: #D32F2F;
    /* Brand Text */
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

/* Connectivity Toasts */
.connectivity-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    animation: slideInDown 0.4s ease-out;
}

.connectivity-toast.success {
    background: #27AE60;
    color: white;
}

.connectivity-toast.warning {
    background: #F39C12;
    color: white;
}

.connectivity-toast.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    transition: all 0.5s ease;
}

@keyframes slideInDown {
    from {
        transform: translateX(-50%) translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translate(-50%, 100px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Premium Action Buttons */
.action-btn,
.secondary-btn,
.save-btn,
.add-address-btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.3);
    /* Brand Shadow */
}

.action-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    background: #f1f5f9;
    color: #475569;
}

/* Bottom Nav */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: 10px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    gap: 2px;
}

.nav-item span {
    font-size: 11px;
    margin-top: 2px;
    font-weight: 500;
}

/* Pestaña activa: color primario + label bold + barrita superior */
.nav-item.active {
    color: var(--primary, #D32F2F);
}

.nav-item.active span {
    font-weight: 700;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--primary, #D32F2F);
    border-radius: 0 0 3px 3px;
}

/* Tab Carrito con ítems: fondo sutil + realza el total */
.nav-item.has-items {
    background: rgba(211, 47, 47, 0.08);
    border-radius: 12px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* PWA Promo Modal - Enhanced Design */
#pwa-modal {
    z-index: 5000;
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.6);
}

.pwa-card {
    background: white;
    width: 90%;
    max-width: 360px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    animation: pwaPopUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    position: relative;
}

.pwa-header {
    background: linear-gradient(135deg, #D32F2F 0%, #b71c1c 100%);
    /* Brand Gradient */
    padding: 30px 20px;
    color: white;
}

.pwa-icon-circle {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.2;
}

.pwa-subtitle {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
}

.pwa-body {
    padding: 24px;
}

.pwa-offer {
    background: #fff1f2;
    border: 2px dashed #fecdd3;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.offer-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #e11d48;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.offer-value {
    font-size: 18px;
    font-weight: 800;
    color: #be123c;
}

.install-btn {
    width: 100%;
    padding: 16px;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(30, 41, 59, 0.2);
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.install-btn:active {
    transform: scale(0.96);
}

.maybe-later {
    margin-top: 16px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
}

@keyframes pwaPopUp {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    padding: 24px;
    border-radius: 20px;
}

/* Cart Drawer — Mobile: full-screen slide-up (se siente como una ruta dedicada).
   Desktop: side panel clásico 450px (ver media query abajo). */
.cart-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    z-index: 3000;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.cart-drawer.open {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .cart-drawer {
        left: auto;
        right: 0;
        max-width: 450px;
        transform: translateX(100%);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    }
    .cart-drawer.open {
        transform: translateX(0);
    }
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.cart-overlay.open {
    opacity: 1;
    visibility: visible;
}

.cart-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.cart-items-container {
    padding: 20px;
    /* Removed scroll limit to show all items */
}

.checkout-form-container {
    padding: 0 20px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.form-title {
    margin: 20px 0 15px;
    font-size: 16px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.7;
}

.form-input,
.checkout-form-container input,
.checkout-form-container select,
.checkout-form-container textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-family: inherit;
    font-size: 14px;
    background: white;
}

.input-with-action {
    display: flex;
    gap: 8px;
}

.location-btn {
    background: #ff4747;
    color: white;
    border: none;
    border-radius: 8px;
    width: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.location-feedback {
    font-size: 11px;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.location-feedback.success {
    background: rgba(39, 174, 96, 0.1);
    color: #27AE60;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.location-feedback.warning {
    background: rgba(243, 156, 18, 0.1);
    color: #F39C12;
    border: 1px solid rgba(243, 156, 18, 0.2);
}

.location-feedback.error {
    background: rgba(231, 76, 60, 0.1);
    color: #E74C3C;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.checkout-form-container textarea {
    resize: none;
}

.cart-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.cart-item-img {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    object-fit: cover;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.cart-item-price {
    font-size: 13px;
    opacity: 0.7;
}

.cart-footer {
    padding: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: inherit;
}

.cart-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
}

.quantity-controls-drawer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 2px;
}

.qty-btn-drawer {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.qty-btn-drawer:active {
    transform: scale(0.95);
}

.qty-val-drawer {
    font-weight: 700;
    min-width: 16px;
    text-align: center;
    font-size: 14px;
}

.remove-btn-drawer {
    background: none;
    border: none;
    color: #FF4747;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 10px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn-drawer:hover {
    opacity: 1;
}

/* Account Drawer — Mobile: full-screen slide-up. Desktop: side panel. */
.account-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    z-index: 3000;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
}

.account-drawer.open {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .account-drawer {
        left: auto;
        right: 0;
        max-width: 450px;
        transform: translateX(100%);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    }
    .account-drawer.open {
        transform: translateX(0);
    }
}

.account-drawer-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: inherit;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Utility */
.hidden {
    display: none !important;
}

.cart-helper-text {

    font-size: 13px;
    color: #888;
    text-align: center;
    margin-bottom: 12px;
    line-height: 1.4;
    padding: 0 10px;
}

.cart-helper-text i {
    vertical-align: middle;
    margin-right: 4px;
    color: #27AE60;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
}

.btn-checkout-full {
    width: 100%;
    padding: 16px;
    background: #D32F2F;
    /* Brand */
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Load More Spacing */
#load-more-container {
    text-align: center;
    padding: 20px 20px 140px 20px;
    /* Huge bottom padding to clear bubble */
    display: none;
    margin-top: 20px;
}

.btn-checkout-full:active {
    transform: scale(0.98);
}

.empty-cart-msg {
    text-align: center;
    padding: 40px 20px;
    opacity: 0.5;
}

/* Account View */
.view-section {
    display: block;
    animation: fadeIn 0.3s ease;
    padding-top: 10px;
    padding-bottom: 80px;
}

.view-section.hidden {
    display: none;
}

.account-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--safe-padding);
}

.account-header {
    text-align: center;
    margin-bottom: 30px;
    margin-top: 10px;
}

.profile-icon-large {
    width: 80px;
    height: 80px;
    background: #f0f0f0;
    border-radius: 50%;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 24px;
}

.profile-icon-large i {
    width: 40px;
    height: 40px;
}

.account-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.account-card h3 {
    margin-bottom: 20px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Address Book */
.address-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid #f1f5f9;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
}

.address-item:active {
    transform: scale(0.99);
}

.address-content {
    flex: 1;
    cursor: pointer;
}

.delete-btn {
    background: #fee2e2;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-address-form {
    margin-top: 20px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.add-address-form.collapsed {
    display: none;
}

/* Global Form Inputs (Premium) */
.form-input,
input[type="text"],
input[type="tel"],
input[type="email"],
select,
textarea {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    width: 100%;
    transition: all 0.2s ease;
    outline: none;
    color: #334155;
}

.form-input:focus,
input[type="text"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 71, 71, 0.1);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
    display: block;
}

/* Remove old specific block if exists to avoid clutter */
.account-form input {
    /* handeled by global */
}

/* Order History */
.order-card {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.order-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

/* ==========================================================================
   Accesibilidad y polishing v409 (ver plan UX PDF 2026-04-23)
   ========================================================================== */

/* Contraste WCAG AA sobre imágenes: text-shadow reforzado */
.overlay-unit {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}

/* Empty states claros y legibles sobre cualquier fondo claro */
.empty-msg,
.empty-cart-msg p,
.empty-state p {
    color: #334155;
    /* Ratio ~10:1 sobre blanco */
    font-size: 14px;
}

/* Close icon del modal producto: touch target 44x44 */
.close-modal-icon {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* PWA modal: botón X en esquina (reemplaza cierre obligatorio por "Quizás más tarde") */
.pwa-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    z-index: 20;
}

.pwa-close-btn:hover,
.pwa-close-btn:active {
    background: rgba(0, 0, 0, 0.16);
}

.pwa-card {
    position: relative;
    /* Para posicionar el close absoluto */
}

/* Campos obligatorios: asterisco rojo tras el label */
.form-group label .required,
.form-group label[data-required="true"]::after {
    color: var(--primary, #D32F2F);
    font-weight: 700;
    margin-left: 3px;
}

/* Instalar App dentro de Mi Cuenta */
.install-app-inline-btn {
    display: none;
    gap: 8px;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    border-radius: 12px;
    background: var(--primary, #D32F2F);
    color: white;
    border: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.install-app-inline-btn.is-available {
    display: flex;
}

/* Sección legales y contacto de la tienda (footer dentro de Mi Cuenta) */
.legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 13px;
    padding-top: 8px;
}

.legal-links a {
    color: #475569;
    text-decoration: underline;
}

.legal-links a:hover {
    color: var(--primary, #D32F2F);
}

/* Destacado placeholder skeleton para imágenes del drawer/modal */
.cart-item-img[loading],
#modal-img-container img[loading] {
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: carnelio-skeleton 1.4s ease-in-out infinite;
}

@keyframes carnelio-skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Stock badge dentro del modal de producto */
.modal-stock-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
}

.modal-stock-badge.disponible {
    background: #dcfce7;
    color: #166534;
}

.modal-stock-badge.agotado {
    background: #fee2e2;
    color: #991b1b;
}

.modal-stock-badge.hidden {
    display: none;
}

/* Botón Agregar deshabilitado cuando el producto está agotado */
.action-btn.disabled,
.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

/* ==========================================================================
   FASE 4 — Header tripartito + bottom nav 5 tabs + hamburger drawer
   ========================================================================== */

/* Header sticky con 3 filas: top-bar / search / categorías */
.app-header {
    position: sticky;
    top: 0;
    background: var(--header-bg, #ffffff);
    box-shadow: var(--header-shadow, 0 2px 8px rgba(0, 0, 0, 0.04));
    padding-top: env(safe-area-inset-top, 0);
}

/* Fila 1: top bar */
.header-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    min-height: 56px;
}

.header-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--header-icon, #1e293b);
    position: relative;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.header-icon-btn:active {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(0.94);
}

.header-icon-btn svg {
    width: 24px;
    height: 24px;
}

/* Cart badge en el header */
.header-cart-btn {
    position: relative;
}

.header-cart-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--cart-badge-bg, #D32F2F);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--header-bg, #ffffff);
    box-sizing: content-box;
    pointer-events: none;
}

.header-cart-badge.hidden {
    display: none;
}

/* Brand center: img logo o texto fallback */
.header-brand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 44px;
    overflow: hidden;
}

.header-logo-img {
    max-height: 38px;
    max-width: 100%;
    width: auto;
    object-fit: contain;
    display: block;
}

.header-brand-fallback {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 17px;
    color: var(--header-brand-fg, #1e293b);
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Fila 2: search pill */
.header-search-row {
    padding: 4px 16px 8px;
}

.search-pill {
    background: var(--search-pill-bg, #f1f5f9);
    border-radius: 999px;
    padding: 10px 16px;
    box-shadow: none;
    margin-top: 0;
}

.search-pill input {
    font-size: 14px;
}

/* Fila 3: category nav (mantiene .category-scroll/.category-pill existente) */
.app-header .category-nav {
    padding: 0 12px 10px;
}

/* ==========================================================================
   Bottom Nav 5 tabs (Fase 4)
   ========================================================================== */
.app-bottom-nav {
    background: var(--bottom-nav-bg, #ffffff);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    height: auto;
    min-height: var(--nav-height);
}

.app-bottom-nav .nav-item {
    flex: 1;
    min-width: 0;
    padding: 8px 4px;
    touch-action: manipulation;
}

.app-bottom-nav .nav-item svg,
.app-bottom-nav .nav-item i {
    width: 22px;
    height: 22px;
}

.app-bottom-nav .nav-item span {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    margin-top: 4px;
}

/* ==========================================================================
   Hamburger Menu Drawer (Fase 4)
   ========================================================================== */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3499;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    backdrop-filter: blur(2px);
}

.menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

.menu-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 340px);
    background: var(--menu-drawer-bg, #ffffff);
    color: var(--menu-drawer-fg, #1e293b);
    z-index: 3500;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.menu-drawer.open {
    transform: translateX(0);
}

.menu-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--menu-divider, rgba(0, 0, 0, 0.06));
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
}

.menu-drawer-header h3 {
    font-size: 17px;
    font-weight: 800;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.menu-drawer-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    flex: 1;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--menu-drawer-fg, #1e293b);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background-color 0.15s ease;
    touch-action: manipulation;
}

.menu-link:active,
.menu-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

.menu-link svg,
.menu-link i {
    width: 20px;
    height: 20px;
    color: var(--menu-link-icon, #475569);
    flex-shrink: 0;
}

.menu-link-secondary {
    font-size: 13px;
    font-weight: 500;
    color: var(--menu-link-secondary-fg, #64748b);
    padding: 10px 20px;
}

.menu-link-secondary svg,
.menu-link-secondary i {
    width: 16px;
    height: 16px;
    color: var(--menu-link-secondary-fg, #64748b);
}

.menu-divider {
    height: 1px;
    background: var(--menu-divider, rgba(0, 0, 0, 0.06));
    margin: 8px 16px;
}

.menu-drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--menu-divider, rgba(0, 0, 0, 0.06));
    text-align: center;
    color: var(--menu-link-secondary-fg, #64748b);
    font-size: 12px;
}

/* Reduced motion: desactivar transitions del drawer */
@media (prefers-reduced-motion: reduce) {
    .menu-drawer,
    .menu-overlay {
        transition: none;
    }
}

/* ==========================================================================
   FASE 5 — Pills con íconos + Cards rediseñadas (CarnesYa) + Vista Categorías
   ========================================================================== */

/* Pills con ícono (Fase 5) */
.category-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    /* deja espacio para ícono */
}

.cat-pill-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: currentColor;
}

.cat-pill-icon svg {
    width: 18px;
    height: 18px;
    color: currentColor;
}

.cat-pill-label {
    line-height: 1;
}

/* Pill "Más" (apertura de vista categorías) */
.cat-pill-more {
    border-style: dashed !important;
    border-color: var(--cat-pill-more-border, rgba(0, 0, 0, 0.2)) !important;
}

/* ==========================================================================
   Cards Fase 5 (.pc-v2) - estructura: imagen arriba con badge+heart, info abajo
   ========================================================================== */

/* La grid actual usa aspect-ratio 1/1 en .product-card (legacy). Sobrescribimos
   solo cuando la card tiene la clase .pc-v2 (Fase 5). */
.product-card.pc-v2 {
    aspect-ratio: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--card-border, rgba(0, 0, 0, 0.06));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.product-card.pc-v2:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.product-card.pc-v2.in-cart {
    border-color: var(--primary, #D32F2F);
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.15), 0 4px 14px rgba(211, 47, 47, 0.18);
}

/* Container de imagen: cuadrado */
.pc-v2-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--img-fallback-bg, #f1f5f9);
    overflow: hidden;
}

.pc-v2-image-container .product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-img-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--img-fallback-fg, #cbd5e1);
}

.product-img-fallback i,
.product-img-fallback svg {
    width: 48px;
    height: 48px;
}

/* Cuando hay imagen, el fallback queda detrás (placeholder mientras carga) */
.pc-v2-image-container:not(.no-img) .product-img-fallback {
    z-index: 0;
}

.pc-v2-image-container .product-image {
    position: relative;
    z-index: 1;
}

/* Badge de etiqueta (top-left)
   Fase 8: text-shadow sutil + outline blanco para separar la pill de imágenes
   claras (mejor legibilidad sin alterar la paleta de colores del badge). */
.product-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.55),
        0 2px 5px rgba(0, 0, 0, 0.18);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
    pointer-events: none;
}

/* Heart de favoritos (top-right) */
.product-fav {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, background-color 0.15s ease;
    touch-action: manipulation;
    color: #94a3b8;
}

.product-fav svg,
.product-fav i {
    width: 20px;
    height: 20px;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.product-fav:active {
    transform: scale(0.92);
}

.product-fav.is-active {
    background: #ffffff;
    color: var(--primary, #D32F2F);
}

.product-fav.is-active svg,
.product-fav.is-active i {
    fill: var(--primary, #D32F2F);
    stroke: var(--primary, #D32F2F);
}

/* Bottom: nombre + presentación + precio + botón */
.pc-v2-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px 12px;
    flex: 1;
}

.pc-v2-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pc-v2-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--card-name-fg, #1e293b);
    margin: 0;
    /* Permitir 2 líneas para nombres largos */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pc-v2-presentacion {
    font-size: 11px;
    font-weight: 500;
    color: var(--card-meta-fg, #64748b);
    line-height: 1;
}

.pc-v2-price {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary, #D32F2F);
    margin-top: 4px;
    line-height: 1.1;
}

.pc-v2-action {
    flex-shrink: 0;
}

/* Reset legacy .add-btn dentro de cards pc-v2 (no absolute, no border-radius:50%) */
.product-card.pc-v2 .add-btn {
    position: static;
    border-radius: 10px;
    background: var(--primary, #D32F2F);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(211, 47, 47, 0.28);
}

.product-card.pc-v2 .stepper-content {
    position: static;
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

/* Botón + cuadrado 44x44 (touch target) */
.pc-v2-add-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: var(--primary, #D32F2F);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(211, 47, 47, 0.28);
    overflow: hidden;
    transition: transform 0.1s ease, width 0.25s ease;
    touch-action: manipulation;
    position: relative;
}

.pc-v2-add-btn:active {
    transform: scale(0.94);
}

.pc-v2-add-btn .btn-icon-plus {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.pc-v2-add-btn .btn-icon-plus svg,
.pc-v2-add-btn .btn-icon-plus i {
    width: 20px;
    height: 20px;
    color: #ffffff;
    stroke-width: 2.5;
}

.pc-v2-add-btn .stepper-content {
    display: none;
    align-items: center;
    gap: 6px;
    color: #ffffff;
    font-weight: 700;
    padding: 0 8px;
}

.pc-v2-add-btn .stepper-content .stepper-btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.pc-v2-add-btn .stepper-content .stepper-btn svg,
.pc-v2-add-btn .stepper-content .stepper-btn i {
    width: 14px;
    height: 14px;
    color: #ffffff;
}

.pc-v2-add-btn .stepper-content .stepper-val {
    min-width: 14px;
    text-align: center;
    font-size: 13px;
}

/* Estado expandido (hay item en carrito) */
.pc-v2-add-btn.expanded {
    width: 110px;
}

.pc-v2-add-btn.expanded .btn-icon-plus {
    display: none;
}

.pc-v2-add-btn.expanded .stepper-content {
    display: flex;
    width: 100%;
    justify-content: space-between;
}

/* Override del grid para que pc-v2 no fuerce aspect-ratio del contenedor padre */
.product-grid {
    grid-auto-rows: auto;
}

/* ==========================================================================
   Vista Categorías (Fase 5)
   ========================================================================== */
.cat-view-wrap {
    padding: 8px 8px 24px;
}

.cat-view-header {
    margin-bottom: 16px;
    padding: 0 8px;
}

.cat-view-title {
    font-size: 20px;
    font-weight: 800;
    margin: 0 0 4px;
    color: var(--card-name-fg, #1e293b);
}

.cat-view-sub {
    margin: 0;
    font-size: 13px;
    color: var(--card-meta-fg, #64748b);
}

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

@media (min-width: 600px) {
    .cat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) {
    .cat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.cat-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--card-border, rgba(0, 0, 0, 0.06));
    border-radius: 14px;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    color: var(--card-name-fg, #1e293b);
    aspect-ratio: 1 / 0.9;
    touch-action: manipulation;
}

.cat-card:hover {
    border-color: var(--primary, #D32F2F);
    box-shadow: 0 6px 14px rgba(211, 47, 47, 0.08);
}

.cat-card:active {
    transform: scale(0.97);
}

.cat-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: var(--primary, #D32F2F);
}

.cat-card-icon svg {
    width: 40px;
    height: 40px;
    color: currentColor;
}

.cat-card-name {
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-card-count {
    font-size: 11px;
    color: var(--card-meta-fg, #64748b);
    font-weight: 500;
}

/* ==========================================================================
   Hero Carousel + Sección "Más vendidos" (Fase 6)
   ========================================================================== */

/* Hero wrapper: vacio por defecto (display:none inline en el HTML); JS lo activa */
.hero-carousel-wrap {
    margin: 12px 0 18px;
    padding: 0;
}

.hero-carousel {
    position: relative;
    overflow: hidden;
}

.hero-track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    /* proximity (no mandatory): evita el bug de snap brusco en iOS Safari */
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding: 0 16px;
    outline: none;
}

.hero-track::-webkit-scrollbar {
    display: none;
}

.hero-track:focus-visible {
    box-shadow: inset 0 0 0 2px var(--primary, #D32F2F);
    border-radius: 16px;
}

.hero-slide {
    flex: 0 0 100%;
    scroll-snap-align: start;
    position: relative;
    min-height: 180px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-bg, #f1f5f9);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}

@media (min-width: 600px) {
    .hero-slide {
        flex: 0 0 calc(100% - 0px);
        min-height: 240px;
    }
}

.hero-slide-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hero-slide-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.55) 100%);
    pointer-events: none;
}

.hero-slide-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 20px;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2;
}

/* Slide generico (sin imagen) → centramos el contenido */
.hero-slide--generico .hero-slide-content {
    inset: 0;
    bottom: auto;
    padding: 28px 20px;
    align-items: flex-start;
    justify-content: center;
    background: transparent;
}

.hero-slide-title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.15;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    letter-spacing: -0.01em;
}

.hero-slide-subtitle {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.94;
    line-height: 1.35;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.hero-slide-cta {
    align-self: flex-start;
    margin-top: 4px;
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    background: var(--primary, #D32F2F);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    touch-action: manipulation;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hero-slide-cta:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.30);
    transform: translateY(-1px);
}

.hero-slide-cta:active {
    transform: scale(0.97);
}

/* Slide producto: el subtitulo (precio) lo destacamos con backdrop sutil */
.hero-slide--producto .hero-slide-subtitle {
    font-weight: 700;
    font-size: 15px;
}

/* Dots */
.hero-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    padding: 0 16px;
}

.hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    border: none;
    padding: 0;
    background: var(--card-border, rgba(0, 0, 0, 0.18));
    cursor: pointer;
    transition: width 0.2s ease, background 0.2s ease;
    touch-action: manipulation;
}

.hero-dot.is-active {
    width: 22px;
    background: var(--primary, #D32F2F);
}

.hero-dot:focus-visible {
    outline: 2px solid var(--primary, #D32F2F);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    .hero-track,
    .hero-slide-cta,
    .hero-dot {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Sección "Más vendidos" (Fase 6)
   ========================================================================== */
.mas-vendidos-section {
    margin: 8px 0 16px;
    padding: 0 14px;
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 8px;
}

.section-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--card-name-fg, #1e293b);
}

.section-link {
    background: none;
    border: none;
    padding: 4px 6px;
    color: var(--primary, #D32F2F);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    touch-action: manipulation;
}

.section-link:hover {
    text-decoration: underline;
}

.section-link:focus-visible {
    outline: 2px solid var(--primary, #D32F2F);
    outline-offset: 2px;
}

/* Grid 2x2 mobile, hereda del .product-grid base */
.mas-vendidos-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
    .mas-vendidos-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================================
   Vista Favoritos + Vista Pedidos (Fase 7)
   ============================================================ */

/* Header común para ambas vistas */
.fav-view-header,
.ped-view-header {
    grid-column: 1 / -1;
    padding: 4px 4px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--card-border, #e2e8f0);
}
.fav-view-title,
.ped-view-title {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    letter-spacing: -0.01em;
}
.fav-view-sub,
.ped-view-sub {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
}

/* Warning modo privado (compartido) */
.ped-private-warn,
.fav-private-warn {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 0 14px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.82rem;
    line-height: 1.35;
}
.ped-private-warn svg,
.ped-private-warn i,
.fav-private-warn svg,
.fav-private-warn i {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #ea580c;
}

/* ---------- Vista Favoritos ---------- */
.fav-view {
    display: contents; /* deja que los hijos respeten el grid principal */
}
.fav-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    grid-column: 1 / -1;
}
@media (min-width: 768px) {
    .fav-grid { grid-template-columns: repeat(4, 1fr); }
}
.fav-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted, #64748b);
}
.fav-empty i,
.fav-empty svg {
    width: 56px;
    height: 56px;
    opacity: 0.3;
    color: var(--primary, #D32F2F);
    margin-bottom: 12px;
}
.fav-empty h3 {
    margin: 4px 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}
.fav-empty p {
    margin: 0 auto 18px;
    max-width: 280px;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ---------- Vista Pedidos ---------- */
#catalog-grid.view-pedidos {
    /* En esta vista no usamos grid de cards; dejamos que .ped-view sea bloque */
    display: block;
}
.ped-view {
    width: 100%;
}
.ped-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}
.ped-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--card-border, #e2e8f0);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ped-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.ped-date {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    font-weight: 500;
}
.ped-total {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary, #D32F2F);
    letter-spacing: -0.01em;
}
.ped-items {
    font-size: 0.88rem;
    color: var(--text-primary, #1f2937);
    line-height: 1.4;
    word-wrap: break-word;
}
.ped-extra {
    color: var(--text-muted, #64748b);
    font-style: normal;
    font-size: 0.8rem;
}
.ped-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--card-border, #e2e8f0);
}
.ped-id {
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    letter-spacing: 0.02em;
}
.ped-repeat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--primary, #D32F2F);
    background: transparent;
    color: var(--primary, #D32F2F);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.ped-repeat-btn svg,
.ped-repeat-btn i {
    width: 14px;
    height: 14px;
}
.ped-repeat-btn:hover {
    background: var(--primary, #D32F2F);
    color: #fff;
}
.ped-repeat-btn:active {
    transform: scale(0.96);
}
.ped-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted, #64748b);
}
.ped-empty i,
.ped-empty svg {
    width: 56px;
    height: 56px;
    opacity: 0.3;
    color: var(--primary, #D32F2F);
    margin-bottom: 12px;
}
.ped-empty h3 {
    margin: 4px 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}
.ped-empty p {
    margin: 0 auto 18px;
    max-width: 280px;
    font-size: 0.9rem;
    line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
    .ped-repeat-btn {
        transition: none;
    }
}