/* =============================================================
   myDiary — Premium Dark Theme
   ============================================================= */

:root {
    --bg: #0D0D0D;
    --bg-card: #1A1A1A;
    --bg-card-hover: #222222;
    --bg-input: #151515;
    --border: #2A2A2A;
    --accent: #7E38BB;
    --accent-light: #9B5DD4;
    --accent-dark: #5E2190;
    --accent-glow: rgba(126, 56, 187, 0.15);
    --text: #F0F0F0;
    --text-secondary: #999999;
    --text-muted: #666666;
    --success: #22C55E;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
table { border-collapse: collapse; width: 100%; }

/* =============================================================
   NAVBAR
   ============================================================= */
.navbar {
    background: rgb(13, 13, 13);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0 1rem;
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-light);
    letter-spacing: -0.5px;
}
.nav-brand:hover { color: var(--accent); }
.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.nav-link {
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-link:hover { color: var(--text); background: var(--bg-card); }
.nav-link.active { color: var(--accent-light); background: var(--accent-glow); }
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
}
.nav-username { color: var(--text-muted); font-size: 0.8rem; }
.nav-logout { color: var(--danger) !important; }
.nav-logout:hover { background: rgba(239, 68, 68, 0.1) !important; }

/* Mobile nav */
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; }
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    margin: 5px 0;
    transition: all var(--transition);
    border-radius: 2px;
}

/* Sidebar overlay */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.nav-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; z-index: 1001; }
    .nav-menu {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 270px;
        max-width: 80vw;
        background: rgb(13, 13, 13);
        backdrop-filter: blur(20px);
        border-right: 1px solid var(--border);
        flex-direction: column;
        padding: 5rem 1rem 1.5rem;
        gap: 0.25rem;
        z-index: 1000;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .nav-menu.open {
        transform: translateX(0);
    }
    .nav-link { width: 100%; padding: 0.75rem 1rem; }
    .nav-user {
        border-left: none;
        border-top: 1px solid var(--border);
        margin-left: 0;
        padding-left: 0;
        padding-top: 0.75rem;
        margin-top: auto;
        width: 100%;
        justify-content: space-between;
    }
    /* Hamburger animation to X */
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
}

/* =============================================================
   LAYOUT
   ============================================================= */
.main-content {
    min-height: calc(100vh - 60px);
    padding-bottom: 2rem;
}
.main-content.guest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* =============================================================
   PAGE HEADER
   ============================================================= */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}
.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =============================================================
   CARDS
   ============================================================= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    animation: fadeInUp 0.3s ease;
}
.card:hover {
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: -0.3px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   BUTTONS
   ============================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    gap: 0.5rem;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 12px rgba(126, 56, 187, 0.3);
}
.btn-primary:hover {
    background: var(--accent-light);
    color: white;
    box-shadow: 0 4px 20px rgba(126, 56, 187, 0.4);
    transform: translateY(-1px);
}
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--bg-card);
}
.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* =============================================================
   FORMS
   ============================================================= */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem; /* min 16px to prevent iOS auto-zoom */
    font-family: var(--font);
    transition: all var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder {
    color: var(--text-muted);
}
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}
.form-grid .form-group { margin-bottom: 0; }
.form-group-wide { grid-column: 1 / -1; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid-4 { grid-template-columns: 1fr 1fr; }
}

