*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --header-h: 56px;
}

/* En mobile el header es más alto (64px) */
@media (max-width: 768px) {
    :root {
        --header-h: 64px;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
}

body.mobile-subtotales-open {
    overflow: hidden;
}

body.optimizer-modal-open,
body.map-modal-open,
body.shipping-modal-open {
    overflow: hidden;
    overscroll-behavior: contain;
}

body.simple-page {
    padding: 0;
}

body.simple-page main {
    flex: 1;
    width: 100%;
    max-width: min(900px, 100vw);
    margin: 80px auto 80px;
    padding: 0 clamp(16px, 4vw, 32px);
    box-sizing: border-box;
}

body.simple-page main .page-card {
    width: min(100%, calc(100vw - clamp(32px, 8vw, 48px)));
    max-width: 680px;
    margin: 0 auto;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1), 0 0 0 1px rgba(99, 102, 241, 0.05);
    box-sizing: border-box;
}

body.simple-page .page-title {
    text-align: center;
    margin: 0 0 20px;
    font-size: 1.6em;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

body.simple-page .account-user-email {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 24px;
    padding: 14px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.06) 100%);
    color: #4338ca;
    font-size: 0.95em;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

body.simple-page .account-user-email span {
    font-weight: 500;
    opacity: 0.8;
}

body.simple-page .account-user-email strong {
    font-size: 1em;
    color: #1f2937;
}

body.simple-page .page-card *,
body.simple-page .page-card *::before,
body.simple-page .page-card *::after {
    box-sizing: border-box;
    max-width: 100%;
}

body.simple-page #form-cp {
    display: grid;
    grid-template-columns: max-content max-content;
    gap: 8px;
    align-items: center;
    justify-content: start;
}

body.simple-page #input-cp,
body.simple-page #input-pickup-radius {
    padding: 8px 12px;
    width: 7ch;
    height: 38px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 10px;
    font-size: 0.95em;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.simple-page #input-cp:focus,
body.simple-page #input-pickup-radius:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Quitar spinners del input number para que se vea igual al CP */
body.simple-page #input-pickup-radius::-webkit-outer-spin-button,
body.simple-page #input-pickup-radius::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

body.simple-page #input-pickup-radius {
    -moz-appearance: textfield;
    appearance: textfield;
}

body.simple-page #btn-aplicar-cp {
    justify-self: start;
    height: 38px;
    padding: 8px 16px;
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    transition: all 0.2s ease;
}

body.simple-page #btn-aplicar-cp:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

body.simple-page #cp-msg {
    grid-column: 1 / -1;
}

body.simple-page #cuenta-preferencias label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.95em;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

body.simple-page #cuenta-preferencias label input[type="checkbox"] {
    flex-shrink: 0;
    margin-top: 2px;
}

body.simple-page #cuenta-preferencias label:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.2);
}

body.simple-page #cuenta-preferencias input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6366f1;
    cursor: pointer;
}

body.simple-page #cuenta-preferencias input[type="number"] {
    padding: 6px;
    width: 90px;
    font-size: 0.95em;
}

/* (dimensiones de #input-pickup-radius están unificadas arriba) */

/* Preferencias: radio (label arriba; input+botón en la misma línea) */
body.simple-page #cuenta-preferencias .pickup-radius-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.simple-page #cuenta-preferencias .pickup-radius-label {
    font-size: 0.95em;
}

body.simple-page #cuenta-preferencias .pickup-radius-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

body.simple-page #cuenta-preferencias .pickup-radius-controls #btn-save-radius {
    width: auto;
    height: 38px;
    padding: 8px 16px;
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    transition: all 0.2s ease;
}

body.simple-page #cuenta-preferencias .pickup-radius-controls #btn-save-radius:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

body.simple-page #radius-msg,
body.simple-page #cp-msg {
    font-size: 0.88em;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

body.simple-page .section-spaced {
    margin-top: 28px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 16px;
}

body.simple-page .section-spaced:first-of-type {
    margin-top: 0;
}

body.simple-page .section-title {
    margin: 0 0 14px;
    font-size: 1.1em;
    font-weight: 700;
    color: #4f46e5;
}

body.simple-page .section-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

body.simple-page .faq-list {
    display: grid;
    gap: 14px;
}

body.simple-page .faq-item {
    margin: 0;
    padding: 16px 18px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

body.simple-page .faq-item:last-child {
    border-bottom: none;
}

body.simple-page .faq-item h3 {
    margin: 0 0 6px;
    font-size: 1.05em;
    color: #1f2937;
    text-align: left;
}

body.simple-page .faq-item p {
    margin: 0;
    color: #374151;
    line-height: 1.55;
}

@media (max-width: 768px) {
    body.simple-page main {
        margin: 72px auto 72px;
        padding: 0 16px;
    }

    body.simple-page main .page-card {
        padding: 24px;
        border-radius: 18px;
        box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
        width: 100%;
        max-width: calc(100vw - 32px);
    }

    /* En móvil, asegurar que no se estire de más la 2da columna */
    body.simple-page #form-cp {
        grid-template-columns: auto auto;
    }

    body.simple-page #cuenta-preferencias .pickup-radius-controls {
        gap: 6px;
    }

    .inputs-area .grid-header>* {
        text-align: left;
        padding: 4px 0;
    }

    .inputs-area .grid-row>* {
        width: 100%;
    }

    .inputs-area .grid-row .cell input[type="number"] {
        width: 100%;
        text-align: left;
    }

    .budget-row {
        flex-direction: column;
        align-items: stretch;
    }

    .budget-row input[type="number"] {
        width: 100%;
        text-align: left;
    }

    .results-box:not(#optimizer-results) {
        max-height: 55vh;
        -webkit-overflow-scrolling: touch;
    }

    /* Optimizador: mantener columnas en móvil (no apilar en 1 columna) */
    #optimizer-modal .inputs-area .grid-header,
    #optimizer-modal .inputs-area .grid-row {
        grid-template-columns: minmax(0, 1fr) clamp(84px, 22vw, 120px) clamp(96px, 26vw, 150px);
    }

    #optimizer-modal .inputs-area .grid-header>* {
        text-align: center;
        padding: 0;
    }
}

