:root {
    --azul: #3470d1;
    --azul-claro: #f6faff;
}
body {
    font-family: Arial, sans-serif;
    background: #f9f9f9;
    margin: 0;
    padding: 0;
}
.layout {
    display: flex;
    min-height: 100vh;
}
/* Sidebar */
.sidebar {
    width: 0;
    background: var(--azul);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.2s;
}
.sidebar.open {
    width: 85vw;
    max-width: 340px;
    box-shadow: 4px 0 22px #0001;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1em 1em;
    font-size: 1.18em;
    font-weight: 700;
    background: #2565b7;
    letter-spacing: 1px;
}
.sidebar-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5em;
    cursor: pointer;
}
.sidebar-content {
    padding: 21px 15px 15px 15px;
    height: 100%;
    overflow-y: auto;
    flex: 1;
}
.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-group-title {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: #ffffff80;
    padding: 8px 13px;
    margin-top: 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}
.sidebar-group-title:hover {
    background: #ffffff15;
    color: #ffffff;
}
.sidebar-group-title::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.2s;
    opacity: 0.7;
}
.sidebar-group-title.collapsed::after {
    transform: rotate(-90deg);
}
.sidebar-group-links {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s;
    opacity: 1;
    padding-left: 8px;
}
.sidebar-group-links.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}
.sidebar-group-links .sidebar-link {
    margin-bottom: 4px;
    padding: 10px 13px;
}
.sidebar-link {
    background: #ffffff10;
    color: #fff;
    font-weight: 600;
    border: none;
    padding: 13px;
    margin-bottom: 0;
    border-radius: 8px;
    font-size: 1.02em;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.sidebar-link.active, .sidebar-link:active {
    background: #e5e9ff;
    color: var(--azul);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    left: 0; top: 0;
    width: 100vw; height: 100vh;
    background: #0007;
    z-index: 999;
}
.sidebar.open ~ .sidebar-overlay {
    display: block;
}
.menu-btn {
    font-size: 2em;
    color: var(--azul);
    background: none;
    border: none;
    position: fixed;
    top: 18px;
    left: 12px;
    z-index: 1100;
    cursor: pointer;
    display: block;
}
/* Conteúdo principal */
.main-content {
    max-width: 520px;
    margin: 0 auto;
    width: 99vw;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.main-content-inner {
    margin-top: 40px;
    padding: 32px 0 24px 0;
    background: #fff;
    box-shadow: 0 4px 16px #0001;
    border-radius: 12px;
}
h2 {
    text-align: center;
    margin-bottom: 22px;
    color: var(--azul);
}
form {
    display: flex;
    flex-direction: column;
    gap: 1em;
    width: 100%;
}
label {
    font-weight: 600;
    margin-bottom: 2px;
}
input, select {
    padding: 9px 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 1rem;
    background: var(--azul-claro);
}
input:focus, select:focus {
    outline: none;
    border-color: var(--azul);
    background: #fff;
}
button[type="submit"] {
    background: var(--azul);
    color: #fff;
    border: none;
    padding: 13px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 7px;
    margin-top: 10px;
}
button[type="submit"]:active {
    background: #2453a5;
}
.hidden {
    display: none !important;
}
.account-list,
.nature-list,
.raiz-list {
    margin-top: 16px;
    background: #255ca3;
    border-radius: 8px;
    padding: 10px 8px 6px 8px;
}
.account-item, .nature-item, .raiz-item {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #4884d74c;
    padding: 10px 4px;
}
.account-name, .nature-name, .raiz-name {
    font-weight: 600;
    color: #fff;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.account-payment, .nature-root {
    font-size: 0.85em;
    color: #d5e2ff;
    background: #ffffff15;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.remove-account-btn, .remove-nature-btn, .remove-raiz-btn {
    color: #ffc3ca;
    background: none;
    border: none;
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: transform .1s;
}
.nav-btns-cadastro {
    margin-top: 1.1em;
    display: flex;
    gap: 10px;
}
.nav-btns-cadastro button {
    flex: 1;
    color: var(--azul);
    background: #e7eeff;
    border: 1px solid #d1dfff;
    font-size: 1rem;
    font-weight: 600;
    padding: 9px;
    border-radius: 7px;
}
.nav-btns-cadastro .btn-b {
    color: #fff;
    background: var(--azul);
    border: none;
}
/* Dashboard */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.card-dash {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px #0001;
    text-align: center;
}
.card-dash h3 {
    margin: 0;
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.card-dash .value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--azul);
    margin: 10px 0;
}
.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
/* Cartões de Crédito */
.cards-list-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.card-summary-item {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px #0001;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 6px solid var(--azul);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-summary-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px #0002;
}
.card-summary-item h3 {
    margin: 0;
    color: #333;
}
.card-summary-item .arrow {
    font-size: 1.5em;
    color: var(--azul);
}

.card-details-view {
    margin-top: 20px;
}
.btn-voltar {
    background: #eee;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 20px;
    font-weight: 600;
    color: #555;
}
.month-group {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px #0001;
    margin-bottom: 20px;
    overflow: hidden;
}
.month-group-header {
    background: #f0f3fa;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e6f0;
}
.month-group-header h4 {
    margin: 0;
    color: var(--azul);
    text-transform: capitalize;
}
.month-total {
    font-weight: 700;
    color: #333;
}
.month-table {
    width: 100%;
    border-collapse: collapse;
}
.month-table th {
    background: #fdfdfd;
    color: #666;
    font-size: 0.8em;
    text-transform: uppercase;
    padding: 10px 20px;
}
.month-table td {
    padding: 12px 20px;
    border-bottom: 1px solid #f5f5f5;
}
@media (max-width: 900px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
    .chart-box {
        grid-column: span 1 !important;
    }
}

/* Responsividade Mobile para Dashboard */
@media (max-width: 768px) {
    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    
    .card-dash {
        padding: 15px !important;
    }
    
    .card-dash h3 {
        font-size: 0.8em !important;
    }
    
    .card-dash .value {
        font-size: 1.4em !important;
    }
    
    .filters-section {
        flex-wrap: wrap;
    }
    
    .filters-section > div {
        flex: 1 1 100%;
    }
    
    .filters-section button {
        flex: 1 1 100%;
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .dashboard-cards {
        grid-template-columns: 1fr !important;
    }
    
    .card-dash .value {
        font-size: 1.3em !important;
    }
    
    .chart-box {
        padding: 15px !important;
    }
    
    .chart-box h3 {
        font-size: 0.9em !important;
    }
    
    canvas {
        max-height: 250px !important;
    }
}
.chart-box {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px #0001;
}
.chart-box h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--azul);
}
/* Listagem de Despesas */
.main-content-wide {
    max-width: 1250px;
}
.filters-section {
    display: flex;
    gap: 15px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px #0001;
    margin-bottom: 20px;
    align-items: flex-end;
}
.filters-section > div {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.filters-section label {
    font-size: 0.85em;
    color: #666;
}
.filters-section button {
    background: var(--azul);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}
.filters-section button:hover {
    background: #2565b7;
}
.table-container {
    overflow-x: auto;
    margin-top: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px #0001;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
th {
    background: var(--azul);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}
tr:hover {
    background: #f8faff;
}
.text-right {
    text-align: right;
}
.tag {
    font-size: 0.85em;
    padding: 2px 8px;
    border-radius: 4px;
    background: #eee;
    color: #555;
}
.tag-natureza {
    background: #e7eeff;
    color: var(--azul);
}
@media (max-width: 800px) {
    .main-content-wide {
        padding: 0;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s;
    margin: 20px;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-header h3 {
    margin: 0;
    color: var(--azul);
    font-size: 1.2em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-content form {
    padding: 20px;
    box-sizing: border-box;
}

.modal-content label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.modal-content input[type="text"],
.modal-content input[type="number"] {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    box-sizing: border-box;
    margin: 0;
}

.modal-content input[type="text"]:focus,
.modal-content input[type="number"]:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 2px rgba(52, 112, 209, 0.1);
}

.modal-content small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85em;
    word-wrap: break-word;
}

@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        margin: 10px;
        max-width: none;
    }
    
    .modal-content form {
        padding: 15px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-header h3 {
        font-size: 1em;
    }
}

.modal-content button[type="submit"] {
    background: var(--azul);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1em;
}

.modal-content button[type="submit"]:hover {
    background: #2565b7;
}

.modal-content button[type="button"] {
    background: #ccc;
    color: #333;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1em;
}

.modal-content button[type="button"]:hover {
    background: #bbb;
}

