:root, [data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #334155;
    --border: #475569;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --radius: 8px;
}
[data-theme="light"] {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface2: #e2e8f0;
    --border: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #ca8a04;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; }
nav .brand { font-size: 1.25rem; font-weight: 700; color: var(--primary); text-decoration: none; }
nav .nav-links { display: flex; gap: 1.5rem; align-items: center; }
nav a { color: var(--text-muted); text-decoration: none; transition: color .2s; }
nav a:hover { color: var(--text); }

.container { max-width: 1400px; margin: 0 auto; padding: 2rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin-bottom: .75rem; color: var(--text-muted); }
h3 { font-size: 1rem; margin-bottom: .5rem; }

.stat-card { text-align: center; }
.stat-card .value { font-size: 2rem; font-weight: 700; }
.stat-card .label { color: var(--text-muted); font-size: .875rem; margin-top: .25rem; }
.stat-card.positive .value { color: var(--green); }
.stat-card.negative .value { color: var(--red); }

.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1rem; border-radius: var(--radius); border: none; cursor: pointer; font-size: .875rem; font-weight: 500; transition: all .2s; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); color: white; }
.btn-sm { padding: .25rem .5rem; font-size: .75rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline.active { border-color: var(--primary); color: var(--primary); background: rgba(59,130,246,.1); }

input, select { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; color: var(--text); font-size: .875rem; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--primary); }
label { display: block; font-size: .75rem; color: var(--text-muted); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .05em; }

.form-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.form-group { flex: 1; min-width: 120px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: .75rem; color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
td { padding: .75rem; border-bottom: 1px solid var(--border); font-size: .875rem; }
tr:hover { background: rgba(255,255,255,.02); }

.amount { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.amount.expense { color: var(--red); }
.amount.income { color: var(--green); }

.badge { display: inline-block; padding: .125rem .5rem; border-radius: 9999px; font-size: .7rem; font-weight: 600; }
.badge-cat { background: rgba(59,130,246,.15); color: var(--primary); }
.badge-reserve { background: rgba(234,179,8,.15); color: var(--yellow); }
.badge-confirmed { background: rgba(34,197,94,.15); color: var(--green); }

.confirm-btn { cursor: pointer; padding: .25rem .5rem; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: .75rem; transition: all .2s; }
.confirm-btn.confirmed { background: rgba(34,197,94,.15); border-color: var(--green); color: var(--green); }

.category-header { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; margin-top: 1rem; border-bottom: 2px solid var(--border); }
.category-total { font-weight: 600; color: var(--red); }

.view-toggle { display: flex; gap: .25rem; margin-bottom: 1rem; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }
.flash.error { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.flash.info { background: rgba(59,130,246,.15); color: var(--primary); border: 1px solid rgba(59,130,246,.3); }
.flash.success { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.3); }

.auth-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 2rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { text-align: center; margin-bottom: 1.5rem; }
.auth-card .form-group { margin-bottom: 1rem; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: .5rem; }
.auth-card .link { text-align: center; margin-top: 1rem; font-size: .875rem; }

.progress-bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-top: .5rem; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .3s; }

.chart-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.chart-bar .bar-label { width: 140px; font-size: .8rem; text-align: right; flex-shrink: 0; }
.chart-bar .bar-track { flex: 1; height: 24px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.chart-bar .bar-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding: 0 .5rem; font-size: .7rem; font-weight: 600; min-width: fit-content; }
.chart-bar .bar-value { width: 100px; text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }

.scenario-card { cursor: pointer; transition: transform .2s, border-color .2s; }
.scenario-card:hover { transform: translateY(-2px); border-color: var(--primary); }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; }

.zoom-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); width: 28px; height: 28px; border-radius: var(--radius); cursor: pointer; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; transition: all .2s; }
.zoom-btn:hover { border-color: var(--primary); color: var(--primary); }
