/* ==========================================================================
   VDS CONTROLE FINANCEIRO - PREMIUM RESPONSIVE APP (BORDAS INTEIRAS)
   ========================================================================== */

:root {
    /* --- DESIGN SYSTEM: PREMIUM DARK MODE --- */
    --bg-body: #030712; 
    --bg-grad: radial-gradient(circle at top center, #111827 0%, #030712 100%);
    --aurora: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 65%);
    --surface: rgba(17, 24, 39, 0.6); 
    --surface-hover: rgba(31, 41, 55, 0.8);
    --border: rgba(255, 255, 255, 0.08); 
    --glass-blur: blur(24px); 
    --text-main: #f3f4f6; 
    --text-sec: #9ca3af; 
    --text-title: #ffffff;
    --input-bg: rgba(24, 31, 48, 0.6);
    --input-focus: rgba(17, 24, 39, 0.95);
    
    --select-arrow: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    
    --primary-grad: linear-gradient(135deg, #7c3aed, #a855f7);
    --primary-color: #a855f7;
    --primary-glow: 0 8px 24px rgba(168, 85, 247, 0.25);
    --inner-glow: inset 0 1px 1px rgba(255, 255, 255, 0.03); 
    
    --c-ganho: #10b981; 
    --c-gasto: #f43f5e; 
    --c-fixo: #0ea5e9; 
    --c-var: #f59e0b;
    
    --radius: 28px; 
    --radius-sm: 18px;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.3); 
    --nav-bg: rgba(10, 15, 30, 0.85);
}

body.light-mode {
    --bg-body: #f1f5f9; 
    --bg-grad: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --aurora: radial-gradient(circle, rgba(124, 58, 237, 0.05), transparent 60%);
    --surface: rgba(255, 255, 255, 0.9); 
    --surface-hover: #ffffff;
    --border: rgba(15, 23, 42, 0.08); 
    --text-main: #0f172a; 
    --text-sec: #64748b; 
    --text-title: #0f172a;
    --input-bg: rgba(241, 245, 249, 0.8); 
    --input-focus: #ffffff;
    --select-arrow: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.05);
    --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --nav-bg: rgba(255, 255, 255, 0.95);
}

