/**
 * app.css — единая таблица стилей для всего веб-ЛК.
 * Подключается после layout.css. Содержит дизайн-систему и все компоненты.
 * Нет локальных стилей по страницам — единый каскад.
 */

/* ========== DESIGN SYSTEM ========== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --border-color: #e5e5ea;
    --error-color: #ff3b30;
    --success-color: #34c759;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    --ds-font-size-xs: 12px;
    --ds-font-size-sm: 13px;
    --ds-font-size-base: 14px;
    --ds-font-size-md: 16px;
    --ds-font-size-lg: 18px;
    --ds-font-size-xl: 22px;
    --ds-font-size-2xl: 24px;
    --ds-font-size-3xl: 28px;
    --ds-line-height: 1.5;
    --ds-font-weight-medium: 500;
    --ds-font-weight-semibold: 600;
    --ds-font-weight-bold: 700;
    --ds-spacing-xs: 4px;
    --ds-spacing-sm: 8px;
    --ds-spacing-md: 12px;
    --ds-spacing-lg: 16px;
    --ds-spacing-xl: 24px;
}

body {
    margin: 0;
    padding-top: var(--layout-content-padding-top, 0);
    padding-bottom: var(--layout-content-padding-bottom, 0);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    line-height: var(--ds-line-height);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
}

h2 {
    margin-top: 0;
    margin-bottom: var(--ds-spacing-md);
}

.title, h1.title {
    font-size: var(--ds-font-size-2xl);
    font-weight: var(--ds-font-weight-bold);
    margin: 0 0 var(--ds-spacing-sm) 0;
    color: var(--tg-theme-text-color);
}

.title-lg { font-size: var(--ds-font-size-3xl); }

.subtitle {
    font-size: var(--ds-font-size-md);
    color: var(--tg-theme-hint-color);
    margin: 0 0 var(--ds-spacing-xl) 0;
}

.widget-title,
.section-title {
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-semibold);
    color: var(--tg-theme-text-color);
    margin: 0 0 var(--ds-spacing-md) 0;
}

.section-title {
    color: var(--tg-theme-hint-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--ds-spacing-md);
}

.step-title {
    font-size: var(--ds-font-size-xl);
    font-weight: var(--ds-font-weight-semibold);
    margin-bottom: var(--ds-spacing-xl);
    color: var(--tg-theme-text-color);
}

.text, .text-body {
    font-size: var(--ds-font-size-md);
    color: var(--tg-theme-text-color);
    margin: 0 0 var(--ds-spacing-md) 0;
}

.text-sm { font-size: var(--ds-font-size-base); color: var(--tg-theme-text-color); }

.caption, .hint {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
}

.hint { display: block; margin-top: 6px; }

.label {
    font-size: 15px;
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-text-color);
}

.error-message {
    display: block;
    font-size: var(--ds-font-size-sm);
    color: var(--error-color);
    margin-top: 6px;
    min-height: 18px;
}

.btn {
    width: 100%;
    padding: 14px 24px;
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-semibold);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    text-align: center;
}

.btn-primary {
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background-color: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
}

.btn-secondary:hover { opacity: 0.9; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 6px 14px;
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
    border-radius: 8px;
    width: auto;
}

.section {
    background-color: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    padding: var(--ds-spacing-lg);
    margin-bottom: var(--ds-spacing-lg);
}

.form-group { margin-bottom: var(--ds-spacing-xl); }

.form-group label {
    display: block;
    font-size: 15px;
    font-weight: var(--ds-font-weight-medium);
    margin-bottom: var(--ds-spacing-sm);
    color: var(--tg-theme-text-color);
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    font-size: var(--ds-font-size-md);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group select {
    min-height: 48px;
    line-height: var(--ds-line-height);
    cursor: pointer;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--tg-theme-button-color);
    box-shadow: 0 0 0 3px rgba(36, 129, 204, 0.1);
}

.form-group input.error,
.form-group textarea.error {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ds-spacing-md);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: var(--ds-spacing-xs);
}

.info-item.wide { grid-column: 1 / -1; }

.info-label {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
}

.info-value {
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-text-color);
}

/* ========== PROFILE / SETTINGS ========== */

.container.content-with-tabbar {
    padding-bottom: calc(var(--layout-tabbar-height) + 24px);
}

.profile-header {
    padding: 24px 16px;
    text-align: center;
    background: linear-gradient(135deg, var(--tg-theme-button-color), #1a6cb3);
    color: var(--tg-theme-button-text-color);
}

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    overflow: hidden;
    position: relative;
}

.avatar-img { width: 100%; height: 100%; object-fit: cover; }

.avatar-icon { font-size: 40px; position: absolute; }

.profile-header .title { margin: 0; }

.profile-content {
    flex: 1;
    padding: 16px;
}

