:root {
    --primary: #4a76a8;
    --secondary: #5b9bd5;
    --light: #f5f7fa;
    --dark: #2c3e50;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #17a2b8;
    --water: #3498db;
    --omega3: #9b59b6;
    --mass: #e67e22;
    --gray: #95a5a6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f0f2f5;
    color: var(--dark);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.seo-title {
    margin: 20px 0 10px 0;
    color: var(--dark);
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
}

.seo-description {
    margin-bottom: 20px;
    color: var(--gray);
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.5;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
}

.date-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.date-btn {
    background: var(--light);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

.current-date {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    text-align: center;
}

.add-meal-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    margin: 0 auto;
    font-size: 0.9rem;
}

.add-meal-btn:hover {
    background: var(--secondary);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 400px;
    }
}

.meals-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.meal-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.meal-header {
    background: var(--light);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e1e8ed;
    flex-wrap: wrap;
    gap: 10px;
}

.meal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.meal-calories {
    color: var(--primary);
    font-weight: 600;
}

.meal-actions {
    display: flex;
    gap: 8px;
}

.delete-meal-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 1.2rem;
    transition: color 0.2s;
    padding: 5px;
}

.delete-meal-btn:hover {
    color: #c0392b;
}

.meal-content {
    padding: 15px;
}

.meal-summary {
    margin-top: 15px;
    padding: 12px;
    background: var(--light);
    border-radius: 5px;
    font-size: 0.85rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-wrap: wrap;
    gap: 5px;
}

.summary-label {
    font-weight: 500;
    color: var(--dark);
}

.summary-value {
    font-weight: 600;
    color: var(--primary);
}

.add-product-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    width: 100%;
    justify-content: center;
    margin-top: 10px;
    font-size: 0.9rem;
}

.add-product-btn:hover {
    background: var(--secondary);
}

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 15px;
}

.product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.product-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.95rem;
    line-height: 1.3;
}

.product-details {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--gray);
    flex-wrap: wrap;
    line-height: 1.4;
}

.product-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray);
    transition: all 0.2s;
    padding: 6px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    border-radius: 4px;
}

.action-btn:hover {
    color: var(--primary);
    background: var(--light);
}

.nutrition-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nutrition-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
}

.card-title {
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--dark);
}

.progress-container {
    margin-bottom: 12px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.progress-label span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.norm-input {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid #e1e8ed;
    border-radius: 3px;
    font-size: 0.8rem;
    text-align: center;
    background: white;
}

.norm-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74, 118, 168, 0.2);
}

.progress-bar {
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
}

.norm-info {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--gray);
    text-align: center;
    font-style: italic;
}

.micro-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 768px) {
    .micro-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.micro-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.micro-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    cursor: help;
    gap: 5px;
}

.micro-name {
    font-weight: 500;
    font-size: 0.8rem;
    min-width: 35px;
}

.micro-progress, .mineral-progress {
    flex: 1;
    margin: 0 8px;
    min-width: 0;
}

.micro-bar, .mineral-bar {
    height: 6px;
    background: var(--light);
    border-radius: 3px;
    overflow: hidden;
}

.micro-fill, .mineral-fill {
    height: 100%;
    border-radius: 3px;
}

.micro-fill {
    background: var(--primary);
}

.mineral-fill {
    background: var(--success);
}

.micro-percent, .mineral-percent {
    font-size: 0.75rem;
    color: var(--dark);
    min-width: 30px;
    text-align: right;
    font-weight: 600;
}

.micro-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.micro-item:hover .micro-tooltip {
    opacity: 1;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.large-modal {
    max-width: 800px;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e1e8ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--dark);
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 130px);
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e1e8ed;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 10;
}

.search-box {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e1e8ed;
    border-radius: 5px;
    font-size: 1rem;
}

.product-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e1e8ed;
    border-radius: 5px;
    margin-bottom: 15px;
}

.list-product-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.list-product-item:hover {
    background: var(--light);
}

.list-product-header {
    padding: 10px 12px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
}

.product-header-text {
    padding: 5px 0;
}

.product-amount {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.amount-input {
    width: 100px;
    padding: 10px;
    border: 1px solid #e1e8ed;
    border-radius: 5px;
    text-align: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
    min-width: 80px;
}

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

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

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 1px solid #e1e8ed;
}

.btn-secondary:hover {
    background: #e1e8ed;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--gray);
}

.meals-section-footer {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* Стили для формы добавления нового продукта */
.form-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e1e8ed;
}

.form-section h4 {
    margin-bottom: 15px;
    color: var(--primary);
    font-size: 1rem;
}

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

@media (min-width: 768px) {
    .input-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

.uniform-input {
    display: flex;
    flex-direction: column;
}

.uniform-input label {
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--dark);
}

