:root {
    --primary: #4f7942;       /* verde */
    --primary-dark: #395c30;  /* verde oscuro (hover) */
    --gray-bg: #f5f1e8;       /* beige */
    --border: #ddd4c0;
    --error: #c92a2a;
    /* Superficies y texto: en modo claro valen lo mismo de siempre; el modo nocturno los
       redefine (ver el bloque MODO NOCTURNO al final). Sirven para que también los estilos
       escritos en línea en las páginas se adapten. */
    --sup: #fff;
    --sup-alta: #f3f4f6;
    --sup-input: #fff;
    --texto: #1c1c1c;
    --texto-suave: #6b7280;
    --etiqueta-verde: #e6f2e6;
    --texto-portal: #1E2A22;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--gray-bg);
    color: #1c1c1c;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-form {
    background: #fff;
    padding: 2.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 360px;
}

.login-form h1 { font-size: 1.3rem; margin-bottom: 1.2rem; text-align: center; }

.login-logo {
    display: block;
    max-height: 100px;
    max-width: 100%;
    margin: 0 auto 1.2rem;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    margin-bottom: 1.2rem;
}
.login-brand .login-logo { margin: 0; }
.login-brand-text { font-weight: 700; color: var(--primary-dark); font-size: 1.05rem; }

.login-form label, .registro-form label {
    display: block;
    margin-top: 1rem;
    margin-bottom: .3rem;
    font-size: .9rem;
}

