/* finbrain PWA - Material Design 3 Design System */

@layer legacy {

/* ===== CSS CUSTOM PROPERTIES (MD3 Tokens) ===== */
:root {
    /* Primary Brand Colors (MD3) */
    --brand-primary: #0A68FF;                      /* MD3 Primary - WCAG 4.6:1 */
    --brand-primary-hover: #0854CC;                /* MD3 Primary Hover - WCAG 6.5:1 */
    --color-primary: #0A68FF;                      /* Alias for legacy compatibility */
    --color-primary-hover: #0854CC;                /* Alias for legacy */
    --color-primary-light: #E6F2FF;                /* Light shade of #0A68FF (50) */
    --color-primary-container: #D3E3FD;            /* Light shade of #0A68FF (100) */
    
    /* Secondary Palette (Google-grade) */
    --color-secondary: #2E7D32;                    /* Success Green - Growth */
    --color-secondary-hover: #1B5E20;              /* Green 800 for hover */
    --color-secondary-light: #C8E6C9;              /* Green 100 */
    --color-secondary-container: #E8F5E9;          /* Green 50 */
    
    /* Tertiary Colors - Magenta (Celebration) */
    --color-tertiary: #C2185B;                     /* Celebration Magenta */
    --color-tertiary-hover: #AD1457;               /* Pink 800 for hover */
    --color-tertiary-light: #FCE4EC;               /* Pink 50 */
    --color-tertiary-container: #F8BBD0;           /* Pink 100 */
    
    /* Semantic Colors (MD3) */
    --color-success: #1E8E3E;                      /* MD3 Success Green */
    --success-green: #2E7D32;                      /* Alternative success */
    --color-success-hover: #1B5E20;
    --color-success-light: #E8F5E9;
    --color-warning: #F9AB00;                      /* MD3 Warning Yellow */
    --warning-yellow: #F9AB00;
    --color-warning-hover: #E65100;
    --color-warning-light: #FFF8E1;
    --color-error: #B3261E;                        /* MD3 Error Red */
    --error-red: #B3261E;
    --bad: #B3261E;                                /* Alias */
    --color-error-hover: #B71C1C;
    --color-error-light: #FFEBEE;
    --color-info: #0A68FF;                         /* MD3 - matches primary */
    --color-info-light: #E1F5FE;
    
    /* Surface & Background Colors (MD3) */
    --surface-page: #FFFFFF;                       /* Pure white page background */
    --surface-card: #FFFFFF;                       /* Pure white card backgrounds */
    --surface-1: #FFFFFF;                          /* Alias for surface-card */
    --surface-2: #FFFFFF;                          /* Pure white secondary surface */
    --surface-hover: #F5F5F5;                      /* Very subtle hover (95% white) */
    
    /* Text Colors (MD3) */
    --text-primary: #1A1C1E;                       /* MD3 Primary text - WCAG 14.5:1 */
    --text-secondary: #43474E;                     /* MD3 Secondary text - WCAG 9.1:1 */
    --text-muted: #43474E;                         /* Alias */
    
    /* Legacy aliases for compatibility */
    --color-bg: #FFFFFF;                           /* Pure white */
    --color-fg: #1A1C1E;                           /* Primary text (MD3) */
    --color-muted: #43474E;                        /* Secondary text (MD3) */
    --color-border: #DADCE0;                       /* Border gray */
    --color-surface: #FFFFFF;                      /* Pure white surface */
    --color-surface-variant: #FFFFFF;              /* Pure white variant surface */
    
    /* On-color text (for use on colored backgrounds) */
    --on-primary: #FFFFFF;
    --on-secondary: #FFFFFF;
    --on-tertiary: #FFFFFF;
    --on-success: #FFFFFF;
    --on-warning: #FFFFFF;
    --on-error: #FFFFFF;
    
    /* Typography (MD3 - Roboto) */
    --font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --text-xs: 0.75rem;                            /* 12px */
    --text-sm: 0.875rem;                           /* 14px */
    --text-base: 1rem;                             /* 16px */
    --text-lg: 1.125rem;                           /* 18px */
    --text-xl: 1.25rem;                            /* 20px */
    --text-2xl: 1.5rem;                            /* 24px */
    --text-3xl: 1.875rem;                          /* 30px */
    --text-4xl: 2.25rem;                           /* 36px */
    /* Legacy aliases */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    /* Spacing (MD3) */
    --space-1: 0.25rem;                            /* 4px */
    --space-2: 0.5rem;                             /* 8px */
    --space-3: 0.75rem;                            /* 12px */
    --space-4: 1rem;                               /* 16px */
    --space-5: 1.5rem;                             /* 24px - MD3 spec */
    --space-6: 2rem;                               /* 32px */
    --space-8: 3rem;                               /* 48px */
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    
    /* Border Radius (MD3) */
    --radius-sm: 0.5rem;                           /* 8px - MD3 small */
    --radius-md: 0.875rem;                         /* 14px - MD3 default */
    --radius-lg: 0.875rem;                         /* 14px - MD3 cards */
    --radius-xl: 1.125rem;                         /* 18px - MD3 large */
    --radius-full: 999px;                          /* Pills, circular */
    
    /* Shadows (MD3) */
    --shadow-soft: 0 1px 2px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.08);    /* MD3 Default */
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 12px 32px rgba(0,0,0,0.12);     /* MD3 Hover */
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.1), 0 20px 48px rgba(0,0,0,0.15);    /* MD3 Dialogs */
    /* Legacy aliases */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.08);
    
    /* Transitions (MD3) */
    --transition-fast: 0.15s ease;                 /* MD3 Quick interactions */
    --transition-base: 0.2s ease;                  /* MD3 Standard */
    --transition-slow: 0.3s ease;                  /* MD3 Smooth */
    --transition-normal: 0.2s ease;                /* Alias */
    
    /* Z-index */
    --z-nav: 100;
    --z-modal: 1000;
    --z-toast: 2500;
    
    /* Bottom Nav Metrics (single source of truth) */
    --bottom-nav-item-h: 48px;            /* min-height of a nav item */
    --bottom-nav-vert-pad: 8px;           /* top/bottom padding around items */
    --bottom-nav-h: calc(var(--bottom-nav-item-h) + (2 * var(--bottom-nav-vert-pad)));
    
    /* Safe-area aware content floor (Samsung-compatible) */
    --content-floor: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    --content-floor-legacy: calc(var(--bottom-nav-h) + constant(safe-area-inset-bottom, 0px));
    --z-tooltip: 1200;
    
    /* Focus Ring (MD3) */
    --ring: 0 0 0 3px rgba(10, 104, 255, 0.3);
    
    /* Category Colors (8 categories for MD3 UI) */
    --cat-food: #34A853;              /* Google Green */
    --cat-transport: #4285F4;         /* Google Blue */
    --cat-bills: #FBBC04;             /* Google Yellow */
    --cat-shopping: #F29900;          /* Amber */
    --cat-entertainment: #E91E63;     /* Pink - distinct from blue */
    --cat-health: #00ACC1;            /* Teal */
    --cat-education: #7C4DFF;         /* Deep Purple */
    --cat-other: #5F6368;             /* Google Gray */
}

