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

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(30, 41, 59, 0.6);
    --border-color: rgba(148, 163, 184, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    z-index: 50;
    display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px; color: white;
}
.sidebar-title { font-size: 18px; font-weight: 700; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--text-muted);
    padding: 0 12px; margin-bottom: 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--text-secondary); text-decoration: none;
    transition: all 0.2s ease; font-size: 14px; font-weight: 500;
    margin-bottom: 2px; position: relative; overflow: hidden;
}
.nav-item:hover { color: var(--text-primary); background: rgba(59, 130, 246, 0.1); }
.nav-item.active {
    color: white; background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; background: var(--accent-blue); border-radius: 0 3px 3px 0;
}
.nav-icon { width: 20px; height: 20px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}
.topbar {
    height: var(--topbar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 12px; color: var(--text-muted); }
.content-area { padding: 24px; }

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
}
.card:hover { border-color: rgba(59, 130, 246, 0.2); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,0.2); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

/* Stat Cards */
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
    content: ''; position: absolute; top: -30px; right: -30px;
    width: 100px; height: 100px; border-radius: 50%;
    opacity: 0.1;
}
.stat-card.blue::before { background: var(--accent-blue); }
.stat-card.emerald::before { background: var(--accent-emerald); }
.stat-card.amber::before { background: var(--accent-amber); }
.stat-card.rose::before { background: var(--accent-rose); }
.stat-card.purple::before { background: var(--accent-purple); }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.stat-icon.rose { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.stat-value { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-change { font-size: 12px; font-weight: 600; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.stat-change.up { color: var(--accent-emerald); }
.stat-change.down { color: var(--accent-rose); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 10px;
    font-size: 14px; font-weight: 600; font-family: 'Inter', sans-serif;
    cursor: pointer; border: none; transition: all 0.2s ease;
    text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, var(--accent-blue), #2563eb); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4); }
.btn-success { background: linear-gradient(135deg, var(--accent-emerald), #059669); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--accent-rose), #dc2626); color: white; }
.btn-outline {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 10px; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 12px 16px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
td {
    padding: 12px 16px; font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}
tr:hover td { background: rgba(59, 130, 246, 0.03); }
.amount-positive { color: var(--accent-emerald); font-weight: 600; }
.amount-negative { color: var(--accent-rose); font-weight: 600; }

/* Badge */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 600;
}
.badge-income { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-expense { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.badge-transfer { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-matched { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-unmatched { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge-adjusted { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    background: var(--bg-primary); border: 1px solid var(--border-color);
    color: var(--text-primary); font-size: 14px; font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}
.form-control:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
select.form-control { cursor: pointer; }

/* Progress Bar */
.progress { height: 8px; background: var(--bg-primary); border-radius: 4px; overflow: hidden; }
.progress-bar {
    height: 100%; border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
}
.progress-bar.danger { background: linear-gradient(90deg, var(--accent-amber), var(--accent-rose)); }
.progress-bar.success { background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan)); }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
    z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 20px; padding: 28px; width: 90%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; padding: 4px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-color); }

/* Account Card */
.account-card { position: relative; overflow: hidden; cursor: pointer; }
.account-card .account-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 12px;
}
.account-card .account-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.account-card .account-type { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }
.account-card .account-balance { font-size: 22px; font-weight: 800; margin-top: 16px; }

/* Filter bar */
.filter-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 16px 20px; background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: 12px;
    margin-bottom: 20px;
}
.filter-bar .form-control { width: auto; min-width: 150px; padding: 8px 12px; font-size: 13px; }

/* Toast */
.toast-container { position: fixed; top: 80px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    backdrop-filter: blur(10px); border: 1px solid var(--border-color);
}
.toast-success { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); border-color: rgba(16, 185, 129, 0.3); }
.toast-error { background: rgba(244, 63, 94, 0.2); color: var(--accent-rose); border-color: rgba(244, 63, 94, 0.3); }
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(100%); } }

/* Hamburger menu */
.hamburger { display: none; background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 8px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 45; }

/* Report tables */
.report-table { margin-bottom: 20px; }
.report-table .section-header td { font-weight: 700; font-size: 15px; color: var(--text-primary); background: rgba(59,130,246,0.05); }
.report-table .total-row td { font-weight: 700; border-top: 2px solid var(--border-color); color: var(--text-primary); }

/* Responsive */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-control { width: 100%; }
    .content-area { padding: 16px; }
    .stat-value { font-size: 20px; }
}
@media print {
    .sidebar, .topbar, .btn, .filter-bar { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { border: 1px solid #ddd; box-shadow: none; background: white; color: #333; }
    body { background: white; color: #333; }
}