.checkbox-group { margin-bottom: 1rem; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.checkbox-text { font-size: 0.9rem; color: var(--text-secondary); }

/* =============================================================
   AUTH PAGES
   ============================================================= */
.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 1rem;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.auth-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-light);
    margin-bottom: 0.25rem;
    letter-spacing: -1px;
}
.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}
.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.auth-form { text-align: left; }
.auth-form .form-group { margin-bottom: 1.25rem; }
.auth-switch {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.auth-features {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.feature-icon { font-size: 1.5rem; }

/* =============================================================
   FLASH MESSAGES
   ============================================================= */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}
.flash-success { background: rgba(34, 197, 94, 0.12); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.25); }
.flash-error { background: rgba(239, 68, 68, 0.12); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   TABLES
   ============================================================= */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(42, 42, 42, 0.5);
    vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.food-name-cell { display: flex; flex-direction: column; gap: 2px; }
.food-name-cell small { display: block; }
.action-cell {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* =============================================================
   BADGES
   ============================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-verified {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}
.badge-pending {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

/* =============================================================
   SEARCH
   ============================================================= */
.search-row {
    display: flex;
    gap: 0.5rem;
}
.search-row .form-control { flex: 1; }

/* =============================================================
   DASHBOARD — CALORIES
   ============================================================= */
.calories-card {
    border-color: var(--accent-dark);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(126, 56, 187, 0.04) 100%);
}
.calories-display {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.calories-current {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
}
.calories-separator {
    color: var(--text-muted);
    font-size: 1.5rem;
}
.calories-target {
    font-size: 1.25rem;
    color: var(--text-secondary);
}
.calories-over {
    font-size: 0.85rem;
    color: var(--danger);
    font-weight: 600;
}
.calories-remaining {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Progress Bar */
.progress-bar-wrapper {
    width: 100%;
    height: 10px;
    background: var(--bg);
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.progress-bar {
    height: 100%;
    border-radius: 50px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.progress-bar-accent {
    background: linear-gradient(90deg, var(--accent-dark), var(--accent-light));
    box-shadow: 0 0 12px rgba(126, 56, 187, 0.4);
}
.progress-bar-danger {
    background: linear-gradient(90deg, var(--danger), #FF6B6B);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

/* Meal Breakdown (on dashboard) */
.meal-breakdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}
.meal-breakdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.meal-breakdown-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.meal-breakdown-value {
    font-size: 0.85rem;
    font-weight: 600;
}

@media (max-width: 600px) {
    .meal-breakdown { grid-template-columns: repeat(2, 1fr); }
    .calories-current { font-size: 2rem; }
}

/* =============================================================
   DASHBOARD — MACROS
   ============================================================= */
.macros-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.macro-card {
    text-align: center;
    padding: 1.25rem;
}
.macro-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.macro-chart-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}
.macro-chart { width: 100px; height: 100px; }
.macro-info {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.25rem;
}
.macro-consumed {
    font-size: 1.25rem;
    font-weight: 700;
}
.macro-target {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.macro-over {
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 600;
}
.macro-remaining {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .macros-grid { grid-template-columns: 1fr; }
    .macro-card { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem 1rem; text-align: left; align-items: center; }
    .macro-title { grid-column: 1 / -1; margin-bottom: 0; }
    .macro-chart-container { margin-bottom: 0; }
}

/* =============================================================
   DASHBOARD — WEIGHT
   ============================================================= */
.weight-dashboard-card .weight-stats,
.weight-overview .weight-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.weight-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}
.weight-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.weight-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.weight-stat-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* Weight Chart */
.weight-chart-wrapper {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
}
.weight-chart-wrapper canvas {
    display: block;
    width: 100%;
}

/* Total Change Summary */
.weight-total-change {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.weight-total-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}
.weight-total-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.weight-total-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Weight History List */
.weight-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.weight-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: background 0.15s;
}
.weight-entry:hover {
    background: rgba(255,255,255,0.06);
}
.weight-entry-main {
    flex: 1;
    min-width: 0;
}
.weight-entry-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}
.weight-entry-value {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.weight-entry-value small {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}
.weight-entry-side {
    flex-shrink: 0;
}
.weight-entry-change {
    display: inline-block;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.weight-entry-change.change-down {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}
.weight-entry-change.change-up {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}
.weight-entry-change.change-same {
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}
.weight-entry-change.change-first {
    background: rgba(126, 56, 187, 0.2);
    color: var(--accent);
    font-size: 0.65rem;
    letter-spacing: 1px;
}
.weight-entry-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.weight-entry-note {
    font-size: 0.85rem;
    cursor: default;
}

@media (max-width: 600px) {
    .weight-overview .weight-stats {
        gap: 0.75rem;
    }
    .weight-stat-value {
        font-size: 1.2rem;
    }
    .weight-stat-arrow {
        font-size: 1rem;
    }
    .weight-entry {
        padding: 0.6rem 0.75rem;
    }
    .weight-entry-value {
        font-size: 1.05rem;
    }
    .weight-entry-change {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    .weight-total-value {
        font-size: 1.3rem;
    }
}

/* =============================================================
   QUICK ACTIONS
   ============================================================= */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}
.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.25rem 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition);
    border: 1px solid transparent;
}
.action-btn:hover {
    color: var(--text);
    background: var(--bg-card-hover);
    border-color: var(--border);
    transform: translateY(-2px);
}
.action-icon { font-size: 1.5rem; }

@media (max-width: 600px) {
    .actions-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =============================================================
   MEALS PAGE
   ============================================================= */
.date-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.date-display {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 160px;
    text-align: center;
}

/* Day Summary */
.day-summary {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(126, 56, 187, 0.04) 100%);
    border-color: var(--accent-dark);
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    text-align: center;
}
.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.summary-value {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.summary-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Meal Cards */
.meal-card { padding: 0; overflow: hidden; }
.meal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background var(--transition);
}
.meal-header:hover { background: var(--bg-card-hover); }
.meal-header .card-title { margin-bottom: 0; font-size: 1rem; }
.meal-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.meal-cals {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.btn-add-food {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 1.1rem;
    border-radius: 50%;
}

/* Meal Items */
.meal-items {
    border-top: 1px solid var(--border);
}
.meal-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid rgba(42, 42, 42, 0.4);
    gap: 1rem;
    transition: background var(--transition);
}
.meal-item:last-child { border-bottom: none; }
.meal-item:hover { background: var(--bg-card-hover); }
.meal-item-info {
    flex: 1;
    min-width: 0;
}
.meal-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.meal-item-grams {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.meal-item-macros {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.meal-item-delete { flex-shrink: 0; }
.btn-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    line-height: 1;
}
.btn-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

@media (max-width: 600px) {
    .meal-item { flex-wrap: wrap; gap: 0.5rem; }
    .meal-item-macros { width: 100%; justify-content: space-between; padding-left: 0; }
}

/* Meal Add Form */
.meal-add-form {
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    animation: slideDown 0.2s ease;
}

/* Food Search Autocomplete */
.food-search-wrapper { position: relative; }
.food-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow);
}
.food-search-results.active { display: block; }
.food-result-item {
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(42, 42, 42, 0.4);
}
.food-result-item:hover { background: var(--bg-card-hover); }
.food-result-item:last-child { border-bottom: none; }
.food-result-name {
    font-size: 0.9rem;
    font-weight: 500;
}
.food-result-macros {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
}
.manual-macros { margin-top: 0.75rem; }
.manual-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-style: italic;
}
.calc-preview {
    display: none;
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: rgba(126, 56, 187, 0.1);
    border: 1px solid rgba(126, 56, 187, 0.25);
    border-radius: 8px;
}
.calc-preview-inner {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.calc-preview-inner span { white-space: nowrap; }
.calc-preview-inner .preview-cal { color: var(--accent); font-weight: 600; }

/* =============================================================
   WEIGHT PAGE
   ============================================================= */
.weight-form .form-grid { margin-bottom: 1rem; }
.weight-chart-wrapper {
    width: 100%;
    max-height: 250px;
    margin-bottom: 1.5rem;
    position: relative;
}
.weight-chart-wrapper canvas {
    width: 100% !important;
    height: 250px !important;
}

/* =============================================================
   MODAL
   ============================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.2s ease;
}
.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* =============================================================
   STREAK BADGE
   ============================================================= */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.streak-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.6rem 1rem;
    border-radius: 14px;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}
.streak-active {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 87, 34, 0.15));
    border: 1px solid rgba(255, 152, 0, 0.3);
}
.streak-zero {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}
.streak-fire {
    font-size: 1.4rem;
    line-height: 1;
}
.streak-count {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
}
.streak-active .streak-count {
    color: #FF9800;
}
.streak-zero .streak-count {
    color: var(--text-muted);
}
.streak-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    line-height: 1;
}

@media (max-width: 600px) {
    .streak-badge {
        padding: 0.4rem 0.7rem;
        min-width: 55px;
        border-radius: 10px;
    }
    .streak-fire { font-size: 1.1rem; }
    .streak-count { font-size: 1.2rem; }
}

/* =============================================================
   APP FOOTER
   ============================================================= */
.app-footer {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    opacity: 0.5;
}

/* =============================================================
   UTILITY
   ============================================================= */
.text-muted { color: var(--text-muted); }
.text-red { color: var(--danger); }
.text-green { color: var(--success); }
.text-success { color: var(--success); }
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* =============================================================
   SCROLLBAR
   ============================================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =============================================================
   PRINT
   ============================================================= */
@media print {
    .navbar, .btn, .btn-delete, .meal-add-form, .quick-actions { display: none !important; }
    body { background: white; color: black; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}
