:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --accent: #06b6d4;
    --accent-light: #22d3ee;
    
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: #1e293b;
    --bg-section: #0c1222;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: rgba(148, 163, 184, 0.12);
    --border-hover: rgba(148, 163, 184, 0.25);
    
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    
    --income: #10b981;
    --expense: #ef4444;
    
    --gradient-primary: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --gradient-accent: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
    
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    --transition: 200ms ease;
    
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--bg-dark);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-section);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

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

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(30, 64, 175, 0.25);
    color: var(--primary-light);
    border-left: 3px solid var(--primary-light);
    margin-left: -3px;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}

.action-btn.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 280px;
}

.search-wrapper:focus-within {
    border-color: var(--primary-light);
}

.search-wrapper svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
}

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

.header-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.header-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.date-badge {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* Sections */
.dashboard-section,
.transactions-section,
.budgets-section,
.analytics-section {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.dashboard-section.active,
.transactions-section.active,
.budgets-section.active,
.analytics-section.active {
    display: block;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

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

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 18px;
    height: 18px;
}

.stat-card.income .stat-icon { background: rgba(16, 185, 129, 0.15); color: var(--income); }
.stat-card.expense .stat-icon { background: rgba(239, 68, 68, 0.15); color: var(--expense); }
.stat-card.balance .stat-icon { background: rgba(30, 64, 175, 0.15); color: var(--primary-light); }
.stat-card.count .stat-icon { background: rgba(6, 182, 212, 0.15); color: var(--accent); }

.stat-trend {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
}

.stat-trend.positive { background: rgba(16, 185, 129, 0.15); color: var(--income); }
.stat-trend.negative { background: rgba(239, 68, 68, 0.15); color: var(--expense); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

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

.chart-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-header select {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
}

.chart-container {
    height: 220px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

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

.card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

.card-header .btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.card-header .btn-link:hover {
    text-decoration: underline;
}

/* Transactions List */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.transaction-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.transaction-row:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.t-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.t-icon svg {
    width: 16px;
    height: 16px;
}

.t-icon.income { background: rgba(16, 185, 129, 0.15); color: var(--income); }
.t-icon.expense { background: rgba(239, 68, 68, 0.15); color: var(--expense); }
.t-icon.debt { background: rgba(217, 119, 6, 0.15); color: #d97706; }

.t-details { flex: 1; min-width: 0; }
.t-desc { font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-cat { font-size: 0.75rem; color: var(--text-muted); }

.t-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
}

.t-amount.income { color: var(--income); }
.t-amount.expense { color: var(--expense); }

.t-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
}

/* Transactions Page */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
}

.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input {
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.filters-bar select:focus,
.filters-bar input:focus {
    border-color: var(--primary-light);
    outline: none;
}

.transactions-table {
    width: 100%;
    border-collapse: collapse;
}

.transactions-table th {
    text-align: left;
    padding: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}

.transactions-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.transactions-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.transactions-table .amount {
    font-family: var(--font-mono);
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-input);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Budgets */
.budgets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.budget-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: all var(--transition);
}

.budget-card:hover {
    border-color: var(--border-hover);
}

.budget-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.budget-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.budget-icon svg { width: 16px; height: 16px; }

.budget-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.budget-amount {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
}

.budget-limit {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 5px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 14px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-fill.safe { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.analytics-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.analytics-card canvas {
    height: 200px;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cat-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cat-color {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.cat-label {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cat-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
}

.cat-bar-fill { height: 100%; border-radius: 2px; }

.cat-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal.active .modal-content { transform: scale(1); }

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

.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
    width: 30px;
    height: 30px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-close svg { width: 14px; height: 14px; color: var(--text-muted); }

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-light);
    outline: none;
}

.type-selector {
    display: flex;
    gap: 6px;
}

.type-selector button {
    flex: 1;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.type-selector button:hover { background: var(--bg-card-hover); }

.type-selector button.active {
    background: rgba(30, 64, 175, 0.2);
    border-color: var(--primary);
    color: var(--primary-light);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions button {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: var(--bg-input);
}

.btn-save {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

.btn-save:hover {
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .budgets-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .top-bar { padding: 0 16px; }
    .search-wrapper { width: 100%; flex: 1; }
    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .budgets-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; }
    .filters-bar select, .filters-bar input { width: 100%; }
}

/* Security overlay */
.security-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: var(--text-primary);
    font-family: var(--font-main);
    text-align: center;
    padding: 40px;
}

.security-overlay.active { display: flex; }

.security-message h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--danger);
}

.security-message p {
    color: var(--text-secondary);
    max-width: 400px;
}
