/* ==========================================================
   MINHAS FINANÇAS — DESIGN SYSTEM FUTURISTA
   Indigo + Cyan neon · Glassmorphism · Modo escuro padrão
   Fontes: Sora (títulos) + Inter (corpo)
   ========================================================== */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.45);
    --accent: #06b6d4;
    --accent-dark: #0891b2;
    --accent-glow: rgba(6, 182, 212, 0.45);

    --grad-primary: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --grad-soft: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(6,182,212,0.12) 100%);
    --grad-radial: radial-gradient(circle at top right, rgba(99,102,241,0.15), transparent 60%);

    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --warning: #f59e0b;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    /* Modo claro */
    --bg: #f6f7fb;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --bg-overlay: rgba(255, 255, 255, 0.7);
    --text: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.15);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 0 40px var(--primary-glow);
}

[data-theme="dark"] {
    --bg: #0a0a14;
    --bg-card: #14141f;
    --bg-elevated: #1c1c2e;
    --bg-overlay: rgba(20, 20, 31, 0.7);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-soft: #64748b;
    --border: rgba(99, 102, 241, 0.18);
    --border-strong: rgba(99, 102, 241, 0.35);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 50px var(--primary-glow);
    --grad-radial: radial-gradient(circle at top right, rgba(99,102,241,0.25), transparent 60%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    background-image: var(--grad-radial);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 90px;
}

h1, h2, h3, h4, .brand {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

a { color: inherit; text-decoration: none; }

/* ---------- LAYOUT ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 18px; }
.page-title { font-size: 1.5rem; margin-bottom: 4px; }
.page-sub { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 22px; }

/* ---------- TOPBAR ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-overlay);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
}
.topbar .brand {
    font-size: 1.15rem;
    background: var(--grad-primary);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex; align-items: center; gap: 8px;
}
.topbar .brand-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--grad-primary); box-shadow: var(--shadow-glow);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-card);
    display: grid; place-items: center; cursor: pointer; font-size: 1.05rem;
    color: var(--text); transition: .2s;
}
.icon-btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    display: flex; justify-content: space-around; align-items: center;
    padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
    background: var(--bg-overlay);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 0.68rem; color: var(--text-soft); padding: 6px 10px;
    border-radius: var(--radius-sm); transition: .2s; font-weight: 600;
}
.nav-item .nav-ico { font-size: 1.25rem; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-ico { filter: drop-shadow(0 0 8px var(--primary-glow)); }
.nav-fab {
    width: 56px; height: 56px; border-radius: 50%; margin-top: -22px;
    background: var(--grad-primary); color: #fff; border: none;
    font-size: 1.7rem; display: grid; place-items: center; cursor: pointer;
    box-shadow: 0 8px 24px var(--primary-glow); transition: .2s;
}
.nav-fab:hover { transform: translateY(-2px) scale(1.03); }

/* ---------- CARDS ---------- */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow-sm); transition: .25s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; display:flex; align-items:center; gap:8px; }

/* ---------- KPIs ---------- */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px; margin-bottom: 22px;
}
.kpi {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px; position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.kpi::before {
    content: ''; position: absolute; inset: 0; opacity: .08; background: var(--grad-primary);
}
.kpi-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-family: 'Sora', sans-serif; font-size: 1.55rem; font-weight: 800; margin-top: 6px; position: relative; }
.kpi-value.pos { color: var(--success); }
.kpi-value.neg { color: var(--danger); }
.kpi-foot { font-size: 0.76rem; color: var(--text-soft); margin-top: 4px; }

/* ---------- GRID DE GRÁFICOS ---------- */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.charts-grid .full { grid-column: 1 / -1; }
@media (max-width: 800px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 280px; }

