:root {
    --primary: #4CAF50;
    --secondary: #2196F3;
    --dark: #2d3436;
    --light: #f7f9fc;
    --white: #ffffff;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e74c3c;

    /* Meal type colors */
    --breakfast: #f39c12;
    --lunch: #27ae60;
    --dinner: #3498db;
    --snack: #9b59b6;
    --coffee: #6f4e37;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--light);
    color: var(--dark);
}

body.modal-open {
    overflow: hidden;
}

body.ingredient-dragging {
    user-select: none;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* =====================================================
   Landing Page
   ===================================================== */
#landing-page {
    --landing-navy: #0d1b2a;
    --landing-ink: #1e293b;
    --landing-muted: #5b6678;
    --landing-surface: #ffffff;
    --landing-line: rgba(255, 255, 255, 0.55);
    --landing-mint: #22c55e;
    --landing-cyan: #06b6d4;
    background: radial-gradient(circle at 10% 10%, rgba(34, 197, 94, 0.18), transparent 38%),
        radial-gradient(circle at 90% 8%, rgba(6, 182, 212, 0.2), transparent 35%),
        linear-gradient(160deg, #f4fbf8 0%, #eef5fb 48%, #f8fafd 100%);
    min-height: 100vh;
    overflow: hidden;
}

.landing-shell {
    position: relative;
    padding: 28px 20px 44px;
}

.landing-glow {
    position: absolute;
    border-radius: 999px;
    filter: blur(18px);
    z-index: 0;
    opacity: 0.65;
}

.landing-glow-one {
    width: 300px;
    height: 300px;
    background: rgba(34, 197, 94, 0.18);
    top: 80px;
    left: -100px;
}

.landing-glow-two {
    width: 360px;
    height: 360px;
    background: rgba(14, 165, 233, 0.16);
    bottom: -120px;
    right: -140px;
}

.landing-container {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
}

.landing-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 46px;
}

.landing-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--landing-navy);
    letter-spacing: 0.01em;
}

.landing-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 28px;
    align-items: stretch;
}

.landing-hero-copy {
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 16px 40px rgba(13, 27, 42, 0.08);
    backdrop-filter: blur(6px);
    border-radius: 26px;
    padding: 34px 34px 38px;
}

.landing-kicker {
    margin: 0 0 12px;
    color: #00796b;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.02em;
    font-weight: 600;
}

.landing-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.1rem, 4vw, 3.3rem);
    color: var(--landing-navy);
    margin: 0 0 14px;
    line-height: 1.05;
}

.landing-subtitle {
    margin: 0;
    color: var(--landing-muted);
    line-height: 1.62;
    font-size: 1.05rem;
    font-family: 'Manrope', sans-serif;
}

.landing-actions {
    margin-top: 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.landing-note {
    color: #38526f;
    font-size: 0.93rem;
    font-family: 'Manrope', sans-serif;
}

.landing-cta {
    display: inline-block;
    text-decoration: none;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    padding: 12px 24px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    background: linear-gradient(135deg, #16a34a, #0ea5e9);
    color: #fff;
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.28);
}

.landing-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(22, 163, 74, 0.25);
}

.landing-cta-ghost {
    background: rgba(255, 255, 255, 0.7);
    color: var(--landing-ink);
    border: 1px solid rgba(13, 27, 42, 0.12);
    box-shadow: none;
}

.landing-cta-ghost:hover {
    box-shadow: 0 10px 20px rgba(13, 27, 42, 0.08);
}

