:root {
    --bg-main: #121212;
    --bg-card: #1E1E1E;
    --bg-hover: #2D2D2D;
    --text-main: #E0E0E0;
    --text-muted: #9E9E9E;
    --primary: #7B61FF; /* Roxo moderno para a marca */
    --primary-hover: #9b86ff;
    --success: #00E676; /* Verde para receitas */
    --danger: #FF5252; /* Vermelho para despesas */
    --warning: #FFAB00; /* Amarelo/Laranja para alertas */
    --investment: #00B0FF; /* Azul para aportes/investimentos */
    --border-color: #333333;
    --font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
*::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #fff;
}

p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* ========================================
   SIDEBAR — Estrutura Premium
   ======================================== */
.sidebar {
    width: 240px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    flex-shrink: 0;
}

/* Logo */
.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

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

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

/* Perfil Compacto */
.sidebar-profile-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(123, 97, 255, 0.45);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-username {
    font-weight: 600;
    font-size: 0.875rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-level {
    font-size: 0.68rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    opacity: 0.9;
}

.sidebar-level i {
    margin-right: 3px;
}

/* Área de Navegação (scrollável) */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0.6rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}

/* Labels de Seção */
.nav-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.22);
    padding: 0.9rem 0.5rem 0.3rem;
    user-select: none;
    pointer-events: none;
}

/* Itens de Navegação */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.18s ease;
    position: relative;
    text-decoration: none;
}

.nav-item i {
    width: 17px;
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.18s ease;
}

.nav-item:hover {
    background-color: rgba(123, 97, 255, 0.1);
    color: #fff;
    transform: translateX(3px);
}

.nav-item:hover i {
    color: var(--primary);
}

.nav-item.active {
    background-color: rgba(123, 97, 255, 0.18);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary);
}

/* Pill lateral no item ativo */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 65%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

/* Rodapé Fixo */
.sidebar-footer {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    gap: 4px;
    flex-shrink: 0;
}

.sidebar-footer-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.1);
    margin: 0 4px;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    color: rgba(255,255,255,0.45);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.18s ease;
    flex: 1;
    justify-content: center;
}

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

.sidebar-footer-btn.active {
    color: var(--primary);
}

.sidebar-footer-logout:hover {
    background: rgba(255, 82, 82, 0.1);
    color: var(--danger) !important;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    height: 70px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
}

.content-area {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-family);
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(123, 97, 255, 0.2);
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-block {
    display: block;
    width: 100%;
}

/* Utilities */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-investment { color: var(--investment); }

.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Auth Layout */
.auth-container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1E1E1E 0%, #121212 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.auth-card h1 {
    margin-bottom: 0.5rem;
}

.auth-card p {
    margin-bottom: 2rem;
}

/* Responsive Design (Mobile First or Desktop Overlay) */
@media (max-width: 768px) {
    body {
        display: block !important;
        height: auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    .app-container {
        display: block !important;
        height: auto !important;
    }
    
    /* Sidebar overlay state for mobile */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -260px !important; /* hidden off-screen */
        width: 250px !important;
        height: 100vh !important;
        z-index: 1000 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.7) !important;
        padding-top: env(safe-area-inset-top) !important;
    }
    
    .sidebar.open {
        left: 0 !important;
    }
    
    .main-content {
        height: auto !important;
        overflow: visible !important;
    }
    
    .content-area {
        padding: 1rem !important; /* smaller padding for mobile */
        overflow-y: visible !important;
    }
    
    /* Mobile header bar styling */
    .mobile-header-bar {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background-color: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        padding: 0 1rem;
        padding-top: env(safe-area-inset-top);
        height: calc(56px + env(safe-area-inset-top));
        box-sizing: border-box;
        position: sticky;
        top: 0;
        z-index: 900;
    }
    
    .mobile-toggle-btn, .mobile-close-btn {
        background: transparent;
        border: none;
        color: var(--text-main);
        font-size: 1.25rem;
        cursor: pointer;
        padding: 0.25rem 0.5rem;
    }
    
    .mobile-close-btn {
        display: block !important;
        position: absolute;
        top: calc(15px + env(safe-area-inset-top));
        right: 15px;
        z-index: 1001;
    }
    
    .mobile-logo {
        font-size: 1.1rem;
        font-weight: 700;
        color: #fff;
    }
    
    .mobile-logo span {
        color: var(--primary);
    }
    
    .mobile-user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background-color: var(--primary);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        font-size: 0.9rem;
    }
    
    /* Sticky first column for tables on mobile */
    #table-wrapper table th:first-child {
        position: sticky !important;
        left: 0 !important;
        background-color: #121212 !important;
        z-index: 6 !important;
    }
    #table-wrapper table tbody tr td:first-child {
        position: sticky !important;
        left: 0 !important;
        background-color: #121212 !important;
        z-index: 5 !important;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.4) !important;
    }
    #table-wrapper table tfoot tr td:first-child {
        position: sticky !important;
        left: 0 !important;
        background-color: #1E1E1E !important; /* matches cardBg */
        z-index: 6 !important;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Compact cell padding and sizes on mobile */
    #table-wrapper table th,
    #table-wrapper table td {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
}
