@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Design Tokens ── */
:root {
    --color-primary: #667eea;
    --color-primary-dark: #764ba2;
    --color-primary-rgb: 102, 126, 234;
    --color-accent-pink: #f093fb;
    --color-accent-pink-dark: #f5576c;
    --color-accent-blue: #4facfe;
    --color-accent-blue-dark: #00f2fe;
    --color-accent-green: #43e97b;
    --color-accent-green-dark: #38f9d7;
    --color-accent-warm: #FFD89B;
    --color-accent-warm-dark: #19547B;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --color-bg: #f8fafc;
    --color-bg-card: #ffffff;
    --gradient-primary: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    --gradient-pink: linear-gradient(135deg, var(--color-accent-pink) 0%, var(--color-accent-pink-dark) 100%);
    --gradient-blue: linear-gradient(135deg, var(--color-accent-blue) 0%, var(--color-accent-blue-dark) 100%);
    --gradient-green: linear-gradient(135deg, var(--color-accent-green) 0%, var(--color-accent-green-dark) 100%);
    --gradient-warm: linear-gradient(135deg, var(--color-accent-warm) 0%, var(--color-accent-warm-dark) 100%);
    --gradient-rainbow: linear-gradient(135deg, #FA8BFF 0%, #2BD2FF 90%, #2BFF88 100%);
    --gradient-llc: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --gradient-more: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
    --shadow-xl: 0 16px 40px rgba(0,0,0,0.12);
    --shadow-primary: 0 4px 14px rgba(var(--color-primary-rgb), 0.25);
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* { font-family: 'Inter', sans-serif; }

/* ── Toggle Button States (JS classList) ── */
.toggle-btn-active-llc {
    background: var(--gradient-llc) !important;
    color: white !important;
    border-color: #3b82f6 !important;
}
.toggle-btn-active-more {
    background: var(--gradient-more) !important;
    color: white !important;
    border-color: #8b5cf6 !important;
}
.toggle-btn-inactive {
    background: white !important;
    color: var(--color-text-secondary) !important;
    border-color: var(--color-border) !important;
}

/* ── Auto-fill Feedback States ── */
.input-autofill-exact {
    background-color: #f0fdf4 !important;
    border-color: #86efac !important;
}
.input-autofill-fuzzy {
    background-color: #fef3c7 !important;
    border-color: #fbbf24 !important;
}

/* ── Pull-to-Refresh States ── */
.pull-refresh-default { background: var(--gradient-primary) !important; }
.pull-refresh-ready { background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important; }

/* ── Base Components ── */
.gradient-bg { background: var(--gradient-primary); }

.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card {
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-xl); }
.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
    animation: pulse 4s ease-in-out infinite;
}
.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 0.8; } }

/* Stat card color variants */
.stat-card--budget { background: var(--gradient-primary); }
.stat-card--spent { background: var(--gradient-pink); }
.stat-card--llc { background: var(--gradient-blue); }
.stat-card--left { background: var(--gradient-green); }
.stat-card--rental { background: var(--gradient-warm); }
.stat-card--predicted { background: var(--gradient-rainbow); }

/* Stat card entrance animation */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.stat-card { animation: fadeSlideUp 0.4s ease both; }
.stat-card:nth-child(1) { animation-delay: 0.03s; }
.stat-card:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3) { animation-delay: 0.09s; }
.stat-card:nth-child(4) { animation-delay: 0.12s; }
.stat-card:nth-child(5) { animation-delay: 0.15s; }
.stat-card:nth-child(6) { animation-delay: 0.18s; }

/* Share card entrance animation */
.card { animation: fadeSlideUp 0.4s ease both; }

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-base);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-primary); }
.btn-primary:active { transform: translateY(0); }
.btn-primary--pink { background: var(--gradient-pink); }

.btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-primary);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--color-border);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-base);
}
.btn-secondary:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }

.flex-2 { flex: 2; }
.input-field { 
    width: 100%; 
    padding: 12px 16px; 
    border: 1.5px solid var(--color-border); 
    border-radius: var(--radius-sm); 
    font-size: 14px; 
    transition: all var(--transition-base); 
    box-sizing: border-box;
    background: var(--color-bg-card);
}
.input-field:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.08); }

/* Specific styling for input elements */
input.input-field { 
    line-height: 1.2;
}

/* Div elements with input-field class (like the date picker) need flex */
div.input-field {
    display: flex;
    align-items: center;
}

input.input-field::placeholder { 
    opacity: 0.6;
    line-height: 1.2;
}
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 1000; align-items: center; justify-content: center; overflow: hidden; }
.modal.active { display: flex; }
.modal-content { background: var(--color-bg-card); border-radius: var(--radius-lg); padding: 32px; max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease; position: relative; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; box-shadow: var(--shadow-xl); }

/* Smart Search chat modal */
.smart-search-modal-content {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.smart-search-header {
    padding: 18px 18px 12px 18px;
    border-bottom: 1px solid #eef2f7;
    background: white;
    flex-shrink: 0;
}

.smart-search-subtitle {
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.smart-search-body {
    flex: 1;
    min-height: 0;
    background: #f9fafb;
    padding: 14px 14px;
    display: flex;
    flex-direction: column;
}

.smart-search-chat {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.smart-search-row {
    display: flex;
    align-items: flex-end;
}

.smart-search-row.user {
    justify-content: flex-end;
}

.smart-search-row.assistant {
    justify-content: flex-start;
}

.smart-search-bubble {
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.35;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    word-break: break-word;
}

.smart-search-bubble.user {
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom-right-radius: 6px;
}

.smart-search-bubble.assistant {
    color: #111827;
    background: white;
    border: 1px solid #eef2f7;
    border-bottom-left-radius: 6px;
}

.smart-search-bubble-rich .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
}

.smart-search-bubble-rich table {
    border-collapse: collapse;
}

.smart-search-inputbar {
    padding: 12px 14px;
    border-top: 1px solid #eef2f7;
    background: white;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.smart-search-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    min-width: 52px;
}

.smart-search-typing {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.smart-search-typing-label {
    font-size: 13px;
    color: #6b7280;
}

.smart-search-dots {
    display: inline-flex;
    gap: 4px;
}

.smart-search-dots span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #9ca3af;
    animation: smartSearchDotBounce 1.1s infinite ease-in-out;
}

.smart-search-dots span:nth-child(2) { animation-delay: 0.15s; }
.smart-search-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes smartSearchDotBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-3px); opacity: 1; }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}
.modal-header { margin-bottom: 1.5rem; }
.modal-footer { margin-top: 1.5rem; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-slide-up { animation: slideUp 0.3s ease; }
.expense-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--color-bg-card); box-shadow: var(--shadow-xs); transition: box-shadow var(--transition-fast), border-color var(--transition-fast); }
.expense-row:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border); }
.expense-header { display: none; }
.spinner { border: 4px solid var(--color-border); border-top: 4px solid var(--color-primary); border-radius: 50%; width: 48px; height: 48px; animation: spin 0.8s linear infinite; display: block; margin: 0 auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after { content: ''; position: absolute; width: 20px; height: 20px; top: 50%; left: 50%; margin-left: -10px; margin-top: -10px; border: 3px solid #ffffff; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.expense-item { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.expense-label { font-size: 12px; color: var(--color-text-secondary); font-weight: 600; }
.payment-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border: 1px solid var(--color-border-light); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--color-bg-card); box-shadow: var(--shadow-xs); transition: box-shadow var(--transition-fast), border-color var(--transition-fast); }
.payment-row:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border); }