/* Temas Opcionais */
body.theme-ocean { --primary-grad: linear-gradient(135deg, #0284c7, #06b6d4); --primary-color: #0ea5e9; --primary-glow: 0 8px 24px rgba(14, 165, 233, 0.25); }
body.theme-sunset { --primary-grad: linear-gradient(135deg, #ea580c, #eab308); --primary-color: #f97316; --primary-glow: 0 8px 24px rgba(249, 115, 22, 0.25); }
body.theme-nature { --primary-grad: linear-gradient(135deg, #059669, #10b981); --primary-color: #10b981; --primary-glow: 0 8px 24px rgba(16, 185, 129, 0.25); }
body.theme-berry { --primary-grad: linear-gradient(135deg, #db2777, #f472b6); --primary-color: #db2777; --primary-glow: 0 8px 24px rgba(219, 39, 119, 0.25); }

/* --- RESET & FLUIDEZ RESPONSIVA --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; -webkit-tap-highlight-color: transparent; outline: none; }
body { background: var(--bg-body); background-image: var(--bg-grad); color: var(--text-main); min-height: 100vh; display: flex; flex-direction: column; background-attachment: fixed; transition: background 0.4s ease, color 0.4s ease; overflow-x: hidden; }
body::before { content: ''; position: fixed; top: -5%; left: -5%; width: 40%; height: 40%; background: var(--aurora); z-index: -1; pointer-events: none; }

.app-shell { width: 100%; display: none; flex-direction: column; min-height: 100vh; } 
/* Padding responsivo: Usa a área segura do iPhone (notch/linha de baixo) */
.main-content { padding: clamp(10px, 3vw, 20px); padding-bottom: calc(110px + env(safe-area-inset-bottom)); width: 100%; max-width: 600px; margin: 0 auto; }

.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-120px); background: var(--nav-bg); border: 1px solid var(--border); color: var(--text-main); padding: 14px 28px; border-radius: 50px; font-size: 0.88rem; font-weight: 700; box-shadow: 0 20px 40px rgba(0,0,0,0.3); backdrop-filter: var(--glass-blur); z-index: 3000; opacity: 0; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); display: flex; align-items: center; gap: 10px; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast i { color: var(--c-ganho); font-size: 1.3rem; }

/* BASES DOS CARTÕES */
.dashboard-header, .list-card, .add-card, .modal-content, .login-card { background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--radius); }
.dashboard-header { padding: clamp(16px, 5vw, 24px); margin-bottom: 20px; } 

.top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.app-title { font-size: 0.7rem; color: var(--primary-color); font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 4px; }
/* Fonte fluida para o título principal caber em qualquer tela */
.app-subtitle { font-weight: 800; font-size: clamp(1.3rem, 6vw, 1.6rem); color: var(--text-title); letter-spacing: -0.5px; line-height: 1.1; }
.header-actions { display: flex; gap: clamp(6px, 2vw, 12px); align-items: center; }

/* FILTROS E PESQUISAS */
.filter-scroll { display: flex; gap: 10px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filter-scroll::-webkit-scrollbar { display: none; }
.chip { padding: 10px 20px; border-radius: 40px; border: 1px solid var(--border); background: rgba(125, 125, 125, 0.05); color: var(--text-sec); font-size: 0.85rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: 0.3s; flex-shrink: 0; }
.chip.active { background: var(--primary-grad); color: white; border-color: transparent; box-shadow: var(--primary-glow); }

.compact-date-row { display: flex; gap: 10px; align-items: center; }
.compact-select { 
    border: 1px solid var(--border); background: rgba(125,125,125,0.05); 
    padding: 12px 16px; border-radius: var(--radius-sm); 
    font-weight: 700; color: var(--text-main); font-size: 0.9rem; 
    outline: none; appearance: none; 
}

/* Regra só para o Mês (Select) */
select.compact-select { 
    flex: 1; /* Faz o mês esticar e ocupar o espaço que sobrar */
    background-image: var(--select-arrow); 
    background-repeat: no-repeat; 
    background-position: right 1rem center; 
    background-size: 0.9em; 
    padding-right: 36px; 
}

/* Regra só para o Ano (Input de Número) */
input[type="number"].compact-select { 
    flex: 0 0 100px !important; /* Trava a largura do ano em 100px (não esmaga) */
    width: 100px !important; 
    padding-left: 10px; 
    padding-right: 10px; 
    background-image: none !important; /* Tira a setinha fantasma */
    text-align: center; 
}

.compact-search { 
    display: flex; align-items: center; gap: 8px; 
    background: rgba(125,125,125,0.05); 
    border: 1px solid var(--border); 
    padding: 12px 16px; border-radius: var(--radius-sm); 
}
.compact-search input { 
    border: none; background: transparent; width: 100%; 
    font-size: 0.9rem; color: var(--text-main); outline:none; font-weight: 600; 
}

/* Regras específicas para Mês e Ano não quebrarem o layout */
select#movMes { flex: 0 0 auto; min-width: 130px; }
input#movAno { flex: 0 0 80px !important; width: 80px !important; padding: 12px 8px; text-align: center; }

.compact-search input::placeholder { color: var(--text-sec); opacity: 0.6; }

.btn-icon { width: clamp(36px, 10vw, 42px); height: clamp(36px, 10vw, 42px); border-radius: 50%; border: 1px solid var(--border); background: rgba(125,125,125,0.05); color: var(--text-main); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: 0.2s; }
.btn-icon:active { transform: scale(0.95); background: rgba(125,125,125,0.15); }

/* =========================================
   KPI GRID (BORDA INTEIRA COM EFEITO PREMIUM)
   ========================================= */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(10px, 3vw, 16px); margin-bottom: clamp(10px, 3vw, 16px); }

.kpi-card, .balance-card { 
    padding: clamp(16px, 5vw, 24px) 12px; text-align: center; position: relative; 
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    background: var(--surface); backdrop-filter: var(--glass-blur);
    border-radius: var(--radius); transition: all 0.3s ease;
}
.balance-card { margin-bottom: 28px; padding: clamp(24px, 6vw, 32px) 16px; }

.kpi-title { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
/* Fonte fluida que se adapta exatamente ao tamanho da tela para nunca quebrar a linha */
.kpi-value { font-size: clamp(1.1rem, 5.5vw, 1.45rem); font-weight: 800; white-space: nowrap; letter-spacing: -0.5px; }
.balance-card .kpi-value { font-size: clamp(1.5rem, 8vw, 2rem); letter-spacing: -1px; }

/* A MAGIA DAS BORDAS COLORIDAS */
.type-ganho { border: 1.5px solid rgba(16, 185, 129, 0.5); box-shadow: 0 0 20px rgba(16, 185, 129, 0.1), var(--inner-glow); }
.type-ganho .kpi-title { color: var(--text-sec); }
.type-ganho .kpi-value { color: var(--text-main); }

.type-gasto { border: 1.5px solid rgba(244, 63, 94, 0.5); box-shadow: 0 0 20px rgba(244, 63, 94, 0.1), var(--inner-glow); }
.type-gasto .kpi-title { color: var(--text-sec); }
.type-gasto .kpi-value { color: var(--text-main); }

.balanco-pos { border: 1.5px solid rgba(16, 185, 129, 0.8); box-shadow: 0 0 30px rgba(16, 185, 129, 0.2), var(--inner-glow); }
.balanco-pos .kpi-title { color: var(--text-sec); }
.balanco-pos .kpi-value { color: var(--c-ganho); }

.balanco-neg { border: 1.5px solid rgba(244, 63, 94, 0.8); box-shadow: 0 0 30px rgba(244, 63, 94, 0.2), var(--inner-glow); }
.balanco-neg .kpi-title { color: var(--text-sec); }
.balanco-neg .kpi-value { color: var(--c-gasto); }

/* =========================================
   LISTAS INTERNAS (PÍLULAS ESCURAS)
   ========================================= */
.list-section { display: flex; flex-direction: column; gap: 24px; }
.list-card { padding: clamp(16px, 5vw, 24px); }
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.list-title { font-weight: 800; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.list-total { font-weight: 800; font-size: 0.95rem; background: rgba(125,125,125,0.1); padding: 6px 14px; border-radius: 20px; }

.txt-ganho { color: var(--c-ganho); } .txt-fixo { color: var(--c-fixo); } .txt-var { color: var(--c-var); }

/* PÍLULA DOS ITENS DA LISTA */
.item-row { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 12px 16px; background: rgba(15, 23, 42, 0.4); 
    border: 1px solid rgba(255, 255, 255, 0.05); 
    border-radius: var(--radius-sm); margin-bottom: 10px; 
}
body.light-mode .item-row { background: rgba(241, 245, 249, 0.6); border-color: rgba(15, 23, 42, 0.05); }

.item-row:last-child { margin-bottom: 0; }
.item-left { display: flex; align-items: center; gap: 12px; }
.item-btn-chart { width: 34px; height: 34px; border-radius: 10px; background: rgba(125,125,125,0.08); color: var(--text-sec); border: none; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.item-name { font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.item-val { font-weight: 800; font-size: 0.95rem; }

/* =========================================
   EXTRATO DE MOVIMENTAÇÕES (CARDS INDIVIDUAIS)
   ========================================= */
.mov-list { display: flex; flex-direction: column; gap: 12px; }
.mov-card { 
    padding: 16px; display: flex; align-items: center; justify-content: space-between; 
    position: relative; overflow: hidden; background: var(--surface); 
    border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.mov-card::before { content: ''; position: absolute; left: 0; top: 15%; bottom: 15%; width: 4px; border-radius: 0 4px 4px 0; }
.mov-card.type-ganho::before { background: var(--c-ganho); box-shadow: 0 0 10px var(--c-ganho); }
.mov-card.type-fixo::before { background: var(--c-fixo); box-shadow: 0 0 10px var(--c-fixo); }
.mov-card.type-var::before { background: var(--c-var); box-shadow: 0 0 10px var(--c-var); }

.mov-left { display: flex; align-items: center; gap: 14px; padding-left: 8px; }
.mov-icon-box { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; color: white; position: relative; z-index: 1; }
.mov-icon-box::before { content:''; position: absolute; inset:0; background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent); border-radius: 14px; }
.mov-details h4 { margin: 0; font-size: 0.95rem; font-weight: 800; color: var(--text-main); letter-spacing: -0.2px; }
.mov-details span { font-size: 0.75rem; color: var(--text-sec); font-weight: 600; display: block; margin-top: 4px; }
.mov-val { font-weight: 800; font-size: 1rem; }

/* =========================================
   FORMULÁRIOS & BOTÕES ESTRUTURAIS
   ========================================= */
.add-card { padding: clamp(20px, 6vw, 30px) clamp(16px, 5vw, 24px); } 
.toggle-row { background: rgba(125,125,125,0.05); padding: 6px; border-radius: 20px; display: flex; margin-bottom: 28px; border: 1px solid var(--border); }
.toggle-btn { flex: 1; padding: 14px; text-align: center; border-radius: 16px; font-weight: 800; color: var(--text-sec); font-size: 0.95rem; transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.toggle-btn.active { background: var(--primary-grad); color: white; box-shadow: var(--primary-glow); }

.field { width: 100%; padding: 16px 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--input-bg); color: var(--text-main); font-size: 1rem; margin-bottom: 16px; font-weight: 600; transition: border-color 0.2s, background-color 0.2s; }
.field::placeholder { color: var(--text-sec); opacity: 0.6; }
.field:focus { background: var(--input-focus); border-color: var(--primary-color); }
select.field { appearance: none; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 1.2rem center; background-size: 1.1em; padding-right: 40px; cursor: pointer; }

.type-selector { display: flex; gap: 12px; margin-bottom: 28px; }
.type-opt { flex: 1; padding: 16px; text-align: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(125,125,125,0.04); color: var(--text-sec); font-weight: 800; font-size: 0.95rem; transition: 0.2s; }
.type-opt.selected { border-color: var(--primary-color); background: rgba(124, 58, 237, 0.08); color: var(--primary-color); }

.btn-plus { width: 60px; height: 60px; border-radius: var(--radius-sm); background: var(--primary-grad); color: white; border: none; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0; box-shadow: var(--primary-glow); }
.btn { width: 100%; padding: 18px; border: none; border-radius: 24px; font-weight: 800; font-size: 1.05rem; background: var(--primary-grad); color: white; display: flex; justify-content: center; align-items: center; gap: 10px; box-shadow: var(--primary-glow); transition: filter 0.2s, transform 0.1s; }
.btn:active { transform: scale(0.96); filter: brightness(0.9); }
.btn-danger { background: linear-gradient(135deg, #f43f5e, #be123c); box-shadow: 0 8px 24px rgba(244, 63, 94, 0.25); }

/* =========================================
   BOTTOM NAVIGATION BAR (PÍLULA FLUTUANTE)
   ========================================= */
.nav-bar { 
    position: fixed; bottom: 20px; 
    left: clamp(10px, 3vw, 20px); right: clamp(10px, 3vw, 20px); 
    max-width: 560px; margin: 0 auto;
    background: var(--nav-bg); 
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); 
    border: 1px solid var(--border); 
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), var(--inner-glow); 
    display: flex; justify-content: space-around; align-items: center; 
    z-index: 1000; padding: 14px 10px; border-radius: 40px; 
}
.nav-item { background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-sec); flex: 1; }
.nav-item i { font-size: 1.7rem; margin-bottom: 2px; transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.nav-item span { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.2px; opacity: 0.8; }
.nav-item.active { color: var(--primary-color); }
.nav-item.active i { transform: translateY(-4px) scale(1.1); filter: drop-shadow(0 6px 12px rgba(168, 85, 247, 0.4)); }
.nav-item.active span { opacity: 1; }
body.light-mode .nav-bar { box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15), var(--inner-glow); }

/* MODAIS E DIÁLOGOS IMMERSIVE */
.hidden { display: none !important; }
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(3, 7, 18, 0.85); z-index: 2000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 16px; }
.modal-content { background: var(--bg-body); background-image: var(--bg-grad); width: 100%; max-width: 450px; max-height: 88vh; border-radius: 32px; padding: clamp(20px, 6vw, 26px); display: flex; flex-direction: column; border: 1px solid var(--border); overflow-y: auto; box-shadow: var(--inner-glow), 0 24px 50px rgba(0,0,0,0.6); }
.modal-content h3 { color: var(--text-main); margin-bottom: 20px; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.5px; }
.modal-content label { color: var(--text-sec); font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; display: block; opacity: 0.9; }
.scroll-y { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.user-form-card { background: rgba(125,125,125,0.04); padding: 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

/* TELAS DE AUTENTICAÇÃO LIMPAS */
.login-container { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: center; justify-content: center; background: var(--bg-body); background-image: var(--bg-grad); flex-direction: column; padding: 24px; }
.login-card { width: 100%; max-width: 380px; padding: 40px 28px; text-align: center; }

/* SPINNER CENTRALIZADO PREMIUM */
#loader { position: fixed; inset: 0; z-index: 9999; background: rgba(3, 7, 18, 0.9); backdrop-filter: blur(16px); display: none; flex-direction: column; justify-content: center; align-items: center; gap: 24px; }
.spinner { width: 50px; height: 50px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.05); border-top-color: var(--primary-color); animation: spin 0.8s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-text { font-weight: 800; letter-spacing: 2px; font-size: 0.85rem; color: var(--text-sec); }

/* LISTA HIERÁRQUICA (RENDA FAMÍLIA ELEGANTE) */
.renda-group-card { background: rgba(125, 125, 125, 0.03); border: 1px solid var(--border); border-radius: 20px; margin-bottom: 12px; overflow: hidden; }
.renda-header { padding: 16px; display: flex; justify-content: space-between; align-items: center; background: rgba(16, 185, 129, 0.06); transition: background 0.2s; }
.renda-title { font-weight: 800; color: var(--text-main); font-size: 0.95rem; display: flex; align-items: center; gap: 10px; }
.renda-sub-group { margin-left: 16px; border-left: 2px solid var(--border); display: none; }
.renda-sub-header { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); background: transparent; }
.renda-sub-title { font-size: 0.88rem; color: var(--text-sec); font-weight: 700; }
.arrow-icon { font-size: 1rem; color: var(--text-sec); transition: transform 0.25s ease; }
.open .arrow-icon { transform: rotate(180deg); color: var(--text-main); }

/* CONTROLE DE BOTÃO DE SUPORTE */
.whatsapp-btn { margin-bottom: 24px; display: inline-flex; align-items: center; gap: 10px; background: rgba(37, 211, 102, 0.08); color: #24d366; padding: 14px 28px; border-radius: 50px; text-decoration: none; font-weight: 800; font-size: 0.95rem; border: 1px solid rgba(37, 211, 102, 0.15); transition: background 0.2s; }
.whatsapp-btn:active { background: rgba(37, 211, 102, 0.2); transform: scale(0.96); }

/* GERENCIADOR DE USUÁRIOS LINHAS COMPACTAS */
.user-item-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: rgba(125,125,125,0.04); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 8px; }
.btn-delete-user { background: rgba(244, 63, 94, 0.08); color: var(--c-gasto); border: 1px solid rgba(244, 63, 94, 0.15); width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }