:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

[data-theme="dark"] {
    --gray-50: #1F2937;
    --gray-100: #111827;
    --gray-200: #374151;
    --gray-300: #4B5563;
    --gray-400: #6B7280;
    --gray-500: #9CA3AF;
    --gray-600: #D1D5DB;
    --gray-700: #E5E7EB;
    --gray-800: #F3F4F6;
    --gray-900: #F9FAFB;
    --primary-light: #312E81;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 20px;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand svg { width: 28px; height: 28px; color: var(--primary); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: .9rem;
    transition: all .2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: white;
    background: rgba(255,255,255,.08);
}

.sidebar-nav a.active {
    border-right: 3px solid var(--primary);
}

.sidebar-nav a svg { width: 20px; height: 20px; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title { font-size: 1.25rem; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 24px; }

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Summary cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.summary-icon.income { background: var(--success-light); color: var(--success); }
.summary-icon.expense { background: var(--danger-light); color: var(--danger); }
.summary-icon.balance { background: var(--info-light); color: var(--info); }
.summary-icon.savings { background: var(--warning-light); color: var(--warning); }

.summary-value { font-size: 1.5rem; font-weight: 700; }
.summary-label { font-size: .8rem; color: var(--gray-500); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-icon { padding: 8px; }
.btn svg { width: 16px; height: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 4px; color: var(--gray-700); }
.form-input, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .9rem;
    background: white;
    transition: border-color .2s;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-error { font-size: .8rem; color: var(--danger); margin-top: 4px; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: .8rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; border-bottom: 2px solid var(--gray-200); }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); font-size: .9rem; }
tr:hover { background: var(--gray-50); }

/* Text utilities */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-bold { font-weight: 700; }
.text-sm { font-size: .8rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all .2s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform .2s;
}
.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--gray-400); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: .9rem;
    box-shadow: var(--shadow-md);
    animation: slideIn .3s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

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

/* Mobile */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    z-index: 100;
    padding: 8px 0;
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    list-style: none;
}

.mobile-nav-items a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--gray-500);
    font-size: .7rem;
    padding: 4px 8px;
}

.mobile-nav-items a.active { color: var(--primary); }
.mobile-nav-items a svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-bottom: 70px; }
    .mobile-nav { display: block; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .page-content { padding: 16px; }
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 8px; }
.login-subtitle { text-align: center; color: var(--gray-500); margin-bottom: 24px; }

/* Chart container */
.chart-container { position: relative; height: 300px; }

/* Budget bar */
.budget-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.budget-bar-fill { height: 100%; border-radius: 4px; transition: width .5s; }
.budget-bar-fill.normal { background: var(--success); }
.budget-bar-fill.warning { background: var(--warning); }
.budget-bar-fill.danger { background: var(--danger); }

/* Amount display */
.amount { font-family: 'SF Mono', monospace; font-weight: 600; }
.amount.positive { color: var(--success); }
.amount.negative { color: var(--danger); }

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-500); }
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--gray-700); }
