/*
 * Criticalo! - componentes compartidos por las paginas con menu lateral.
 * Usa los tokens de css/tokens.css (enlazar antes).
 */

/* --- Menu lateral: cerrado en movil, fuera del orden de tabulacion --- */
@media (max-width: 992px) {
    body .sidebar:not(.active) {
        visibility: hidden;
    }

    body .sidebar {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
    }

    body .sidebar.active {
        visibility: visible;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
    }
}

/* Cabecera movil y velo del menu. Las paginas antiguas traen su copia en
   linea (que manda por ir despues); estas son las de base para las que no. */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface);
    z-index: 1050;
    padding: 0 var(--space-5);
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 992px) {
    .mobile-header {
        display: flex;
    }
}

.mobile-toggle-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 1.25rem;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1090;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar .nav-item {
    min-height: var(--tap);
}

.sidebar .nav-item.active {
    color: var(--brand-600);
}

.sidebar-legal {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    margin-top: var(--space-3);
    font-size: var(--fs-12);
}

.sidebar-legal a,
.sidebar-legal button {
    color: var(--text-2);
    text-decoration: underline;
    text-underline-offset: 2px;
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding-block: 2px;
}

/* «Cerrar sesión»: objetivo de 24 px como mínimo */
.sidebar form .btn-link {
    min-height: 24px;
    padding-block: 2px !important;
}

/* El anillo de foco sale al instante aunque el elemento tenga `transition: all` */
a:focus-visible,
button:focus-visible {
    transition-duration: 0s !important;
}

.sidebar-legal a:hover,
.sidebar-legal button:hover {
    color: var(--text);
}

/* En escritorio el menu no tapa los modales (Bootstrap usa 1050-1060) */
@media (min-width: 993px) {
    body .sidebar {
        z-index: 1030;
    }
}

/* Botones de abrir/cerrar menu: 44 px */
.mobile-toggle-btn,
.btn-close-sidebar {
    min-width: var(--tap);
    min-height: var(--tap);
}

.btn-close-sidebar {
    color: var(--brand-600);
}

/* --- Objetivos tactiles de 44 px: marcar, cantidad, favorito y borrar --- */
.check-circle,
.qty-btn,
.favorite-btn,
.btn-trash,
.btn-icon-44,
.back-btn,
.header-action-btn,
.btn-manage,
.edit-avatar-btn,
.rec-overlay-btn,
.btn-add-quick {
    min-width: var(--tap) !important;
    min-height: var(--tap) !important;
}


/* --- Tarjetas que son enlaces enteros --- */
a.card-link-reset,
a.list-card-carousel,
a.list-card {
    color: inherit;
    text-decoration: none;
    display: flex;
}

a.card-link-reset:hover,
a.list-card-carousel:hover,
a.list-card:hover {
    color: inherit;
}

/* Tarjeta entera clicable con .stretched-link en el titulo: lo que hay
   dentro y se puede pulsar va por encima del enlace estirado */
.card-over-link {
    position: relative;
    z-index: 2;
}

