:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #22263a;
    --border: #2a2e3f;
    --text: #e1e4ed;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --positive: #22c55e;
    --negative: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 8px;
}

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

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

/* Nav */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-hover); }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Typography */
h1 { font-size: 1.5rem; margin-bottom: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; margin-bottom: 0.75rem; font-weight: 600; color: var(--text-muted); }

/* Cards */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.card h3 { margin-bottom: 0.25rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.amount { font-size: 1.5rem; font-weight: 700; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Charts */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:hover { background: var(--surface-hover); }
.table-compact td, .table-compact th { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.table-scroll { overflow-x: auto; }

/* Forms */
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.form-group small { display: block; color: var(--text-muted); font-size: 0.75rem; margin-top: 0.15rem; }
input[type="text"], input[type="password"], input[type="date"], input[type="file"], select, textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.select-sm { width: auto; padding: 0.25rem 0.5rem; font-size: 0.85rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.form-inline .form-group { margin-bottom: 0; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: transparent; border-color: var(--negative); color: var(--negative); }
.btn-danger:hover { background: var(--negative); color: white; }
.btn-secondary { background: transparent; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.button-group { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid var(--negative); color: var(--negative); }
.alert-success { background: rgba(34,197,94,0.15); border: 1px solid var(--positive); color: var(--positive); }
.alert-info { background: rgba(59,130,246,0.15); border: 1px solid var(--info); color: var(--info); }
.alert-warning { background: rgba(245,158,11,0.15); border: 1px solid var(--warning); color: var(--warning); }
.alert a { color: inherit; text-decoration: underline; }

/* Sections */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }

/* Tags / Categories */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
    display: inline-flex; align-items: center; gap: 0.25rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
    padding: 0.3rem 0.75rem; font-size: 0.85rem;
}
.tag-income { border-color: var(--positive); color: var(--positive); }
.tag-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }
.tag-delete:hover { color: var(--negative); }

/* Categories grid */
.categories-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

/* Filters */
.filters-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filters-form .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; font-size: 0.9rem; color: var(--text-muted); }

/* Badge */
.badge { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 10px; border: 1px solid var(--border); }

/* Period label */
.period-label { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }

/* Account settings */
.account-settings { display: flex; flex-direction: column; gap: 0.25rem; }

/* Login */
.login-container { max-width: 360px; margin: 100px auto; padding: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.login-container h1 { margin-bottom: 1.5rem; }
.login-form .form-group { text-align: left; }
.login-form .btn { width: 100%; margin-top: 0.5rem; }

/* Mapping form */
.mapping-form { max-width: 600px; }
.amount-fields { margin-left: 1rem; padding-left: 1rem; border-left: 2px solid var(--border); }

/* Empty state */
.empty-state { color: var(--text-muted); text-align: center; padding: 2rem; }

/* Responsive */
@media (max-width: 768px) {
    .navbar { flex-direction: column; gap: 0.5rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .charts-grid { grid-template-columns: 1fr; }
    .summary-cards { grid-template-columns: 1fr; }
    .filters-form { flex-direction: column; }
}