/* ===== BASE STYLES ===== */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    background-color: #FFFFFF;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: #FFFFFF;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-4) 0;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.hero-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--color-fg);
    margin-bottom: var(--space-2);
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-muted);
    font-weight: 400;
    margin-bottom: var(--space-8);
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-6);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
}

/* ===== LAYOUT ===== */
.app-container {
    min-height: 100vh;
    padding-bottom: 80px; /* Space for bottom navigation */
}

.page-container {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-4);
    padding-bottom: var(--space-8);
}

@media (min-width: 768px) {
    .page-container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .page-container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .page-container {
        max-width: 1140px;
    }
}

.hero-section {
    text-align: center;
    padding: var(--space-8) 0;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-soft);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: var(--font-size-base);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px; /* HIG touch target */
    line-height: 1;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn-neutral {
    background: var(--color-surface);
    color: var(--color-fg);
    border: 1px solid var(--color-border);
}

.btn-neutral:hover:not(:disabled) {
    background: var(--color-primary-light);
}

.btn-success {
    background: var(--color-success);
    color: var(--on-success);
    font-weight: 600;
}

.btn-success:hover:not(:disabled) {
    background: var(--color-success-hover);
    transform: translateY(-1px);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    min-height: 36px;
}

.btn-full {
    width: 100%;
}

.btn-danger {
    background: var(--error-red);
    color: var(--on-error);
    font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-error-hover);
    transform: translateY(-1px);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
    min-height: 52px;
}

