@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Sora:wght@600;700;800&display=swap');

/* ═══════════════════════════════════════════
   VARIABLES — modo claro / oscuro
═══════════════════════════════════════════ */
:root {
    --verde-primario: #15803d;
    --verde-oscuro: #14532d;
    --verde-medio: #16a34a;
    --verde-claro: #f0fdf4;
    --verde-acento: #4ade80;
    --gris-borde: #e2e8f0;
    --gris-texto: #475569;
    --blanco: #ffffff;
    --fondo-body: #f0f4f0;
    --fondo-card: #ffffff;
    --fondo-input: #f1f5f9;
    --texto-principal: #0f1f14;
    --texto-h2: #15803d;
    --sombra-card: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(21,128,61,0.07);
    --sombra-hover: 0 4px 12px rgba(0,0,0,0.08), 0 16px 40px rgba(21,128,61,0.12);
    --borde-seccion: #e2e8f0;
    --fondo-seccion: #ffffff;
    --fondo-th: #15803d;
    --fondo-td-alt: #f8fafc;
    --fondo-barra-guardado: #f8fafc;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;

    /* Espaciado responsivo */
    --padding-body: clamp(12px, 3vw, 32px);
    --padding-card: clamp(16px, 4vw, 40px);
    --padding-seccion: clamp(16px, 3vw, 28px);
    --font-base: clamp(13px, 1.5vw, 15px);
}

body.dark {
    --verde-primario: #4ade80;
    --verde-oscuro: #4ade80;
    --verde-medio: #34d399;
    --verde-claro: #14532d33;
    --verde-acento: #86efac;
    --gris-borde: #1e3a2a;
    --gris-texto: #94a3b8;
    --blanco: #0d1f14;
    --fondo-body: #080f0b;
    --fondo-card: #0d1f14;
    --fondo-input: #162a1c;
    --texto-principal: #e2f0e8;
    --texto-h2: #4ade80;
    --sombra-card: 0 4px 24px rgba(0,0,0,0.5);
    --sombra-hover: 0 8px 32px rgba(0,0,0,0.6);
    --borde-seccion: #1a3324;
    --fondo-seccion: #0d1f14;
    --fondo-th: #14532d;
    --fondo-td-alt: #0f2318;
    --fondo-barra-guardado: #0d1f14;
}

/* ═══════════════════════════════════════════
   BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: var(--font-base);
    background-color: var(--fondo-body);
    color: var(--texto-principal);
    margin: 0;
    padding: var(--padding-body);
    padding-top: clamp(60px, 8vw, 80px); /* espacio para botón oscuro fijo */
    transition: background-color 0.3s, color 0.3s;
    background-image:
        radial-gradient(circle at 20% 10%, rgba(21,128,61,0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 90%, rgba(74,222,128,0.04) 0%, transparent 50%);
    min-height: 100vh;
}

/* ═══════════════════════════════════════════
   TOGGLE MODO OSCURO — responsivo
═══════════════════════════════════════════ */
#toggleDark {
    position: fixed;
    top: 14px;
    right: clamp(10px, 3vw, 20px);
    z-index: 8000;
    background: var(--fondo-card);
    border: 1.5px solid var(--gris-borde);
    border-radius: 30px;
    padding: clamp(6px, 1.2vw, 9px) clamp(10px, 2vw, 16px);
    font-size: clamp(11px, 1.3vw, 13px);
    font-weight: 700;
    color: var(--gris-texto);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
    transition: all 0.25s;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
#toggleDark:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-color: var(--verde-primario);
    color: var(--verde-primario);
    transform: translateY(-1px);
}

/* ── Tarjeta principal ── */
#pdfArea {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--fondo-card);
    padding: var(--padding-card);
    border: 1.5px solid var(--gris-borde);
    box-shadow: var(--sombra-card);
    border-radius: clamp(14px, 3vw, 24px);
    transition: background 0.3s, border-color 0.3s;
}

/* ── Secciones con tarjeta visual ── */
.seccion {
    background: var(--fondo-seccion);
    border: 1.5px solid var(--borde-seccion);
    border-radius: var(--radius-lg);
    padding: var(--padding-seccion);
    margin: clamp(12px, 2vw, 20px) 0;
    transition: background 0.3s, border-color 0.3s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* ── Encabezados ── */
h1 {
    font-family: 'Sora', sans-serif;
    color: var(--verde-primario);
    text-transform: uppercase;
    font-size: clamp(16px, 2.5vw, 22px);
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--verde-primario);
    padding-bottom: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

h2 {
    font-family: 'Sora', sans-serif;
    color: var(--texto-h2);
    font-size: clamp(14px, 2vw, 16px);
    font-weight: 700;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.2px;
    flex-wrap: wrap;
}

/* ── Barra de guardado ── */
.barra-guardado {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(10px, 1.5vw, 12px);
    color: #94a3b8;
    margin: 0 0 clamp(12px, 2vw, 20px);
    padding: 6px 10px;
    background: var(--fondo-barra-guardado);
    border-radius: 8px;
    border: 1px solid var(--gris-borde);
    flex-wrap: wrap;
    gap: 6px;
}
#indicadorGuardado {
    font-weight: 600;
    color: var(--verde-primario);
    opacity: 0;
    transition: opacity 0.4s;
}
#indicadorGuardado.visible { opacity: 1; }

/* ── Labels e inputs ── */
label {
    display: block;
    font-size: clamp(11px, 1.5vw, 13px);
    font-weight: 600;
    color: var(--gris-texto);
    margin-bottom: 5px;
}

