/* Диабет – хранителна система: обща рамка (ляво меню) и начало */

@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url("../fonts/manrope-cyrillic-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ink: #1c2622;
    --muted: #5e6763;
    --line: #e9eeea;
    --bg: #f7f9f7;
    --card: #fff;
    --green: #2f6f3e;
    --green-mid: #4f8c50;
    --green-bright: #43a047;
    --green-soft: #e8f2e6;
    --green-soft-2: #f1f7ef;
    --side-top: #1a3d34;
    --side-bottom: #13332c;
    --kcal: #ef5a24;
    --carbs: #d4a03c;
    --protein: #e04a2f;
    --fat: #f0a21c;
    --radius: 18px;
    --shadow: 0 1px 2px rgba(20, 45, 35, .04), 0 8px 24px rgba(20, 45, 35, .06);
    --sidebar: 272px;
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 500 15px/1.5 var(--font);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    /* стандартните кирилски букви, не българските варианти на шрифта (д, т, л) */
    font-feature-settings: "locl" 0;
}

h1, h2, h3, h4, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
.icon { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.18em; }
i.icon { width: auto; height: auto; }

:focus-visible { outline: 3px solid rgba(67, 160, 71, .45); outline-offset: 2px; }

/* ——— Рамка ——— */

.app { min-height: 100vh; }

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 28px 12px;
    color: #eaf3ee;
    background:
        url("../img/sidebar-leaves.webp") left bottom / 100% auto no-repeat,
        linear-gradient(180deg, var(--side-top), var(--side-bottom) 75%);
    overflow-y: auto;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 34px;
}

.app-brand img { width: 56px; height: 56px; }
.app-brand strong { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.app-brand small { display: block; font-size: .92rem; font-weight: 500; opacity: .9; white-space: nowrap; }

.app-nav { display: grid; gap: 6px; }

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 54px;
    padding: 0 18px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #f2f7f4;
    transition: background-color .15s ease;
}

.app-nav-link .icon { font-size: 1.45rem; width: 1.45rem; height: 1.45rem; }
.app-nav-link:hover { background: rgba(255, 255, 255, .07); }
.app-nav-link.is-active { background: var(--green-mid); color: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.app-nav-link.is-soon { cursor: default; }

.app-main {
    margin-left: var(--sidebar);
    padding: 24px 28px 40px 36px;
    max-width: calc(1320px + var(--sidebar));
}

.app-topbar {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.app-heading { flex: 1; min-width: 0; }
.app-heading h1 { font-size: clamp(1.8rem, 2.6vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.app-heading p { margin-top: 4px; max-width: 560px; font-size: 1.15rem; color: var(--muted); }
.wave { display: inline-block; transform-origin: 70% 70%; }

.app-topbar-actions { display: flex; align-items: center; gap: 18px; }

.app-icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    font-size: 1.35rem;
    box-shadow: var(--shadow);
}

.app-icon-btn.has-dot::after {
    content: "";
    position: absolute;
    top: 12px;
    right: 13px;
    width: 9px;
    height: 9px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #e53935;
}

.app-avatar {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 50%;
    background: var(--side-top);
    color: #fff;
    font-size: 1.7rem;
}

.app-mobilebar, .app-sidebar-close { display: none; }
.app-backdrop { display: none; }

/* ——— Общи ——— */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.btn-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: var(--green-soft);
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s ease;
}

.btn-soft:hover { background: #dcebd9; }
.btn-soft .bi { color: var(--green); font-size: 1.1rem; }
.btn-block { width: 100%; }

.title-icon { color: var(--green-bright); font-size: 1.6rem; }

/* ——— Начало ——— */

.dash {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 24px;
    align-items: start;
}

.dash-main, .dash-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; min-width: 0; }

.hero {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 198px;
    padding: 28px 48px;
    border-radius: 22px;
    overflow: hidden;
    background: linear-gradient(100deg, #eef5ea 0%, #e6f0df 45%, #dfeadb 100%);
}

.hero-list { position: relative; z-index: 1; display: grid; gap: 14px; font-size: 1.15rem; font-weight: 600; }
.hero-list li { display: flex; align-items: center; gap: 14px; }
.hero-list .bi { color: var(--green-bright); font-size: 1.6rem; filter: drop-shadow(0 2px 4px rgba(67, 160, 71, .25)); }

.hero-image {
    position: absolute;
    inset: 0 0 0 auto;
    width: 46%;
    height: 100%;
    object-fit: cover;
    object-position: left center;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%);
    mask-image: linear-gradient(90deg, transparent, #000 18%);
}

.goals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.goal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 18px 20px;
}

.goal-icon { font-size: 1.6rem; width: 1.6rem; height: 1.6rem; margin-bottom: 8px; }
.goal-kcal .goal-icon { color: var(--kcal); }
.goal-carbs .goal-icon { color: var(--carbs); }
.goal-protein .goal-icon { color: var(--protein); }
.goal-fat .goal-icon { color: var(--fat); }
.goal-label { color: #3a4440; font-weight: 600; }
.goal-value { font-size: 1.45rem; font-weight: 800; white-space: nowrap; letter-spacing: -.01em; }

.ring {
    --p: 0;
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(var(--green-bright) calc(var(--p) * 1%), #e5efe2 0);
}

.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff; }
.ring span { position: relative; font-size: .95rem; font-weight: 700; }

/* седмично меню */

.menu { padding: 22px 18px 18px; }

.menu-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; margin-bottom: 18px; }
.menu-head h2, .side-card h2 { display: flex; align-items: center; gap: 12px; font-size: 1.45rem; font-weight: 800; letter-spacing: -.01em; }
.menu-head h2 { flex: 1; }

.week-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-weight: 600;
}

.week-nav a { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; }
.week-nav a:hover { background: var(--green-soft-2); }
.week-nav span { padding: 0 8px; white-space: nowrap; }

.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }

.day {
    display: grid;
    gap: 2px;
    padding: 10px 4px;
    border: 0;
    border-radius: 10px;
    background: #f2f4f2;
    text-align: center;
    transition: background-color .15s ease;
}

.day strong { font-size: 1.05rem; font-weight: 700; }
.day span { font-size: .9rem; color: var(--muted); }
.day:hover { background: #e9efe8; }
.day.is-active { background: var(--green); color: #fff; }
.day.is-active span { color: rgba(255, 255, 255, .9); }

.day-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 18px 2px 20px; }
.day-head h3 { font-size: 1.3rem; font-weight: 500; }
.day-head h3 strong { font-weight: 800; }

.macros { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.macros li { display: flex; align-items: center; gap: 8px; }
.macros .icon { font-size: 1.25rem; width: 1.25rem; height: 1.25rem; }
.macros span { display: grid; line-height: 1.15; }
.macros b { font-weight: 700; }
.macros small { font-size: .75rem; color: var(--muted); }

.m-kcal .icon, .m-kcal .bi { color: var(--kcal); }
.m-carbs .icon { color: var(--carbs); }
.m-protein .icon { color: var(--protein); }
.m-fat .icon, .m-fat .bi { color: var(--fat); }

.meals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.meal {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    transition: transform .15s ease, box-shadow .15s ease;
}

.meal:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.meal-photo { position: relative; aspect-ratio: 3 / 2; background: var(--green-soft-2); }
.meal-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.meal-placeholder { display: grid; place-items: center; height: 100%; color: #9cc29a; }
.meal-placeholder .icon { width: 42px; height: 42px; }

.meal-type {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 3px 12px;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
}

.meal-fav {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    font-size: 1.05rem;
}

.meal-fav[aria-pressed="true"] { color: #e53950; }

.meal h4 { flex: 1; padding: 14px 14px 10px; font-size: 1rem; font-weight: 700; line-height: 1.3; }
.meal-facts { display: flex; gap: 18px; padding: 0 14px 16px; font-size: .92rem; font-weight: 600; }
.meal-facts span { display: inline-flex; align-items: center; gap: 6px; }

/* дясна колона */

.side-card { padding: 22px; }
.side-card h2 { margin-bottom: 16px; }

.badge-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--green-soft);
    color: var(--green);
    font-size: 1.35rem;
}

.profile { display: grid; grid-template-columns: auto 1fr; gap: 8px 22px; margin-bottom: 20px; font-size: 1.05rem; }
.profile dt { color: #3a4440; }
.profile dd { font-weight: 700; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin-bottom: 14px; border-radius: 10px; background: #edf1ed; }
.segmented button { min-height: 32px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; }
.segmented button.is-active { background: var(--green); color: #fff; }

.chart { width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: #edf0ed; stroke-width: 1; }
.chart-label { fill: #4b5551; font-size: 10px; font-family: var(--font); font-weight: 500; }
.chart-line { fill: none; stroke: var(--green-bright); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--green-bright); stroke: #fff; stroke-width: 1.5; }

.chart-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.chart-foot small { display: block; color: #3a4440; font-size: .95rem; }
.chart-foot strong { font-size: 1.35rem; font-weight: 800; white-space: nowrap; }

.pill { flex: none; padding: 6px 14px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: .85rem; font-weight: 700; text-align: center; }

.quick { display: grid; gap: 10px; }

.quick a {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 12px;
    background: var(--green-soft-2);
    font-weight: 600;
    transition: background-color .15s ease;
}

.quick a:hover { background: var(--green-soft); }
.quick .bi:first-child { color: var(--green); font-size: 1.2rem; }
.quick .bi:last-child { margin-left: auto; }

/* ——— По-малки екрани ——— */

@media (max-width: 1400px) {
    .goal { flex-direction: column; align-items: flex-start; }
    .goal .ring { align-self: flex-end; margin-top: -40px; }
}

@media (max-width: 1240px) {
    .dash { grid-template-columns: minmax(0, 1fr); }
    .dash-side { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
    .goal { flex-direction: row; align-items: center; }
    .goal .ring { align-self: auto; margin-top: 0; }
}

@media (max-width: 1100px) {
    .meals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .goals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    /* менюто се плъзга отдясно */
    .app-sidebar { inset: 0 0 0 auto; width: min(300px, 86vw); padding-top: 22px; transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
    .app.sidebar-open .app-sidebar { transform: none; visibility: visible; transition: transform .25s ease; }
    .app.sidebar-open { overflow: hidden; }
    .app.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(10, 25, 20, .45); }
    .app-sidebar-close { display: grid; place-items: center; position: absolute; top: 16px; right: 14px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.1rem; }
    .app-sidebar .app-brand { padding-right: 52px; padding-bottom: 26px; }
    .app-nav-link { min-height: 52px; }

    .app-main { margin-left: 0; padding: 0 16px 32px; }

    /* мобилна лента: профил и камбана вляво, лого, меню вдясно */
    .app-mobilebar {
        position: sticky;
        top: 0;
        z-index: 25;
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 8px;
        margin: 0 -16px 14px;
        padding: 10px 16px;
        padding-top: max(10px, env(safe-area-inset-top));
        background: rgba(247, 249, 247, .92);
        border-bottom: 1px solid rgba(233, 238, 234, .9);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }

    .app-mobilebar-account { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 10px; }
    .app-mobilebar-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
    .app-mobilebar-brand img { width: 34px; height: 34px; }
    .app-mobilebar .app-menu-btn { justify-self: end; }
    .app-mobilebar .app-icon-btn, .app-mobilebar .app-avatar { width: 44px; height: 44px; box-shadow: none; }
    .app-mobilebar .app-icon-btn { font-size: 1.25rem; }
    .app-mobilebar .app-icon-btn.has-dot::after { top: 9px; right: 10px; }
    .app-mobilebar .app-avatar { font-size: .95rem; }
    .app-mobilebar .app-account-menu { left: 0; right: auto; width: min(280px, calc(100vw - 32px)); }

    .app-topbar { margin-bottom: 18px; }
    .app-topbar-actions { display: none; }
    .app-heading h1 { font-size: 1.75rem; }
    .app-heading p { font-size: 1rem; }
    .app-heading:empty { display: none; }

    /* iPhone не увеличава страницата при поле с шрифт от 16 px нагоре */
    input:not([type="checkbox"], [type="radio"]), select, textarea { font-size: 16px !important; }
}

@media (max-width: 640px) {
    .hero { padding: 24px 22px; min-height: 0; }
    .hero-list { font-size: 1rem; }
    .hero-image { width: 55%; opacity: .45; }
    .goals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .goal { position: relative; padding: 16px; }
    .goal .ring { position: absolute; top: 12px; right: 12px; width: 46px; height: 46px; }
    .goal .ring::before { inset: 5px; }
    .goal .ring span { font-size: .75rem; }
    .goal-value { font-size: 1.2rem; }
    .days { display: flex; overflow-x: auto; scrollbar-width: none; }
    .day { flex: 0 0 64px; }
    .menu-head .btn-soft { width: 100%; }
    .meals { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
    .wave { animation: wave 2.4s ease-in-out 1s 2; }
}

@keyframes wave {
    0%, 60%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
}

/* ——— Бутони, полета, съобщения ——— */

.btn-primary, .btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 22px;
    border: 0;
    border-radius: 12px;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color .15s ease;
}

.btn-primary { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(47, 111, 62, .25); }
.btn-primary:hover { background: #275f34; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef2ee; color: var(--ink); }

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
}

.alert .bi { font-size: 1.2rem; }
.alert-success { background: var(--green-soft); color: #1f5a2c; }
.alert-danger { background: #fdecea; color: #a12a1c; }

.pill.is-warning { background: #fff1dc; color: #9a5b00; }

.form { display: grid; gap: 18px; }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field label, .field legend { display: flex; align-items: center; gap: 8px; padding: 0; font-weight: 700; }
.field legend { margin-bottom: 6px; }
.field-hint { font-size: .85rem; color: var(--muted); }
.field-error { font-size: .875rem; font-weight: 600; color: #c0392b; }

.field input:not([type="checkbox"], [type="radio"]) {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid #d9e0da;
    border-radius: 12px;
    background: #fff;
    font: inherit;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus { outline: 0; border-color: var(--green-bright); box-shadow: 0 0 0 4px rgba(67, 160, 71, .15); }
.field input:disabled { background: #f3f5f3; color: var(--muted); }
.field input.is-invalid { border-color: #e06656; }

.input-icon { position: relative; }
.input-icon > .bi { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #8a948f; pointer-events: none; }
.field .input-icon input, .input-icon.field input { padding-left: 42px; }
.input-action { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: #6b7570; }
.input-action:hover { background: #f0f3f0; }
.field .input-icon:has(.input-action) input { padding-right: 48px; }

.input-unit { display: flex; align-items: stretch; }
.field .input-unit input { flex: 1 1 0; border-radius: 12px 0 0 12px; min-width: 0; }
.input-unit span { flex: none; display: grid; place-items: center; min-width: 64px; padding: 0 12px; border: 1px solid #d9e0da; border-left: 0; border-radius: 0 12px 12px 0; background: #f4f7f4; color: var(--muted); font-weight: 600; white-space: nowrap; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid #d9e0da; border-radius: 999px; background: #fff; font-weight: 600; cursor: pointer; transition: all .15s ease; }
.chip span:hover { border-color: var(--green-bright); }
.chip input:checked + span { border-color: var(--green); background: var(--green); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid rgba(67, 160, 71, .45); outline-offset: 2px; }

/* ——— Меню на профила ——— */

.app-account { position: relative; }
.app-account summary { list-style: none; cursor: pointer; font-size: 1.05rem; font-weight: 800; letter-spacing: .02em; }
.app-account summary::-webkit-details-marker { display: none; }

.app-account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 50;
    width: 260px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(20, 45, 35, .16);
}

.app-account-head { display: grid; padding: 10px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.app-account-head small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.app-account-menu a, .app-account-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-weight: 600;
    text-align: left;
}

.app-account-menu a:hover, .app-account-menu button:hover { background: var(--green-soft-2); }
.app-account-menu .bi { color: var(--green); font-size: 1.1rem; }
.app-account-menu form { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--line); }

/* ——— Моите настройки ——— */

.settings { max-width: 1100px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.settings-grid .side-card { display: grid; gap: 18px; }
.settings-grid .side-card h2 { margin-bottom: 0; }
.settings-goals { grid-column: 1 / -1; }
.goal-inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.goal-inputs label .icon { font-size: 1.2rem; width: 1.2rem; height: 1.2rem; }
.range-inputs { display: flex; align-items: center; gap: 10px; }
.range-inputs .input-unit { flex: 1; min-width: 0; }
.range-inputs .input-unit span { min-width: 0; padding: 0 10px; font-size: .85rem; }
.range-sep { color: var(--muted); font-weight: 600; }
.settings-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

@media (max-width: 1100px) {
    .goal-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .settings-grid { grid-template-columns: minmax(0, 1fr); }
    .settings-actions { position: sticky; bottom: 0; margin: 22px -16px -32px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: rgba(247, 249, 247, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
    .settings-actions .btn-primary { flex: 1; }
}

/* ——— Вход ——— */

.auth { background: #fff; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }

.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 40px 48px;
    overflow: hidden;
    color: #eaf3ee;
    background: linear-gradient(160deg, var(--side-top), var(--side-bottom) 70%);
}

.auth-aside::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 340px;
    height: 400px;
    background: url("../img/sidebar-leaves.webp") left bottom / 100% auto no-repeat;
    -webkit-mask-image: radial-gradient(130% 110% at 0 100%, #000 55%, transparent 80%);
    mask-image: radial-gradient(130% 110% at 0 100%, #000 55%, transparent 80%);
    opacity: .9;
}

.auth-aside .app-brand { padding: 0; }
.auth-aside-body { position: relative; z-index: 1; margin: auto 0; max-width: 460px; }
.auth-aside h2 { margin-bottom: 26px; font-size: clamp(1.8rem, 2.6vw, 2.4rem); font-weight: 800; line-height: 1.2; letter-spacing: -.02em; color: #fff; }
.auth-aside .hero-list .bi { color: #8fd16a; }

.auth-aside-image {
    position: absolute;
    right: -40px;
    bottom: -30px;
    width: 300px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
    opacity: .95;
}

.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.auth-card .muted { margin: 6px 0 28px; color: var(--muted); }
.auth-card .btn-primary { margin-top: 4px; min-height: 52px; font-size: 1.05rem; }
.auth-brand-mobile { display: none; padding: 0 0 28px; color: var(--ink); }

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-form { place-items: start center; padding-top: 56px; }
    .auth-brand-mobile { display: flex; }
}

/* ——— Общи допълнения ——— */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.alert-warning { background: #fff4de; color: #8a5300; }
.alert span { flex: 1; }
.alert-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.back-link { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; font-weight: 700; color: var(--muted); }
.back-link:hover { color: var(--ink); }
.muted-note { display: block; font-size: .875rem; color: var(--muted); }
a.muted-note { margin-top: 14px; text-decoration: underline; text-underline-offset: 3px; }

.field select {
    width: 100%;
    min-height: 48px;
    padding: 0 36px 0 14px;
    border: 1px solid #d9e0da;
    border-radius: 12px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235e6763' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") right 14px center / 12px no-repeat;
    font: inherit;
    color: var(--ink);
    appearance: none;
}

.field select:focus { outline: 0; border-color: var(--green-bright); box-shadow: 0 0 0 4px rgba(67, 160, 71, .15); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 48px 24px; text-align: center; }
.empty > .icon, .empty > .bi { width: 48px; height: 48px; font-size: 48px; color: #9cc29a; }
.empty h2 { font-size: 1.3rem; font-weight: 800; }
.empty p { max-width: 420px; color: var(--muted); }
.empty .btn-primary { margin-top: 8px; }

.bar { height: 8px; margin: 6px 0 4px; border-radius: 999px; background: #edf1ed; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--green-bright); transition: width .3s ease; }

.gl { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.gl-low { background: #e3f3e1; color: #24692f; }
.gl-medium { background: #fff1d6; color: #8a5a00; }
.gl-high { background: #fde4df; color: #a5321f; }

.badge-soft { display: inline-flex; padding: 4px 12px; border-radius: 8px; background: var(--green); color: #fff; font-size: .8rem; font-weight: 700; }
.badge-tag { padding: 3px 10px; border-radius: 999px; background: #f0f3f0; color: var(--muted); font-size: .8rem; font-weight: 600; }
.badge-tag:hover { background: var(--green-soft); color: var(--green); }

/* ——— Каталог с рецепти ——— */

.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-bottom: 18px; padding: 18px; }
.filters-search { display: flex; gap: 10px; }
.filters-search .field { flex: 1; }
.filters-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.chip-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid #dfe5e0;
    border-radius: 999px;
    background: #fff;
    font-weight: 600;
    white-space: nowrap;
    transition: all .15s ease;
}

.chip-link:hover { border-color: var(--green-bright); }
.chip-link.is-active { border-color: var(--green); background: var(--green); color: #fff; }

.select-inline { position: relative; display: inline-flex; align-items: center; }
.select-inline > .icon, .select-inline > .bi { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.select-inline select {
    min-height: 38px;
    padding: 0 32px 0 36px;
    border: 1px solid #dfe5e0;
    border-radius: 999px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235e6763' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") right 12px center / 10px no-repeat;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    appearance: none;
    cursor: pointer;
}

.filters-sort { margin-left: auto; }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; color: var(--muted); }
.results-head strong { color: var(--ink); }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.recipe-card { position: relative; }
.recipe-card h3 { flex: 1; padding: 14px 14px 10px; font-size: 1.02rem; font-weight: 700; line-height: 1.3; }
.recipe-card .stretched::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.recipe-card .meal-fav { z-index: 2; }
.recipe-card .meal-facts { flex-wrap: wrap; gap: 6px 14px; }
.recipe-card .gl { position: absolute; top: 10px; left: 10px; z-index: 2; box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }

.meal-fav button {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
}

.meal-fav [aria-pressed="true"], .btn-fav [aria-pressed="true"] { color: #e53950; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; font-weight: 600; color: var(--muted); }
.pager a, .pager .is-disabled { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); }
.pager .is-disabled { opacity: .4; }

/* ——— Страница на рецепта ——— */

.recipe-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); overflow: hidden; margin-bottom: 22px; }
.recipe-hero-photo { position: relative; min-height: 300px; background: var(--green-soft-2); }
.recipe-hero-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.recipe-hero-body { display: flex; flex-direction: column; gap: 14px; padding: 28px 30px; }
.recipe-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.recipe-hero h1 { font-size: clamp(1.7rem, 2.4vw, 2.3rem); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.recipe-summary { font-size: 1.08rem; color: var(--muted); }

.recipe-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 4px 0 0; }
.recipe-facts div { padding: 12px; border-radius: 12px; background: var(--green-soft-2); }
.recipe-facts dt { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.recipe-facts dt .bi { color: var(--green); }
.recipe-facts dd { margin-top: 2px; font-weight: 800; }
.difficulty { display: flex; align-items: center; gap: 4px; }
.difficulty span { width: 8px; height: 8px; border-radius: 50%; background: #d5ddd6; }
.difficulty span.is-on { background: var(--green-bright); }
.difficulty span:last-of-type { margin-right: 4px; }

.recipe-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.btn-fav button { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 1px solid #e3e8e4; border-radius: 12px; background: #fff; font-weight: 700; }
.btn-fav button:hover { border-color: #f1a7b3; }

.recipe-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.recipe-main, .recipe-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; min-width: 0; }
.recipe-side { position: sticky; top: 20px; }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.section-head h2 { margin-bottom: 0 !important; }

.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 999px; background: #f0f4f0; font-weight: 700; }
.stepper button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.stepper button:hover { color: var(--green); }
.stepper output { min-width: 26px; text-align: center; font-size: 1.1rem; }
.stepper span { margin-right: 8px; color: var(--muted); }

.ingredients-form { margin-top: 12px; }
.ingredients-group { margin: 18px 0 6px; font-size: .85rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--green); }
.ingredients { display: grid; margin-bottom: 18px; }
.ingredients li + li { border-top: 1px dashed var(--line); }
.ingredients label { display: grid; grid-template-columns: auto 104px minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 10px 2px; cursor: pointer; }
.ingredients input { width: 18px; height: 18px; margin: 0; align-self: center; accent-color: var(--green); }
.ingredient-amount { font-weight: 800; white-space: nowrap; }
.ingredient-name small { color: var(--muted); font-size: .9rem; }
.ingredients input:checked ~ span { color: #9aa29e; text-decoration: line-through; }

.steps { display: grid; gap: 18px; padding: 0; margin: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; }
.step-number { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; }
.step-body { display: grid; gap: 8px; justify-items: start; padding-top: 5px; line-height: 1.65; }

.timer { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid #d6e6d4; border-radius: 999px; background: var(--green-soft-2); font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.timer:hover { background: var(--green-soft); }
.timer.is-running { background: var(--green); border-color: var(--green); color: #fff; }
.timer.is-done { background: #fde4df; border-color: #f5b5a8; color: #a5321f; animation: pulse 1s ease-in-out 3; }

@keyframes pulse { 50% { transform: scale(1.06); } }

.video { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose { line-height: 1.7; color: #33403a; }

.nutrition { display: grid; gap: 14px; }
.nutrition-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nutrition-row span { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.nutrition small { color: var(--muted); font-size: .8rem; }
.nutrition .m-kcal .bar span { background: var(--kcal); }
.nutrition .m-carbs .bar span { background: var(--carbs); }
.nutrition .m-protein .bar span { background: var(--protein); }
.nutrition .m-fat .bar span { background: var(--fat); }
.nutrition-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.nutrition-extra div { padding: 10px 12px; border-radius: 10px; background: #f4f7f4; }
.nutrition-extra dt { font-size: .8rem; color: var(--muted); }
.nutrition-extra dd { font-weight: 800; }

.tip-card { display: grid; gap: 10px; background: linear-gradient(160deg, #f4faf1, #fff); }
.tip-card h2 { margin-bottom: 4px !important; }
.tip-card p { line-height: 1.6; }
.tip-card .gl { margin-right: 4px; }
.source-link { display: inline-flex; align-items: center; gap: 6px; padding-left: 6px; font-weight: 600; color: var(--muted); }
.source-link:hover { color: var(--ink); }

.related { margin-top: 34px; }
.related h2 { margin-bottom: 14px; font-size: 1.35rem; font-weight: 800; }

/* ——— Списък за пазар ——— */

.shopping { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.shopping-main, .shopping-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.shopping-side { position: sticky; top: 20px; }
.shopping-progress { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; }
.shopping-progress > div:first-child { flex: 1; min-width: 200px; color: var(--muted); }
.shopping-progress strong { color: var(--ink); }
.shopping-tools { display: flex; gap: 8px; }

.shopping-section { padding: 18px 20px 8px; }
.shopping-section h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 1.1rem; font-weight: 800; }
.shopping-section h2 .icon { color: var(--green); font-size: 1.2rem; width: 1.2rem; height: 1.2rem; }
.shopping-section .count { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: #f0f3f0; font-size: .8rem; color: var(--muted); }

.shopping-items li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 0; }
.shopping-items li + li { border-top: 1px dashed var(--line); }
.shopping-item-body { display: grid; min-width: 0; }
.shopping-item-name { font-weight: 700; }
.shopping-item-body small { overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.shopping-item-amount { font-weight: 800; white-space: nowrap; }

.check-btn { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 2px solid #c8d3ca; border-radius: 8px; background: #fff; color: transparent; transition: all .15s ease; }
.check-btn:hover { border-color: var(--green-bright); }
.is-checked .check-btn { border-color: var(--green-bright); background: var(--green-bright); color: #fff; }
.is-checked .shopping-item-name, .is-checked .shopping-item-amount { color: #9aa29e; text-decoration: line-through; }

.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #9aa29e; }
.icon-btn:hover { background: #fdecea; color: #c0392b; }
.shopping-clear { display: grid; gap: 8px; }
.btn-soft:disabled { opacity: .5; cursor: default; }

@media (max-width: 1240px) {
    .recipe-layout, .shopping { grid-template-columns: minmax(0, 1fr); }
    .recipe-side, .shopping-side { position: static; }
}

@media (max-width: 900px) {
    .recipe-hero { grid-template-columns: minmax(0, 1fr); }
    .recipe-hero-photo { min-height: 0; aspect-ratio: 16 / 10; }
    .recipe-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .filters-search { flex-direction: column; }
    .filters-sort { margin-left: 0; }
    .filters-row.filters-more { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
    nav.chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .recipe-hero-body { padding: 20px; }
    .ingredients label { grid-template-columns: auto 84px minmax(0, 1fr); gap: 10px; }
    .recipe-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ——— Печат: рецептата и списъкът без менюта и бутони ——— */

@media print {
    body { background: #fff; font-size: 12pt; }
    .app-sidebar, .app-mobilebar, .app-topbar-actions, .app-menu-btn, .app-backdrop, .back-link, .recipe-actions, .stepper button, .ingredients-form .btn-primary,
    .ingredients input, .timer, #video, .related, .muted-note, .shopping-side, .shopping-tools, [data-shopping-delete], .alert, .filters { display: none !important; }
    .app-main { margin: 0; padding: 0; max-width: none; }
    .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
    .recipe-layout, .shopping { grid-template-columns: 1fr; }
    .recipe-hero { grid-template-columns: 220px 1fr; }
    .recipe-hero-photo { min-height: 160px; }
    .recipe-side { position: static; }
    .ingredients label { grid-template-columns: 90px 1fr; }
}

/* ——— Седмично меню (истинско) и списък от менюто ——— */

.menu-head form { margin: 0; }
.day.is-empty strong { opacity: .55; }
.day.is-active.is-empty strong { opacity: 1; }

.meal-add {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    min-height: 220px;
    border: 2px dashed #d5e2d4;
    border-radius: 14px;
    background: var(--green-soft-2);
    color: var(--muted);
    text-align: center;
    transition: border-color .15s ease, background-color .15s ease;
}

.meal-add:hover { border-color: var(--green-bright); background: var(--green-soft); color: var(--ink); }
.meal-add .bi { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 50%; background: #fff; color: var(--green); font-size: 1.3rem; }
.meal-add strong { color: var(--ink); }

.meal-fav button .bi-x-lg { font-size: .9rem; }
.meal-fav:has(.bi-x-lg) button:hover { color: #c0392b; }

.day-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.menu-empty { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: #f4f7f4; color: var(--muted); }
.menu-empty .bi { color: var(--green); }
.menu-empty a { color: var(--green); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.from-menu .section-head { margin-bottom: 4px; }
.from-menu .section-head h2 { margin: 0; }

.day-picks { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: 14px 0 6px; }
.day-pick { position: relative; cursor: pointer; }
.day-pick input { position: absolute; opacity: 0; pointer-events: none; }
.day-pick span { display: grid; gap: 1px; padding: 10px 4px; border: 2px solid transparent; border-radius: 12px; background: #f2f4f2; text-align: center; transition: all .15s ease; }
.day-pick strong { font-size: 1.05rem; }
.day-pick small { color: var(--muted); }
.day-pick em { margin-top: 4px; font-size: .75rem; font-style: normal; font-weight: 700; color: var(--green); }
.day-pick:hover span { background: #e9efe8; }
.day-pick input:checked + span { border-color: var(--green); background: var(--green); color: #fff; }
.day-pick input:checked + span small, .day-pick input:checked + span em { color: rgba(255, 255, 255, .9); }
.day-pick input:focus-visible + span { outline: 3px solid rgba(67, 160, 71, .45); outline-offset: 2px; }
.day-pick.is-empty { cursor: default; }
.day-pick.is-empty span { opacity: .5; }
.day-pick.is-empty em { color: var(--muted); }

.from-menu-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 14px; }
.from-menu-actions .btn-primary { margin-left: auto; }

@media (max-width: 640px) {
    .day-picks { display: flex; overflow-x: auto; scrollbar-width: none; }
    .day-pick { flex: 0 0 72px; }
    .from-menu-actions .btn-primary { width: 100%; margin-left: 0; }
    .meal-add { min-height: 120px; }
}

@media print {
    .from-menu, .day-actions, .menu-empty { display: none !important; }
}

/* ——— Проследяване ——— */

:root {
    --r-very-low: #b3261e;
    --r-low: #ef6c57;
    --r-in: #43a047;
    --r-high: #f2b33d;
    --r-very-high: #e07b12;
}

.tracking-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.tracking-links { display: flex; gap: 8px; }
.tracking { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 22px; align-items: start; }
.tracking-main, .tracking-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.tracking-side { position: sticky; top: 20px; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: #3a4440; }
.kpi-value { margin-top: 4px; font-size: 1.7rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; white-space: nowrap; }
.kpi-value small { font-size: .8rem; font-weight: 600; color: var(--muted); }
.kpi-note { margin-top: 4px; font-size: .8rem; color: var(--muted); }
.kpi.is-alert { border-color: #f5c1b8; background: #fff7f5; }
.kpi.is-alert .kpi-value { color: var(--r-very-low); }
.hint { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #e8ede9; font-size: .7rem; font-weight: 800; color: var(--muted); cursor: help; }

.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.trend.is-good { color: #2e7d32; }
.trend.is-bad { color: #c0392b; }

.ranges-bar { display: flex; height: 22px; overflow: hidden; border-radius: 999px; background: #edf1ed; }
.ranges-bar span { flex-grow: 0; flex-shrink: 0; min-width: 4px; }
.r-very-low { background: var(--r-very-low); }
.r-low { background: var(--r-low); }
.r-in { background: var(--r-in); }
.r-high { background: var(--r-high); }
.r-very-high { background: var(--r-very-high); }
.ranges-legend { display: grid; gap: 8px; margin: 16px 0 10px; }
.ranges-legend li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 52px; align-items: center; gap: 10px; }
.ranges-legend .dot, .chart-legend .dot { width: 12px; height: 12px; border-radius: 4px; }
.ranges-name small { margin-left: 4px; color: var(--muted); }
.ranges-goal { font-size: .8rem; color: var(--muted); }
.ranges-legend strong { text-align: right; }

.glucose-chart { width: 100%; height: auto; overflow: visible; }
.chart-band { fill: rgba(67, 160, 71, .09); }
.chart-line.thin { stroke-width: 1.5; stroke: #9ccc9e; }
.chart-median { fill: none; stroke: var(--side-top); stroke-width: 2.5; stroke-dasharray: 6 4; stroke-linejoin: round; }
.chart-target { stroke: var(--green); stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart-label.big { font-size: 22px; }
circle.dot-ok, circle.dot-below { fill: var(--r-in); stroke: #fff; stroke-width: 1.5; }
circle.dot-high { fill: var(--r-high); stroke: #fff; stroke-width: 1.5; }
circle.dot-very_high { fill: var(--r-very-high); stroke: #fff; stroke-width: 1.5; }
circle.dot-low { fill: var(--r-low); stroke: #fff; stroke-width: 1.5; }
circle.dot-very_low { fill: var(--r-very-low); stroke: #fff; stroke-width: 1.5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: .82rem; color: var(--muted); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.band-swatch { width: 18px; height: 12px; border-radius: 3px; background: rgba(67, 160, 71, .18); }

.glucose-value { font-weight: 800; white-space: nowrap; }
.glucose-value small { font-size: .75rem; font-weight: 600; color: var(--muted); }
.status-ok { color: #2e7d32; }
.status-below { color: #8a6d00; }
.status-high { color: #b26a00; }
.status-very_high { color: #c25000; }
.status-low, .status-very_low { color: var(--r-very-low); }

.by-context li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 10px 0; }
.by-context li + li { border-top: 1px dashed var(--line); }
.by-context-name { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.by-context-name .bi, .log-context .bi { color: var(--green); }

.log-day { margin: 16px 0 4px; font-size: .8rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.log-day:first-of-type { margin-top: 0; }
.log li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 9px 0; }
.log li + li { border-top: 1px dashed var(--line); }
.log time { font-weight: 700; font-variant-numeric: tabular-nums; }
.log-context { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.log-context small { flex-basis: 100%; padding-left: 26px; color: var(--muted); font-size: .8rem; }
.empty.compact { padding: 26px 12px; }
.empty.compact .bi { font-size: 36px; width: 36px; height: 36px; }

.input-big input { min-height: 58px !important; font-size: 1.5rem !important; font-weight: 800; }
.context-chips { gap: 6px; }
.context-chips .chip span { gap: 6px; min-height: 36px; padding: 0 12px; font-size: .88rem; }
.optional { font-weight: 500; color: var(--muted); font-size: .85rem; }
.targets-note { margin-top: 12px; }
.targets-note a { text-decoration: underline; text-underline-offset: 3px; }

.weight-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.weight-summary div { display: grid; padding: 12px; border-radius: 12px; background: var(--green-soft-2); }
.weight-summary strong { font-size: 1.5rem; font-weight: 800; }
.weight-summary small { font-size: .85rem; color: var(--muted); }
.weight-notes { margin: 10px 0 6px; font-size: .9rem; color: var(--muted); }
.weight-notes a { text-decoration: underline; }
.weight-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* изядено в менюто */
.goal-eaten { margin-top: 2px; font-size: .78rem; font-weight: 600; color: var(--green); }
.eaten-form { position: relative; z-index: 2; padding: 0 14px 12px; }
.eaten-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border: 1px solid #dbe5da; border-radius: 999px; background: #fff; font-size: .82rem; font-weight: 700; color: var(--muted); }
.eaten-btn:hover { border-color: var(--green-bright); color: var(--green); }
.eaten-btn.is-on { border-color: var(--green-bright); background: var(--green-soft); color: var(--green); }
.meal.is-eaten .meal-photo { opacity: .75; }
.side-card h2 a:hover { color: var(--green); }

/* отчет за лекаря */
.report-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.report { display: grid; gap: 26px; max-width: 980px; padding: 32px 36px; }
.report h2 { margin-bottom: 12px; font-size: 1.05rem; font-weight: 800; }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 2px solid var(--ink); }
.report-head h1 { font-size: 1.6rem; font-weight: 800; }
.report-head p { color: var(--muted); }
.report-head dl { display: grid; gap: 4px; margin: 0; font-size: .9rem; }
.report-head dl div { display: flex; gap: 8px; }
.report-head dt { min-width: 76px; color: var(--muted); }
.report-head dd { font-weight: 600; }
.report-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.report-kpis div { display: grid; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.report-kpis span { font-size: .78rem; color: var(--muted); }
.report-kpis strong { font-size: 1.35rem; font-weight: 800; }
.report-kpis small { font-size: .75rem; color: var(--muted); }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.report-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.report-table th { padding: 6px 8px; border-bottom: 1px solid var(--ink); font-size: .78rem; text-align: left; color: var(--muted); }
.report-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.report-dl { display: grid; gap: 6px; margin: 0; }
.report-dl div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.report-dl dt { color: var(--muted); }
.report-dl dd { font-weight: 700; }
.report-note { padding-top: 14px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }

@media (max-width: 1400px) {
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1240px) {
    .tracking { grid-template-columns: minmax(0, 1fr); }
    .tracking-side { position: static; order: -1; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}

@media (max-width: 900px) {
    .report-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .report-grid { grid-template-columns: minmax(0, 1fr); }
    .report { padding: 22px 18px; }
}

@media (max-width: 640px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-value { font-size: 1.4rem; }
    .tracking-side { grid-template-columns: minmax(0, 1fr); }
    .ranges-legend li { grid-template-columns: auto minmax(0, 1fr) 44px; }
    .ranges-goal { display: none; }
    .log li { grid-template-columns: 46px minmax(0, 1fr) auto auto; gap: 8px; }
}

@media print {
    .report-tools, .tracking-toolbar, .tracking-side, .eaten-form { display: none !important; }
    .report { max-width: none; padding: 0; border: 0; box-shadow: none; gap: 14px; break-inside: auto; }
    .app-topbar { display: none !important; }
    .report-head { padding-bottom: 10px; }
    .report-kpis div { padding: 8px; }
    .report .glucose-chart { max-height: 170px; }
    .report-kpis { grid-template-columns: repeat(6, 1fr); }
    .report-grid { grid-template-columns: 1fr 1fr; }
    .report section { break-inside: avoid; }
    .glucose-chart { max-height: 200px; }
}

@media (max-width: 640px) {
    .chips.context-chips { flex-wrap: wrap; overflow: visible; }
    .context-chips .chip span { white-space: nowrap; }
}


/* ——— Телефон и таблет: бутони за пръст (поне 40 px) – последни, за да важат над всичко ——— */

@media (max-width: 991.98px) {
    .week-nav { height: 46px; }
    .week-nav a { width: 40px; height: 40px; }
    .chip-link, .select-inline select { min-height: 42px; }
    .meal-fav { width: 40px; height: 40px; }
    .stepper button { width: 40px; height: 40px; }
    .icon-btn { width: 40px; height: 40px; }
    .eaten-btn { min-height: 38px; padding: 0 14px; }
    .segmented button { min-height: 40px; }
    .chip span, .context-chips .chip span { min-height: 40px; }
    .check { min-height: 40px; }
    .timer { min-height: 40px; }
    .side-card h2 a { display: inline-flex; align-items: center; min-height: 40px; }
    nav.chips::-webkit-scrollbar, .days::-webkit-scrollbar, .day-picks::-webkit-scrollbar, .filters-more::-webkit-scrollbar { display: none; }
}

/* ——— Телефон: компактни карти, подредба на Проследяване, четими графики ——— */

@media (max-width: 991.98px) {
    /* Проследяване: първо новото измерване, после показателите и графиките, теглото накрая */
    .tracking-side { display: contents; }
    #new-reading { order: -1; }
    #weight { order: 1; }
}

@media (max-width: 640px) {
    /* ястия и рецепти като редове: снимка вляво, текст вдясно */
    .meals, .recipe-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }

    .meal {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        column-gap: 12px;
        align-content: start;
        padding: 10px;
        min-height: 116px;
    }

    .meal:hover { transform: none; }
    .meal > :not(.meal-photo, .meal-fav) { grid-column: 2; }
    .meal-photo { grid-row: 1 / span 4; align-self: start; aspect-ratio: 1; border-radius: 10px; overflow: hidden; }
    .meal-placeholder .icon { width: 30px; height: 30px; }
    .meal-type { left: 4px; bottom: 4px; padding: 2px 7px; border-radius: 6px; font-size: .66rem; }
    .meal h3, .meal h4 { padding: 2px 44px 6px 0; font-size: .98rem; }
    .meal-facts { gap: 4px 12px; padding: 0; font-size: .84rem; }
    .meal-fav { top: 6px; right: 6px; }
    .eaten-form { order: 2; padding: 8px 0 0; }
    .meal-facts { order: 1; }
    .recipe-card .gl { position: static; justify-self: start; margin-top: 8px; box-shadow: none; }

    .meal-add { display: flex; align-items: center; justify-content: flex-start; gap: 14px; min-height: 72px; padding: 12px 16px; text-align: left; }
    .meal-add .bi { flex: none; margin: 0; }
    .meal-add strong { margin-right: auto; }

    .macros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
    .day-actions .btn-soft, .day-actions { width: 100%; }

    /* търсачка в един ред */
    .filters { padding: 14px; }
    .filters-search { flex-direction: row; }
    .filters-search .btn-primary { padding: 0 16px; }

    /* бутоните под рецептата – 2 × 2 */
    .recipe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .recipe-actions > *, .recipe-actions .btn-fav button { width: 100%; justify-content: center; }
    .recipe-actions .btn-soft { padding: 0 10px; }

    /* графиките: по-едри надписи по осите (SVG-то е два пъти по-тясно от екрана на компютър) */
    .glucose-chart .chart-label { font-size: 19px; }
    .glucose-chart circle { r: 6; }
    .chart-legend { font-size: .78rem; }

    .kpi { padding: 14px; }
    .tracking-toolbar { gap: 10px; }
    .tracking-links { width: 100%; }
    .tracking-links .btn-soft { flex: 1; }
    .report-tools .btn-primary { width: 100%; }
    .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-head dl div { flex-direction: column; gap: 0; }

    .shopping-progress { padding: 14px; }
    .shopping-tools { width: 100%; }
    .shopping-tools .btn-soft { flex: 1; }
    .shopping-items li { gap: 10px; }
    .from-menu-actions { gap: 10px; }
    .from-menu-actions .btn-ghost { padding: 0 8px; }
}

@media (max-width: 380px) {
    .meal { grid-template-columns: 84px minmax(0, 1fr); }
    .app-mobilebar-brand span { display: none; }
    .recipe-facts { gap: 8px; }
    .goal-value { font-size: 1.1rem; }
}

@media (max-width: 640px) {
    .log-context { display: block; line-height: 1.35; }
    .log-context .bi { margin-right: 6px; }
    .log-context small { display: block; padding-left: 0; }
}