/* ===== TEXT UTILITIES (MD3) ===== */
.text-primary {
    color: var(--text-primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-success {
    color: var(--success-green) !important;
}

.text-danger {
    color: var(--error-red) !important;
}

.text-warning {
    color: var(--warning-yellow) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* ===== BACKGROUND UTILITIES (MD3) ===== */
.bg-success-light {
    background-color: var(--color-success-light) !important;
}

.bg-danger-light {
    background-color: var(--color-error-light) !important;
}

.bg-warning-light {
    background-color: var(--color-warning-light) !important;
}

.bg-primary-light {
    background-color: var(--color-primary-light) !important;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-fg);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    background: var(--color-bg);
    transition: border-color var(--transition-fast);
    min-height: 44px;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--ring);
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: var(--space-4);
    color: var(--color-muted);
    font-weight: 500;
    z-index: 1;
}

.input-group .form-input {
    padding-left: var(--space-8);
}

.form-help {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-muted);
    margin-top: var(--space-1);
}

/* ===== FIELD ERROR STYLES ===== */
.form-field-error {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px hsl(0, 84%, 60%, 0.1) !important;
}

.form-field-error:focus {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px hsl(0, 84%, 60%, 0.2) !important;
}

.field-error-message {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-error);
    margin-top: var(--space-1);
    font-weight: 500;
    animation: slideInError 0.2s ease-out;
}

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

/* ===== NAVIGATION ===== */
/* Z-INDEX HIERARCHY (single source of truth):
   - Bottom nav:        30 (visible behind scrim, non-interactive when modal open)
   - Activity scrim:    40 (covers whole app including bottom nav)
   - Activity sheet:    50 (side sheet panel)
   - Toast:            100
*/
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-page, #fff);
    border-top: 1px solid var(--outline-variant, #e6e6e6);
    padding: var(--bottom-nav-vert-pad) 12px;
    display: flex;
    justify-content: space-around;
    z-index: 30;
    min-height: var(--bottom-nav-h);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-muted);
    transition: all var(--transition-fast);
    min-width: 48px;
    min-height: 48px;
}

.nav-item:hover,
.nav-item.active {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.nav-icon {
    font-size: var(--font-size-lg);
}

.nav-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
}

/* Bottom nav line-height normalization: ensures consistent nav item height
   across all pages regardless of inherited line-height from html/body */
.bottom-nav .nav-icon,
.bottom-nav .nav-label {
    line-height: 1;
}

/* Bottom nav icon size fix: ensures Material Symbols icons render at 24px
   regardless of font-size cascade from page-specific stylesheets */
.bottom-nav .material-symbols-outlined.nav-icon {
    font-size: 24px !important;
}

/* Activity Feed Modal: Scroll lock (bottom nav remains visible but non-interactive behind scrim) */
html.activity-feed-open,
body.activity-feed-open {
    overflow: hidden !important;
}

/* ===== MD3 ACTIVITY FEED SIDE SHEET ===== */
#activity-feed-container {
    z-index: 40;
}

#activity-feed-backdrop {
    background: rgba(0, 0, 0, 0.32);
}

#activity-feed-panel {
    z-index: 50;
    background: var(--sys-surface-container-low, #F7F8FA);
    border-left: 1px solid var(--outline-variant, #C4C7C5);
    border-radius: 28px 0 0 28px;
}

/* MD3 Side Sheet Header - 56dp height */
.activity-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 8px 0 16px;
    border-bottom: 1px solid var(--outline-variant, #C4C7C5);
    flex-shrink: 0;
}

.activity-feed-header__title {
    font-size: 16px;
    font-weight: 500;
    color: var(--sys-on-surface, #1D1B20);
    margin: 0;
}

.activity-feed-header__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* MD3 Tonal Pill Button */
.activity-feed-header__show-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--sys-on-secondary-container, #1D192B);
    background: var(--sys-secondary-container, #E8DEF8);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.activity-feed-header__show-all:hover {
    background: var(--sys-secondary-container-hover, #D0BCFF);
}

/* MD3 Icon Button (40-48dp touch target) */
.activity-feed-header__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    border-radius: 24px;
    cursor: pointer;
    color: var(--sys-on-surface-variant, #49454F);
    transition: background 0.2s;
}

.activity-feed-header__close:hover {
    background: var(--sys-surface-container-highest, #E6E0E9);
}

/* MD3 Activity List Items */
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--sys-surface-container-low, #F7F8FA);
    border-radius: 16px;
    margin-bottom: 8px;
    box-shadow: none;
}

.activity-item:last-child {
    margin-bottom: 0;
}

/* MD3 Edit Icon Button (40dp touch target) */
.activity-item .edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    background: transparent;
    border-radius: 20px;
    cursor: pointer;
    color: var(--sys-on-surface-variant, #49454F);
    transition: background 0.2s;
    flex-shrink: 0;
}

.activity-item .edit-btn:hover {
    background: var(--sys-surface-container-highest, #E6E0E9);
}

/* ===== EXPENSE SPECIFIC STYLES ===== */
/* Alert Messages */
.form-messages {
    margin-bottom: 1rem;
}

.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-out;
}

.alert-success {
    background-color: var(--color-success-light);
    color: var(--color-success);
    border-left: 4px solid var(--color-success);
}

.alert-error {
    background-color: var(--color-error-light);
    color: var(--color-error);
    border-left: 4px solid var(--color-error);
}

.alert-warning {
    background-color: var(--color-warning-light);
    color: var(--color-warning);
    border-left: 4px solid var(--color-warning);
}

.alert-info {
    background-color: var(--color-info-light);
    color: var(--color-info);
    border-left: 4px solid var(--color-info);
}

.alert-celebration {
    background-color: var(--color-tertiary-light);
    color: var(--color-tertiary);
    border-left: 4px solid var(--color-tertiary);
    font-weight: 600;
}

.alert-icon {
    font-size: 1.2rem;
    min-width: 1.2rem;
}

.alert-message {
    flex: 1;
}

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

/* Legacy .expense-form-card removed - web-only architecture */

.cta-content {
    text-align: center;
    padding: var(--space-4) 0;
}

.cta-examples {
    margin-bottom: var(--space-6);
    text-align: left;
}

.cta-examples ul {
    margin: var(--space-3) 0 0 var(--space-4);
}

.cta-examples code {
    background: var(--color-surface);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: var(--font-size-sm);
}

.entries-section {
    margin-bottom: var(--space-8);
}

.entries-list {
    space-y: var(--space-4);
}

/* Responsive Grid for Expense Cards */
.entries-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 576px) {
    .entries-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.entry-item {
    display: flex;
    flex-direction: column;
    padding: var(--space-5);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
    position: relative;
    cursor: pointer;
}

.entry-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.entry-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    width: 100%;
}

.entry-category {
    font-size: var(--font-size-2xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.category-name {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-muted);
    text-transform: capitalize;
}

.entry-details {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
    display: none;
}

.entry-details.show {
    display: block;
    animation: expandDetails 0.2s ease-out;
}

.entry-details .btn {
    margin-top: var(--space-2);
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
}

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

.entry-description {
    font-weight: 500;
    margin-bottom: var(--space-2);
    font-size: var(--font-size-base);
}

.entry-meta {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.entry-amount {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.expand-icon {
    color: var(--color-muted);
    font-size: var(--font-size-sm);
    transition: transform var(--transition-fast);
}

.entry-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.amount-value {
    font-weight: 700;
    font-size: var(--font-size-xl);
    color: var(--color-fg);
}

.amount-category {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    text-transform: capitalize;
}

.detail-label {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    font-weight: 500;
}

.detail-value {
    font-size: var(--font-size-base);
    color: var(--color-fg);
}

.entry-actions {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.entry-item:hover .entry-actions,
.entry-item.show-actions .entry-actions {
    opacity: 1;
}

.entry-action {
    background: none;
    border: none;
    font-size: var(--font-size-base);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.entry-action:hover {
    background: var(--color-surface);
}

.entries-empty {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--color-muted);
}

.empty-icon {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--space-4);
}

.empty-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-fg);
    margin-bottom: var(--space-2);
}

.empty-description {
    margin-bottom: var(--space-6);
}

.entries-summary {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    text-align: center;
}

.summary-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.summary-label {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    font-weight: 500;
}

.summary-value {
    font-size: var(--font-size-sm);
    color: var(--color-fg);
    font-weight: 600;
}

.recent-expenses-list {
    margin-top: var(--space-6);
}

#progress-ring {
    margin-bottom: var(--space-4);
}

/* ===== EXPENSE ROW STYLING ===== */
.expense-row {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    transition: all var(--transition-normal);
}

.expense-row:hover {
    background: var(--color-surface);
    border-color: var(--color-primary);
}

.expense-amount {
    font-weight: 600;
    color: var(--color-fg);
    min-width: 80px;
}

.expense-separator {
    margin: 0 var(--space-2);
    color: var(--color-muted);
}

.expense-category {
    font-weight: 500;
    text-transform: capitalize;
    color: var(--color-primary);
    min-width: 100px;
}

.expense-description {
    color: var(--color-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== SUMMARY CARDS ===== */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

@media (min-width: 640px) {
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.summary-card {
    padding: var(--space-5);
    text-align: center;
    background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-bg) 100%);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.summary-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-muted);
    margin: 0;
}

.summary-icon {
    font-size: var(--font-size-lg);
}

.summary-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-fg);
    margin-bottom: var(--space-2);
}