@media (min-width: 768px) {
   .expense-row { grid-template-columns: 1.5fr 1fr 1fr 0.9fr 1.2fr 0.6fr 0.5fr 90px; gap: 8px; padding: 16px; border: none; border-bottom: 1px solid #f3f4f6; border-radius: 0; margin-bottom: 0; box-shadow: none; }
   .expense-header { display: grid; font-weight: 700; color: #374151; background: #f9fafb; border-radius: 8px; }
   .expense-item { display: block; padding: 0; }
   .expense-label { display: none; }
   .payment-row { grid-template-columns: 1fr 1fr 1fr 2fr 80px; gap: 12px; padding: 16px; border: none; border-bottom: 1px solid #f3f4f6; border-radius: 0; margin-bottom: 0; box-shadow: none; }
}

.badge { display: inline-block; padding: 4px 12px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }
.badge-llc { background: #dcfce7; color: #166534; }
.badge-personal { background: #fef3c7; color: #92400e; }
.loading { display: block; width: 48px; height: 48px; border: 4px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.fancy-spinner {
   position: absolute;
   width: 100%;
   height: 100%;
   border: 4px solid rgba(255, 255, 255, 0.2);
   border-top-color: white;
   border-radius: 50%;
   animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.fancy-spinner-inner {
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   width: 70%;
   height: 70%;
   border: 4px solid rgba(255, 255, 255, 0.3);
   border-bottom-color: white;
   border-radius: 50%;
   animation: spin-reverse 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.fancy-spinner-dot {
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   width: 16px;
   height: 16px;
   background: white;
   border-radius: 50%;
   box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
   animation: pulse-dot 1.5s ease-in-out infinite;
}

.loading-dot {
   width: 12px;
   height: 12px;
   background: white;
   border-radius: 50%;
   animation: bounce-dot 1.4s ease-in-out infinite;
}

@keyframes spin-reverse {
   to { transform: translate(-50%, -50%) rotate(-360deg); }
}

@keyframes pulse-dot {
   0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
   50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.6; }
}

@keyframes bounce-dot {
   0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
   40% { transform: scale(1); opacity: 1; }
}

.chart-container { position: relative; height: 300px; margin-top: 20px; }
.progress-bar { height: 6px; background: var(--color-border); border-radius: var(--radius-full); overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--gradient-primary); border-radius: var(--radius-full); transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.tab-button { padding: 12px 20px; border: none; background: transparent; color: var(--color-text-secondary); font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; transition: all var(--transition-base); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab-button:hover { color: var(--color-primary); background: rgba(var(--color-primary-rgb), 0.04); }
.tab-button.active { color: var(--color-primary); border-bottom-color: var(--color-primary); background: rgba(var(--color-primary-rgb), 0.06); }
.expense-detail-tabs { display: flex; gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-content { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.notification { position: fixed; top: calc(20px + env(safe-area-inset-top, 0px)); right: 20px; left: 20px; background: var(--color-bg-card); padding: 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 2000; display: none; animation: slideIn 0.3s ease; font-size: 14px; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.notification.success { border-left: 4px solid var(--color-success); }
.notification.error { border-left: 4px solid var(--color-danger); }
.fab { position: fixed; bottom: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: 20px; width: 56px; height: 56px; border-radius: 50%; background: var(--gradient-primary); color: white; border: none; font-size: 24px; box-shadow: var(--shadow-primary); cursor: pointer; z-index: 100; display: flex; align-items: center; justify-content: center; -webkit-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; transition: box-shadow var(--transition-fast); }
.fab:hover { box-shadow: 0 6px 20px rgba(var(--color-primary-rgb), 0.4); }
.fab:active { transform: scale(0.95) translateZ(0); }

/* Full-page loading overlay */
#fullPageLoader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#fullPageLoader.active {
    display: flex;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    color: white;
    margin-top: 20px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

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

.mobile-only { display: block; }
.desktop-only { display: none; }

@media (min-width: 768px) {
   .notification { right: 20px; left: auto; }
   .fab { display: none; }
   .mobile-only { display: none; }
   .desktop-only { display: block; }
   .modal-content { padding: 32px; }
   .chart-container { height: 300px; }
   .stat-card { padding: 24px; }
   .tab-button { padding: 12px 24px; font-size: 14px; }
}

@media (max-width: 767px) {
   .modal-content { padding: 20px; max-width: 100%; width: 95%; max-height: 90vh; }

   #smartSearchModal .smart-search-modal-content {
       width: 95%;
       max-width: 95%;
       max-height: 92vh;
   }

   #smartSearchModal .smart-search-header {
       padding: 14px 14px 10px 14px;
   }

   #smartSearchModal .smart-search-body {
       padding: 12px 12px;
   }

   #smartSearchModal .smart-search-send-label {
       display: none;
   }

   #smartSearchModal .smart-search-hint {
       max-width: 70%;
   }

   /* Fix for expense modal on mobile */
   #expenseModal .modal-content {
       width: 95%;
       max-width: 95%;
       padding: 20px;
       margin: 10px;
       max-height: 95vh;
       overflow-y: auto;
   }

   #expenseModal .modal-header {
       position: sticky;
       top: -20px;
       background: white;
       z-index: 10;
       margin: -20px -20px 16px -20px;
       padding: 16px 20px;
       border-bottom: 1px solid #e5e7eb;
   }

   #expenseModal .modal-footer {
       position: sticky;
       bottom: -20px;
       background: white;
       z-index: 10;
       margin: 16px -20px -20px -20px;
       padding: 16px 20px;
       border-top: 1px solid #e5e7eb;
   }

   #expenseModal .modal-footer .flex {
       flex-direction: column;
       gap: 12px;
   }

   #expenseModal .modal-footer button {
       width: 100%;
       padding: 14px;
   }

   .chart-container { height: 250px; }
   .stat-card { padding: 16px; }
   .tab-button { padding: 10px 12px; font-size: 13px; }
   .input-field { font-size: 16px; }
   body { padding-bottom: 80px; }
   
   /* Budget Manager Modal - Mobile Optimized */
   #budgetManagerModal .modal-content {
       max-width: 100%;
       width: 95%;
       margin: 10px;
       padding: 0;
       max-height: 95vh;
       overflow: hidden;
       display: flex;
       flex-direction: column;
   }

   /* Modal header - NOT sticky, scrolls with content */
   #budgetManagerModal .modal-header {
       padding: 16px 20px;
       border-bottom: 1px solid #e5e7eb;
       background: white;
       flex-shrink: 0;
   }

   /* Scrollable content area */
   #budgetManagerModal .modal-body {
       flex: 1;
       overflow-y: auto;
       padding: 16px 20px;
   }

   /* Remove max-height restriction from overflow container */
   #budgetManagerModal .overflow-x-auto {
       overflow-x: visible;
       max-height: none;
       overflow-y: visible;
   }

   /* Modal footer - NOT sticky, scrolls with content */
   #budgetManagerModal .modal-footer {
       padding: 16px 20px;
       border-top: 1px solid #e5e7eb;
       background: white;
       flex-shrink: 0;
   }

   #budgetManagerModal table { display: block; border: none; }
   #budgetManagerModal thead { display: none; }
   #budgetManagerModal tfoot { display: none; }
   #budgetTableBody { display: block !important; width: 100%; padding: 0; margin: 0; }
   #budgetTableBody tr { display: none !important; }
   #budgetTableBody tr.no-categories-row { display: none !important; }
   .budget-card { display: block !important; background: var(--color-bg-card); border-radius: var(--radius-md); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); border-left: 4px solid var(--color-primary); }
   .budget-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #e5e7eb; }
   .budget-card-category { font-size: 16px; font-weight: 700; color: #1f2937; }
   .budget-card-recurring { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #6b7280; }
   .budget-card-body { display: grid; gap: 12px; }
   .budget-card-row { display: flex; justify-content: space-between; align-items: center; }
   .budget-card-label { font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; }
   .budget-card-value { font-size: 14px; font-weight: 600; color: #1f2937; }
   .budget-card-input { width: 100%; max-width: 200px; }
   .budget-card-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e5e7eb; }
   .budget-card-delete { background: #fee; color: #dc2626; padding: 8px 16px; border-radius: 6px; border: none; font-size: 12px; font-weight: 600; cursor: pointer; flex: 1; }
   .budget-rollover { font-size: 11px; color: #059669; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
   .budget-total-mobile { display: block; background: var(--gradient-primary); color: white; border-radius: var(--radius-md); padding: 16px; margin: 16px 0; box-shadow: var(--shadow-md); }
   .budget-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
   .budget-total-row:last-child { margin-bottom: 0; }
   .budget-total-label { font-size: 12px; font-weight: 600; opacity: 0.9; }
   .budget-total-value { font-size: 18px; font-weight: 700; }
   
   #budgetManagerModal h2 { font-size: 18px; }
   #budgetManagerModal .mb-6.flex.items-center.gap-4 { 
       flex-direction: column; 
       gap: 12px; 
       align-items: stretch;
   }
   #budgetManagerModal .mb-6.flex.items-center.gap-4 > div {
       width: 100%;
   }
   #budgetManagerModal select { 
       font-size: 16px; 
       padding: 12px; 
       width: 100%;
   }
   
   #budgetManagerModal .flex-1.p-3 {
       font-size: 13px;
       padding: 12px !important;
   }
   #budgetManagerModal .flex-1.p-3 .text-sm {
       font-size: 13px;
   }
   
   /* Footer buttons - full width, stacked, NOT sticky */
   #budgetManagerModal .mt-6.flex.gap-3 {
       flex-direction: column; 
       gap: 12px; 
       margin-top: 16px;
   }
   #budgetManagerModal .mt-6.flex.gap-3 button {
       width: 100%;
       padding: 14px;
   }
   
   #budgetManagerModal tfoot { display: none; }
   
   #categoryTab .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
       grid-template-columns: 1fr;
       gap: 12px;
   }
   #categoryTab .flex.gap-3 {
       flex-direction: column;
       gap: 12px;
   }
   #categoryTab .flex.gap-3 button {
       width: 100%;
       padding: 12px;
   }
   #categoryTab h3 {
       font-size: 18px;
   }
   #categoryTab p {
       font-size: 14px;
   }
   
   .stat-card { font-size: 14px; }
   .stat-card h3 { font-size: 12px; }
   .stat-card .text-4xl { font-size: 28px !important; }
   .stat-card .text-2xl { font-size: 20px !important; }
   
   .grid { gap: 12px; }
   
   .btn-primary, .btn-secondary { padding: 10px 16px; font-size: 14px; }
   
   h3.text-lg { font-size: 16px !important; }
   h2.text-2xl { font-size: 20px !important; }
   
   #contributionModal .modal-content { width: 95%; padding: 16px; }
   #contributionModal h2 { font-size: 18px; }
   #contributionModal .text-4xl { font-size: 28px !important; }
   
   #fixedExpensesModal .modal-content { width: 95%; padding: 16px; }
   #fixedExpensesModal table { font-size: 13px; }
   
   .input-field { font-size: 16px !important; padding: 10px 12px; }
   select.input-field { font-size: 16px !important; }
   
   .notification { left: 10px; right: 10px; font-size: 13px; padding: 12px; }
   
   input[type="text"], input[type="number"], input[type="tel"], textarea, select {
       font-size: 16px !important;
   }
}

@media (min-width: 768px) {
   .budget-card { display: none !important; }
   .budget-total-mobile { display: none !important; }
   #budgetManagerModal table { display: table; }
   #budgetManagerModal thead { display: table-header-group; }
   #budgetManagerModal tfoot { display: table-footer-group; }
   #budgetTableBody { display: table-row-group; }
   #budgetTableBody tr { display: table-row; }
   #budgetTableBody tr.no-categories-row { display: table-row !important; }
   #budgetTableBody > div.budget-card { display: none !important; }
}

.custom-dropdown {
   position: relative;
   width: 100%;
}
.custom-dropdown-button {
   width: 100%;
   padding: 12px 16px;
   border: 1.5px solid var(--color-border);
   border-radius: var(--radius-sm);
   font-size: 14px;
   background: var(--color-bg-card);
   cursor: pointer;
   display: flex;
   justify-content: space-between;
   align-items: center;
   transition: all var(--transition-base);
}
.custom-dropdown-button:hover {
   border-color: var(--color-primary);
}
.custom-dropdown-button.active {
   border-color: var(--color-primary);
   box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.08);
}
.custom-dropdown-content {
   display: none;
   position: absolute;
   top: 100%;
   left: 0;
   right: 0;
   background: var(--color-bg-card);
   border: 1.5px solid var(--color-primary);
   border-radius: var(--radius-sm);
   margin-top: 4px;
   max-height: 300px;
   overflow-y: auto;
   z-index: 1000;
   box-shadow: var(--shadow-lg);
}
.custom-dropdown-content.show {
   display: block;
   animation: dropdownFadeIn 0.2s ease;
}
@keyframes dropdownFadeIn {
   from { opacity: 0; transform: translateY(-10px); }
   to { opacity: 1; transform: translateY(0); }
}
.custom-dropdown-item {
   padding: 10px 16px;
   cursor: pointer;
   display: flex;
   align-items: center;
   gap: 10px;
   transition: background var(--transition-fast);
}
.custom-dropdown-item:hover {
   background: var(--color-border-light);
}
.custom-dropdown-item input[type="checkbox"] {
   width: 18px;
   height: 18px;
   cursor: pointer;
   accent-color: var(--color-primary);
}
.custom-dropdown-item label {
   cursor: pointer;
   flex: 1;
   user-select: none;
}
.custom-dropdown-selected {
   color: var(--color-primary);
   font-weight: 500;
}
.custom-dropdown-placeholder {
   color: var(--color-text-secondary);
}
.custom-dropdown-count {
   background: var(--color-primary);
   color: white;
   padding: 2px 8px;
   border-radius: var(--radius-full);
   font-size: 12px;
   font-weight: 600;
}

/* ============================================================ */
/* Ingredient Analyzer — futuristic, on-brand                   */
/* ============================================================ */
.ingredient-modal-content {
    overflow: hidden;
    /* iOS Safari fix: .modal centers content vertically with overflow:hidden,
       so a 92vh modal can extend above the visible viewport (behind the
       notch/status bar) and clip the header + close X. Switch to dvh (which
       excludes browser chrome) and subtract safe-area insets so the entire
       header is always visible on iPhones. !important is needed because the
       HTML carries inline max-height:92vh. */
    max-height: 92vh; /* fallback for browsers without dvh support */
    max-height: min(92dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px)) !important;
}

