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

:root {
    --primary: #4A90D9;
    --primary-light: #6BA3E0;
    --primary-dark: #357ABD;
    --success: #4CAF50;
    --danger: #F44336;
    --warning: #FF9800;
    --info: #2196F3;
    --bg: #F0F2F5;
    --card: #FFFFFF;
    --text: #333333;
    --text-light: #888888;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Auth Page */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px; }
.auth-card { background: white; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.auth-card h1 { text-align: center; margin-bottom: 8px; color: var(--primary); font-size: 28px; }
.auth-card .subtitle { text-align: center; color: var(--text-light); margin-bottom: 30px; font-size: 14px; }
.auth-tabs { display: flex; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.auth-tab { flex: 1; text-align: center; padding: 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; font-weight: 500; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: #555; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 15px; transition: border-color 0.2s; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: white; border-right: 1px solid var(--border); padding: 20px 0; position: fixed; height: 100vh; overflow-y: auto; z-index: 100; transition: transform 0.3s; }
.sidebar-brand { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.sidebar-brand h2 { color: var(--primary); font-size: 20px; }
.sidebar-brand small { color: var(--text-light); font-size: 12px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 20px; cursor: pointer; transition: all 0.2s; color: #555; font-size: 14px; }
.nav-item:hover { background: #F5F5F5; }
.nav-item.active { background: #EBF2FC; color: var(--primary); border-right: 3px solid var(--primary); font-weight: 500; }
.nav-section { padding: 10px 20px 5px; font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; }

.main-content { flex: 1; margin-left: 240px; padding: 24px; min-height: 100vh; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 24px; }

/* Mobile hamburger */
.mobile-header { display: none; position: fixed; top: 0; left: 0; right: 0; height: 56px; background: white; border-bottom: 1px solid var(--border); z-index: 99; align-items: center; padding: 0 16px; }
.hamburger { background: none; border: none; font-size: 24px; cursor: pointer; padding: 8px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 99; }

/* Cards */
.card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .value.positive { color: var(--success); }
.stat-card .value.negative { color: var(--danger); }
.stat-card .sub { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* Table */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #F8F9FA; font-weight: 600; color: #555; position: sticky; top: 0; }
tr:hover { background: #F8F9FA; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.amount.income { color: var(--success); }
.amount.expense { color: var(--danger); }

/* Progress bar */
.progress-bar { height: 8px; background: #E0E0E0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-fill.safe { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* Tags */
.tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.tag-blue { background: #E3F2FD; color: #1976D2; }
.tag-green { background: #E8F5E9; color: #388E3C; }
.tag-red { background: #FFEBEE; color: #D32F2F; }
.tag-orange { background: #FFF3E0; color: #F57C00; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; justify-content: center; align-items: center; z-index: 200; padding: 20px; }
.modal { background: white; border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); }

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

/* Quick add */
.quick-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick-add input { flex: 1; min-width: 100px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { margin-bottom: 16px; }

/* Responsive */
@media (max-width: 768px) {
    .mobile-header { display: flex; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; padding: 72px 16px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card .value { font-size: 22px; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .btn-group { flex-wrap: wrap; }
    .quick-add { flex-direction: column; }
    .quick-add input { width: 100%; }
    .modal { margin: 10px; max-width: calc(100vw - 20px); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CCC; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #AAA; }