.landing-preview-card {
    background: linear-gradient(165deg, #0d1b2a 0%, #172a46 100%);
    color: #fff;
    border-radius: 26px;
    padding: 30px;
    box-shadow: 0 24px 42px rgba(10, 17, 31, 0.3);
}

.landing-preview-card h2 {
    margin: 0 0 18px;
    font-size: 1.65rem;
    font-family: 'Space Grotesk', sans-serif;
}

.landing-preview-card p {
    margin: 18px 0 0;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Manrope', sans-serif;
    line-height: 1.5;
}

.preview-chip {
    display: inline-flex;
    margin-bottom: 18px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid var(--landing-line);
    font-family: 'Manrope', sans-serif;
    font-size: 0.84rem;
    letter-spacing: 0.02em;
}

.preview-bars {
    height: 150px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    align-items: end;
}

.preview-bars span {
    border-radius: 10px 10px 4px 4px;
    background: linear-gradient(180deg, #22c55e, #06b6d4);
    animation: lift-in 0.7s ease forwards;
    transform-origin: bottom;
}

.landing-feature-row {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.landing-feature-card {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(13, 27, 42, 0.06);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 24px rgba(13, 27, 42, 0.06);
}

.landing-feature-card h3 {
    margin: 0 0 8px;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--landing-ink);
}

.landing-feature-card p {
    margin: 0;
    color: var(--landing-muted);
    font-family: 'Manrope', sans-serif;
    line-height: 1.5;
    font-size: 0.95rem;
}

@keyframes lift-in {
    0% {
        transform: scaleY(0.2);
        opacity: 0.4;
    }
    100% {
        transform: scaleY(1);
        opacity: 1;
    }
}

@media (max-width: 940px) {
    .landing-hero-grid {
        grid-template-columns: 1fr;
    }

    .landing-preview-card {
        padding: 24px;
    }

    .landing-feature-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 580px) {
    .landing-shell {
        padding: 18px 14px 30px;
    }

    .landing-topbar {
        margin-bottom: 20px;
    }

    .landing-brand {
        font-size: 1.2rem;
    }

    .landing-hero-copy {
        border-radius: 20px;
        padding: 24px 20px 26px;
    }

    .landing-subtitle {
        font-size: 0.98rem;
    }

    .landing-cta {
        width: 100%;
        text-align: center;
    }

    .landing-cta-ghost {
        width: auto;
        font-size: 0.9rem;
        padding: 9px 16px;
    }

    .landing-note {
        font-size: 0.85rem;
    }
}

.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

/* App Dashboard */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.logo {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-link-btn {
    border: 1px solid #d4dbe4;
    background: #f9fbff;
    color: #334155;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.nav-link-btn:hover {
    background: #eef4ff;
    border-color: #b9c7d8;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--dark);
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--light);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#user-email {
    color: #666;
    font-size: 0.9rem;
}

#logout-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

#logout-btn:hover {
    background: var(--light);
}

/* Daily Summary */
.daily-summary {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

.summary-header h2 {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    font-size: 1.5rem;
}

#today-date {
    color: #666;
    font-size: 0.9rem;
}

.calorie-progress {
    text-align: center;
}

.progress-info {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.progress-info .separator {
    color: #ccc;
    margin: 0 4px;
}

.progress-info .unit {
    font-size: 1rem;
    font-weight: 400;
    color: #666;
}

.progress-info .editable {
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.progress-info .editable:hover {
    background: rgba(76, 175, 80, 0.15);
    color: var(--primary);
}

.progress-bar-container {
    background: #e0e0e0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-container.small {
    height: 8px;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--success);
    border-radius: 10px;
    transition: width 0.3s ease, background 0.3s ease;
}

.progress-bar.near {
    background: var(--warning);
}

.progress-bar.over {
    background: var(--danger);
}

.progress-remaining {
    color: #666;
    font-size: 0.9rem;
}

/* Upload Section */
.upload-section {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s ease;
    border: 2px solid transparent;
}

.upload-section h3 {
    font-family: 'Montserrat', sans-serif;
    margin: 0 0 16px 0;
    font-size: 1.2rem;
    transition: color 0.3s ease;
}

/* Upload Mode Selector */
.upload-mode-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.upload-mode-option {
    flex: 1;
    cursor: pointer;
}

.upload-mode-option input[type="radio"] {
    display: none;
}

.mode-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 2px solid #ddd;
    background: var(--light);
}

.mode-label svg {
    flex-shrink: 0;
}

.upload-mode-option input[type="radio"]:checked + .mode-label.mode-add {
    border-color: var(--success);
    background: rgba(0, 184, 148, 0.1);
    color: var(--success);
}

.upload-mode-option input[type="radio"]:checked + .mode-label.mode-deduct {
    border-color: #e67e22;
    background: rgba(230, 126, 34, 0.1);
    color: #e67e22;
}

.mode-label:hover {
    border-color: #bbb;
}

/* Upload Hint */
.upload-hint {
    font-size: 0.85rem;
    color: #888;
    margin: -8px 0 16px 0;
}

/* Deduct Mode Styles */
.upload-section.deduct-mode {
    border-color: var(--warning);
}

.upload-section.deduct-mode h3 {
    color: #e67e22;
}

.deduct-drop-zone {
    border-color: #f0c674 !important;
}

.deduct-drop-zone:hover,
.deduct-drop-zone.dragover {
    border-color: var(--warning) !important;
    background: rgba(253, 203, 110, 0.1) !important;
}

.btn-deduct {
    background: #e67e22 !important;
}

.btn-deduct:hover {
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.4) !important;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-area {
    border: 2px dashed #ccc;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    background: var(--light);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(76, 175, 80, 0.05);
}

.upload-area p {
    margin: 0 0 16px 0;
    color: #666;
}

.upload-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-secondary,
.btn-camera,
.btn-mic {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-secondary:hover,
.btn-camera:hover,
.btn-mic:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

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

.btn-camera:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-mic {
    background: #ef4444;
    font-size: 1.05rem;
    line-height: 1;
    touch-action: none;
    user-select: none;
}

.btn-mic:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.45);
}

.btn-mic.recording {
    background: #dc2626;
    animation: micPulse 1.1s ease-in-out infinite;
}

.btn-mic:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.audio-recorder-visual {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    background: rgba(254, 226, 226, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.audio-recorder-visual.hidden {
    display: none;
}

.recorder-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #b91c1c;
    white-space: nowrap;
}

.waveform-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 20px;
}

.waveform-bars span {
    width: 3px;
    background: #ef4444;
    border-radius: 999px;
    animation: waveform 1s ease-in-out infinite;
    transform-origin: bottom center;
}

.waveform-bars span:nth-child(3n) { animation-duration: 0.8s; }
.waveform-bars span:nth-child(4n) { animation-duration: 1.2s; }
.waveform-bars span:nth-child(5n) { animation-duration: 0.95s; }
.waveform-bars span:nth-child(2n) { animation-delay: 0.08s; }

@keyframes waveform {
    0%, 100% { height: 4px; opacity: 0.55; }
    50% { height: 20px; opacity: 1; }
}

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

.meal-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meal-options-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.option-group {
    flex: 1;
    min-width: 0;
}

.option-group label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.option-group input,
.option-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: var(--white);
}

.option-group input:focus,
.option-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Deduct Meal Selection */
.deduct-meal-options {
    margin-top: 12px;
    padding: 12px;
    background: rgba(231, 76, 60, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.deduct-meal-options.hidden {
    display: none;
}

.deduct-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--danger);
    margin-bottom: 10px;
}

.deduct-meal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.deduct-meal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.deduct-meal-item:hover {
    background: var(--surface);
}

