/* ==========================================================
   SISTEMA DE DISEÑO - OPTICA CHILE (Premium & Cálido)
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Koho:ital,wght@0,500;0,700;1,500;1,700&display=swap');

:root {
    /* Fondo con un gris ultra sutil para que las tarjetas blancas resalten */
    --background: 210 20% 98%; 
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    
    /* Azul Profundo (Oxford Blue) de la marca — #1b2447 exacto */
    --primary: 228 45% 19%;
    --primary-hover: 228 45% 25%;
    --primary-foreground: 210 40% 98%;
    
    /* Dorado Cálido para acentos y estados activos — #d0aa63 exacto */
    --brand-gold: 39 54% 60%;
    --brand-gold-hover: 39 54% 68%;
    --brand-gold-light: 39 54% 92%;

    /* Colores secundarios y bordes */
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --destructive: 0 84.2% 60.2%;
    --border: 214.3 31.8% 90%;
    --input: 214.3 31.8% 91.4%;
    --ring: 43 74% 49%; /* El anillo de enfoque ahora es dorado */
    
    --radius: 6px;
    --radius-pill: 999px;

    /* Rojo de acento de marca — #db3545 exacto */
    --brand-red: 354 70% 53%;

    /* Colores propios de cada laboratorio (paso 3, Bifocal/Multifocal) —
       aparte de tu paleta de marca, para diferenciar cada tarjeta. */
    --rod-blue: 214 76% 48%;
    --rod-blue-light: 213 77% 95%;
    --emp-yellow: 48 100% 50%;
    --emp-yellow-light: 48 100% 94%;

    /* Spacing & Sizing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Nuevas Sombras de Elevación (Más difusas y elegantes) */
    --shadow-sm: 0 2px 4px rgba(27, 36, 71, 0.04);
    --shadow-md: 0 4px 12px rgba(27, 36, 71, 0.08);
    --shadow-hover: 0 12px 24px -4px rgba(27, 36, 71, 0.15);
}

/* ==========================================================
   RESET & BASE
   ========================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================
   LAYOUT Y PANELES
   ========================================================== */
#app-container {
    max-width: 1200px;
    margin: var(--spacing-lg) auto;
    padding: 0 var(--spacing-md);
    position: relative;
}

.main-layout {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    align-items: stretch;
}

.visual-panel {
    flex: 0 0 calc(38% - var(--spacing-md));
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-self: stretch; /* Volvemos a stretch para la estructura original */
    /* Eliminamos el position: sticky y el top */
}

/* ==========================================================
   SKELETON LOADERS (Efecto de carga parpadeante)
   ========================================================== */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.skeleton-card {
    border: 2px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 1.5);
    padding: var(--spacing-lg);
    background: hsl(var(--card));
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.skeleton-line {
    background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--border)) 50%, hsl(var(--muted)) 75%);
    background-size: 200% 100%;
    animation: pulseSkeleton 1.5s infinite linear;
    border-radius: var(--radius);
}

.skeleton-title { height: 20px; width: 70%; }
.skeleton-price { height: 28px; width: 40%; margin-bottom: 8px; }
.skeleton-text { height: 14px; width: 100%; }
.skeleton-text-short { height: 14px; width: 80%; }
.skeleton-buttons { display: flex; gap: 8px; margin-top: auto; }
.skeleton-btn { height: 32px; flex: 1; border-radius: var(--radius); }

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

.frame-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 2);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

/* Resumen del pedido (Con acento dorado) */
.summary-inline-container {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    margin-top: var(--spacing-sm);
    background: hsl(var(--card));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    border-top: 4px solid hsl(var(--brand-gold));
    box-shadow: var(--shadow-md);
    text-align: left;
}

.summary-inline-container h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    color: hsl(var(--primary));
}

.summary-inline-container .summary-inline {
    font-size: 0.9rem;
    line-height: 1.6;
    color: hsl(var(--foreground));
}

.summary-inline-container .summary-inline strong {
    color: hsl(var(--primary));
    font-weight: 600;
}

.summary-inline-container .separator {
    color: hsl(var(--muted-foreground));
    margin: 0 var(--spacing-sm);
}

