/**
 * Product System - Shared styles for products and search modals
 * Extracted from lista-compra.css
 */

/* --- PRODUCT CARDS --- */
.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-2);
    border-color: var(--brand-100);
}

.product-img-box {
    height: 160px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.product-img-emoji {
    font-size: 4.5rem;
}

.product-title {
    font-weight: 700;
    font-size: var(--fs-16);
    margin-bottom: 4px;
    line-height: 1.3;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-size {
    font-size: var(--fs-14);
    color: var(--text-muted);
    margin-bottom: 8px;
}

.price-section {
    margin-top: auto;
    border-top: 1px dashed var(--border-light);
    padding-top: 12px;
}

.main-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 5px;
    margin-bottom: 4px;
}

.main-price .price-date {
    flex-basis: 100%;
}

.main-price .price {
    font-size: var(--fs-22);
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-main);
}

.main-price .unit-price {
    font-size: var(--fs-12);
    color: var(--text-muted);
}

/* Junto al súper más barato, cuántos más lo tienen: "(+5)" */
.super-info .stores-more {
    margin-left: 6px;
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Genéricos: "desde 1,09 €/kg en ALDI" */
.super-info .group-stores {
    display: block;
    margin-top: 4px;
    font-size: var(--fs-12);
    color: var(--text-muted);
}

/* --- BADGES --- */
.semantic-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 2px 8px;
    border-radius: var(--radius-badge);
    font-size: var(--fs-12);
    font-weight: 700;
    color: #6D28D9;
    border: 1px solid #DDD6FE;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- MODAL COMPACT (Taxonomía) --- */
.modal-compact .modal-content {
    border-radius: var(--radius-modal);
    border: none;
    box-shadow: var(--shadow-2);
}

.modal-compact .modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 1.5rem 1.5rem 1rem;
}

.modal-compact .modal-body {
    padding: 1.5rem;
}

/* --- BREADCRUMB --- */
.breadcrumb-custom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-btn);
    background: white;
    border: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: var(--fs-14);
    min-height: var(--tap);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.breadcrumb-item:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.breadcrumb-home {
    background: var(--brand-600);
    color: white;
    border-color: var(--brand-600);
}

.breadcrumb-home:hover {
    background: var(--primary-hover);
    color: white;
}

.breadcrumb-separator {
    color: #cbd5e1;
}

/* --- SIMILAR PRODUCTS (Detail Modal) --- */
.similar-product-card {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: var(--radius-card);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.similar-product-card:hover {
    background: white;
    border-color: var(--primary-soft);
    box-shadow: var(--shadow-1);
    transform: translateX(4px);
}

.similar-thumb {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.similar-thumb img {
    max-width: 100%;
    max-height: 100%;
}

.similar-info {
    flex-grow: 1;
    overflow: hidden;
}

.similar-name {
    font-weight: 700;
    font-size: var(--fs-14);
    color: var(--text-main);
}

.similar-brand {
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.similar-price-box {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.similar-price {
    font-weight: 800;
    color: var(--text-main);
}

.btn-add-similar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* --- INLINE SIMILAR --- */
.inline-similar-item:hover {
    border-color: var(--primary-soft) !important;
}

/* --- COMPACT BUTTONS --- */
.btn-back-modal {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    min-height: var(--tap);
    border-radius: var(--radius-btn);
    background: white;
    border: 1px solid var(--border-light);
    color: var(--text-main);
    font-weight: 700;
    transition: 0.2s;
    cursor: pointer;
}

.btn-back-modal:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- ADMIN --- */
.btn-manage {
    color: #1D4ED8 !important;
    background: #eff6ff !important;
    border: 2px solid #1D4ED8 !important;
}

/* --- Botones que abren la ficha (titulo e imagen) --- */
.product-title-btn {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
    font-weight: inherit;
    line-height: inherit;
    border-radius: 4px;
}

.product-title-btn:hover {
    color: var(--brand-600);
    text-decoration: underline;
}

.product-img-open img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.similar-name {
    font-weight: 700;
    font-size: var(--fs-14);
    color: var(--text-main);
}

.similar-name:hover {
    color: var(--brand-600);
}

button.breadcrumb-item {
    font: inherit;
    font-size: var(--fs-14);
    font-weight: 600;
}

li.breadcrumb-item.active {
    cursor: default;
    background: var(--bg);
}

.breadcrumb-custom > li {
    display: inline-flex;
}

/* --- BUSCADOR GRANDE: toda la pantalla menos un margen, para ver muchos productos ---
   Gana a la regla de 900 px de lista-compra.css (más específica). En el móvil
   ya es pantalla completa (modal-fullscreen-sm-down). */
@media (min-width: 576px) {
    #productSearchModal .modal-dialog.modal-buscador {
        max-width: none;
        width: auto;
        margin: 1rem;
    }

    #productSearchModal .modal-buscador .modal-content {
        height: calc(100vh - 2rem);
    }

    #productSearchModal .modal-buscador .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        /* El modal tiene altura fija y .modal-content corta lo que sobra:
           sin esto no había scroll (ni barra) en PC */
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

/* Barra de scroll del buscador: la de .custom-scrollbar casi no se veía
   sobre el fondo gris claro */
#productSearchModal .buscador-cuerpo {
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 transparent;
}

#productSearchModal .buscador-cuerpo::-webkit-scrollbar {
    width: 12px;
}

#productSearchModal .buscador-cuerpo::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border: 3px solid var(--bg, #f8fafc);
    border-radius: 10px;
}

#productSearchModal .buscador-cuerpo::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* --- INFORMACIÓN NUTRICIONAL (Open Food Facts) --- */
.nutriscore {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 6px;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--border-light);
}

.nutriscore-titulo {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-right: 4px;
}

.nutriscore-letra {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    color: white;
    background: var(--ns);
    opacity: 0.35;
}

.nutriscore-letra.activa {
    opacity: 1;
    width: 30px;
    height: 30px;
    font-size: 1rem;
    border-radius: 6px;
}

.tabla-nutricion {
    --bs-table-bg: transparent;
}

.tabla-nutricion tr.sub th {
    padding-left: 1.25rem;
    color: var(--text-muted);
}

.breadcrumb-custom .breadcrumb-item + .breadcrumb-item::before {
    content: none;
}

/* =====================================================================
   FICHA DE PRODUCTO (includes/product-modals.php)
   Grande: a la izquierda la foto, el precio y los botones; a la derecha la
   comparativa, la nutricion, los similares y las opiniones. En escritorio
   cada columna tiene su scroll y el precio no se pierde de vista; por debajo
   de 992 px es una sola columna con el precio y "Añadir" fijos abajo.
   ===================================================================== */
#productDetailModal .modal-content {
    border: 0;
    border-radius: var(--radius-modal);
    box-shadow: var(--shadow-2);
    background: var(--surface);
    overflow: hidden;
}

#productDetailModal .modal-content::before {
    content: none;
}

#productDetailModal .ficha-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-6);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* Cerrar la ficha: un boton de verdad, no un aspa que nadie ve */
.ficha-cerrar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 18px 0 14px;
    border: 0;
    border-radius: 999px;
    background: #0F172A;
    color: #fff;
    font-size: var(--fs-14);
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .25);
    transition: background-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.ficha-cerrar i {
    font-size: 1.25rem;
}

.ficha-cerrar:hover {
    background: #1E293B;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .3);
}

.ficha-cerrar:active {
    transform: scale(.97);
}

.ficha-cerrar:focus-visible {
    outline: 3px solid var(--brand-600);
    outline-offset: 2px;
}