.uniform-input input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e1e8ed;
    border-radius: 5px;
    font-size: 0.9rem;
}

/* Стили для управления массой в просмотре нутриентов */
.nutrients-mass-control {
    margin-bottom: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 5px;
}

.nutrients-mass-control .input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nutrients-mass-control label {
    font-weight: 500;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.nutrients-mass-control input {
    width: 100px;
    padding: 8px;
    border: 1px solid #e1e8ed;
    border-radius: 5px;
}

/* Стили для кнопок действий */
.delete-from-db-btn {
    color: var(--danger) !important;
}

.delete-from-db-btn:hover {
    color: #c0392b !important;
    background: rgba(231, 76, 60, 0.1) !important;
}

.view-nutrients-btn {
    color: var(--info) !important;
}

.view-nutrients-btn:hover {
    color: #138496 !important;
    background: rgba(23, 162, 184, 0.1) !important;
}

/* Стили для информации о продукте */
.product-mass-info {
    margin-bottom: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 5px;
}

.product-mass-info p {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.product-mass-info strong {
    color: var(--dark);
}

/* Увеличиваем z-index для окна просмотра нутриентов */
#view-product-nutrients-modal {
    z-index: 2000;
}

/* Информационный блок */
.info-content {
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-content p {
    margin-bottom: 10px;
    color: var(--dark);
}

.info-list {
    margin-left: 20px;
    margin-bottom: 0;
}

.info-list li {
    margin-bottom: 5px;
    color: var(--gray);
}

/* Адаптивные улучшения для мобильных устройств */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .seo-title {
        font-size: 1.5rem;
        margin: 15px 0 8px 0;
    }
    
    .seo-description {
        font-size: 1rem;
        margin-bottom: 15px;
    }
    
    .date-selector {
        padding: 10px;
    }
    
    .current-date {
        font-size: 0.9rem;
    }
    
    .meal-header {
        padding: 12px;
    }
    
    .meal-content {
        padding: 12px;
    }
    
    .nutrition-card {
        padding: 15px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(95vh - 130px);
    }
    
    .product-details {
        font-size: 0.75rem;
        gap: 8px;
    }
    
    .progress-label {
        font-size: 0.8rem;
    }
    
    .micro-item {
        padding: 6px 0;
    }
    
    .micro-name {
        font-size: 0.75rem;
        min-width: 30px;
    }
    
    .micro-percent, .mineral-percent {
        font-size: 0.7rem;
        min-width: 25px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
        min-width: 70px;
    }
    
    .modal-footer {
        padding: 12px 15px;
        flex-wrap: wrap;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .product-item {
        gap: 12px;
        padding: 10px 0;
    }
    
    .product-details {
        gap: 8px;
        font-size: 0.75rem;
    }
    
    .product-actions {
        gap: 6px;
    }
    
    .action-btn {
        padding: 5px;
        font-size: 1rem;
        min-width: 28px;
        height: 28px;
    }
    
    .norm-input {
        width: 50px;
        padding: 3px 4px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .seo-title {
        font-size: 1.3rem;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .date-selector {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .current-date {
        order: -1;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .product-item {
        align-items: center;
    }
    
    .product-actions {
        align-self: center;
    }
    
    .product-details {
        flex-direction: row;
        gap: 8px;
    }
    
    .summary-line {
        flex-direction: column;
        gap: 2px;
    }
    
    .micro-grid {
        grid-template-columns: 1fr;
    }
    
    .input-grid {
        grid-template-columns: 1fr;
    }
    
    .nutrients-mass-control .input-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .nutrients-mass-control input {
        width: 100%;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        border-radius: 6px;
    }
    
    .modal-header, .modal-footer {
        padding: 12px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 360px) {
    .container {
        padding: 8px;
    }
    
    .seo-title {
        font-size: 1.2rem;
    }
    
    .product-details {
        flex-direction: column;
        gap: 4px;
    }
    
    .product-actions {
        gap: 5px;
    }
    
    .action-btn {
        padding: 3px;
        font-size: 0.9rem;
    }
    
    .micro-item {
        gap: 3px;
    }
    
    .micro-progress, .mineral-progress {
        margin: 0 5px;
    }
    
    .product-item {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    
    .product-actions {
        align-self: center;
    }
}

/* Плавная анимация для улучшения UX */
.modal-content {
    animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Улучшение доступности */
.btn:focus, .action-btn:focus, .close-modal:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.search-input:focus, .amount-input:focus, .uniform-input input:focus, .norm-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74, 118, 168, 0.2);
}

/* Улучшение скроллбаров */
.product-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.product-list::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.product-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.product-list::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}