.image-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
}

.product-image-container img {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block !important;
    transition: transform 0.3s ease;
}

.product-image-container img:hover {
    transform: scale(1.05); /* Zoom sutil al ver el armazón */
}

.product-image-container h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: hsl(var(--primary));
    text-align: center;
    margin-top: var(--spacing-sm);
}

/* Image Carousel */
.image-carousel {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--primary));
    background: hsl(0 0% 100%);
    border: 1px solid hsl(var(--border));
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.carousel-btn:hover {
    background: hsl(var(--brand-gold));
    color: white;
    border-color: hsl(var(--brand-gold));
    transform: translateY(-50%) scale(1.1);
}

.carousel-btn.prev { left: -20px; }
.carousel-btn.next { right: -20px; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: var(--spacing-sm);
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: hsl(var(--muted-foreground) / 0.4);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-dot.active {
    background: hsl(var(--brand-gold));
    width: 24px;
    border-radius: 4px;
}

/* Panel de Opciones (Derecha) */
.options-panel {
    flex: 1;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 2);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    align-self: stretch;
}

/* ==========================================================
   CABECERA Y PROGRESO
   ========================================================== */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-sm);
}

.header-text { flex: 1; }

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--primary));
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.95rem;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

.step-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.step-progress .step-segment {
    height: 6px;
    width: 40px;
    border-radius: var(--radius-pill);
    background: hsl(var(--border));
    transition: all 0.4s ease;
}

.step-progress .step-segment.completed {
    background: hsl(var(--primary));
}

.step-progress .step-segment.current {
    background: hsl(var(--brand-gold));
    box-shadow: 0 0 8px hsl(var(--brand-gold) / 0.4);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ==========================================================
   BOTONES
   ========================================================== */
button {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    outline: none;
}

.btn-prev {
    background-color: white;
    color: hsl(var(--primary));
    border: 2px solid hsl(var(--border));
    padding: 0 1.2rem;
    height: 2.2rem;
}

.btn-prev:hover:not(:disabled) {
    border-color: hsl(var(--primary));
    background-color: hsl(var(--primary) / 0.05);
}

.btn-prev:focus-visible,
.btn-next:focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
}

.btn-confirm:focus-visible {
    outline: 2px solid hsl(var(--brand-gold));
    outline-offset: 2px;
}

.btn-next, .btn-confirm {
    background-color: hsl(var(--primary));
    color: white;
    padding: 0 1.5rem;
    height: 2.2rem;
    box-shadow: 0 4px 10px hsl(var(--primary) / 0.2);
}

.btn-next:hover:not(:disabled), .btn-confirm:hover:not(:disabled) {
    background-color: hsl(var(--primary-hover));
    transform: translateY(-2px);
    box-shadow: 0 6px 15px hsl(var(--primary) / 0.3);
}

.btn-next:disabled, .btn-confirm:disabled, .btn-prev:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-confirm {
    background-color: hsl(var(--brand-gold));
    color: hsl(var(--primary));
    height: 2.5rem;
    font-size: 1rem;
    box-shadow: 0 4px 10px hsl(var(--brand-gold) / 0.3);
}

.btn-confirm:hover:not(:disabled) {
    background-color: hsl(var(--brand-gold-hover));
    box-shadow: 0 6px 15px hsl(var(--brand-gold) / 0.4);
}

/* ==========================================================
   SECCIONES Y TARJETAS (Focos y Cristales)
   ========================================================== */
.section-group {
    display: none !important;
    animation: fadeInStep 0.4s ease forwards;
}

.section-group.active {
    display: block !important;
}

@keyframes fadeInStep {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: hsl(var(--primary));
    margin-bottom: var(--spacing-md);
    padding-bottom: 8px;
    border-bottom: 2px solid hsl(var(--border));
}

.options-list, .cristal-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

/* Micro-interacción: Elevación de Tarjetas */
.option-card, .cristal-card {
    border: 2px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 1.5);
    padding: var(--spacing-lg);
    cursor: pointer;
    background: hsl(var(--card));
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.option-card:hover, .cristal-card:hover {
    border-color: hsl(var(--brand-gold) / 0.6);
    box-shadow: var(--shadow-hover);
    transform: translateY(-5px);
}