@media (max-width: 400px) {
    .ficha-cerrar-extra {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ficha-cerrar {
        transition: none;
    }
}

.ficha-ruta {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text-2);
}

.ficha-ruta > i {
    flex-shrink: 0;
    color: var(--brand-600);
    font-size: 1.1rem;
}

/* Migas: Despensa › Dulces y Desayuno › Regaliz › el producto. Los niveles
   no se encogen hasta que no queda sitio; el producto, el que se recorta */
.ficha-migas {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 2px;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ficha-miga {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
}

.ficha-miga-sep {
    flex-shrink: 0;
    margin: 0 2px;
    color: var(--text-2);
    opacity: .6;
}

.ficha-miga-texto {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ficha-miga-enlace {
    display: inline-flex;
    min-width: 0;
    max-width: 16em;
    padding: 2px 4px;
    margin: 0 -2px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-2);
    font: inherit;
    cursor: pointer;
}

.ficha-miga-enlace:hover {
    color: var(--brand-600);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ficha-miga-enlace:focus-visible {
    outline: 2px solid var(--brand-600);
    outline-offset: 1px;
}

.ficha-miga.is-actual {
    flex: 1 1 0;
    min-width: 6em;
    color: var(--text);
}

/* Movil: dos renglones, «Dulces y Desayuno › Regaliz» y debajo el producto.
   El departamento sobra cuando hay niveles por debajo (3 migas o mas) */
@media (max-width: 575.98px) {
    .ficha-ruta {
        align-items: flex-start;
    }

    .ficha-ruta > i {
        display: none;
    }

    .ficha-miga:first-child:nth-last-child(n+3) {
        display: none;
    }

    .ficha-miga:first-child:nth-last-child(n+3) + .ficha-miga .ficha-miga-sep,
    .ficha-miga.is-actual .ficha-miga-sep {
        display: none;
    }

    /* Base mínima y tope en su ancho: caben siempre en un renglón y el corto
       (Regaliz) deja al largo el sitio que le sobra. Con base 0 cabían
       «justas» junto al producto (100 %) y se quedaban sin ancho */
    .ficha-miga:not(.is-actual) {
        flex: 1 1 1px;
        max-width: max-content;
    }

    /* Sin tope: encoge con su miga (flex). Un max-width en % aquí hacía
       que el navegador midiera mal la miga y recortara con sitio libre */
    .ficha-miga-enlace {
        max-width: none;
    }

    .ficha-miga.is-actual {
        flex-basis: 100%;
    }
}

#productDetailModal .ficha-cuerpo {
    padding: 0;
    background: var(--bg);
}

.ficha {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

/* --- Columna izquierda --- */
.ficha-resumen {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding: var(--space-6);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.ficha-foto {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    padding: var(--space-4);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.ficha-foto img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Favorito y avisar de un error, encima de la foto arriba a la izquierda */
.ficha-foto-botones {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    display: flex;
    gap: 8px;
}

#productDetailModal .ficha-foto-boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: var(--text-2);
    font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .12);
}

#productDetailModal .ficha-foto-boton[hidden] {
    display: none;
}

#productDetailModal .ficha-foto-boton:hover {
    background: var(--brand-50);
    border-color: var(--brand-100);
}

#productDetailModal .ficha-foto-boton.activo {
    background: var(--brand-50);
    border-color: var(--brand-600);
    color: var(--brand-600);
}

.ficha-foto-emoji {
    font-size: 5rem;
    line-height: 1;
}

.ficha-etiquetas {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--space-2);
}

.ficha-etiquetas .badge {
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-12);
    font-weight: 700;
}

.ficha-etiqueta {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg);
    color: var(--text-2);
    font-size: var(--fs-12);
    font-weight: 600;
}

.ficha-nombre {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    overflow-wrap: anywhere;
}

.ficha-precio {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: var(--space-4) var(--space-5);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
}

.ficha-precio-grande {
    font-family: var(--font-heading);
    font-size: var(--fs-36);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.ficha-precio-unidad {
    font-size: var(--fs-14);
    font-weight: 500;
    color: var(--text-2);
}

.ficha-precio-fecha {
    font-size: var(--fs-12);
    color: var(--text-2);
}

.ficha-precio .ficha-chip {
    margin-top: var(--space-2);
}

.ficha-acciones {
    display: flex;
    gap: var(--space-2);
}

#productDetailModal .ficha-btn-anadir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    flex: 1 1 auto;
    min-height: 48px;
    padding: 0 var(--space-5);
    border: 0;
    border-radius: var(--radius-btn);
    background: var(--brand-600);
    color: #fff;
    font-size: var(--fs-16);
    font-weight: 700;
    box-shadow: none;
    transform: none;
}

#productDetailModal .ficha-btn-anadir:hover {
    background: var(--brand-700);
}

#productDetailModal .ficha-btn-anadir::before {
    content: none;
}

/* El control de cantidad de la ficha (en una lista): ocupa el sitio del botón */
#productDetailModal .ficha-cantidad {
    flex: 1 1 auto;
    min-width: 0;
}

#productDetailModal .ficha-cantidad .ficha-btn-anadir {
    width: 100%;
}

#productDetailModal .ficha-cantidad .producto-enlista {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    color: var(--success, #15803D);
    font-size: var(--fs-14);
    font-weight: 700;
}

#productDetailModal .ficha-cantidad .producto-cantidad-fila {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

#productDetailModal .ficha-cantidad .producto-cantidad {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 48px;
    border: 1.5px solid var(--brand-600);
    border-radius: var(--radius-btn, 12px);
    background: var(--surface);
    overflow: hidden;
}

#productDetailModal .ficha-cantidad .producto-cantidad-btn {
    flex: 0 0 52px;
    height: 100%;
    padding: 0;
    border: 0;
    background: var(--brand-600);
    color: #fff;
    font-size: 1.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#productDetailModal .ficha-cantidad .producto-cantidad-btn:hover {
    background: var(--brand-700, #9F1620);
}

#productDetailModal .ficha-cantidad .producto-cantidad-valor {
    flex: 1;
    text-align: center;
    color: var(--text);
    font-size: var(--fs-18, 1.125rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

#productDetailModal .ficha-cantidad .producto-unidad,
#productDetailModal .ficha-cantidad .producto-unidad-fija {
    flex: 0 0 76px;
    height: 48px;
    padding: 0 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-btn, 12px);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-16);
    font-weight: 600;
}

#productDetailModal .ficha-cantidad .producto-unidad-fija {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#productDetailModal .ficha-btn-anadir i {
    font-size: 1.2rem;
}

#productDetailModal .ficha-btn-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    background: #fff;
    font-size: 1.3rem;
}

#productDetailModal .ficha-btn-icono:hover {
    background: var(--brand-50);
    border-color: var(--brand-100);
}

.ficha-datos {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-14);
    color: var(--text-2);
}

.ficha-datos li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.ficha-datos li > i {
    font-size: 1.05rem;
}

.ficha-datos a {
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ficha-ean {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
}

/* --- Columna derecha --- */
.ficha-detalle {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    min-width: 0;
    padding: var(--space-5);
}

.ficha-seccion {
    padding: var(--space-5) var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
}

.ficha-seccion-cabecera {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.ficha-seccion-titulo {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--fs-18);
    font-weight: 700;
    color: var(--text);
}

.ficha-seccion-nota {
    margin: 4px 0 0;
    font-size: var(--fs-14);
    color: var(--text-2);
}

.ficha-fuente {
    margin: var(--space-3) 0 0;
    font-size: var(--fs-12);
    color: var(--text-2);
}

.ficha-fuente a {
    color: var(--text);
}

.ficha-opiniones:empty {
    display: none;
}

.ficha-aviso:not(:has(form:not([hidden]), .report-hecho:not([hidden]))) {
    display: none;
}

/* Modificar el producto (solo admins): el lápiz encima de la foto, en el
   color de aviso para que se vea que no es algo que ve todo el mundo */
#productDetailModal .ficha-foto-boton.is-admin {
    color: var(--warning);
}