input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: clamp(8px, 1.5vw, 10px) clamp(8px, 1.5vw, 12px);
    border: 2px solid var(--gris-borde);
    border-radius: 8px;
    background-color: var(--fondo-input);
    color: var(--texto-principal);
    box-sizing: border-box;
    font-size: clamp(13px, 1.5vw, 14px);
    transition: all 0.2s;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--verde-primario);
    background-color: var(--blanco);
    box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.15);
}

textarea { resize: vertical; min-height: 80px; }

select {
    font-family: inherit;
    font-size: clamp(12px, 1.5vw, 14px);
    background: var(--fondo-input);
    color: var(--texto-principal);
    border: 2px solid var(--gris-borde);
    border-radius: 8px;
    padding: 8px 10px;
    transition: border-color 0.2s;
}
select:focus {
    outline: none;
    border-color: var(--verde-primario);
}

/* ── Grids ── */
.grid-2cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(10px, 2vw, 16px);
    margin: 12px 0;
}
.grid-3cols {
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.9fr;
    gap: clamp(10px, 2vw, 16px);
    margin-top: 4px;
}

/* ── Info + imagen ── */
.info-imagen-wrapper {
    display: flex;
    gap: clamp(14px, 3vw, 25px);
    flex-wrap: wrap;
}
.info-column  { flex: 2; min-width: min(250px, 100%); }
.imagen-column { flex: 1; min-width: min(180px, 100%); text-align: center; }

.preview-container {
    width: 100%;
    min-height: clamp(120px, 20vw, 180px);
    border: 2px dashed var(--gris-borde);
    border-radius: 16px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--fondo-input);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.preview-container:hover { border-color: var(--verde-primario); }
.preview-container img {
    max-width: 100%;
    max-height: clamp(120px, 25vw, 200px);
    object-fit: cover;
}
.preview-placeholder {
    color: #888;
    font-size: clamp(12px, 1.5vw, 14px);
    text-align: center;
    padding: 20px;
}

#btnEliminarImagen {
    display: none;
    margin-top: 8px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: clamp(11px, 1.5vw, 13px);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
#btnEliminarImagen:hover { background: #fecaca; transform: translateY(-1px); }

/* ── Tablas — scroll horizontal en móvil ── */
.tabla-scroll-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

table {
    width: 100%;
    min-width: 480px; /* evita aplastamiento */
    border-collapse: collapse;
    margin: 10px 0;
    border-radius: 12px;
    overflow: hidden;
}
th {
    background-color: var(--fondo-th);
    color: white;
    text-align: left;
    padding: clamp(8px, 1.5vw, 12px);
    font-size: clamp(11px, 1.3vw, 13px);
    white-space: nowrap;
}
td {
    padding: clamp(7px, 1.2vw, 10px);
    border-bottom: 2px solid var(--gris-borde);
    color: var(--texto-principal);
    font-size: clamp(12px, 1.3vw, 13px);
}
tr:nth-child(even) td { background: var(--fondo-td-alt); }

