/* =========================================
   Modern Health & Fitness Tracker v3.0
   Clean, Mobile-First Design
   ========================================= */

/* Import Modern Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=DM+Sans:wght@400;500;600;700&display=swap');

/* CSS Variables - Light Theme */
:root {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.2);
    
    /* Accent Colors */
    --accent-green: #10b981;
    --accent-green-light: #34d399;
    --accent-blue: #0ea5e9;
    --accent-orange: #f97316;
    --accent-pink: #ec4899;
    --accent-purple: #a855f7;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    
    /* Surfaces */
    --bg-base: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-input: #f1f5f9;
    
    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    /* Borders */
    --border: rgba(148, 163, 184, 0.2);
    --border-strong: rgba(148, 163, 184, 0.3);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.07), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-warning: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    --gradient-blue: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
    --gradient-mesh: radial-gradient(at 40% 20%, rgba(99, 102, 241, 0.08) 0px, transparent 50%), 
                     radial-gradient(at 80% 0%, rgba(236, 72, 153, 0.06) 0px, transparent 50%),
                     radial-gradient(at 0% 50%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
    
    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Spacing */
    --nav-height: 70px;
    --bottom-nav-height: 72px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-light: #a5b4fc;
    --primary-dark: #6366f1;
    --primary-glow: rgba(129, 140, 248, 0.25);
    
    --bg-base: #0f172a;
    --bg-elevated: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(30, 41, 59, 0.6);
    --bg-input: #1e293b;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border: rgba(71, 85, 105, 0.3);
    --border-strong: rgba(71, 85, 105, 0.5);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(129, 140, 248, 0.2);
    
    --gradient-mesh: radial-gradient(at 40% 20%, rgba(129, 140, 248, 0.1) 0px, transparent 50%), 
                     radial-gradient(at 80% 0%, rgba(236, 72, 153, 0.08) 0px, transparent 50%),
                     radial-gradient(at 0% 50%, rgba(16, 185, 129, 0.06) 0px, transparent 50%);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    background-image: var(--gradient-mesh);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
    transition: background var(--transition-base), color var(--transition-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Keyboard / accessibility: visible focus for interactive controls */
:focus {
    outline: none;
}
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.tab-btn:focus-visible,
.nav-item:focus-visible,
.icon-btn:focus-visible,
button:focus-visible,
a.user-avatar:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.btn-submit:focus-visible,
.btn-secondary:focus-visible,
.quick-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

/* =========================================
   Header / Top Navigation
   ========================================= */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.top-bar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.top-bar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--shadow-md);
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: transform var(--transition-fast);
    text-decoration: none;
}

.user-avatar:hover {
    transform: scale(1.05);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

/* =========================================
   Date Picker Section
   ========================================= */
.date-section {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.date-nav-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.date-display {
    text-align: center;
    flex: 1;
}

.date-display .day-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.date-display .date-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.date-picker-wrap {
    position: relative;
}

.date-picker-wrap input[type="date"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
}

.today-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.today-badge:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* =========================================
   Bottom Navigation (Mobile)
   ========================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 6px 2px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 44px;
    flex: 1;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
    color: var(--primary);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-glow);
}

.nav-item .nav-icon {
    font-size: 20px;
    transition: transform var(--transition-bounce);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-item .nav-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Desktop Tab Navigation */
.tabs {
    display: none;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: 14px 22px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.tab-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.tab-btn:active {
    transform: scale(0.97);
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md), 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.3s ease-out;
}

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

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   Cards Grid
   ========================================= */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.metric-card:active {
    transform: scale(0.98);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-accent, var(--gradient-primary));
}

.metric-card.calories { --card-accent: var(--accent-orange); }
.metric-card.calories::before { background: var(--gradient-warning); }
.metric-card.water { --card-accent: var(--accent-blue); }
.metric-card.water::before { background: var(--gradient-blue); }
.metric-card.protein { --card-accent: var(--accent-green); }
.metric-card.protein::before { background: var(--gradient-success); }
.metric-card.exercise { --card-accent: var(--accent-red); }
.metric-card.exercise::before { background: var(--gradient-danger); }
.metric-card.supplement { --card-accent: var(--accent-purple); }
.metric-card.supplement::before { background: linear-gradient(135deg, #a855f7 0%, #d946ef 100%); }
.metric-card.weight { --card-accent: var(--accent-pink); }
.metric-card.weight::before { background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%); }

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

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--bg-input);
}

.metric-card.calories .metric-icon { background: rgba(249, 115, 22, 0.1); }
.metric-card.water .metric-icon { background: rgba(14, 165, 233, 0.1); }
.metric-card.protein .metric-icon { background: rgba(16, 185, 129, 0.1); }
.metric-card.exercise .metric-icon { background: rgba(239, 68, 68, 0.1); }
.metric-card.supplement .metric-icon { background: rgba(168, 85, 247, 0.1); }
.metric-card.weight .metric-icon { background: rgba(236, 72, 153, 0.1); }

.metric-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 2px;
}