@media (max-width: 640px) {
    body.simple-page #form-cp {
        grid-template-columns: auto auto;
    }

    body.simple-page #cuenta-preferencias label {
        align-items: flex-start;
        flex-direction: row;
        gap: 8px;
    }

    body.simple-page #cuenta-preferencias input[type="number"]:not(#input-pickup-radius) {
        width: 100%;
    }

    /* El botón Guardar del radio va al lado del input (no full-width) */
    body.simple-page #cuenta-preferencias label #btn-save-radius {
        width: 100%;
    }

    body.simple-page #cuenta-preferencias .pickup-radius-controls #btn-save-radius {
        width: auto;
    }
}

body.simple-page .auth-page {
    width: 100%;
}

body.simple-page .page-card.auth-card {
    max-width: 980px;
}

body.simple-page .auth-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 26px;
    align-items: start;
}

body.simple-page .auth-layout.auth-layout-single {
    grid-template-columns: 1fr;
    max-width: 720px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    body.simple-page .auth-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

body.simple-page .auth-hero {
    padding: 8px 6px;
}

body.simple-page .auth-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #4338ca;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14) 0%, rgba(139, 92, 246, 0.10) 100%);
    border: 1px solid rgba(99, 102, 241, 0.18);
}

@media (max-width: 900px) {
    body.simple-page .auth-badge {
        display: flex;
        width: fit-content;
        margin: 0 auto;
    }
}

body.simple-page .auth-title {
    margin: 14px 0 10px;
    font-size: 1.9em;
    line-height: 1.15;
    font-weight: 800;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

body.simple-page .auth-subtitle {
    margin: 0 0 18px;
    color: #4b5563;
    line-height: 1.6;
    font-size: 1.02em;
}

body.simple-page .auth-features {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0 0 18px;
}



body.simple-page .auth-feature {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.12);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

body.simple-page .auth-feature-title {
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

body.simple-page .auth-feature-desc {
    color: #4b5563;
    line-height: 1.5;
}

body.simple-page .auth-note {
    color: #4338ca;
    font-weight: 600;
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.10) 0%, rgba(139, 92, 246, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

body.simple-page .auth-panel {
    border-radius: 18px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(99, 102, 241, 0.12);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

body.simple-page .auth-panel-title {
    margin: 0 0 16px;
    padding-bottom: 10px;
    font-size: 1.2em;
    font-weight: 800;
    color: #1f2937;
    text-align: center;
    letter-spacing: -0.01em;
    border-bottom: 1px solid rgba(99, 102, 241, 0.14);
}

body.simple-page .auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

body.simple-page .auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

body.simple-page .auth-field span {
    font-weight: 600;
    color: #374151;
    font-size: 0.92em;
}

body.simple-page .auth-field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.22);
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.simple-page .auth-field input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

body.simple-page .auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 42px;
    padding: 10px 14px;
    font-size: 1em;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(99, 102, 241, 0.28);
    transition: all 0.18s ease;
}

body.simple-page .auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 34px rgba(99, 102, 241, 0.36);
}

body.simple-page .auth-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.28);
}

body.simple-page .auth-alt {
    margin-top: 14px;
    font-size: 0.95em;
    color: #4b5563;
    text-align: center;
}

body.simple-page .auth-alt a {
    color: #4f46e5;
    font-weight: 700;
    text-decoration: none;
}

body.simple-page .auth-alt a:hover {
    text-decoration: underline;
}

body.simple-page .flash {
    margin: 10px 0 12px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.95em;
    font-weight: 600;
}

body.simple-page .flash.error {
    background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%);
    color: #b91c1c;
    border: 1px solid rgba(185, 28, 28, 0.22);
}

body.simple-page .flash.ok {
    background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
    color: #047857;
    border: 1px solid rgba(4, 120, 87, 0.22);
}

/* “Padding” visual sin mover el layout: un fondo expandido alrededor */
.boton-ia {
    width: 100%;
    background-color: #007bff;
    margin-bottom: 10px;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
}

.boton-ia:hover {
    background-color: #0056b3;
}

.recomendacion-ia {
    min-height: 150px;
    background-color: #f0f8ff;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.95em;
}