/* ── % del total ── */
.celda-pct { min-width: 90px; }
.pct-wrap  { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.pct-bar {
    height: 7px;
    border-radius: 99px;
    transition: width 0.4s ease, background-color 0.3s;
    min-width: 2px;
    flex-shrink: 0;
    max-width: 50px;
}
.pct-bajo  { background: #22c55e; }
.pct-medio { background: #f59e0b; }
.pct-alto  { background: #ef4444; }
.pct-texto { font-size: 11px; font-weight: 700; color: var(--gris-texto); white-space: nowrap; }

/* ── Merma ── */
.merma-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    white-space: nowrap;
}
.merma-ok   { background: #dcfce7; color: #166534; }
.merma-med  { background: #fef9c3; color: #854d0e; }
.merma-alta { background: #fee2e2; color: #991b1b; }

/* ── Botones generales ── */
button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
button[onclick*="agregar"] {
    background-color: #15803d;
    color: white;
    padding: clamp(8px, 1.5vw, 10px) clamp(14px, 3vw, 20px);
    font-size: clamp(12px, 1.5vw, 13px);
    margin: 10px 0;
}
button[onclick*="agregar"]:hover { background-color: #166534; transform: translateY(-1px); }

.btn-eliminar { background: none; color: #dc2626; font-size: 18px; padding: 4px 8px; }
.btn-eliminar:hover { background: #fee2e2; border-radius: 6px; }

/* ── Totales ── */
h3 {
    text-align: right;
    font-size: clamp(14px, 2vw, 16px);
    color: var(--texto-principal);
    margin: 14px 0 8px;
}

/* ── Semáforo de rentabilidad ── */
.semaforo-wrap {
    display: flex;
    align-items: flex-start;
    gap: clamp(10px, 2vw, 16px);
    padding: clamp(12px, 2vw, 16px) clamp(14px, 2.5vw, 20px);
    border-radius: 14px;
    margin: 12px 0;
    border: 2px solid transparent;
    transition: all 0.4s;
}
.semaforo-icono { font-size: clamp(24px, 4vw, 32px); line-height: 1; flex-shrink: 0; margin-top: 2px; }
.semaforo-texto h4 { margin: 0 0 3px; font-size: clamp(13px, 1.8vw, 15px); font-weight: 700; }
.semaforo-texto p  { margin: 0; font-size: clamp(11px, 1.3vw, 12px); opacity: 0.8; }

.semaforo-verde    { background: #f0fdf4; border-color: #86efac; }
.semaforo-amarillo { background: #fefce8; border-color: #fde047; }
.semaforo-rojo     { background: #fff1f2; border-color: #fca5a5; }
body.dark .semaforo-verde    { background: #14532d33; border-color: #166534; }
body.dark .semaforo-amarillo { background: #78350f33; border-color: #b45309; }
body.dark .semaforo-rojo     { background: #7f1d1d33; border-color: #b91c1c; }

/* ── Precio final ── */
#precioFinal {
    background-color: var(--verde-claro);
    padding: 5px 15px;
    border-radius: 8px;
    color: var(--verde-primario);
    font-size: clamp(20px, 4vw, 28px);
    font-weight: 800;
}

/* ── Toggle N° Porciones ── */
.porciones-wrap { display: flex; align-items: center; gap: 8px; }
.porciones-wrap input { flex: 1; min-width: 0; }
#btnLockPorciones {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 16px;
    background: var(--fondo-input);
    border: 1px solid var(--gris-borde);
    color: var(--gris-texto);
    line-height: 1;
    flex-shrink: 0;
}
#btnLockPorciones:hover { border-color: var(--verde-primario); }

/* ── Botones de descarga ── */
.botones-pdf {
    text-align: center;
    margin: clamp(24px, 4vw, 40px) 0 24px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(10px, 2vw, 14px);
    padding: clamp(16px, 3vw, 28px) clamp(12px, 2.5vw, 24px);
    background: linear-gradient(135deg, var(--verde-claro), rgba(240,253,244,0.3));
    border: 1.5px solid rgba(21,128,61,0.15);
    border-radius: var(--radius-lg);
}
.btn-descarga {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: clamp(12px, 2vw, 15px) clamp(18px, 3vw, 30px);
    font-size: clamp(12px, 1.6vw, 14px);
    font-weight: 700;
    color: white;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, filter 0.2s;
    min-width: clamp(160px, 40vw, 210px);
    justify-content: center;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}
.btn-descarga::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s;
    border-radius: inherit;
}
.btn-descarga:hover:not(:disabled)::after { background: rgba(255,255,255,0.12); }
.btn-descarga:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}
.btn-descarga:active:not(:disabled) { transform: translateY(-1px); }
.btn-descarga:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-receta   { background: linear-gradient(135deg, #15803d 0%, #16a34a 100%); box-shadow: 0 4px 14px rgba(21,128,61,0.35); }
.btn-completa { background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%); box-shadow: 0 4px 14px rgba(37,99,235,0.35); }
.btn-excel    { background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%); box-shadow: 0 4px 14px rgba(124,58,237,0.35); color: #ffffff; }
.btn-reset    { background: linear-gradient(135deg, #475569 0%, #64748b 100%); box-shadow: 0 4px 14px rgba(71,85,105,0.3); }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}
.btn-descarga.cargando .spinner  { display: inline-block; }
.btn-descarga.cargando .btn-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
    position: fixed;
    bottom: clamp(16px, 3vw, 30px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    padding: clamp(10px, 2vw, 12px) clamp(16px, 4vw, 24px);
    border-radius: 40px;
    font-size: clamp(12px, 1.5vw, 14px);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
    max-width: calc(100vw - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.exito { background: #166534; }
#toast.error { background: #dc2626; }

/* ── Modales ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 3vw, 20px);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.modal-overlay.visible { display: flex; }

.modal-box {
    background: var(--fondo-card);
    color: var(--texto-principal);
    border-radius: clamp(14px, 3vw, 20px);
    padding: clamp(20px, 5vw, 32px) clamp(18px, 5vw, 36px);
    max-width: min(420px, 96vw);
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: popIn 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
}
@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.modal-box h3 { text-align: center; font-size: clamp(16px, 3vw, 20px); margin: 0 0 10px; }
.modal-box p  { color: var(--gris-texto); font-size: clamp(12px, 1.6vw, 14px); margin: 0 0 24px; }
.modal-acciones { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal-acciones button {
    padding: clamp(8px, 2vw, 10px) clamp(16px, 3vw, 24px);
    border-radius: 30px;
    font-size: clamp(12px, 1.5vw, 14px);
    font-weight: 700;
    flex: 1;
    min-width: 100px;
    max-width: 180px;
}
#btnConfirmarReset { background: #dc2626; color: white; }
#btnCancelarReset  { background: #f1f5f9; color: #475569; }

/* ── Modal preview PDF ── */
#modalPreview .modal-box {
    max-width: min(680px, 96vw);
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
    padding: clamp(16px, 3vw, 24px);
}
#previewPDFContenido {
    border: 1px solid var(--gris-borde);
    border-radius: 12px;
    padding: clamp(12px, 2vw, 20px);
    background: var(--fondo-input);
    font-size: clamp(11px, 1.4vw, 13px);
    line-height: 1.7;
    color: var(--texto-principal);
    margin-bottom: 16px;
    max-height: 55vh;
    overflow-y: auto;
}
#previewPDFContenido h4 {
    margin: 12px 0 4px;
    font-size: clamp(11px, 1.3vw, 13px);
    text-transform: uppercase;
    color: var(--verde-primario);
    letter-spacing: 0.5px;
}
#previewPDFContenido table { font-size: 12px; margin: 6px 0; min-width: auto; }
#previewPDFContenido th { font-size: 11px; padding: 7px 10px; }
#previewPDFContenido td { padding: 6px 10px; }

.preview-acciones { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.preview-acciones button {
    padding: clamp(8px, 2vw, 10px) clamp(14px, 2.5vw, 20px);
    border-radius: 20px;
    font-size: clamp(12px, 1.5vw, 13px);
}
#btnConfirmarDescarga { background: #166534; color: white; }
#btnCerrarPreview     { background: #f1f5f9; color: #475569; }

/* ═══════════════════════════════════════════
   PANTALLA: MIS RECETAS
═══════════════════════════════════════════ */
#pantallaRecetas {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 0 80px;
}

.recetas-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: clamp(10px, 2vw, 14px);
    margin-bottom: clamp(16px, 3vw, 28px);
    padding-bottom: clamp(14px, 2.5vw, 20px);
    border-bottom: 2px solid var(--gris-borde);
}

.recetas-header h1 {
    font-family: 'Sora', sans-serif;
    font-size: clamp(18px, 3.5vw, 24px);
    margin: 0;
    border: none;
    padding: 0;
}

/* Botones del header — columna en móvil */
.recetas-header > div:last-child {
    display: flex;
    gap: clamp(6px, 1.5vw, 8px);
    flex-wrap: wrap;
    align-items: center;
}

#conteoRecetas {
    font-size: 13px;
    color: var(--gris-texto);
    font-weight: 600;
}

.recetas-buscador-wrap { margin-bottom: clamp(16px, 3vw, 28px); }
.recetas-buscador-wrap input {
    max-width: 520px;
    width: 100%;
    font-size: clamp(13px, 1.5vw, 14px);
    padding: clamp(10px, 2vw, 12px) clamp(14px, 3vw, 20px);
    border-radius: 30px;
    border: 1.5px solid var(--gris-borde);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    font-weight: 500;
    transition: all 0.2s;
}
.recetas-buscador-wrap input:focus {
    border-color: var(--verde-primario);
    box-shadow: 0 0 0 3px rgba(21,128,61,0.12), 0 2px 8px rgba(0,0,0,0.05);
}

/* Grid de tarjetas */
#gridRecetas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 30vw, 280px), 1fr));
    gap: clamp(12px, 2.5vw, 18px);
}

.receta-card {
    background: var(--fondo-card);
    border: 1.5px solid var(--gris-borde);
    border-radius: var(--radius-lg);
    padding: 0;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(.34,1.56,.64,1), box-shadow 0.22s, border-color 0.22s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sombra-card);
}
.receta-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--sombra-hover);
    border-color: var(--verde-primario);
}

/* Imagen de portada en tarjeta */
.receta-card-img {
    width: 100%;
    height: clamp(130px, 18vw, 170px);
    object-fit: cover;
    display: block;
    flex-shrink: 0;
    background: var(--fondo-input);
}

.receta-card-placeholder-img {
    width: 100%;
    height: clamp(80px, 12vw, 100px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(36px, 6vw, 48px);
    background: linear-gradient(135deg, var(--verde-claro), #dcfce7);
    flex-shrink: 0;
}

.receta-card-body {
    padding: clamp(12px, 2vw, 16px) clamp(14px, 2.5vw, 18px) 10px;
    flex: 1;
}
.receta-card-nombre {
    font-family: 'Sora', sans-serif;
    font-size: clamp(13px, 1.8vw, 15px);
    font-weight: 700;
    color: var(--texto-principal);
    margin-bottom: 8px;
    line-height: 1.3;
}
.receta-card-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.receta-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 99px;
    background: var(--verde-claro);
    color: var(--verde-primario);
    border: 1px solid rgba(21,128,61,0.15);
}
.receta-badge.gris {
    background: var(--fondo-input);
    color: var(--gris-texto);
    border-color: var(--gris-borde);
}
.receta-card-precio {
    font-family: 'Sora', sans-serif;
    font-size: clamp(20px, 3.5vw, 24px);
    font-weight: 800;
    color: var(--verde-primario);
    margin-bottom: 5px;
    line-height: 1.2;
}
.receta-card-precio span {
    font-size: 12px;
    font-weight: 500;
    color: var(--gris-texto);
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.receta-card-fecha { font-size: 11px; color: var(--gris-texto); margin-bottom: 2px; }

/* Botones de descarga rápida dentro de la tarjeta */
.receta-card-descargas {
    display: flex;
    gap: 6px;
    padding: 10px clamp(14px, 2.5vw, 18px) 12px;
    flex-wrap: wrap;
}

.btn-card-descarga {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: clamp(6px, 1.2vw, 7px) clamp(10px, 1.8vw, 12px);
    font-size: clamp(10px, 1.2vw, 11px);
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
    border: none;
    color: white;
    letter-spacing: 0.2px;
    flex: 1;
    justify-content: center;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.btn-card-descarga:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    filter: brightness(1.05);
}
.btn-card-descarga-receta   { background: linear-gradient(135deg, #15803d, #16a34a); }
.btn-card-descarga-completa { background: linear-gradient(135deg, #1d4ed8, #2563eb); }
.btn-card-descarga-excel    { background: linear-gradient(135deg, #7c3aed, #9333ea); }

.receta-card-acciones { display: flex; border-top: 1.5px solid var(--gris-borde); }
.btn-card-accion {
    flex: 1;
    padding: clamp(8px, 1.5vw, 10px) 8px;
    font-size: clamp(11px, 1.2vw, 12px);
    font-weight: 700;
    background: none;
    color: var(--gris-texto);
    border-radius: 0;
    border-right: 1.5px solid var(--gris-borde);
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.2px;
    -webkit-tap-highlight-color: transparent;
}
.btn-card-accion:last-child { border-right: none; }
.btn-card-accion:hover { background: var(--fondo-input); color: var(--texto-principal); }
.btn-card-accion.peligro:hover { background: #fee2e2; color: #dc2626; }

/* Estado vacío */
.vacio-wrap {
    text-align: center;
    padding: clamp(40px, 8vw, 60px) 20px;
    color: var(--gris-texto);
}

/* ═══════════════════════════════════════════
   PANTALLA: EDITOR — topbar
═══════════════════════════════════════════ */
.editor-topbar {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.5vw, 12px);
    max-width: 1100px;
    margin: 0 auto clamp(12px, 2vw, 20px);
    background: var(--fondo-card);
    border: 1.5px solid var(--gris-borde);
    border-radius: 16px;
    padding: clamp(10px, 1.8vw, 12px) clamp(12px, 2.5vw, 18px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    flex-wrap: wrap;
    gap: 8px;
}

.btn-volver {
    background: var(--fondo-input);
    color: var(--verde-primario);
    border: 1.5px solid var(--gris-borde);
    border-radius: 30px;
    padding: clamp(7px, 1.2vw, 8px) clamp(12px, 2vw, 18px);
    font-size: clamp(11px, 1.4vw, 13px);
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.2px;
    transition: all 0.2s;
}
.btn-volver:hover {
    background: var(--verde-claro);
    border-color: var(--verde-primario);
    transform: translateX(-2px);
}

.btn-guardar-manual {
    background: linear-gradient(135deg, #15803d, #16a34a);
    color: white;
    border-radius: 30px;
    padding: clamp(7px, 1.2vw, 8px) clamp(14px, 2.5vw, 20px);
    font-size: clamp(11px, 1.4vw, 13px);
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: 0.2px;
    box-shadow: 0 3px 10px rgba(21,128,61,0.3);
    transition: all 0.2s;
}
.btn-guardar-manual:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(21,128,61,0.4);
}

#pantallaEditor #pdfArea h1 { margin-top: 0; }

/* ── Botones header (Comparar, Estadísticas, Exportar, Importar) ── */
.btn-header-accion {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: clamp(7px, 1.5vw, 9px) clamp(10px, 2vw, 18px);
    font-size: clamp(11px, 1.3vw, 13px);
    font-weight: 700;
    color: var(--gris-texto);
    background: var(--fondo-card);
    border: 1.5px solid var(--gris-borde);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.btn-header-accion:hover {
    border-color: var(--verde-primario);
    color: var(--verde-primario);
    background: var(--verde-claro);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21,128,61,0.15);
}

.importar-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: clamp(7px, 1.5vw, 9px) clamp(10px, 2vw, 18px);
    font-size: clamp(11px, 1.3vw, 13px);
    font-weight: 700;
    color: var(--gris-texto);
    background: var(--fondo-card);
    border: 1.5px solid var(--gris-borde);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    user-select: none;
    letter-spacing: 0.2px;
}
.importar-label:hover {
    border-color: var(--verde-primario);
    color: var(--verde-primario);
    background: var(--verde-claro);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21,128,61,0.15);
}

/* Radio buttons en modal importar */
#modalImportar input[type="radio"] {
    width: auto;
    accent-color: var(--verde-primario);
}

/* ═══════════════════════════════════════════
   PLANTILLAS DE RECETA
═══════════════════════════════════════════ */
#seccionPlantillas { margin-top: clamp(28px, 5vw, 44px); }

.plantillas-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid var(--gris-borde);
    font-size: clamp(13px, 2vw, 15px);
    font-weight: 800;
    font-family: 'Sora', sans-serif;
    color: var(--texto-principal);
}

.plantillas-sub {
    font-size: 12px;
    font-weight: 400;
    color: var(--gris-texto);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.plantillas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 22vw, 200px), 1fr));
    gap: clamp(10px, 2vw, 14px);
}

.plantilla-card {
    background: var(--fondo-card);
    border: 2px dashed var(--gris-borde);
    border-radius: var(--radius-lg);
    padding: clamp(16px, 3vw, 24px) clamp(12px, 2vw, 16px) clamp(14px, 2.5vw, 20px);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.22s cubic-bezier(.34,1.56,.64,1), box-shadow 0.22s, background 0.2s;
}
.plantilla-card:hover {
    border-color: var(--verde-primario);
    border-style: solid;
    background: var(--verde-claro);
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 24px rgba(21,128,61,0.14);
}

.plantilla-emoji {
    font-size: clamp(32px, 6vw, 44px);
    margin-bottom: 10px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.plantilla-titulo {
    font-size: clamp(12px, 1.8vw, 14px);
    font-weight: 700;
    font-family: 'Sora', sans-serif;
    color: var(--texto-principal);
    margin-bottom: 4px;
}
.plantilla-desc { font-size: 11px; color: var(--gris-texto); line-height: 1.4; }

/* ═══════════════════════════════════════════
   PUNTO DE EQUILIBRIO
═══════════════════════════════════════════ */
.pe-descripcion { font-size: clamp(12px, 1.5vw, 13px); color: var(--gris-texto); margin: -6px 0 18px; }

.pe-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: clamp(10px, 2vw, 14px);
    margin-bottom: 22px;
}

.pe-card {
    background: var(--fondo-input);
    border: 1px solid var(--gris-borde);
    border-radius: 14px;
    padding: clamp(12px, 2.5vw, 16px) clamp(10px, 2vw, 18px);
    text-align: center;
    transition: background 0.3s;
}
.pe-card-principal {
    background: linear-gradient(135deg, var(--verde-claro), #dcfce7);
    border-color: #86efac;
}
body.dark .pe-card-principal {
    background: linear-gradient(135deg, #14532d33, #166534aa);
    border-color: #166534;
}

.pe-label {
    font-size: clamp(10px, 1.2vw, 11px);
    font-weight: 600;
    color: var(--gris-texto);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}
.pe-valor {
    font-size: clamp(26px, 5vw, 36px);
    font-weight: 900;
    color: var(--verde-primario);
    line-height: 1;
    margin-bottom: 4px;
}
.pe-valor-sm { font-size: clamp(18px, 3.5vw, 26px); }
.pe-sub { font-size: clamp(10px, 1.2vw, 11px); color: var(--gris-texto); }

.pe-progreso-wrap { margin-bottom: 14px; }
.pe-progreso-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(12px, 1.5vw, 13px);
    color: var(--texto-principal);
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.pe-barra-fondo {
    position: relative;
    height: 14px;
    background: var(--fondo-input);
    border-radius: 99px;
    overflow: visible;
    border: 1px solid var(--gris-borde);
}
.pe-barra-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s ease, background-color 0.4s;
    position: relative;
}
.pe-fill-verde    { background: linear-gradient(90deg, #22c55e, #16a34a); }
.pe-fill-amarillo { background: linear-gradient(90deg, #f59e0b, #d97706); }
.pe-fill-rojo     { background: linear-gradient(90deg, #ef4444, #dc2626); }

.pe-barra-meta {
    position: absolute;
    top: -4px;
    left: 100%;
    transform: translateX(-50%);
    width: 3px;
    height: 22px;
    background: var(--texto-principal);
    border-radius: 2px;
    opacity: 0.35;
}
.pe-progreso-leyenda {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gris-texto);
    margin-top: 5px;
}

.pe-estado-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    white-space: nowrap;
}
.pe-badge-verde    { background: #dcfce7; color: #166534; }
.pe-badge-amarillo { background: #fef9c3; color: #854d0e; }
.pe-badge-rojo     { background: #fee2e2; color: #991b1b; }
body.dark .pe-badge-verde    { background: #14532d55; color: #4ade80; }
body.dark .pe-badge-amarillo { background: #78350f55; color: #fbbf24; }
body.dark .pe-badge-rojo     { background: #7f1d1d55; color: #f87171; }

.pe-margen-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: clamp(10px, 2vw, 14px) clamp(12px, 2vw, 16px);
    border-radius: 12px;
    border: 1.5px solid transparent;
    margin-top: 4px;
    font-size: clamp(12px, 1.6vw, 14px);
    font-weight: 600;
}
.pe-margen-icono { font-size: 22px; flex-shrink: 0; line-height: 1.3; }
.pe-margen-verde { background: #f0fdf4; border-color: #86efac; }
.pe-margen-rojo  { background: #fff1f2; border-color: #fca5a5; }
body.dark .pe-margen-verde { background: #14532d22; border-color: #166534; }
body.dark .pe-margen-rojo  { background: #7f1d1d22; border-color: #b91c1c; }

/* ═══════════════════════════════════════════
   CONVERTIDOR DE UNIDADES
═══════════════════════════════════════════ */
.conv-panel {
    margin-bottom: 14px;
    border: 1px solid var(--gris-borde);
    border-radius: 10px;
    overflow: hidden;
}
.conv-panel summary {
    padding: clamp(8px, 1.5vw, 10px) 14px;
    font-size: clamp(12px, 1.5vw, 13px);
    font-weight: 600;
    color: var(--verde-primario);
    cursor: pointer;
    background: var(--fondo-input);
    user-select: none;
    list-style: none;
}
.conv-panel summary::-webkit-details-marker { display: none; }
.conv-panel[open] summary { border-bottom: 1px solid var(--gris-borde); }
.conv-body {
    padding: 14px;
    background: var(--fondo-card);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.conv-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.conv-select {
    padding: 8px 10px;
    border: 1px solid var(--gris-borde);
    border-radius: 8px;
    background: var(--fondo-input);
    color: var(--texto-principal);
    font-size: clamp(12px, 1.3vw, 13px);
    font-family: inherit;
    flex: 1;
    min-width: clamp(80px, 15vw, 120px);
}
.btn-conv {
    background: var(--verde-primario);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: clamp(12px, 1.5vw, 13px);
    font-weight: 600;
    white-space: nowrap;
}
.btn-conv:hover { opacity: 0.85; }
.conv-resultado {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: clamp(12px, 1.5vw, 14px);
}
.conv-ok    { background: var(--verde-claro); color: var(--verde-primario); }
.conv-error { background: #fee2e2; color: #dc2626; }

/* ═══════════════════════════════════════════
   RECETAS COMPUESTAS
═══════════════════════════════════════════ */
.subrecetas-aviso {
    background: var(--verde-claro);
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: clamp(8px, 1.5vw, 10px) 14px;
    font-size: clamp(12px, 1.5vw, 13px);
    color: var(--verde-primario);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.btn-subreceta-agregar {
    background: var(--verde-primario);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}
.subreceta-item {
    padding: 12px 14px;
    border: 1px solid var(--gris-borde);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--fondo-card);
}
.subreceta-item:hover {
    border-color: var(--verde-primario);
    background: var(--verde-claro);
}

/* ═══════════════════════════════════════════
   GRÁFICA DE COSTOS
═══════════════════════════════════════════ */
.grafica-wrap {
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 32px);
    flex-wrap: wrap;
}
#graficaCostos {
    max-width: clamp(140px, 25vw, 200px);
    max-height: clamp(140px, 25vw, 200px);
    width: 100%;
    height: auto;
}
.grafica-leyenda {
    flex: 1;
    min-width: clamp(160px, 30vw, 200px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.grafica-leyenda-item {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    align-items: center;
    gap: 8px;
    font-size: clamp(11px, 1.4vw, 13px);
}
.grafica-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.grafica-leyenda-label { color: var(--texto-principal); font-weight: 500; }
.grafica-leyenda-valor { font-weight: 700; color: var(--texto-principal); }
.grafica-leyenda-pct { color: var(--gris-texto); font-size: 12px; min-width: 38px; text-align: right; }

/* ═══════════════════════════════════════════
   TEMPORADA / DISPONIBILIDAD
═══════════════════════════════════════════ */
.celda-temp { min-width: 85px; }
.sel-temporada {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--gris-borde);
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    text-align: center;
    transition: all 0.2s;
}
.temp-ok        { background: #f0fdf4; color: #166534; border-color: #86efac; }
.temp-temporada { background: #fefce8; color: #854d0e; border-color: #fde047; }
.temp-importado { background: #eff6ff; color: #1e40af; border-color: #93c5fd; }
.temp-escaso    { background: #fff1f2; color: #991b1b; border-color: #fca5a5; }
body.dark .temp-ok        { background: #14532d33; color: #4ade80; border-color: #166534; }
body.dark .temp-temporada { background: #78350f33; color: #fbbf24; border-color: #b45309; }
body.dark .temp-importado { background: #1e3a8a33; color: #93c5fd; border-color: #1e40af; }
body.dark .temp-escaso    { background: #7f1d1d33; color: #f87171; border-color: #b91c1c; }

/* ═══════════════════════════════════════════
   SIMULADOR DE ESCENARIOS
═══════════════════════════════════════════ */
.sim-slider-grupo { margin-bottom: clamp(12px, 2vw, 18px); }
.sim-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(12px, 1.5vw, 13px);
    font-weight: 500;
    color: var(--texto-principal);
    margin-bottom: 6px;
}
.sim-slider-label strong {
    font-size: clamp(13px, 1.6vw, 14px);
    font-weight: 800;
    color: var(--verde-primario);
    min-width: 50px;
    text-align: right;
}
input[type="range"] {
    width: 100%;
    accent-color: var(--verde-primario);
    height: 5px;
    cursor: pointer;
}

/* ═══════════════════════════════════════════
   HISTORIAL DE VERSIONES
═══════════════════════════════════════════ */
.hist-item {
    padding: 12px 14px;
    border: 1px solid var(--gris-borde);
    border-radius: 10px;
    background: var(--fondo-card);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.hist-item:hover { border-color: var(--verde-primario); }

/* ═══════════════════════════════════════════
   TOOLTIP ATAJOS DE TECLADO
═══════════════════════════════════════════ */
.atajo-hint {
    position: fixed;
    bottom: clamp(80px, 12vw, 100px);
    right: clamp(10px, 3vw, 20px);
    background: var(--fondo-card);
    border: 1px solid var(--gris-borde);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: clamp(11px, 1.3vw, 12px);
    color: var(--gris-texto);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    z-index: 7000;
    line-height: 2;
    display: none;
    max-width: calc(100vw - 40px);
}
.atajo-hint.visible { display: block; }
kbd {
    background: var(--fondo-input);
    border: 1px solid var(--gris-borde);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-family: monospace;
    color: var(--texto-principal);
}

/* ═══════════════════════════════════════════
   APORTE NUTRIMENTAL
═══════════════════════════════════════════ */
.nutri-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 22vw, 200px), 1fr));
    gap: clamp(8px, 1.5vw, 12px);
    margin-bottom: 20px;
}

.nutri-campo { display: flex; flex-direction: column; gap: 4px; }
.nutri-campo label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gris-texto);
    margin: 0;
}
.nutri-campo input { padding: 9px 12px; font-size: 14px; font-weight: 600; }
.nutri-campo .nutri-unidad { font-size: 11px; color: var(--gris-texto); font-weight: 400; margin-top: 2px; }

.nutri-etiqueta {
    border: 2px solid var(--texto-principal);
    border-radius: 12px;
    overflow: hidden;
    max-width: 320px;
    font-size: clamp(11px, 1.4vw, 13px);
    margin-top: 4px;
}
.nutri-etiqueta-header {
    background: var(--texto-principal);
    color: var(--blanco);
    padding: clamp(8px, 1.5vw, 10px) 14px;
    font-size: clamp(14px, 2vw, 16px);
    font-weight: 900;
    letter-spacing: -0.3px;
}
.nutri-etiqueta-sub {
    padding: 4px 14px 8px;
    font-size: 11px;
    color: var(--gris-texto);
    border-bottom: 6px solid var(--texto-principal);
}
.nutri-fila {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 14px;
    border-bottom: 1px solid var(--gris-borde);
    font-size: 12px;
    gap: 8px;
}
.nutri-fila:last-child { border-bottom: none; }
.nutri-fila.principal { font-weight: 700; font-size: 13px; border-bottom: 3px solid var(--texto-principal); }
.nutri-fila.sub { padding-left: 26px; font-size: 11.5px; color: var(--gris-texto); }
.nutri-fila .nutri-pct { font-weight: 700; font-size: 12px; color: var(--texto-principal); white-space: nowrap; }

.nutri-barra-wrap { margin: 16px 0 4px; }
.nutri-barra-titulo {
    font-size: 12px;
    font-weight: 700;
    color: var(--gris-texto);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.nutri-barra-item {
    display: grid;
    grid-template-columns: clamp(80px, 15vw, 110px) 1fr clamp(40px, 6vw, 50px);
    align-items: center;
    gap: clamp(6px, 1.2vw, 10px);
    margin-bottom: 8px;
    font-size: clamp(11px, 1.3vw, 12px);
}
.nutri-barra-label { color: var(--texto-principal); font-weight: 600; }
.nutri-barra-track {
    height: 8px;
    background: var(--fondo-input);
    border-radius: 99px;
    overflow: hidden;
}
.nutri-barra-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s ease;
}
.nutri-fill-cals   { background: #f97316; }
.nutri-fill-prot   { background: #3b82f6; }
.nutri-fill-carbs  { background: #eab308; }
.nutri-fill-grasas { background: #a855f7; }
.nutri-fill-fibra  { background: #22c55e; }
.nutri-barra-val { font-weight: 700; font-size: 12px; color: var(--gris-texto); text-align: right; }

.nutri-aviso {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: clamp(8px, 1.5vw, 10px) 14px;
    font-size: clamp(11px, 1.3vw, 12px);
    color: #1e40af;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}
body.dark .nutri-aviso { background: #1e3a8a22; border-color: #1e40af; color: #93c5fd; }

.nutri-layout {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 320px);
    gap: clamp(16px, 3vw, 28px);
    align-items: start;
}

.nutri-aviso-ok      { background: #f0fdf4; border-color: #86efac; color: #166534; }
.nutri-aviso-parcial { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.nutri-aviso-warn    { background: #fff1f2; border-color: #fca5a5; color: #991b1b; }
body.dark .nutri-aviso-ok      { background: #14532d22; border-color: #166534; color: #4ade80; }
body.dark .nutri-aviso-parcial { background: #78350f22; border-color: #b45309; color: #fbbf24; }
body.dark .nutri-aviso-warn    { background: #7f1d1d22; border-color: #b91c1c; color: #f87171; }

/* ═══════════════════════════════════════════
   BOTÓN Y PANEL DE MERMA
═══════════════════════════════════════════ */
.btn-merma {
    background: none;
    border: 1px solid var(--gris-borde);
    border-radius: 6px;
    color: var(--gris-texto);
    font-size: 14px;
    padding: 3px 6px;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 4px;
}
.btn-merma:hover {
    background: var(--fondo-input);
    border-color: var(--verde-primario);
    color: var(--verde-primario);
}
body.dark .btn-merma:hover { border-color: #34d399; color: #34d399; }

/* ═══════════════════════════════════════════
   PRINT
═══════════════════════════════════════════ */
@media print {
    body { background: white; padding: 0; }
    #pdfArea { border: none; box-shadow: none; }
    .botones-pdf, #modalReset, #modalPreview, #toast, #toggleDark { display: none; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET (601–900px)
═══════════════════════════════════════════ */
@media (max-width: 900px) {
    .grid-3cols { grid-template-columns: 1fr 1fr; }
    .pe-grid { grid-template-columns: 1fr 1fr; }
    #gridRecetas { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .nutri-layout { grid-template-columns: 1fr; }
    .nutri-etiqueta { max-width: 100%; }

    /* Simulador en columna única en tablet pequeña */
    #pantallaSimulador > div > div { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MÓVIL (≤600px)
═══════════════════════════════════════════ */
@media (max-width: 600px) {
    body { padding: 10px; padding-top: 70px; }

    /* Grids → columna única */
    .grid-2cols,
    .grid-3cols { grid-template-columns: 1fr; gap: 10px; }

    /* Área editor */
    #pdfArea { padding: 14px; border-radius: 14px; }

    /* Header recetas */
    .recetas-header { flex-direction: column; align-items: flex-start; }
    .recetas-header > div:last-child { width: 100%; }

    /* Tarjetas de receta en columna única */
    #gridRecetas { grid-template-columns: 1fr; }

    /* Info + imagen apilado */
    .info-imagen-wrapper { flex-direction: column; }
    .imagen-column { order: -1; width: 100%; }

    /* Botones de descarga: full width */
    .botones-pdf { flex-direction: column; align-items: stretch; padding: 14px; }
    .btn-descarga { min-width: unset; width: 100%; }

    /* Punto de equilibrio */
    .pe-grid { grid-template-columns: 1fr; }
    .pe-valor { font-size: 28px; }

    /* Nutrimental */
    .nutri-layout { grid-template-columns: 1fr; }
    .nutri-etiqueta { max-width: 100%; }
    .nutri-grid { grid-template-columns: 1fr 1fr; }

    /* Plantillas */
    .plantillas-grid { grid-template-columns: 1fr 1fr; }

    /* Editor topbar: colapsa los botones */
    .editor-topbar {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    #editorNombreTop {
        width: 100%;
        order: -1;
        text-align: left !important;
        font-size: 13px;
    }

    /* Botones header: más pequeños */
    .btn-header-accion,
    .importar-label { padding: 7px 11px; font-size: 11px; }

    /* Tablas: scroll horizontal */
    .seccion > table,
    .seccion > div > table { min-width: 480px; }

    /* Gráfica */
    .grafica-wrap { flex-direction: column; align-items: flex-start; }
    #graficaCostos { max-width: 160px; max-height: 160px; }

    /* Convertidor */
    .conv-row { flex-direction: column; align-items: stretch; }
    .conv-select { width: 100%; }

    /* Modales */
    .modal-box { padding: 18px 16px; }
    .modal-acciones { flex-direction: column; }
    .modal-acciones button { max-width: none; }

    /* Semáforo */
    .semaforo-wrap { flex-direction: row; align-items: flex-start; }

    /* Chef IA panel */
    #cia-panel { width: 100vw; }

    /* Storage meter */
    #sm-widget { bottom: 10px; right: 10px; min-width: 190px; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MÓVIL PEQUEÑO (≤380px)
═══════════════════════════════════════════ */
@media (max-width: 380px) {
    .plantillas-grid { grid-template-columns: 1fr 1fr; }
    .nutri-grid { grid-template-columns: 1fr; }
    .receta-card-badges { gap: 3px; }

    /* Botones de acción de tarjeta: reducir padding */
    .btn-card-accion { font-size: 10px; padding: 8px 4px; }
    .btn-card-descarga { font-size: 10px; padding: 5px 8px; }

    h1 { font-size: 15px; }
    h2 { font-size: 13px; }
}
/* ════════════════════════════════════════════════════════════════
   ANUNCIOS — bloques formales, discretos, con etiqueta "Publicidad"
   Solo aparecen en pantallas secundarias (Estadísticas y Simulador),
   nunca sobre el editor principal ni tapando contenido.
   Se ocultan automáticamente para usuarios Premium (ver ads-formal.js)
════════════════════════════════════════════════════════════════ */
.anuncio-formal {
  margin: 0 auto 24px;
  padding: 14px 14px 16px;
  background: var(--fondo-card);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radius-md);
  box-shadow: var(--sombra-card);
  text-align: center;
  overflow: hidden;
}
.anuncio-formal .anuncio-etiqueta {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--gris-texto);
  margin-bottom: 10px;
}
.anuncio-formal .anuncio-contenedor {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60px;
}