#productDetailModal .ficha-foto-boton.is-admin.activo {
    background: var(--warning-50);
    border-color: var(--warning);
}

.ficha-admin {
    padding: var(--space-4);
    border: 1px dashed var(--warning);
    border-radius: var(--radius-card);
    background: var(--warning-50);
}

.ficha-admin[hidden] {
    display: none;
}

.ficha-admin-titulo {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 var(--space-3);
    font-size: var(--fs-16);
    font-weight: 700;
}

.ficha-admin-titulo > i {
    color: var(--warning);
}

.ficha-admin-chip {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--warning);
    color: #fff;
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: .02em;
}

.ficha-admin-label {
    display: block;
    margin: var(--space-2) 0 4px;
    font-size: var(--fs-12);
    font-weight: 700;
    color: var(--text-2);
}

.ficha-admin .form-select {
    background-color: var(--surface);
}

.ficha-admin-nota {
    margin: var(--space-3) 0 0;
    font-size: var(--fs-12);
    color: var(--text-2);
}

.ficha-admin-error {
    margin: var(--space-2) 0 0;
    font-size: var(--fs-14);
    color: var(--danger);
}

.ficha-admin-error:empty {
    display: none;
}

.ficha-admin-botones {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.ficha-admin-retirar {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid rgba(180, 83, 9, .25);
}

.ficha-admin-peligro {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--danger);
    font-size: var(--fs-14);
    font-weight: 600;
}

.ficha-admin-peligro:hover {
    text-decoration: underline;
}

/* Ya avisaste: la bandera rellena y, al pulsarla, este mensaje */
#productDetailModal .ficha-foto-boton.hecho {
    color: var(--brand-600);
}

.report-hecho {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-card);
    background: var(--success-50);
    color: var(--success);
    font-weight: 600;
    font-size: var(--fs-14);
}

.report-hecho[hidden] {
    display: none;
}

.report-hecho:focus {
    outline: 0;
}

.report-hecho i {
    font-size: 1.2rem;
    line-height: 1.2;
}

/* Resumen de la comparativa: tres datos y la barra de rango */
.comparativa-resumen:not(:empty) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.comparativa-dato {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.comparativa-dato-etiqueta {
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
}

.comparativa-dato-valor {
    margin-top: 2px;
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.comparativa-dato-sub {
    font-size: var(--fs-12);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comparativa-dato.is-best {
    background: var(--success-50);
    border-color: #A7F3D0;
}

.comparativa-dato.is-best .comparativa-dato-valor {
    color: var(--success);
}

.comparativa-dato.is-este {
    background: var(--brand-50);
    border-color: var(--brand-100);
}

.comparativa-dato.is-este.is-best {
    background: var(--success-50);
    border-color: #A7F3D0;
}

.comparativa-rango {
    grid-column: 1 / -1;
    position: relative;
    height: 22px;
    margin: 0 9px;
}

.comparativa-rango::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 9px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, #6EE7B7 0%, #FDE68A 50%, #FCA5A5 100%);
}

.rango-punto {
    position: absolute;
    top: 6px;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--text-2);
}

.rango-punto.is-este {
    top: 2px;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    background: var(--brand-600);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--brand-600);
    z-index: 1;
}

/* La tabla */
.comparativa {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-14);
}

.comparativa th {
    padding: 0 var(--space-3) var(--space-2);
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
    text-align: left;
    white-space: nowrap;
}

.comparativa th.num {
    text-align: right;
}

.comparativa td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.comparativa tbody tr:last-child td {
    border-bottom: 0;
}

.comparativa .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.comparativa tbody tr:hover td {
    background: var(--bg);
}

.comparativa tr.is-este td,
.comparativa tr.is-este:hover td {
    background: var(--brand-50);
}

.comparativa tr.is-este td:first-child {
    box-shadow: inset 3px 0 0 var(--brand-600);
}

/* Este es además el más barato: en verde, como "Más barato" */
.comparativa tr.is-este.is-best td,
.comparativa tr.is-este.is-best:hover td {
    background: var(--success-50);
}

.comparativa tr.is-este.is-best td:first-child {
    box-shadow: inset 3px 0 0 var(--success);
}

.comparativa .c-super {
    width: 1%;
    white-space: nowrap;
}

.comp-super {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    color: var(--text);
}

.comp-punto {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.comp-tag {
    display: inline-block;
    margin: 4px 4px 0 18px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
}

.comp-tag + .comp-tag {
    margin-left: 0;
}

.comp-tag.is-este {
    background: var(--brand-600);
}

.comp-tag.is-este.is-best {
    background: var(--success);
}

.comp-tag.is-best {
    background: var(--success);
}

.comp-nombre {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text);
    font-weight: 500;
    text-align: left;
    line-height: 1.35;
}

.comp-abrir:hover,
.comp-abrir:focus-visible {
    color: var(--brand-600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.comp-sub {
    display: block;
    margin-top: 1px;
    font-size: var(--fs-12);
    color: var(--text-2);
}

.comp-valor {
    font-weight: 800;
    color: var(--text);
}

.comparativa tr.is-best .comp-valor {
    color: var(--success);
}

.comp-diff-up {
    color: var(--danger);
    font-weight: 700;
}

.comp-diff-down {
    color: var(--success);
    font-weight: 700;
}

.comp-sin {
    color: var(--text-2);
}

.comparativa .c-enlace {
    width: 1%;
    padding-left: 0;
    padding-right: 0;
}

.comp-enlace {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-2);
    font-size: 1.05rem;
}

.comp-enlace:hover {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-1);
}

.comparativa-mas {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    margin-top: var(--space-3);
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font-size: var(--fs-14);
    font-weight: 600;
}

.comparativa-mas:hover {
    background: var(--bg);
    border-style: solid;
}

/* Nutrición dentro de la ficha */
.ficha-seccion .tabla-nutricion {
    max-width: 520px;
    font-size: var(--fs-14);
}

.ficha-seccion .tabla-nutricion thead th {
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
}

.ficha-seccion .tabla-nutricion tbody td {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Barra de abajo (móvil y tableta) */
.ficha-barra {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 16px -8px rgba(15, 23, 42, 0.12);
}

.ficha-barra-precio {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ficha-barra-grande {
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
}

.ficha-barra-unidad {
    font-size: var(--fs-12);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ficha-barra .ficha-btn-anadir {
    flex: 0 0 auto;
}

/* Tableta: una columna; arriba, la foto a la izquierda del precio */
@media (min-width: 576px) and (max-width: 991.98px) {
    #productDetailModal .modal-dialog {
        --bs-modal-width: calc(100vw - 2rem);
        margin-left: auto;
        margin-right: auto;
    }

    .ficha-resumen {
        display: grid;
        grid-template-columns: 220px minmax(0, 1fr);
        grid-template-areas:
            "foto identidad"
            "foto precio"
            "foto acciones"
            "foto datos";
        align-content: start;
        column-gap: var(--space-6);
        row-gap: var(--space-4);
    }

    .ficha-foto { grid-area: foto; align-self: start; }
    .ficha-identidad { grid-area: identidad; }
    .ficha-precio { grid-area: precio; }
    .ficha-acciones { grid-area: acciones; }
    .ficha-datos { grid-area: datos; }
    .ficha-aviso,
    .ficha-admin { grid-column: 1 / -1; }
}

/* Escritorio: dos columnas, cada una con su scroll */
@media (min-width: 992px) {
    #productDetailModal .modal-dialog {
        --bs-modal-width: min(1320px, calc(100vw - 3rem));
    }

    #productDetailModal .modal-content {
        height: calc(100vh - 3.5rem);
    }

    #productDetailModal .ficha-cuerpo {
        overflow: hidden;
    }

    #productDetailModal .ficha-cuerpo > #productDetailLoading {
        margin-top: 15vh;
    }

    .ficha {
        grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
        height: 100%;
    }

    .ficha-resumen,
    .ficha-detalle {
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .ficha-resumen {
        border-bottom: 0;
        border-right: 1px solid var(--border);
        padding: var(--space-6) var(--space-6) var(--space-8);
    }

    .ficha-detalle {
        padding: var(--space-6) var(--space-8) var(--space-8);
    }

    .ficha-nombre {
        font-size: 1.5rem;
    }

    .ficha-barra {
        display: none !important;
    }
}

/* Pantallas bajas: la foto no se come el precio */
@media (min-width: 992px) and (max-height: 820px) {
    .ficha-foto {
        max-width: 220px;
    }
}

/* Móvil: pantalla completa, una columna. El margen y el ancho, explícitos:
   lista-compra.css deja 1rem de margen a todos los modales */
@media (max-width: 575.98px) {
    #productDetailModal .modal-dialog {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    #productDetailModal .modal-content {
        height: 100%;
        border-radius: 0;
    }

    #productDetailModal .ficha-cabecera {
        padding: var(--space-3) var(--space-4);
    }

    .ficha-resumen {
        padding: var(--space-4);
        gap: var(--space-4);
    }

    .ficha-foto {
        max-width: 220px;
    }

    .ficha-detalle {
        padding: var(--space-3);
        gap: var(--space-3);
    }

    .ficha-seccion {
        padding: var(--space-4);
    }

    .comparativa-dato-etiqueta {
        font-size: 0.625rem;
        letter-spacing: 0.02em;
    }

    .comparativa-dato-sub {
        white-space: normal;
    }
}

/* La barra de abajo sale solo cuando el botón "Añadir" de arriba ya no se ve
   (js/product-system.js) */
.ficha-barra.is-oculta {
    display: none;
}

/* La tabla de la comparativa en estrecho: cada súper, una tarjeta de dos líneas */
@media (max-width: 767.98px) {
    .comparativa-resumen:not(:empty) {
        gap: var(--space-2);
    }

    .comparativa-dato {
        padding: var(--space-2) var(--space-3);
    }

    .comparativa-dato-valor {
        font-size: var(--fs-16);
    }

    .comparativa thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .comparativa,
    .comparativa tbody {
        display: block;
    }

    .comparativa tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto 36px;
        grid-template-areas:
            "super precio enlace"
            "producto diff enlace";
        column-gap: var(--space-2);
        row-gap: 2px;
        padding: var(--space-3) var(--space-2);
        border-bottom: 1px solid var(--border);
    }

    .comparativa tbody tr:last-child {
        border-bottom: 0;
    }

    .comparativa tbody tr[hidden] {
        display: none;
    }

    .comparativa td {
        padding: 0;
        border: 0;
        background: transparent !important;
    }

    .comparativa tr.is-este.is-best {
        background: var(--success-50);
        box-shadow: inset 3px 0 0 var(--success);
    }

    .comparativa tr.is-este {
        background: var(--brand-50);
        border-radius: 10px;
        box-shadow: inset 3px 0 0 var(--brand-600);
    }

    .comparativa tr.is-este td:first-child {
        box-shadow: none;
    }

    .comparativa .c-super { grid-area: super; width: auto; white-space: normal; }
    .comparativa .c-producto { grid-area: producto; }
    .comparativa .c-precio { grid-area: precio; }
    .comparativa .c-diff { grid-area: diff; align-self: start; font-size: var(--fs-12); }
    .comparativa .c-enlace { grid-area: enlace; align-self: center; width: auto; }

    .comparativa .c-super .comp-tag {
        margin-left: 6px;
        margin-top: 0;
        vertical-align: middle;
    }

    .comp-super {
        display: inline-flex;
    }

    .comp-nombre {
        -webkit-line-clamp: 1;
        font-size: var(--fs-12);
        color: var(--text-2);
    }
}

/* El foco que pone enfocarFicha() en el nombre es para el lector de pantalla:
   un titulo no es un control, sin recuadro */
.ficha-nombre:focus,
.ficha-nombre:focus-visible {
    outline: none !important;
}

/* Similares dentro de la ficha: foto | nombre, súper y precio | "Añadir".
   Con #productDetailModal para ganar a las reglas viejas de lista-compra.css */
#productDetailModal .similar-product-card {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    height: 100%;
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: default;
    transform: none;
}

#productDetailModal .similar-product-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--shadow-1);
    transform: none;
}

#productDetailModal .similar-thumb {
    width: 64px;
    height: 64px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

#productDetailModal .similar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#productDetailModal .similar-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

#productDetailModal .similar-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: var(--fs-14);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    text-align: left;
}

#productDetailModal .similar-name:hover,
#productDetailModal .similar-name:focus-visible {
    color: var(--brand-600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

#productDetailModal .similar-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

#productDetailModal .similar-meta .badge {
    flex-shrink: 0;
    font-size: 0.6875rem;
}

#productDetailModal .similar-brand {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--fs-12);
    color: var(--text-2);
}

#productDetailModal .similar-precios {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    column-gap: 6px;
}

#productDetailModal .similar-price {
    font-size: var(--fs-16);
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

#productDetailModal .similar-unit {
    font-size: var(--fs-12);
    color: var(--text-2);
}

#productDetailModal .similar-anadir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    font-size: 1.2rem;
}

#productDetailModal .similar-anadir:hover {
    background: var(--brand-600);
    border-color: var(--brand-600) !important;
    color: #fff;
}

/* Producto que solo esta en un super */
.comparativa-vacia {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg);
    border-radius: 12px;
    font-size: var(--fs-14);
    color: var(--text-2);
}

.comparativa-vacia > i {
    font-size: 1.2rem;
}

/* =====================================================================
   BUSCADOR (includes/product-modals.php, #productSearchModal)
   Arriba, el campo y las migas; debajo, departamentos, categorías, tipos o
   productos. Todo va con #productSearchModal delante: lista-compra.css
   restiliza los .btn, .form-check y cabeceras de todos sus modales.
   ===================================================================== */
#productSearchModal .modal-content {
    border: 0;
    border-radius: var(--radius-modal);
    box-shadow: var(--shadow-2);
    background: var(--surface);
    overflow: hidden;
}

#productSearchModal .modal-content::before {
    content: none;
}

/* --- Cabecera --- */
#productSearchModal .buscador-cabecera {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.buscador-fila-titulo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

#productSearchModal .buscador-titulo {
    flex: 1;
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--fs-18);
    font-weight: 700;
    color: var(--text);
}

#productSearchModal .buscador-titulo::before {
    content: none;
}

#productSearchModal .buscador-cabecera .btn-close {
    margin: 0;
}

.buscador-btn-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-size: 1.2rem;
}

.buscador-btn-icono:hover {
    background: var(--bg);
}

.buscador-fila-campo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.buscador-campo {
    position: relative;
    flex: 1;
    min-width: 0;
}

.buscador-campo-icono {
    position: absolute;
    top: 50%;
    left: 16px;
    z-index: 1;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--text-2);
    pointer-events: none;
}

