:root {
    --primary-color: #3b36db; /* Azul moderno */
    --secondary-color: #6c757d;
    --success-color: #03bb85;
    --danger-color: #ff6961;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-bg: #f3f4f6;
    --sidebar-width: 250px;
    --header-height: 60px;
    --card-shadow: 0 4px 15px rgba(0,0,0,0.05);
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: var(--font-main);
    background-color: var(--light-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    color: #333;
}

/* Layout Estrutural */
.main-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    top: 0;
    left: 0;
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 25px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-color);
    border-bottom: 1px solid #f0f0f0;
}

.menu {
    list-style: none;
    padding: 20px 0;
    margin: 0;
}

.menu li a {
    display: flex;
    align-items: center;
    padding: 14px 25px;
    color: #666;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.95rem;
}

.menu li a:hover, .menu li a.active {
    background-color: #f4f6ff;
    color: var(--primary-color);
    border-right: 4px solid var(--primary-color);
}

.menu li a i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Conteúdo Principal */
.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
}

.topbar {
    height: var(--header-height);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Cards e KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    position: relative;
    border: 1px solid rgba(0,0,0,0.03);
}

.card h3 {
    margin: 0 0 10px 0;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.card .value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-primary { color: var(--primary-color) !important; }

/* Utilitários */
.d-flex { display: flex; }
.gap-20 { gap: 20px; }
.wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Botões */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: #2a25b8; box-shadow: 0 4px 10px rgba(59, 54, 219, 0.3); }

.btn-danger { background: var(--danger-color); color: white; }
.btn-danger:hover { background: #e04f47; }

/* Tabelas */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 15px;
    border-bottom: 2px solid #f0f0f0;
    color: #999;
    font-size: 0.85rem;
    text-transform: uppercase;
}

td {
    padding: 15px;
    border-bottom: 1px solid #f5f5f5;
    color: #444;
    font-size: 0.95rem;
    vertical-align: middle;
}

tr:hover td { background-color: #fafafa; }

/* Badges de Status */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}

.badge-pago { background: #e6fffa; color: var(--success-color); }
.badge-pendente { background: #fff8e1; color: var(--warning-color); }
.badge-atrasado { background: #ffebeb; color: var(--danger-color); }

/* Cartões de Crédito (Visual) */
.cc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.cc-card {
    background: #333;
    color: white;
    border-radius: 16px;
    padding: 25px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.cc-card:hover { transform: translateY(-5px); }

/* Estilos Específicos de Cartões */
.cc-card.nubank { background: linear-gradient(135deg, #820ad1 0%, #4c0677 100%); }
.cc-card.inter { background: linear-gradient(135deg, #ff7a00 0%, #ff5e00 100%); }
.cc-card.xp { background: linear-gradient(135deg, #111 0%, #333 100%); }
.cc-card.blue { background: linear-gradient(135deg, #005c97 0%, #363795 100%); }

.cc-top { display: flex; justify-content: space-between; align-items: start; z-index: 2; }
.cc-logo { font-size: 1.4rem; font-weight: 800; font-style: italic; }
.cc-info { z-index: 2; }

.cc-val { font-size: 1.4rem; font-weight: bold; margin: 5px 0 2px 0; }
.cc-label { font-size: 0.75rem; opacity: 0.8; text-transform: uppercase; }
.cc-bar-bg { background: rgba(255,255,255,0.2); height: 6px; border-radius: 3px; margin: 12px 0; width: 100%; }
.cc-bar-fill { background: white; height: 100%; border-radius: 3px; }

/* Responsivo */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.active { transform: translateX(0); }
    .content-wrapper { margin-left: 0; width: 100%; }
}

/* Login */
.login-body {
    background: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}
.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 360px;
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #555; }
.form-control { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 8px; box-sizing: border-box; }
.form-control:focus { border-color: var(--primary-color); outline: none; }

/* --- Componente Seletor de Data Customizado --- */
.date-selector-wrapper {
    position: relative;
    display: inline-block;
}

.date-selector-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.date-selector-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.date-dropdown {
    display: none; /* Oculto por padrão */
    position: absolute;
    top: 110%;
    right: 0;
    background: white;
    border: 1px solid #eee;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 12px;
    width: 280px;
    z-index: 1000;
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.date-dropdown.show {
    display: block;
}

/* Anos (Acordeão) */
.year-group {
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 5px;
}

.year-group:last-child {
    border-bottom: none;
}

.year-header {
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
    border-radius: 6px;
}

.year-header:hover {
    background-color: #f9f9f9;
}

.year-header i {
    transition: transform 0.3s;
    font-size: 0.8rem;
    color: #999;
}

.year-group.active .year-header i {
    transform: rotate(180deg);
}

.year-header.active-year-text {
    color: var(--primary-color);
}

/* Grade de Meses */
.months-grid {
    display: none; /* Oculto por padrão */
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 5px 10px 15px 10px;
}

.year-group.active .months-grid {
    display: grid;
}

.month-btn {
    padding: 6px;
    text-align: center;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    color: #666;
    border: 1px solid transparent;
    transition: 0.2s;
}

.month-btn:hover {
    background-color: #f0f4ff;
    color: var(--primary-color);
}

.month-btn.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.month-btn.current {
    border-color: var(--primary-color);
}

/* ... [Mantenha o CSS anterior] ... */

/* Estilos Específicos do Seletor Accordion */
.date-selector-wrapper {
    position: relative;
    display: inline-block;
    user-select: none;
}

.date-selector-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #444;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.date-selector-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.date-dropdown {
    display: none;
    position: absolute;
    top: 115%;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-radius: 12px;
    width: 300px;
    z-index: 1000;
    padding: 10px;
    max-height: 450px;
    overflow-y: auto;
}

.date-dropdown.show { display: block; animation: fadeIn 0.2s; }

/* Grupo de Anos */
.year-group {
    border-bottom: 1px solid #f5f5f5;
}

.year-group:last-child { border-bottom: none; }

.year-header {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #555;
    transition: background 0.2s;
    border-radius: 6px;
}

.year-header:hover { background-color: #f8f9fa; color: var(--primary-color); }

/* Ícone de rotação */
.year-header i { transition: transform 0.3s ease; font-size: 0.8rem; opacity: 0.6; }
.year-group.active .year-header i { transform: rotate(180deg); opacity: 1; color: var(--primary-color); }

/* Grade de Meses (Escondida por padrão) */
.months-grid {
    display: none;
    grid-template-columns: repeat(4, 1fr); /* 4 colunas para ficar compacto */
    gap: 8px;
    padding: 5px 15px 15px 15px;
    background-color: #fff;
}

/* Mostra grid quando ativo */
.year-group.active .months-grid { display: grid; }

.month-btn {
    padding: 8px 0;
    text-align: center;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    color: #666;
    background: #f8f9fa;
    transition: 0.2s;
    border: 1px solid transparent;
}

.month-btn:hover {
    background-color: #eef2ff;
    color: var(--primary-color);
    border-color: #dbe4ff;
}

.month-btn.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(59, 54, 219, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- SISTEMA DE MODAIS --- */
.modal-overlay {
    display: none; /* Oculto por padrão */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
    animation: slideUp 0.3s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.modal-header h3 { margin: 0; color: var(--primary-color); font-size: 1.2rem; }
.modal-close { cursor: pointer; font-size: 1.2rem; color: #999; transition: 0.2s; }
.modal-close:hover { color: var(--danger-color); }

/* Formulários no Modal */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.full-width { grid-column: span 2; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 54, 219, 0.1);
}

.modal-footer {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Animações */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}