.option-card.selected, .cristal-card.selected {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.02);
    box-shadow: 0 0 0 1px hsl(var(--primary));
}

/* Adorno visual para tarjeta seleccionada */
.option-card.selected::before, .cristal-card.selected::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: hsl(var(--brand-gold));
}

.option-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: hsl(var(--primary));
    margin-bottom: 4px;
}

.option-card p {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}

/* Textos de Cristales */
.cristal-card-titulo {
    font-size: 1rem;
    font-weight: 700;
    color: hsl(var(--primary));
    margin-bottom: var(--spacing-xs);
}

.cristal-card-precio {
    font-size: 1.25rem;
    font-weight: 700;
    color: hsl(var(--brand-gold));
    margin-bottom: var(--spacing-sm);
}

.cristal-card-detalles {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: var(--spacing-md);
}

.cristal-card-acciones {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: auto;
}

/* Botón de acción secundaria (Info / Video) — reutilizable en cualquier
   parte del wizard, no solo en las tarjetas de cristales. */
.btn-accion {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: none;
    background: hsl(var(--primary) / 0.05);
    color: hsl(var(--primary));
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: background 0.25s ease;
}

.btn-accion::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 3px;
    height: 2px;
    width: 0;
    background: hsl(var(--brand-gold));
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-accion:hover {
    background: hsl(var(--brand-gold-light));
}

.btn-accion:hover::after {
    width: calc(100% - 24px);
}

.btn-accion svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    stroke: currentColor;
    transition: transform 0.3s ease;
}

.btn-accion:hover svg {
    transform: scale(1.15);
}

.cristal-card-acciones .btn-accion {
    flex: 1;
}

/* ==========================================================
   FORMULARIO Y TABLA DE DIOPTRÍAS
   ========================================================== */
.prescription-container {
    width: 100%;
    margin-top: var(--spacing-sm);
}

/* Tabla anclada con el color de marca */
.prescription-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: var(--spacing-lg);
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.prescription-table th:first-child,
.prescription-table td:first-child {
    width: 110px;
}

.prescription-table thead th {
    background: hsl(var(--primary));
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    border-right: 1px solid hsl(var(--primary-hover));
}

.prescription-table thead th:first-child { text-align: left; }
.prescription-table thead th:last-child { border-right: none; }

.prescription-table tbody td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid hsl(var(--border));
}

.prescription-table tbody td:first-child {
    font-weight: 600;
    color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.03);
}

/* Inputs mejorados (fondo gris sutil, borde dorado al hacer click) */
.prescription-table input, .measurement-field input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid transparent;
    background: hsl(var(--muted) / 0.5);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    color: hsl(var(--primary));
    text-align: center;
    transition: all 0.3s ease;
}

.prescription-table input:focus, .measurement-field input:focus {
    outline: none;
    background: white;
    border-color: hsl(var(--brand-gold));
    box-shadow: 0 0 0 4px hsl(var(--brand-gold) / 0.15);
}

.additional-measurements {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.measurement-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: hsl(var(--primary));
    margin-bottom: var(--spacing-xs);
}

.measurement-field label small { color: hsl(var(--muted-foreground)); font-weight: 400; }

/* Subir receta */
.prescription-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: hsl(var(--primary));
    margin-bottom: var(--spacing-sm);
}

.upload-group-desc {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: var(--spacing-md);
}

/* Cada categoría de archivo (Bifocal/Multifocal): la caja de subida a la
   derecha, y a la izquierda un espacio reservado para una imagen
   ilustrativa (icono/foto de referencia) que se agrega más adelante. */
.upload-group {
    margin-bottom: var(--spacing-lg);
}

.upload-group:last-child {
    margin-bottom: 0;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.upload-illustration {
    flex: 0 0 130px;
    aspect-ratio: 1 / 1;
    align-self: center;
    border-radius: var(--radius);
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
}

.upload-illustration-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.upload-row .upload-area {
    flex: 1;
    min-width: 0;
}

.upload-box-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: hsl(var(--primary));
    margin-bottom: 2px;
}