.list-card:has(.stretched-link:focus-visible),
.list-card-carousel:has(.stretched-link:focus-visible) {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

.list-card .stretched-link:focus-visible,
.list-card-carousel .stretched-link:focus-visible {
    outline: none !important;
}

/* Botones que antes eran div/span con onclick */
.btn-reset {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
}

/* --- Avisos (js/toast-helper.js) ---------------------------------------------
   Todos arriba en el centro, por encima de los modales, con fondo sólido del
   color del tipo y texto blanco (contraste AA): antes salían abajo, blancos y
   con una raya de color, y se perdían. Icono en círculo, título y mensaje,
   y una barra que dice cuánto le queda (se para con el ratón o el foco). */
.toast-pila {
    position: fixed;
    left: 50%;
    top: clamp(12px, 8vh, 88px);
    transform: translateX(-50%);
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(560px, calc(100vw - 24px));
    pointer-events: none;
}

.toast-region {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.super-toast {
    --toast-fondo: #1D4ED8;
    position: relative;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 10px 16px 14px;
    overflow: hidden;
    background: var(--toast-fondo);
    color: #fff;
    border: 0;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.2);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(-18px) scale(0.96);
    transition: opacity 0.22s ease, transform 0.32s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.super-toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.super-toast.success { --toast-fondo: #15803D; }
.super-toast.error { --toast-fondo: #B91C1C; }
.super-toast.warning { --toast-fondo: #B45309; }
.super-toast.info { --toast-fondo: #1D4ED8; }

.super-toast .toast-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.super-toast .toast-msg {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-wrap: anywhere;
}

.super-toast .toast-titulo {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.25;
}

.super-toast .toast-detalle {
    opacity: 0.95;
}

.super-toast .toast-close {
    flex-shrink: 0;
    align-self: flex-start;
    width: 40px;
    height: 40px;
    margin: -4px 0 0;
    border: 0;
    background: none;
    color: #fff;
    border-radius: 10px;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.super-toast .toast-close:hover,
.super-toast .toast-close:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    outline: none;
}

.super-toast .toast-action {
    flex-shrink: 0;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    background: #fff;
    color: var(--toast-fondo);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 800;
    text-decoration: none;
}

.super-toast .toast-action:hover {
    background: rgba(255, 255, 255, 0.88);
}

.super-toast .toast-action:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* Lo que le queda: se vacía de izquierda a derecha */
.super-toast .toast-progreso {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    width: 100%;
    background: rgba(255, 255, 255, 0.55);
    transform-origin: left center;
    animation: toast-progreso linear forwards;
}

.super-toast.pausado .toast-progreso {
    animation-play-state: paused;
}

@keyframes toast-progreso {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 575.98px) {
    .toast-pila { top: 10px; }
    .super-toast { flex-wrap: wrap; padding-right: 48px; }
    .super-toast .toast-close { position: absolute; top: 8px; right: 6px; margin: 0; }
    .super-toast .toast-action { order: 5; flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .super-toast,
    .super-toast.visible { transform: none; transition: opacity 0.15s ease; }
    .super-toast .toast-progreso { display: none; }
}

/* --- Precio: el unitario manda --- */
.price-unit-lead {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--fs-22);
    color: var(--text);
    line-height: 1.1;
}

.price-pack-sub {
    font-size: var(--fs-14);
    color: var(--text-2);
}

.chip-cheaper {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--success-50);
    color: var(--success);
    border: 1px solid #A7F3D0;
    font-size: var(--fs-12);
    font-weight: 600;
    line-height: 1.4;
}

.chip-cheaper.is-best {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

/* Fila de la comparativa */
.compare-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
}

.compare-row:last-child { border-bottom: 0; }

.compare-row .compare-store {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 600;
    font-size: var(--fs-14);
    min-width: 0;
}

.compare-row .compare-prices {
    text-align: right;
    font-size: var(--fs-14);
}

.compare-row .compare-unit {
    display: block;
    font-weight: 700;
    color: var(--text);
}

.compare-row .compare-pack {
    display: block;
    font-size: var(--fs-12);
    color: var(--text-2);
}

/* La fecha de cada precio: en la comparativa conviven capturas de dias
   distintos (js/product-system.js) */
.compare-row .compare-date,
.price-date {
    display: block;
    font-size: var(--fs-12);
    color: var(--text-2);
    font-weight: 400;
}

.price-dates-note {
    margin-top: var(--space-1);
    font-size: var(--fs-12);
    color: var(--text);
}

.compare-row .compare-diff-up { color: var(--danger); font-weight: 600; }
.compare-row .compare-diff-down { color: var(--success); font-weight: 600; }

/* --- Reseñas: estrellas como radiogroup --- */
.star-input {
    display: inline-flex;
    gap: var(--space-1);
    border: 0;
    padding: 0;
    margin: 0;
}

.star-input .star-option {
    position: relative;
    display: inline-flex;
}

.star-input input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.star-input label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    margin: 0;
    border-radius: var(--radius-btn);
    font-size: 1.5rem;
    line-height: 1;
    color: #94A3B8;
    cursor: pointer;
}

.star-input label.is-on {
    color: #B45309;
}

.star-input label:hover {
    background: var(--warning-50);
}

.star-input input:focus-visible + label {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

.review-threshold {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-card);
    background: var(--bg);
    border: 1px dashed var(--border);
    color: var(--text-2);
    font-size: var(--fs-14);
}

.review-summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-14);
    color: var(--text-2);
}

.review-summary .review-avg {
    font-family: var(--font-heading);
    font-size: var(--fs-22);
    font-weight: 700;
    color: var(--text);
}

.review-stars-static {
    color: #B45309;
    letter-spacing: 1px;
}

.review-list .review-card,
.review-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--space-4);
    background: var(--surface);
}