#productSearchModal .buscador-input {
    width: 100%;
    height: 52px;
    padding: 0 48px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
    color: var(--text);
    font-size: var(--fs-16);
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

#productSearchModal .buscador-input::placeholder {
    color: #94A3B8;
}

#productSearchModal .buscador-input:hover {
    border-color: #CBD5E1;
}

/* El anillo de foco es el borde de marca y un halo (tokens.css pone además
   un contorno negro a todo :focus-visible: con los dos salía doble) */
#productSearchModal .buscador-input:focus,
#productSearchModal .buscador-input:focus-visible {
    outline: none !important;
    background: var(--surface);
    border-color: var(--brand-600);
    box-shadow: 0 0 0 4px rgba(200, 29, 42, 0.14);
}

#productSearchModal .buscador-input::-webkit-search-cancel-button {
    display: none;
    -webkit-appearance: none;
}

.buscador-limpiar {
    position: absolute;
    top: 50%;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #94A3B8;
    font-size: 1.3rem;
    transform: translateY(-50%);
}

.buscador-limpiar:hover {
    background: var(--bg);
    color: var(--text);
}

/* Migas: Inicio › Frescos › Carne › Aves */
#productSearchModal .buscador-migas {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#productSearchModal .buscador-migas .breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 4px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    color: var(--text-2);
    font-size: var(--fs-14);
    font-weight: 600;
    line-height: 1.4;
}

#productSearchModal .buscador-migas button.breadcrumb-item:hover {
    background: var(--bg);
    color: var(--text);
}

#productSearchModal .buscador-migas .breadcrumb-item.active {
    background: transparent;
    color: var(--text);
    font-weight: 700;
}

#productSearchModal .buscador-migas .breadcrumb-separator {
    display: inline-flex;
    padding: 0;
    color: #94A3B8;
}

/* --- Cuerpo --- */
#productSearchModal .buscador-cuerpo {
    padding: var(--space-5) var(--space-6) var(--space-8);
    background: var(--bg);
}

/* Título de un grupo de subtipos en el menú de tipos («Leche», «Yogures») */
.buscador-familia {
    margin-top: var(--space-4);
}

.buscador-familia-titulo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text, #0f172a);
}

.buscador-familia-titulo::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border, #e2e8f0);
}

/* Tarjeta de menú: departamento, categoría o tipo */
.buscador-tarjeta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    height: 100%;
    min-height: 76px;
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.buscador-tarjeta:hover {
    border-color: var(--tono, var(--brand-600));
    box-shadow: var(--shadow-1);
}

.buscador-tarjeta-icono,
.buscador-vista-icono {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tono-fondo, var(--bg));
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    line-height: 1;
}

.buscador-tarjeta-icono {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 1.75rem;
}

.buscador-tarjeta-icono i {
    color: var(--tono, var(--text));
    font-size: 1.5rem;
}

.buscador-tarjeta-textos {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.buscador-tarjeta-nombre {
    font-size: var(--fs-16);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

.buscador-tarjeta-sub {
    margin-top: 2px;
    font-size: var(--fs-12);
    color: var(--text-2);
}

.buscador-tarjeta-flecha {
    flex-shrink: 0;
    color: #CBD5E1;
    font-size: 1.4rem;
    transition: transform 0.15s, color 0.15s;
}

.buscador-tarjeta:hover .buscador-tarjeta-flecha {
    color: var(--tono, var(--brand-600));
    transform: translateX(2px);
}

/* "Ver todo": del color del departamento */
.buscador-tarjeta.is-todo {
    background: var(--tono-fondo);
    border-color: transparent;
}

.buscador-tarjeta.is-todo .buscador-tarjeta-icono {
    background: var(--surface);
}

.buscador-tarjeta.is-todo:hover {
    border-color: var(--tono);
}

/* "Crear un producto": la última tarjeta de las secciones, resaltada con el
   color de la marca para que se vea sin buscarla (solo en la lista) */
#productSearchModal .buscador-tarjeta.is-crear {
    --tono: var(--brand-600);
    border: 2px dashed var(--brand-500);
    background: var(--brand-50);
}

#productSearchModal .buscador-tarjeta.is-crear:hover {
    border-style: solid;
    border-color: var(--brand-600);
}

#productSearchModal .buscador-tarjeta.is-crear .buscador-tarjeta-icono {
    background: var(--brand-600);
}

#productSearchModal .buscador-tarjeta.is-crear .buscador-tarjeta-icono i {
    color: #fff;
}

#productSearchModal .buscador-tarjeta.is-crear .buscador-tarjeta-nombre,
#productSearchModal .buscador-tarjeta.is-crear .buscador-tarjeta-flecha {
    color: var(--brand-700);
}

/* Cabecera de las vistas de menú: Frescos, 9 categorías */
.buscador-vista-cabecera:not(:empty) {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.buscador-vista-icono {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    font-size: 2.2rem;
}

.buscador-vista-textos {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.buscador-vista-titulo {
    font-family: var(--font-heading);
    font-size: var(--fs-28);
    font-weight: 800;
    line-height: 1.15;
    color: var(--text);
}

.buscador-vista-sub {
    margin-top: 2px;
    font-size: var(--fs-14);
    color: var(--text-2);
}

/* Mientras llegan los números de los súpers de la lista, las tarjetas no enseñan los globales */
.is-contando .buscador-tarjeta-sub,
.is-contando .buscador-tarjeta-hijos {
    visibility: hidden;
}

/* --- Resultados --- */
.buscador-resultados-cabecera {
    margin-bottom: var(--space-4);
}

.buscador-resultados-titulo {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 800;
    color: var(--text);
    overflow-wrap: anywhere;
}

.buscador-resultados-cuantos {
    margin: 2px 0 0;
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text-2);
}

#productSearchModal #searchPricesUpdated {
    margin: 2px 0 0 !important;
    font-size: var(--fs-12);
    color: var(--text-2);
}

#productSearchModal .product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    box-shadow: none;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#productSearchModal .product-card:hover {
    transform: none;
    border-color: #CBD5E1;
    box-shadow: var(--shadow-2);
}

#productSearchModal .product-img-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 168px;
    padding: var(--space-3);
    background: #fff;
    border-bottom: 1px solid #F1F5F9;
}

#productSearchModal .product-img-open {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#productSearchModal .product-img-open img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s;
}

#productSearchModal .product-card:hover .product-img-open img {
    transform: scale(1.04);
}

#productSearchModal .product-img-emoji {
    font-size: 3.5rem;
}

.producto-atajos {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#productSearchModal .producto-atajo,
#productSearchModal .product-card .favorite-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border: 1px solid var(--border) !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.94) !important;
    box-shadow: var(--shadow-1);
    color: var(--text-2);
    font-size: 1.05rem;
    transform: none;
}

#productSearchModal .product-card .favorite-btn::before,
#productSearchModal .producto-atajo::before {
    content: none;
}

#productSearchModal .producto-atajo:hover,
#productSearchModal .product-card .favorite-btn:hover {
    background: #fff !important;
    color: var(--text);
}

/* Con ratón, los atajos (filtrar, admin) salen al pasar por encima; el corazón, siempre */
@media (hover: hover) {
    #productSearchModal .producto-atajo {
        opacity: 0;
        transition: opacity 0.15s;
    }

    #productSearchModal .product-card:hover .producto-atajo,
    #productSearchModal .producto-atajo:focus-visible {
        opacity: 1;
    }
}

#productSearchModal .product-card .card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-3);
}

#productSearchModal .super-info {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