/* Anchor any modal that hosts an ingredient-modal-content to the TOP of the
   safe area instead of vertical-centering it. iOS Safari's position:fixed +
   align-items:center combo otherwise pushes the centered modal's top edge
   behind the notch/status bar, hiding the header + close button. */
.modal:has(.ingredient-modal-content) {
    align-items: flex-start;
    padding-top: max(env(safe-area-inset-top, 0px), 12px);
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    box-sizing: border-box;
}
.ingredient-modal-header {
    position: relative;
    overflow: hidden;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}
.ingredient-modal-header-bg {
    position: absolute; inset: 0;
    background:
        radial-gradient(120% 100% at 0% 0%, rgba(67,233,123,0.85) 0%, rgba(56,249,215,0.0) 55%),
        radial-gradient(120% 100% at 100% 0%, rgba(102,126,234,0.95) 0%, rgba(118,75,162,0.85) 60%);
    background-color: #0f172a;
}
.ingredient-modal-header-bg::after {
    content: '';
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(80% 60% at 70% 30%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(80% 60% at 70% 30%, #000 30%, transparent 75%);
    opacity: 0.7;
}
.ingredient-logo-orb {
    width: 44px; height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #0f172a;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 8px 24px rgba(56,249,215,0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}
.ingredient-close-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-base);
    backdrop-filter: blur(8px);
}
.ingredient-close-btn:hover { background: rgba(255,255,255,0.22); transform: scale(1.05); }

/* Keep the close X (and the rest of the action cluster) reachable on narrow
   viewports. Without this, 5 × 36px buttons + logo + title overflow the
   modal width and get clipped by the parent's overflow:hidden. */
@media (max-width: 640px) {
    .ingredient-modal-header-row {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-top: 14px !important;
        padding-bottom: 14px !important;
        gap: 8px !important;
    }
    .ingredient-modal-header-row .ingredient-logo-orb {
        width: 38px; height: 38px;
        font-size: 17px;
        border-radius: 12px;
    }
    .ingredient-modal-header-row h2 { font-size: 16px; line-height: 1.2; }
    .ingredient-modal-subtitle { display: none; }
    .ingredient-modal-header-row .ingredient-close-btn {
        width: 32px; height: 32px;
        font-size: 12px;
    }
    .ingredient-modal-header-row > div:last-child { gap: 6px !important; }
}
@media (max-width: 380px) {
    .ingredient-modal-header-row .ingredient-close-btn { width: 30px; height: 30px; }
    .ingredient-modal-header-row > div:last-child { gap: 4px !important; }
}

.ingredient-modal-body {
    padding: 20px 22px 24px;
    overflow-y: auto;
    flex: 1;
    background: #fafbff;
    display: flex; flex-direction: column; gap: 18px;
    -webkit-overflow-scrolling: touch;
}

.ingredient-goal-banner {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    background: linear-gradient(135deg, rgba(67,233,123,0.1) 0%, rgba(102,126,234,0.08) 100%);
    border: 1px solid rgba(16,185,129,0.18);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: #0f5132;
    font-size: 13px;
}
.ingredient-goal-chip {
    background: white;
    border: 1px solid rgba(16,185,129,0.25);
    color: #047857;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.ingredient-capture-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1.5px dashed #c7d2fe;
    padding: 22px;
    transition: all var(--transition-base);
}
.ingredient-capture-card:hover { border-color: var(--color-primary); }

.ingredient-upload-placeholder {
    display: flex; flex-direction: column; align-items: center;
}
.ingredient-scan-orb {
    position: relative;
    width: 88px; height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #0f172a;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
    box-shadow: 0 12px 32px rgba(56,249,215,0.4), inset 0 2px 0 rgba(255,255,255,0.5);
}
.ingredient-scan-ring {
    position: absolute; inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(67,233,123,0.5);
    animation: ingredient-pulse 2.2s ease-out infinite;
}
.ingredient-scan-ring--delay { animation-delay: 1.1s; }
@keyframes ingredient-pulse {
    0% { transform: scale(0.85); opacity: 0.9; }
    100% { transform: scale(1.5); opacity: 0; }
}

.ingredient-upload-preview {
    display: flex; flex-direction: column; align-items: center;
}
.ingredient-preview-img {
    max-height: 280px;
    width: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.ingredient-cta-btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex; align-items: center; justify-content: center;
}
.ingredient-cta-btn--primary {
    flex: 1;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 6px 16px rgba(16,185,129,0.3);
}
.ingredient-cta-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(16,185,129,0.4); }
.ingredient-cta-btn--primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.ingredient-cta-btn--ghost {
    background: white;
    color: var(--color-text-primary);
    border: 1.5px solid var(--color-border);
}
.ingredient-cta-btn--ghost:hover { background: var(--color-bg); border-color: var(--color-primary); }

.ingredient-status-card {
    display: flex; align-items: center; gap: 14px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}
.ingredient-status-spinner {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(16,185,129,0.18);
    border-top-color: #10b981;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.ingredient-results {
    display: flex; flex-direction: column; gap: 16px;
    animation: fadeSlideUp 0.4s ease both;
}

