/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-card: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-orange: #FF6B35;
    --accent-blue: #4A90E2;
    --accent: #4A90E2;
    --accent-hover: #357ABD;
    --success: #66BB6A;
    --danger: #EF5350;
    --border: #3a3a3a;
    --shadow: rgba(0, 0, 0, 0.4);
    --card-white: #ffffff;
    --card-orange: #FF6B35;
    --card-blue: #4A90E2;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent: #4A90E2;
    --accent-hover: #357ABD;
    --success: #4CAF50;
    --danger: #F44336;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
    padding-bottom: 80px;
    min-height: 100vh;
    line-height: 1.5;
}

/* Навигация */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px var(--shadow);
    backdrop-filter: blur(10px);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
}

/* Контейнер */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Экраны */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* Загрузка */
#loadingScreen {
    text-align: center;
    padding: 40px 20px;
}

.loader {
    border: 4px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Календарь */
.calendar-widget {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.calendar-month {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.calendar-nav-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.calendar-nav-btn:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.1);
}

.calendar-nav-btn:active {
    transform: scale(0.95);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 6px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.calendar-weekdays span {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-dates {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.calendar-date {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    width: 100%;
    box-sizing: border-box;
    aspect-ratio: 1;
    max-width: 100%;
    margin: 0 auto;
}

.calendar-date:hover {
    background-color: var(--bg-secondary);
}

.calendar-date.today {
    color: var(--text-primary);
}

.calendar-date.active {
    color: var(--text-primary);
    background-color: transparent;
    border: 2px solid var(--text-primary);
    font-weight: 600;
}

.calendar-date.today.active {
    border-color: var(--text-primary);
    border-width: 2px;
}

/* Карточки */
.stats-card, .recommendations-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border);
}

.stats-card h2, .recommendations-card h3 {
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.recommendation-item {
    background-color: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: 0 2px 6px var(--shadow);
}

/* Секции */
.section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-header .btn-icon {
    margin-left: auto;
}

/* Кнопки */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4);
}

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

.btn-secondary:hover {
    background-color: var(--border);
}

.btn-icon {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-icon:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4);
}

/* Списки */
.habits-list, .goals-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.goals-list > .goal-item,
.goals-list > .goal-item-binary,
.goals-list > .goal-item-progress {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.habit-item, .goal-item {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 4px 12px var(--shadow);
    display: block;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    width: 100% !important;
    height: 120px !important;
    min-height: 120px !important;
    max-height: 120px !important;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

.habit-item:hover, .goal-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow);
}

/* Прогрессные цели - вся карточка является прогресс-баром */
.goal-item-progress {
    position: relative;
    background-color: var(--bg-secondary);
    overflow: hidden;
    padding: 0;
    height: 120px !important;
    min-height: 120px !important;
    max-height: 120px !important;
    cursor: grab;
    touch-action: none;
    width: 100%;
    box-sizing: border-box;
}

.goal-item-progress:active {
    cursor: grabbing;
}

.progress-card-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #8D1839;
    transition: width 0.3s ease;
    z-index: 1;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
}

.progress-card-content {
    position: relative;
    z-index: 2;
    padding: 18px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    overflow: hidden;
}