.upload-box-desc {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: var(--spacing-sm);
}

.upload-area {
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    text-align: center;
    background: hsl(var(--card));
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-group .upload-area {
    padding: var(--spacing-md);
}

.upload-area:hover {
    border-color: hsl(var(--brand-gold));
    background: hsl(var(--brand-gold) / 0.02);
}

.upload-area.has-file {
    border-style: solid;
    border-color: hsl(142 71% 45%);
    background: hsl(142 71% 45% / 0.05);
}

.upload-placeholder p { font-weight: 600; color: hsl(var(--primary)); }
.upload-placeholder span { font-size: 0.8rem; color: hsl(var(--muted-foreground)); }

.file-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

/* ==========================================================
   MODALES Y TOASTS
   ========================================================== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: white; border-radius: var(--radius); box-shadow: var(--shadow-hover); padding: 1rem; display: flex; gap: 1rem; align-items: center; border-left: 4px solid; animation: toastSlideIn 0.3s ease-out; }
.toast.success { border-color: hsl(142 71% 45%); }
.toast.error { border-color: hsl(var(--destructive)); }
.toast-title { font-weight: 600; color: hsl(var(--primary)); }
.toast-message { font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
@keyframes toastSlideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.cristal-modal-overlay, .success-modal { position: fixed; z-index: 20000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(27, 36, 71, 0.8); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.3s; }
.cristal-modal-content, .success-modal-content { background: white; padding: 2rem; border-radius: calc(var(--radius)*2); width: 90%; max-width: 500px; box-shadow: var(--shadow-hover); position: relative; text-align: center; }
.cristal-modal-close { position: absolute; top: 15px; right: 20px; font-size: 1.5rem; cursor: pointer; color: hsl(var(--muted-foreground)); }

.success-icon { width: 80px; height: 80px; border-radius: 50%; background: hsl(var(--brand-gold) / 0.15); color: hsl(var(--brand-gold)); display: flex; align-items: center; justify-content: center; font-size: 3rem; margin: 0 auto 1rem; }
.success-title { font-size: 1.5rem; color: hsl(var(--primary)); margin-bottom: 0.5rem; }
.success-submessage { color: hsl(var(--brand-gold)); font-weight: 600; margin-top: 1rem; }

/* ==========================================================
   RESPONSIVE (No se alteró la lógica, solo variables)
   ========================================================== */
@media (max-width: 992px) {
    .main-layout { flex-direction: column; }
    .visual-panel { flex: 0 0 100%; order: 1; }
    .options-panel { flex: 0 0 100%; order: 2; padding: var(--spacing-lg); }
    .frame-card { flex-direction: row; padding: var(--spacing-md); }
    .image-wrapper { flex: 0 0 40%; }
    .summary-inline-container { flex: 1; margin-top: 0; border-top: none; border-left: 4px solid hsl(var(--brand-gold)); }
    .header-section { flex-direction: column; align-items: stretch; }
    .header-nav { justify-content: flex-end; margin-top: var(--spacing-sm); }
}

@media (max-width: 640px) {
    #app-container { padding: 0 var(--spacing-sm); margin: var(--spacing-sm) auto; }
    .options-panel { padding: var(--spacing-md); }
    .frame-card { flex-direction: column; }
    .summary-inline-container { border-left: none; border-top: 4px solid hsl(var(--brand-gold)); margin-top: var(--spacing-sm); }
    .additional-measurements { grid-template-columns: 1fr; gap: var(--spacing-md); }
    .prescription-table { overflow-x: auto; display: block; }
}

/* Animaciones y utilidades extra */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.info-text { font-size: 0.9rem; color: hsl(var(--muted-foreground)); text-align: center; padding: 1rem; }

/* ==========================================================
   SUCCESS MODAL WITH CONFETTI
   ========================================================== */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall linear infinite;
    border-radius: 2px;
    /* El color y la posición los asigna WO.showSuccessModal() por partícula */
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

@media (max-width: 640px) {
    /* ... lo que ya tengas de los paneles arriba ... */

    .upload-row {
        gap: var(--spacing-sm);
    }

    .upload-illustration {
        flex: 0 0 64px;
        width: 64px;
    }

    .upload-box-desc {
        font-size: 0.75rem;
    }

    /* ==========================================================
       TABLA DE DIOPTRÍAS PARA MÓVIL (Con color de marca)
       ========================================================== */
    .prescription-table {
        display: block;
        border: none;
        background: transparent;
        box-shadow: none;
        overflow-x: hidden;
    }

    .prescription-table thead { display: none; }

    .prescription-table tbody {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .prescription-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        background: hsl(var(--card));
        border: 2px solid hsl(var(--border));
        border-radius: calc(var(--radius) * 1.5);
        padding: var(--spacing-sm);
        box-shadow: var(--shadow-sm);
        overflow: hidden; /* Evita que el fondo azul se salga de las esquinas curvas */
    }

    .prescription-table tbody td:first-child {
        /* ESTA ES LA LÍNEA QUE ARREGLA EL HUECO */
        width: calc(100% + (var(--spacing-sm) * 2)); 
        
        text-align: center;
        background: hsl(var(--primary));
        color: white;
        border-bottom: none;
        margin: calc(var(--spacing-sm) * -1) calc(var(--spacing-sm) * -1) var(--spacing-sm) calc(var(--spacing-sm) * -1);
        padding: var(--spacing-sm);
        font-size: 0.95rem;
        font-weight: 600;
    }

    .prescription-table tbody td:not(:first-child) {
        flex: 1 1 0;
        min-width: 58px;
        display: flex;
        flex-direction: column;
        gap: 6px;
        border: none;
        padding: 0 var(--spacing-xs);
    }

    .prescription-table tbody td:nth-child(2)::before { content: "ESF"; }
    .prescription-table tbody td:nth-child(3)::before { content: "CIL"; }
    .prescription-table tbody td:nth-child(4)::before { content: "EJE"; }
    .prescription-table tbody td:nth-child(5)::before { content: "AD"; }

    .prescription-table tbody td:not(:first-child)::before {
        font-size: 0.75rem;
        font-weight: 700;
        color: hsl(var(--muted-foreground));
        text-align: center;
        letter-spacing: 0.5px;
    }

    .prescription-table input {
        padding: 10px 2px;
        font-size: 0.9rem;
    }
}
/* ==========================================================
   PASO 3: SELECCIÓN DE LABORATORIO (Rodenstock / Emporio)
   ========================================================== */
.lab-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.lab-card {
    position: relative;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-md);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease, border-color 0.35s ease;
}