.ingredient-score-hero {
    display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.ingredient-score-hero::before {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(60% 60% at 20% 20%, rgba(67,233,123,0.18) 0%, transparent 60%),
        radial-gradient(60% 60% at 100% 80%, rgba(102,126,234,0.25) 0%, transparent 60%);
    pointer-events: none;
}
@media (max-width: 540px) {
    .ingredient-score-hero { grid-template-columns: 1fr; text-align: center; }
}

.ingredient-score-gauge-wrap {
    position: relative; width: 160px; height: 160px; margin: 0 auto;
}
.ingredient-score-gauge { width: 100%; height: 100%; transform: rotate(0deg); }
.ingredient-score-gauge-bg {
    fill: none;
    stroke: rgba(255,255,255,0.1);
    stroke-width: 10;
}
.ingredient-score-gauge-fg {
    fill: none;
    stroke: url(#ingredientGaugeGrad);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 326.7;
    stroke-dashoffset: 326.7;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
    filter: drop-shadow(0 0 6px rgba(56,249,215,0.45));
}
.ingredient-score-center {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ingredient-score-number {
    font-size: 44px; font-weight: 800; line-height: 1;
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ingredient-score-out-of { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 4px; letter-spacing: 0.05em; }

.ingredient-score-meta { position: relative; }
.ingredient-verdict-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: white;
}
.ingredient-verdict-badge[data-tier="excellent"] { background: linear-gradient(135deg, #10b981, #059669); border-color: transparent; }
.ingredient-verdict-badge[data-tier="good"]      { background: linear-gradient(135deg, #22d3ee, #0ea5e9); border-color: transparent; }
.ingredient-verdict-badge[data-tier="mediocre"]  { background: linear-gradient(135deg, #f59e0b, #d97706); border-color: transparent; }
.ingredient-verdict-badge[data-tier="avoid"]     { background: linear-gradient(135deg, #ef4444, #b91c1c); border-color: transparent; }
.ingredient-verdict-badge[data-tier="unclear"]   { background: rgba(148,163,184,0.4); border-color: rgba(255,255,255,0.2); }

.ingredient-score-hero p, .ingredient-score-hero .text-sm { color: rgba(255,255,255,0.85); }
.ingredient-score-hero #ingredientProductGuess { color: rgba(255,255,255,0.6) !important; }

.ingredient-category-badge {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.9);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    max-width: 100%;
}
.ingredient-category-badge i { font-size: 10px; opacity: 0.75; }
.ingredient-category-badge.hidden { display: none; }
.ingredient-category-context {
    display: block;
    width: 100%;
    margin-top: 4px;
    color: rgba(255,255,255,0.7);
    font-weight: 400;
    font-size: 11px;
    line-height: 1.35;
}
.ingredient-category-context:empty { display: none; }

.ingredient-section {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px 18px;
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-xs);
}
.ingredient-section-title {
    font-size: 13px; font-weight: 700; color: var(--color-text-primary);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.ingredient-section--healthy { border-color: rgba(16,185,129,0.25); background: linear-gradient(180deg, rgba(16,185,129,0.04), white 60%); }
.ingredient-section--concerning { border-color: rgba(244,63,94,0.22); background: linear-gradient(180deg, rgba(244,63,94,0.04), white 60%); }
.ingredient-section--flag { border-color: rgba(244,63,94,0.3); background: linear-gradient(180deg, rgba(244,63,94,0.06), white 60%); }

/* Goal mini cards */
.ingredient-goal-card {
    background: linear-gradient(180deg, #f8fafc 0%, white 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px;
}
.ingredient-goal-card-header { display: flex; align-items: center; justify-content: space-between; }
.ingredient-goal-card-name { font-weight: 700; color: var(--color-text-primary); font-size: 13px; }
.ingredient-goal-card-score { font-weight: 800; font-size: 18px; color: var(--color-primary); }
.ingredient-goal-bar {
    width: 100%; height: 6px; background: var(--color-border-light); border-radius: var(--radius-full); overflow: hidden;
}
.ingredient-goal-bar-fill {
    height: 100%; border-radius: var(--radius-full);
    background: linear-gradient(90deg, #ef4444, #f59e0b, #10b981);
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.ingredient-goal-card-note { font-size: 11px; color: var(--color-text-secondary); line-height: 1.5; }

/* Macro grid */
.ingredient-macro-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.ingredient-macro-tile {
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--color-border-light);
    background: #f8fafc;
    display: flex; flex-direction: column; gap: 4px;
}
.ingredient-macro-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-secondary); font-weight: 600; }
.ingredient-macro-value { font-size: 14px; font-weight: 700; color: var(--color-text-primary); }
.ingredient-macro-tile[data-tone="good"]    { background: linear-gradient(135deg, rgba(16,185,129,0.10), rgba(16,185,129,0.02)); border-color: rgba(16,185,129,0.25); }
.ingredient-macro-tile[data-tone="warn"]    { background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(245,158,11,0.02)); border-color: rgba(245,158,11,0.3); }
.ingredient-macro-tile[data-tone="bad"]     { background: linear-gradient(135deg, rgba(244,63,94,0.10), rgba(244,63,94,0.02)); border-color: rgba(244,63,94,0.3); }
.ingredient-macro-tile[data-tone="neutral"] { background: #f8fafc; }

/* Ingredient rows */
.ingredient-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
}
.ingredient-row-dot {
    width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto;
}
.ingredient-row-dot--good { background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,0.15); }
.ingredient-row-dot--low { background: #fbbf24; box-shadow: 0 0 0 4px rgba(251,191,36,0.18); }
.ingredient-row-dot--medium { background: #f97316; box-shadow: 0 0 0 4px rgba(249,115,22,0.18); }
.ingredient-row-dot--high { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,0.18); }
.ingredient-row-name { font-weight: 600; color: var(--color-text-primary); font-size: 13px; }
.ingredient-row-reason { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; line-height: 1.5; }

.ingredient-red-flag-chip {
    background: rgba(244,63,94,0.1);
    color: #b91c1c;
    border: 1px solid rgba(244,63,94,0.25);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

/* Consumption Frequency card */
.ingredient-frequency-card {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    background: linear-gradient(135deg, #f8fafc 0%, white 100%);
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
    animation: fadeSlideUp 0.5s ease both;
}
.ingredient-frequency-card::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.6) 100%);
    pointer-events: none;
    opacity: 0.3;
}
.ingredient-frequency-icon {
    width: 56px; height: 56px; flex: 0 0 auto;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 22px;
    box-shadow: var(--shadow-md);
    position: relative;
}
.ingredient-frequency-body { position: relative; flex: 1; min-width: 0; }
.ingredient-frequency-eyebrow {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--color-text-secondary); font-weight: 700;
}
.ingredient-frequency-label {
    font-size: 20px; font-weight: 800; color: var(--color-text-primary);
    line-height: 1.2; margin-top: 2px;
}
.ingredient-frequency-portion {
    display: inline-block; margin-top: 6px;
    font-size: 11px; font-weight: 600;
    padding: 2px 10px; border-radius: var(--radius-full);
    background: rgba(15,23,42,0.06); color: var(--color-text-primary);
}
.ingredient-frequency-portion:empty { display: none; }
.ingredient-frequency-reason {
    font-size: 12px; color: var(--color-text-secondary);
    line-height: 1.5; margin-top: 8px;
}

/* Tier color palettes — icon background + subtle card tint */
.ingredient-frequency-card[data-tone="great"] {
    background: linear-gradient(135deg, rgba(16,185,129,0.08) 0%, white 70%);
    border-color: rgba(16,185,129,0.25);
}
.ingredient-frequency-card[data-tone="great"] .ingredient-frequency-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.ingredient-frequency-card[data-tone="good"] {
    background: linear-gradient(135deg, rgba(34,211,238,0.08) 0%, white 70%);
    border-color: rgba(14,165,233,0.25);
}
.ingredient-frequency-card[data-tone="good"] .ingredient-frequency-icon {
    background: linear-gradient(135deg, #22d3ee 0%, #0ea5e9 100%);
}
.ingredient-frequency-card[data-tone="ok"] {
    background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, white 70%);
    border-color: rgba(102,126,234,0.25);
}
.ingredient-frequency-card[data-tone="ok"] .ingredient-frequency-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.ingredient-frequency-card[data-tone="warn"] {
    background: linear-gradient(135deg, rgba(245,158,11,0.10) 0%, white 70%);
    border-color: rgba(245,158,11,0.3);
}
.ingredient-frequency-card[data-tone="warn"] .ingredient-frequency-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.ingredient-frequency-card[data-tone="low"] {
    background: linear-gradient(135deg, rgba(249,115,22,0.10) 0%, white 70%);
    border-color: rgba(249,115,22,0.3);
}
.ingredient-frequency-card[data-tone="low"] .ingredient-frequency-icon {
    background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
}
.ingredient-frequency-card[data-tone="bad"] {
    background: linear-gradient(135deg, rgba(239,68,68,0.10) 0%, white 70%);
    border-color: rgba(239,68,68,0.3);
}
.ingredient-frequency-card[data-tone="bad"] .ingredient-frequency-icon {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}

.ingredient-recommendation {
    display: flex; gap: 14px;
    background: linear-gradient(135deg, rgba(67,233,123,0.08) 0%, rgba(102,126,234,0.06) 100%);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}
.ingredient-recommendation-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    color: #0f172a;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex: 0 0 auto;
    box-shadow: 0 4px 12px rgba(245,158,11,0.25);
}

.ingredient-raw-details {
    background: white;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 0 14px;
}
.ingredient-raw-details summary {
    cursor: pointer; padding: 10px 0; font-size: 12px; font-weight: 600; color: var(--color-text-secondary);
    list-style: none;
}
.ingredient-raw-details summary::-webkit-details-marker { display: none; }
.ingredient-raw-details summary::before { content: '\002B'; margin-right: 8px; font-weight: 800; color: var(--color-primary); }
.ingredient-raw-details[open] summary::before { content: '\2212'; }
.ingredient-raw-text {
    white-space: pre-wrap; word-break: break-word;
    font-family: 'SF Mono', Menlo, monospace; font-size: 11px;
    color: var(--color-text-secondary);
    padding: 0 0 12px;
    max-height: 220px; overflow: auto;
}

/* Edit-profile pen button in goal banner */
.ingredient-edit-profile-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: white;
    border: 1px solid rgba(16,185,129,0.25);
    color: #047857;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-base);
    flex: 0 0 auto;
}
.ingredient-edit-profile-btn:hover { background: #d1fae5; transform: rotate(8deg); }

/* Aisle mode toggle "active" state — uses the same close-btn baseline */
.ingredient-close-btn.is-active {
    background: linear-gradient(135deg, #fcd34d, #f59e0b) !important;
    color: #0f172a !important;
    border-color: transparent !important;
}

/* Data source badge */
.ingredient-source-badge {
    align-self: flex-start;
    display: inline-flex; align-items: center;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, rgba(102,126,234,0.12), rgba(67,233,123,0.10));
    border: 1px solid rgba(102,126,234,0.25);
    color: #3730a3;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.02em;
}

/* Section aside (right-aligned tiny text in section header) */
.ingredient-section-aside {
    margin-left: auto;
    font-size: 11px; color: var(--color-text-secondary);
    font-weight: 500; text-transform: none; letter-spacing: 0;
}
.ingredient-section-title { display: flex; align-items: center; }

/* Nutrition facts grid */
.ingredient-nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}
.ingredient-nutrition-tile {
    background: #f8fafc;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 2px;
}
.ingredient-nutrition-tile[data-tone="good"] { background: linear-gradient(135deg, rgba(16,185,129,0.10), rgba(16,185,129,0.02)); border-color: rgba(16,185,129,0.25); }
.ingredient-nutrition-tile[data-tone="warn"] { background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(245,158,11,0.02)); border-color: rgba(245,158,11,0.3); }
.ingredient-nutrition-tile[data-tone="bad"]  { background: linear-gradient(135deg, rgba(244,63,94,0.10), rgba(244,63,94,0.02)); border-color: rgba(244,63,94,0.3); }
.ingredient-nutrition-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-secondary); font-weight: 700; }
.ingredient-nutrition-value { font-size: 16px; font-weight: 800; color: var(--color-text-primary); }
.ingredient-nutrition-sub { font-size: 10px; color: var(--color-text-secondary); margin-top: 2px; }

/* Per-100kcal density row */
.ingredient-density-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--color-border);
}
.ingredient-density-tile {
    background: linear-gradient(135deg, rgba(67,233,123,0.10), rgba(56,249,215,0.06));
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex; align-items: center; gap: 10px;
}
.ingredient-density-tile[data-tone="bad"] {
    background: linear-gradient(135deg, rgba(244,63,94,0.08), rgba(244,63,94,0.02));
    border-color: rgba(244,63,94,0.25);
}
.ingredient-density-tile[data-tone="warn"] {
    background: linear-gradient(135deg, rgba(245,158,11,0.10), rgba(245,158,11,0.02));
    border-color: rgba(245,158,11,0.3);
}
.ingredient-density-icon {
    width: 32px; height: 32px; border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white; display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex: 0 0 auto;
}
.ingredient-density-tile[data-tone="bad"] .ingredient-density-icon { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.ingredient-density-tile[data-tone="warn"] .ingredient-density-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ingredient-density-label { font-size: 11px; color: var(--color-text-secondary); font-weight: 600; }
.ingredient-density-value { font-size: 14px; font-weight: 800; color: var(--color-text-primary); }

/* Alternatives */
.ingredient-section--alts {
    background: linear-gradient(180deg, rgba(102,126,234,0.05), white 60%);
    border-color: rgba(102,126,234,0.25);
}
.ingredient-alts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 600px) {
    .ingredient-alts-grid { grid-template-columns: 1fr 1fr; }
}
.ingredient-alt-card {
    background: white;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex; flex-direction: column; gap: 6px;
    transition: all var(--transition-base);
}
.ingredient-alt-card:hover { border-color: var(--color-primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ingredient-alt-name { font-weight: 700; color: var(--color-text-primary); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ingredient-alt-name i { color: var(--color-primary); }
.ingredient-alt-why { font-size: 12px; color: var(--color-text-secondary); line-height: 1.5; }

/* ========================= */
/* Aisle Mode (compact view) */
/* ========================= */
.ingredient-aisle-results {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    animation: fadeSlideUp 0.4s ease both;
}
.ingredient-aisle-card {
    width: 100%;
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: white;
    box-shadow: var(--shadow-xl);
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.ingredient-aisle-card::before {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(60% 50% at 50% 0%, rgba(67,233,123,0.18), transparent 60%),
        radial-gradient(60% 50% at 50% 100%, rgba(102,126,234,0.25), transparent 60%);
    pointer-events: none;
}
.ingredient-aisle-card > * { position: relative; z-index: 1; }
.ingredient-aisle-card[data-tier="excellent"] { background: linear-gradient(180deg, #059669 0%, #064e3b 100%); }
.ingredient-aisle-card[data-tier="good"]      { background: linear-gradient(180deg, #0ea5e9 0%, #0c4a6e 100%); }
.ingredient-aisle-card[data-tier="mediocre"]  { background: linear-gradient(180deg, #d97706 0%, #78350f 100%); }
.ingredient-aisle-card[data-tier="avoid"]     { background: linear-gradient(180deg, #dc2626 0%, #7f1d1d 100%); }
.ingredient-aisle-decision-icon {
    width: 84px; height: 84px; border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex; align-items: center; justify-content: center;
    font-size: 40px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.ingredient-aisle-decision {
    font-size: 36px; font-weight: 900; letter-spacing: -0.02em;
    line-height: 1;
}
.ingredient-aisle-score {
    font-size: 28px; font-weight: 800;
}
.ingredient-aisle-score span { font-size: 14px; color: rgba(255,255,255,0.6); font-weight: 600; }
.ingredient-aisle-frequency {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.18);
    font-weight: 700; font-size: 13px;
}
.ingredient-aisle-reason {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    max-width: 480px;
    line-height: 1.5;
}
.ingredient-aisle-details-btn {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 10px 16px;
    border-radius: var(--radius-full);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-top: 4px;
}
.ingredient-aisle-details-btn:hover { background: rgba(255,255,255,0.22); }

/* ========================= */
/* Profile Sub-Modal Pieces  */
/* ========================= */
.ingredient-profile-toggle-row {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.ingredient-profile-who-btn {
    flex: 1;
    min-width: 100px;
    border: 1.5px solid var(--color-border);
    background: white;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text-secondary);
    transition: all var(--transition-base);
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.ingredient-profile-who-btn.is-active {
    border-color: transparent;
    color: white;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 6px 16px rgba(16,185,129,0.3);
}

.ingredient-pill-grid {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.ingredient-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--color-border);
    background: white;
    color: var(--color-text-secondary);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    user-select: none;
}
.ingredient-pill:hover { border-color: var(--color-primary); color: var(--color-primary); }
.ingredient-pill.is-active {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(16,185,129,0.25);
}
.ingredient-pill.is-active-warn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-color: transparent;
}

/* ============================================================ */
/* INGREDIENT ANALYZER — Today's Intake Strip                  */
/* ============================================================ */
.ingredient-today-strip {
    margin: 0 16px 12px;
    padding: 10px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(16,185,129,0.07), rgba(16,185,129,0.02));
    border: 1px solid rgba(16,185,129,0.2);
    cursor: pointer;
    transition: all var(--transition-base);
}
.ingredient-today-strip:hover { background: linear-gradient(135deg, rgba(16,185,129,0.12), rgba(16,185,129,0.04)); }
.ingredient-today-strip-head {
    display: flex; align-items: center;
    font-size: 12px; font-weight: 700; color: #047857;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.ingredient-today-strip-bars {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 8px; margin-top: 8px;
}
.ingredient-today-bar {
    display: flex; flex-direction: column; gap: 4px;
}
.ingredient-today-bar-label {
    font-size: 10px; font-weight: 700; color: #475569;
    display: flex; justify-content: space-between; align-items: center;
}
.ingredient-today-bar-track {
    height: 6px; border-radius: 999px;
    background: rgba(15,23,42,0.07);
    overflow: hidden;
}
.ingredient-today-bar-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, #10b981, #059669);
    transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}
.ingredient-today-bar[data-tone="bad"] .ingredient-today-bar-fill { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.ingredient-today-bar[data-tone="warn"] .ingredient-today-bar-fill { background: linear-gradient(90deg, #f59e0b, #d97706); }

/* ============================================================ */
/* INGREDIENT ANALYZER — Photo Quality Coach                   */
/* ============================================================ */
.ingredient-photo-coach {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(15,23,42,0.08);
    background: linear-gradient(180deg, #f8fafc, white 80%);
}
.ingredient-photo-coach[data-tone="ok"]   { border-color: rgba(16,185,129,0.25); background: linear-gradient(180deg, rgba(16,185,129,0.05), white 70%); }
.ingredient-photo-coach[data-tone="warn"] { border-color: rgba(245,158,11,0.35); background: linear-gradient(180deg, rgba(245,158,11,0.08), white 70%); }
.ingredient-photo-coach[data-tone="bad"]  { border-color: rgba(239,68,68,0.35);  background: linear-gradient(180deg, rgba(239,68,68,0.07), white 70%); }
.ingredient-photo-coach-head {
    display: flex; align-items: center; gap: 12px;
}
.ingredient-photo-coach-head > i {
    font-size: 18px; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; background: white;
    color: #475569;
    box-shadow: 0 2px 6px rgba(15,23,42,0.06);
}
.ingredient-photo-coach[data-tone="ok"] .ingredient-photo-coach-head > i   { color: #059669; }
.ingredient-photo-coach[data-tone="warn"] .ingredient-photo-coach-head > i { color: #d97706; }
.ingredient-photo-coach[data-tone="bad"] .ingredient-photo-coach-head > i  { color: #b91c1c; }
.ingredient-photo-coach-title { font-size: 13px; font-weight: 700; color: var(--color-text-primary); }
.ingredient-photo-coach-sub   { font-size: 11px; color: var(--color-text-secondary); margin-top: 2px; }
.ingredient-photo-coach-score {
    margin-left: auto;
    font-size: 16px; font-weight: 800;
    color: #059669;
    background: rgba(16,185,129,0.1);
    padding: 4px 10px; border-radius: 999px;
    min-width: 48px; text-align: center;
}
.ingredient-photo-coach[data-tone="warn"] .ingredient-photo-coach-score { color: #d97706; background: rgba(245,158,11,0.12); }
.ingredient-photo-coach[data-tone="bad"]  .ingredient-photo-coach-score { color: #b91c1c; background: rgba(239,68,68,0.12); }
.ingredient-photo-coach-list {
    margin: 10px 0 0; padding: 0; list-style: none;
    display: flex; flex-direction: column; gap: 6px;
}
.ingredient-photo-coach-list:empty { display: none; }
.ingredient-photo-coach-list li {
    font-size: 12px; color: #334155;
    display: flex; gap: 8px; align-items: flex-start;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(15,23,42,0.04);
}
.ingredient-photo-coach-list li i { margin-top: 2px; }
.ingredient-photo-coach-list li[data-level="bad"]  { background: rgba(239,68,68,0.08); color: #991b1b; }
.ingredient-photo-coach-list li[data-level="warn"] { background: rgba(245,158,11,0.10); color: #92400e; }

/* ============================================================ */
/* INGREDIENT ANALYZER — Log Serving Card                      */
/* ============================================================ */
.ingredient-log-card {
    display: flex; flex-wrap: wrap; gap: 14px;
    align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1.5px dashed rgba(16,185,129,0.4);
    background: linear-gradient(135deg, rgba(16,185,129,0.06), rgba(16,185,129,0.02));
}
.ingredient-log-card.is-logged {
    border-style: solid;
    border-color: rgba(16,185,129,0.5);
    background: linear-gradient(135deg, rgba(16,185,129,0.14), rgba(16,185,129,0.04));
}
.ingredient-log-card-info { flex: 1 1 220px; min-width: 0; }
.ingredient-log-card-eyebrow {
    font-size: 11px; font-weight: 700; color: #047857;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.ingredient-log-card-title {
    margin-top: 4px; font-size: 13px; font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.45;
}
.ingredient-log-card-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ingredient-log-stepper {
    display: inline-flex; align-items: center;
    background: white;
    border: 1.5px solid rgba(15,23,42,0.1);
    border-radius: 999px;
    padding: 2px;
}
.ingredient-log-stepper button {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px;
    color: var(--color-primary);
    transition: all var(--transition-base);
}
.ingredient-log-stepper button:hover { background: rgba(16,185,129,0.1); }
.ingredient-log-stepper span {
    min-width: 36px; text-align: center;
    font-weight: 700; color: var(--color-text-primary);
}

/* ============================================================ */
/* INGREDIENT ANALYZER — Scan History List                     */
/* ============================================================ */
.ingredient-history-controls {
    display: flex; flex-direction: column; gap: 10px;
    margin-bottom: 14px;
}
.ingredient-history-search-wrap {
    position: relative;
}
.ingredient-history-search-wrap > i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: #94a3b8; font-size: 13px;
}
.ingredient-history-search-wrap input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border-radius: 12px;
    border: 1.5px solid var(--color-border);
    font-size: 14px;
    background: white;
    transition: all var(--transition-base);
}
.ingredient-history-search-wrap input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.ingredient-history-filter-row {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.ingredient-history-filter-pill {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1.5px solid var(--color-border);
    background: white;
    font-size: 12px; font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}
.ingredient-history-filter-pill.is-active {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white; border-color: transparent;
}

.ingredient-history-trend {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white;
    margin-bottom: 14px;
}
.ingredient-history-trend-tile {
    display: flex; flex-direction: column;
    text-align: center;
}
.ingredient-history-trend-label {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.05em; opacity: 0.65;
    font-weight: 700;
}
.ingredient-history-trend-value {
    margin-top: 4px;
    font-size: 22px; font-weight: 800;
    line-height: 1;
}
.ingredient-history-trend-sub {
    margin-top: 2px;
    font-size: 10px; opacity: 0.75;
}

.ingredient-history-list {
    display: flex; flex-direction: column; gap: 10px;
}
.ingredient-history-item {
    display: flex; gap: 12px; align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1.5px solid var(--color-border);
    background: white;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
}
.ingredient-history-item:hover {
    border-color: rgba(16,185,129,0.4);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15,23,42,0.06);
}
.ingredient-history-item.is-selected {
    border-color: rgba(16,185,129,0.6);
    background: linear-gradient(135deg, rgba(16,185,129,0.07), rgba(16,185,129,0.02));
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.ingredient-history-thumb {
    width: 56px; height: 56px;
    border-radius: 12px;
    background: #f1f5f9 center/cover no-repeat;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; font-size: 20px;
}
.ingredient-history-meta { flex: 1; min-width: 0; }
.ingredient-history-product {
    font-weight: 700; color: var(--color-text-primary);
    font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ingredient-history-row {
    display: flex; gap: 8px; align-items: center;
    margin-top: 4px;
    font-size: 11px; color: #64748b;
    flex-wrap: wrap;
}
.ingredient-history-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569; font-weight: 600;
    font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.ingredient-history-tag.is-logged { background: rgba(16,185,129,0.12); color: #047857; }
.ingredient-history-score {
    flex-shrink: 0;
    width: 48px; height: 48px;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 16px;
    color: white;
    background: linear-gradient(135deg, #94a3b8, #64748b);
}
.ingredient-history-score[data-tier="excellent"] { background: linear-gradient(135deg, #10b981, #059669); }
.ingredient-history-score[data-tier="good"]      { background: linear-gradient(135deg, #22d3ee, #0ea5e9); }
.ingredient-history-score[data-tier="mediocre"]  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ingredient-history-score[data-tier="avoid"]     { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.ingredient-history-score[data-tier="unclear"]   { background: linear-gradient(135deg, #94a3b8, #64748b); }
.ingredient-history-delete {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px;
    border-radius: 999px;
    background: white;
    color: #94a3b8;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    opacity: 0; transition: all var(--transition-base);
}
.ingredient-history-item:hover .ingredient-history-delete { opacity: 1; }
.ingredient-history-delete:hover { color: #b91c1c; background: #fef2f2; }

.ingredient-history-empty {
    text-align: center; padding: 40px 20px;
    color: var(--color-text-secondary);
}
.ingredient-history-empty i { font-size: 36px; margin-bottom: 10px; opacity: 0.4; }
.ingredient-history-empty p { font-size: 13px; }

.ingredient-history-compare-banner {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(99,102,241,0.04));
    border: 1px solid rgba(99,102,241,0.3);
    display: flex; align-items: center;
    font-size: 13px; font-weight: 600; color: #4338ca;
}
.ingredient-history-compare-result {
    margin-bottom: 14px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(15,23,42,0.08);
    background: linear-gradient(180deg, #f8fafc, white 80%);
}
.ingredient-history-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.ingredient-history-compare-col {
    padding: 10px; border-radius: 12px;
    background: white; border: 1px solid rgba(15,23,42,0.06);
}
.ingredient-history-compare-col h4 {
    font-size: 12px; font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ingredient-history-compare-row {
    display: grid;
    grid-template-columns: 1fr 80px 1fr;
    align-items: center; gap: 8px;
    padding: 6px 0;
    border-top: 1px dashed rgba(15,23,42,0.07);
    font-size: 12px;
}
.ingredient-history-compare-row:first-child { border-top: 0; }
.ingredient-history-compare-key {
    text-align: center;
    font-size: 10px; font-weight: 700;
    color: #64748b;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.ingredient-history-compare-cell {
    text-align: center;
    font-weight: 700; color: var(--color-text-primary);
}
.ingredient-history-compare-cell.is-better { color: #059669; }
.ingredient-history-compare-cell.is-worse  { color: #b91c1c; }

/* ============================================================ */
/* INGREDIENT ANALYZER — Daily Targets                         */
/* ============================================================ */
.ingredient-targets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.ingredient-target-tile {
    padding: 12px;
    border-radius: 14px;
    background: white;
    border: 1px solid rgba(15,23,42,0.08);
    display: flex; flex-direction: column; gap: 6px;
}
.ingredient-target-ring-wrap {
    position: relative;
    width: 80px; height: 80px;
    margin: 0 auto;
}
.ingredient-target-ring-bg, .ingredient-target-ring-fg {
    fill: none; stroke-width: 8;
}
.ingredient-target-ring-bg { stroke: rgba(15,23,42,0.07); }
.ingredient-target-ring-fg {
    stroke: #10b981;
    stroke-linecap: round;
    transition: stroke-dashoffset 800ms cubic-bezier(0.4, 0, 0.2, 1), stroke 200ms;
}
.ingredient-target-tile[data-tone="warn"] .ingredient-target-ring-fg { stroke: #f59e0b; }
.ingredient-target-tile[data-tone="bad"]  .ingredient-target-ring-fg { stroke: #ef4444; }
.ingredient-target-ring-center {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; color: var(--color-text-primary);
    flex-direction: column;
}
.ingredient-target-ring-center .pct { font-size: 16px; }
.ingredient-target-ring-center .of  { font-size: 9px; color: #94a3b8; font-weight: 600; margin-top: 1px; letter-spacing: 0.04em; }
.ingredient-target-tile-label {
    text-align: center;
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.05em; font-weight: 700; color: #64748b;
}
.ingredient-target-tile-value {
    text-align: center;
    font-size: 13px; font-weight: 700; color: var(--color-text-primary);
}
.ingredient-target-tile-value small {
    color: #94a3b8; font-weight: 600; font-size: 11px;
}

.ingredient-targets-logged-list {
    margin-top: 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.ingredient-targets-logged-list:empty { display: none; }
.ingredient-targets-logged-row {
    display: flex; gap: 10px; align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 12px;
}
.ingredient-targets-logged-name { flex: 1; font-weight: 600; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ingredient-targets-logged-meta { color: #64748b; font-size: 11px; }
.ingredient-targets-logged-remove {
    color: #94a3b8; padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    transition: all var(--transition-base);
}
.ingredient-targets-logged-remove:hover { color: #b91c1c; background: #fef2f2; }

.ingredient-targets-editor {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}
.ingredient-targets-editor-row {
    display: flex; flex-direction: column; gap: 4px;
}
.ingredient-targets-editor-row label {
    font-size: 11px; font-weight: 700;
    color: #64748b; text-transform: uppercase; letter-spacing: 0.04em;
}
.ingredient-targets-editor-row input {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1.5px solid var(--color-border);
    background: white;
    font-size: 13px; font-weight: 600;
    color: var(--color-text-primary);
    transition: all var(--transition-base);
}
.ingredient-targets-editor-row input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
