:root {
            /* Fallback цвета для случаев, когда Telegram переменные недоступны */
            --fallback-bg-color: #f8f9fa;
            --fallback-text-color: #212529;
            --fallback-secondary-bg-color: #ffffff;
            --fallback-header-bg-color: #343a40;
            --fallback-hint-color: #6c757d;
            --fallback-button-color: #0d6efd;
            --fallback-button-text-color: #ffffff;
            --fallback-link-color: #0d6efd;
            --fallback-section-bg-color: #ffffff;
        }
        


        body {
            background-color: var(--tg-theme-bg-color, var(--fallback-bg-color));
            color: var(--tg-theme-text-color, var(--fallback-text-color));
            font-family: 'Rubik', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        
        .om-header {
            background: var(--tg-theme-header-bg-color, linear-gradient(148deg, #000000 0%, #193f48 50%, #000000 100%));
            color: var(--tg-theme-button-text-color, white);
            padding: 10px 0;
            margin-bottom: 15px;
            box-shadow: 0 5px 5px rgba(0, 0, 0, 0.2);
        }
        
        .om-logo {
            height: 50px;
            width: auto;
            filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
        }
        
        .om-title {
            margin-left: 15px;
            font-size: 24px;
            font-weight: 600;
            color: var(--tg-theme-button-text-color, white);
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }
        
        .main-content {
            padding: 0;
            min-height: calc(100vh - 120px);
            background-color: var(--tg-theme-bg-color, var(--fallback-bg-color));
        }
        
        .om-footer {
            background-color: var(--tg-theme-secondary-bg-color, #343a40);
            color: var(--tg-theme-hint-color, #adb5bd);
            padding: 20px 0;
            text-align: center;
            font-size: 14px;
        }
        
        .om-footer a {
            color: var(--tg-theme-link-color, #6c757d);
            text-decoration: none;
        }
        
        .om-footer a:hover {
            color: var(--tg-theme-text-color, #adb5bd);
        }
        
        /* Custom styles for compatibility */
        .status {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: bold;
            text-transform: uppercase;
        }
        
        /* Telegram theme aware components */
        .card {
            background-color: var(--tg-theme-section-bg-color, var(--fallback-section-bg-color));
            border-color: var(--tg-theme-section-separator-color, #dee2e6);
            color: var(--tg-theme-text-color, var(--fallback-text-color));
        }
        
        .btn-primary {
            background-color: var(--tg-theme-button-color, var(--fallback-button-color));
            border-color: var(--tg-theme-button-color, var(--fallback-button-color));
            color: var(--tg-theme-button-text-color, var(--fallback-button-text-color));
        }
        
        .btn-primary:hover {
            background-color: var(--tg-theme-button-color, var(--fallback-button-color));
            border-color: var(--tg-theme-button-color, var(--fallback-button-color));
            opacity: 0.9;
        }
        
        .text-muted {
            color: var(--tg-theme-hint-color, #6c757d) !important;
        }
        
        .bg-light {
            background-color: var(--tg-theme-secondary-bg-color, #f8f9fa) !important;
        }
        
        a {
            color: var(--tg-theme-link-color, var(--fallback-link-color));
        }
        
        a:hover {
            color: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, var(--fallback-link-color)));
        }
        
        .images-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .image-card {
            text-align: center;
        }
        
        .image-card img {
            max-width: 100%;
            height: 150px;
            object-fit: cover;
            border-radius: 6px;
            border: 2px solid var(--tg-theme-section-separator-color, #ddd);
        }
        
        .loading {
            display: none;
            text-align: center;
            padding: 20px;
        }


/* ========= ОБЩИЕ СТИЛИ ========= */
        .nutrition-dashboard, .weeks-dashboard {
            padding: 15px;
            max-width: 100%;
            margin: 0 auto;
        }

        .nutrition-dashboard .weeks-dashboard {
            padding: 0;
        }
        
 
        
        .chart-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 15px;
            color: #2c3e50;
        }
        
        .chart-canvas {
            max-height: 300px;
        }
        
        /* ========= СТИЛИ ДЛЯ ЦЕЛЕЙ ========= */
        .goals-section {
            background: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .goals-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 15px;
            margin-top: 15px;
        }
        
        .goal-card {
            background: #f8f9fa;
            border-radius: 8px;
            padding: 15px;
            border-left: 4px solid #007bff;
        }
        
        .goal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        
        .goal-title {
            font-weight: bold;
            color: #2c3e50;
            font-size: 14px;
        }
        
        .goal-percentage {
            font-weight: bold;
            font-size: 16px;
            padding: 4px 8px;
            border-radius: 4px;
        }
        
        .goal-achieved {
            background: #d4edda;
            color: #155724;
        }
        
        .goal-close {
            background: #fff3cd;
            color: #856404;
        }
        
        .goal-far {
            background: #f8d7da;
            color: #721c24;
        }
        
        .goal-values {
            font-size: 12px;
            color: #6c757d;
            margin-bottom: 10px;
        }
        
        .goal-recommendations {
            margin-top: 10px;
        }
        
        .recommendation-item {
            font-size: 12px;
            color: #495057;
            background: rgba(0, 123, 255, 0.1);
            padding: 6px 8px;
            border-radius: 4px;
            margin-bottom: 4px;
        }
        
        /* Цели для недель */
        .week-goals {
            margin-top: 15px;
            padding-top: 15px;
            border-top: 1px solid  #c8c8c8ff;
        }
        
        .week-goals-title {
            font-size: 13px;
            font-weight: bold;
            color: #495057;
            margin-bottom: 8px;
        }
        
        .week-goals-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        
        .week-goal-item {
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(0, 123, 255, 0.05);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
        }
        
        .week-goal-name {
            color: #495057;
        }
        
        .week-goal-percentage {
            font-weight: bold;
            font-size: 11px;
            padding: 2px 4px;
            border-radius: 3px;
        }

        /* Цели внутри карточек */
        .goals-in-card {
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid #c8c8c8ff;
        }
        
        .goals-header {
            font-size: 14px;
            font-weight: bold;
            color: #495057;
            margin-bottom: 12px;
        }
        
        .goals-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        
        .goal-item {
            background: rgba(0, 123, 255, 0.05);
            border-radius: 6px;
            padding: 12px;
            border-left: 3px solid #007bff;
        }
        
        .goal-item-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
        }
        
        .goal-item-title {
            font-size: 13px;
            font-weight: 600;
            color: #2c3e50;
        }
        
        .goal-item-percentage {
            font-size: 12px;
            font-weight: bold;
            padding: 3px 6px;
            border-radius: 10px;
            color: white;
        }
        
        .goal-item-percentage.goal-achieved {
            background: #28a745;
        }
        
        .goal-item-percentage.goal-close {
            background: #ffc107;
            color: #212529;
        }
        
        .goal-item-percentage.goal-far {
            background: #dc3545;
        }
        
        .goal-item-values {
            font-size: 12px;
            color: #6c757d;
            margin-bottom: 8px;
        }
        
        .goal-item-recommendations {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        
        .recommendation-text {
            font-size: 11px;
            color: #495057;
            background: rgba(255, 193, 7, 0.1);
            padding: 4px 6px;
            border-radius: 3px;
            border-left: 2px solid #ffc107;
        }

        /* Прогресс-бары для целей */
        .goal-progress {
            margin-top: 8px;
            margin-bottom: 8px;
        }
        
        .goal-progress-bar {
            width: 100%;
            height: 8px;
            background-color: #e9ecef;
            border-radius: 4px;
            overflow: hidden;
        }
        
        .goal-progress-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.3s ease;
        }
        
        .goal-progress-fill.goal-achieved {
            background-color: #28a745;
        }
        
        .goal-progress-fill.goal-close {
            background-color: #ffc107;
        }
        
        .goal-progress-fill.goal-far {
            background-color: #dc3545;
        }

        /* ========= СТИЛИ ДЛЯ СТАТИСТИКИ (index.view.php) ========= */
        .nutrition-dashboard {
            padding: 0;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 15px;
            margin-bottom: 25px;
        }
        
        .stat-card {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 15px;
            text-align: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        
        .stat-value {
            font-size: 24px;
            font-weight: bold;
            color: #2c3e50;
            margin-bottom: 5px;
        }
        
        .stat-label {
            font-size: 12px;
            color: #7f8c8d;
            text-transform: uppercase;
        }
        
        .trend {
            font-size: 14px;
            margin-top: 5px;
        }
        
        .trend.positive { color: #e74c3c; }
        .trend.negative { color: #27ae60; }
        .trend.neutral { color: #95a5a6; }
        
        /* ========= СТИЛИ ДЛЯ БЛЮД ========= */
        .dishes-list {
            background: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        
        .dish-item {
            
            border-top: 1px solid #c8c8c8ff;
            
            padding: 10px 0;
        }
        
        .dish-item:last-child
        {
            padding-bottom: 0;
        }
        
        
        .dish-title {
            /* font-weight: bold; */
            margin-bottom: 5px;
            font-size: 14px;
            line-height: 1.2em;

        }
        
        .dish-actions {
            float: right;
            margin-left: 10px;
            display: flex;
            align-items: center;
        }
        
        .dish-edit-btn {
            color: #95a5a6;
            font-size: 18px;
            cursor: pointer;
            padding: 0 5px;
            text-decoration: none;
            transition: color 0.2s;
        }
        
        .dish-edit-btn:hover {
            color: #3498db;
        }
        
        .dish-repeat-btn {
            background: white;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            
        }
        
        .dish-repeat-btn:hover {
            background: #2980b9;
        }
        
        .dish-meta {
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            font-size: 14px;
            color: #7f8c8d;
            flex-direction: column;
        }



        .dish-macro {
            display: flex; align-items: center; gap: 10px;
        }

        .dish-meta .dish-cal {
            font-weight: bold; color: #2c3e50; min-width: 80px; white-space: nowrap; 
            
        }
        
        .dish-actions {
            display: flex; gap: 2px; align-items: center;
        }

        .dish-nutrients {
            display: flex;
            gap: 15px;
        }
        
        .nutrient {
            font-size: 12px;
        }
        
        /* ========= СТИЛИ ДЛЯ КАРТОЧЕК ========= */
        .today-card, .week-card, .chart-container {
            background: white;
            border-radius: 8px;
            padding: 8px;
            margin: 0 0;
            margin-bottom: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        
        .chart-container {
            overflow: hidden;
        }

        /* ========= СТИЛИ ДЛЯ ГРАФИКОВ И ЭЛЕМЕНТОВ ========= */
        .chart-header-flex {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .echarts-container {
            width: 100%;
            height: 300px;
        }

        .charts-toggle-wrapper {
            text-align: center;
            margin-bottom: 20px;
        }

        .charts-toggle-link {
            text-decoration: none;
            border-bottom: 1px dashed;
            color: #3498db;
        }
        
        .today-subtitle {
            font-size: 14px;
            color: #7f8c8d;
            font-weight: normal;
        }

        .no-data-placeholder {
            text-align: center;
            color: #95a5a6;
            padding: 40px;
        }
        
        .current-week-label {
            color: #27ae60;
            font-size: 14px;
        }
        
        .week-card {
            margin-bottom: 15px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        
        .today-header, .week-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid  #c8c8c8ff;
        }
        
        .today-title, .week-title {
            font-size: 18px;
            font-weight: bold;
            color: #2c3e50;
        }
        
        .today-date, .week-dates {
            font-size: 14px;
            color: #7f8c8d;
        }
        
        /* ========= СТИЛИ ДЛЯ НАПОМИНАНИЙ ========= */
        .reminder-card {
            background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
            border-left: 4px solid #f39c12;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 20px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        
        .reminder-card.warning {
            background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
            border-left-color: #e74c3c;
        }
        
        .reminder-card.info {
            background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
            border-left-color: #17a2b8;
        }
        
        .reminder-content {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .reminder-icon {
            font-size: 20px;
        }
        
        .reminder-text {
            font-size: 14px;
            font-weight: 500;
            color: #2c3e50;
        }
        
        /* ========= СТИЛИ ДЛЯ КАРТОЧЕК ПИТАНИЯ (card.php) ========= */
        .nutrition-layout {
            display: flex;
            gap: 20px;
            align-items: center;
        }
        
        /* Круглая карточка калорий */
        .calories-card-circle {
            flex: 0 0 auto;
            width: 90px;
            height: 90px;
            border-radius: 50%;
            background: white;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        }

        /* Кольцевой индикатор */
        .progress-ring {
            position: relative;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* Внутренний круг (белый фон) */
        .progress-ring::before {
            content: "";
            position: absolute;
            inset: 8px; /* Толщина кольца */
            border-radius: 50%;
            background: white;
            z-index: 1;
        }

        /* Контент внутри кольца */
        .progress-content {
            position: relative;
            z-index: 2;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .calories-value-circle {
            font-size: 22px;
            font-weight: bold;
            color: #2c3e50;
            line-height: 1.2;
        }

        .calories-label-circle {
            font-size: 10px;
            color: #7f8c8d;
            text-transform: uppercase;
            font-weight: 500;
        }

        /* Стили для целей в квадратных блоках */
        .goals-grid-inline {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid  #c8c8c8ff;
        }

        .goal-square-card {
            background: #fff;
            border-radius: 8px;
            padding: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.05);
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100px;
            text-align: center;
            border: 1px solid #f0f0f0;
        }

        .goal-square-title {
            font-size: 11px;
            font-weight: 600;
            color: #2c3e50;
            margin-bottom: 10px;
            height: 28px; /* Фиксированная высота для двух строк */
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1.2;
        }

        .goal-ring-container {
            width: 60px;
            height: 60px;
            margin-bottom: 5px;
        }
        
        .goal-ring-container .progress-ring::before {
            inset: 5px; /* Тоньше кольцо для маленьких целей */
        }

        .goal-value-circle {
            font-size: 14px;
            font-weight: bold;
            color: #2c3e50;
        }

        .goal-unit-circle {
            font-size: 10px;
            color: #95a5a6;
            margin-top: 2px;
        }

        /* Цвета для колец */
        .ring-color-primary { --ring-color: #78a347ff; }
        .ring-color-success { --ring-color: #3ac81aff; }
        .ring-color-warning { --ring-color: #f1c40f; }
        .ring-color-danger { --ring-color: #e74c3c; }
        .ring-color-neutral { --ring-color: #ecf0f1; }

        /* Тень для перевыполнения (без макс значения) */
        .ring-shadow-glow {
            box-shadow: 0 0 15px var(--ring-color);
            border-radius: 50%;
        }

        .macros-container {
            flex: 1;
        }
        
        .macros-bar-tall {
            display: flex;
            height: 60px;
            border-radius: 15px;
            overflow: hidden;
            margin-bottom: 15px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }
        
        .macros-bar-compact {
            display: flex;
            height: 25px;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            min-width: 90px;
        }
        
        .macro-protein-tall, .macro-fat-tall, .macro-carb-tall, .macro-fiber-tall {
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            min-width: 20px;
        }
        
        .macro-protein-compact, .macro-fat-compact, .macro-carb-compact, .macro-fiber-compact {
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            min-width: 10px;
        }
        
        /* Единые цвета макронутриентов */
        .macro-protein {
            background-color: #4cb076ff;
        }
        
        .macro-fat {
            background-color: #d9b501ff;
        }
        
        .macro-carb {
            background-color: #a22733ff;
        }
        
        .macro-fiber {
            background-color: #bba076;
        }
        
        .macro-text {
            color: white;
            font-weight: bold;
            font-size: 14px;
            text-shadow: 0 1px 2px rgba(0,0,0,0.3);
        }
        
        .macro-text-compact {
            color: white;
            font-weight: bold;
            font-size: 10px;
            text-shadow: 0 1px 2px rgba(0,0,0,0.3);
        }
        
        .macros-legend-new {
            display: flex;
            justify-content: space-around;
            font-size: 12px;
        }
        
        .legend-item-new {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .legend-color-new {
            width: 12px;
            height: 12px;
            border-radius: 3px;
        }
        
        /* Цвета для легенды наследуются от общих классов .macro-* */
        
        
        /* ========= АДАПТИВНЫЕ СТИЛИ ========= */
        @media (max-width: 410px) {

            .echarts-container {
                width: 100%;
                height: 180px;
            }


            .container {
                padding: 5px;
            }

            .nutrition-dashboard, .weeks-dashboard {
                padding: 0;
            }
            
            .dish-meta {
                flex-direction: column;
            }
            
            .dish-nutrients {
                justify-content: space-between;
            }
            
            .today-header, .week-header {
                flex-direction: column;
                text-align: center;
                gap: 5px;
            }
            
            .goals-grid-inline {
                justify-content: center;
            }
            
            /* Адаптивные стили для карточек питания */
            .nutrition-layout {
                /* flex-direction: column; */
                gap: 15px;
            }
            
            .calories-card {
                flex: none;
                width: 100%;
            }
            
            .macros-container {
                width: 100%;
            }
            
            .macros-bar-tall {
                height: 50px;
            }
            
            .macros-bar-compact {
                height: 20px;
            }
            
            .macro-text {
                font-size: 12px;
            }
            
            .macro-text-compact {
                font-size: 8px;
            }
        }
        
        /* ========= СТИЛИ ДЛЯ ДНЕВНЫХ БЛЮД ========= */
        .macros-summary {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 15px;
        }
        
        .macros-calories {
            font-weight: bold;
            font-size: 18px;
            color: #2c3e50;
            min-width: 100px;
        }
        
        .macros-bar-wrapper {
            flex: 1;
            max-width: 100%;
        }
        
        .day-dishes-list {
            margin-top: 15px;
        }
        
        .dish-time {
            color: #7f8c8d;
            font-weight: normal;
            font-size: 12px;
        }

        /* ========= СТИЛИ ДЛЯ ОПЦИОНАЛЬНЫХ ЦЕЛЕЙ ========= */
        .goals-wrapper {
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid #c8c8c8;
        }

        .main-goals-section {
            width: 100%;
        }
        
        /* Сброс отступов для сетки внутри секции */
        .main-goals-section .goals-grid-inline {
            margin-top: 0;
            border-top: none;
            padding-top: 0;
        }

        /* Карточка-контейнер для списка опциональных целей */
        .goal-square-card.optional-goals-card {
            width: auto;
            min-width: 160px;
            align-items: stretch;
            padding: 10px;
            height: auto;
        }

        .optional-goals-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
            width: 100%;
            margin-top: 5px;
        }

        .optional-goal-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 11px;
            padding: 4px 8px;
            border-radius: 6px;
            background: #f8f9fa;
            border: 1px solid #eee;
            transition: all 0.3s ease;
        }

        .optional-goal-row.achieved {
            background: #f0fff4;
            border-color: #d4edda;
            color: #155724;
        }

        .optional-goal-row.loading {
            /* Стили для строки во время загрузки (если она видна) */
            display: flex;
            opacity: 0.7;
        }

        /* Блокировка списка и показ общего лоадера */
        .optional-goals-card.loading .optional-goals-list {
            display: none;
        }
        
        .opt-block-loader {
            display: none;
            width: 20px;
            height: 20px;
            border: 2px solid #e0e0e0;
            border-top-color: #888;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: auto;
        }
        
        .optional-goals-card.loading .opt-block-loader {
            display: block;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        .opt-name {
            font-weight: 600;
            margin-right: 10px;
            text-align: left;
        }
        
        .opt-val {
            font-weight: bold;
            white-space: nowrap;
        }
        
        .opt-unit {
            font-size: 0.9em;
            opacity: 0.8;
            margin-left: 2px;
        }