aside.subtotales-panel {
    position: fixed;
    left: 0;
    top: 56px;
    width: 240px;
    height: calc(100% - 56px);
    background: linear-gradient(180deg, #ffffff 0%, #f4f6ff 100%);
    border-right: 1px solid rgba(99, 102, 241, 0.15);
    padding: 20px 16px 24px;
    box-shadow: 8px 0 32px rgba(99, 102, 241, 0.1);
    overflow-y: auto;
    transition: transform 0.18s ease;
}

aside.subtotales-panel.collapsed {
    transform: translateX(-100%);
    pointer-events: none;
    overflow: hidden;
}

aside.subtotales-panel h3 {
    text-align: center;
    margin: 0 0 16px 0;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tienda-subtotal {
    margin-bottom: 14px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 16px;
    padding: 14px 14px 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    text-align: left;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.08);
}

.tienda-subtotal:hover {
    background: linear-gradient(180deg, #f8faff 0%, #f0f2ff 100%);
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.15);
}

.tienda-subtotal .nombre-tienda {
    font-weight: 700;
    font-size: 0.95em;
    color: #1f2937;
    display: block;
    margin-bottom: 8px;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.tienda-subtotal .subtotal-precio {
    font-size: 1.05em;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.tienda-subtotal .selected-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78em;
    color: #6b7280;
    margin-top: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: 20px;
    font-weight: 500;
}

.selected-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 4px 0;
    padding: 6px 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 10px;
    transition: all 0.15s ease;
}

.selected-item:hover {
    background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
    border-color: rgba(99, 102, 241, 0.25);
}

.selected-item .sucursal-inline {
    display: block;
    font-size: 0.72em;
    font-weight: 600;
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
}

.selected-item .item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.selected-item .item-name {
    flex: 1;
    min-width: 0;
    font-size: 0.85em;
    color: #374151;
    font-weight: 500;
    line-height: 1.3;
    word-break: break-word;
}

.selected-item .promo-inline {
    display: inline-block;
    font-size: 0.72em;
    font-weight: 600;
    color: #ea580c;
    background: rgba(249, 115, 22, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.selected-item .quantity-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.selected-item .quantity-controls .quantity-btn {
    width: 20px;
    height: 20px;
    border-radius: 999px;
}

.selected-item .quantity-controls .quantity-display {
    min-width: 20px;
    font-size: 0.82em;
}

.quantity-btn {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.quantity-btn:hover {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-color: #6366f1;
    color: #fff;
}

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

.quantity-display {
    min-width: 24px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9em;
    color: #4f46e5;
}

main {
    flex: 1;
    margin: 64px 0 0 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    transition: margin-left 0.18s ease;
}

body[data-has-results="1"] main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
}

.aside-hidden main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

h1 {
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
}

h2.store-header {
    font-size: 1.3em;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    text-align: center;
}

h3.product-header {
    display: inline-block;
    margin: 10px auto 14px auto;
    padding: 4px 14px;
    color: #4f46e5;
    font-weight: 600;
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
}

textarea {
    width: 100%;
    max-width: 600px;
    display: block;
    margin: 0 auto 20px auto;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    font-size: 1em;
    transition: all 0.18s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.06);
}

textarea:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), 0 4px 16px rgba(99, 102, 241, 0.08);
}

#productos-textarea {
    margin-bottom: 0;
}

/* ===================== Search Hero Section ===================== */
.search-hero {
    max-width: 760px;
    margin: 0 auto 32px;
    padding: 32px 28px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.08);
    transition: max-width 0.24s ease, box-shadow 0.24s ease;
}

.search-hero.ean-expanded {
    max-width: 1040px;
    box-shadow: 0 10px 36px rgba(99, 102, 241, 0.11);
}

.search-hero-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
    text-align: left;
}

.search-hero-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.search-hero-icon svg {
    color: #fff;
}

.search-hero-text {
    flex: 1;
}

.search-hero h1 {
    margin: 0 0 6px;
    text-align: left;
    font-size: 1.75em;
}

.search-hero-subtitle {
    margin: 0;
    font-size: 1em;
    color: #6b7280;
    line-height: 1.4;
}

.search-inputs-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    margin-bottom: 20px;
}

.search-inputs-grid.ean-open {
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: stretch;
}

.search-textarea-wrapper {
    margin-bottom: 0;
}

.search-textarea-wrapper textarea {
    margin-bottom: 0;
    resize: vertical;
    min-height: 220px;
    height: 100%;
}

.ean-scanner-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-self: end;
    align-self: start;
    gap: 8px;
}

.search-inputs-grid.ean-open .ean-scanner-panel {
    width: 100%;
    align-items: stretch;
    justify-self: stretch;
}

.ean-scanner-body {
    display: none;
    width: min(100%, 360px);
    background: linear-gradient(180deg, #fbfcff 0%, #f1f5ff 100%);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.08);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.search-inputs-grid.ean-open .ean-scanner-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.ean-scanner-panel.scanner-running .ean-scanner-body {
    border-color: rgba(22, 163, 74, 0.4);
    box-shadow: 0 8px 26px rgba(22, 163, 74, 0.16);
}

.ean-scanner-panel.scanner-detected .ean-scanner-body {
    animation: scannerPulse 0.5s ease;
}

.ean-scanner-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.ean-scanner-head h3 {
    margin: 0;
    font-size: 1rem;
    color: #273b7a;
}

.ean-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.ean-scan-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(79, 70, 229, 0.35);
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #3246a8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ean-scan-icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(50, 70, 168, 0.2);
}

.ean-scan-icon-btn.scanner-active {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    border-color: rgba(22, 163, 74, 0.45);
}

.ean-scan-icon-btn.scanner-busy {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    color: #b45309;
    border-color: rgba(234, 88, 12, 0.35);
    cursor: wait;
}

.search-inputs-grid.ean-open .ean-scan-icon-btn {
    align-self: flex-end;
}

.ean-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.ean-status-idle {
    background: #eef2ff;
    color: #5b6aa5;
}

.ean-status-running {
    background: #e8f8ed;
    color: #0f8a40;
}

.ean-status-ok {
    background: #dcfce7;
    color: #146c2e;
}

.ean-status-error {
    background: #fee2e2;
    color: #b42318;
}

.ean-scanner-preview-wrap {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border: 1px solid rgba(15, 23, 42, 0.22);
}

.ean-scanner-preview {
    width: 100%;
    height: 224px;
}

.ean-scanner-preview video,
.ean-scanner-preview canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.ean-scanner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
}

.ean-scanline {
    display: none;
    position: absolute;
    left: 6%;
    width: 88%;
    height: 2px;
    background: linear-gradient(90deg, rgba(34, 197, 94, 0) 0%, rgba(74, 222, 128, 0.95) 45%, rgba(34, 197, 94, 0) 100%);
    box-shadow: 0 0 14px rgba(74, 222, 128, 0.9);
    animation: scannerLine 2.1s linear infinite;
}

