:root {
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1f2530;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-bg: #161c2d;
    --sidebar-text: #c7cede;
    --sidebar-active: #2563eb;
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0891b2;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

[data-theme="dark"] {
    --bg: #10131c;
    --card-bg: #171c2b;
    --text: #e7e9ee;
    --text-muted: #9aa1b1;
    --border: #262c3d;
    --sidebar-bg: #0c0f19;
    --sidebar-text: #aab0c2;
}

* { box-sizing: border-box; }

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

a { text-decoration: none; }

.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand img { height: 34px; }

.sidebar-nav-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    padding: 16px 18px 6px;
}

.sidebar-nav { flex: 1; padding-bottom: 12px; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: var(--sidebar-text);
    font-size: .92rem;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

.sidebar-nav .nav-link.active {
    background: rgba(37,99,235,0.18);
    border-left-color: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: .85rem;
}

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 999px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
[data-theme="dark"] .theme-toggle .theme-icon-dark { display: inline-block; }

.content-body { padding: 24px; flex: 1; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 14px 18px;
}

.icon-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(37,99,235,0.12);
    color: var(--primary);
}

.kpi-card { padding: 18px; }
.kpi-label { color: var(--text-muted); font-size: .82rem; margin-bottom: 6px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-trend { font-size: .8rem; margin-top: 4px; display: inline-block; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-muted); }

.table { color: var(--text); }
.table thead th {
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}
.table td, .table th { border-color: var(--border); vertical-align: middle; }

.badge-receita { background: rgba(22,163,74,0.14); color: var(--success); }
.badge-despesa { background: rgba(220,38,38,0.14); color: var(--danger); }
.badge-pago { background: rgba(22,163,74,0.14); color: var(--success); }
.badge-pendente { background: rgba(245,158,11,0.16); color: #b45309; }
.badge-futuro { background: rgba(8,145,178,0.14); color: var(--info); }

.form-control, .form-select {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(37,99,235,0.15);
}
.form-label { font-size: .85rem; font-weight: 500; color: var(--text-muted); }

.perm-badge { min-width: 92px; text-align: center; }

.auth-body { background: var(--bg); }
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}
.auth-logo { height: 48px; }

.text-muted { color: var(--text-muted) !important; }
.border { border-color: var(--border) !important; }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 1000; transition: left .2s; }
    .sidebar.open { left: 0; }
}
