:root {
    --bg-app: #f4f6f8;
    --card-bg: #ffffff;
    --text-color: #1e272e;
    --green: #00d2d3; 
    --red: #ff6b6b;   
    --blue: #2e86de;
    --purple: #6c5ce7;
    --brand-gradient: linear-gradient(135deg, #093048 0%, #00988d 100%);
    --shadow-soft: 0 10px 20px rgba(0,0,0,0.05);
    --shadow-hover: 0 15px 30px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0; padding: 20px;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; color: var(--text-color);
    background-color: #093048;
    background-image: linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px; background-attachment: fixed;
    transition: background-color 0.3s;
}

body.dark-mode {
    background-color: #000;
}
body.dark-mode .app-frame {
    background: #1e1e1e;
    color: #eee;
}
body.dark-mode .login-box,
body.dark-mode .modal-box,
body.dark-mode #sidebar {
    background: #2d2d2d;
    color: #eee;
}
body.dark-mode .caixa-card {
    background: #2d3436; 
    border: 1px solid #444; 
    color: #fff; 
    box-shadow: none; 
}
body.dark-mode .caixa-hint { color: #aaa; }
body.dark-mode tr[style*="#f9f9f9"] {
    background: #333 !important;
    color: #fff !important;
    border: 1px solid #444;
}
body.dark-mode .expense-card,
body.dark-mode .dash-item,
body.dark-mode .table-container,
body.dark-mode .resumo-table th {
    background: #333;
    color: #eee;
}
body.dark-mode .resumo-table td,
body.dark-mode .col-name {
    color: #eee;
    border-color: #444;
}
body.dark-mode .search-container input {
    background: #333;
    color: white;
}
body.dark-mode .btn-small,
body.dark-mode .month-selector {
    background: #444;
    color: white;
}
body.dark-mode .goal-container,
body.dark-mode .modal-tabs,
body.dark-mode .tab,
body.dark-mode .btn-cancel,
body.dark-mode .date-badge,
body.dark-mode .btn-check,
body.dark-mode .vec-item,
body.dark-mode .progress-bg {
    background: #444;
    color: #eee;
    border-color: #555;
}
body.dark-mode .tab.active.saida, 
body.dark-mode .tab.active.entrada {
    background: #333;
}
body.dark-mode header h1 { color: #eee; }
body.dark-mode .dash-value { color: #eee; }
body.dark-mode .menu-item { color: #ccc; }
body.dark-mode .sub-link, body.dark-mode .sub-info { color: #aaa; border-color: #555; }
body.dark-mode .bottom-nav { background: #2d2d2d; border-top-color: #444; }
body.dark-mode .nav-item { color: #888; }
body.dark-mode .nav-item:hover, body.dark-mode .nav-item:active { color: var(--blue); }
body.dark-mode #modal-veiculo .dash-item { background: #333; border-color: #444 !important; }
body.dark-mode #modal-veiculo select { background: #333; color: white; border-color: #444; }

.app-frame {
    background: var(--bg-app); width: 100%; max-width: 400px;
    border-radius: 40px; padding: 25px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column; position: relative;
    max-height: 90vh; overflow-y: auto;
    padding-bottom: 0 !important; 
}
.app-frame::-webkit-scrollbar { width: 0px; background: transparent; }

header { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 10px;}
header h1 { font-size: 16px; margin: 0; text-transform: uppercase; letter-spacing: 2px; color: var(--text-color); font-weight: 700; opacity: 0.8;}
#welcome-msg { color: var(--green) !important; text-shadow: none; }

#sidebar {
    position: fixed; top: 0; left: -280px; width: 280px; height: 100%;
    background: white; z-index: 9500;
    transition: 0.3s; padding: 20px; box-sizing: border-box;
    box-shadow: 5px 0 20px rgba(0,0,0,0.2);
    overflow-y: auto; color: #333;
}
#sidebar.active { left: 0; }
#overlay-sidebar {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 9400; display: none; backdrop-filter: blur(2px);
}
#overlay-sidebar.active { display: block; }
.sidebar-header { margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 15px; display: flex; justify-content: space-between; align-items: center; }
.menu-item { padding: 12px 5px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; color: #555; }
.menu-item:hover { background: rgba(0,0,0,0.03); border-radius: 5px; }
.icon-left { font-size: 18px; margin-right: 10px; color: var(--blue); vertical-align: middle; }
.arrow { font-size: 16px; color: #ccc; }
.submenu { display: none; padding-left: 10px; margin-bottom: 10px; }
.sub-link, .sub-info { padding: 8px 10px; font-size: 12px; color: #777; border-left: 2px solid #eee; cursor: pointer; }
.sub-link:hover { color: var(--blue); border-left-color: var(--blue); }

#login-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #093048;
    background-image: linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px; z-index: 5000;
    display: flex; justify-content: center; align-items: center;
}
.login-box { background: white; padding: 35px; border-radius: 30px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); width: 85%; max-width: 320px; text-align: center; }

.btn-small { background: white; border: none; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #555; box-shadow: var(--shadow-soft); }
.month-selector { background: white; border: none; padding: 10px 20px; border-radius: 30px; font-weight: bold; color: #093048; box-shadow: var(--shadow-soft); }
.caixa-card { background: var(--brand-gradient); color: white; padding: 25px; border-radius: 25px; text-align: center; margin-bottom: 20px; box-shadow: 0 15px 30px rgba(0, 152, 141, 0.2); }
.caixa-valor { font-size: 28px; font-weight: bold; letter-spacing: 1px; }

.dashboard { display: flex; justify-content: space-between; gap: 10px; background: transparent; padding: 0; margin-bottom: 20px; }
.dash-item { text-align: center; flex: 1; background: white; padding: 15px 5px; border-radius: 20px; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; justify-content: center; }
.dash-label { font-size: 10px; font-weight: bold; color: #808e9b; margin-bottom: 5px; }
.dash-value { font-size: 13px; font-weight: bold; color: var(--text-color); }

.lista-gastos { max-height: 300px; overflow-y: auto; margin-bottom: 15px; padding: 5px; }
.expense-card { background: white; border-radius: 20px; margin-bottom: 12px; padding: 15px; display: flex; align-items: center; box-shadow: var(--shadow-soft); position: relative; }
.expense-card::before { content: ''; position: absolute; left: 0; top: 15px; bottom: 15px; width: 4px; border-radius: 0 4px 4px 0; }
.expense-card.pago::before { background: var(--green); } 
.expense-card.ganho::before { background: var(--blue); }
.expense-card:not(.pago):not(.ganho)::before { background: var(--red); }

.date-badge { background: #f1f2f6; color: #808e9b; width: 45px; height: 45px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: bold; font-size: 8px; margin-right: 15px; }
.date-badge span { font-size: 16px; color: var(--text-color); }
.col-name { font-weight: 600; font-size: 14px; color: var(--text-color); }
.btn-check { background: #f1f2f6; border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pago .btn-check { background: var(--green); color: white; }

.table-container { background: white; border-radius: 20px; overflow: hidden; margin-bottom: 20px; border: none; box-shadow: var(--shadow-soft); }
.resumo-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.resumo-table th { background: #fff; color: #808e9b; padding: 15px; text-align: left; font-weight: 600; border-bottom: 1px solid #eee; }
.resumo-table td { padding: 15px; border-bottom: 1px solid #f5f5f5; color: var(--text-color); }
.valor-pos { color: var(--green); font-weight: bold; }
.valor-neg { color: var(--red); font-weight: bold; }

.btn-add { background: var(--brand-gradient); color: white; border: none; padding: 18px; width: 100%; border-radius: 20px; font-weight: bold; cursor: pointer; margin-top: 10px; box-shadow: 0 8px 20px rgba(0, 152, 141, 0.25); }
.btn-vehicle { background: linear-gradient(135deg, #2e86de 0%, #54a0ff 100%); color: white; border: none; padding: 15px; width: 100%; border-radius: 20px; margin-top: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: bold; box-shadow: 0 8px 20px rgba(46, 134, 222, 0.3); }
.vec-item { background: #f8f9fa; border-radius: 12px; padding: 10px; border-left: 4px solid var(--blue); position: relative; font-size: 12px; }
.vec-info { display: flex; justify-content: space-between; align-items: center; }
.vec-delta { background: #fff3cd; color: #856404; padding: 4px 8px; border-radius: 6px; font-size: 10px; font-weight: bold; margin-top: 5px; display: inline-block; border: 1px solid #ffeeba; }
.btn-pdf { background: #34495e; color: white; border: none; padding: 15px; width: 100%; border-radius: 20px; margin-top: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 8px 20px rgba(52, 73, 94, 0.3); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; justify-content: center; align-items: center; z-index: 10000; backdrop-filter: blur(5px); }
.modal-box { background: white; padding: 25px; border-radius: 30px; width: 85%; max-width: 320px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.modal-tabs { display: flex; background: #f1f2f6; border-radius: 15px; padding: 5px; margin-bottom: 20px; }
.tab { flex: 1; text-align: center; padding: 10px; border-radius: 12px; font-size: 13px; cursor: pointer; font-weight: 600; color: #b2bec3; }
.tab.active.saida { background: white; color: var(--red); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.tab.active.entrada { background: white; color: var(--green); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.input-group label { font-size: 12px; color: #808e9b; font-weight: 600; }
.input-group input { border-radius: 12px; padding: 12px; border: 1px solid #dfe6e9; background: #fdfdfd; width: 100%; box-sizing: border-box; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-m { flex: 1; padding: 12px; border: none; border-radius: 12px; font-weight: bold; cursor: pointer; }
.btn-save { background: var(--green); color: white; }
.btn-cancel { background: #f1f2f6; color: #808e9b; }
.btn-delete { background: #ff7675; color: white; }

.search-container { margin: 10px 0 15px 0; position: relative; }
.search-container input { width: 100%; padding: 10px 10px 10px 35px; border-radius: 15px; border: 1px solid #dfe6e9; background: white; box-sizing: border-box; font-size: 13px; outline: none; box-shadow: var(--shadow-soft); }
.search-container .material-icons { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #808e9b; font-size: 18px; }

.goal-container { background: white; padding: 15px; border-radius: 20px; margin-bottom: 20px; box-shadow: var(--shadow-soft); border: 1px solid #f1f2f6; }
.goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.goal-title { font-size: 11px; font-weight: bold; color: #808e9b; text-transform: uppercase; }
.goal-value { font-size: 12px; color: var(--blue); cursor: pointer; font-weight: bold; text-decoration: underline; }
.progress-bg { background: #f1f2f6; height: 8px; border-radius: 4px; overflow: hidden; }
.progress-fill { background: var(--brand-gradient); height: 100%; width: 0%; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.goal-footer { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px; color: #808e9b; font-weight: 600; }

#modal-pagamento { display:none; z-index: 9999; }
input[type="checkbox"] { accent-color: var(--blue); width: 18px; height: 18px; }

* { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; }

.fab-container {
    position: sticky;
    bottom: 85px;          
    z-index: 900;
    width: 100%;           
    display: flex;         
    justify-content: flex-end;    
    pointer-events: none;  
}

.fab-btn {
    pointer-events: auto;  
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin-right: -15px;   
    background: var(--brand-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 152, 141, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.fab-btn:active {
    transform: scale(0.95);
}

.fab-btn .material-icons {
    font-size: 28px;
}

.bottom-nav {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    width: calc(100% + 50px); 
    margin-left: -25px; 
    margin-right: -25px;
    margin-bottom: -25px;
    height: auto; 
    min-height: 70px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #eee;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    z-index: 1000;
    border-bottom-left-radius: 40px; 
    border-bottom-right-radius: 40px;
    padding-bottom: 15px; 
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #b2bec3;
    cursor: pointer;
    width: 25%;
    height: 100%;
    transition: 0.3s;
    padding-top: 10px;
}

.nav-item:active {
    background-color: rgba(0,0,0,0.02);
}

.nav-item .material-icons {
    font-size: 24px;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
}

.tab-content {
    animation: fadeIn 0.3s ease-in-out;
}

#tab-transacoes .lista-gastos.full-height {
    max-height: none; 
    height: auto;
    overflow-y: visible;
    padding-bottom: 20px;
}

.nav-item.active {
    color: var(--blue);
}
.nav-item.active span {
    font-weight: bold;
}
.nav-item.active .material-icons {
    color: var(--blue);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    body {
        padding: 0; 
        background: var(--bg-app); 
        align-items: flex-start; 
    }

    .app-frame {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0; 
        border: none;
        box-shadow: none;
        padding-bottom: 0;
        padding-left: 15px;
        padding-right: 15px;
    }

    .bottom-nav {
        position: fixed; 
        bottom: 0;
        left: 0;
        width: 100%; 
        margin: 0; 
        border-radius: 0;
        padding-bottom: 15px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
    }
    
    .fab-container {
        position: fixed;
        bottom: 120px; 
        right: 20px;
        width: auto;
        margin: 0;
    }
    
    .spacer-bottom {
        height: 130px !important;
    }
}

/* =========================================
   ESTILOS DO TOAST (NOTIFICAÇÕES)
   ========================================= */
#toast-notificacao {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 30px;
    color: white;
    font-size: 13px;
    font-weight: bold;
    z-index: 100000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
    text-align: center;
    visibility: hidden;
}

#toast-notificacao.mostrar {
    transform: translateX(-50%) translateY(0);
    visibility: visible;
}

.toast-sucesso {
    background-color: var(--green);
}

.toast-erro {
    background-color: var(--red);
}