.summary-change {
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.summary-change.positive {
    color: var(--color-success);
}

.summary-change.negative {
    color: var(--color-error);
}

.summary-change.neutral {
    color: var(--color-muted);
}

/* ===== CATEGORIES ===== */
.categories-list {
    space-y: var(--space-4);
}

.category-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}

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

.category-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
}

.category-icon {
    font-size: var(--font-size-lg);
}

.category-name {
    font-weight: 500;
}

.category-amount {
    font-weight: 600;
    color: var(--color-fg);
    margin-left: auto;
    margin-right: var(--space-4);
}

.category-bar {
    width: 60px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}

.category-progress {
    height: 100%;
    background: var(--color-primary);
    transition: width var(--transition-normal);
}

/* ===== INSIGHTS ===== */
.insights-list {
    space-y: var(--space-4);
}

.insight-item {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border-left: 4px solid;
}

.insight-tip {
    background: var(--color-primary-light);
    border-left-color: var(--color-primary);
}

.insight-warning {
    background: hsl(45, 100%, 95%);
    border-left-color: var(--color-warning);
}

.insight-success {
    background: hsl(142, 76%, 95%);
    border-left-color: var(--color-success);
}

.insight-icon {
    font-size: var(--font-size-lg);
}

.insight-content {
    flex: 1;
}

.insight-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin: 0 0 var(--space-1) 0;
}

.insight-text {
    font-size: var(--font-size-sm);
    color: var(--color-muted);
    margin: 0;
}

.insight-disclaimer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--sys-outline-variant);
    font-size: var(--font-size-xs);
    color: var(--sys-on-surface-variant);
    font-style: italic;
    text-align: center;
}

.disclaimer-text {
    opacity: 0.75;
}

/* ===== QUICK ACTIONS ===== */
.quick-actions {
    margin-bottom: var(--space-8);
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-6);
    min-height: 44px;
    min-width: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.action-card:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-card:focus {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

.action-card:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.action-card:focus:not(:focus-visible) {
    outline: none;
}

.action-icon {
    font-size: var(--font-size-2xl);
}

.action-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-align: center;
}

/* ===== TOASTS ===== */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition-normal);
}

.toast-success {
    border-left-color: var(--color-success);
    border-left-width: 4px;
}

.toast-error {
    border-left-color: var(--color-error);
    border-left-width: 4px;
}

.toast-warning {
    border-left-color: var(--color-warning);
    border-left-width: 4px;
}

.toast-info {
    border-left-color: var(--color-primary);
    border-left-width: 4px;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
}

.toast-icon {
    font-size: var(--font-size-lg);
}

.toast-message {
    flex: 1;
    font-size: var(--font-size-sm);
}

.toast-trace {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-muted);
    margin-top: var(--space-1);
    font-family: monospace;
    opacity: 0.8;
}

.toast-close {
    background: none;
    border: none;
    font-size: var(--font-size-lg);
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--color-fg);
}

/* ===== OFFLINE/PWA SPECIFIC ===== */
.offline-banner {
    background: var(--color-warning-light);
    color: var(--color-fg);
    border-bottom: 3px solid var(--color-warning);
    padding: var(--space-3);
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    transform: translateY(-100%);
    transition: transform var(--transition-normal);
}

.offline-banner:not(.hidden) {
    transform: translateY(0);
}

.offline-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.install-banner {
    background: var(--color-primary);
    color: var(--on-primary);
    padding: var(--space-3);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    transform: translateY(-100%);
    transition: transform var(--transition-normal);
}

.install-banner:not(.hidden) {
    transform: translateY(0);
}

.install-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    max-width: 428px;
    margin: 0 auto;
}

.offline-page {
    text-align: center;
    padding-top: var(--space-16);
}

.offline-hero {
    margin-bottom: var(--space-12);
}

.offline-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
}

.offline-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.offline-subtitle {
    color: var(--color-muted);
    font-size: var(--font-size-lg);
}

/* ===== WELCOME BANNER ===== */
.welcome-banner {
    margin-bottom: var(--space-4);
    padding: 0;
    overflow: hidden;
}

.welcome-banner .alert {
    margin-bottom: 0;
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    background-color: var(--color-primary-light);
    border-color: var(--color-primary-container);
    color: var(--color-fg);
}

.welcome-banner .alert-heading {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-2);
    line-height: 1.4;
    color: var(--color-primary);
}

.welcome-banner ul {
    padding-left: 1.5rem;
    margin-bottom: var(--space-2);
}

.welcome-banner li {
    margin-bottom: var(--space-1);
}

.welcome-banner .banner-icon {
    flex-shrink: 0;
}

