:root {
    --bg-dark: #050a18;
    --bg-darker: #0a1128;
    --glass-bg: rgba(15, 23, 52, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f1f5f9;
    --text-secondary: #64748b;
    --text-muted: #475569;
    
    --color-blue: #3b82f6;
    --color-purple: #8b5cf6;
    --color-pink: #ec4899;
    --color-green: #10b981;
    --color-yellow: #f59e0b;
    --color-cyan: #06b6d4;
    --color-red: #ef4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs */
.bg-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    z-index: -1;
    animation: blobBounce 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}
.blob-1 {
    top: -10%; left: -10%;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--color-purple) 0%, transparent 70%);
}
.blob-2 {
    bottom: -10%; right: -10%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--color-blue) 0%, transparent 70%);
    animation-delay: -5s;
}
.blob-3 {
    top: 40%; left: 60%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, var(--color-pink) 0%, transparent 70%);
    animation-delay: -10s;
}

@keyframes blobBounce {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

/* Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.text-md { font-size: 1.25rem !important; }

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    border-top: none;
    border-bottom: none;
    border-left: none;
}

.main-content {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Sidebar Components */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}
.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, var(--color-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}
.nav-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-blue);
    border-left: 3px solid var(--color-blue);
}

.bot-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
}
.status-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--color-green);
    border-radius: 50%;
    position: relative;
}
.status-indicator::after {
    content: '';
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border: 2px solid var(--color-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}
.top-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.month-selector {
    display: flex;
    padding: 6px;
    border-radius: var(--radius-xl);
    gap: 4px;
}
.month-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}
.month-btn:hover {
    color: var(--text-primary);
}
.month-btn.active {
    background: var(--text-primary);
    color: var(--bg-dark);
}

/* Type Toggle */
.type-toggle-container {
    display: flex;
    justify-content: center;
}
.type-toggle {
    display: flex;
    padding: 6px;
    border-radius: var(--radius-xl);
}
.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 32px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
}
.toggle-btn:hover {
    color: var(--text-primary);
}
.toggle-btn.active {
    background: var(--color-blue);
    color: white;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}
.card {
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
}
.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.bg-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bg-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.bg-pink { background: linear-gradient(135deg, #ec4899, #db2777); }
.bg-green { background: linear-gradient(135deg, #10b981, #059669); }
.bg-cyan { background: linear-gradient(135deg, #06b6d4, #0891b2); }

.card-info h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
}
.card-info .amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Charts */
.charts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.chart-container {
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.chart-container h3 {
    font-size: 1.125rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}
.canvas-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

.two-cols-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.progress-bars-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    max-height: 300px;
    padding-right: 8px;
}
.progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}
.progress-track {
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Accounts Grid */
.accounts-section {
    margin-bottom: 24px;
}
.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}
.account-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.account-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.account-card-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}
.account-balance {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: auto;
}
.account-balance.credit {
    color: var(--color-purple);
}
.account-balance .limit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Table */
.expenses-section {
    padding: 24px;
}
.section-header {
    margin-bottom: 24px;
}
.table-container {
    overflow-x: auto;
}

.category-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.cat-filter-btn {
    padding: 6px 12px;
    border-radius: var(--radius-xl);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    transition: var(--transition);
}
.cat-filter-btn:hover {
    background: rgba(255,255,255,0.05) !important;
}
.cat-filter-btn.active {
    border-color: var(--text-primary) !important;
    color: var(--text-primary) !important;
}

table {
    width: 100%;
    border-collapse: collapse;
}
th {
    text-align: left;
    padding: 16px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--glass-border);
}
td {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    font-size: 0.95rem;
}
tr {
    transition: var(--transition);
}
tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.cat-tag {
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}
.actions {
    display: flex;
    gap: 8px;
}
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}
.icon-btn.delete:hover {
    color: var(--color-red);
    background: rgba(239, 68, 68, 0.1);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--text-muted);
    gap: 16px;
}
.empty-state.hidden {
    display: none;
}
.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}
.btn-primary {
    background: var(--color-blue);
    color: white;
}
.btn-primary:hover {
    background: #2563eb;
}
.btn-secondary {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
}

