/* =========================================================
   style.css — DietApp
   Glassmorphism, responsive, breakpoints 320 / 768 / 1024 / 1440
   ========================================================= */

:root {
    --bg: #eef3fb;
    --bg-grad-1: #e6ecfb;
    --bg-grad-2: #dcedf2;
    --text: #1e2a3a;
    --muted: #64748b;
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0284c7;
    --glass-bg: rgba(255, 255, 255, 0.62);
    --glass-brd: rgba(255, 255, 255, 0.55);
    --card-shadow: 0 8px 32px rgba(31, 38, 135, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background: linear-gradient(135deg, var(--bg-grad-1), var(--bg-grad-2)) fixed;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    overflow-x: clip;
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

img { max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
p { line-height: 1.5; }

/* ---------------------------------------------------------
   Utilidades
   --------------------------------------------------------- */
.muted { color: var(--muted); }
.muted-note { color: var(--muted); font-size: .9rem; }
.hidden { display: none !important; }
.good { color: var(--success); }
.warn { color: var(--danger); }
.sep { border: 0; border-top: 1px solid rgba(100, 116, 139, .25); margin: 1.5rem 0; }
.center-empty { text-align: center; padding: 2.5rem 1.5rem; }
.center-page { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.tip { font-size: .85rem; }

/* ---------------------------------------------------------
   Layout general (app)
   --------------------------------------------------------- */
.app-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--glass-brd);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: .6rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1.15rem;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; }

.main-nav {
    display: flex;
    gap: .2rem;
    flex-wrap: wrap;
    flex: 1;
}
.main-nav a {
    color: var(--muted);
    font-weight: 600;
    padding: .45rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    transition: background .15s, color .15s;
}
.main-nav a:hover {
    color: var(--brand);
    background: rgba(79, 70, 229, .08);
    text-decoration: none;
}
.main-nav a.active {
    color: var(--brand);
    background: rgba(79, 70, 229, .12);
}

/* Submenú desplegable (p. ej. Informes) */
.nav-drop {
    position: relative;
}
.nav-drop-btn {
    background: transparent;
    border: 0;
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    font-size: .92rem;
    font-family: inherit;
    padding: .45rem .7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: normal;
}
.nav-drop-btn:hover {
    color: var(--brand);
    background: rgba(79, 70, 229, .08);
}
.nav-drop-btn.open { color: var(--brand); }
.nav-drop-menu {
    position: absolute;
    top: calc(100% + .4rem);
    left: 0;
    z-index: 60;
    min-width: 190px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    backdrop-filter: blur(14px);
    display: none;
    flex-direction: column;
    padding: .4rem;
    gap: .15rem;
}
.nav-drop.open .nav-drop-menu { display: flex; }
.nav-drop-menu a {
    padding: .55rem .7rem;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    white-space: nowrap;
}
.nav-drop-menu a:hover {
    background: rgba(79, 70, 229, .1);
    color: var(--brand);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.icon-btn {
    position: relative;
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    cursor: pointer;
    padding: .35rem .5rem;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.icon-btn:hover { background: rgba(100, 116, 139, .15); }
.badge-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 17px;
    height: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.avatar-link { display: inline-flex; align-items: center; gap: .5rem; }
.avatar-ph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-weight: 700;
    border-radius: 50%;
    overflow: hidden;
}
.avatar-sm { width: 30px; height: 30px; font-size: .85rem; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 42px; height: 42px; font-size: 1rem; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; }

.logout-link { color: var(--muted); font-size: 1.1rem; padding: .3rem .5rem; }

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

/* ---------------------------------------------------------
   Menú hamburguesa (móvil)
   --------------------------------------------------------- */
.hamburger {
    display: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: .35rem;
    color: var(--text);
    line-height: 0;
}
.hamburger svg {
    display: block;
    width: 24px;
    height: 24px;
}

/* Informe Evolución */
.evo-row { cursor: pointer; }
.evo-row:hover td { background: rgba(79, 70, 229, .06); }
.evo-thumb { cursor: pointer; }
.evo-period {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .7rem;
}
.evo-period .btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
/* Modal comparativa */
.evo-photos {
    display: flex;
    gap: 1rem;
    margin-bottom: .8rem;
}
.evo-photos figure {
    flex: 1;
    margin: 0;
    text-align: center;
}
.evo-photos img {
    width: 100%;
    max-height: 38vh;
    border-radius: var(--radius);
    object-fit: cover;
    display: block;
}
.evo-photos figcaption {
    margin-top: .3rem;
    font-size: .82rem;
    color: var(--muted);
}
.evo-nophoto {
    width: 100%;
    height: 20vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(100, 116, 139, .08);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .85rem;
}
.evo-select-label {
    display: block;
    margin-bottom: .6rem;
    font-weight: 600;
    font-size: .88rem;
}
.evo-select-label select {
    margin-left: .4rem;
    font-weight: 400;
}
.evo-modal-photo img {
    max-width: 100%;
    max-height: 50vh;
    border-radius: var(--radius);
    display: block;
    margin: 0 auto .8rem;
}
.evo-modal .table { margin-bottom: .5rem; }
.evo-diff td, .evo-diff th { text-align: left; }
.diff-up   { color: #dc2626; font-weight: 700; }
.diff-down { color: #16a34a; font-weight: 700; }
.diff-same { color: var(--muted); }
.evo-notes { margin-top: .4rem; }

/* ---------------------------------------------------------
   Cards (glass)
   --------------------------------------------------------- */
.chart-wrap {
    position: relative;
    width: 100%;
    height: 300px;
}
.chart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.card h2 { font-size: 1.05rem; margin-bottom: .75rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; }
.narrow { max-width: 560px; margin: 0 auto 1.25rem; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-head h1 { font-size: 1.5rem; display: flex; align-items: center; gap: .6rem; }

/* ---------------------------------------------------------
   Botones
   --------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: transform .08s, box-shadow .15s, background .15s;
    font-family: var(--font);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .35); }
.btn-primary:hover { background: #4338ca; }

.btn-outline { background: transparent; color: var(--brand); border-color: rgba(79, 70, 229, .4); }
.btn-outline:hover { background: rgba(79, 70, 229, .08); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }

.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.inline-form { display: inline; margin: 0; }

.inline-del { display: inline; margin: 0; }
.row-actions { display: inline-flex; gap: .4rem; align-items: center; }
.row-actions form { margin: 0; }
.meal-photo-item { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }

/* ---------------------------------------------------------
   Formularios
   --------------------------------------------------------- */
.stack-form { display: flex; flex-direction: column; gap: .85rem; }
.stack-form label.remember-row { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.stack-form label.remember-row input[type="checkbox"] { width: auto; flex: 0 0 auto; }
.stack-form label, .form-row label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--text); flex: 1; }
.stack-form input,
.stack-form select,
.stack-form textarea,
.form-row input,
.form-row select,
.form-row textarea,
.search-bar input,
.food-search,
.feed-comment-form input,
.chat-form input {
    font-family: var(--font);
    font-size: .95rem;
    color: var(--text);
    background: rgba(255, 255, 255, .7);
    border: 1px solid rgba(100, 116, 139, .3);
    border-radius: var(--radius-sm);
    padding: .55rem .7rem;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus,
.form-row input:focus, .form-row select:focus, .form-row textarea:focus,
.search-bar input:focus, .food-search:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
.form-row { display: flex; gap: .8rem; align-items: flex-end; }
.form-row label { flex: 1; }
.form-row label:has(> div) { flex: none; }
input[type="date"], input[type="datetime-local"] { min-width: 0; }

.check-line {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    font-size: .92rem;
}
.check-line input { width: auto; }

.switch-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 600;
}
.switch-label input { width: auto; }

.section-title { font-size: 1rem; margin-top: .5rem; }

/* ---------------------------------------------------------
   Búsqueda / barras
   --------------------------------------------------------- */
.search-bar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.search-bar label { display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .88rem; }
.search-bar input { width: auto; }

/* ---------------------------------------------------------
   Flash / alerts
   --------------------------------------------------------- */
.flash {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: .8rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    border: 1px solid transparent;
}
.flash-success { background: rgba(22, 163, 74, .12); border-color: rgba(22, 163, 74, .35); color: #14532d; }
.flash-error   { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .35); color: #7f1d1d; }
.flash-warning { background: rgba(217, 119, 6, .15); border-color: rgba(217, 119, 6, .4); color: #78350f; }
.flash-info    { background: rgba(2, 132, 199, .12); border-color: rgba(2, 132, 199, .35); color: #0c4a6e; }
.flash-close { border: 0; background: transparent; font-size: 1.15rem; cursor: pointer; color: inherit; }

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; }
.alert-warning { background: rgba(217, 119, 6, .15); border: 1px solid rgba(217, 119, 6, .4); }
.alert-info { background: rgba(2, 132, 199, .12); border: 1px solid rgba(2, 132, 199, .35); }

/* ---------------------------------------------------------
   KPIs
   --------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.card.kpi { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; margin-bottom: 0; }
.kpi-icon { font-size: 1.6rem; }
.kpi-label { margin: 0; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { margin: .1rem 0 0; font-size: 1.35rem; font-weight: 700; }
.kpi-value small { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------
   Tablas
   --------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: .6rem .6rem; border-bottom: 1px solid rgba(100, 116, 139, .25); }
.table td { padding: .6rem; border-bottom: 1px solid rgba(100, 116, 139, .12); }
.table tr:last-child td { border-bottom: 0; }
.table-total td { border-top: 2px solid rgba(79, 70, 229, .35); background: rgba(79, 70, 229, .05); }

.rank-table td { padding: .45rem .5rem; }
.rank-pos { font-weight: 800; color: var(--brand); width: 2rem; }
.row-me { background: rgba(79, 70, 229, .10); }

.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pagination a {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(79, 70, 229, .35);
    color: var(--brand);
    font-weight: 600;
}
.pagination a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------------------------------------------------------
   Calorías y macros
   --------------------------------------------------------- */
.cal-summary { display: flex; flex-direction: column; gap: .5rem; }
.cal-item { display: flex; align-items: center; gap: .6rem; font-size: .92rem; }
.cal-item span:nth-child(2) { flex: 1; color: var(--muted); }
.cal-item strong { font-size: 1rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-purple { background: var(--brand-2); }
.dot-blue { background: var(--info); }
.dot-orange { background: var(--warning); }
.dot-red { background: var(--danger); }

.macro-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(100, 116, 139, .15); margin: .8rem 0 .4rem; }
.macro-bar span { transition: width .3s; }
.macro-legend { display: flex; gap: 1rem; font-size: .85rem; flex-wrap: wrap; }

/* ---------------------------------------------------------
   Comidas
   --------------------------------------------------------- */
.meal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.meal-card h2 { font-size: .95rem; color: var(--brand); }
.meal-entry { margin-bottom: .8rem; padding-bottom: .6rem; border-bottom: 1px dashed rgba(100, 116, 139, .25); }
.meal-entry:last-child { border-bottom: 0; }
.meal-macros { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-top: .3rem; }
.meal-photo { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--glass-brd); }
.photo-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.photo-upload { display: flex; flex-direction: column; gap: .4rem; font-weight: 600; font-size: .9rem; }
.photo-upload input[type="file"] { font-size: .85rem; }
.photo-preview-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.photo-preview-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

.food-results { margin-top: .5rem; display: flex; flex-direction: column; gap: .3rem; max-height: 340px; overflow-y: auto; }
.food-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .5rem .7rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(100, 116, 139, .25);
    background: rgba(255, 255, 255, .55);
    cursor: pointer;
    transition: background .15s;
}
.food-result:hover { background: rgba(79, 70, 229, .08); }
.food-result .muted { font-size: .78rem; }

/* Recetas */
.recipe-card h2 { font-size: 1rem; }
.recipe-ingredients { border-top: 1px dashed rgba(100, 116, 139, .3); padding-top: .4rem; }
.ingredient-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}
.ingredient-row .food-search { flex: 1; }
.qty-label { flex: 0 0 90px; display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }
.ingredient-remove { flex: none; padding: .4rem .7rem; }
.recipe-steps { white-space: pre-line; line-height: 1.6; }

/* ---------------------------------------------------------
   Progreso
   --------------------------------------------------------- */
.progress-track {
    height: 14px;
    background: rgba(100, 116, 139, .18);
    border-radius: 999px;
    overflow: hidden;
    margin: .6rem 0;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    border-radius: 999px;
    transition: width .5s ease;
}
.progress-label { margin: .3rem 0 0; font-size: .9rem; }
.progress-wrap { margin-top: .8rem; }

/* ---------------------------------------------------------
   Usuarios / listas
   --------------------------------------------------------- */
.user-list { display: flex; flex-direction: column; }
.user-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .6rem .4rem;
    border-bottom: 1px solid rgba(100, 116, 139, .12);
}
.user-row:last-child { border-bottom: 0; }
.user-row:hover { background: rgba(79, 70, 229, .05); text-decoration: none; border-radius: var(--radius-sm); }
.user-row .btn-row { margin-left: auto; }
.compare-link { justify-content: space-between; }
.challenge-progress { flex: 1; max-width: 320px; }

/* ---------------------------------------------------------
   Chips
   --------------------------------------------------------- */
.chip {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    background: rgba(100, 116, 139, .15);
    color: var(--muted);
    white-space: nowrap;
}
.chip-red { background: rgba(220, 38, 38, .12); color: #b91c1c; }
.chip-blue { background: rgba(79, 70, 229, .12); color: var(--brand); }
.chip-green { background: rgba(22, 163, 74, .12); color: var(--success); }
.chip-gold { background: rgba(217, 119, 6, .15); color: #b45309; }
.chip-grey { background: rgba(100, 116, 139, .15); color: var(--muted); }

/* ---------------------------------------------------------
   Chat
   --------------------------------------------------------- */
.chat-card { display: flex; flex-direction: column; height: 70vh; }
.chat-log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .5rem 0;
}
.bubble { max-width: 72%; padding: .55rem .8rem; border-radius: 14px; font-size: .93rem; }
.bubble p { margin: 0 0 .2rem; }
.bubble .muted { font-size: .72rem; }
.bubble-mine { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.bubble-mine .muted { color: rgba(255, 255, 255, .75); }
.bubble-theirs { align-self: flex-start; background: rgba(100, 116, 139, .18); border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: .5rem; margin-top: .6rem; }

/* ---------------------------------------------------------
   Feed / muro
   --------------------------------------------------------- */
.feed-list { display: flex; flex-direction: column; gap: 1rem; }
.feed-post { padding: 1rem; }
.feed-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.feed-head .avatar-link { gap: .6rem; }
.feed-text { margin: .3rem 0 .6rem; }
.feed-actions { display: flex; gap: 1rem; align-items: center; }
.like-btn { transition: background .15s; }
.like-btn.liked { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .4); color: #b91c1c; }
.feed-comments { margin-top: .5rem; }
.comment { font-size: .88rem; padding: .25rem 0; }
.feed-comment-form { display: flex; gap: .5rem; margin-top: .6rem; }
.feed-item { padding: .4rem 0; border-bottom: 1px dashed rgba(100, 116, 139, .2); }
.feed-item:last-child { border-bottom: 0; }
.post-list { display: flex; flex-direction: column; }

/* ---------------------------------------------------------
   Notificaciones
   --------------------------------------------------------- */
.notif-row { align-items: flex-start; }
.notif-unread { background: rgba(79, 70, 229, .06); border-radius: var(--radius-sm); }
.notif-dot { font-size: .9rem; }

/* ---------------------------------------------------------
   Insignias
   --------------------------------------------------------- */
.badge-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.badge-chip {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(79, 70, 229, .15), rgba(124, 58, 237, .15));
    border: 1px solid rgba(79, 70, 229, .3);
}

/* Ayuda: insignias, XP y niveles */
.xp-sources { list-style: none; padding: 0; display: grid; gap: .5rem; }
.xp-sources li { padding: .35rem .6rem; border-radius: 10px; background: rgba(79, 70, 229, .06); }
.row-active td { background: rgba(79, 70, 229, .08); font-weight: 600; }
.badge-help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.badge-help-item {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .9rem; border-radius: 14px;
    border: 1px solid rgba(79, 70, 229, .25); background: linear-gradient(135deg, rgba(79, 70, 229, .06), rgba(124, 58, 237, .06));
}
.badge-help-item.badge-locked { opacity: .62; filter: saturate(.6); border-color: rgba(100, 116, 139, .25); }
.badge-help-icon { font-size: 1.8rem; }
.badge-help-item h3 { margin: 0 0 .2rem; font-size: 1rem; }
.badge-help-item p { margin: .15rem 0; font-size: .88rem; }
.badge-how { font-size: .85rem !important; }
.badge-reward { font-size: .82rem !important; color: var(--accent, #4f46e5); font-weight: 600; }

/* ---------------------------------------------------------
   Perfil
   --------------------------------------------------------- */
.profile-dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.profile-dl dt { color: var(--muted); font-weight: 600; font-size: .9rem; }
.profile-dl dd { margin: 0; }

/* ---------------------------------------------------------
   Auth
   --------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff, #dbeafe 55%, #ccfbf1);
}
.auth-shell { width: 100%; max-width: 420px; padding: 1.5rem; }
.auth-brand { display: block; text-align: center; margin-bottom: 1.4rem; }
.auth-brand img { width: 70px; height: 70px; border-radius: 20px; box-shadow: var(--card-shadow); }
.auth-brand h1 { margin-top: .7rem; font-size: 1.5rem; }
.auth-brand p { color: var(--muted); margin: 0; }
.auth-card { padding: 1.6rem; }
.auth-links { margin-top: .5rem; text-align: center; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: .92rem; }
.auth-lang { text-align: center; margin-top: 1.2rem; color: var(--muted); font-size: .85rem; }
.auth-lang a { color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------
   Modal
   --------------------------------------------------------- */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(4px);
    z-index: 100;
}
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 560px);
    max-height: 85vh;
    overflow-y: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    padding: 1.5rem;
    z-index: 110;
}
.modal-close {
    position: absolute;
    top: .6rem;
    right: .8rem;
    border: 0;
    background: transparent;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--muted);
}

/* ---------------------------------------------------------
   Dashboard hero / acciones rápidas
   --------------------------------------------------------- */
.dash-hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.dash-sub { color: var(--muted); margin: 0; }
.quick-actions { display: flex; gap: .5rem; }
.milestone-list { margin: 0; padding-left: 1.1rem; }
.milestone-list li { margin-bottom: .3rem; }

/* AJAX feedback */
.ajax-msg { font-size: .86rem; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .hamburger { display: block; }
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--glass-bg);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--glass-brd);
        padding: .4rem .65rem;
        display: none;
        max-height: calc(100vh - 64px);
        max-height: calc(100dvh - 64px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .main-nav.open { display: flex; }
    .main-nav a { padding: .55rem .7rem; }
    .nav-drop { position: static; }
    .nav-drop-btn { width: 100%; text-align: left; }
    .nav-drop-menu {
        position: static;
        box-shadow: none;
        border: 0;
        padding: 0 0 .2rem .7rem;
        min-width: 0;
    }
    .header-inner { flex-wrap: wrap; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; align-items: stretch; }
    .chat-card { height: 62vh; }
    .bubble { max-width: 88%; }
}

/* Tablas -> tarjetas en móvil (clase opt-in .data-to-cards) */
@media (max-width: 640px) {
    .table-wrap.data-to-cards { overflow: visible; }
    .data-to-cards .data-table thead { display: none; }
    .data-to-cards .data-table,
    .data-to-cards .data-table tbody,
    .data-to-cards .data-table tr,
    .data-to-cards .data-table td { display: block; width: 100%; }
    .data-to-cards .data-table tr {
        margin-bottom: .8rem;
        padding: .55rem .2rem;
        border: 1px solid rgba(100, 116, 139, .2);
        border-radius: var(--radius-sm);
        background: rgba(255, 255, 255, .55);
    }
    .data-to-cards .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        border-bottom: 0;
        padding: .42rem .55rem;
    }
    .data-to-cards .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .76rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        flex-shrink: 0;
    }
    .data-to-cards .data-table td.actions-cell::before { content: none; }
    .data-to-cards .data-table td.actions-cell .row-actions { width: 100%; justify-content: flex-end; }
    .data-to-cards .data-table td.muted-note { justify-content: flex-start; flex-wrap: wrap; gap: .3rem 1rem; }
    .data-to-cards .data-table td.muted-note::before { min-width: 80px; }
}