.progress-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.progress-card-header .goal-title {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-card-header .goal-actions {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.progress-card-content .goal-details {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.9;
    margin-bottom: 8px;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-card-header .btn-analyze,
.progress-card-header .btn-edit,
.progress-card-header .btn-delete,
.progress-card-header .btn-add-food-icon {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
    cursor: pointer;
}

.progress-card-header .btn-analyze .icon,
.progress-card-header .btn-edit .icon,
.progress-card-header .btn-delete .icon,
.progress-card-header .btn-add-food-icon .icon {
    width: 18px;
    height: 18px;
    stroke: white;
    fill: none;
}

.progress-card-header .btn-analyze:hover,
.progress-card-header .btn-edit:hover,
.progress-card-header .btn-delete:hover,
.progress-card-header .btn-add-food-icon:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.progress-card-stats {
    margin-top: auto;
}

.progress-card-stats .progress-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.progress-current {
    color: var(--text-primary);
    font-size: 32px;
}

.progress-separator {
    opacity: 0.6;
    font-size: 24px;
}

.progress-target {
    opacity: 0.8;
    font-size: 22px;
}

/* Цвет заливки берется из inline стиля */

.goal-item-progress.completed .progress-card-content {
    color: white;
}

.progress-card-draggable {
    user-select: none;
}

/* Бинарные цели - в стиле прогрессных карточек */
.goal-item-binary {
    position: relative;
    background-color: var(--bg-secondary);
    overflow: hidden;
    padding: 0;
    height: 120px !important;
    min-height: 120px !important;
    max-height: 120px !important;
    cursor: pointer;
    user-select: none;
    width: 100%;
    box-sizing: border-box;
}

.goal-item-binary:active {
    transform: scale(0.98);
}

.binary-card-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #8D1839;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
}

.binary-card-content {
    position: relative;
    z-index: 2;
    padding: 18px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    overflow: hidden;
}

.binary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.binary-card-header .goal-title {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.binary-card-header .goal-actions {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.binary-card-header .btn-edit,
.binary-card-header .btn-delete {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.binary-card-header .btn-edit .icon,
.binary-card-header .btn-delete .icon {
    width: 18px;
    height: 18px;
    stroke: white;
    fill: none;
}

.binary-card-header .btn-edit:hover,
.binary-card-header .btn-delete:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.binary-card-content .goal-details {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.9;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.goal-checkmark {
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-right: 8px;
}

.goal-checkmark .icon {
    width: 16px;
    height: 16px;
    stroke: white;
}

.goal-item-binary.completed .binary-card-content {
    color: white;
}

.goal-item-binary.completed .goal-title {
    text-decoration: line-through;
    opacity: 0.95;
}

.habit-info, .goal-info {
    flex: 1;
}

.habit-title, .goal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.habit-details, .goal-details {
    font-size: 14px;
    color: var(--text-secondary);
}

.habit-actions, .goal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--accent);
}

.btn-edit, .btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
}

.btn-edit:hover {
    background-color: var(--bg-secondary);
}

.btn-delete {
    color: var(--danger);
}

.btn-delete:hover {
    background-color: var(--bg-secondary);
}

/* SVG иконки */
.icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    display: inline-block;
    vertical-align: middle;
}

.icon-check {
    width: 18px;
    height: 18px;
}

.icon-edit,
.icon-delete {
    width: 18px;
    height: 18px;
}

.icon-plus {
    width: 24px;
    height: 24px;
}

.icon-home,
.icon-stats {
    width: 22px;
    height: 22px;
}

.icon-lightbulb {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
}

.icon-moon {
    width: 20px;
    height: 20px;
}

.icon-target {
    width: 48px;
    height: 48px;
    opacity: 0.5;
    color: var(--text-secondary);
}

.icon-chart {
    width: 18px;
    height: 18px;
}

/* Анализ цели */
.analysis-container {
    padding: 16px;
}

.analysis-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-back {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 16px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.btn-back:hover {
    background-color: var(--bg-secondary);
}

.analysis-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.analysis-summary {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
}

.summary-item {
    text-align: center;
}

.summary-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-blue);
}

.goal-calendar-container,
.goal-chart-container {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.goal-calendar-container h3,
.goal-chart-container h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.goal-calendar {
    margin-top: 16px;
}

.chart-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.chart-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.chart-btn.active {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

#goalChart {
    width: 100%;
    height: 100%;
}

.btn-analyze {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
    cursor: pointer;
}

.btn-analyze:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.btn-analyze .icon {
    width: 18px;
    height: 18px;
    stroke: white;
    fill: none;
}

.progress-card-header .btn-analyze,
.binary-card-header .btn-analyze {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.progress-card-header .btn-analyze:hover,
.binary-card-header .btn-analyze:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

/* Формы */
.form-container {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin: 16px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.form-container h2 {
    margin-bottom: 20px;
    font-size: 20px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s;
    box-sizing: border-box;
    overflow: visible;
    text-overflow: ellipsis;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    background-color: var(--bg-card);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn {
    flex: 1;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border);
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    font-weight: 500;
}

/* Статистика */
.stats-container {
    padding: 16px;
}

/* Навигация по месяцам */
.month-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    background-color: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.month-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    flex: 1;
}

.month-nav-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.month-nav-btn:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.1);
}

.month-nav-btn:active {
    transform: scale(0.95);
}

/* Шапка месяца с метриками */
.monthly-header {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.month-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.month-stat-item {
    text-align: center;
}

.month-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.month-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-blue);
    line-height: 1.4;
}

/* Календарь месяца */
.monthly-calendar {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.calendar-weekdays-month {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 12px;
    text-align: center;
}

.calendar-weekdays-month span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 4px;
}

.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 40px;
    border: 1px solid var(--border);
}

.calendar-day-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px var(--shadow);
    z-index: 1;
}

.calendar-day-cell.empty {
    background-color: transparent;
    border: none;
    cursor: default;
}

.calendar-day-cell.empty:hover {
    transform: none;
    box-shadow: none;
}

