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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 5px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 8px;
}

h1 {
    color: #333;
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.current-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin: 5px 0;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.date-controls {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.time-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.btn {
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.date-input, .select {
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    transition: border-color 0.3s;
}

.date-input:focus, .select:focus {
    outline: none;
    border-color: #667eea;
}

.chart-container {
    position: relative;
    height: 500px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: #666;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.green {
    background: #10b981;
}

.dot.yellow {
    background: #f59e0b;
}

.dot.red {
    background: #ef4444;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    color: white;
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.9;
    margin-bottom: 3px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
}

.loading {
    text-align: center;
    padding: 20px;
    font-size: 1.2rem;
    color: #667eea;
    display: none;
}

.loading.show {
    display: block;
}

.error {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
    display: none;
}

.error.show {
    display: block;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    font-size: 1.2rem;
    color: #333;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    background: #667eea;
    flex: 1;
}

.btn-secondary {
    background: #6b7280;
    flex: 1;
}

.btn-danger {
    background: #ef4444;
    flex: 1;
}

.btn-meal {
    background: #10b981;
}

.btn-meal:hover {
    background: #059669;
}

#mealDetailsContent {
    font-size: 0.9rem;
    line-height: 1.6;
}

#mealDetailsContent p {
    margin: 8px 0;
}

#mealDetailsContent strong {
    color: #667eea;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container {
        padding: 8px;
        border-radius: 10px;
    }

    h1 {
        font-size: 1.2rem;
    }

    .current-value {
        font-size: 1.8rem;
    }

    .chart-container {
        height: 480px;
    }

    .controls {
        gap: 6px;
    }

    .btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .date-input, .select {
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    .legend {
        gap: 8px;
    }

    .legend-item {
        font-size: 0.7rem;
    }

    .stat-card {
        padding: 8px;
    }

    .stat-value {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 3px;
    }

    .container {
        padding: 6px;
    }

    .current-value {
        font-size: 1.6rem;
    }

    .chart-container {
        height: 400px;
        padding: 8px;
    }

    .date-controls {
        width: 100%;
    }

    .date-input {
        flex: 1;
    }
}