/* ===== SMART BANNER ===== */
.smart-banner {
    margin-bottom: var(--space-4);
    padding: 0;
    overflow: hidden;
}

.smart-banner .alert {
    margin-bottom: 0;
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.smart-banner .alert-heading {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-2);
    line-height: 1.4;
}

.smart-banner .alert p {
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-3);
    line-height: 1.5;
}

.smart-banner .btn-close {
    padding: var(--space-2);
    opacity: 0.6;
}

.smart-banner .btn-close:hover {
    opacity: 1;
}

/* Compact banner layout */
.smart-banner .d-flex {
    gap: var(--space-3);
}

.smart-banner .banner-text {
    flex: 1;
}

/* Override Bootstrap alert spacing */
.smart-banner .alert-success {
    background-color: var(--color-success-light);
    border-color: var(--color-secondary-light);
    color: var(--color-success);
}

.smart-banner .alert-info {
    background-color: var(--color-info-light);
    border-color: var(--color-primary-container);
    color: var(--color-info);
}

.smart-banner .alert-celebration,
.smart-banner .alert-primary {
    background-color: var(--color-tertiary-light);
    border-color: var(--color-tertiary-container);
    color: var(--color-tertiary);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-8);
    color: var(--color-muted);
}

.loading-spinner {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    opacity: 0.6;
    animation: gentlePulse 1.8s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.9);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 640px) {
    .page-container {
        padding: var(--space-3);
    }
    
    .hero-section {
        padding: var(--space-6) 0;
    }
    
    .hero-title {
        font-size: var(--font-size-2xl);
    }
    
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ===== SAFE AREA INSETS (for notched devices) ===== */
@supports (padding: max(0px)) {
    .bottom-nav {
        padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    }
    
    .app-container {
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
    }
}

/* ===== DARK MODE SUPPORT (Future Enhancement) ===== */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here in future iterations */
}

/* ===== REDUCED MOTION SUPPORT ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== AI CHAT INTERFACE STYLES ===== */
.chat-card {
    margin-bottom: 1.5rem;
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: #FFFFFF;
    border-radius: 12px;
    margin-bottom: 1rem;
    scroll-behavior: smooth;
}

/* ===== CLARIFICATION UI ===== */
.clarification-msg {
    background-color: var(--color-primary-light);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin: var(--space-3) 0;
}

.clarification-text {
    margin-bottom: var(--space-4);
    font-weight: 500;
    color: var(--color-fg);
    white-space: pre-line;
}

.clarification-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.clarification-chip {
    background-color: var(--color-bg);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clarification-chip:hover:not(:disabled) {
    background-color: var(--color-primary);
    color: var(--color-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.clarification-chip:active:not(:disabled) {
    transform: translateY(0);
}

.clarification-chip:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--color-border);
    border-color: var(--color-border);
    color: var(--color-muted);
}

.clarification-chip.loading {
    position: relative;
}

.clarification-chip.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    margin-left: var(--space-2);
}

.clarification-chip-other {
    border-color: var(--color-muted);
    color: var(--color-muted);
}

.clarification-chip-other:hover:not(:disabled) {
    background-color: var(--color-muted);
    color: var(--color-bg);
}

.selected-category {
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background-color: var(--color-success);
    color: white;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    display: inline-block;
}

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

.message {
    display: flex;
    margin-bottom: 1rem;
    animation: messageSlideIn 0.3s ease-out;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, var(--color-primary) 0%, #42A5F5 100%);
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #66BB6A 100%);
    color: white;
}

.message-content {
    background: white;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 85%;
    word-wrap: break-word;
}

.ai-message .message-content {
    border-top-left-radius: 4px;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    margin-left: 0.75rem;
    margin-right: 0;
}

.user-message .message-content {
    border-top-right-radius: 4px;
    background: #FFFFFF;
}

.chat-input-container {
    background: white;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.chat-input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    resize: none;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(103, 80, 164, 0.12);
    outline: none;
}

.chat-send-btn {
    min-width: 80px;
    border-radius: 12px;
    font-weight: 600;
}

.chat-suggestions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.suggestion-btn {
    background: #FFFFFF;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: #e2e8f0;
    color: #475569;
    transform: translateY(-1px);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.5s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ===== TOAST ANIMATIONS ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ===== PROGRESS RING ===== */
#progress-ring {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #66BB6A 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    color: white;
    box-shadow: var(--shadow-lg);
}

.progress-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(
        #fff 0% var(--percentage, 0%),
        rgba(255, 255, 255, 0.3) var(--percentage, 0%) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-circle::before {
    content: '';
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-secondary) 0%, #66BB6A 100%);
}