.deduct-meal-item input[type="radio"] {
    accent-color: var(--danger);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.deduct-meal-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.deduct-meal-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deduct-meal-meta {
    font-size: 0.75rem;
    color: #666;
}

.deduct-meal-calories {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.no-meals-hint {
    font-size: 0.85rem;
    color: #888;
    text-align: center;
    padding: 12px;
}

.no-meals-hint.hidden {
    display: none;
}

/* Loading Indicator */
#loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    color: var(--primary);
    font-weight: 500;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Calendar Section */
.calendar-section {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

.calendar-header h3 {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    font-size: 1.3rem;
}

.nav-btn {
    background: var(--light);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--dark);
    transition: background 0.2s;
}

.nav-btn:hover {
    background: #e0e0e0;
}

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

.calendar-weekdays span {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    padding: 8px 0;
}

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

.calendar-day {
    min-height: 80px;
    padding: 8px;
    background: var(--light);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.calendar-day:hover {
    background: #e8eaed;
    transform: scale(1.02);
}

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

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

.calendar-day.today {
    border: 2px solid var(--primary);
}

.calendar-day.has-meals {
    background: #e8f5e9;
}

.calendar-day.over-goal {
    background: #ffebee;
}

.calendar-day.near-goal {
    background: #fff8e1;
}

.calendar-day.drag-target {
    background: #e3f2fd;
    box-shadow: inset 0 0 0 2px var(--secondary);
}

.copy-tooltip {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(33, 150, 243, 0.95);
    color: #fff;
    font-size: 0.65rem;
    padding: 4px 6px;
    border-radius: 6px;
    pointer-events: none;
    z-index: 2;
    white-space: nowrap;
}

.copy-tooltip.hidden {
    display: none;
}

.day-number {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.day-calories {
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
}

.day-progress {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.day-progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
}

.calendar-day.over-goal .day-progress-fill {
    background: var(--danger);
}

.calendar-day.near-goal .day-progress-fill {
    background: var(--warning);
}

.day-thumbnails {
    display: flex;
    gap: 2px;
    margin-top: auto;
    flex-wrap: wrap;
}

.day-thumbnail {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}

.more-meals {
    font-size: 0.65rem;
    color: #888;
    display: flex;
    align-items: center;
}

/* Day Detail View */
.day-detail {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.day-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-right: 40px;
    position: relative;
}

.day-detail-header h3 {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.close-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    padding: 8px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-btn:hover {
    color: var(--dark);
    background: var(--light);
}

.day-summary {
    font-size: 0.9rem;
    color: #666;
    flex-shrink: 0;
}

.meals-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meal-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--light);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    position: relative;
}

.meal-card:hover {
    background: #e8eaed;
    transform: translateX(4px);
}

.meal-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.meal-info {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.meal-time-display {
    color: #888;
    font-size: 0.85rem;
}

.meal-calories {
    font-weight: 600;
    margin-left: auto;
}

.meal-deducted-note {
    margin-left: auto;
    font-size: 0.78rem;
    color: #0f766e;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    padding: 2px 8px;
}

.delete-meal-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #888;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.delete-meal-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.no-meals {
    text-align: center;
    color: #888;
    padding: 20px;
}

/* Meal Type Badges */
.meal-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.meal-badge.fruehstueck {
    background: rgba(243, 156, 18, 0.15);
    color: var(--breakfast);
}

.meal-badge.mittagessen {
    background: rgba(39, 174, 96, 0.15);
    color: var(--lunch);
}

.meal-badge.abendessen {
    background: rgba(52, 152, 219, 0.15);
    color: var(--dinner);
}

.meal-badge.snack {
    background: rgba(155, 89, 182, 0.15);
    color: var(--snack);
}

.meal-badge.kaffee {
    background: rgba(111, 78, 55, 0.15);
    color: var(--coffee);
}

.meal-badge.clickable {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.meal-badge.clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.meal-type-select {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 2px solid var(--primary);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    outline: none;
}

.meal-type-select.hidden {
    display: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    overscroll-behavior: contain;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    position: relative;
    overscroll-behavior: contain;
}

.modal-content .close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1;
}

.modal-content .close:hover {
    opacity: 0.8;
}

#modal-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

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

#modal-meal-datetime {
    color: #888;
    font-size: 0.9rem;
}

.clickable-time {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.clickable-time:hover {
    background: rgba(33, 150, 243, 0.1);
    color: var(--secondary);
}

.modal-time-input {
    padding: 4px 8px;
    border: 2px solid var(--secondary);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--white);
    outline: none;
}

.modal-time-input.hidden {
    display: none;
}

.modal-body h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
}

.ingredients-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ingredient-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--light);
    border-radius: 8px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ingredient-item.dragging {
    opacity: 0.5;
}

.ingredient-name {
    flex: 1;
    font-weight: 500;
}

.ingredient-quantity {
    color: #888;
    margin-right: 16px;
}

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

.no-ingredients {
    color: #888;
    text-align: center;
    padding: 20px;
}

.ingredient-trash {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(235, 87, 87, 0.95);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 12px 24px rgba(235, 87, 87, 0.35);
    z-index: 5;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.ingredient-trash.hidden {
    display: none;
}

.ingredient-trash.hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 16px 32px rgba(235, 87, 87, 0.45);
}

.ingredient-trash-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.ingredient-trash-label {
    font-size: 0.9rem;
}

.ingredient-ghost {
    position: fixed;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2000;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    opacity: 0.9;
}

.modal-total {
    padding: 16px;
    background: var(--light);
    border-radius: 8px;
    text-align: right;
    font-size: 1.1rem;
}