.review-card .review-meta {
    font-size: var(--fs-12);
    color: var(--text-2);
}

.review-card .review-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

/* Los me gusta de tu propia opinión: solo texto, no un botón */
.review-card .review-likes-texto {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding-right: var(--space-2);
    color: var(--text-2);
    font-size: var(--fs-14);
}

.review-card .review-actions button {
    min-height: var(--tap);
    padding: 0 var(--space-3);
    border-radius: var(--radius-btn);
    border: 1px solid transparent;
    background: none;
    color: var(--text);
    font-size: var(--fs-14);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.review-card .review-actions button:hover {
    background: var(--bg);
}

.review-card .review-actions button[aria-pressed="true"] {
    color: var(--brand-600);
}

.review-mine-badge {
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--info);
    background: var(--info-50);
    border-radius: var(--radius-badge);
    padding: 2px var(--space-2);
}

/* --- Avisar de un error --- */
.report-form {
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--space-4);
    background: var(--bg);
}

.report-form fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.report-form legend {
    font-size: var(--fs-14);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.report-form .form-check {
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.report-form .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    float: none;
}

/* --- Selector de emoji como radiogroup --- */
.emoji-radio {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.emoji-radio input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.emoji-radio label {
    width: var(--tap);
    height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    border-radius: var(--radius-btn);
    border: 2px solid transparent;
    background: var(--bg);
    cursor: pointer;
}

.emoji-radio input:checked + label {
    border-color: var(--brand-600);
    background: var(--brand-50);
}

.emoji-radio input:focus-visible + label {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

/* --- Nivel, experiencia y logros (Logros::nivelHtml / listaHtml) ---
   El estado no depende solo del color: lleva texto ("Conseguido" /
   "Pendiente"), borde continuo o discontinuo e icono a color o atenuado. */
.nivel-xp {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

.nivel-xp-cab {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-2);
}

.nivel-xp-nombre {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--fs-18, 1.125rem);
    color: var(--text);
}

.nivel-xp-nombre i {
    color: var(--warning);
}

.nivel-xp-cifra {
    font-weight: 700;
    font-size: var(--fs-14);
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

.nivel-xp-barra,
.logro-barra {
    display: block;
    overflow: hidden;
    background: var(--border);
    border-radius: var(--radius-pill);
}

.nivel-xp-barra {
    height: 12px;
    margin: var(--space-3) 0 var(--space-2);
}

.nivel-xp-barra span,
.logro-barra span {
    display: block;
    height: 100%;
    background: var(--brand-600);
    border-radius: inherit;
    transition: width 0.6s ease;
}

.nivel-xp-falta {
    margin: 0;
    font-size: var(--fs-14);
    color: var(--text);
}

.nivel-xp-como {
    margin-top: var(--space-4);
    border-top: 1px solid var(--border);
    padding-top: var(--space-3);
    font-size: var(--fs-14);
    color: var(--text-2);
}

.nivel-xp-como summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    min-height: 32px;
}

.nivel-xp-como summary:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

.nivel-xp-como ul {
    padding-left: var(--space-5);
    margin: var(--space-2) 0;
}

.nivel-xp-desglose {
    margin: var(--space-2) 0;
    padding: var(--space-2) var(--space-3);
    background: var(--bg);
    border-radius: var(--radius-btn);
    color: var(--text);
}

.nivel-xp-niveles {
    margin: 0;
    font-size: var(--fs-12);
}

.logros-lista {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    grid-auto-rows: 1fr;
    gap: var(--space-3);
}

.logro {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 100%;
    padding: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.logro-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-2);
}

.logro-icono {
    width: var(--tap);
    height: var(--tap);
    border-radius: var(--radius-btn);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
}

.logro-xp {
    font-size: var(--fs-12);
    font-weight: 700;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--warning-50);
    color: var(--warning);
    white-space: nowrap;
}