.progress-value {
    position: relative;
    z-index: 1;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: white;
}

.progress-message {
    text-align: center;
    font-size: var(--font-size-base);
    margin: 0;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
}

/* ===== EXPENSE CHART ===== */
#expense-chart {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.chart-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: var(--color-fg);
}

.chart-container {
    margin-top: var(--space-4);
}

/* ===== CATEGORY COLOR CLASSES (MD3 Compliant) ===== */
/* NOTE: Legacy .cat-* background rules REMOVED to prevent solid boxes in chat.
   Category styling now uses --cat-color CSS variable + category-visuals.css.
   See md3-tokens.css for canonical category color definitions. */

/* ===== STACKED BAR CHART (MD3 Compliant) ===== */
/* Horizontal stacked bar for category breakdown */

.stacked-bar {
    display: flex;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--surface-2);
}

.stacked-bar .segment {
    height: 100%;
    transition: opacity 0.2s ease;
}

.stacked-bar .segment:hover {
    opacity: 0.85;
}

/* Category-specific colors using data attributes */
.stacked-bar .segment[data-cat="food"] {
    background-color: var(--cat-food);
}

.stacked-bar .segment[data-cat="transport"] {
    background-color: var(--cat-transport);
}

.stacked-bar .segment[data-cat="bills"] {
    background-color: var(--cat-bills);
}

.stacked-bar .segment[data-cat="shopping"] {
    background-color: var(--cat-shopping);
}

.stacked-bar .segment[data-cat="other"],
.stacked-bar .segment[data-cat="uncategorized"] {
    background-color: var(--cat-other);
}

.stacked-bar .segment[data-cat="entertainment"] {
    background-color: var(--cat-entertainment);
}

.stacked-bar .segment[data-cat="health"] {
    background-color: var(--cat-health);
}

.stacked-bar .segment[data-cat="education"] {
    background-color: var(--cat-education);
}

/* ===== CHART LEGEND (MD3 Compliant) ===== */

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

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

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot[data-cat="food"] {
    background-color: var(--cat-food);
}

.legend-dot[data-cat="transport"] {
    background-color: var(--cat-transport);
}

.legend-dot[data-cat="bills"] {
    background-color: var(--cat-bills);
}

.legend-dot[data-cat="shopping"] {
    background-color: var(--cat-shopping);
}

.legend-dot[data-cat="other"],
.legend-dot[data-cat="uncategorized"] {
    background-color: var(--cat-other);
}

.legend-dot[data-cat="entertainment"] {
    background-color: var(--cat-entertainment);
}

.legend-dot[data-cat="health"] {
    background-color: var(--cat-health);
}

.legend-dot[data-cat="education"] {
    background-color: var(--cat-education);
}

.legend-label {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.legend-amount {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: auto;
}

/* ===== MD3 SMART BANNERS (MD3 Compliant) ===== */
/* Goal-aware coaching banners with white text on colored backgrounds */

.md3-banner {
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    animation: bannerSlideIn 0.4s ease-out;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

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

.banner-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.banner-text {
    flex: 1;
}

.banner-title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--on-primary);
}

.banner-message {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--on-primary);
    opacity: 0.95;
}

.banner-action {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--on-primary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.banner-action:hover {
    background-color: rgba(255, 255, 255, 0.3);
    color: var(--on-primary);
}

.banner-close {
    background: transparent;
    border: none;
    color: var(--on-primary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.banner-close:hover {
    opacity: 1;
}

/* Banner color variants using MD3 tokens */

.banner-success {
    background-color: var(--success-green);
    color: var(--on-success);
}

.banner-error {
    background-color: var(--error-red);
    color: var(--on-error);
}

.banner-warning {
    background-color: var(--warning-yellow);
    color: var(--on-warning);
}

.banner-info {
    background-color: var(--brand-primary);
    color: var(--on-primary);
}

.banner-primary {
    background-color: var(--brand-primary);
    color: var(--on-primary);
}

/* ===== AI PULSE RING ANIMATION (FINAL) ===== */

.ai-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    border-radius: 9999px;
    pointer-events: none;
    z-index: 0;

    /* Google-style multi-color ring - brighter */
    background: conic-gradient(
        from 0deg,
        #4285F4,
        #EA4335,
        #FBBC05,
        #34A853,
        #4285F4
    );

    /* Simple thin ring mask */
    -webkit-mask: radial-gradient(farthest-side, transparent 70%, black 76%);
    mask: radial-gradient(farthest-side, transparent 70%, black 76%);

    filter: blur(1px);
    opacity: 0.6;

    animation:
        aiSpin 8s linear infinite,
        aiPulseGlow 3s ease-in-out infinite;
}

@keyframes aiSpin {
    0%   { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes aiPulseGlow {
    0%, 100% {
        opacity: 0.4;
        filter: blur(1px);
    }
    50% {
        opacity: 0.75;
        filter: blur(1.5px);
    }
}

/* Header icons: consistent 24px size for robot and history */
#ai-onboarding-btn .material-symbols-outlined,
#activity-feed-btn .material-symbols-outlined {
    font-size: 24px !important;
}

/* Ensure halo containers don't clip the blur effect */
#ai-onboarding-btn > div,
#activity-feed-btn > div {
    overflow: visible !important;
}

/* Disable hover transforms that could shift/clip the halo */
#ai-onboarding-btn:hover,
#activity-feed-btn:hover {
    transform: none !important;
}

/* Tilt animation for robo icon when activated */
#ai-onboarding-btn .toy-icon-active {
    transform: rotate(-6deg) scale(1.02);
    transition: transform 160ms ease-out;
}