.ean-scanner-panel.scanner-running .ean-scanline {
    display: block;
}

.ean-scanner-message {
    margin: 0;
    font-size: 0.82rem;
    color: #475569;
    min-height: 1.2em;
}

.ean-scanner-last {
    background: #eff6ff;
    border: 1px dashed #93c5fd;
    border-radius: 10px;
    padding: 7px 10px;
    color: #1d4ed8;
    font-size: 0.82rem;
    text-align: center;
    font-weight: 600;
}

@keyframes scannerLine {
    0% {
        top: 12%;
    }
    50% {
        top: 84%;
    }
    100% {
        top: 12%;
    }
}

@keyframes scannerPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.015);
    }
    100% {
        transform: scale(1);
    }
}

.textarea-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #9ca3af;
    font-size: 0.85em;
}

.textarea-hint svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.search-primary-actions {
    text-align: center;
    margin: 0;
}

.buscar-btn-hero {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px !important;
    font-size: 1.05rem !important;
}

.buscar-btn-hero svg {
    flex-shrink: 0;
}

/* ===================== Results Actions Bar ===================== */
.results-actions-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: fit-content;
    margin: 0 auto 24px;
    padding: 16px 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.06);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.18s ease;
}

.action-btn-secondary {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.action-btn-secondary:hover {
    background: #e5e7eb;
    color: #1f2937;
    transform: translateY(-1px);
}

.action-btn-secondary svg {
    opacity: 0.7;
}

.action-btn-secondary:hover svg {
    opacity: 1;
}

/* Vista Toggle Group */
.vista-toggle-group {
    display: flex;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.vista-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.18s ease;
}

.vista-btn:hover:not(.vista-btn-active) {
    background: rgba(99, 102, 241, 0.08);
    color: #4f46e5;
}

.vista-btn-active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.vista-btn svg {
    flex-shrink: 0;
}

/* Quota Indicator Premium */
.quota-indicator {
    max-width: 680px;
    margin: 0 auto 20px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 14px;
    color: #4f46e5;
    font-size: 0.92em;
}

.quota-indicator strong {
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Flash Messages Premium */
.flash-messages {
    max-width: 680px;
    margin: 0 auto 20px;
}

.flash {
    margin-bottom: 10px;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.flash.error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fecaca;
    color: #991b1b;
}

.flash.ok {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #bbf7d0;
    color: #166534;
}

.flash.info {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #bfdbfe;
    color: #1e40af;
}

/* Vista toggle legacy - ocultar */
.vista-toggle,
.search-secondary-actions {
    display: none;
}

@media (max-width: 768px) {
    .search-hero {
        margin: 0 -4px 24px;
        padding: 24px 20px;
        border-radius: 20px;
        max-width: none;
    }

    .search-hero.ean-expanded {
        max-width: none;
    }

    .search-hero-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 16px;
    }

    .search-hero-icon {
        width: 56px;
        height: 56px;
        border-radius: 14px;
    }

    .search-hero-icon svg {
        width: 28px;
        height: 28px;
    }

    .search-hero h1 {
        text-align: center;
        font-size: 1.5em;
    }

    .search-hero-subtitle {
        font-size: 0.95em;
    }

    .search-inputs-grid {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        margin-bottom: 16px;
    }

    .search-inputs-grid.ean-open {
        grid-template-columns: 1fr;
    }

    .search-textarea-wrapper textarea {
        min-height: 150px;
    }

    .ean-scanner-body {
        max-width: none;
        padding: 12px;
    }

    .ean-scanner-preview {
        height: 198px;
    }

    .ean-scanner-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .results-actions-bar {
        width: calc(100% + 8px);
        margin-left: -4px;
        margin-right: -4px;
        gap: 12px;
        padding: 14px 16px;
    }

    .vista-toggle-group {
        width: 100%;
    }

    .vista-btn {
        flex: 1;
        justify-content: center;
        padding: 12px 12px;
    }

    .action-btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .buscar-btn-hero {
        width: 100%;
        padding: 14px 24px !important;
    }
}

.search-primary-actions,
.search-secondary-actions {
    text-align: center;
    margin: 8px 0;
}

/* Separación extra entre Buscar y Vaciar selección */
.search-primary-actions {
    margin-bottom: 0;
}

.search-secondary-actions {
    margin-top: 0;
    margin-bottom: 14px;
}

button.buscar-btn {
    margin: 0 5px;
    padding: clamp(10px, 2vw, 14px) clamp(20px, 4vw, 28px);
    font-size: clamp(0.9rem, 2.1vw, 1rem);
    line-height: 1.25;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    white-space: normal;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
    transition: all 0.18s ease;
}

button.buscar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.4);
}

button.buscar-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.25);
}

.sticky-optimizer {
    position: sticky;
    top: 10px;
    z-index: 10;
}

.vista-toggle {
    text-align: center;
    margin: 10px 0 20px 0;
}

.tienda,
.producto-row {
    margin-bottom: 30px;
    text-align: center;
}

.producto-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.producto-grid.store-grid {
    justify-content: center;
}

.product-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 14px;
    border-radius: 999px;
    background: linear-gradient(180deg, #f0f2ff 0%, #e8ebff 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    color: #4f46e5;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 auto 10px;
    max-width: 100%;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

.card {
    padding: 12px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 16px;
    text-align: center;
    width: 100%;
    max-width: 200px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.06);
    position: relative;
}

/* Checkbox container profesional */
.card .checkbox-container {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.card .checkbox-container input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.card .checkbox-container input[type="checkbox"]:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}

.card .checkbox-container input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-color: #6366f1;
}