.logro-titulo {
    color: var(--text);
    font-size: var(--fs-16);
    font-family: var(--font-heading);
    line-height: 1.3;
}

.logro-descripcion {
    font-size: var(--fs-14);
    color: var(--text-2);
    line-height: 1.4;
}

.logro-pie {
    margin-top: auto;
    padding-top: var(--space-3);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
}

.logro-estado {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--fs-12);
    font-weight: 600;
    padding: 2px var(--space-2);
    border-radius: var(--radius-badge);
    white-space: nowrap;
}

.logro-fecha {
    font-weight: 400;
}

.logro-progreso-caja {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
}

.logro-barra {
    flex: 1;
    height: 6px;
}

.logro-progreso {
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.logro--conseguido {
    border-color: #6EE7B7;
    background: linear-gradient(180deg, var(--success-50), var(--surface) 70%);
    box-shadow: var(--shadow-1);
}

.logro--conseguido .logro-icono {
    background: var(--success);
    color: #fff;
}

.logro--conseguido .logro-estado {
    background: var(--success-50);
    color: var(--success);
}

.logro--conseguido .logro-estado::before {
    content: "\2713";
    content: "\2713" / "";
    font-weight: 700;
}

.logro--pendiente {
    border-style: dashed;
    background: var(--bg);
}

.logro--pendiente .logro-titulo,
.logro--pendiente .logro-icono {
    opacity: 0.75;
}

.logro--pendiente .logro-xp {
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.logro--pendiente .logro-icono {
    background: var(--surface);
    color: #64748B;
    border: 1px dashed #94A3B8;
}

.logro--pendiente .logro-estado {
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
    .nivel-xp-barra span,
    .logro-barra span,
    .logro {
        transition: none;
    }
}

@media (max-width: 480px) {
    .logros-lista {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }
}

/* Sustituye a animate.css (cdnjs) en el feed de supers.php */
.animate__animated {
    animation-duration: 0.5s;
    animation-fill-mode: both;
}

.animate__fadeInUp {
    animation-name: criticaloFadeInUp;
}

@keyframes criticaloFadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 16px, 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* --- Fecha de los precios (js/precios-actualizados.js): discreta pero
   legible, minimo 12 px y texto secundario de 7:1 --- */
.precios-actualizados {
    font-size: max(0.8125rem, 12px) !important;
    color: var(--text-2) !important;
    line-height: 1.4;
}


/* --- Favorito que la tienda ya no vende (favoritos.php) ---
   Se avisa con texto y con borde discontinuo; la foto se apaga pero el texto
   mantiene el contraste (sin opacity en la tarjeta) */
.product-card--unavailable {
    border-style: dashed !important;
    border-color: #94A3B8 !important;
    background: var(--bg) !important;
}

.product-card--unavailable .product-img-box img,
.product-card--unavailable .product-img-emoji {
    filter: grayscale(1);
    opacity: 0.7;
}

.product-card--unavailable .product-unavailable {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
    padding: 2px var(--space-2);
    border-radius: var(--radius-badge);
    background: var(--danger-50);
    color: var(--danger) !important;
}


/* Selector de icono de lista (inicio, mis-listas y editar lista) */
button.emoji-option {
    border: 2px solid transparent;
    background: none;
    min-width: 40px;
    min-height: 40px;
    border-radius: var(--radius-badge);
    line-height: 1;
}

button.emoji-option[aria-pressed="true"] {
    border-color: var(--brand-600);
    background: var(--brand-50);
}

button.emoji-selector {
    padding: 0;
}

/* El aviso del skip-link va dentro de su propio nav */
.skip-nav {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
}

/* (los avisos van arriba: ya no tapan la barra inferior del total) */

/* Icono de marca (el carrito de logo.png recortado) en cabeceras y menu */
.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-badge);
    object-fit: contain;
}

/* Giro del icono de carga (Remix Icon no trae ri-spin) */
.ri-spin { display: inline-block; animation: ri-spin-giro 1s linear infinite; }
@keyframes ri-spin-giro { to { transform: rotate(360deg); } }

/* Píldora de los súpers de una lista (tarjetas de «Tus listas activas»):
   por encima del enlace estirado de la tarjeta, para que salga su tooltip */
.lista-supers-pill {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    background: #F1F5F9;
    color: var(--text, #0F172A);
    border: 1px solid var(--border, #E2E8F0);
    font-size: 0.78rem;
    font-weight: 700;
}

/* Barrita de niveles (Logros::barraNivelesHtml): un tramo por nivel */
.barra-niveles {
    margin: 10px 0 4px;
}

.barra-niveles-tramos {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.barra-niveles-tramo {
    position: relative;
    display: block;
    height: 10px;
    border-radius: 999px;
    background: #E2E8F0;
    overflow: hidden;
}

.barra-niveles-tramo > span {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #F59E0B, #D97706);
    transition: width .6s ease;
}

.barra-niveles-tramo.es-actual {
    box-shadow: 0 0 0 2px #FDE68A;
}

.barra-niveles-pie {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-2, #475569);
}

.barra-niveles-mini {
    margin: 6px 0 4px;
    max-width: 240px;
}

.barra-niveles-mini .barra-niveles-tramo {
    height: 7px;
}

@media (prefers-reduced-motion: reduce) {
    .barra-niveles-tramo > span {
        transition: none;
    }
}

/* Instalar la app (PWA) en el menu lateral: un nav-item mas, pero boton.
   js/app.js quita el `hidden` solo si se puede instalar. */
.sidebar-instalar {
    margin-bottom: var(--space-3, 12px);
}

.sidebar-instalar .nav-item {
    width: 100%;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    text-align: left;
    color: var(--brand-600, #C81D2A);
}

.sidebar-instalar-ayuda {
    margin: 4px 0 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--brand-50, #FFF1F2);
    color: var(--text, #0F172A);
    font-size: .875rem;
    line-height: 1.45;
}

/* Teclado del movil abierto (js/app.js pone <html class="teclado-abierto">).
   - Las barras fijas de abajo (total de la lista...) se esconden: con el
     teclado subian encima de el y tapaban los botones.
   - Los modales ocupan solo el trozo de pantalla que se ve (en el iPhone el
     teclado no encoge la pagina): asi «Guardar» o «Entrar» se pueden alcanzar
     desplazando el modal, en vez de quedar debajo del teclado. */
@media (max-width: 991.98px) {
    .teclado-abierto .mobile-bottom-bar {
        display: none !important;
    }

    .teclado-abierto .modal.show {
        top: var(--arriba-visible, 0);
        height: var(--alto-visible, 100%);
    }

    .teclado-abierto .modal.show .modal-dialog-centered {
        min-height: calc(100% - var(--bs-modal-margin, .5rem) * 2);
    }

    .teclado-abierto .modal.show .modal-fullscreen-sm-down,
    .teclado-abierto .modal.show .modal-fullscreen {
        height: 100%;
    }
}

/* Logo de la cabecera movil: enlace a inicio, con el color del texto */
.mobile-header-marca {
    min-height: 44px;
    color: var(--text, #0F172A);
    text-decoration: none;
}

.mobile-header-marca:hover {
    color: var(--text, #0F172A);
}
