:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-green: #22c55e;
    --accent-green-light: #4ade80;
    --accent-blue: #3b82f6;
    --accent-purple: #a855f7;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
#loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loading-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}
.loading-text { font-size: 1.125rem; color: var(--text-secondary); }

/* Screens */
.screen { display: none; }
.screen.visible { display: flex; }

/* Login */
#login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #1a2744 100%);
}
.login-logo { width: 120px; height: 120px; margin-bottom: 32px; }
.login-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 48px;
    max-width: 300px;
}
.google-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: var(--text-primary);
    color: #1f2937;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}
.google-btn:hover { transform: translateY(-2px); }
.google-btn:active { transform: translateY(0); }
.google-btn svg { width: 20px; height: 20px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}
.modal-overlay.visible { display: flex; }
.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 1.25rem; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-body h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-green);
    margin: 16px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.modal-body h4:first-child { margin-top: 0; }
.modal-body p, .modal-body li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.modal-body ul { list-style: none; padding-left: 16px; }
.modal-body li::before {
    content: "•";
    color: var(--accent-green);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}
.modal-footer { padding: 0 24px 24px; display: flex; gap: 12px; }

/* Buttons */
.btn {
    flex: 1;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary { background: var(--accent-green); color: #0f172a; }
.btn-primary:hover { background: var(--accent-green-light); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-secondary:hover { background: #475569; }
.btn.full-width { width: 100%; margin-top: 16px; }

/* App Container */
.app-container { display: none; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app-container.visible { display: flex; }

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 36px; height: 36px; }
.header-title { font-size: 1.25rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 12px; }
.lang-select {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    cursor: pointer;
    object-fit: cover;
}

/* User Menu */
.user-menu {
    position: absolute;
    top: 60px;
    right: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
    overflow: hidden;
    z-index: 200;
    border: 1px solid var(--border-color);
}
.user-menu.visible { display: block; }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.user-menu-item:hover { background: var(--bg-tertiary); }
.user-menu-item.danger { color: var(--accent-red); }
.user-menu-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* Main Content */
.main-content { flex: 1; padding: 20px; padding-bottom: 40px; }

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: var(--radius);
}
.tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.tab.active { background: var(--accent-green); color: #0f172a; }
.tab:not(.active):hover { color: var(--text-primary); background: var(--bg-tertiary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Camera */
.camera-section { text-align: center; }
.camera-preview {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 24px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-secondary);
    aspect-ratio: 4/3;
}
.camera-preview video, .camera-preview img { width: 100%; height: 100%; object-fit: cover; }
.camera-preview .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 16px;
}
.camera-controls { display: flex; justify-content: center; align-items: center; gap: 24px; margin-bottom: 24px; }
.camera-btn {
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-btn.primary {
    width: 72px;
    height: 72px;
    background: var(--accent-green);
    color: #0f172a;
}
.camera-btn.primary:hover { background: var(--accent-green-light); transform: scale(1.05); }
.camera-btn.secondary {
    width: 52px;
    height: 52px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.camera-btn.secondary:hover { background: #475569; }

/* Analysis Result */
.analysis-result {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
}
.analysis-result h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 16px; }
.foods-list { margin-bottom: 20px; }
.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.food-item:last-child { border-bottom: none; }
.food-name { font-weight: 500; }
.food-portion { color: var(--text-secondary); font-size: 0.875rem; }
.nutrition-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}
.nutrition-item { text-align: center; }
.nutrition-value { font-size: 1.25rem; font-weight: 600; color: var(--accent-green); }
.nutrition-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; }

/* Dashboard */
.period-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.period-btn {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.period-btn.active { background: var(--accent-green); color: #0f172a; border-color: var(--accent-green); }
.period-btn:not(.active):hover { border-color: var(--text-secondary); color: var(--text-primary); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
}
.stat-icon { font-size: 2rem; margin-bottom: 8px; }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 0.875rem; color: var(--text-secondary); }
.stat-card.calories .stat-value { color: var(--accent-orange); }
.stat-card.proteins .stat-value { color: var(--accent-blue); }
.stat-card.carbs .stat-value { color: var(--accent-purple); }
.stat-card.lipids .stat-value { color: var(--accent-green); }

.vitamins-section, .meals-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.vitamins-section h3, .meals-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}
.vitamins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
.vitamin-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.vitamin-name { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase; }
.vitamin-value { font-size: 1rem; font-weight: 600; color: var(--accent-green); }

.meals-count { font-size: 3rem; font-weight: 700; color: var(--accent-green); text-align: center; }

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    opacity: 0;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }

/* Confirm Dialog */
.confirm-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1002;
}
.confirm-dialog.visible { display: flex; }
.confirm-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}
.confirm-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 12px; }
.confirm-message { color: var(--text-secondary); margin-bottom: 24px; }
.confirm-buttons { display: flex; gap: 12px; }

/* Responsive */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.5rem; }
    .period-selector { gap: 6px; }
    .period-btn { padding: 8px 12px; font-size: 0.8125rem; }
}