.card .checkbox-container input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid #fff;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.card .checkbox-container input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Card seleccionado */
.card:has(.checkbox-container input[type="checkbox"]:checked) {
    border-color: rgba(99, 102, 241, 0.5);
    background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

@media (min-width: 600px) {
    .card {
        max-width: 180px;
    }
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.35);
}

.card img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 10px;
}

.card .precio {
    margin-top: 10px;
    font-size: 1.15em;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card .store-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, #f0f2ff 0%, #e8ebff 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    color: #4f46e5;
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.card .product-name {
    margin-top: 4px;
    font-weight: 600;
    color: #222;
}

.card .product-name a {
    color: inherit;
    text-decoration: none;
}

.in-card-qty {
    margin-top: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.img-container {
    display: inline-block;
    /* mantiene la imagen y promo juntos */
    text-align: center;
    /* centra la promo debajo de la imagen */
}

.img-container img {
    display: block;
    /* asegura que la imagen ocupe su propio bloque */
    max-width: 100%;
}

.promo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 6px 14px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.promo-badge::before {
    content: '🏷️';
    font-size: 0.8em;
    margin-right: 2px;
}

.promo-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

/* ========== VISTA POR PRODUCTO - ESTILOS GLOBALES ========== */
#vista-producto .producto-grid .card label {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    width: 100%;
}

#vista-producto .producto-grid .card .checkbox-container {
    order: 0;
}

#vista-producto .producto-grid .card .checkbox-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border-radius: 5px;
}

#vista-producto .producto-grid .card .checkbox-container input[type="checkbox"]:checked::after {
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border-width: 0 2px 2px 0;
}

#vista-producto .producto-grid .card .store-pill {
    order: 1;
}

#vista-producto .producto-grid .card .img-container {
    order: 2;
}

#vista-producto .producto-grid .card .product-name {
    order: 3;
}

#vista-producto .producto-grid .card .precio {
    order: 4;
}

aside.ia-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    background: #f9f9f9;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.ia-panel h3 {
    margin: 0;
    padding: 12px;
    background: #0078d7;
    color: white;
    font-size: 16px;
    text-align: center;
}

.chat-container {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
}

.chat-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.chat-user {
    align-self: flex-end;
    background: #e1e1e1;
    color: #333;
}

.chat-ia {
    align-self: flex-start;
    background: #0078d7;
    color: white;
}

.error-msg {
    background: #ffe6e6;
    color: #b30000;
    border: 1px solid #b30000;
    border-radius: 6px;
    padding: 10px;
    margin: 10px 0;
    font-weight: bold;
    text-align: center;
}

#chat-form {
    border-top: 1px solid #ddd;
    width: 85%;
    max-width: 260px;
    /* un poco más chico de ancho */
}

/* Subtotal final row styling */
.subtotal-final-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 16px;
    background: linear-gradient(135deg, #f0f2ff 0%, #e8ebff 100%);
    font-weight: 700;
    color: #1f2937;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.subtotal-final-row .label {
    color: #4f46e5;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.72em;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
    font-weight: 700;
}

.subtotal-final-row #subtotal-final {
    white-space: nowrap;
    font-size: clamp(0.9em, 2vw, 1.1em);
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtotales-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1400;
}

.subtotales-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ===================== Responsive ===================== */
/* Laptops y tablets (<= 1200px): reducir márgenes y tamaños */
@media (max-width: 1200px) {
    main {
        margin-left: 0;
    }

    body[data-has-results="1"] main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .card {
        width: 160px;
    }

    .card img {
        max-width: 130px;
        max-height: 130px;
    }
}

/* ===================== User Menu (top-right) ===================== */
.user-menu {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    z-index: 1100;
    display: flex;
}

.user-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    background: #fff;
    color: #222;
    font-size: 13px;
    cursor: pointer;
    height: 40px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.user-menu-button:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15), 0 6px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.user-menu .user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-menu .user-avatar svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.user-menu-button:hover .user-avatar {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.45);
}

.user-menu .user-caret {
    font-size: 11px;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.user-menu.open .user-caret {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: 52px;
    right: 0;
    min-width: 240px;
    background: linear-gradient(180deg, #ffffff 0%, #fafaff 100%);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.05);
    padding: 8px;
    display: none;
    --dropdown-x: 0%;
    transform: translateX(var(--dropdown-x));
    animation: dropdownSlideIn 0.2s ease;
    backdrop-filter: blur(12px);
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateX(var(--dropdown-x)) translateY(-8px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateX(var(--dropdown-x)) translateY(0) scale(1);
    }
}

@keyframes dropdownSlideInCentered {
    from {
        opacity: 0;
        transform: translateX(var(--dropdown-x)) translateY(-8px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateX(var(--dropdown-x)) translateY(0) scale(1);
    }
}

.user-menu.open .user-dropdown {
    display: block;
}

.user-menu.onboarding-elevated {
    z-index: 9600 !important;
}

.user-menu.onboarding-elevated .user-dropdown {
    z-index: 9610 !important;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}

.user-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 0 4px 4px 0;
    transition: height 0.15s ease;
}

.user-item:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
    color: #4f46e5;
    transform: translateX(2px);
}

.user-item:hover::before {
    height: 60%;
}

.user-item:active {
    transform: translateX(2px) scale(0.98);
}

/* Separador visual antes del logout */
.user-item.logout-item {
    color: #dc2626;
    background: none;
    border: none;
    cursor: pointer;
    margin-top: 4px;
    padding-top: 10px;
    width: 100%;
    text-align: left;
    border-top: 1px solid rgba(99, 102, 241, 0.08);
    border-radius: 0 0 10px 10px;
}

.user-item.logout-item::before {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

.user-item.logout-item:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: #b91c1c;
}

/* Íconos en user-item */
.user-item svg {
    flex-shrink: 0;
    display: block;
    align-self: center;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.user-item:hover svg {
    opacity: 1;
}

.user-item.logout-item svg {
    stroke: currentColor;
}

/* Hover style for main action buttons */
.hover-pill {
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
    border-radius: 24px;
}

.hover-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: #000 !important;
    color: #fff !important;
}

/* ======= Header fijo ======= */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    z-index: 7500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.app-header .nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-extra-links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.mobile-nav-toggle {
    display: none;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-direction: column;
    cursor: pointer;
    position: relative;
    z-index: 1100;
}

.mobile-nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
}