#ai-onboarding-btn .material-symbols-outlined {
    transition: transform 160ms ease-out;
}

/* ===== PENDING EXPENSE NOTICE BANNER ===== */
/* MD3-compliant notice banner for pending expense clarity */
.pending-notice-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 12px;
    background: var(--md-sys-color-surface-variant, #E7E0EC);
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.pending-notice-icon {
    font-size: 20px;
    color: var(--md-sys-color-tertiary, #7D5260);
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    flex-shrink: 0;
}

.pending-notice-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.pending-notice-text strong {
    font-weight: 600;
}

.pending-notice-subtext {
    display: block;
    font-size: 12px;
    color: var(--md-sys-color-outline, #79747E);
    margin-top: 2px;
}

.pending-notice-action {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-primary, #6750A4);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 20px;
    transition: background 0.2s;
}

.pending-notice-action:hover {
    background: var(--md-sys-color-primary-container, #EADDFF);
}

/* Pending count badge (for header) */
.pending-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--md-sys-color-tertiary, #7D5260);
    color: var(--md-sys-color-on-tertiary, #FFFFFF);
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .pending-notice-banner {
        background: var(--md-sys-color-surface-variant, #49454F);
        color: var(--md-sys-color-on-surface-variant, #CAC4D0);
    }
    
    .pending-notice-icon {
        color: var(--md-sys-color-tertiary, #EFB8C8);
    }
    
    .pending-notice-subtext {
        color: var(--md-sys-color-outline, #938F99);
    }
    
    .pending-notice-action {
        color: var(--md-sys-color-primary, #D0BCFF);
    }
    
    .pending-notice-action:hover {
        background: var(--md-sys-color-primary-container, #4F378B);
    }
    
    .pending-count-badge {
        background: var(--md-sys-color-tertiary, #EFB8C8);
        color: var(--md-sys-color-on-tertiary, #492532);
    }
}

} /* end @layer legacy */

/* ✅ Canonical toast placement: TOP-RIGHT (never full-screen) */
#toast-container.toast-container {
  position: fixed;
  top: var(--space-4, 16px);
  right: var(--space-4, 16px);

  /* critical resets (prevents stretch from mixed rules) */
  bottom: auto !important;
  left: auto !important;
  transform: none !important;

  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);

  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);

  pointer-events: none; /* container never blocks UI */
  z-index: var(--z-toast, 1001);
}

/* Allow clicks inside the toast card itself (close button) */
#toast-container .toast,
#toast-container .toast * {
  pointer-events: auto;
}

/* ===== NAVIGATION PROGRESS BAR (Jan 2026) ===== */
/* Perceived speed optimization - shows immediate feedback on nav tap */

#nav-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 30%;
  background: linear-gradient(90deg, var(--brand-primary, #0A68FF), var(--color-secondary, #2E7D32));
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.15s ease-out;
  pointer-events: none;
  transform: translateX(-100%);
}

#nav-progress-bar.active {
  opacity: 1;
  animation: nav-progress-slide 1.2s ease-in-out infinite;
}

@keyframes nav-progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(433%); }
}

/* Nav loading state - disable nav and show pressed state */
body.nav-loading .bottom-nav {
  pointer-events: none;
}

body.nav-loading .nav-item {
  opacity: 0.7;
}

body.nav-loading .nav-item.nav-loading-target {
  opacity: 1;
  background: var(--color-primary-light, #E6F2FF);
  color: var(--color-primary, #0A68FF);
}