/* ---------- FILTROS ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: center; }
.seg {
    display: inline-flex; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-pill); padding: 4px; gap: 2px;
}
.seg button {
    border: none; background: transparent; color: var(--text-muted);
    padding: 7px 15px; border-radius: var(--radius-pill); cursor: pointer;
    font-weight: 600; font-size: 0.84rem; transition: .2s; font-family: inherit;
}
.seg button.active { background: var(--grad-primary); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }

/* ---------- FORMULÁRIOS ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
input, select, textarea {
    width: 100%; padding: 13px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
    font-size: 0.95rem; font-family: inherit; transition: .2s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    flex: 1; min-width: 90px; text-align: center; padding: 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 600; font-size: 0.88rem; transition: .2s; background: var(--bg);
    color: var(--text-muted);
}
.chip:hover { border-color: var(--border-strong); }
.chip.active { border-color: var(--primary); background: var(--grad-soft); color: var(--text); box-shadow: 0 0 0 1px var(--primary); }
.chip.active.receita { border-color: var(--success); box-shadow: 0 0 0 1px var(--success); color: var(--success); }
.chip.active.despesa { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); color: var(--danger); }

/* ---------- BOTÕES ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 22px; border: none; border-radius: var(--radius-sm);
    font-weight: 700; font-size: 0.95rem; cursor: pointer; font-family: inherit;
    transition: .2s; width: 100%;
}
.btn-primary { background: var(--grad-primary); color: #fff; box-shadow: 0 6px 18px var(--primary-glow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px var(--primary-glow); }
.btn-ghost { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; width: auto; }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---------- TABELA ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table.fin { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 900px; background: var(--bg-card); }
table.fin th, table.fin td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.fin th:first-child, table.fin td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-card); z-index: 1; }
table.fin thead th { background: var(--bg-elevated); font-family: 'Sora', sans-serif; font-weight: 700; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
table.fin thead th:first-child { z-index: 2; }
tr.grupo td { background: var(--grad-soft); font-weight: 700; font-family: 'Sora', sans-serif; }
tr.grupo td:first-child { background: var(--grad-soft); }
tr.total-row td { font-weight: 800; border-top: 2px solid var(--border-strong); }
tr.total-row td:first-child { background: var(--bg-card); }
.col-total { font-weight: 700; color: var(--primary); }
.v-zero { color: var(--text-soft); }
.v-pos { color: var(--success); }
.v-neg { color: var(--danger); }

/* ---------- LISTA DE LANÇAMENTOS ---------- */
.lanc-list { display: flex; flex-direction: column; gap: 10px; }
.lanc {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
    transition: .2s;
}
.lanc:hover { border-color: var(--border-strong); }
.lanc-ico { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.lanc-ico.receita { background: var(--success-glow); }
.lanc-ico.despesa { background: var(--danger-glow); }
.lanc-info { flex: 1; min-width: 0; }
.lanc-desc { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lanc-meta { font-size: 0.76rem; color: var(--text-muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.lanc-valor { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1rem; }
.lanc-valor.receita { color: var(--success); }
.lanc-valor.despesa { color: var(--danger); }
.lanc-acoes { display: flex; gap: 6px; }

.tag { font-size: 0.68rem; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--grad-soft); border: 1px solid var(--border); font-weight: 600; }
.tag.pago { color: var(--success); border-color: var(--success); }
.tag.pendente { color: var(--warning); border-color: var(--warning); }
.tag.pessoa { color: var(--accent); border-color: var(--accent); }

/* ---------- AUTH ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 34px 28px; box-shadow: var(--shadow-lg); }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .brand { font-size: 1.7rem; background: var(--grad-primary); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* ---------- EMPTY STATE ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .ico { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- ALERTAS ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 16px; border: 1px solid; }
.alert.erro { background: var(--danger-glow); border-color: var(--danger); color: var(--text); }
.alert.ok { background: var(--success-glow); border-color: var(--success); color: var(--text); }

/* ---------- BARRA % RENDA ---------- */
.gauge { margin-top: 8px; }
.gauge-bar { height: 12px; border-radius: var(--radius-pill); background: var(--bg-elevated); overflow: hidden; border: 1px solid var(--border); }
.gauge-fill { height: 100%; border-radius: var(--radius-pill); background: var(--grad-primary); transition: width .6s ease; }
.gauge-fill.alto { background: linear-gradient(135deg, #f59e0b, #ef4444); }

/* ---------- UTIL ---------- */
.fade-in { animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.text-center { text-align: center; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }
html { scroll-behavior: smooth; }