.app-header a.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%); */
    font-weight: 600;
    font-size: 13px;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

/* estilo distinto solo para el dropdown de mapa y optimizador */
#nav-extra-links[aria-hidden="false"] #nav-link-optimizer,
#nav-extra-links[aria-hidden="false"] #nav-link-map,
#nav-extra-links[aria-hidden="false"] #btn-open-map {
    color: #374151;
}

.app-header a.nav-link svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.app-header a.nav-link:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35) 0%, rgba(139, 92, 246, 0.25) 100%);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

.app-header a.nav-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* Botón de toggle para el aside, ubicado en el header a la izquierda, sin afectar el centrado */
.app-header .aside-toggle {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.15) 100%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.app-header .aside-toggle:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4) 0%, rgba(139, 92, 246, 0.3) 100%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    transform: translateY(-50%) translateY(-1px);
}

.app-header .aside-toggle:active {
    transform: translateY(-50%);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* Centrar header con el área de contenido cuando hay aside */
.app-header.with-aside {
    padding-left: 250px;
}

.aside-hidden .app-header.with-aside {
    padding-left: 0;
}

#modal-overlay-placeholder,
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.15);
    max-width: 880px;
    width: 92vw;
    padding: 20px;
    position: relative;
}

#map-modal .modal-content {
    max-width: 880px !important;
    width: 92vw !important;
}

/* Mapa: altura responsive (sobreescribe inline height:420px)
   En desktop limitamos a 420px; en mobile se usa flex para ser dinámico. */
#map-modal #leaflet-map {
    height: min(420px, 52dvh) !important;
    min-height: 200px;
    max-width: 100%;
}

/* Mobile: ajustar modales y mapa al viewport dinámico (address bar)
   y a la altura real del header mobile (64px). */
@media (max-width: 768px) {
    #optimizer-modal,
    #shipping-editor-modal,
    #min-shipping-editor-modal,
    #map-modal,
    #search-validate-modal {
        top: 64px;
        height: calc(100dvh - 64px);
        padding: 12px 8px 16px 8px;
    }

    #optimizer-modal .modal-content,
    #shipping-editor-modal .modal-content,
    #min-shipping-editor-modal .modal-content,
    #map-modal .modal-content,
    #search-validate-modal .modal-content {
        max-height: calc(100dvh - 64px - 32px);
    }

    /* En mobile, el mapa usa flex para tomar el espacio sobrante.
       Quitamos la altura fija y dejamos que el flex-layout decida. */
    #map-modal #leaflet-map {
        height: auto !important;
        min-height: 150px;
        flex: 1 1 0;
    }

    /* El overlay del modal del mapa en mobile debe ser flex column
       para que modal-content ocupe todo el alto disponible. */
    #map-modal {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    #map-modal .modal-content {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }
}

/* Map modal: permitir scroll interno consistente */
#map-modal .modal-content {
    display: flex;
    flex-direction: column;
    /* En mobile, el modal-content debe estirarse para llenar el espacio disponible */
    flex: 1 1 auto;
    min-height: 0;
}

#map-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* El mapa toma todo el espacio vertical restante */
#map-modal #leaflet-map {
    flex: 1 1 auto;
    min-height: 150px;
    max-width: 100%;
}

/* Con el tutorial activo, dar margen interno en el modal del mapa para que el halo del highlight no se recorte contra el scroll container */
body.onboarding-active #map-modal .modal-body {
    padding: 12px;
}

/* Reintegros bancarios: centrar subtítulos */
#reintegros-subtitle-vigentes,
#reintegros-subtitle-vigentes-text {
    text-align: center;
    font-weight: 600;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Reintegros bancarios: botones con estética premium violeta */
#reintegros-form .buscar-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 999px;
    padding: 12px 24px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.35);
    transition: all 0.18s ease;
}

#reintegros-form .buscar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(99, 102, 241, 0.45);
}

#reintegros-form .buscar-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

/* Variante secundaria: Guardar sin bancos */
#btn-guardar-vacio.buscar-btn {
    background: linear-gradient(180deg, #f8faff 0%, #f0f2ff 100%);
    color: #4f46e5;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.1);
}

#btn-guardar-vacio.buscar-btn:hover {
    background: linear-gradient(180deg, #f0f2ff 0%, #e8ebff 100%);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.18);
    transform: translateY(-1px);
}

/* Index (buscar productos): botones con estilo violeta premium */
#buscar-form .buscar-btn,
.search-secondary-actions .buscar-btn,
.vista-toggle .buscar-btn,
#search-validate-modal .buscar-btn,
#shipping-editor-modal .buscar-btn,
#min-shipping-editor-modal .buscar-btn,
#map-modal .buscar-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 999px;
    padding: 12px 24px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.3);
    transition: all 0.18s ease;
}

#buscar-form .buscar-btn:hover,
.search-secondary-actions .buscar-btn:hover,
.vista-toggle .buscar-btn:hover,
#search-validate-modal .buscar-btn:hover,
#shipping-editor-modal .buscar-btn:hover,
#min-shipping-editor-modal .buscar-btn:hover,
#map-modal .buscar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(99, 102, 241, 0.4);
}