/* FAB */
.fab {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-blue), var(--color-purple));
    border: none;
    color: white;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 100;
}
.fab:hover {
    transform: scale(1.05) translateY(-4px);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.6);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 10, 24, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.modal {
    width: 100%;
    max-width: 480px;
    padding: 32px;
    transform: scale(0.9);
    transition: var(--transition);
    position: absolute; /* Modals overlap, we just show/hide them */
}
.modal-overlay.active .modal:not(.hidden) {
    transform: scale(1);
    position: relative;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.form-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.form-group input, .form-group select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}
@keyframes fadeIn {
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.login-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 48px 40px;
    text-align: center;
    animation: fadeIn 0.6s ease forwards;
}
.login-logo {
    font-size: 3.5rem;
    margin-bottom: 8px;
}
.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, var(--color-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}
.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}
.login-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-red);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: left;
}
.login-card .form-group {
    text-align: left;
}

@media (max-width: 480px) {
    .login-card {
        max-width: 90vw;
        padding: 32px 24px;
    }
}
/* ============================================
   RESPONSIVE MOBILE DESIGN
   ============================================ */

/* Hamburger button (hidden on desktop) */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: var(--transition);
}
.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* Tablet */
@media (max-width: 1024px) {
    .main-content {
        padding: 24px;
        gap: 24px;
    }
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .app-container {
        flex-direction: column;
    }

    /* Sidebar → Slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid var(--glass-border);
        border-radius: 0;
        background: var(--bg-darker);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }
    .sidebar-overlay.active {
        display: block;
    }

    /* Main content */
    .main-content {
        padding: 72px 16px 100px 16px;
        gap: 20px;
        max-width: 100%;
    }

    /* Header */
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        width: 100%;
    }
    .top-header h2 {
        font-size: 1.4rem;
    }

    /* Month selector: horizontal scroll */
    .month-selector {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
    }
    .month-selector::-webkit-scrollbar {
        display: none;
    }
    .month-btn {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    /* Type toggle */
    .toggle-btn {
        padding: 8px 20px;
        font-size: 0.9rem;
    }

    /* Summary cards: 2 columns on mobile */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .card {
        padding: 16px;
        flex-direction: column;
        gap: 10px;
    }
    .card-icon {
        width: 40px;
        height: 40px;
    }
    .card-info h3 {
        font-size: 0.75rem;
    }
    .card-info .amount {
        font-size: 1.25rem;
    }

    /* Charts: full width stacked */
    .charts-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .chart-container {
        padding: 16px;
    }
    .canvas-wrapper {
        height: 200px;
    }

    /* Two-column sections → stacked */
    .two-cols-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Accounts grid */
    .accounts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .account-card {
        padding: 16px;
    }
    .account-balance {
        font-size: 1.5rem;
    }

    /* Table */
    .expenses-section {
        padding: 16px;
    }
    table {
        font-size: 0.85rem;
    }
    th, td {
        padding: 10px 8px;
    }
    /* Hide description column on mobile */
    th:nth-child(2), td:nth-child(2) {
        display: none;
    }

    /* Category filters */
    .category-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    .cat-filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* FAB */
    .fab {
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
    }

    /* Modals */
    .modal {
        max-width: 95vw;
        padding: 24px;
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Buttons */
    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    .btn-sm {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Blobs: smaller on mobile */
    .blob-1 { width: 300px; height: 300px; }
    .blob-2 { width: 350px; height: 350px; }
    .blob-3 { width: 250px; height: 250px; }
}

/* Very small phones */
@media (max-width: 380px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
    .card-info .amount {
        font-size: 1.1rem;
    }
    .main-content {
        padding: 68px 12px 100px 12px;
    }
}


/* AI Advisor Styles */
.btn-ai {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, #9f7aea, #60a5fa);
}

.ai-modal {
    max-width: 600px;
}

.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.ai-content {
    line-height: 1.6;
    color: var(--text-primary);
    padding: 10px;
}

.ai-content p {
    margin-bottom: 12px;
}

.ai-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.ai-content li {
    margin-bottom: 6px;
}

.ai-content strong {
    color: #8b5cf6;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-left-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