.modal-deduction-info {
    margin-top: 8px;
    font-size: 0.88rem;
    color: #0f766e;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 8px 10px;
}

#modal-total-calories {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.3rem;
}

/* Reanalyze Section */
.reanalyze-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    color: #888;
    transition: background 0.2s, color 0.2s;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reanalyze-toggle-btn:hover {
    background: rgba(76, 175, 80, 0.1);
    color: var(--primary);
}

.reanalyze-section {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.reanalyze-section.hidden {
    display: none;
}

.reanalyze-textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    resize: vertical;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s;
}

.reanalyze-textarea:focus {
    border-color: var(--primary);
}

.reanalyze-submit-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}

.reanalyze-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.reanalyze-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Calorie Adjustment Slider */
.calorie-adjustment {
    margin-top: 16px;
    padding: 16px;
    background: var(--light);
    border-radius: 8px;
}

.calorie-adjustment label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 4px;
    outline: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#slider-value {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--primary);
}

/* Settings Modal */
.settings-content {
    padding: 24px;
}

.settings-content h2 {
    font-family: 'Montserrat', sans-serif;
    margin: 0 0 24px 0;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.setting-group label {
    font-weight: 500;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-unit input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1.1rem;
}

.input-with-unit .unit {
    color: #888;
}

.version-info {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 0.75rem;
    color: #999;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 4px;
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    z-index: 2001;
    line-height: 1;
}

.close-lightbox:hover {
    opacity: 0.8;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    animation: slideUp 0.3s ease-out;
}

.toast.hidden {
    display: none;
}

.toast.error {
    background: var(--danger);
}

.toast button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 5px 15px;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.toast button:hover {
    background: rgba(255, 255, 255, 0.1);
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* PWA Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--dark);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    z-index: 4000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
}

.install-banner span {
    font-weight: 500;
}

.install-banner-buttons {
    display: flex;
    gap: 10px;
}

.btn-install {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-dismiss {
    background: transparent;
    color: #aaa;
    border: 1px solid #555;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Floating Camera Button (FAB) */
.camera-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
    z-index: 800;
    transition: transform 0.2s, box-shadow 0.2s;
}

.camera-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.camera-fab:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 768px) {
    nav {
        padding: 12px 16px;
    }

    .nav-actions {
        gap: 8px;
    }

    .nav-link-btn {
        padding: 6px 10px;
        font-size: 0.82rem;
    }

    #user-email {
        display: none;
    }

    .container {
        padding: 12px;
    }

    .daily-summary,
    .upload-section,
    .calendar-section,
    .day-detail {
        padding: 16px;
        border-radius: 12px;
    }

    .progress-info {
        font-size: 1.5rem;
    }

    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .day-calories {
        font-size: 0.65rem;
    }

    .day-thumbnails {
        display: none;
    }

    .mode-label {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .meal-options-row .option-group input {
        padding: 8px 6px;
        font-size: 0.9rem;
    }

    .modal-content {
        max-height: 95vh;
        border-radius: 12px;
    }

    #modal-image {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .install-banner {
        flex-direction: column;
        text-align: center;
        padding: 14px;
    }

    .install-banner-buttons {
        width: 100%;
        justify-content: center;
    }

    .calendar-weekdays span {
        font-size: 0.7rem;
    }

    .calendar-day {
        min-height: 50px;
    }

    .meal-card {
        padding: 8px;
        gap: 10px;
    }

    .meal-thumbnail {
        width: 50px;
        height: 50px;
    }

    .meal-info {
        font-size: 0.85rem;
    }
}

/* =====================================================
   Stats Page Styles
   ===================================================== */

/* Stats Page Container - Full screen overlay */
#stats-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--light);
    z-index: 900;
    overflow-y: auto;
    padding: 0;
}

#stats-page.hidden {
    display: none;
}

/* Stats Header */
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 16px 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.stats-header h2 {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    font-size: 1.3rem;
    color: var(--dark);
    flex: 1;
    text-align: center;
}