.goal-badge {
    display: inline-block;
    padding: 4px 12px;
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border-radius: 16px;
    font-size: 14px;
    width: fit-content;
}

.diet-restrictions {
    font-size: 15px;
    color: var(--tg-theme-text-color);
    line-height: 1.6;
}

.profile-footer {
    padding: 12px 16px;
    background-color: var(--tg-theme-bg-color);
    margin-top: 16px;
}

.profile-version {
    padding: 16px;
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    text-align: center;
}

.profile-error-banner {
    margin: 12px 16px;
    padding: 12px 16px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.profile-error-banner #profileErrorText {
    flex: 1;
    font-size: 14px;
    color: #856404;
}

/* ========== ONBOARDING / FORMS ========== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
}

.page-header .title {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.edit-close-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    background-color: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    cursor: pointer;
    box-shadow: 0 1px 4px var(--shadow);
    transition: opacity 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.edit-close-btn:hover { opacity: 0.9; }
.edit-close-btn:active { transform: scale(0.96); }
.edit-close-btn svg { display: block; }

.progress-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--tg-theme-secondary-bg-color);
    z-index: 1000;
}

.progress-fill {
    height: 100%;
    background-color: var(--tg-theme-button-color);
    transition: width 0.3s ease;
    width: 20%;
}

.form-wrapper .title { font-size: var(--ds-font-size-3xl); }

.form-wrapper {
    flex: 1;
    padding: 24px 16px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.form-step { display: none; animation: fadeIn 0.3s ease; }
.form-step.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.radio-label.error {
    border-color: var(--error-color);
    background-color: rgba(255, 59, 48, 0.05);
}

.form-group input[type="tel"][readonly] {
    background-color: var(--tg-theme-secondary-bg-color);
    cursor: not-allowed;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.radio-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.radio-group.vertical {
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    flex: 1;
    min-width: fit-content;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--tg-theme-bg-color);
    transition: all 0.2s;
}

.radio-group.vertical .radio-label {
    flex: none;
    width: 100%;
}

.radio-label:hover {
    border-color: var(--tg-theme-button-color);
    background-color: var(--tg-theme-secondary-bg-color);
}

.radio-label input[type="radio"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    accent-color: var(--tg-theme-button-color);
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--tg-theme-button-color);
    font-weight: 500;
}

.radio-group.vertical .radio-label span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.radio-group.horizontal .radio-label span { display: inline; }

.radio-label span strong {
    font-size: 15px;
    font-weight: 500;
}

.radio-label span small {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
}

.radio-label.large {
    padding: 16px;
    min-height: 80px;
    align-items: flex-start;
}

.radio-label.large span { flex: 1; }

.step-description {
    font-size: var(--ds-font-size-base);
    color: var(--tg-theme-hint-color);
    margin-bottom: var(--ds-spacing-xl);
}

.avatar-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--tg-theme-button-color);
}

.avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--tg-theme-secondary-bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    border: 3px solid var(--border-color);
}

.phone-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.phone-input-group input { flex: 1; }

.phone-success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background-color: var(--tg-theme-secondary-bg-color);
    border-radius: 8px;
    flex: 1;
    border: 1px solid var(--success-color);
}

.phone-success span:first-child {
    flex: 1;
    color: var(--tg-theme-text-color);
    font-size: 15px;
}

.phone-checkmark {
    color: var(--success-color);
    font-size: 18px;
    font-weight: bold;
}

.phone-input-group .btn-small {
    padding: 12px 16px;
    flex: 0 0 auto;
}

.btn-small.success {
    background-color: var(--success-color);
    color: white;
}

.benefits-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.benefit-item {
    padding: 16px;
    background-color: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    border-left: 4px solid var(--tg-theme-button-color);
}

.benefit-item.highlight {
    background-color: rgba(36, 129, 204, 0.1);
    border-left-color: var(--tg-theme-button-color);
    border-left-width: 6px;
}

.benefit-item strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--tg-theme-text-color);
}

.benefit-item p {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
    line-height: 1.5;
    margin: 0;
}

.measurement-guide {
    margin: 24px 0;
    text-align: center;
}

.measurement-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.summary {
    margin-top: 32px;
    padding: 16px;
    background-color: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
}

.summary h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

#summaryContent {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child { border-bottom: none; }

.summary-item .label {
    font-weight: 500;
    color: var(--tg-theme-hint-color);
}

.summary-item .value {
    font-weight: 500;
    color: var(--tg-theme-text-color);
}

.navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background-color: var(--tg-theme-bg-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    z-index: 100;
}

.navigation .btn { flex: 1; }

.page-body-measurements .navigation {
    position: static;
    bottom: auto;
    margin-top: 24px;
    padding: 16px 16px 12px;
    border-top: 1px solid var(--border-color);
}

/* ========== NUTRITION ========== */