.metric-value .unit {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.metric-target {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric-remaining {
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-remaining.ok { color: var(--accent-green); }
.metric-remaining.over { color: var(--accent-red); }

/* Progress Ring */
.progress-ring-wrap {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 4;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--card-accent, var(--primary));
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--transition-slow);
}

.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Progress Bar (Linear) */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    transition: width var(--transition-slow);
}

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

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

.metric-card.calories .progress-fill { background: var(--gradient-warning); }
.metric-card.water .progress-fill { background: var(--gradient-blue); }
.metric-card.protein .progress-fill { background: var(--gradient-success); }
.metric-card.exercise .progress-fill { background: var(--gradient-danger); }
.metric-card.supplement .progress-fill { background: linear-gradient(135deg, #a855f7 0%, #d946ef 100%); }

/* =========================================
   Stats Row
   ========================================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.stat-pill {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 12px 8px;
    text-align: center;
}

.stat-pill .stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-pill .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =========================================
   Form Cards
   ========================================= */
.form-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.form-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-card h3 .form-icon {
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Form Elements */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    min-height: 50px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Quick Add Buttons */
.quick-add-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.quick-btn {
    padding: 12px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex: 1;
    min-width: 80px;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.quick-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.quick-btn:active {
    transform: scale(0.97);
}

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

/* Submit Button */
.btn-submit {
    width: 100%;
    padding: 18px 24px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--gradient-primary);
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-submit:active {
    transform: translateY(0) scale(0.98);
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

/* =========================================
   Entry Lists
   ========================================= */
.list-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.list-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
}

.list-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-count {
    font-size: 0.7rem;
    padding: 4px 10px;
    background: var(--primary-glow);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-weight: 600;
}

.list-body {
    max-height: 350px;
    overflow-y: auto;
}

.entry-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: background var(--transition-fast);
}

.entry-item:last-child {
    border-bottom: none;
}

.entry-item:hover {
    background: var(--bg-input);
}

.entry-info {
    flex: 1;
    min-width: 0;
}

.entry-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.entry-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.entry-delete {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.entry-delete:hover {
    background: var(--accent-red);
    color: white;
    transform: scale(1.1);
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* =========================================
   Tables (for detailed views)
   ========================================= */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

thead {
    background: var(--bg-input);
}

th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tbody tr:hover {
    background: var(--bg-input);
}

/* =========================================
   Badges
   ========================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge-warning { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge-info { background: rgba(14, 165, 233, 0.15); color: var(--accent-blue); }
.badge-primary { background: var(--primary-glow); color: var(--primary); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }

/* =========================================
   Supplement Checklist
   ========================================= */
.supplement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.supplement-item {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    position: relative;
}

.supplement-item:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.supplement-item.taken {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--accent-green);
}

.supplement-item .supp-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.supplement-item .supp-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.supplement-item .supp-dose {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.supplement-item .supp-check {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 14px;
    color: var(--accent-green);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.supplement-item.taken .supp-check {
    opacity: 1;
}

/* =========================================
   Charts & Analytics
   ========================================= */
.chart-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

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

.chart-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-container {
    height: 220px;
    position: relative;
}

.chart-subtitle {
    font-size: 0.8rem;
    margin: -8px 0 14px;
    line-height: 1.45;
}

.analytics-intro {
    padding: 14px 18px;
    margin-bottom: 16px;
}

.analytics-intro-text {
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0;
}

.analytics-table-caption {
    font-size: 0.78rem;
    margin: 0 0 12px;
    line-height: 1.4;
}

.analytics-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
}

.analytics-table {
    width: 100%;
    min-width: 280px;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.analytics-table th,
.analytics-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.analytics-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.analytics-table td:nth-child(2),
.analytics-table td:nth-child(3),
.analytics-table td:nth-child(4) {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.analytics-metric-name {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.analytics-metric-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

/* =========================================
   Alerts & Messages
   ========================================= */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.alert-warning {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    color: var(--accent-orange);
}

.alert-info {
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.2);
    color: var(--accent-blue);
}

/* =========================================
   Search
   ========================================= */
.search-wrap {
    position: relative;
    margin-bottom: 16px;
    z-index: 10;
}

.search-input {
    width: 100%;
    padding: 14px 18px 14px 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--primary-glow);
}

/* =========================================
   Footer
   ========================================= */
footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

/* =========================================
   Login Page
   ========================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-bottom: 20px;
}

.login-page body,
body.login-body {
    padding-bottom: 20px;
}

.login-card {
    max-width: 420px;
    width: 100%;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 40px 28px;
    box-shadow: var(--shadow-xl);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: var(--gradient-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* =========================================
   Utilities
   ========================================= */
.text-success { color: var(--accent-green) !important; }
.text-danger { color: var(--accent-red) !important; }
.text-warning { color: var(--accent-orange) !important; }
.text-info { color: var(--accent-blue) !important; }
.text-muted { color: var(--text-muted) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }

.text-center { text-align: center !important; }

.hidden { display: none !important; }

/* =========================================
   Loading & Animations
   ========================================= */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* =========================================
   Mobile UX Improvements
   ========================================= */

/* --- Settings tabs: horizontal scroll on mobile --- */
@media (max-width: 767px) {
    .tabs[style*="display: flex"] {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
    }

    .tabs[style*="display: flex"]::-webkit-scrollbar {
        display: none;
    }

    .tabs[style*="display: flex"] .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 0.8rem;
    }

    /* Preset buttons grid on mobile */
    .btn-preset {
        min-width: 80px;
        padding: 12px 10px;
        font-size: 0.8rem;
    }

    /* Meal template list items */
    li[style*="display: flex"][style*="justify-content: space-between"] {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* --- Keto guidance grid defaults --- */
.keto-guidance-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* --- Touch target fixes: ensure 44px minimum --- */
.entry-delete {
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 18px;
}

.date-nav-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 18px;
}

/* --- Mobile-first: standard phones (up to 767px) --- */
@media (max-width: 767px) {
    /* Prevent horizontal overflow globally */
    html, body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 12px;
    }

    /* Stats row: 2 columns on phones instead of 4 */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Form row with 3 cols collapses to 1 */
    .form-row-3,
    .form-row.form-row-3 {
        grid-template-columns: 1fr;
    }

    /* Keto coach metrics: wrap properly on phones */
    .keto-coach-metrics {
        gap: 8px 12px;
    }

    .keto-coach-metric {
        min-width: 100px;
        flex: 1 1 calc(50% - 12px);
    }

    /* GKI latest reading grid: stack to 1 col on small phones */
    .gki-latest-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }

    /* Inline-styled grids in keto guidance */
    .keto-guidance-grid {
        grid-template-columns: 1fr !important;
    }

    /* Copy day / template forms: stack vertically */
    .copy-day-form,
    .form-card form[style*="display: flex"][style*="flex-wrap"] {
        flex-direction: column;
        align-items: stretch;
    }

    .copy-day-form .btn-submit,
    .form-card form[style*="display: flex"] .btn-submit {
        width: 100%;
    }

    /* Analytics comparison tables */
    .analytics-table {
        font-size: 0.78rem;
    }

    .analytics-table th,
    .analytics-table td {
        padding: 8px 6px;
    }

    /* Chart container: slightly taller for readability */
    .chart-container {
        height: 200px;
    }

    /* Ensure modals don't go off-screen */
    .modal-overlay {
        padding: 16px;
        align-items: flex-start;
        padding-top: 60px;
    }

    .modal-content {
        max-width: 100%;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }

    /* Supplement grid: ensure items don't get too narrow */
    .supplement-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }

    .supplement-item {
        padding: 10px 6px;
    }

    /* Tracker summary stats: wrap on mobile */
    .tracker-summary-stats {
        flex-wrap: wrap;
        gap: 16px;
    }

    .tracker-summary-actions {
        flex-direction: column;
    }

    .tracker-summary-actions button {
        max-width: 100%;
    }

    /* Tag checkboxes: ensure proper spacing for touch */
    .tag-checkbox .tag-label {
        padding: 8px 14px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* User items on account page */
    .user-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .user-info {
        min-width: 0;
        width: 100%;
    }

    /* Login card: adjust padding */
    .login-card {
        padding: 28px 20px;
    }

    /* Bottom nav label size increase for readability */
    .nav-item .nav-label {
        font-size: 0.65rem;
    }

    /* Metric card value: prevent overflow */
    .metric-value {
        word-break: break-word;
        font-size: 1.35rem;
    }

    /* Date section: compact */
    .date-section {
        padding: 12px;
    }

    .date-display .date-text {
        font-size: 1rem;
    }

    /* Top bar: compact */
    .top-bar {
        padding: 10px 12px;
        margin-bottom: 12px;
    }

    /* Form cards: reduce padding */
    .form-card {
        padding: 16px;
    }

    /* GKI guide items: ensure full width */
    .gki-guide > div {
        padding: 8px;
    }

    .gki-guide > div span:first-child {
        min-width: 50px;
    }

    /* Wellness cards grid */
    .wellness-cards {
        grid-template-columns: 1fr;
    }

    /* Analytics stat pills */
    .analytics-stat-pills {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    /* Export form: stack date inputs */
    .export-form .form-row {
        grid-template-columns: 1fr;
    }

    /* Prevent long entry names from overflowing */
    .entry-name {
        max-width: calc(100vw - 160px);
    }

    /* Keto food ideas: smaller chips */
    .keto-coach-idea-chip {
        font-size: 0.72rem;
        padding: 5px 9px;
    }

    /* Keto score big number */
    .keto-coach-score-big {
        font-size: 1.8rem;
    }

    /* Alert messages: better mobile sizing */
    .alert {
        font-size: 0.85rem;
        padding: 12px 14px;
    }

    /* AI button in food form: full width below input */
    .ai-calc-wrap {
        flex-direction: column !important;
    }

    .ai-calc-wrap .form-group {
        min-width: 0 !important;
    }
}

/* --- Very small phones (320px, iPhone SE) --- */
@media (max-width: 374px) {
    .metric-value {
        font-size: 1.2rem;
    }

    .metric-label {
        font-size: 0.65rem;
    }

    .metric-icon {
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .progress-ring-wrap {
        width: 36px;
        height: 36px;
        top: 10px;
        right: 10px;
    }

    .progress-ring-text {
        font-size: 0.5rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 12px 14px;
        font-size: 0.95rem;
        min-height: 46px;
    }

    .btn-submit {
        padding: 14px 20px;
        font-size: 0.95rem;
        min-height: 50px;
    }

    .quick-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
        min-width: 60px;
    }

    .form-label {
        font-size: 0.75rem;
    }

    .form-card h3 {
        font-size: 0.9rem;
    }

    .form-card h3 .form-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .list-header h3 {
        font-size: 0.8rem;
    }

    .entry-name {
        font-size: 0.8rem;
    }

    .entry-meta {
        font-size: 0.65rem;
    }

    .entry-value {
        font-size: 0.8rem;
    }

    /* GKI latest reading: stack to 1 column */
    .gki-latest-grid {
        grid-template-columns: 1fr !important;
    }

    /* Keto guidance: single column */
    .keto-guidance-food-columns {
        grid-template-columns: 1fr !important;
    }

    /* Login card shrink */
    .login-card {
        padding: 24px 16px;
    }

    .login-logo .logo-icon {
        width: 52px;
        height: 52px;
        font-size: 28px;
    }

    .login-logo h1 {
        font-size: 1.25rem;
    }

    /* Chart container: compact */
    .chart-container {
        height: 180px;
    }

    /* Supplement grid */
    .supplement-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    }

    .supplement-item .supp-icon {
        font-size: 20px;
    }

    .supplement-item .supp-name {
        font-size: 0.65rem;
    }
}

/* --- Landscape mode on phones --- */
@media (max-height: 500px) and (orientation: landscape) {
    .top-bar {
        padding: 6px 12px;
    }

    .bottom-nav {
        padding: 4px 2px;
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }

    .nav-item {
        padding: 4px 2px;
    }

    .nav-item .nav-icon {
        font-size: 16px;
    }

    .nav-item .nav-label {
        display: none;
    }

    body {
        padding-bottom: calc(var(--bottom-nav-height) - 16px);
    }

    .chart-container {
        height: 160px;
    }

    .modal-overlay {
        padding: 8px;
        padding-top: 8px;
        align-items: center;
    }
}

/* =========================================
   Responsive Design
   ========================================= */

/* Tablet and up */
@media (min-width: 768px) {
    body {
        padding-bottom: 20px;
    }
    
    .container {
        padding: 0 24px;
    }
    
    .bottom-nav {
        display: none;
    }
    
    .tabs {
        display: flex;
    }
    
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    
    .metric-card {
        padding: 20px;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    .stats-row {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .form-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .list-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 280px;
    }
    
    .supplement-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Large screens */
@media (min-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .form-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .list-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 300px;
    }
}

/* Extra large screens */
@media (min-width: 1280px) {
    .container {
        padding: 0 32px;
    }
    
    .cards-grid {
        gap: 20px;
    }
    
    .cards-grid.six-cols {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Small mobile (374px and below) */
@media (max-width: 374px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .nav-item {
        min-width: 40px;
        padding: 6px 2px;
    }

    .nav-item .nav-icon {
        font-size: 18px;
    }

    .nav-item .nav-label {
        font-size: 0.5rem;
    }

    /* Ensure bottom nav items don't overflow */
    .bottom-nav {
        padding: 4px 0;
    }
}

/* Hide nav labels on narrow screens (380px and below) */
@media (max-width: 380px) {
    .nav-item .nav-label {
        display: none;
    }

    .nav-item {
        min-width: 36px;
        padding: 8px 4px;
    }

    .nav-item .nav-icon {
        font-size: 20px;
    }
}

/* Standard mobile phones (up to 480px) */
@media (max-width: 480px) {
    /* Fix 3-col form rows on phones */
    .form-row-3,
    .form-row.form-row-3 {
        grid-template-columns: 1fr;
    }

    /* Stat pills within analytics: prevent overflow */
    .stats-row[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* AI Calculator Button */
.btn-ai {
    width: 100%;
    padding: 20px 28px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
    min-height: 80px;
    position: relative;
    overflow: hidden;
}

.btn-ai::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn-ai:hover::before {
    left: 100%;
}

.btn-ai:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 50px rgba(99, 102, 241, 0.6), 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.btn-ai:active {
    transform: translateY(-2px) scale(0.98);
}

/* GPS Activity Tracker */
.tracker-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
    padding: 0 10px;
}

.tracker-btn {
    flex: 1;
    max-width: 180px;
    min-width: 140px;
    padding: 45px 25px;
    border: none;
    border-radius: 28px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    min-height: 160px;
    position: relative;
    overflow: hidden;
}

.tracker-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tracker-btn:hover::before {
    opacity: 1;
}

.tracker-btn.walk {
    background: linear-gradient(145deg, #10b981 0%, #059669 50%, #047857 100%);
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.tracker-btn.run {
    background: linear-gradient(145deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.tracker-btn:hover {
    transform: translateY(-8px) scale(1.03);
}

.tracker-btn.walk:hover {
    box-shadow: 0 20px 50px rgba(16, 185, 129, 0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}

.tracker-btn.run:hover {
    box-shadow: 0 20px 50px rgba(245, 158, 11, 0.6), inset 0 1px 0 rgba(255,255,255,0.3);
}

.tracker-btn:active {
    transform: translateY(-4px) scale(0.98);
}

.tracker-btn-icon {
    font-size: 5rem;
    line-height: 1;
}

.tracker-btn-label {
    font-size: 1.5rem;
    font-weight: 700;
}

.tracker-btn-cal {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 5px;
}

.tracker-type {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Timer Display */
.tracker-timer-display {
    text-align: center;
    margin: 25px 0;
    padding: 25px;
    background: linear-gradient(135deg, var(--primary-glow), transparent);
    border-radius: 20px;
    border: 2px solid var(--primary);
}

.tracker-time-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    letter-spacing: 2px;
}

.tracker-time-label {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
}

/* Stats Grid */
.tracker-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

.tracker-stat-box {
    background: var(--bg-input);
    border-radius: 16px;
    padding: 20px 15px;
    text-align: center;
    border: 1px solid var(--border);
}

.tracker-stat-box.calories {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(249, 115, 22, 0.1));
    border-color: rgba(239, 68, 68, 0.3);
}

.tracker-stat-box.minutes {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border-color: rgba(99, 102, 241, 0.3);
}

.tracker-stat-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.tracker-stat-box .tracker-stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.tracker-stat-box .tracker-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

/* Old stats styles (kept for compatibility) */
.tracker-stats {
    text-align: center;
    margin: 20px 0;
}

.tracker-stat.main .tracker-stat-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.tracker-stat.main .tracker-stat-label {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.tracker-stats-row {
    display: flex;
    justify-content: space-around;
    margin: 25px 0;
    padding: 15px;
    background: var(--bg-input);
    border-radius: 15px;
}

.tracker-stat {
    text-align: center;
}

.tracker-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tracker-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.tracker-status {
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-dot.active {
    background: #10b981;
}

.status-dot.warning {
    background: #f59e0b;
}

.status-dot.error {
    background: #ef4444;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stop Button */
.tracker-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.tracker-stop-btn {
    width: 100%;
    max-width: 280px;
    padding: 18px 30px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.2s ease;
    color: white;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

.tracker-stop-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(239, 68, 68, 0.5);
}

.tracker-stop-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.tracker-stop-btn .stop-icon {
    font-size: 1.5rem;
}

.tracker-control-btn {
    flex: 1;
    max-width: 140px;
    padding: 15px 20px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    color: white;
}

.tracker-control-btn.pause {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.tracker-control-btn.stop {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.tracker-control-btn:hover {
    transform: translateY(-2px);
}

.tracker-summary {
    text-align: center;
    padding: 20px;
}

.tracker-summary h4 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.tracker-summary-stats {
    display: flex;
    justify-content: space-around;
    margin: 25px 0;
    padding: 20px;
    background: var(--bg-input);
    border-radius: 15px;
}

.summary-stat {
    text-align: center;
}

.summary-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.tracker-summary-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.tracker-summary-actions button {
    flex: 1;
    max-width: 160px;
}

/* Background Activity Tracker */
.background-tracker-controls {
    padding: 10px 0;
}

.tracker-toggle-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-input);
    transition: 0.3s;
    border-radius: 32px;
    border: 2px solid var(--border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #10b981;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(28px);
}

.toggle-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.bg-tracking-status {
    background: var(--bg-input);
    border-radius: 12px;
    padding: 15px;
    margin-top: 10px;
}

.bg-status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-weight: 600;
}

.bg-tracking-stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.bg-stat {
    display: flex;
    flex-direction: column;
}

.bg-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.bg-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.bg-tracking-info {
    margin-top: 10px;
}

.bg-tracking-info ul {
    padding-left: 20px;
}

.bg-tracking-info li {
    margin-bottom: 3px;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

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

.btn-ai #ai-btn-icon {
    font-size: 2.2rem;
}

.ai-status {
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.ai-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.ai-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Time display in entries */
.entry-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 8px;
}

/* Supplement time display */
.supp-time {
    font-size: 0.7rem;
    color: var(--primary);
    margin-top: 2px;
    font-weight: 500;
}

.supplement-item.taken .supp-time {
    color: var(--accent-green);
}

/* Modal styles — hidden by default; JS sets display:flex to open */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 25px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
}

.modal-content .text-muted {
    margin-bottom: 20px;
}

.modal-content input[type="time"] {
    margin-bottom: 20px;
}

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

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

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

/* User Management Styles */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-input);
    border-radius: 12px;
    border: 1px solid var(--border);
    gap: 15px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-email {
    font-size: 0.9rem;
    color: var(--text-muted);
    word-break: break-word;
}

.user-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-edit, .btn-delete {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-edit {
    background: var(--bg-card);
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

.btn-delete {
    background: var(--bg-card);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.btn-delete:hover {
    background: var(--accent-red);
    color: white;
}

.badge-admin {
    background: var(--gradient-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-you {
    background: var(--accent-green);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

/* Goal Preset Buttons */
.btn-preset {
    flex: 1;
    min-width: 100px;
    padding: 15px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-preset:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-preset small {
    display: block;
    opacity: 0.7;
    margin-top: 4px;
}

.btn-preset:hover small {
    opacity: 1;
}

@media (max-width: 500px) {
    .user-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .user-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* =========================================
   Mobile Button Enhancements
   ========================================= */

/* Large mobile screens (phones in landscape, small tablets) */
@media (max-width: 768px) {
    .btn-ai {
        padding: 18px 24px;
        font-size: 1.4rem;
        min-height: 75px;
        border-radius: 18px;
    }
    
    .btn-ai #ai-btn-icon {
        font-size: 2rem;
    }
    
    .tracker-buttons {
        gap: 16px;
        padding: 0 5px;
    }
    
    .tracker-btn {
        min-height: 155px;
        padding: 40px 20px;
        border-radius: 26px;
    }
    
    .tracker-btn-icon {
        font-size: 4.5rem;
    }
    
    .tracker-btn-label {
        font-size: 1.4rem;
    }
}

/* Standard mobile screens */
@media (max-width: 480px) {
    .btn-ai {
        padding: 16px 20px;
        font-size: 1.3rem;
        min-height: 70px;
        border-radius: 16px;
    }
    
    .btn-ai #ai-btn-icon {
        font-size: 1.8rem;
    }
    
    .tracker-buttons {
        gap: 14px;
        margin: 25px 0;
    }
    
    .tracker-btn {
        min-height: 150px;
        max-width: 48%;
        padding: 35px 15px;
        border-radius: 24px;
    }
    
    .tracker-btn-icon {
        font-size: 4rem;
    }
    
    .tracker-btn-label {
        font-size: 1.3rem;
    }
}

/* Small mobile screens */
@media (max-width: 380px) {
    .btn-ai {
        padding: 14px 18px;
        font-size: 1.2rem;
        min-height: 65px;
        gap: 10px;
    }
    
    .btn-ai #ai-btn-icon {
        font-size: 1.6rem;
    }
    
    .tracker-buttons {
        gap: 12px;
    }
    
    .tracker-btn {
        min-height: 140px;
        padding: 30px 12px;
        border-radius: 22px;
    }
    
    .tracker-btn-icon {
        font-size: 3.5rem;
    }
    
    .tracker-btn-label {
        font-size: 1.2rem;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .btn-ai {
        padding: 12px 16px;
        font-size: 1.1rem;
        min-height: 60px;
    }
    
    .btn-ai #ai-btn-icon {
        font-size: 1.5rem;
    }
    
    .tracker-btn {
        min-height: 130px;
        padding: 25px 10px;
    }
    
    .tracker-btn-icon {
        font-size: 3rem;
    }
    
    .tracker-btn-label {
        font-size: 1.1rem;
    }
}

/* Touch-friendly improvements for all mobile */
@media (hover: none) and (pointer: coarse) {
    .btn-ai,
    .tracker-btn,
    .btn-submit,
    .water-btn,
    .tab-btn {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .btn-ai:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }
    
    .tracker-btn:active {
        transform: scale(0.96);
        transition: transform 0.1s ease;
    }
}

/* Print styles */
@media print {
    .top-bar,
    .bottom-nav,
    .tabs,
    .btn-submit,
    .entry-delete {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
        padding-bottom: 0;
    }
    
    .metric-card,
    .form-card,
    .list-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Tag checkbox styles for GKI tracking */
.tags-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.tag-checkbox input[type="checkbox"] {
    display: none;
}

.tag-checkbox .tag-label {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.tag-checkbox input[type="checkbox"]:checked + .tag-label {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.tag-checkbox:hover .tag-label {
    border-color: var(--primary);
}

/* GKI Preview styles */
.gki-preview {
    animation: fadeIn 0.3s ease;
}

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

/* GKI Guide styles */
.gki-guide {
    display: grid;
    gap: 10px;
}

.gki-guide > div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
}

/* ========== Keto Coach (dashboard) ========== */
.keto-coach-card {
    border-left: 4px solid var(--accent-purple);
    margin-bottom: 20px;
}

.keto-coach-card--muted {
    border-left-color: var(--border-strong);
}

.keto-coach-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.keto-coach-head h3 {
    margin: 0;
}

.keto-coach-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.keto-coach-badge--ok {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.keto-coach-badge--warn {
    background: rgba(234, 179, 8, 0.2);
    color: #a16207;
}

[data-theme="dark"] .keto-coach-badge--warn {
    color: var(--accent-yellow);
}

.keto-coach-badge--high {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.keto-coach-head-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.keto-coach-score-pill {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: rgba(139, 92, 246, 0.18);
    color: var(--accent-purple);
}

.keto-coach-disclaimer-short {
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--text-muted);
    margin: 0 0 12px 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
}

.keto-coach-score-row {
    margin: 0 0 14px 0;
}

.keto-coach-score-main {
    display: flex;
    align-items: center;
    gap: 14px;
}

.keto-coach-score-big {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    min-width: 3.2rem;
    text-align: center;
}

.keto-coach-score-meta {
    flex: 1;
    min-width: 0;
}

.keto-coach-score-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.keto-coach-score-track {
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--border);
    overflow: hidden;
}

.keto-coach-score-fill {
    display: block;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent-green), var(--accent-purple));
    transition: width 0.25s ease;
}

.keto-coach-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px 0;
}

.keto-coach-flag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text-secondary);
}

.keto-coach-flag--low {
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.08);
}

.keto-coach-flag--med {
    border-color: rgba(234, 179, 8, 0.45);
    background: rgba(234, 179, 8, 0.12);
}

.keto-coach-flag--high {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

.keto-coach-ideas {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 4px 0;
}

.keto-coach-idea-chip {
    font-size: 0.78rem;
    padding: 6px 11px;
    border-radius: var(--radius-full);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    line-height: 1.35;
}

.keto-coach-summary {
    font-size: 0.95rem;
    margin: 0 0 14px 0;
    color: var(--text-secondary);
    line-height: 1.45;
}

.keto-coach-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.keto-coach-metric {
    min-width: 120px;
}

.keto-coach-metric-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.keto-coach-metric-value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.keto-coach-subhead {
    margin: 18px 0 8px 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.keto-coach-rec-list {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.keto-coach-rec-list li + li {
    margin-top: 8px;
}

.keto-coach-ai-wrap {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
}

.keto-coach-ai-btn {
    font-size: 0.9rem;
}

.keto-coach-ai-summary {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
}

/* ==========================================
   Photo Upload & Display
   ========================================== */

/* Hidden native file input */
.photo-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Custom upload button */
.photo-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 2px dashed var(--border-color, rgba(0, 0, 0, 0.15));
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary, #666);
    background: var(--glass-bg, rgba(255, 255, 255, 0.5));
    transition: border-color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.photo-upload-btn:hover,
.photo-upload-btn:focus-within {
    border-color: var(--accent-primary, #007aff);
    background: var(--glass-bg-hover, rgba(255, 255, 255, 0.7));
}

.photo-upload-btn:active {
    transform: scale(0.98);
}

.photo-upload-icon {
    font-size: 1.3rem;
}

.photo-upload-group .form-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
}

/* Photo preview (before upload) */
.photo-preview {
    position: relative;
    margin-top: 10px;
    max-width: 200px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.photo-preview img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
}

.photo-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: -8px -8px 0 0;
}

.photo-remove-btn:hover {
    background: rgba(220, 50, 50, 0.8);
}

/* Entry photo thumbnail in list */
.entry-item.has-photo {
    flex-wrap: wrap;
}

.entry-photo-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    -webkit-tap-highlight-color: transparent;
}

.entry-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.entry-photo-thumb:active {
    transform: scale(0.95);
}

/* Photo Lightbox — hidden by default; JS sets display:flex to open */
.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.photo-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    z-index: 1;
}

.photo-lightbox-content img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.photo-lightbox-close {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s;
}

.photo-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Mobile adjustments for photo */
@media (max-width: 767px) {
    .photo-preview {
        max-width: 150px;
    }
    .photo-preview img {
        max-height: 150px;
    }
    .entry-photo-thumb {
        width: 40px;
        height: 40px;
    }
    .photo-lightbox-close {
        top: 10px;
        right: 10px;
    }
}

/* ==========================================
   Chat Agent — Floating Button & Panel
   ========================================== */

/* Chat Panel — hidden by default; JS sets display:flex to open */
.chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 380px;
    max-width: 100vw;
    height: 520px;
    max-height: calc(100vh - 60px);
    background: var(--glass-bg, rgba(255, 255, 255, 0.95));
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);
    z-index: 6000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

[data-theme="dark"] .chat-panel {
    background: rgba(30, 30, 40, 0.97);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.4);
}

/* Panel Header */
.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    flex-shrink: 0;
}

.chat-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary, #1a1a2e);
}

.chat-panel-icon {
    font-size: 1.2rem;
}

.chat-panel-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--glass-bg-hover, rgba(0, 0, 0, 0.05));
    color: var(--text-secondary, #666);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -4px -4px -4px 0;
    -webkit-tap-highlight-color: transparent;
}

.chat-panel-close:hover {
    background: rgba(220, 50, 50, 0.1);
    color: #dc3232;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

/* Message bubbles */
.chat-msg {
    display: flex;
    max-width: 88%;
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.assistant {
    align-self: flex-start;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
}

.chat-msg.user .chat-msg-bubble {
    background: var(--accent-primary, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-bubble {
    background: var(--glass-bg-hover, rgba(0, 0, 0, 0.05));
    color: var(--text-primary, #1a1a2e);
    border-bottom-left-radius: 4px;
}

[data-theme="dark"] .chat-msg.assistant .chat-msg-bubble {
    background: rgba(255, 255, 255, 0.08);
}

/* Answer text inside assistant bubble */
.chat-answer {
    line-height: 1.5;
}

.chat-answer p {
    margin: 0;
}

.chat-answer p + p {
    margin-top: 6px;
}

.chat-answer strong {
    font-weight: 600;
    color: var(--accent-primary, #6366f1);
}

[data-theme="dark"] .chat-answer strong {
    color: #a5b4fc;
}

/* Recommendations label */
.chat-recs-label {
    margin-top: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #666);
}

/* Recommendations list inside assistant bubble */
.chat-recs {
    margin: 4px 0 4px;
    padding: 0;
    list-style: none;
}

.chat-recs li {
    padding: 3px 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #555);
}

.chat-recs li::before {
    content: "→ ";
    color: var(--accent-primary, #6366f1);
}

.chat-recs li strong {
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}

[data-theme="dark"] .chat-recs li strong {
    color: #e2e8f0;
}

/* Warnings inside assistant bubble (shown at top) */
.chat-warnings {
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(234, 179, 8, 0.1);
    border-left: 3px solid #eab308;
    border-radius: 6px;
    font-size: 0.82rem;
    color: #92400e;
}

[data-theme="dark"] .chat-warnings {
    background: rgba(234, 179, 8, 0.08);
    color: #fcd34d;
}

/* Loading indicator */
.chat-msg.loading .chat-msg-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
}

.chat-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary, #999);
    animation: chatDotPulse 1.4s ease-in-out infinite;
}

.chat-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Suggestion chips */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 10px;
    flex-shrink: 0;
}

.chat-suggestion-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
    background: var(--glass-bg, rgba(255, 255, 255, 0.7));
    color: var(--accent-primary, #6366f1);
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 36px;
}

.chat-suggestion-btn:hover {
    background: var(--accent-primary, #6366f1);
    color: #fff;
    border-color: var(--accent-primary, #6366f1);
}

/* Input area */
.chat-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 24px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
    background: var(--glass-bg, rgba(255, 255, 255, 0.8));
    color: var(--text-primary, #1a1a2e);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    min-height: 44px;
}

.chat-input:focus {
    border-color: var(--accent-primary, #6366f1);
}

[data-theme="dark"] .chat-input {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent-primary, #6366f1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.chat-send-btn:hover {
    background: var(--accent-hover, #4f46e5);
}

.chat-send-btn:active {
    transform: scale(0.92);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .chat-panel {
        width: 100vw;
        height: calc(100vh - 50px);
        max-height: calc(100vh - 50px);
        border-radius: 16px 16px 0 0;
    }
}

/* =========================================
   Edit Entry Button
   ========================================= */
.entry-edit {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
    flex-shrink: 0;
}
.entry-edit:hover,
.entry-edit:focus-visible {
    color: var(--accent-blue);
    background: rgba(74, 108, 247, 0.1);
}

/* =========================================
   Edit Entry Modal
   ========================================= */
/* Hidden by default; JS sets display:flex to open */
#edit-entry-modal {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#edit-entry-modal .modal-content-lg {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
#edit-entry-modal .modal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
#edit-entry-modal .modal-header-row h3 {
    margin: 0;
    font-size: 1.2rem;
}
#edit-entry-modal .modal-close-x {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
}
#edit-entry-modal .modal-close-x:hover {
    background: rgba(0,0,0,0.1);
}
#edit-entry-modal .form-group {
    margin-bottom: 12px;
}
#edit-entry-modal .form-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
#edit-entry-modal .form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--input-bg, #fff);
    color: var(--text-primary);
    box-sizing: border-box;
}
#edit-entry-modal textarea.form-input {
    resize: vertical;
}
#edit-entry-modal .modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}
#edit-entry-modal .modal-buttons .btn-secondary,
#edit-entry-modal .modal-buttons .btn-submit {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
}
#edit-entry-modal .btn-secondary {
    background: var(--bg-secondary, #f0f0f0);
    color: var(--text-primary);
}
#edit-entry-modal .btn-submit {
    background: var(--accent-blue);
    color: #fff;
}
#edit-entry-modal .btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    #edit-entry-modal .modal-content-lg {
        width: 95%;
        padding: 18px;
        max-height: 90vh;
    }
}

/* ======================================
   Favorite Food Button (star on entries)
   ====================================== */
.entry-fav {
    background: none;
    border: none;
    color: var(--text-secondary, #999);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 6px;
    transition: color 0.2s, transform 0.15s;
    line-height: 1;
    flex-shrink: 0;
}
.entry-fav:hover {
    color: #f5a623;
    transform: scale(1.15);
}
.entry-fav.is-fav {
    color: #f5a623;
}
.entry-fav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Favorite food chips in quick-add */
.fav-btn {
    border: 1.5px solid rgba(245, 166, 35, 0.3) !important;
    background: rgba(245, 166, 35, 0.08) !important;
}
.fav-btn:hover {
    background: rgba(245, 166, 35, 0.15) !important;
    border-color: rgba(245, 166, 35, 0.5) !important;
}

/* ======================================
   Batch Operations
   ====================================== */
.batch-toggle-btn {
    background: var(--bg-secondary, #f0f0f0);
    border: 1px solid var(--border-color, #e0e0e0);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.batch-toggle-btn:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}
.batch-action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border-color, #e0e0e0);
    flex-wrap: wrap;
}
.batch-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: auto;
}
.batch-select-all-btn {
    background: none;
    border: 1px solid var(--border-color, #ccc);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
}
.batch-select-all-btn:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}
.batch-delete-btn {
    background: var(--accent-red, #e74c3c);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.batch-delete-btn:hover {
    opacity: 0.9;
}
.batch-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