.stats-header .close-btn {
    position: static;
    transform: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.stats-header .close-btn:hover {
    color: var(--dark);
    background: var(--light);
}

.settings-header .close-btn {
    position: static;
    transform: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.settings-header .close-btn:hover {
    color: var(--dark);
    background: var(--light);
}

.admin-header .close-btn {
    position: static;
    transform: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.admin-header .close-btn:hover {
    color: var(--dark);
    background: var(--light);
}

/* Time Range Dropdown */
#stats-range {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--white);
    color: var(--dark);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 140px;
}

#stats-range:hover {
    border-color: #bbb;
}

#stats-range:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* =====================================================
   Settings Page Styles
   ===================================================== */

#settings-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--light);
    z-index: 900;
    overflow-y: auto;
    padding: 0;
}

#settings-page.hidden {
    display: none;
}

#admin-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--light);
    z-index: 900;
    overflow-y: auto;
    padding: 0;
}

#admin-page.hidden {
    display: none;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 16px 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-header h2 {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    font-size: 1.3rem;
    color: var(--dark);
    flex: 1;
    text-align: center;
}

.admin-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 20px;
}

.admin-uploads-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-upload-card {
    background: var(--white);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.admin-upload-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.admin-upload-user {
    font-weight: 600;
    color: #1f2937;
}

.admin-upload-meta {
    color: #6b7280;
    font-size: 0.85rem;
}

.admin-upload-kcal {
    font-weight: 700;
    color: #0f766e;
    white-space: nowrap;
}

.admin-upload-image {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: 10px;
    background: #eef2f7;
}

.admin-upload-info {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    color: #475569;
    font-size: 0.9rem;
}

.admin-reevaluate-btn {
    border: 1px solid #c4d2e4;
    background: #f0f7ff;
    color: #0f3f7a;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.admin-reevaluate-btn:hover:not(:disabled) {
    background: #e2f0ff;
}

.admin-reevaluate-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.admin-analysis-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.admin-analysis-column h4 {
    margin: 0 0 8px;
    font-size: 0.92rem;
    color: #334155;
}

.admin-new-summary {
    font-size: 0.84rem;
    color: #475569;
    margin-bottom: 8px;
}

.admin-gemini-raw {
    margin: 12px 0 0;
    background: #0f172a;
    color: #cbd5e1;
    border-radius: 10px;
    padding: 12px;
    line-height: 1.45;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 360px;
    overflow: auto;
}

.admin-state {
    text-align: center;
    color: #64748b;
    padding: 12px 0;
}

.admin-sentinel {
    height: 1px;
}

@media (max-width: 768px) {
    .admin-analysis-columns {
        grid-template-columns: 1fr;
    }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 16px 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.settings-header h2 {
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    font-size: 1.3rem;
    color: var(--dark);
    flex: 1;
    text-align: center;
}

.settings-content-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-section {
    background: var(--white);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.settings-section h3 {
    font-family: 'Montserrat', sans-serif;
    margin: 0 0 12px 0;
    font-size: 1.1rem;
}

.settings-help {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 0.95rem;
}

.settings-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.4;
    resize: vertical;
    font-family: 'Inter', sans-serif;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Stat Cards */
.stat-card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.stat-card h3 {
    font-family: 'Montserrat', sans-serif;
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    color: var(--dark);
    border-bottom: 2px solid var(--light);
    padding-bottom: 12px;
}

.stat-content {
    min-height: 150px;
}

/* Horizontal Bar Charts */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.bar-name {
    color: var(--dark);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.bar-value {
    color: #666;
    font-size: 0.85rem;
    font-weight: 600;
}

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

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    background: var(--primary);
}

/* Bar color variations */
.bar-fill.breakfast { background: var(--breakfast); }
.bar-fill.lunch { background: var(--lunch); }
.bar-fill.dinner { background: var(--dinner); }
.bar-fill.snack { background: var(--snack); }
.bar-fill.coffee { background: var(--coffee); }
.bar-fill.success { background: var(--success); }
.bar-fill.secondary { background: var(--secondary); }

/* Donut Chart Container */
.donut-chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 12px 0;
}

/* Donut Chart using conic-gradient */
.donut-chart {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(
        var(--breakfast) 0deg 72deg,
        var(--lunch) 72deg 144deg,
        var(--dinner) 144deg 216deg,
        var(--snack) 216deg 288deg,
        var(--coffee) 288deg 360deg
    );
    position: relative;
    flex-shrink: 0;
}

.donut-chart::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    background: var(--white);
    border-radius: 50%;
}

.donut-chart::after {
    content: attr(data-total);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
}

/* Donut Legend */
.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-color.breakfast { background: var(--breakfast); }
.legend-color.lunch { background: var(--lunch); }
.legend-color.dinner { background: var(--dinner); }
.legend-color.snack { background: var(--snack); }
.legend-color.coffee { background: var(--coffee); }

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

.legend-value {
    color: #888;
    margin-left: auto;
}

/* Daily Trends Chart */
.trend-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    height: 120px;
    padding: 12px 0;
}