.nutrition-dashboard {
    display: grid;
    gap: 20px;
    padding: 12px 0;
    width: 100%;
}

@media (max-width: 599px) {
    .nutrition-dashboard {
        grid-template-columns: 1fr;
        padding: 8px 0;
    }
}

@media (min-width: 600px) and (max-width: 1023px) {
    .nutrition-dashboard {
        grid-template-columns: 2fr 1fr;
        gap: 16px;
        padding: 12px 0;
    }
}

@media (min-width: 1024px) {
    .nutrition-dashboard {
        grid-template-columns: 2fr 1fr;
        gap: 20px;
        padding: 16px 0;
    }
}

.nutrition-widget-fullwidth {
    grid-column: 1 / -1;
}

/* --- Селектор профиля для тренера: «Мой профиль» + подопечные --- */
.nutrition-profile-selector-wrap {
    grid-column: 1 / -1;
    margin-bottom: 4px;
}

.nutrition-profile-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
}

.nutrition-profile-chip {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--tg-theme-button-color, #2481cc);
    background: var(--tg-theme-secondary-bg-color, #f4f4f5);
    color: var(--tg-theme-text-color, #000);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nutrition-profile-chip:hover {
    background: rgba(36, 129, 204, 0.1);
}

.nutrition-profile-chip.active {
    background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #fff);
    border-color: var(--tg-theme-button-color, #2481cc);
}

/* --- Виджет «Динамика питания»: заголовок + переключатель --- */
.nutrition-charts-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 24px;
}

.nutrition-charts-body {
    position: relative;
    min-height: 420px;
}

@media (max-width: 767px) {
    .nutrition-charts-body {
        min-height: 546px;
    }
}

.nutrition-charts-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.nutrition-charts-loading-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.nutrition-charts-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--tg-theme-button-color, #2481cc);
    border-radius: 50%;
    animation: nutrition-charts-spin 0.8s linear infinite;
}

@keyframes nutrition-charts-spin {
    to { transform: rotate(360deg); }
}

.nutrition-chart-skeleton-area {
    background: rgba(0, 0, 0, 0.03);
}

.nutrition-charts-header .nutrition-widget-title {
    margin: 0;
}

.nutrition-charts-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.nutrition-period-picker-wrap {
    position: relative;
}

.nutrition-period-picker-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 8px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color);
    font-size: var(--ds-font-size-sm);
    font-weight: 500;
    cursor: pointer;
}