#buscar-form .buscar-btn:active,
.search-secondary-actions .buscar-btn:active,
.vista-toggle .buscar-btn:active,
#search-validate-modal .buscar-btn:active,
#shipping-editor-modal .buscar-btn:active,
#min-shipping-editor-modal .buscar-btn:active,
#map-modal .buscar-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}

/* Cuenta: botones con estilo violeta premium */
body.simple-page .buscar-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 999px;
    padding: 12px 24px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.3);
    transition: all 0.18s ease;
}

body.simple-page .buscar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(99, 102, 241, 0.4);
}

body.simple-page .buscar-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}

/* Place specific larger modals below the fixed header so they start under it.
   Keep the header visually above these modals by using a slightly lower z-index.
   Usamos height en dvh en vez de bottom:0 para que el viewport dinámico
   (barra de direcciones en móviles) se respete correctamente. */
#optimizer-modal,
#shipping-editor-modal,
#min-shipping-editor-modal,
#map-modal,
#search-validate-modal {
    position: fixed;
    /* start immediately below the header (header height = 56px) */
    top: 56px;
    left: 0;
    right: 0;
    height: calc(100dvh - 56px);
    /* ensure overlay covers the rest of the viewport but leaves header visible */
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px 32px 12px;
    background: rgba(0, 0, 0, 0.32);
    /* must be under the header (header z-index: 7500) */
    z-index: 7490;
    overflow-y: auto;
}

/* Make sure the modal content can scroll inside the reduced viewport area */
#optimizer-modal .modal-content,
#shipping-editor-modal .modal-content,
#min-shipping-editor-modal .modal-content,
#map-modal .modal-content,
#search-validate-modal .modal-content {
    margin-top: 8px;
    max-height: calc(100dvh - 56px - 48px);
}

/* Tablets en vertical y pantallas medianas (<= 992px) */
@media (max-width: 992px) {
    body {
        padding: 12px;
    }

    .app-header.with-aside {
        padding-left: 0;
    }

    .user-dropdown {
        min-width: min(280px, calc(100dvw - 24px));
    }

    /* En tablets, el panel de subtotales se comporta como en móvil (sheet flotante) */
    #btn-toggle-aside {
        display: none;
    }

    aside.subtotales-panel {
        position: fixed;
        left: 12px;
        bottom: 12px;
        top: auto;
        width: calc(100% - 24px);
        max-height: calc(100dvh - 90px);
        padding: 16px;
        border-radius: 16px;
        border: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.35);
        z-index: 1500;
        background: #fff;
        overflow-y: auto;
        --subtotales-base-offset: calc(100% - 70px);
        --subtotales-drag-offset: 0px;
        transform: translateY(calc(var(--subtotales-base-offset) + var(--subtotales-drag-offset)));
        transition: transform 0.25s ease, box-shadow 0.2s ease;
    }

    aside.subtotales-panel.mobile-placed {
        margin-top: 0;
    }

    aside.subtotales-panel.mobile-floating {
        --subtotales-base-offset: calc(100% - 70px);
    }

    aside.subtotales-panel.mobile-floating.mobile-open {
        --subtotales-base-offset: 0px;
    }

    aside.subtotales-panel.mobile-floating.mobile-dragging {
        transition: none;
    }

    aside.subtotales-panel.mobile-floating.mobile-collapsed h3,
    aside.subtotales-panel.mobile-floating.mobile-collapsed .tienda-subtotal {
        display: none;
    }

    aside.subtotales-panel.mobile-floating .subtotal-final-row {
        cursor: pointer;
        padding: 10px 14px;
        margin-bottom: 16px;
        border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    }

    aside.subtotales-panel.mobile-floating.mobile-collapsed .subtotal-final-row {
        margin-bottom: 0;
        padding-bottom: 12px;
        border-bottom: none;
    }

    main {
        margin: 80px 0 0 0;
        padding: 0 8px 20px;
    }

    h1 {
        font-size: 22px;
    }

    .vista-toggle {
        margin: 8px 0 14px 0;
    }

    .producto-grid {
        gap: 12px;
    }

    .card {
        width: calc(50% - 12px);
        max-width: 240px;
    }

    .card img {
        max-width: 120px;
        max-height: 120px;
    }

    .sticky-optimizer {
        position: static;
    }

    /* Top actions: apilar */
    .top-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .left-actions,
    .right-actions {
        flex: 1 1 auto !important;
        width: 100% !important;
        text-align: left !important;
    }

    .right-actions form {
        width: 100%;
    }

    .right-actions input[name="cp"] {
        width: 100% !important;
        max-width: none !important;
    }

    .right-actions .buscar-btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    #btn-toggle-aside {
        display: none;
    }

    .mobile-nav-toggle {
        display: flex;
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        border: 1px solid rgba(255, 255, 255, 0.18);
        background: rgba(255, 255, 255, 0.08);
    }

    .app-header {
        flex-wrap: nowrap;
        height: 64px;
        padding: 0 16px;
        justify-content: center;
    }

    .app-header .nav-left {
        width: 100%;
        justify-content: center;
        position: static;
        padding: 0 72px;
    }

    .app-header .nav-left #nav-link-search {
        flex: 0 0 auto;
        text-align: center;
        padding: 10px 16px;
    }

    .nav-extra-links {
        position: absolute;
        left: 0;
        right: auto;
        margin: 0;
        width: fit-content;
        max-width: calc(100dvw - 32px);
        min-width: min(180px, calc(100dvw - 32px));
        top: 64px;
        display: none;
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        background: #ffffff;
        border: 1px solid rgba(99, 102, 241, 0.12);
        border-radius: 16px;
        box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.05);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-6px);
        transition: opacity 0.18s ease, transform 0.18s ease;
        z-index: 1090;
    }

    .app-header.tutorial-allowed:not(.mobile-menu-open) .nav-extra-links {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(-6px) !important;
    }

    .nav-extra-links .nav-link {
        width: 100%;
        min-width: 0;
        justify-content: flex-start;
        text-align: left;
        border-radius: 10px;
        padding: 10px 14px;
        border: none;
        background: transparent;
        color: #374151;
        font-size: 14px;
        font-weight: 500;
        box-shadow: none;
        backdrop-filter: none;
    }

    .nav-extra-links .nav-link svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
    }

    .nav-extra-links .nav-link:hover,
    .nav-extra-links .nav-link:active {
        background: rgba(99, 102, 241, 0.1);
        color: #4338ca;
        border: none;
        box-shadow: none;
        transform: none;
    }

    .app-header.mobile-menu-open .nav-extra-links {
        display: flex;
        opacity: 1;
        background: #ffffff;
        pointer-events: auto;
        transform: translateY(0);
    }

    .app-header.mobile-menu-open .mobile-nav-toggle {
        background: rgba(255, 255, 255, 0.2);
    }

    .user-menu {
        right: 12px;
    }

    .user-menu-button {
        width: 42px;
        height: 42px;
        padding: 0;
        justify-content: center;
        gap: 0;
        border-radius: 50%;
        background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
        border: 2px solid rgba(255, 255, 255, 0.25);
        box-shadow: 0 3px 12px rgba(99, 102, 241, 0.35);
    }

    .user-menu-button:hover {
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
    }

    .user-menu .user-avatar {
        width: auto;
        height: auto;
        background: transparent !important;
        background-image: none !important;
        color: #fff;
        box-shadow: none;
    }

    .user-menu .user-avatar svg {
        width: 20px;
        height: 20px;
        fill: #fff;
    }

    .user-menu-button:hover .user-avatar {
        transform: none;
        box-shadow: none;
    }

    .user-menu-button .user-label,
    .user-menu-button .user-caret {
        display: none;
    }

    aside.subtotales-panel {
        position: fixed;
        left: 12px;
        bottom: 12px;
        width: calc(100% - 24px);
        max-height: calc(100dvh - 90px);
        padding: 16px;
        border-radius: 16px;
        border: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.35);
        z-index: 1500;
        background: #fff;
        --subtotales-base-offset: calc(100% - 70px);
        --subtotales-drag-offset: 0px;
        transform: translateY(calc(var(--subtotales-base-offset) + var(--subtotales-drag-offset)));
        transition: transform 0.25s ease, box-shadow 0.2s ease;
    }

    aside.subtotales-panel.mobile-placed {
        margin-top: 0;
    }

    aside.subtotales-panel.mobile-floating {
        --subtotales-base-offset: calc(100% - 70px);
    }

    aside.subtotales-panel.mobile-floating.mobile-open {
        --subtotales-base-offset: 0px;
    }

    aside.subtotales-panel.mobile-floating.mobile-dragging {
        transition: none;
    }

    aside.subtotales-panel.mobile-floating.mobile-collapsed h3,
    aside.subtotales-panel.mobile-floating.mobile-collapsed .tienda-subtotal {
        display: none;
    }

    aside.subtotales-panel.mobile-floating .subtotal-final-row {
        cursor: pointer;
        padding: 10px 14px;
        margin-bottom: 16px;
        border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    }

    aside.subtotales-panel.mobile-floating.mobile-collapsed .subtotal-final-row {
        margin-bottom: 0;
        padding-bottom: 12px;
        border-bottom: none;
    }
}