/* Objetivos táctiles cómodos (≥44px) en pantallas táctiles */
@media (hover: none) and (pointer: coarse) {
    .main-nav a { padding: .9rem .75rem; min-height: 48px; display: flex; align-items: center; }
    .icon-btn, .logout-link, .hamburger { min-width: 46px; min-height: 46px; padding: .5rem .6rem; display: inline-flex; align-items: center; justify-content: center; }
    .btn { padding: .72rem 1.1rem; }
    .btn-sm { padding: .55rem .8rem; min-height: 40px; }
    .search-bar input, .stack-form input, .stack-form select, .stack-form textarea { padding: .7rem .75rem; }
}

/* Menú desplegable móvil: compacto y sin desbordar la pantalla */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    .main-nav { padding-bottom: .6rem; }
    .main-nav a { padding: .6rem .7rem; min-height: 42px; }
}

@media (max-width: 320px) {
    .app-main { padding: .9rem .6rem 2rem; }
    .brand-name { display: none; }
    .card { padding: 1rem; }
    .meal-photo { width: 64px; height: 64px; }
}

@media (min-width: 1440px) {
    .app-main, .header-inner { max-width: 1320px; }
}
/* =========================================================
   Móvil coarse: dropdown compacto que quepa en pantalla
   (se define al final para ganar a las reglas coarse/touch)
   ========================================================= */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    .main-nav { padding: .3rem .5rem; }
    .main-nav a { padding: .5rem .6rem; min-height: 40px; font-size: .95rem; }
    .main-nav a svg, .main-nav a img, .main-nav a .avatar-ph, .main-nav a .avatar-sm { width: 20px; height: 20px; min-height: 0; }
    .main-nav { max-height: calc(100dvh - 58px); }
}

