:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --border: #2d3a4f;
    --text: #e7ecf3;
    --muted: #8b9cb3;
    --primary: #3b82f6;
    --income: #22c55e;
    --expense: #ef4444;
    --radius: 10px;
    --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); }

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.nav .brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
}

.nav-links a:hover { color: var(--text); }

.nav .user { color: var(--muted); font-size: 0.9rem; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 { margin: 0; font-size: 1.75rem; }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.filters select,
.filters input[type="search"],
.filters input[type="text"] {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    min-width: 0;
}

.filters-stack label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--muted);
    gap: 0.25rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

.filter-row .grow {
    flex: 1;
    min-width: 200px;
}

.filter-row .grow input {
    width: 100%;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 0 0.5rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.kpi .label { display: block; color: var(--muted); font-size: 0.85rem; }
.kpi .value { font-size: 1.5rem; font-weight: 700; }
.kpi.income .value { color: var(--income); }
.kpi.expense .value { color: var(--expense); }
.kpi.net.positive .value { color: var(--income); }
.kpi.net.negative .value { color: var(--expense); }
.kpi.investment .value { color: #a78bfa; }
.kpi .kpi-hint { display: block; font-size: 0.7rem; color: var(--muted); font-weight: normal; margin-top: 0.25rem; }

.badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.badge-investment { background: rgba(167, 139, 250, 0.25); color: #c4b5fd; }
.row-investment { opacity: 0.92; }
.investment { color: #a78bfa; }

.toggle-form { margin: 0; }
.toggle-label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; cursor: pointer; }
.toggle-label input { width: auto; margin: 0; }

.inline-form { display: inline; }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.75rem; border-radius: 4px; cursor: pointer; border: none; }
.btn-danger { background: rgba(239, 68, 68, 0.3); color: #fca5a5; }
.rules-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.add-rule-form { margin-top: 1rem; }
.reapply-form { margin-top: 1rem; }

.charts-grid, .two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th, .table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.table th { color: var(--muted); font-weight: 600; }

.positive { color: var(--income); }
.negative { color: var(--expense); }

.auth-card {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.auth-card h1 { margin-top: 0; }

label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

input, select, button {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

button, .btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
}

button:hover { filter: brightness(1.1); }

.btn-outline {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text) !important;
    text-decoration: none;
    font-size: 0.85rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert.success { background: rgba(34, 197, 94, 0.15); color: var(--income); }
.alert.error { background: rgba(239, 68, 68, 0.15); color: var(--expense); }
.alert.warning { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

.footer {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 0.85rem;
}

code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}