#productSearchModal .super-info .badge {
    max-width: 100%;
    overflow: hidden;
    padding: 3px 7px;
    border-radius: 6px;
    font-size: 0.6875rem;
    text-overflow: ellipsis;
}

#productSearchModal .super-info .stores-more {
    margin-left: 2px;
}

#productSearchModal .product-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.6em;
    margin: 0;
    overflow: hidden;
    font-size: var(--fs-14);
    font-weight: 600;
    line-height: 1.3;
}

#productSearchModal .product-title-btn {
    color: var(--text);
    text-align: left;
}

#productSearchModal .product-title-btn:hover {
    color: var(--brand-600);
}

#productSearchModal .product-size {
    margin: 0;
    font-size: var(--fs-12);
    color: var(--text-2);
}

#productSearchModal .product-size strong {
    font-weight: 600;
    color: var(--text-2);
}

#productSearchModal .price-section {
    margin-top: auto;
    padding-top: var(--space-2);
    border-top: 0;
}

#productSearchModal .main-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 6px;
    margin: 0;
}

#productSearchModal .main-price .price {
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}

#productSearchModal .main-price .unit-price {
    font-size: var(--fs-12);
    color: var(--text-2);
}

/* "Añadir": con borde (24 botones rojos rellenos cansaban la vista); se rellena al pasar */
#productSearchModal .producto-anadir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 40px;
    margin-top: var(--space-2);
    padding: 0;
    border: 1.5px solid var(--brand-600);
    border-radius: 10px;
    background: var(--surface);
    color: var(--brand-600);
    font-size: var(--fs-14);
    font-weight: 700;
    transition: background 0.15s, color 0.15s;
}

#productSearchModal .producto-anadir i {
    font-size: 1.1rem;
}

#productSearchModal .producto-anadir:hover {
    background: var(--brand-600);
    color: #fff;
}

/* Sin resultados */
.buscador-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-12) var(--space-4);
    text-align: center;
}

.buscador-vacio-icono {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin-bottom: var(--space-4);
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-2);
    font-size: 2rem;
}

.buscador-vacio-titulo {
    margin: 0 0 4px;
    font-family: var(--font-heading);
    font-size: var(--fs-18);
    font-weight: 700;
    color: var(--text);
}

.buscador-vacio-texto {
    max-width: 440px;
    margin: 0 0 var(--space-4);
    font-size: var(--fs-14);
    color: var(--text-2);
}

.buscador-btn-secundario {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 var(--space-5);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
}

.buscador-btn-secundario:hover {
    border-color: #CBD5E1;
    box-shadow: var(--shadow-1);
}

.buscador-vacio-acciones {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
}

#productSearchModal .buscador-btn-primario {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    height: 44px;
    padding: 0 var(--space-5);
    border: 0;
    border-radius: 12px;
    background: var(--brand-600);
    color: #fff;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#productSearchModal .buscador-btn-primario:hover {
    background: var(--brand-700);
}

/* En pantallas muy anchas, ocho productos por fila en vez de seis */
@media (min-width: 2200px) {
    #productSearchModal #productsGrid > .col-xl-2 {
        width: 12.5%;
    }
}

/* Qué hay dentro de cada sección: "Frutas · Verduras · Carne..." */
.buscador-tarjeta-hijos {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 6px;
    font-size: var(--fs-12);
    line-height: 1.45;
    color: var(--text-2);
}

/* PC: tarjetas grandes en vertical (icono arriba, la flecha en la esquina),
   que en horizontal y a 76 px de alto dejaban la pantalla vacía */
@media (min-width: 992px) {
    .buscador-tarjeta {
        position: relative;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
        min-height: 168px;
        padding: var(--space-5);
        border-radius: 20px;
        transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    }

    .buscador-tarjeta:hover {
        box-shadow: var(--shadow-2);
        transform: translateY(-2px);
    }

    .buscador-tarjeta-icono {
        flex: 0 0 auto;
        width: 72px;
        height: 72px;
        border-radius: 18px;
        font-size: 2.5rem;
    }

    .buscador-tarjeta-icono i {
        font-size: 2rem;
    }

    .buscador-tarjeta-textos {
        width: 100%;
    }

    .buscador-tarjeta-nombre {
        padding-right: var(--space-6);
        font-size: var(--fs-18);
    }

    .buscador-tarjeta-sub {
        font-size: var(--fs-14);
    }

    .buscador-tarjeta-hijos {
        -webkit-line-clamp: 2;
        margin-top: var(--space-2);
        font-size: var(--fs-14);
    }

    .buscador-tarjeta-flecha {
        position: absolute;
        top: var(--space-5);
        right: var(--space-4);
        font-size: 1.6rem;
    }

}

/* Móvil: pantalla completa (lista-compra.css deja 1rem de margen a los modales) */
@media (max-width: 575.98px) {
    #productSearchModal .modal-dialog {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    #productSearchModal .modal-content {
        height: 100%;
        border-radius: 0;
    }

    #productSearchModal .buscador-cabecera {
        gap: var(--space-2);
        padding: var(--space-3) var(--space-4);
    }

    #productSearchModal .buscador-titulo {
        font-size: var(--fs-16);
    }

    #productSearchModal .buscador-input {
        height: 48px;
        font-size: var(--fs-16);
    }

    #productSearchModal .buscador-cuerpo {
        padding: var(--space-4) var(--space-3) var(--space-6);
    }

    .buscador-tarjeta {
        min-height: 64px;
    }

    .buscador-tarjeta-icono {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 1.5rem;
    }

    .buscador-vista-icono {
        flex-basis: 52px;
        width: 52px;
        height: 52px;
        font-size: 1.8rem;
    }

    .buscador-vista-titulo {
        font-size: var(--fs-22);
    }

    #productSearchModal .product-img-box {
        height: 132px;
        padding: var(--space-2);
    }

    #productSearchModal .main-price .price {
        font-size: var(--fs-18);
    }

}

/* El corazón, siempre arriba: los atajos invisibles no lo empujan */
#productSearchModal .producto-atajos .favorite-btn {
    order: -1;
}

/* --- Esqueletos de carga: la forma de lo que llega, con un brillo que pasa --- */
.esq {
    display: block;
    border-radius: 8px;
    background: linear-gradient(90deg, #E9EEF4 0%, #F6F8FB 50%, #E9EEF4 100%);
    background-size: 200% 100%;
    animation: esq-brillo 1.3s ease-in-out infinite;
}

@keyframes esq-brillo {
    from { background-position: 150% 0; }
    to { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .esq {
        animation: none;
    }
}

.buscador-esqueleto {
    pointer-events: none;
}

.buscador-tarjeta.buscador-esqueleto {
    box-shadow: none;
    transform: none;
}

.esq-icono {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 14px;
}

.esq-linea {
    height: 16px;
    margin: 3px 0;
    border-radius: 6px;
}

.esq-fina {
    height: 10px;
    margin-top: 6px;
}

.esq-solo-pc {
    display: none;
}

.esq-cabecera {
    width: 110px;
    margin-top: 8px;
}

#productSearchModal .product-card.buscador-esqueleto .card-body {
    gap: 6px;
}

.esq-foto {
    height: 168px;
    border-radius: 0;
}

.esq-precio {
    width: 48%;
    height: 24px;
    margin-top: auto;
}

.esq-boton {
    width: 100%;
    height: 40px;
    margin-top: 6px;
    border-radius: 10px;
}

/* Afinando una búsqueda: los resultados de antes, atenuados hasta que llegan los nuevos */
#productsGrid.is-actualizando {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.15s;
}