.trend-bar {
    flex: 1;
    min-width: 0;
    background: var(--light);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: background 0.2s;
    cursor: pointer;
}

.trend-bar:hover {
    background: rgba(33, 150, 243, 0.3);
}

.trend-bar .fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--secondary);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}

.trend-bar.over .fill {
    background: var(--danger);
}

.trend-bar.near .fill {
    background: var(--warning);
}

.trend-bar .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 4px;
}

.trend-bar:hover .tooltip {
    opacity: 1;
}

.trend-labels {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--light);
}

.trend-labels span {
    font-size: 0.7rem;
    color: #888;
}

/* Meal Times Distribution */
.time-distribution {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.time-slot {
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-label {
    width: 80px;
    font-size: 0.85rem;
    color: var(--dark);
    font-weight: 500;
}

.time-bar-track {
    flex: 1;
    height: 24px;
    background: var(--light);
    border-radius: 12px;
    overflow: hidden;
}

.time-bar-fill {
    height: 100%;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    transition: width 0.5s ease;
}

.time-bar-fill span {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Tips Section */
.tips-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 24px;
}

.tips-section h3 {
    font-family: 'Montserrat', sans-serif;
    margin: 0 0 16px 0;
    font-size: 1.2rem;
    color: var(--dark);
}

.tips-section .btn-secondary {
    margin-bottom: 16px;
}

/* Tips Cards Container */
.tips-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

/* Individual Tip Card */
.tip-card {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.tip-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.tip-icon {
    font-size: 2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    border-radius: 12px;
}

.tip-content {
    flex: 1;
    min-width: 0;
}

.tip-content h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--dark);
}

.tip-content p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

/* Tips Timestamp */
.tips-timestamp {
    color: #888;
    font-size: 0.8rem;
    margin-top: 12px;
    text-align: right;
}

/* Tips Empty State */
.tips-empty {
    color: #888;
    text-align: center;
    padding: 24px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Button Spinner for Tips Generation */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.btn-secondary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Stats Loading State */
.stat-content.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

.stat-content.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 12px;
}

/* Stats Empty State */
.stat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    text-align: center;
    padding: 20px;
}

.stat-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.stat-empty p {
    margin: 0;
    font-size: 0.9rem;
}

/* Stats Page Responsive Styles */
@media (max-width: 768px) {
    .stats-header {
        padding: 12px 16px;
    }

    .stats-header h2 {
        font-size: 1.1rem;
    }

    #stats-range {
        padding: 6px 10px;
        font-size: 0.85rem;
        min-width: 120px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .stat-card {
        padding: 16px;
        border-radius: 12px;
    }

    .stat-card h3 {
        font-size: 1rem;
        padding-bottom: 10px;
        margin-bottom: 14px;
    }

    .stat-content {
        min-height: 120px;
    }

    .donut-chart-container {
        flex-direction: column;
        gap: 16px;
    }

    .donut-chart {
        width: 120px;
        height: 120px;
    }

    .donut-legend {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    .tips-section {
        padding: 0 16px 16px;
    }

    .tips-cards {
        grid-template-columns: 1fr;
    }

    .tip-card {
        padding: 16px;
    }

    .tip-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .time-label {
        width: 60px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .stats-header .close-btn {
        font-size: 1.5rem;
        padding: 2px 6px;
    }

    #stats-range {
        min-width: 100px;
        font-size: 0.8rem;
    }

    .bar-label {
        font-size: 0.8rem;
    }

    .bar-name {
        max-width: 50%;
    }

    .trend-chart {
        height: 100px;
    }

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