.calendar-day-number {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.calendar-day-stats {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
}

.period-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.period-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.period-btn.active {
    background-color: var(--accent-blue);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.stats-content {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row-label {
    color: var(--text-secondary);
}

.stat-row-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Нижняя навигация */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    box-shadow: 0 -4px 12px var(--shadow);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 8px 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    font-size: 12px;
}

.nav-btn.active {
    color: var(--accent-orange);
    font-weight: 600;
}

.nav-btn .icon {
    margin-bottom: 4px;
}

/* Пустые состояния */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    line-height: 1;
    opacity: 0.8;
}

/* Прогресс-бар */
.progress-info {
    margin-top: 8px;
}

.progress-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.progress-bar-container {
    position: relative;
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: grab;
    touch-action: none;
}

.progress-bar:active {
    cursor: grabbing;
}

.progress-bar-draggable {
    user-select: none;
}

.progress-fill {
    height: 100%;
    background-color: var(--accent-blue);
    transition: width 0.3s ease;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.5);
}

.progress-hint {
    position: absolute;
    top: -50px;
    background-color: var(--accent-blue);
    color: white;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.5);
    z-index: 20;
    pointer-events: none;
    transform: translateX(-50%);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Убраны кнопки управления прогрессом - теперь используется drag-to-fill */

/* Выбор цвета */
.color-picker {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.color-picker input[type="hidden"] {
    display: none;
}

.color-presets {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;  /* В одну строку */
    justify-content: center !important;  /* По центру */
    align-items: center;
    min-height: 64px;
    padding: 8px 0;
    overflow-x: auto;  /* Горизонтальная прокрутка если не помещается */
    -webkit-overflow-scrolling: touch;  /* Плавная прокрутка на iOS */
}

.color-presets::-webkit-scrollbar {
    display: none;  /* Скрыть скроллбар */
}

.color-preset {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--border);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    background: none;
    box-shadow: 0 2px 8px var(--shadow);
    position: relative;
    flex-shrink: 0;
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: var(--text-primary);
    box-shadow: 0 4px 12px var(--shadow);
}

.color-preset.active {
    width: 56px;
    height: 56px;
    border-color: var(--text-primary);
    border-width: 4px;
    box-shadow: 0 0 0 3px var(--bg-primary), 0 6px 20px var(--shadow);
    transform: scale(1);
    z-index: 10;
    margin: -8px;
}

/* Адаптивность - объединено с основным блоком мобильной оптимизации ниже */

/* Иконки вместо эмодзи */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: middle;
    fill: currentColor;
}

.icon-moon {
    width: 20px;
    height: 20px;
}

.icon-sun {
    width: 20px;
    height: 20px;
}

.icon-target {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.icon-check {
    width: 20px;
    height: 20px;
}

.icon-edit {
    width: 18px;
    height: 18px;
}

.icon-delete {
    width: 18px;
    height: 18px;
}

.icon-lightbulb {
    width: 20px;
    height: 20px;
}

.icon-home {
    width: 20px;
    height: 20px;
}

.icon-stats {
    width: 20px;
    height: 20px;
}

/* Выбор дней недели/месяца */
.day-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.weekly-picker {
    justify-content: space-between;
}

.monthly-picker {
    justify-content: flex-start;
}

/* Календарь для выбора дней месяца */
.monthly-calendar-container {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: var(--bg-card);
}

.monthly-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.month-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.month-nav-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
}

.month-nav-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.monthly-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.monthly-calendar-weekdays span {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
}

