* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

:root {
    --primary: #4361ee;
    --success: #06d6a0;
    --danger: #ef476f;
    --warning: #ffd166;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #64748b;
    --bg: #ffffff;
    --text: #1e293b;
    --card: #ffffff;
    --border: #e2e8f0;
    --input: #ffffff;
    --input-bg: #ffffff;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --text: #f1f5f9;
    --card: #1e293b;
    --border: #334155;
    --input: #334155;
    --input-bg: #334155;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Botão Tema com animação */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    z-index: 1000;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    outline: none;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 6px 15px rgba(67,97,238,0.4);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle i {
    transition: transform 0.5s ease;
}

.theme-toggle:hover i {
    transform: rotate(180deg);
}

/* Telas */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Login */
.login-card {
    max-width: 400px;
    margin: 50px auto;
    background: var(--card);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: slideUp 0.5s ease;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 10px;
    animation: float 3s ease-in-out infinite;
}

.logo h1 {
    font-size: 2rem;
}

.logo h1 span {
    color: var(--primary);
}

/* Tabs */
.tab-container {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: var(--bg);
    padding: 5px;
    border-radius: 10px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: var(--gray);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

/* Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: slideIn 0.3s ease;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    transition: color 0.3s;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 15px 15px 15px 45px;
    background: var(--input);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

.input-group input:focus + i {
    color: var(--primary);
}

/* Botões */
.btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(67,97,238,0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255,255,255,0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn-primary:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

.btn-full {
    grid-column: 1 / -1;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-google {
    width: 100%;
    padding: 15px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
}

.btn-google:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-google:hover i {
    color: white;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05) rotate(5deg);
    border-color: var(--primary);
}

/* Divider */
.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: var(--border);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

.divider span {
    background: var(--card);
    padding: 0 10px;
    color: var(--gray);
}

/* ===== HEADER CORRIGIDO ===== */
header {
    background: var(--card);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    border: 1px solid var(--border);
    animation: slideDown 0.5s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-content h2 {
    font-size: 1.5rem;
    margin: 0;
    background: linear-gradient(135deg, var(--primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-content h2 span {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#user-name {
    font-weight: 500;
    color: var(--text);
    padding: 0 10px;
    background: var(--bg);
    border-radius: 20px;
    line-height: 40px;
    white-space: nowrap;
    border: 1px solid var(--border);
}

/* Cards */
.card, .meta-card, .stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover, .meta-card:hover, .stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Progresso */
.progress-container {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--warning), var(--success));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    color: var(--gray);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
}

.stat-card i {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 10px;
    transition: transform 0.3s;
}

.stat-card:hover i {
    transform: scale(1.2);
}

.stat-label {
    display: block;
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.form-grid input,
.form-grid select {
    padding: 12px;
    background: var(--input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    transition: all 0.3s;
}

.form-grid input:focus,
.form-grid select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    height: 250px;
    position: relative;
}

/* Lista */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--input);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 5px 15px;
    margin-bottom: 20px;
    transition: all 0.3s;
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

.search-bar input {
    flex: 1;
    padding: 10px 0;
    background: none;
    border: none;
    color: var(--text);
}

.search-bar input:focus {
    outline: none;
}

.search-bar i {
    color: var(--gray);
    transition: color 0.3s;
}

.search-bar:focus-within i {
    color: var(--primary);
}

.gastos-lista {
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--border);
}

.gastos-lista::-webkit-scrollbar {
    width: 6px;
}

.gastos-lista::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 3px;
}

.gastos-lista::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.gasto-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s ease;
    transition: all 0.3s;
}

.gasto-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.gasto-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.gasto-data {
    color: var(--gray);
    font-size: 0.85rem;
}

.gasto-categoria {
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    border-radius: 15px;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.gasto-categoria:hover {
    transform: scale(1.05);
}

.gasto-valor {
    font-weight: 600;
    color: var(--danger);
}

.gasto-acoes {
    display: flex;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray);
    display: none;
    animation: fadeIn 0.5s ease;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    display: none;
    animation: slideInRight 0.3s ease;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== MODAL DE METAS ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: var(--card);
    max-width: 400px;
    margin: 100px auto;
    border-radius: 15px;
    border: 1px solid var(--border);
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    color: var(--text);
}

.modal-header h3 i {
    color: var(--primary);
    margin-right: 10px;
}

.modal-header .close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    transition: all 0.3s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-header .close:hover {
    color: var(--danger);
    background: rgba(239, 71, 111, 0.1);
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
}

.meta-config {
    margin-bottom: 25px;
}

.meta-config label {
    display: block;
    color: var(--text);
    margin-bottom: 10px;
    font-weight: 500;
}

.meta-input {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    margin-bottom: 10px;
    font-size: 1rem;
    transition: all 0.3s;
}

.meta-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

/* ===== MODAL DE CATEGORIAS (NOVO) ===== */
.modal-lg {
    max-width: 500px;
}

.categorias-lista {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.categoria-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    transition: all 0.3s;
    animation: slideIn 0.3s ease;
}

.categoria-item:hover {
    border-color: var(--primary);
    transform: translateX(5px);
}

.categoria-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.categoria-info i {
    color: var(--primary);
    font-size: 1.1rem;
}

.categoria-nome {
    font-weight: 500;
    color: var(--text);
}

.categoria-acoes {
    display: flex;
    gap: 8px;
}

.categoria-acoes button {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.categoria-acoes button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.1);
}

.categoria-acoes button.delete-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.categoria-fixa {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
}

.add-categoria {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.add-categoria input {
    flex: 1;
    padding: 12px;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s;
}

.add-categoria input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

.add-categoria button {
    width: 45px;
    height: 45px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.add-categoria button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(67,97,238,0.3);
}

/* Keyframes */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { 
        transform: translateY(-50px); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

@keyframes slideUp {
    from { 
        transform: translateY(50px); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .gasto-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    
    #user-name {
        flex: 1;
        text-align: center;
    }
    
    .toast {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
    
    .add-categoria {
        flex-direction: column;
    }
    
    .add-categoria button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .user-info {
        gap: 5px;
    }
    
    .btn-icon {
        width: 35px;
        height: 35px;
    }
    
    .modal-content {
        margin: 50px 20px;
    }
    
    .categoria-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .categoria-acoes {
        width: 100%;
        justify-content: flex-end;
    }
}