.nutrition-period-picker {
    position: fixed;
    padding: 12px;
    background: var(--tg-theme-bg-color, #fff);
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.n-pp-title-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.n-pp-arrow {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 6px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.n-pp-arrow:hover:not(.is-disabled):not(:disabled) {
    border-color: var(--tg-theme-button-color, #2481cc);
}

.n-pp-arrow.is-disabled,
.n-pp-arrow:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.n-pp-calendars {
    display: flex;
    gap: 16px;
}

.n-pp-month {
    min-width: 140px;
}

.n-pp-month-title {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.n-pp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 10px;
    color: var(--tg-theme-hint-color);
    text-align: center;
    margin-bottom: 4px;
}

.n-pp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.n-pp-day, .n-pp-empty {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.n-pp-day {
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 11px;
    cursor: pointer;
    padding: 0;
}

.n-pp-day:hover {
    background: rgba(0, 0, 0, 0.06);
}

.n-pp-day.n-pp-selected, .n-pp-day.n-pp-inrange {
    background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #fff);
}

.n-pp-day.n-pp-future,
.n-pp-day.n-pp-future:hover {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.n-pp-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.n-pp-footer {
    display: flex;
    justify-content: flex-end;
}

.n-pp-show-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #fff);
    font-size: var(--ds-font-size-sm);
    font-weight: 500;
    cursor: pointer;
}

.n-pp-show-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.n-pp-show-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nutrition-period-range {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

/* Навигация по неделям */
.nutrition-week-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 0 4px 0;
}

.nutrition-week-nav-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 6px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nutrition-week-nav-btn:hover:not(.is-disabled):not(:disabled) {
    border-color: var(--tg-theme-button-color, #2481cc);
}

.nutrition-week-nav-btn.is-disabled,
.nutrition-week-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nutrition-week-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--tg-theme-text-color);
    white-space: nowrap;
}

.nutrition-charts-period {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.nutrition-period-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 8px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color);
    font-size: var(--ds-font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.nutrition-period-btn:hover {
    border-color: var(--tg-theme-button-color, #2481cc);
}

.nutrition-period-btn.active {
    background: var(--tg-theme-button-color, #2481cc);
    border-color: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #fff);
}


.nutrition-period-label {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    white-space: nowrap;
}

.nutrition-period-select {
    padding: 6px 28px 6px 10px;
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 8px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color);
    font-size: var(--ds-font-size-sm);
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 120px;
}

.nutrition-period-select:hover {
    border-color: var(--tg-theme-button-color, #2481cc);
}

.nutrition-period-select:focus {
    outline: none;
    border-color: var(--tg-theme-button-color, #2481cc);
    box-shadow: 0 0 0 2px rgba(36, 129, 204, 0.2);
}

.nutrition-chart-block {
    margin-bottom: 0;
}

.nutrition-chart-title {
    font-size: var(--ds-font-size-base);
    font-weight: 600;
    margin: 0 0 10px 0;
    color: var(--tg-theme-text-color);
}

.nutrition-chart-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
}

.n-c-legend-item::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.n-c-legend-item.n-c-pr::before { background: #34c759; }
.n-c-legend-item.n-c-fat::before { background: #ff9500; }
.n-c-legend-item.n-c-carb::before { background: #007aff; }
.n-c-legend-item.n-c-cal::before { background: var(--tg-theme-button-color, #2481cc); }

/* Линейные графики */
.nutrition-line-chart {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    padding: 12px 12px 12px 8px;
}

.nutrition-line-chart svg {
    width: 100%;
    height: 100%;
    display: block;
}

.n-c-line {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.n-c-line.n-c-pr { stroke: #34c759; }
.n-c-line.n-c-fat { stroke: #ff9500; }
.n-c-line.n-c-carb { stroke: #007aff; }
.n-c-line.n-c-cal { stroke: var(--tg-theme-button-color, #2481cc); }

.n-c-bar.n-c-pr { fill: #34c759; }
.n-c-bar.n-c-fat { fill: #ff9500; }
.n-c-bar.n-c-carb { fill: #007aff; }
.n-c-bar.n-c-cal { fill: var(--tg-theme-button-color, #2481cc); }

.n-c-grid {
    stroke: rgba(0, 0, 0, 0.08);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.n-c-goal-line {
    stroke-width: 1;
    stroke-dasharray: 4 4;
    vector-effect: non-scaling-stroke;
}

.n-c-chart-inner {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.n-c-y-axis {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    padding-right: 8px;
}

.n-c-y-tick {
    position: absolute;
    left: 0;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--tg-theme-hint-color);
    white-space: nowrap;
}

.n-c-svg-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.n-c-chart-area {
    flex: 1;
    position: relative;
    min-height: 0;
}

.n-c-chart-area svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.n-c-hover-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.n-c-hover-overlay * {
    pointer-events: none;
}

.n-c-hover-overlay .n-c-vline {
    position: absolute;
    left: 0;
    width: 1px;
    background: rgba(0, 0, 0, 0.15);
    transform: translateX(-50%);
}

.n-c-hover-overlay .n-c-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    transform: translate(-50%, -50%);
}

.n-c-hover-overlay .n-c-dot-pr { background: #34c759; }
.n-c-hover-overlay .n-c-dot-fat { background: #ff9500; }
.n-c-hover-overlay .n-c-dot-carb { background: #007aff; }
.n-c-hover-overlay .n-c-dot-cal { background: var(--tg-theme-button-color, #2481cc); }

.n-c-hover-overlay .n-c-label {
    position: absolute;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transform: translate(6px, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 1px 6px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.n-c-hover-overlay .n-c-label-left {
    transform: translate(calc(-100% - 6px), -50%);
    text-align: right;
}

.n-c-hover-overlay .n-c-label-cal {
    color: var(--tg-theme-button-color, #2481cc);
}

.n-c-hover-overlay .n-c-date-bubble {
    position: absolute;
    bottom: 2px;
    left: 0;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--tg-theme-hint-color);
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 8px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.nutrition-chart-labels {
    position: relative;
    margin-top: 8px;
    min-height: 28px;
    flex-shrink: 0;
}

.nutrition-chart-label {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    white-space: nowrap;
}

.nutrition-chart-label-two {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
}

.nutrition-chart-label-two .n-c-label-dow {
    font-size: 10px;
    color: var(--tg-theme-hint-color);
}

.nutrition-chart-label-two .n-c-label-date {
    font-size: 11px;
}

.nutrition-chart-label-pos {
    position: absolute;
    transform: translateX(-50%);
}

@media (min-width: 600px) {
    .nutrition-chart-label { font-size: 13px; }
}

.nutrition-widget {
    background: var(--tg-theme-secondary-bg-color, #f4f4f5);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    min-width: 0;
}

@media (min-width: 600px) {
    .nutrition-widget { padding: 20px; }
}

@media (min-width: 1024px) {
    .nutrition-widget {
        padding: 24px;
        border-radius: 16px;
    }
}

.nutrition-widget-title {
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-semibold);
    color: var(--tg-theme-text-color);
    margin: 0 0 var(--ds-spacing-md) 0;
}

.nutrition-widget-subtitle {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    margin: 0 0 var(--ds-spacing-lg) 0;
}

@media (min-width: 1024px) {
    .nutrition-widget-title { font-size: var(--ds-font-size-lg); }
    .nutrition-widget-subtitle {
        font-size: var(--ds-font-size-base);
        margin-bottom: 20px;
    }
}

.nutrition-today-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@media (min-width: 1024px) {
    .nutrition-today-bars { gap: 18px; }
}

.nutrition-bar-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nutrition-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.nutrition-bar-label {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-text-color);
}

@media (min-width: 1024px) {
    .nutrition-bar-label { font-size: var(--ds-font-size-base); }
}

.nutrition-bar-value {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-text-color);
    text-align: right;
}

@media (min-width: 1024px) {
    .nutrition-bar-value { font-size: var(--ds-font-size-base); }
}

/* Оверфлоу: красные цифры */
.nutrition-bar-value.nutrition-bar-overflow {
    color: #dc3545;
}

.nutrition-bar-track {
    position: relative;
    height: 20px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    overflow: visible;
}

@media (min-width: 1024px) {
    .nutrition-bar-track {
        height: 24px;
        border-radius: 12px;
    }
}

.nutrition-bar-track-nogoal .nutrition-bar-fill {
    max-width: 100%;
}

.nutrition-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 10px;
    transition: width 0.35s ease-out;
    max-width: 100%;
}

@media (min-width: 1024px) {
    .nutrition-bar-fill { border-radius: 12px; }
}

/* 0–80% — зеленый */
.nutrition-bar-fill-low {
    background: #34c759;
}

/* 80–100% — желтый */
.nutrition-bar-fill-mid {
    background: #ffc107;
}

/* >100% — весь бар красный */
.nutrition-bar-fill-overflow {
    background: #dc3545;
}

/* Белок: зелёный до 100% */
.nutrition-bar-fill-protein-ok {
    background: #34c759;
}

/* Белок: жёлтый при 100–120% */
.nutrition-bar-fill-protein-over {
    background: #ffc107;
}

/* Нет цели — серый */
.nutrition-bar-fill-nogoal {
    background: var(--tg-theme-hint-color, #999);
}

.nutrition-no-goal {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.nutrition-report {
    font-size: var(--ds-font-size-base);
    line-height: var(--ds-line-height);
    color: var(--tg-theme-text-color);
}

.nutrition-report-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: var(--ds-spacing-lg);
}

.nutrition-report-header .nutrition-widget-title {
    margin: 0;
}

.nutrition-report-header .nutrition-report-date {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    margin: 0;
}

@media (min-width: 1024px) {
    .nutrition-report-header {
        flex-wrap: nowrap;
    }
    .nutrition-report-header .nutrition-report-date {
        flex-shrink: 0;
        margin-left: auto;
    }
}

.nutrition-report-date {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    margin: 0 0 var(--ds-spacing-lg) 0;
}

.nutrition-report-section { margin-bottom: 14px; }

.nutrition-report-section strong {
    display: block;
    margin-bottom: 4px;
}

.nutrition-meals-accordion {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.nutrition-meals-accordion-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    margin: 0 0 10px 0;
    background: none;
    border: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font-weight: 600;
}

.nutrition-meals-accordion-trigger:hover { opacity: 0.85; }

.nutrition-accordion-icon {
    flex-shrink: 0;
    margin-left: 8px;
    font-size: 18px;
    font-weight: 400;
    opacity: 0.8;
    min-width: 1em;
    text-align: center;
}

.nutrition-meals-accordion-content {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.3s ease-out;
}

.nutrition-meals-accordion-content.nutrition-accordion-collapsed {
    max-height: 0;
    margin-bottom: 0;
}

.nutrition-meal-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    padding-left: 0;
    font-size: var(--ds-font-size-sm);
}

.nutrition-meal-item-main {
    flex: 1;
    min-width: 0;
}

.nutrition-meal-delete {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--tg-theme-hint-color);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.nutrition-meal-delete:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--tg-theme-text-color);
}

.nutrition-meal-time {
    color: var(--tg-theme-hint-color);
    font-weight: 500;
}

.nutrition-meal-macros {
    display: block;
    margin-top: 2px;
    margin-left: 1.5em;
    font-size: var(--ds-font-size-xs);
    color: var(--tg-theme-hint-color);
}

.nutrition-report-text {
    margin: 0 0 var(--ds-spacing-md) 0;
    font-size: var(--ds-font-size-md);
    color: var(--tg-theme-text-color);
}

.nutrition-report-hint {
    margin: var(--ds-spacing-md) 0 6px 0;
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
}

.nutrition-report-list {
    margin: 0;
    padding-left: 1.2em;
    color: var(--tg-theme-hint-color);
    font-size: var(--ds-font-size-sm);
}

.nutrition-report-nogoal {
    margin-top: 14px;
    padding-top: var(--ds-spacing-md);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    font-style: italic;
}

.nutrition-goals-list {
    margin-bottom: 16px;
    min-width: 0;
}

.nutrition-goal-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: var(--ds-spacing-md);
    margin-bottom: var(--ds-spacing-sm);
    font-size: var(--ds-font-size-base);
    min-width: 0;
}

.nutrition-goal-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nutrition-goal-value {
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.nutrition-goals-actions {
    text-align: right;
}

.nutrition-goals-btn {
    display: inline-block;
    padding: 10px 18px;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    text-decoration: none;
    border-radius: 10px;
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-medium);
}

/* Модальное окно подтверждения удаления записи питания */
.nutrition-delete-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.nutrition-delete-modal {
    background: var(--tg-theme-bg-color);
    padding: 20px;
    border-radius: 12px;
    max-width: 320px;
    width: 100%;
}

.nutrition-delete-modal-text {
    margin: 0 0 16px;
    font-size: var(--ds-font-size-base);
    color: var(--tg-theme-text-color);
}

.nutrition-delete-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.nutrition-delete-modal-btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-medium);
    cursor: pointer;
}

.nutrition-delete-modal-cancel {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
}

.nutrition-delete-modal-confirm {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.nutrition-loading,
.nutrition-error {
    text-align: center;
    padding: 32px 16px;
    color: var(--tg-theme-hint-color);
}

.nutrition-error { color: #ff3b30; }

.nutrition-loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--tg-theme-button-color);
    border-radius: 50%;
    animation: nutrition-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes nutrition-spin {
    to { transform: rotate(360deg); }
}

/* ========== BODY (дашборд) ========== */

.body-loading,
.body-error {
    text-align: center;
    padding: 32px 16px;
    color: var(--tg-theme-hint-color);
}

.body-error { color: #ff3b30; }

.body-loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--tg-theme-button-color);
    border-radius: 50%;
    animation: nutrition-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

.body-page-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.body-page-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    padding: 0 0 0 4px;
}

.body-page-tab {
    padding: 10px 14px;
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-hint-color);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    margin-bottom: -1px;
}

.body-page-tab:hover {
    color: var(--tg-theme-text-color);
}

.body-page-tab.is-active {
    font-weight: var(--ds-font-weight-semibold);
    color: var(--tg-theme-text-color);
    border-bottom-color: var(--tg-theme-button-color, #2481cc);
}

.body-page-panel {
    min-width: 0;
}

.body-measurements-tab-content {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.body-dashboard {
    display: grid;
    gap: 20px;
    padding: 12px 0;
    width: 100%;
}

@media (max-width: 599px) {
    .body-dashboard {
        grid-template-columns: 1fr;
        padding: 8px 0;
    }
}

@media (min-width: 600px) and (max-width: 1023px) {
    .body-dashboard {
        grid-template-columns: 2fr 1fr;
        gap: 16px;
        padding: 12px 0;
    }
}

@media (min-width: 1024px) {
    .body-dashboard {
        grid-template-columns: 2fr 1fr;
        gap: 20px;
        padding: 16px 0;
    }
}

.body-dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.body-dashboard-side {
    min-width: 0;
}

.body-side-inner {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Виджет Оценка InBody */
.body-inbody-score-widget .body-widget-title {
    margin-bottom: var(--ds-spacing-sm);
}

.body-inbody-score-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--tg-theme-text-color);
    margin-bottom: var(--ds-spacing-sm);
    line-height: 1.2;
}

.body-inbody-score-note {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    line-height: 1.4;
    margin: 0 0 var(--ds-spacing-md) 0;
}

.body-inbody-score-section {
    margin-bottom: var(--ds-spacing-md);
    padding-bottom: var(--ds-spacing-md);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.body-inbody-score-section-title {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-semibold);
    color: var(--tg-theme-text-color);
    margin: 0 0 var(--ds-spacing-xs) 0;
    padding-bottom: var(--ds-spacing-xs);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.body-inbody-score-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: var(--ds-spacing-xs) 0;
    font-size: var(--ds-font-size-sm);
}

.body-inbody-score-label {
    color: var(--tg-theme-hint-color);
    flex-shrink: 0;
}

.body-inbody-score-val {
    color: var(--tg-theme-text-color);
    font-weight: var(--ds-font-weight-medium);
    text-align: right;
}

.body-widget {
    background: var(--tg-theme-secondary-bg-color, #f4f4f5);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    min-width: 0;
}

@media (min-width: 600px) {
    .body-widget { padding: 20px; }
}

@media (min-width: 1024px) {
    .body-widget {
        padding: 24px;
        border-radius: 16px;
    }
}

.body-widget-title {
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-semibold);
    color: var(--tg-theme-text-color);
    margin: 0 0 var(--ds-spacing-md) 0;
}

.body-widget-subtitle {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    margin: 0 0 var(--ds-spacing-lg) 0;
}

/* Виджет «Анализ тела по сегментам» */
.body-segmental-widget .body-widget-title {
    margin-bottom: var(--ds-spacing-sm);
}

.body-segmental-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--ds-spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.body-segmental-tab {
    padding: 8px 12px;
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-hint-color);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    margin-bottom: -1px;
}

.body-segmental-tab:hover {
    color: var(--tg-theme-text-color);
}

.body-segmental-tab.is-active {
    font-weight: var(--ds-font-weight-semibold);
    color: var(--tg-theme-text-color);
    border-bottom-color: var(--tg-theme-button-color, #2481cc);
}

.body-segmental-figure-wrap {
    position: relative;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.body-segmental-figure {
    max-height: 100%;
    width: auto;
    object-fit: contain;
    z-index: 0;
}

.body-segmental-figure-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--ds-font-size-xs);
    color: var(--tg-theme-hint-color);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: translateY(-50%) rotate(-180deg);
    z-index: 1;
    pointer-events: none;
}

.body-segmental-figure-label--left {
    left: 4px;
}

.body-segmental-figure-label--right {
    right: 4px;
    left: auto;
}

.body-segmental-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 2;
    min-width: 64px;
}

.body-segmental-zone-value {
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-bold);
    color: var(--tg-theme-text-color);
}

.body-segmental-zone-percent {
    font-size: var(--ds-font-size-xs);
    color: var(--tg-theme-hint-color);
}

.body-segmental-pill {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: var(--ds-font-weight-medium);
    color: #fff;
}

.body-segmental-pill--normal {
    background: #22a847;
}

.body-segmental-pill--high {
    background: #ff9500;
}

.body-segmental-pill--low {
    background: #e65c00;
}

/* Общая плашка под цифры центрального сегмента (торс) */
.body-segmental-zone--torso .body-segmental-zone-values-bg {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 8pt;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.body-segmental-zone--torso .body-segmental-zone-values-bg .body-segmental-zone-value {
    color: var(--tg-theme-text-color, #000);
}

.body-segmental-zone--torso .body-segmental-zone-values-bg .body-segmental-zone-percent {
    color: var(--tg-theme-hint-color, #666);
}

.body-segmental-zone--left-arm  { top: 8%;   left: 0; }
.body-segmental-zone--right-arm { top: 8%;   right: 0; left: auto; }
.body-segmental-zone--torso    { top: 42%;  left: 50%; transform: translateX(-50%); }
.body-segmental-zone--left-leg { bottom: 12%; left: 12%; }
.body-segmental-zone--right-leg { bottom: 12%; right: 12%; left: auto; }

@media (max-width: 480px) {
    .body-segmental-figure-wrap {
        height: 260px;
    }
    .body-segmental-zone-value {
        font-size: var(--ds-font-size-base);
    }
}

.body-summary-cols {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 600px) {
    .body-summary-cols {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

.body-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.body-summary-label {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
}

.body-summary-value {
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-text-color);
}

.body-measurement-date {
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
    margin-top: 12px;
}

.body-add-measurement-btn {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-medium);
    background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #ffffff);
    border: none;
    cursor: pointer;
}

.body-add-measurement-btn:hover {
    opacity: 0.9;
}

/* Виджет динамики InBody */
.body-inbody-charts {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.body-chart-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.body-chart-metric-label {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
    color: var(--tg-theme-text-color);
}

.body-chart-wrap {
    position: relative;
    width: 100%;
    height: 132px;
    padding: 8px 0 24px;
}

.body-chart-wrap svg {
    display: block;
    width: 100%;
    height: 84px;
}

.body-chart-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    font-size: var(--ds-font-size-sm);
    color: var(--tg-theme-hint-color);
}

.body-chart-legend-item::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.body-chart-legend-item.body-chart-weight::before { background: var(--tg-theme-button-color, #2481cc); }
.body-chart-legend-item.body-chart-fat::before { background: #ff9500; }
.body-chart-legend-item.body-chart-muscle::before { background: #34c759; }

.body-chart-line {
    fill: none;
    stroke: var(--tg-theme-button-color, #2481cc);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.body-chart-line.body-chart-weight { stroke: var(--tg-theme-button-color, #2481cc); }
.body-chart-line.body-chart-fat { stroke: #ff9500; }
.body-chart-line.body-chart-muscle { stroke: #34c759; }

.body-chart-point {
    fill: var(--tg-theme-button-color, #2481cc);
}

.body-chart-grid {
    stroke: rgba(0, 0, 0, 0.08);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.body-chart-value-labels {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--tg-theme-text-color);
    pointer-events: none;
}

.body-chart-value-label {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.body-chart-date-labels {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 20px;
    font-size: 10px;
    color: var(--tg-theme-hint-color);
    pointer-events: none;
}

.body-chart-date-label {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.body-inbody-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--tg-theme-hint-color);
    font-size: var(--ds-font-size-sm);
}

.body-inbody-debug {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.85;
}

/* ========== TABBAR ========== */

.tabbar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background-color: var(--tg-theme-bg-color, #ffffff) !important;
    border-top: 1px solid var(--tg-theme-secondary-bg-color, #e5e5ea) !important;
    display: flex !important;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: calc(8px + var(--layout-safe-area-bottom, env(safe-area-inset-bottom, 0px)));
    z-index: 9999 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    width: 100% !important;
    max-width: 100% !important;
}

.tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 4px 8px;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
    color: var(--tg-theme-hint-color, #8e8e93);
    min-width: 0;
}

.tabbar-item:hover { opacity: 0.7; }
.tabbar-item:active { opacity: 0.5; }
.tabbar-item.active { color: var(--tg-theme-button-color, #2481cc); }

.tabbar-icon {
    font-size: 24px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.tabbar-icon img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.tabbar-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== LOGIN ========== */

.login-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-header { text-align: center; margin-bottom: 32px; }

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--tg-theme-text-color, #000);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 16px;
    color: var(--tg-theme-hint-color, #999);
}

.login-content {
    background: var(--tg-theme-secondary-bg-color, #f4f4f5);
    border-radius: 16px;
    padding: 24px;
}

.login-section { margin-bottom: 20px; }
.login-section:last-of-type { margin-bottom: 0; }

.login-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tg-theme-hint-color, #999);
    margin: 0 0 var(--ds-spacing-md) 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-field { margin-bottom: 16px; }

.login-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--tg-theme-text-color, #000);
}

.login-field input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid var(--border-color, #e5e5ea);
    border-radius: 10px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
    box-sizing: border-box;
}

.login-field input:focus {
    outline: none;
    border-color: var(--tg-theme-button-color, #2481cc);
}

.login-field-code { margin-top: 16px; }

.btn-block { width: 100%; margin-top: 8px; }

.login-divider {
    text-align: center;
    font-size: 14px;
    color: var(--tg-theme-hint-color, #999);
    margin: 20px 0;
}

#telegram-login-container {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

.login-message {
    font-size: 14px;
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 8px;
}

.login-message.error { background: #fee; color: #c00; }
.login-message.success { background: #efe; color: #060; }

/* ========== HOME ========== */

.home-content {
    padding: var(--ds-spacing-lg) var(--ds-spacing-lg) 0;
    width: 100%;
}

.home-content .nutrition-loading,
.home-content .nutrition-profile-selector-wrap,
.home-content .nutrition-widget,
.home-content .body-widget.home-body-charts {
    margin-top: var(--ds-spacing-lg);
    width: 100%;
}

.home-content .nutrition-loading:first-child,
.home-content .nutrition-profile-selector-wrap:first-of-type,
.home-content .nutrition-widget:first-of-type {
    margin-top: 0;
}

/* ========== DEBUG ========== */

.debug-block {
    margin: 8px 16px 12px;
    padding: 10px 12px;
    background: #e8f4fd;
    border: 1px solid #0a84ff;
    border-radius: 10px;
    font-size: 12px;
    color: #1c1c1e;
}

.debug-block__title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #0a84ff;
}

.debug-block__title.debug-block__section { margin-top: 12px; }

.debug-block__row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.debug-block__label { color: #666; min-width: 90px; }

.debug-block__value {
    font-family: ui-monospace, monospace;
    word-break: break-all;
}

/* ========== ADAPTIVE ========== */

@media (max-width: 480px) {
    .profile-header { padding: 20px 12px; }
    .profile-content { padding: 12px; }
    .profile-header .title { font-size: 22px; }
    .avatar { width: 70px; height: 70px; }
    .avatar-icon { font-size: 35px; }
    .form-wrapper { padding: 20px 12px; }
    .form-wrapper .title { font-size: var(--ds-font-size-2xl); }
    .step-title { font-size: 20px; }
    .radio-group:not(.vertical) { flex-direction: column; }
}

@media (prefers-color-scheme: dark) {
    :root {
        --border-color: #38383a;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-strong: rgba(0, 0, 0, 0.4);
    }
    .tabbar {
        border-top-color: var(--border-color);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }
}