.monthly-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-cell {
    aspect-ratio: 1;
    min-height: 40px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.calendar-day-cell:hover:not(.empty) {
    border-color: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 2px 8px var(--shadow);
}

.calendar-day-cell.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.calendar-day-cell.empty {
    border: none;
    background: transparent;
    cursor: default;
}

[data-theme="light"] .monthly-calendar-container {
    background: var(--bg-card);
    border-color: var(--border);
}

[data-theme="light"] .month-nav-btn {
    border-color: var(--border);
}

[data-theme="light"] .month-nav-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

[data-theme="light"] .calendar-day-cell {
    background: var(--bg-card);
    border-color: var(--border);
}

[data-theme="light"] .calendar-day-cell:hover:not(.empty) {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.day-chip {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.day-chip:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px var(--shadow);
}

.day-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.weekly-picker .day-chip {
    flex: 1;
    min-width: 0;
}

.monthly-picker .day-chip {
    min-width: 40px;
    width: auto;
}

[data-theme="light"] .day-chip {
    background: var(--bg-card);
    border-color: var(--border);
}

[data-theme="light"] .day-chip:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .day-chip.active {
    background: var(--accent);
    color: white;
}

/* Мобильная оптимизация */
@media (max-width: 480px) {
    /* Навигация */
    .navbar {
        padding: 12px 16px;
    }
    
    .nav-title {
        font-size: 18px;
    }
    
    .theme-toggle {
        font-size: 20px;
        padding: 4px 6px;
    }
    
    /* Контейнер */
    .container {
        padding: 12px 8px !important;  /* Минимальный padding по бокам */
        max-width: 100% !important;
        overflow-x: visible !important;
    }
    
    /* Заголовки секций */
    .section-header h2 {
        font-size: 18px;
    }
    
    /* Карточки целей */
    .goal-item-binary {
        height: 100px !important;
        min-height: 100px !important;
        max-height: 100px !important;
    }
    
    .binary-card-content {
        padding: 14px;
    }
    
    .binary-card-header .goal-title {
        font-size: 16px;
    }
    
    .binary-card-content .goal-details {
        font-size: 12px;
    }
    
    .progress-card-content {
        padding: 14px;
    }
    
    .progress-card-header .goal-title {
        font-size: 16px;
    }
    
    .progress-card-stats .progress-text {
        font-size: 24px;
    }
    
    .progress-current {
        font-size: 28px;
    }
    
    .progress-separator {
        font-size: 20px;
    }
    
    .progress-target {
        font-size: 18px;
    }
    
    /* Форма */
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 12px;
        font-size: 15px;
        border-radius: 10px;
    }
    
    .form-actions {
        margin-top: 20px;
        gap: 10px;
    }
    
    .form-actions .btn {
        padding: 10px 20px;
        font-size: 15px;
    }
    
    /* Кнопки */
    .btn {
        padding: 10px 20px;
        font-size: 15px;
    }
    
    /* Статистика */
    .stats-card, .recommendations-card {
        padding: 10px !important;
        margin-bottom: 10px !important;
        border-radius: 10px !important;
    }
    
    .stats-card h2, .recommendations-card h3 {
        font-size: 14px !important;
        margin-bottom: 8px !important;
    }
    
    .stats-grid {
        gap: 8px !important;
    }
    
    .stat-value {
        font-size: 28px !important;
        margin-bottom: 2px !important;
    }
    
    .stat-label {
        font-size: 11px !important;
    }
    
    .recommendation-item {
        padding: 8px !important;
        font-size: 12px !important;
        margin-bottom: 6px !important;
        border-radius: 8px !important;
    }
    
    /* Навигация по месяцам */
    .month-navigation {
        padding: 10px;
        margin-bottom: 16px;
    }
    
    .month-title {
        font-size: 18px;
    }
    
    .month-nav-btn {
        font-size: 24px;
        width: 40px;
        height: 40px;
        padding: 6px 12px;
    }
    
    /* Шапка месяца */
    .monthly-header {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .month-stat-label {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .month-stat-value {
        font-size: 20px;
    }
    
    /* Календарь на главном экране - еще меньше для мобильных */
    .calendar-widget {
        padding: 6px !important;
        margin-bottom: 10px !important;
    }
    
    .calendar-header {
        padding: 4px 2px !important;
        margin-bottom: 4px !important;
    }
    
    .calendar-month {
        font-size: 12px !important;
        padding: 2px 4px !important;
    }
    
    .calendar-nav-btn {
        font-size: 16px !important;
        width: 24px !important;
        height: 24px !important;
        padding: 0 !important;
    }
    
    .calendar-weekdays {
        margin-bottom: 4px !important;
        padding: 2px 0 !important;
        gap: 3px !important;
    }
    
    .calendar-weekdays span {
        font-size: 9px !important;
        padding: 2px 0 !important;
    }
    
    .calendar-dates {
        gap: 3px !important;
    }
    
    .calendar-date {
        min-height: 24px !important;
        font-size: 11px !important;
        padding: 2px !important;
    }
    
    /* Календарь в статистике */
    .monthly-calendar-container {
        padding: 12px;
    }
    
    .monthly-calendar-weekdays span {
        font-size: 11px;
        padding: 6px 0;
    }
    
    .calendar-day-cell {
        min-height: 36px;
        font-size: 13px;
        border-radius: 6px;
    }
    
    /* Выбор дней недели/месяца */
    .day-chip {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 36px;
    }
    
    .weekly-picker {
        gap: 6px;
    }
    
    /* Цветовая палитра */
    .color-picker {
        gap: 8px;
    }
    
    .color-presets {
        flex-wrap: nowrap;  /* В одну строку */
        gap: 8px;
        justify-content: center !important;  /* Выравнивание по центру */
        overflow-x: auto;  /* Горизонтальная прокрутка если не помещается */
        padding: 8px 0;
        -webkit-overflow-scrolling: touch;  /* Плавная прокрутка на iOS */
    }
    
    .color-presets::-webkit-scrollbar {
        display: none;  /* Скрыть скроллбар */
    }
    
    .color-preset {
        width: 32px;
        height: 32px;
        flex-shrink: 0;  /* Не сжимать элементы */
    }
    
    .color-preset.active {
        width: 40px;
        height: 40px;
        margin: -4px;
    }
    
    /* Поле даты - уменьшаем размеры и предотвращаем переполнение */
    .form-group input[type="date"] {
        font-size: 12px !important;  /* Уменьшенный размер шрифта */
        padding: 10px 4px !important;  /* Минимальный padding */
        max-width: 100% !important;
        box-sizing: border-box !important;
        width: 100% !important;
        min-width: 0 !important;  /* Позволяет сжиматься */
        overflow: hidden !important;  /* Скрываем переполнение */
        text-overflow: ellipsis !important;  /* Многоточие для длинного текста */
        white-space: nowrap !important;  /* Не переносить текст */
        -webkit-appearance: none !important;  /* Убрать стандартный вид iOS */
    }
    
    /* Убеждаемся что форма не выходит за границы */
    .form-container {
        max-width: 100% !important;
        overflow-x: visible !important;
        padding: 12px 6px !important;  /* Минимальный padding */
        margin: 8px 4px !important;  /* Минимальный margin */
    }
    
    .form-group {
        max-width: 100% !important;
        overflow-x: visible !important;
        margin-bottom: 12px;
        padding: 0 !important;
        width: 100% !important;
    }
    
    /* Контейнер формы - убеждаемся что всё помещается */
    #goalForm {
        max-width: 100% !important;
        overflow-x: visible !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Контейнер приложения */
    .container {
        padding: 12px 8px !important;  /* Минимальный padding */
        max-width: 100% !important;
        overflow-x: visible !important;
    }
    
    /* Экран формы */
    #goalFormScreen {
        overflow-x: visible !important;
        max-width: 100% !important;
    }
    
    /* Пустое состояние */
    .empty-state {
        padding: 30px 20px;
    }
    
    .empty-state-icon {
        font-size: 48px;
        margin-bottom: 16px;
    }
    
    .empty-state h3 {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .empty-state p {
        font-size: 14px;
    }
    
    /* Нижняя навигация */
    .bottom-nav {
        padding: 8px 0;
    }
    
    .nav-item {
        font-size: 11px;
    }
    
    .nav-item .icon {
        width: 20px;
        height: 20px;
        margin-bottom: 4px;
    }
    
    /* Форма контейнер */
    .form-container {
        margin: 12px;
        padding: 16px;
    }
    
    /* Прогресс контролы */
    .progress-controls {
        gap: 4px;
    }
    
    .btn-progress {
        padding: 4px 8px;
        font-size: 12px;
    }
}

/* Шаблоны привычек */
.goal-templates {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.goal-templates label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.template-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.template-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
    border: none;
    border-radius: 16px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    position: relative;
    overflow: hidden;
}

.template-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.template-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #FF8C42 0%, #FF6B35 100%);
}

.template-btn:hover::before {
    left: 100%;
}

.template-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.template-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.template-name {
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

/* Калории в карточке цели */
.calories-summary {
    margin-top: 12px;
    display: block !important;
    visibility: visible !important;
}

.calories-macros {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.calories-macros span {
    color: var(--text-primary);
    font-weight: 500;
}


.btn-add-food:hover {
    background-color: var(--accent-hover);
}

.btn-add-food:active {
    transform: scale(0.98);
}

/* Экран добавления еды */
#foodFormScreen .form-container {
    max-width: 100%;
}

#foodFormScreen .form-group {
    margin-bottom: 16px;
}

#foodFormScreen .form-group input[type="number"] {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
}

#foodFormScreen .form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* Мобильная адаптация для калорий */
@media (max-width: 480px) {
    .template-btn {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 14px;
        gap: 8px;
    }
    
    .template-icon {
        font-size: 20px;
    }
    
    .calories-summary {
        margin-top: 8px;
        padding-top: 8px;
    }
    
    .calories-main {
        font-size: 14px;
    }
    
    .calories-macros {
        font-size: 12px;
    }
    
    .btn-add-food {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .template-btn {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 14px;
    }
    
    .template-icon {
        font-size: 20px;
    }
}