/* --- Nombres de las tarjetas y título de la sección: más grandes, con la letra de los títulos --- */
.buscador-tarjeta-nombre {
    font-family: var(--font-heading);
    font-size: var(--fs-18);
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.buscador-vista-titulo {
    font-size: var(--fs-36);
    letter-spacing: -0.02em;
}

@media (min-width: 992px) {
    .buscador-tarjeta-nombre {
        font-size: var(--fs-22);
    }

    .buscador-vista-icono {
        flex-basis: 76px;
        width: 76px;
        height: 76px;
        border-radius: 20px;
        font-size: 2.6rem;
    }

    .esq-icono {
        flex: 0 0 auto;
        width: 72px;
        height: 72px;
        border-radius: 18px;
    }

    .esq-linea {
        height: 22px;
    }

    .esq-fina {
        height: 12px;
        margin-top: 10px;
    }

    .esq-solo-pc {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .buscador-tarjeta-nombre {
        font-size: 1.0625rem;
    }

    .buscador-vista-titulo {
        font-size: var(--fs-28);
    }

    .esq-icono {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .esq-foto {
        height: 132px;
    }
}

/* El título de los productos (la categoría, el tipo o la búsqueda), a juego */
.buscador-resultados-titulo {
    font-size: var(--fs-28);
    letter-spacing: -0.02em;
}

@media (max-width: 575.98px) {
    .buscador-resultados-titulo {
        font-size: var(--fs-22);
    }
}

/* --- Cantidad en la lista: «Añadir» se convierte en [−] cantidad [+] y unidad ---
   El contenedor es de consulta: con sitio (PC) la unidad va al lado; en la
   tarjeta estrecha del móvil (2 columnas) pasa a su propia fila. */
#productSearchModal .producto-accion {
    container-type: inline-size;
    margin-top: var(--space-2);
}

#productSearchModal .producto-accion .producto-anadir {
    margin-top: 0;
}

#productSearchModal .producto-enlista {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    color: var(--success, #15803D);
    font-size: var(--fs-12, 0.75rem);
    font-weight: 700;
}

#productSearchModal .producto-cantidad-fila {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

#productSearchModal .producto-cantidad {
    flex: 1 1 128px;
    display: flex;
    align-items: center;
    min-width: 0;
    height: 40px;
    border: 1.5px solid var(--brand-600);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
}

#productSearchModal .producto-cantidad-btn {
    flex: 0 0 40px;
    width: 40px;
    height: 100%;
    padding: 0;
    border: 0;
    background: var(--brand-600);
    color: #fff;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#productSearchModal .producto-cantidad-btn:hover {
    background: var(--brand-700, #9F1620);
}

#productSearchModal .producto-cantidad-valor {
    flex: 1;
    min-width: 0;
    text-align: center;
    color: var(--text);
    font-size: var(--fs-14);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

#productSearchModal .producto-unidad,
#productSearchModal .producto-unidad-fija {
    flex: 1 1 100%;
    height: 40px;
    min-width: 64px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-14);
    font-weight: 600;
}

#productSearchModal .producto-unidad {
    padding: 0 6px;
}

#productSearchModal .producto-unidad-fija {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@container (min-width: 190px) {
    #productSearchModal .producto-cantidad { flex: 1 1 0; }
    #productSearchModal .producto-unidad,
    #productSearchModal .producto-unidad-fija { flex: 0 0 64px; }
}

#productSearchModal .product-card.en-lista {
    border-color: var(--success, #15803D);
    box-shadow: 0 0 0 1px var(--success, #15803D);
}

/* Avisos: el diseño de todos está en css/components.css (.super-toast) */

/* --- Tarjeta «Favoritos»: tono propio (rosa del corazón) --- */
#productSearchModal .buscador-tarjeta.is-favoritos {
    --tono: #BE123C;
    --tono-fondo: #FFE4E6;
    border: 1.5px solid #FDA4AF;
}

#productSearchModal .buscador-tarjeta.is-favoritos:hover {
    border-color: #BE123C;
}

.buscador-vacio-icono.es-favoritos {
    background: #FFE4E6;
    border-color: #FDA4AF;
    color: #BE123C;
}

.rango-punto.is-este.is-best {
    background: var(--success);
}

.rango-punto.is-este.is-best {
    box-shadow: 0 0 0 2px var(--success);
}

/* Ingredientes de la ficha (Open Food Facts): legibles, alérgenos en negrita */
.ficha-ingredientes {
    margin: .25rem 0 .75rem;
}

.ficha-ingredientes summary {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0F172A;
    cursor: pointer;
}

.ficha-ingredientes p {
    margin: .4rem 0 0;
    padding: .8rem 1rem;
    border-radius: 12px;
    background: #F8FAFC;
    font-size: .95rem;
    line-height: 1.6;
    color: #334155;
}

.ficha-ingredientes p strong {
    color: #0F172A;
    font-weight: 800;
}

.ficha-ingredientes .ficha-ingredientes-nota {
    padding: 0;
    background: none;
    font-size: .85rem;
    color: #64748B;
}

.ficha-ingredientes summary {
    list-style: none;
}

.ficha-ingredientes summary::-webkit-details-marker {
    display: none;
}

.ficha-ingredientes summary::before {
    content: "\25B8";
    display: inline-block;
    transition: transform .15s ease;
}

.ficha-ingredientes[open] summary::before {
    transform: rotate(90deg);
}

/* Historial de precios */
#productPriceHistory {
    --h-linea: #1D4ED8;
    --h-area: rgba(29, 78, 216, .12);
    --h-grid: #E2E8F0;
    --h-texto: #475569;
}
.historial-cabecera { flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.historial-resumen { margin: .15rem 0 0; font-size: .95rem; color: #475569; }
.historial-periodos { display: flex; flex-wrap: wrap; gap: .4rem; }
.historial-periodo {
    min-height: 44px; padding: .4rem .9rem; font-size: .95rem; font-weight: 600;
    border: 1px solid #CBD5E1; border-radius: 999px; background: #fff; color: #0F172A; cursor: pointer;
}
.historial-periodo:hover { background: #F1F5F9; }
.historial-periodo.activo { background: #0F172A; border-color: #0F172A; color: #fff; }
.historial-periodo:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; }
.historial-grafica { position: relative; width: 100%; }
.historial-svg { display: block; width: 100%; height: auto; touch-action: pan-y; overflow: visible; }
.historial-svg .h-grid { stroke: var(--h-grid); stroke-width: 1; }
.historial-svg .h-eje { fill: var(--h-texto); font-size: 13px; }
.historial-svg .h-linea { stroke: var(--h-linea); stroke-width: 2.5; stroke-linejoin: round; }
.historial-svg .h-area { fill: var(--h-area); stroke: none; }
.historial-svg .h-punto { fill: var(--h-linea); stroke: #fff; stroke-width: 2; }
.historial-svg .h-guia { stroke: #94A3B8; stroke-width: 1; stroke-dasharray: 4 3; }
.historial-svg .h-marca { fill: var(--h-linea); stroke: #fff; stroke-width: 2; }
.historial-tip {
    position: absolute; pointer-events: none; z-index: 2; display: flex; flex-direction: column;
    padding: .4rem .65rem; background: #0F172A; color: #fff; border-radius: 8px; white-space: nowrap;
    font-size: .9rem; line-height: 1.3; box-shadow: 0 4px 12px rgba(15, 23, 42, .25);
}
.historial-tip[hidden] { display: none; }
.historial-tip span { font-size: .85rem; color: #CBD5E1; }
.historial-vacio { padding: .75rem 0 .25rem; }
.historial-vacio-precio { display: block; font-size: 1.75rem; font-weight: 800; color: #0F172A; }
.historial-vacio-fecha { display: block; font-size: .9rem; color: #475569; }
.historial-vacio p { margin: .6rem 0 0; font-size: .95rem; color: #475569; }
@media (prefers-color-scheme: dark) {
    :root[data-theme="dark"] #productPriceHistory { --h-linea: #60A5FA; --h-area: rgba(96, 165, 250, .16); --h-grid: #334155; --h-texto: #CBD5E1; }
}

/* --- Ordenar y filtrar (vista de productos del buscador) ---
   La barra va a la derecha del título en PC y debajo en el móvil. El panel
   de filtros se abre debajo, encima de los productos (js/product-system.js). */
#productSearchModal .buscador-resultados-cabecera {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
}

.buscador-resultados-textos {
    min-width: 0;
}

.buscador-herramientas {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.buscador-orden {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.buscador-orden > i {
    position: absolute;
    left: 14px;
    font-size: 1.15rem;
    color: var(--text-2);
    pointer-events: none;
}

.buscador-orden-select {
    height: 44px;
    max-width: 100%;
    padding: 0 38px 0 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23475569' d='M12 15.6 6.4 10l1.4-1.4 4.2 4.2 4.2-4.2 1.4 1.4z'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.buscador-orden-select:focus-visible,
.buscador-btn-filtros:focus-visible,
.buscador-chip-super:focus-visible,
.buscador-rapido:focus-visible {
    outline: 3px solid #1D4ED8;
    outline-offset: 2px;
}

.buscador-btn-filtros {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 var(--space-4);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
}

.buscador-btn-filtros i {
    font-size: 1.15rem;
}

.buscador-btn-filtros.is-activo,
.buscador-btn-filtros[aria-expanded="true"] {
    border-color: var(--brand-600);
    color: var(--brand-600);
}

.buscador-filtros-n {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brand-600);
    color: #fff;
    font-size: .8125rem;
    font-weight: 700;
}

.buscador-filtros {
    margin: 0 0 var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-2, #F8FAFC);
}

.buscador-filtros[hidden] {
    display: none;
}

.buscador-filtro {
    margin: 0 0 var(--space-4);
    padding: 0;
    border: 0;
    min-width: 0;
}

.buscador-filtro legend {
    float: none;
    width: auto;
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.buscador-filtro-ayuda {
    margin: 0 0 var(--space-2);
    font-size: .875rem;
    color: var(--text-2);
}

.buscador-filtro-supers,
.buscador-rapidos {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.buscador-chip-super,
.buscador-rapido {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: .9375rem;
    font-weight: 600;
}

.buscador-chip-super .sc-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: none;
}

.buscador-chip-ok {
    display: none;
    font-size: 1.1rem;
}

.buscador-chip-super.is-on,
.buscador-rapido.is-on {
    border-color: var(--brand-600);
    background: var(--brand-50, #FFF1F2);
    color: var(--brand-700, #A3151F);
}

.buscador-chip-super.is-on .buscador-chip-ok {
    display: inline;
}

.buscador-rango {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-3);
}

.buscador-rango-campo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.buscador-rango-campo input {
    width: 120px;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    font-size: 1rem;
}

.buscador-filtros-pie {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
}

@media (max-width: 575.98px) {
    .buscador-herramientas {
        width: 100%;
        flex-wrap: nowrap;
    }

    /* «Ordenar» y «Filtrar» en la misma fila: el desplegable se encoge */
    .buscador-orden {
        flex: 1 1 0;
        min-width: 0;
    }

    .buscador-btn-filtros {
        flex: none;
        padding: 0 12px;
    }

    /* Que quepa «Mayor coincidencia» en 360 px */
    .buscador-orden > i {
        left: 10px;
    }

    .buscador-orden-select {
        padding: 0 26px 0 34px;
        background-position: right 6px center;
        font-size: .9375rem;
    }

    .buscador-orden-select {
        width: 100%;
    }

    .buscador-filtros {
        padding: var(--space-3);
    }

    .buscador-rango-campo {
        flex: 1 1 140px;
    }

    .buscador-rango-campo input {
        width: 100%;
        min-width: 0;
    }

    .buscador-filtros-pie > * {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* Comparativa de la ficha en una lista: «Solo con los súpers de tu lista ·
   Ver también otros N» (js/product-system.js, renderComparison) */
.comparativa-filtro {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin: var(--space-3) 0 0;
    font-size: .9375rem;
    color: var(--text-2);
}

.comparativa-filtro i {
    font-size: 1.1rem;
}

.comparativa-filtro-btn {
    min-height: 44px;
    padding: 0 4px;
    color: var(--brand-600);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Nutri-Score y valoración en la línea del súper (letra mínima 0,8 rem) */
.super-info { flex-wrap: wrap; }
.card-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 0.8rem;
}
.nutri-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    padding: 1px 5px;
    border-radius: 6px;
    background: var(--ns);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.3;
}
.nutri-chip.nutri-c { color: var(--text, #1f2937); }
.rating-chip {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text, #1f2937);
    white-space: nowrap;
}
.rating-chip .rating-n { font-weight: 400; color: var(--text-2); }
/* La estrella en ámbar (3,2:1 sobre blanco; la nota va en texto y en el aria-label) */
.rating-chip .rating-estrella { color: #D97706; }
/* En móvil la tarjeta es estrecha: sin el número de reseñas, para no ocupar otra línea */
@media (max-width: 575.98px) {
    .card-badges { gap: 4px; }
    .rating-chip .rating-n { display: none; }
}

/* --- Básicos: «huevos» = lo más barato de cada súper, arriba de los resultados
   (js/product-system.js, pintarBasico). Una fila por súper; la más barata en verde. */
.basico-tarjeta {
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    transition: opacity 0.15s;
}

.basico-tarjeta.is-actualizando {
    opacity: 0.5;
    pointer-events: none;
}

.basico-cabecera {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.basico-icono {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--brand-50);
    font-size: 1.75rem;
}

.basico-titulo {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.basico-sub {
    margin: 2px 0 0;
    color: var(--text-2);
    font-size: var(--fs-16);
}

.basico-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.basico-chip {
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-16);
    font-weight: 600;
}

.basico-chip[aria-pressed="true"] {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
}

.basico-filas {
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
}

.basico-fila {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border);
}

.basico-producto {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    text-align: left;
}

.basico-nombre {
    color: var(--text);
    font-size: var(--fs-16);
    font-weight: 600;
    line-height: 1.3;
}

.basico-producto:hover .basico-nombre {
    text-decoration: underline;
}

.basico-envase {
    color: var(--text-2);
    font-size: var(--fs-14);
}

.basico-derecha {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    width: 128px;
}

.basico-precio {
    color: var(--text);
    font-family: var(--font-heading);
    font-size: var(--fs-18);
    font-weight: 800;
    white-space: nowrap;
}

.basico-fila.es-mas-barato .basico-precio {
    color: var(--success);
}

.basico-fila.es-mas-barato .basico-precio::after {
    content: "más barato";
    display: block;
    font-family: var(--font-body);
    font-size: var(--fs-12);
    font-weight: 700;
    text-align: right;
}

#productSearchModal .basico-derecha .producto-anadir,
#productSearchModal .basico-derecha .producto-accion {
    width: 100%;
    margin-top: 0;
}

.basico-ver-mas {
    width: 100%;
    min-height: 44px;
    margin-top: var(--space-2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-16);
    font-weight: 700;
}

.basico-nota {
    margin: var(--space-3) 0 0;
    color: var(--text-2);
    font-size: var(--fs-14);
}

@media (max-width: 420px) {
    .basico-derecha {
        width: 112px;
    }
}