.lab-card-tag {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: var(--spacing-sm);
    z-index: 1;
}

.lab-card-logo {
    max-width: 140px;
    max-height: 60px;
    object-fit: contain;
    margin-bottom: var(--spacing-xs);
    z-index: 1;
}

.lab-card-wordmark {
    font-family: 'Koho', sans-serif;
    font-weight: 700;
    font-style: italic;
    font-size: 1.3rem;
    color: hsl(var(--primary));
    letter-spacing: 0.01em;
    z-index: 1;
}

.lab-card-desc {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    margin-top: 4px;
    margin-bottom: var(--spacing-sm);
    z-index: 1;
}

.lab-card-acciones {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    z-index: 1;
}

/* Rodenstock: subrayado azul, ícono con un "click" seco y rápido —
   coherente con la sensación técnica/precisa de esta tarjeta. */
.lab-card.rodenstock .btn-accion::after {
    background: hsl(var(--rod-blue));
}

.lab-card.rodenstock .btn-accion:hover {
    background: hsl(var(--rod-blue-light));
}

.lab-card.rodenstock .btn-accion:hover svg {
    animation: rodSnap 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rodSnap {
    0% { transform: scale(1); }
    40% { transform: scale(0.85); }
    100% { transform: scale(1.15); }
}

/* Emporio: subrayado dorado, ícono con un rebote juguetón —
   coherente con la sensación cálida/cercana de esta tarjeta. */
.lab-card.emporio .btn-accion::after {
    background: hsl(var(--emp-yellow));
}

.lab-card.emporio .btn-accion:hover {
    background: hsl(var(--emp-yellow-light));
}

.lab-card.emporio .btn-accion:hover svg {
    animation: empWiggle 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes empWiggle {
    0% { transform: rotate(0) scale(1); }
    30% { transform: rotate(-12deg) scale(1.15); }
    60% { transform: rotate(10deg) scale(1.15); }
    100% { transform: rotate(0) scale(1.15); }
}

.lab-card-indicator {
    margin-top: auto;
    display: flex;
    gap: 5px;
    z-index: 1;
}

.lab-card-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: hsl(var(--border));
    transition: background 0.3s ease, transform 0.3s ease;
}

/* --- Rodenstock: fría, técnica, precisa --- */
.lab-card.rodenstock {
    border-top: 3px solid hsl(var(--rod-blue));
}

.lab-card.rodenstock .lab-card-tag {
    color: hsl(var(--rod-blue));
    background: hsl(var(--rod-blue-light));
}

.lab-card.rodenstock::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(hsl(var(--rod-blue-light)) 1px, transparent 1px),
        linear-gradient(90deg, hsl(var(--rod-blue-light)) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.lab-card.rodenstock:hover::before {
    opacity: 0.6;
}

.lab-card.rodenstock::after {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(100deg, transparent, hsl(var(--rod-blue) / 0.12), transparent);
    transform: skewX(-20deg);
    transition: left 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.lab-card.rodenstock:hover::after {
    left: 140%;
}

.lab-card.rodenstock:hover {
    transform: translateY(-4px);
    border-color: hsl(var(--rod-blue));
    box-shadow: 0 10px 24px hsl(var(--rod-blue) / 0.18);
}

.lab-card.rodenstock.selected {
    border-color: hsl(var(--rod-blue));
    border-width: 1.5px;
    box-shadow: 0 0 0 3px hsl(var(--rod-blue) / 0.14);
}

.lab-card.rodenstock:hover .lab-card-indicator span {
    background: hsl(var(--rod-blue));
}

/* --- Emporio: cálida, local, cercana --- */
.lab-card.emporio {
    border-top: 3px solid hsl(var(--emp-yellow));
    border-radius: 18px;
}

.lab-card.emporio .lab-card-tag {
    color: hsl(48 100% 24%);
    background: hsl(var(--emp-yellow-light));
}

.lab-card.emporio::before {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, hsl(var(--emp-yellow) / 0.35), transparent 70%);
    top: -60px;
    right: -60px;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.lab-card.emporio:hover::before {
    opacity: 1;
    transform: scale(1);
}

.lab-card.emporio:hover {
    transform: translateY(-4px) scale(1.01);
    border-color: hsl(var(--emp-yellow));
    box-shadow: 0 10px 26px hsl(var(--emp-yellow) / 0.3);
}

.lab-card.emporio.selected {
    border-color: hsl(var(--emp-yellow));
    border-width: 1.5px;
    box-shadow: 0 0 0 3px hsl(var(--emp-yellow) / 0.25);
}

.lab-card.rodenstock .lab-card-logo {
    max-height: 84px;
    max-width: 170px;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.lab-card.rodenstock:hover .lab-card-logo {
    transform: scale(1.1);
}

.lab-card.emporio .lab-card-logo {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 46px;
}

.lab-card.emporio:hover .lab-card-logo {
    transform: rotate(18deg) scale(1.08);
}

.lab-card.emporio:hover .lab-card-indicator span {
    background: hsl(var(--emp-yellow));
}

.lab-card.emporio:hover .lab-card-indicator span:nth-child(1) { transform: translateY(-3px); transition-delay: 0s; }
.lab-card.emporio:hover .lab-card-indicator span:nth-child(2) { transform: translateY(-3px); transition-delay: 0.08s; }
.lab-card.emporio:hover .lab-card-indicator span:nth-child(3) { transform: translateY(-3px); transition-delay: 0.16s; }

@media (max-width: 640px) {
    .lab-cards-grid {
        grid-template-columns: 1fr;
    }
}