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

:root {
    --bg:        #0f0f0f;
    --surface:   #18181b;
    --border:    #27272a;
    --muted:     #71717a;
    --text:      #e4e4e7;
    --subtle:    #a1a1aa;
    --accent:    #6366f1;
    --accent-h:  #4f46e5;
    --green:     #22c55e;
    --red:       #ef4444;
    --yellow:    #f59e0b;
    --radius:    12px;
    --sidebar-w: 240px;
}

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

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-size: 1.375rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-accent { color: var(--accent); }

.nav-links {
    list-style: none;
    padding: 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6875rem 0.875rem;
    border-radius: 8px;
    color: var(--subtle);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

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

.nav-link:hover { background: #27272a; color: var(--text); }
.nav-link.active { background: #1e1e3f; color: var(--accent); }

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.6875rem;
    color: var(--muted);
    text-transform: capitalize;
}

.logout-btn {
    color: var(--muted);
    display: flex;
    align-items: center;
    padding: 0.375rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.logout-btn svg { width: 17px; height: 17px; }
.logout-btn:hover { color: var(--red); background: #1f0a0a; }

/* ── MOBILE HEADER ── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 99;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.375rem;
    display: flex;
    align-items: center;
}

.mobile-menu-btn svg { width: 22px; height: 22px; }

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

.mobile-overlay.show { display: block; }

/* ── MAIN CONTENT ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 2rem;
    min-height: 100vh;
    max-width: 100%;
}

/* ── FLASH MESSAGES ── */
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.flash-error   { background: #450a0a; border: 1px solid #7f1d1d; color: #fca5a5; }
.flash-success { background: #052e16; border: 1px solid #14532d; color: #86efac; }
.flash-info    { background: #0c1a3a; border: 1px solid #1e3a6e; color: #93c5fd; }

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0.7;
    padding: 0 0.25rem;
}

.flash-close:hover { opacity: 1; }

/* ── PAGE HEADER ── */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.page-header p {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

/* ── CARDS ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card-sm { padding: 1.125rem; }

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

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

/* ── GRID ── */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── STAT CARDS ── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-value {
    font-size: 1.625rem;
    font-weight: 700;
    color: #fff;
    margin-top: 0.375rem;
    letter-spacing: -0.5px;
}

.stat-value.income { color: var(--green); }
.stat-value.expense { color: var(--red); }

.stat-sub {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-danger   { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }
.btn-danger:hover { background: #7f1d1d; }
.btn-ghost    { background: transparent; color: var(--subtle); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-sm       { padding: 0.4375rem 0.875rem; font-size: 0.8125rem; }
.btn svg      { width: 16px; height: 16px; }

/* ── FORMS ── */
.form-group { margin-bottom: 1.125rem; }

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--subtle);
    margin-bottom: 0.4375rem;
}

input, select, textarea {
    width: 100%;
    background: #09090b;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6875rem 0.875rem;
    color: var(--text);
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #3f3f46; }
select option { background: var(--surface); }
textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.hint {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.3125rem;
}

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-income  { background: #052e16; color: #86efac; }
.badge-expense { background: #450a0a; color: #fca5a5; }
.badge-personal  { background: #0c1a3a; color: #93c5fd; }
.badge-business  { background: #1c1a00; color: #fde68a; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

thead th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #1c1c1f;
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #1c1c1f; }

/* ── PROGRESS BAR ── */
.progress-wrap {
    background: #27272a;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.4s ease;
}

/* ── FAB ── */
.fab {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    width: 52px;
    height: 52px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
    transition: background 0.15s, transform 0.15s;
    z-index: 50;
}

.fab:hover { background: var(--accent-h); transform: scale(1.05); }
.fab svg   { width: 22px; height: 22px; }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.empty-state svg {
    width: 40px;
    height: 40px;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p { font-size: 0.9375rem; }

/* ── DIVIDER ── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .mobile-header { display: flex; }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(56px + 1rem);
    }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .grid-2.keep-2 { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }

    .fab {
        bottom: 1.25rem;
        right: 1.25rem;
    }
}