/* Móviles (<= 600px) */
@media (max-width: 600px) {
    body {
        padding: 8px 10px 28px;
    }

    h1 {
        font-size: 20px;
    }

    textarea {
        max-width: 100%;
    }

    .producto-grid {
        gap: 10px;
    }

    .card {
        width: 100%;
        max-width: none;
    }

    .card img {
        max-width: 110px;
        max-height: 110px;
    }

    button.buscar-btn {
        width: 100%;
        padding: 10px 14px;
        font-size: 0.95em;
    }

    .card label {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: center;
        text-align: center;
        width: 100%;
    }

    #vista-producto .producto-grid .card,
    #tiendas-fisicas-results .producto-grid .card {
        min-height: 230px;
    }

    /* Botones específicos que deben quedar más chicos en móvil */
    #btn-clear-selection.buscar-btn,
    #btn-buscar-productos.buscar-btn,
    #btn-aplicar-cp.buscar-btn {
        width: auto;
        padding: 8px 12px;
    }

    .subtotal-final-row {
        padding: 6px 8px;
    }

    .tienda-subtotal {
        padding: 8px;
    }

    .app-header a.nav-link {
        flex: 1 1 100%;
    }

    .user-dropdown {
        position: fixed;
        --dropdown-x: -75%;
        right: auto;
        /* top: 60px; */
        min-width: min(200px, calc(100dvw - 32px));
        max-width: calc(100dvw - 32px);
        padding: 10px;
        animation: dropdownSlideInCentered 0.2s ease;
    }

    .user-item {
        padding: 12px 16px;
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vista-toggle {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 14px 8px;
        margin-top: 0;
    }

    .vista-toggle button {
        width: auto;
    }

    #vista-producto .producto-grid .card label {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: center;
        text-align: center;
        width: 100%;
    }

    #vista-producto .producto-grid .card .checkbox-container {
        order: 0;
        align-self: center;
    }

    #vista-producto .producto-grid .card .store-pill {
        order: 1;
        align-self: center;
        display: inline-flex;
        width: auto;
        max-width: 100%;
    }

    #vista-producto .producto-grid .card .img-container {
        order: 2;
        width: auto;
    }

    #vista-producto .producto-grid .card .product-name {
        order: 3;
        width: 100%;
    }

    #vista-producto .producto-grid .card .precio {
        order: 4;
        width: 100%;
    }
}