.login-form input, .registro-form input, .registro-form select {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

.login-form button, .registro-form button:not(.btn):not(.boton-calendario), .btn {
    display: inline-block;
    margin-top: 1.5rem;
    width: 100%;
    padding: .7rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn-secondary { background: #495057; margin-top: .8rem; }

.login-form button:hover, .registro-form button:not(.btn):not(.boton-calendario):hover, .btn:hover { background: var(--primary-dark); }

.registro-form { background: #fff; padding: 2.5rem; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); width: 100%; max-width: 640px; margin: 2rem auto; }
.registro-form h1 { font-size: 1.3rem; margin-bottom: .3rem; text-align: center; }
.registro-form h3 { margin: 1.4rem 0 .6rem; font-size: 1.05rem; }
.plan-membresia { display: flex; gap: 1rem; flex-wrap: wrap; }
.plan-membresia-opcion { flex: 1; min-width: 180px; border: 2px solid var(--border); border-radius: 8px; padding: 1rem; cursor: pointer; text-align: center; }
.plan-membresia-opcion.seleccionado { border-color: var(--primary); background: #f3f8f2; }
.plan-membresia-opcion .precio { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); display: block; margin-top: .3rem; }
.metodo-pago-opcion { display: flex; align-items: center; gap: .6rem; border: 2px solid var(--border); border-radius: 8px; padding: .8rem 1rem; margin-bottom: .6rem; cursor: pointer; }
.metodo-pago-opcion.seleccionado { border-color: var(--primary); background: #f3f8f2; }
.metodo-pago-opcion.deshabilitado { opacity: .55; cursor: not-allowed; }
.resumen-precio { background: var(--gray-bg); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.resumen-precio-total { font-size: 1.4rem; font-weight: 700; color: var(--primary-dark); }
.qr-pago-imagen { max-width: 260px; display: block; margin: 1rem auto; border: 1px solid var(--border); border-radius: 8px; }

.error {
    background: #fff5f5;
    color: var(--error);
    border: 1px solid #ffc9c9;
    padding: .6rem .8rem;
    border-radius: 6px;
    font-size: .9rem;
}

.topbar a { color: var(--primary-dark); text-decoration: none; }

.content { padding: 2rem; max-width: 1100px; margin: 0 auto; min-width: 0; width: 100%; }



/* Contenedor estándar para centrar y ensanchar el contenido de una página. Antes existían
   3 clases distintas (.lista-ajustada, .lista-compacta, .config-panel) haciendo lo mismo
   con anchos distintos; ahora todas las páginas usan esta única clase. */
.contenedor-ancho { max-width: 1400px; margin: 0 auto; }
.contenedor-ancho > h1 { text-align: center; }
.contenedor-ancho .card, .contenedor-ancho form.card { max-width: 100%; }

.ficha-banner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.ficha-banner-titulo { display: flex; gap: .8rem; align-items: flex-start; }
.ficha-banner-icono { width: 26px; height: 26px; flex-shrink: 0; fill: none; stroke: var(--primary); stroke-width: 1.8; margin-top: .2rem; }
.ficha-tabs { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; }
.ficha-tab {
    display: flex; align-items: center; gap: .4rem;
    padding: .65rem 1rem;
    color: #6b7280; text-decoration: none; font-size: .92rem; font-weight: 600;
    border-bottom: 2px solid transparent;
}
.ficha-tab:hover { color: var(--primary-dark); }
.ficha-tab.active { background: var(--primary); color: #fff; border-radius: 8px 8px 0 0; border-bottom-color: var(--primary); }
.ficha-tab-icon { width: 17px; height: 17px; display: inline-flex; }
.ficha-tab-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; }
.aviso-info { background: #e7f3fb; border: 1px solid #bfe0f5; color: #1c5d80; padding: .8rem 1rem; border-radius: 8px; font-size: .9rem; margin-top: 1.2rem; }
.aviso-info a { color: #0d6ba8; font-weight: 600; }

.fotos-layout { display: grid; grid-template-columns: 300px 1fr; gap: 1.2rem; align-items: start; }
.fotos-form { margin: 0; }
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.foto-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.foto-card img { width: 100%; height: 180px; object-fit: cover; display: block; }
.foto-card-info { padding: .8rem; }
@media (max-width: 900px) {
    .fotos-layout { grid-template-columns: 1fr; }
}

.foto-card img { cursor: zoom-in; }
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 2rem;
}
.lightbox-overlay.activo { display: flex; }
.lightbox-overlay img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox-contenido { max-width: 92vw; max-height: 92vh; }
.lightbox-contenido img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox-contenido .grafico-evolucion-serie {
    background: #fff;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
    cursor: default;
    width: min(92vw, 900px);
}
.lightbox-contenido .grafico-evolucion-titulo { font-size: 1.2rem; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-overlay.activo { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 10px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: left;
    position: relative;
}
.modal-box h2 { margin-top: 0; }
.modal-box label {
    display: block;
    margin-top: 1rem;
    margin-bottom: .3rem;
    font-size: .9rem;
}
.modal-box input {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}
.modal-box select {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}
#modalEditarItemPlan input, #modalEditarItemPlan select { box-sizing: border-box; height: 2.6rem; line-height: 1.3; }
.modal-box button[type="submit"] {
    display: inline-block;
    margin-top: 1.2rem;
    width: 100%;
    padding: .7rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}
.modal-box button[type="submit"]:hover { background: var(--primary-dark); }
.modal-cerrar {
    position: absolute;
    top: .8rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #6b7280;
    width: auto;
    margin: 0;
    padding: 0;
}
.login-olvide { display: block; text-align: center; margin-top: .8rem; font-size: .9rem; }

.grafico-evolucion {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 980px;
    margin: 0 auto 1.5rem;
}
.grafico-evolucion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grafico-evolucion-grid-uno { grid-template-columns: 1fr; }
.grafico-evolucion-selector { max-width: 220px; margin: 0 0 1rem; }
.grafico-evolucion-serie { min-width: 0; cursor: zoom-in; }
.grafico-evolucion-serie:not(:first-child) { border-left: 1px solid var(--border); padding-left: 1.5rem; }
.grafico-evolucion-titulo { font-weight: 600; font-size: .95rem; margin: 0 0 .5rem; color: #374151; }
.grafico-evolucion-svg { width: 100%; height: auto; display: block; }
.grafico-evolucion-leyenda { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; margin-bottom: 1.1rem; font-size: .8rem; color: #374151; }
.grafico-leyenda-item { display: inline-flex; align-items: center; gap: .35rem; }
.grafico-leyenda-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
@media (max-width: 700px) {
    .grafico-evolucion-grid { grid-template-columns: 1fr; }
    .grafico-evolucion-serie:not(:first-child) {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 1.5rem;
    }
}

.acordeon-ficha { border: 1px solid var(--border); border-radius: 8px; margin-top: 1rem; overflow: hidden; }
.acordeon-ficha summary {
    cursor: pointer;
    padding: .8rem 1rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    list-style: none;
}
.acordeon-ficha summary:hover { background: var(--primary-dark); }
.acordeon-ficha summary::-webkit-details-marker { display: none; }
.acordeon-ficha summary::before { content: '▸ '; color: #fff; }
.acordeon-ficha[open] summary::before { content: '▾ '; }
.acordeon-contenido { padding: 1rem; }
.checkbox-linea { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; margin-bottom: .6rem; }
.tabla-habitos { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.tabla-habitos th, .tabla-habitos td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.tabla-habitos th { color: #6b7280; font-size: .78rem; text-transform: uppercase; }
.tabla-habitos input[type="text"] { width: 100%; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; }

.banner-solo-lectura {
    background: #fff3bf;
    color: #7a5c00;
    border: 1px solid #ffe08a;
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
    font-size: .9rem;
}

.banner-membresia-por-vencer {
    background: #e7f1ff;
    color: #1c4d8c;
    border: 1px solid #b6d4fe;
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
    font-size: .9rem;
}

/* --- Formularios de configuración / tema --- */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 480px;
}

.color-field {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-top: 1rem;
}

.color-field label { flex: 1; font-size: .9rem; }

.color-field input[type="color"] {
    width: 48px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
}

.success {
    background: #ebfbee;
    color: var(--primary-dark);
    border: 1px solid #b2f2bb;
    padding: .6rem .8rem;
    border-radius: 6px;
    font-size: .9rem;
}

.toast-contenedor {
    position: fixed;
    top: 1.2rem;
    right: 1.2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: min(360px, calc(100vw - 2.4rem));
}
.toast {
    background: #ebfbee;
    color: var(--primary-dark);
    border: 1px solid #b2f2bb;
    border-radius: 8px;
    padding: .8rem 2.2rem .8rem 1rem;
    font-size: .9rem;
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
    position: relative;
    animation: toast-entrada .25s ease-out;
}
.toast-cerrar {
    position: absolute;
    top: .5rem;
    right: .6rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: inherit;
    opacity: .6;
}
.toast-cerrar:hover { opacity: 1; }
.toast.toast-saliendo { animation: toast-salida .2s ease-in forwards; }
@keyframes toast-entrada { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-salida { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

.checkbox-field {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1.2rem;
    font-size: .9rem;
}

/* ============ Layout interno (sidebar + topbar) ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width .2s ease;
}

.app-shell.collapsed .sidebar { width: 68px; }
.app-shell.collapsed .nav-label { display: none; }
.app-shell.collapsed .sidebar-brand .brand-text { display: none; }

.sidebar-brand {
    height: 64px;
    padding: 0 1rem;
    font-weight: 700;
    color: var(--primary-dark);
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    box-sizing: border-box;
}

.brand-logo { max-height: 48px; max-width: 150px; flex-shrink: 0; }
.sidebar-brand-link { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.app-shell.collapsed .sidebar-brand { padding: 0 .4rem; }
.app-shell.collapsed .brand-logo { max-height: 32px; max-width: 48px; }

.sidebar-nav { display: flex; flex-direction: column; padding: .6rem; gap: .2rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .65rem .75rem;
    border-radius: 8px;
    color: #495057;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link:hover { background: var(--primary); color: #fff; }
.nav-link:hover .nav-icon svg { stroke: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; }
.nav-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link.active .nav-icon svg { stroke: #fff; }

.nav-group { display: flex; flex-direction: column; }

.nav-link-submenu {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.nav-chevron { flex-shrink: 0; margin-left: auto; stroke: currentColor; fill: none; stroke-width: 2; transition: transform .15s ease; }
.nav-link-submenu.abierto .nav-chevron { transform: rotate(90deg); }
.nav-link-submenu.active .nav-chevron { stroke: #fff; }

.nav-submenu {
    padding: .2rem 0 .2rem 2.4rem;
}

.nav-sublink {
    display: block;
    padding: .5rem .6rem;
    border-radius: 6px;
    color: #6b7280;
    text-decoration: none;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
}
.nav-sublink:hover { background: var(--primary); color: #fff; }
.nav-sublink.active { background: var(--gray-bg); color: var(--primary-dark); font-weight: 600; }

.app-shell.collapsed .nav-submenu { display: none !important; }
.app-shell.collapsed .nav-chevron { display: none; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    padding: 0 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #495057;
    padding: .3rem;
    border-radius: 6px;
}
.icon-btn:hover { background: var(--gray-bg); }
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .95rem;
    color: #1c1c1c;
    padding: .3rem .5rem;
    border-radius: 8px;
}
.user-menu-trigger:hover { background: var(--gray-bg); }
.user-menu-trigger svg { stroke: #495057; fill: none; stroke-width: 2; }

.avatar-sm { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .85rem;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.1);
    min-width: 200px;
    padding: .4rem;
    z-index: 20;
}
.user-dropdown.open { display: block; }
.user-dropdown a {
    display: block;
    padding: .55rem .7rem;
    border-radius: 6px;
    color: #1c1c1c;
    text-decoration: none;
    font-size: .9rem;
}
.user-dropdown a:hover { background: var(--gray-bg); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: .4rem 0; }
.topbar-derecha { display: flex; align-items: center; gap: 1rem; }

/* ============ Mi Membresía (nutricionista) ============ */
.ref-tabla { width: 100%; border-collapse: collapse; }
.ref-tabla td { padding: .5rem .2rem; border-bottom: 1px solid var(--border); }
.ref-tabla td:first-child { color: var(--texto-suave, #6b6355); width: 40%; }
.pildora-estado { display: inline-block; padding: .25rem .7rem; border-radius: 20px; font-size: .85rem; font-weight: 600; }
.pildora-activa { background: #e6f4ea; color: #1e7b34; }
.pildora-por-vencer { background: #fff3cd; color: #8a6d1a; }
.pildora-vencida { background: #fde2e2; color: #b91c1c; }
.radio-pildora {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid var(--border); border-radius: 20px;
    padding: .4rem .9rem; cursor: pointer; font-size: .9rem;
}
.radio-pildora-deshabilitada { opacity: .55; cursor: not-allowed; }
:where(html[data-tema="oscuro"]) .pildora-activa { background: #163a22; color: #7fd996; }
:where(html[data-tema="oscuro"]) .pildora-por-vencer { background: #4a3b10; color: #f0c94f; }
:where(html[data-tema="oscuro"]) .pildora-vencida { background: #4a1818; color: #ff8a8a; }

/* ============ Campanita de notificaciones ============ */
.btn-volver-arriba {
    position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 40;
    width: 46px; height: 46px; border-radius: 50%; border: none;
    background: var(--primary); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
    opacity: 0; pointer-events: none; transform: translateY(10px);
    transition: opacity .15s, transform .15s;
}
.btn-volver-arriba.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.btn-volver-arriba:hover { background: var(--primary-dark); }

.notif-campanita { position: relative; }
.notif-trigger { position: relative; }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: #dc2626; color: #fff;
    font-size: .65rem; font-weight: 700; line-height: 1;
    min-width: 16px; height: 16px; padding: 0 3px;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}
.notif-badge[hidden] { display: none; }
.notif-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.1);
    width: 340px;
    max-width: 90vw;
    z-index: 25;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: .9rem;
}
.notif-marcar-todas {
    background: none; border: none; cursor: pointer;
    color: var(--primary); font-size: .78rem; font-weight: 500; padding: 0;
}
.notif-marcar-todas:hover { text-decoration: underline; }
.notif-lista { list-style: none; margin: 0; padding: .3rem; max-height: 360px; overflow-y: auto; }
.notif-item { border-radius: 6px; position: relative; }
.notif-item + .notif-item { margin-top: 2px; }
.notif-item-eliminar {
    position: absolute; top: 6px; right: 6px;
    width: 20px; height: 20px; border-radius: 50%;
    border: none; background: transparent; color: var(--texto-suave);
    font-size: 15px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.notif-item-eliminar:hover { background: rgba(0,0,0,.08); color: #dc2626; }
.notif-item-link {
    display: flex; flex-direction: column; gap: .15rem;
    padding: .6rem 28px .6rem .7rem; border-radius: 6px;
    color: #1c1c1c; text-decoration: none;
}
.notif-item-link:hover { background: var(--gray-bg); }
.notif-item-titulo { font-size: .87rem; font-weight: 600; }
.notif-item-mensaje { font-size: .82rem; color: var(--texto-suave); }
.notif-item-tiempo { font-size: .75rem; color: var(--texto-suave); margin-top: .1rem; }
.notif-item.notif-no-leida .notif-item-link { background: #f0f6ff; }
.notif-item.notif-no-leida .notif-item-titulo::before {
    content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--primary); margin-right: .4rem; vertical-align: middle;
}
.notif-vacio { padding: 1.4rem .9rem; text-align: center; color: var(--texto-suave); font-size: .88rem; }

:where(html[data-tema="oscuro"]) .notif-dropdown { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .notif-item-link { color: var(--texto); }
:where(html[data-tema="oscuro"]) .notif-item.notif-no-leida .notif-item-link { background: var(--sup-input); }
:where(html[data-tema="oscuro"]) .notif-dropdown-header { border-color: var(--border); }

@media (max-width: 480px) {
    .notif-dropdown { position: fixed; right: 8px; left: 8px; width: auto; top: 58px; }
}

/* ============ Dashboard: estadísticas y calendario ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: .85rem; color: #6b7280; }

.grafico-barras-svg { width: 100%; height: auto; max-height: 220px; }
.grafico-barras-valor { font-size: 11px; fill: #374151; font-weight: 600; }
.grafico-barras-etiqueta { font-size: 11px; fill: #6b7280; }
.grafico-barras-eje { stroke: var(--border); stroke-width: 1; }

.estado-vacio { text-align: center; padding: 2.5rem 1rem; }
.estado-vacio-icono { font-size: 2.2rem; opacity: .5; margin-bottom: .6rem; }
.estado-vacio-texto { color: #6b7280; margin: 0 0 1rem; }

.calendar-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    margin-top: 1.5rem;
}

.calendario-sin-horario .fc-view-harness {
    filter: grayscale(1);
    opacity: .55;
    cursor: not-allowed;
}

.calendar-toolbar-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.btn-inline { width: auto; margin-top: 0; padding: .5rem 1rem; }

.fc { font-family: inherit; }
.fc .fc-button-primary { background: var(--primary); border-color: var(--primary); }
.fc .fc-button-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.fc .fc-button-primary:disabled { opacity: .6; }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ============ Detalle de cita ============ */
.detalle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.5rem; margin: 1rem 0 1.5rem; }
.detalle-grid dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; }
.detalle-grid dd { margin: 0; font-size: 1rem; }
.lab-valor-normal { color: #16a34a; font-weight: 600; }
.lab-valor-alto { color: #dc2626; font-weight: 600; }
.lab-valor-bajo { color: #2563eb; font-weight: 600; }

.perfil-lista { margin: 0 0 1.2rem; }
.perfil-lista-fila {
    display: flex;
    gap: .5rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
}
.perfil-lista-fila:last-child { border-bottom: none; }
.perfil-lista-fila dt { font-weight: 600; color: #495057; flex-shrink: 0; min-width: 150px; }
.perfil-lista-fila dd { margin: 0; color: #1f2937; }
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-programada { background: #e7f5ec; color: var(--primary-dark); }
.badge-completada { background: #e9ecef; color: #495057; }
.badge-cancelada { background: #fff5f5; color: var(--error); }
.acciones-fila { display: flex; gap: .7rem; flex-wrap: wrap; }
.acciones-fila .btn, .acciones-fila button { width: auto; margin-top: 0; padding: .6rem 1.1rem; }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #a51111; }
.btn-outline { background: #fff; color: #495057; border: 1px solid var(--border); }
.btn-outline:hover { background: var(--gray-bg); }

/* Menú de Mantenimiento: todos los botones iguales; solo el que está bajo el mouse (o con el
   foco del teclado) toma el color del sistema. */
.menu-mantenimiento .btn-outline:hover,
.menu-mantenimiento .btn-outline:focus-visible {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============ Formularios ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { margin-top: 1rem; }
.form-field label { display: block; margin-bottom: .3rem; font-size: .88rem; }
.form-field input:not([type="checkbox"]):not([type="radio"]), .form-field select, .form-field textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .95rem;
    font-family: inherit;
}
.form-field input[type="checkbox"], .form-field input[type="radio"] {
    width: auto;
    margin: 0;
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-field input:disabled {
    background: var(--gray-bg);
    color: #6b7280;
    cursor: not-allowed;
    border-style: dashed;
}
.info-tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: .35rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
}
.info-tooltip-contenido {
    display: none;
    position: absolute;
    bottom: 135%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    border-radius: 8px;
    padding: .7rem .8rem;
    font-size: .78rem;
    font-weight: 400;
    width: 260px;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    z-index: 50;
    white-space: normal;
}
.info-tooltip-wrap:hover .info-tooltip-contenido,
.info-tooltip-wrap:focus .info-tooltip-contenido { display: block; }
.info-tooltip-contenido table { width: 100%; border-collapse: collapse; margin-top: .3rem; }
.info-tooltip-contenido th, .info-tooltip-contenido td { padding: .25rem .4rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,.15); }
.info-tooltip-contenido th { color: #d1d5db; font-weight: 600; }
.form-hint { font-size: .8rem; color: #6b7280; margin-top: .3rem; }

.dia-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.dia-row:last-child { border-bottom: none; }
.dia-nombre { width: 110px; font-weight: 600; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #ccc; border-radius: 999px; transition: .2s;
}
.switch-slider::before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

.dia-horarios { display: flex; align-items: center; gap: .6rem 1.2rem; flex-wrap: wrap; }
.dia-horarios .campo-hora { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }
.dia-horarios input[type="time"] { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; }

.perfil-header { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1.5rem; }
.form-foto-perfil { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-width: 0; }
.form-foto-perfil input[type="file"] { max-width: 100%; min-width: 0; }
.perfil-foto { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.perfil-foto-placeholder {
    width: 84px; height: 84px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 700;
}

.nav-link.nav-disabled { color: #adb5bd; cursor: not-allowed; }
.nav-link.nav-disabled:hover { background: none; }
.nav-link.nav-disabled .nav-icon svg { stroke: #adb5bd; }

/* ============ Listados admin (nutricionistas / administradores) ============ */
.filtros-bar {
    display: flex;
    gap: .8rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 1.2rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}
.filtros-bar .form-field { margin-top: 0; min-width: 180px; }
.filtros-bar .campo-busqueda-ancho { flex: 2 1 320px; min-width: 320px; }

.envoltura-campo-limpiable { position: relative; }
.campo-busqueda-limpiable { padding-right: 2.2rem !important; }
.btn-limpiar-campo {
    position: absolute;
    right: .4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
}
.btn-limpiar-campo:hover { background: var(--gray-bg); color: #495057; }

.tabla-datos { width: fit-content; max-width: 100%; margin: 0 auto; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabla-datos th, .tabla-datos td { text-align: center; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
.tabla-datos th { background: var(--gray-bg); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; }

.panel-admin .tabla-datos th, .panel-nutricionista .tabla-datos th { background: var(--primary); color: #fff; }
.panel-admin .tabla-datos .th-ordenable:hover, .panel-nutricionista .tabla-datos .th-ordenable:hover { color: #fff; text-decoration: underline; }
.th-ordenable { color: inherit; text-decoration: none; white-space: nowrap; }
.th-ordenable:hover { color: var(--primary-dark); }
.tabla-datos tbody tr { cursor: pointer; }
.tabla-datos tbody tr:hover { background: var(--primary); color: #fff; }
.tabla-datos tbody tr:last-child td { border-bottom: none; }
.badge-activo { background: #e7f5ec; color: var(--primary-dark); padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-inactivo2 { background: #fff5f5; color: var(--error); padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }

.pagina-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; gap: .8rem; }

.input-con-boton { display: flex; gap: .5rem; }
.input-con-boton input { flex: 1; }
.input-con-boton .btn { width: auto; margin-top: 0; white-space: nowrap; }

.paginacion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .8rem;
    margin-top: 1rem;
}
.paginacion-controles { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.paginacion-controles select { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; }

.campo-password { position: relative; flex: 1; }
.campo-password input { width: 100%; padding-right: 2.5rem; }
.toggle-password {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: .2rem;
    display: flex;
    align-items: center;
}
.toggle-password:hover { color: var(--primary-dark); }
.toggle-password svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.campo-fecha { position: relative; }
.campo-fecha input.fecha-formato { width: 100%; padding-right: 2.5rem; box-sizing: border-box; }
.fecha-nativa-oculta {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 19px;
    height: 19px;
    opacity: 0;
    pointer-events: none;
    border: none;
    padding: 0;
    margin: 0;
}
.boton-calendario {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: .2rem;
    display: flex;
    align-items: center;
}
.boton-calendario:hover { color: var(--primary-dark); }
.boton-calendario svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.campo-hora { position: relative; }
.campo-hora input.hora-formato { width: 100%; padding-right: 2.5rem; box-sizing: border-box; }
.hora-nativa-oculta {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 19px;
    height: 19px;
    opacity: 0;
    pointer-events: none;
    border: none;
    padding: 0;
    margin: 0;
}
.boton-reloj {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: .2rem;
    display: flex;
    align-items: center;
}
.boton-reloj:hover { color: var(--primary-dark); }
.boton-reloj svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 150;
}

/* ============ Tablets y celulares ============ */
@media (max-width: 900px) {
    .content { padding: 1.2rem; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 200;
        width: 250px;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    /* En móvil el botón de la topbar abre/cierra el menú (no lo colapsa a solo-íconos). */
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }
    .app-shell.collapsed .sidebar { width: 250px; }
    .app-shell.collapsed .nav-label,
    .app-shell.collapsed .sidebar-brand .brand-text { display: block; }
    .app-shell.collapsed .sidebar-brand { padding: 0 1rem; }
    .app-shell.collapsed .brand-logo { max-height: 48px; max-width: 150px; }
    .app-shell.sidebar-open .sidebar-backdrop { display: block; }

    .form-grid { grid-template-columns: 1fr; }
    .detalle-grid { grid-template-columns: 1fr; }
    .filtros-bar { flex-direction: column; align-items: stretch; }

    .perfil-header { flex-direction: column; align-items: flex-start; text-align: left; }

    .calendar-toolbar-custom { flex-wrap: wrap; gap: .6rem; }
    .calendar-section { padding: .8rem; }

    /* El desplazamiento horizontal de tablas anchas ya es una regla base (no solo móvil). */

    .pagina-header { flex-direction: column; align-items: stretch; }
    .pagina-header > a, .pagina-header > .btn { width: 100%; text-align: center; }

    .paginacion { flex-direction: column; align-items: stretch; text-align: center; }
    .paginacion-controles { justify-content: center; }
}

@media (max-width: 560px) {
    .content { padding: 1rem; }
    .topbar { padding: 0 .8rem; }
    .user-menu-trigger span:not(.avatar-placeholder) { display: none; }
    .card { padding: 1.1rem; }
    .login-form { padding: 1.6rem; }
    .acciones-fila { flex-direction: column; align-items: stretch; }
    .acciones-fila .btn, .acciones-fila button { width: 100%; }
    .dia-nombre { width: 100%; }
}

/* Editor WYSIWYG (barra de herramientas + área editable) */
.wysiwyg-wrap { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; }
.wysiwyg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .4rem; background: var(--gray-bg); border-bottom: 1px solid var(--border); }
.wysiwyg-btn {
    padding: .3rem .55rem;
    font-size: .82rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    line-height: 1.2;
}
.wysiwyg-btn:hover { background: var(--gray-bg); }
.wysiwyg-btn-activo { background: var(--primary); color: #fff; border-color: var(--primary); }
.wysiwyg-separador { width: 1px; align-self: stretch; background: var(--border); margin: 0 .15rem; }
.wysiwyg-select {
    padding: .3rem .4rem;
    font-size: .82rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
.wysiwyg-color-wrap {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .3rem .5rem;
    font-size: .82rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
.wysiwyg-color-wrap input[type="color"] {
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}
.wysiwyg-editable {
    min-height: 140px;
    padding: .7rem .8rem;
    font-size: .95rem;
    line-height: 1.5;
    outline: none;
}
.wysiwyg-editable:focus { box-shadow: inset 0 0 0 2px var(--primary); }
.wysiwyg-editable ul, .wysiwyg-editable ol { padding-left: 1.4rem; margin: .4rem 0; }
.wysiwyg-editable a { color: var(--primary); }
.wysiwyg-editable img { max-width: 100%; height: auto; }
.wysiwyg-fuente {
    display: block;
    width: 100%;
    min-height: 140px;
    padding: .7rem .8rem;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: .82rem;
    line-height: 1.5;
    border: none;
    outline: none;
    resize: vertical;
    box-sizing: border-box;
}

/* Footer del sitio (franja del color primario, ancho completo de la página) */
.footer-sitio { width: 100%; color: #fff; padding: 1.2rem 1.5rem; }
.footer-sitio-cols { display: grid; gap: 1.2rem; font-size: .85rem; line-height: 1.5; }
.footer-sitio-cols-1 { grid-template-columns: 1fr; text-align: center; }
.footer-sitio-cols-2 { grid-template-columns: 1fr 1fr; }
.footer-sitio-cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.footer-sitio-col { min-width: 0; overflow-wrap: break-word; }
.footer-sitio-col a { color: #fff; text-decoration: underline; }
.footer-sitio-col p { margin: 0 0 .4rem; }
.footer-sitio-col p:last-child { margin-bottom: 0; }
@media (max-width: 700px) {
    .footer-sitio-cols-2, .footer-sitio-cols-3 { grid-template-columns: 1fr; text-align: center; }
}

/* ---- Receta: foto, buscador de ingredientes, pasos dinámicos ---- */
.receta-foto-preview { width: 100%; max-width: 360px; height: 260px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; margin-bottom: .6rem; background: #f3f4f6; cursor: zoom-in; }
.receta-ingrediente-buscador { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; background: #fafafa; }
.receta-ingrediente-buscador-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.tabla-ingredientes-buscar { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tabla-ingredientes-buscar th { text-align: left; padding: .4rem .5rem; color: #6b7280; font-weight: 600; font-size: .78rem; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.tabla-ingredientes-buscar td { padding: .5rem; border-bottom: 1px solid #eee; vertical-align: middle; }
.tabla-ingredientes-buscar tr.fila-ingrediente { position: relative; }
.tabla-ingredientes-buscar tr.fila-ingrediente:hover { background: #f0f7ec; }
.tabla-ingredientes-buscar input[type=number] { width: 70px; padding: .3rem .4rem; }
.tabla-ingredientes-buscar select { padding: .3rem .4rem; max-width: 140px; }
.btn-agregar-ingrediente-fila { visibility: hidden; background: var(--primary); color: #fff; border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 1rem; line-height: 1; }
tr.fila-ingrediente:hover .btn-agregar-ingrediente-fila { visibility: visible; }
.paso-preparacion-fila { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .6rem; }
.paso-preparacion-numero { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 600; margin-top: .3rem; }
.paso-preparacion-texto { flex: 1; min-height: 44px; resize: vertical; }
.paso-preparacion-borrar { background: none; border: none; cursor: pointer; color: #b91c1c; padding: .3rem; margin-top: .2rem; }
.paso-preparacion-borrar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.ingrediente-guardado-fila { display: flex; justify-content: space-between; align-items: center; padding: .6rem .2rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.ingrediente-guardado-fila:last-child { border-bottom: none; }
.ingrediente-guardado-nombre { font-weight: 600; }
.ingrediente-guardado-detalle { color: #6b7280; font-size: .82rem; }

/* ---- Receta: menú flotante de ingrediente + modal ancho de valores nutricionales ---- */
.ingrediente-guardado-fila { cursor: pointer; }
.ingrediente-guardado-fila:hover { background: #f7f7f2; }
.menu-flotante-ingrediente {
    display: none;
    position: fixed;
    z-index: 1100;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    min-width: 200px;
    overflow: hidden;
}
.menu-flotante-ingrediente.activo { display: block; }
.menu-flotante-ingrediente button {
    display: block;
    width: 100%;
    text-align: left;
    padding: .7rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .92rem;
    color: #1f2937;
}
.menu-flotante-ingrediente button:hover { background: var(--gray-bg); }
.modal-box-ancho { max-width: 900px; max-height: 85vh; overflow-y: auto; }
.modal-cerrar-abajo {
    display: block;
    margin: 1.4rem 0 0 auto;
    padding: .55rem 1.4rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: .95rem;
}
.modal-cerrar-abajo:hover { background: var(--primary-dark); }
.grupo-nutricional-modal-titulo { font-weight: 600; color: var(--primary-dark); padding: .9rem 0 .3rem; margin: 0; }
.grid-nutricional-modal { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
.grid-nutricional-modal > div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .3rem; border-bottom: 1px solid #eee; font-size: .9rem; }
.grid-nutricional-modal > div span:last-child { font-weight: 600; white-space: nowrap; }
@media (max-width: 640px) {
    .grid-nutricional-modal { grid-template-columns: 1fr; }
}
.btn-icono-borrar { background: none; border: none; cursor: pointer; color: #b91c1c; padding: .3rem; }
.btn-icono-editar { background: none; border: none; cursor: pointer; color: #2563eb; padding: .3rem; }
.btn-icono-editar:hover { color: #1d4ed8; }
:where(html[data-tema="oscuro"]) .btn-icono-editar { color: #60a5fa; }
:where(html[data-tema="oscuro"]) .btn-icono-editar:hover { color: #93c5fd; }
.btn-icono-editar svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.btn-icono-borrar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.lista-archivos-adjuntos { list-style: none; padding: 0; margin: .4rem 0 0; }
.lista-archivos-adjuntos li { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.lista-archivos-adjuntos li:last-child { border-bottom: none; }
.lista-archivos-adjuntos a { color: var(--primary); text-decoration: none; word-break: break-word; }
.lista-archivos-adjuntos a:hover { text-decoration: underline; }

/* ---- Receta: campo de tiempo de preparación (horas + minutos) ---- */
.campo-tiempo-preparacion { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; }
.campo-tiempo-preparacion .campo-tiempo-icono { padding: 0 .5rem; color: #6b7280; display: flex; align-items: center; }
.campo-tiempo-preparacion .campo-tiempo-icono svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.campo-tiempo-preparacion input[type="number"] { border: none; border-left: 1px solid var(--border); width: 2.4em; padding: .55rem .2rem; text-align: center; border-radius: 0; }
.campo-tiempo-preparacion input:focus { outline: none; }
.campo-tiempo-display { display: none; align-items: center; padding: .55rem .8rem; user-select: none; font-variant-numeric: tabular-nums; }
.campo-tiempo-display[tabindex] { cursor: pointer; }
.campo-tiempo-display:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.campo-archivo-oculto { display: none; }
.campo-archivo-personalizado { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.campo-archivo-personalizado label { cursor: pointer; margin: 0; }
.form-grid-tres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1.5rem; align-items: end; }
.campo-con-icono { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; }
.campo-con-icono-icono { padding: 0 .55rem; color: #6b7280; display: flex; align-items: center; flex-shrink: 0; }
.campo-con-icono-icono svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.campo-con-icono input { border: none !important; padding: .6rem .4rem; border-radius: 0 !important; width: 6.2em !important; }
.campo-con-icono input:focus { outline: none; }
@media (max-width: 700px) {
    .form-grid-tres { grid-template-columns: 1fr; gap: 1rem 0; }
}

/* ---- Receta: gráfico circular (donut) de macronutrientes ---- */
.donut-nutricional-wrap { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; margin: 1rem 0; }
.donut-nutricional { width: 200px; height: 200px; border-radius: 50%; position: relative; flex-shrink: 0; }
.donut-nutricional-centro {
    position: absolute;
    inset: 18%;
    background: #fff;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 0 0 1px #eee inset;
}
.donut-nutricional-centro strong { font-size: 1.15rem; }
.donut-nutricional-centro span { font-size: .72rem; color: #6b7280; max-width: 90px; }
.leyenda-donut { display: flex; flex-direction: column; gap: .6rem; }
.leyenda-donut-item { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.leyenda-donut-punto { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
@media (max-width: 640px) {
    .donut-nutricional-wrap { justify-content: center; }
}


/* Gráficos de evolución: el valor de cada punto aparece al pasar el mouse o al enfocarlo */
.grafico-evolucion-svg .punto-grafico { cursor: pointer; outline: none; }
.grafico-evolucion-svg .punto-etiqueta { opacity: 0; pointer-events: none; transition: opacity .1s; }
.grafico-evolucion-svg .punto-grafico:hover .punto-etiqueta,
.grafico-evolucion-svg .punto-grafico:focus .punto-etiqueta { opacity: 1; }
.grafico-evolucion-svg .punto-grafico:hover .punto-visible,
.grafico-evolucion-svg .punto-grafico:focus .punto-visible { r: 5.5; }

/* ==========================================================================
   MODO NOCTURNO (generado a partir de las reglas de arriba)
   Se activa cuando el servidor marca <html data-tema="oscuro"> (según la programación
   horaria del sistema o del nutricionista). Los colores de marca (--primary, --primary-dark,
   --gray-bg) ya llegan con los valores nocturnos configurados; aquí solo se oscurecen las
   superficies y el texto que en el modo claro son blancos/grises fijos.
   Los selectores usan :where() para no ganarle en especificidad a las reglas más específicas
   que ya existen (hover, activo, texto blanco sobre el color primario).
   ========================================================================== */
:root[data-tema="oscuro"] {
    color-scheme: dark;
    --border: #3a4048;
    --error: #ff7b7b;
    --sup: #1f2328;        /* tarjetas, barras laterales y superiores */
    --sup-alta: #272c33;   /* menús flotantes, modales, filas resaltadas */
    --sup-input: #181b1f;  /* campos de formulario */
    --texto: #e6e4de;
    --texto-suave: #a3abb5;
    --etiqueta-verde: #1a2f22;
}
:where(html[data-tema="oscuro"]) body { color: var(--texto); }
:where(html[data-tema="oscuro"]) a { color: #8ab4f8; }
:where(html[data-tema="oscuro"]) input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]), :where(html[data-tema="oscuro"]) select, :where(html[data-tema="oscuro"]) textarea {
    background: var(--sup-input); color: var(--texto); border-color: var(--border);
}
:where(html[data-tema="oscuro"]) ::placeholder { color: var(--texto-suave); opacity: .75; }
:where(html[data-tema="oscuro"]) body { color: var(--texto); }
:where(html[data-tema="oscuro"]) .login-form { background: var(--sup); }
:where(html[data-tema="oscuro"]) .registro-form { background: var(--sup); }
:where(html[data-tema="oscuro"]) .plan-membresia-opcion.seleccionado { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .metodo-pago-opcion.seleccionado { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .ficha-tab { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .foto-card { background: var(--sup); }
:where(html[data-tema="oscuro"]) .lightbox-contenido .grafico-evolucion-serie { background: var(--sup); }
:where(html[data-tema="oscuro"]) .modal-box { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .modal-cerrar { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .grafico-evolucion { background: var(--sup); }
:where(html[data-tema="oscuro"]) .grafico-evolucion-titulo { color: var(--texto); }
:where(html[data-tema="oscuro"]) .grafico-evolucion-leyenda { color: var(--texto); }
:where(html[data-tema="oscuro"]) .tabla-habitos th { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .card { background: var(--sup); }
:where(html[data-tema="oscuro"]) .sidebar { background: var(--sup); }
:where(html[data-tema="oscuro"]) .nav-link { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .nav-sublink { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .topbar { background: var(--sup); }
:where(html[data-tema="oscuro"]) .icon-btn { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .user-menu-trigger { color: var(--texto); }
:where(html[data-tema="oscuro"]) .user-dropdown { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .user-dropdown a { color: var(--texto); }
:where(html[data-tema="oscuro"]) .stat-card { background: var(--sup); }
:where(html[data-tema="oscuro"]) .stat-label { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .estado-vacio-texto { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .calendar-section { background: var(--sup); }
:where(html[data-tema="oscuro"]) .detalle-grid dt { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .perfil-lista-fila dt { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .perfil-lista-fila dd { color: var(--texto); }
:where(html[data-tema="oscuro"]) .badge-completada { background: var(--sup-alta); color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .btn-outline { background: var(--sup); color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .form-field input:disabled { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .form-hint { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .nav-link.nav-disabled { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .filtros-bar { background: var(--sup); }
:where(html[data-tema="oscuro"]) .btn-limpiar-campo:hover { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .tabla-datos { background: var(--sup); }
:where(html[data-tema="oscuro"]) .tabla-datos th { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .toggle-password { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .boton-calendario { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .boton-reloj { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .wysiwyg-wrap { background: var(--sup); }
:where(html[data-tema="oscuro"]) .wysiwyg-btn { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .wysiwyg-select { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .wysiwyg-color-wrap { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .receta-foto-preview { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .receta-ingrediente-buscador { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .tabla-ingredientes-buscar th { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .tabla-ingredientes-buscar td { border-color: var(--border); }
:where(html[data-tema="oscuro"]) .tabla-ingredientes-buscar tr.fila-ingrediente:hover { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .ingrediente-guardado-detalle { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .ingrediente-guardado-fila:hover { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .menu-flotante-ingrediente { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .menu-flotante-ingrediente button { color: var(--texto); }
:where(html[data-tema="oscuro"]) .grid-nutricional-modal > div { border-color: var(--border); }
:where(html[data-tema="oscuro"]) .campo-tiempo-preparacion { background: var(--sup); }
:where(html[data-tema="oscuro"]) .campo-tiempo-preparacion .campo-tiempo-icono { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .campo-con-icono { background: var(--sup); }
:where(html[data-tema="oscuro"]) .campo-con-icono-icono { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .donut-nutricional-centro { background: var(--sup-alta); }
:where(html[data-tema="oscuro"]) .donut-nutricional-centro span { color: var(--texto-suave); }
:where(html[data-tema="oscuro"]) .btn-outline:hover { background: var(--sup-alta); }

/* Avisos de color (éxito, error, información) en versión oscura */
:where(html[data-tema="oscuro"]) .error { background:#3a1f23; border-color:#6b2c32; color:var(--error); }
:where(html[data-tema="oscuro"]) .aviso-info { background:#1b2d3d; border-color:#2c4a63; color:#8fc5ea; }
:where(html[data-tema="oscuro"]) .banner-solo-lectura { background:#3a3420; border-color:#5e5330; color:#f0d36b; }
:where(html[data-tema="oscuro"]) .banner-membresia-por-vencer { background:#1c2b45; border-color:#2f4a75; color:#9cc0f5; }
:where(html[data-tema="oscuro"]) .success { background:#1a2f22; border-color:#2f5a3d; }
:where(html[data-tema="oscuro"]) .toast { background:#1a2f22; border-color:#2f5a3d; }
:where(html[data-tema="oscuro"]) .badge-programada { background:#1a2f22; }
:where(html[data-tema="oscuro"]) .badge-activo { background:#1a2f22; }
:where(html[data-tema="oscuro"]) .badge-completada { background:var(--sup-alta); color:var(--texto-suave); }
:where(html[data-tema="oscuro"]) .badge-cancelada { background:#3a1f23; }
:where(html[data-tema="oscuro"]) .badge-inactivo2 { background:#3a1f23; }
:where(html[data-tema="oscuro"]) .plan-membresia-opcion.seleccionado { background:#1a2f22; }
:where(html[data-tema="oscuro"]) .metodo-pago-opcion.seleccionado { background:#1a2f22; }

/* Texto blanco sobre el color primario: se reafirma */
:where(html[data-tema="oscuro"]) .login-form button { color: #fff; }
:where(html[data-tema="oscuro"]) .registro-form button:not(.btn):not(.boton-calendario) { color: #fff; }
:where(html[data-tema="oscuro"]) .btn { color: #fff; }
:where(html[data-tema="oscuro"]) .ficha-tab.active { color: #fff; }
:where(html[data-tema="oscuro"]) .modal-box button[type="submit"] { color: #fff; }
:where(html[data-tema="oscuro"]) .acordeon-ficha summary { color: #fff; }
:where(html[data-tema="oscuro"]) .acordeon-ficha summary::before { color: #fff; }
:where(html[data-tema="oscuro"]) .nav-link:hover { color: #fff; }
:where(html[data-tema="oscuro"]) .nav-link.active { color: #fff; }
:where(html[data-tema="oscuro"]) .nav-sublink:hover { color: #fff; }
:where(html[data-tema="oscuro"]) .avatar-placeholder { color: #fff; }
:where(html[data-tema="oscuro"]) /* Menú de Mantenimiento: todos los botones iguales; solo el que está bajo el mouse (o con el
   foco del teclado) toma el color del sistema. */
.menu-mantenimiento .btn-outline:hover { color: #fff; }
:where(html[data-tema="oscuro"]) .menu-mantenimiento .btn-outline:focus-visible { color: #fff; }
:where(html[data-tema="oscuro"]) .info-tooltip-wrap { color: #fff; }
:where(html[data-tema="oscuro"]) .info-tooltip-contenido { color: #fff; }
:where(html[data-tema="oscuro"]) .perfil-foto-placeholder { color: #fff; }
:where(html[data-tema="oscuro"]) .panel-admin .tabla-datos th { color: #fff; }
:where(html[data-tema="oscuro"]) .panel-nutricionista .tabla-datos th { color: #fff; }
:where(html[data-tema="oscuro"]) .panel-admin .tabla-datos .th-ordenable:hover { color: #fff; }
:where(html[data-tema="oscuro"]) .panel-nutricionista .tabla-datos .th-ordenable:hover { color: #fff; }
:where(html[data-tema="oscuro"]) .tabla-datos tbody tr:hover { color: #fff; }
:where(html[data-tema="oscuro"]) .wysiwyg-btn-activo { color: #fff; }
:where(html[data-tema="oscuro"]) .footer-sitio { color: #fff; }
:where(html[data-tema="oscuro"]) .footer-sitio-col a { color: #fff; }
:where(html[data-tema="oscuro"]) .btn-agregar-ingrediente-fila { color: #fff; }
:where(html[data-tema="oscuro"]) .paso-preparacion-numero { color: #fff; }
:where(html[data-tema="oscuro"]) .modal-cerrar-abajo { color: #fff; }

/* El botón de peligro conserva su rojo (--error en modo nocturno es un rojo claro para texto) */
:where(html[data-tema="oscuro"]) .btn-danger { background: #c92a2a; color: #fff; }
:where(html[data-tema="oscuro"]) .btn-danger:hover { background: #a51111; }

/* Fondos de hover/activo que en modo claro usan el "primario oscuro" con texto blanco: en modo
   nocturno ese color es claro (se usa para textos), así que aquí se usa un derivado oscuro del
   color primario para que el texto blanco se siga leyendo. */
:root[data-tema="oscuro"] { --hover-fondo: #3b6a31; --texto-portal: var(--texto); }
@supports (background: color-mix(in srgb, red, blue)) {
    :root[data-tema="oscuro"] { --hover-fondo: color-mix(in srgb, var(--primary) 78%, #000); }
}
:where(html[data-tema="oscuro"]) .login-form button:hover { background: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .registro-form button:not(.btn):not(.boton-calendario):hover { background: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .btn:hover { background: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .modal-box button[type="submit"]:hover { background: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .acordeon-ficha summary:hover { background: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .fc .fc-button-primary:hover { background: var(--hover-fondo); border-color: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--hover-fondo); border-color: var(--hover-fondo); }
:where(html[data-tema="oscuro"]) .modal-cerrar-abajo:hover { background: var(--hover-fondo); }

/* FullCalendar (librería externa con sus propias variables de color). Se usa html[...] sin
   :where() porque la librería inyecta sus estilos después de esta hoja y, con igual
   especificidad, ganaría ella. */
html[data-tema="oscuro"] .fc {
    --fc-page-bg-color: var(--sup);
    --fc-neutral-bg-color: var(--sup-alta);
    --fc-neutral-text-color: var(--texto-suave);
    --fc-border-color: var(--border);
    --fc-today-bg-color: rgba(255, 255, 255, .07);
    --fc-highlight-color: rgba(255, 255, 255, .12);
    --fc-non-business-color: rgba(255, 255, 255, .04);
    --fc-list-event-hover-bg-color: var(--sup-alta);
    --fc-more-link-bg-color: var(--sup-alta);
    --fc-now-indicator-color: #ff7b7b;
    color: var(--texto);
}
/* En el calendario los enlaces (números de día, títulos de citas) heredan el color del texto,
   igual que en modo claro; no deben tomar el azul de enlace general. */
html[data-tema="oscuro"] .fc a { color: inherit; }

/* Flechas para reordenar el menú del nutricionista (Mantenimiento > Mantenimiento Menú) */
.btn-flecha-orden { background: #fff; border: 1px solid var(--border); border-radius: 5px; width: 26px; height: 24px; cursor: pointer; font-size: 13px; line-height: 1; }
.btn-flecha-orden:disabled { opacity: .35; cursor: not-allowed; }
.btn-flecha-orden:not(:disabled):hover { background: var(--gray-bg); }
:where(html[data-tema="oscuro"]) .btn-flecha-orden { background: var(--sup-input); color: var(--texto); border-color: var(--border); }

/* ============ Mensajería interna (sobre + chat) ============ */
.msg-sobre { position: relative; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; align-items: start; }
.chat-lista { padding: .5rem; max-height: 70vh; overflow-y: auto; }
.chat-conv { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; padding: .6rem .7rem; border-radius: 8px; text-decoration: none; color: inherit; }
.chat-conv:hover, .chat-conv.activa { background: var(--gray-bg); }
.chat-conv-nombre { font-weight: 600; font-size: .9rem; }
.chat-conv-badge { background: var(--primary); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 .45rem; align-self: center; }
.chat-conv-ultimo { grid-column: 1 / -1; font-size: .8rem; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-panel { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; }
.chat-cabecera { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.chat-mensajes { display: flex; flex-direction: column; gap: .5rem; height: 55vh; min-height: 280px; overflow-y: auto; padding: .4rem; background: var(--gray-bg); border-radius: 12px; }
.chat-burbuja { max-width: 78%; padding: .5rem .75rem; border-radius: 14px; }
.chat-propio { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-ajeno { align-self: flex-start; background: var(--sup, #fff); color: var(--texto, #1c1c1c); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-texto { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.chat-hora { font-size: .68rem; opacity: .75; text-align: right; margin-top: .15rem; }
.chat-form textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.chat-form-pie { display: flex; align-items: center; justify-content: flex-end; gap: .8rem; margin-top: .4rem; }
.chat-form-pie .error { margin-right: auto; }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; } .chat-lista { max-height: 220px; } }
.chat-form-pie .error:empty { display: none; }

/* Botón luna/sol: en modo normal se ve la luna; en modo oscuro, el sol. */
.btn-tema { background: none; border: none; cursor: pointer; color: inherit; display: inline-flex; align-items: center; justify-content: center; }
.btn-tema .tema-sol { display: none; }
html[data-tema="oscuro"] .btn-tema .tema-luna { display: none; }
html[data-tema="oscuro"] .btn-tema .tema-sol { display: block; }

/* Primeros pasos (dashboard del nutricionista). Usa los colores del sistema/nutricionista y el modo nocturno. */
.onboarding-card { margin-bottom: 1.2rem; }
.onboarding-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.onboarding-barra { height: 8px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; margin: .9rem 0 .6rem; }
.onboarding-barra span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.onboarding-lista { list-style: none; margin: 0; padding: 0; }
.onboarding-lista li { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; border-top: 1px solid var(--border); }
.onboarding-lista li:first-child { border-top: none; }
.onboarding-marca { flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; }
.onboarding-hecho .onboarding-marca { background: var(--primary); border-color: var(--primary); }
.onboarding-texto { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.onboarding-texto span { font-size: .85rem; color: var(--texto-suave); }
.onboarding-hecho .onboarding-texto strong { text-decoration: line-through; opacity: .6; }

/* Barras simples de las métricas del admin (usan el color primario vigente). */
.barra-metrica { height: 10px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; min-width: 80px; }
.barra-metrica span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* Tarjetas de alerta de reportes (antes con colores fijos): ahora también en modo oscuro. */
.stat-alerta-roja { border-color: #fecaca; background: #fef2f2; }
.stat-alerta-roja .stat-value, .stat-alerta-roja .stat-label { color: #b91c1c; }
.stat-alerta-amarilla { border-color: #ffe08a; background: #fff3bf; }
.stat-alerta-amarilla .stat-value, .stat-alerta-amarilla .stat-label { color: #7a5c00; }
:where(html[data-tema="oscuro"]) .stat-alerta-roja { border-color: #7a2a2a; background: #3a1818; }
:where(html[data-tema="oscuro"]) .stat-alerta-roja .stat-value, :where(html[data-tema="oscuro"]) .stat-alerta-roja .stat-label { color: #ff9a9a; }
:where(html[data-tema="oscuro"]) .stat-alerta-amarilla { border-color: #6b5410; background: #3a3010; }
:where(html[data-tema="oscuro"]) .stat-alerta-amarilla .stat-value, :where(html[data-tema="oscuro"]) .stat-alerta-amarilla .stat-label { color: #f0c94f; }

/* Bioimpedancia > Distribución segmental (formulario de antropometría). Usa variables del tema. */
.tabla-segmental { width: 100%; border-collapse: collapse; }
.tabla-segmental th, .tabla-segmental td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; }
.tabla-segmental thead th { font-size: .88rem; color: var(--texto-suave); font-weight: 600; }
.tabla-segmental tbody th, .tabla-segmental tbody th[scope="row"] { font-weight: 400 !important; font-size: .88rem; white-space: nowrap; }
.tabla-segmental .form-field { margin: 0; min-width: 110px; }
.tabla-segmental .form-field input { text-align: right; }

/* Botón Cerrar del detalle de notificación: legible en claro y oscuro */
#modalNotifDetalle .modal-cerrar-abajo { background: var(--gray-bg); color: #1c1c1c; border: 1px solid var(--border); }
:where(html[data-tema="oscuro"]) #modalNotifDetalle .modal-cerrar-abajo { background: var(--sup-alta); color: var(--texto-suave); border-color: var(--border); }

/* Alternativas (equivalencias) de los alimentos del plan */
.alt-lista { margin-top: .35rem; font-size: .82rem; color: var(--texto-suave); display: flex; flex-wrap: wrap; gap: .3rem .4rem; align-items: center; justify-content: flex-start; text-align: left; min-width: 240px; }
.alt-titulo { font-weight: 600; }
.alt-chip { background: var(--etiqueta-verde); color: var(--texto); border-radius: 10px; padding: .15rem .2rem .15rem .6rem; display: inline-flex; align-items: center; gap: .2rem; text-align: left; }
.alt-quitar { background: none; border: none; cursor: pointer; color: var(--texto-suave); font-size: 1rem; line-height: 1; padding: 0 .4rem; }
.alt-quitar:hover { color: var(--error); }
.btn-alt-pequeno { padding: .15rem .6rem; font-size: .8rem; }

/* Comparación de un total del plan con la meta (el signo y el % van en el texto: el color solo refuerza) */
.meta-dif { display:inline-block; margin-left:.4rem; padding:.05rem .5rem; border-radius:999px; font-size:.75rem; font-weight:600; white-space:nowrap; }
.meta-ok { background:#ebf5e8; color:#2f6b25; }
.meta-aviso { background:#fff4d6; color:#8a5a00; }
.meta-alerta { background:#fff5f5; color:var(--error); }
:where(html[data-tema="oscuro"]) .meta-ok { background:#1f3a22; color:#9be29b; }
:where(html[data-tema="oscuro"]) .meta-aviso { background:#3d3417; color:#f2cf73; }
:where(html[data-tema="oscuro"]) .meta-alerta { background:#3a1f23; color:#ff9a9a; }

/* Adherencia en Comidas: tarjetas resumen, tira de 28 días y barras por semana (solo HTML/CSS) */
.card.adh { max-width:760px; }
.adh { --adh-ok:#3f8f3a; --adh-cambios:#e0a526; --adh-vacio:#e3e6e0; --adh-bajo:#d9534f; }
:where(html[data-tema="oscuro"]) .adh { --adh-ok:#5fb45a; --adh-cambios:#d9a93a; --adh-vacio:#3a3f3c; --adh-bajo:#e0706c; }
.adh-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:.7rem; margin:.7rem 0 1.1rem; }
.adh-kpi { background:var(--gray-bg); border-radius:12px; padding:.7rem .9rem; }
.adh-kpi-valor { font-size:1.6rem; font-weight:700; line-height:1.1; }
.adh-kpi-valor small { font-size:.9rem; font-weight:500; color:var(--texto-suave); }
.adh-kpi-etq { font-size:.78rem; color:var(--texto-suave); margin-top:.15rem; }
.adh-sub { font-size:.8rem; font-weight:600; color:var(--texto-suave); margin:0 0 .4rem; }
.adh-tira { display:grid; grid-template-columns:repeat(28,1fr); gap:3px; }
.adh-dia { aspect-ratio:1; border-radius:4px; background:var(--adh-vacio); min-width:0; }
.adh-dia.ok { background:var(--adh-ok); } .adh-dia.cambios { background:var(--adh-cambios); }
.adh-leyenda { display:flex; flex-wrap:wrap; gap:.4rem 1rem; font-size:.78rem; color:var(--texto-suave); margin-top:.5rem; }
.adh-leyenda i { display:inline-block; width:.7rem; height:.7rem; border-radius:3px; margin-right:.3rem; vertical-align:-1px; }
.adh-semanas { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.8rem; margin-top:1.2rem; align-items:end; }
.adh-sem { text-align:center; }
.adh-barra-caja { height:110px; display:flex; align-items:flex-end; justify-content:center; background:repeating-linear-gradient(to top, transparent 0, transparent calc(100%/7 - 1px), var(--border) calc(100%/7 - 1px), var(--border) calc(100%/7)); border-radius:6px; }
.adh-barra { width:58%; max-width:56px; border-radius:6px 6px 0 0; min-height:3px; background:var(--adh-ok); }
.adh-barra.medio { background:var(--adh-cambios); } .adh-barra.bajo { background:var(--adh-bajo); }
.adh-sem-valor { font-weight:700; margin-top:.4rem; } .adh-sem-valor small { font-weight:500; color:var(--texto-suave); }
.adh-sem-fecha { font-size:.75rem; color:var(--texto-suave); } .adh-sem-fiel { font-size:.75rem; margin-top:.15rem; }
@media (max-width:520px) { .adh-tira { grid-template-columns:repeat(14,1fr); } .adh-barra-caja { height:80px; } }