/* Icono menú móvil (libro) — comparte estilos del bloque base de arriba */
.hamburger { padding: .4rem; }

/* =========================================================
   Calendario de comidas (views/meals/list.php)
   ========================================================= */
.calendar { margin-bottom: 1.25rem; }
.cal-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .5rem; margin-bottom: .85rem;
}
.cal-head h2 { margin: 0; font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-wd {
    text-align: center; font-size: .72rem; font-weight: 700;
    letter-spacing: .04em; color: var(--muted); text-transform: uppercase; padding: .2rem 0;
}
.cal-day {
    position: relative; aspect-ratio: 1 / 1; display: flex; align-items: center;
    justify-content: center; border-radius: 10px; font-weight: 700; font-size: .95rem;
    text-decoration: none; color: inherit; border: 1px solid rgba(0,0,0,.05);
    transition: transform .1s ease, box-shadow .1s ease;
}
.cal-day:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.cal-day--empty { background: transparent; border: none; pointer-events: none; }
.cal-num { line-height: 1; }
.cal-ex { position: absolute; bottom: 1px; right: 2px; font-size: .6rem; line-height: 1; }
.cal-day--none { background: #fecaca; color: #991b1b; }
.cal-day--low  { background: #bbf7d0; color: #166534; }
.cal-day--mid  { background: #4ade80; color: #064e3b; }
.cal-day--full { background: #16a34a; color: #ffffff; }
.cal-day--today { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal-day--selected { box-shadow: 0 0 0 3px var(--brand); }
.cal-legend {
    display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
    margin-top: .9rem; font-size: .76rem; color: var(--muted);
}
.cal-key {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .6rem; border-radius: 999px; font-weight: 600;
}
.cal-key--ex { background: rgba(148,163,184,.18); }

body.dark .cal-day { border-color: rgba(255,255,255,.08); }
body.dark .cal-day--none { background: #7f1d1d; color: #fecaca; }
body.dark .cal-day--low  { background: #14532d; color: #bbf7d0; }
body.dark .cal-day--mid  { background: #166534; color: #dcfce7; }
body.dark .cal-day--full { background: #16a34a; color: #ffffff; }
