/* ... Estilos anteriores se mantienen ... */

/* ACORDEÓN DE HISTORIAL */
.accordion-cell {
    position: relative;
    cursor: default; /* Solo el toggle es cursor pointer */
}

.main-value {
    display: inline-block;
    cursor: pointer;
    font-weight: bold;
}

.accordion-toggle {
    font-size: 0.7rem;
    color: #6b7280;
    cursor: pointer;
    margin-left: 5px;
    vertical-align: middle;
}

.history-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    min-width: 150px;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 10;
    border-radius: 6px;
    padding: 5px 0;
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    padding: 5px 10px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    color: #374151;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item small {
    color: #9ca3af;
    font-size: 0.75rem;
}

/* ... Resto de estilos ... */
:root {
    --primary: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --light: #f3f4f6;
    --border: #e5e7eb;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--light);
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

.main-header { margin-bottom: 20px; }
h1, h2 { color: var(--dark); margin: 0; }

.nav-bar { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid var(--border); padding-bottom: 10px; }
.nav-link { text-decoration: none; padding: 10px 20px; color: #4b5563; font-weight: bold; border-radius: 6px; }
.nav-link:hover { background-color: #e5e7eb; }
.nav-link.active { background-color: var(--primary); color: white; }

.period-filter {
    background: white; padding: 15px; border-radius: 8px; margin-bottom: 20px;
    display: flex; gap: 10px; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.period-filter select { padding: 8px; border-radius: 4px; border: 1px solid #d1d5db; font-weight: bold; color: var(--dark); }

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.card {
    background: white; padding: 20px; border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); text-align: center;
}
.card h3 { font-size: 0.9rem; color: #6b7280; margin: 0; }
.card p { font-size: 1.5rem; font-weight: bold; margin: 10px 0 0; }
.card.income p { color: var(--success); }
.card.receivable p { color: var(--warning); }
.card.expense p { color: var(--danger); }
.card.net p { color: var(--primary); }

.form-section {
    background: white; padding: 25px; border-radius: 10px;
    margin-bottom: 30px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.form-group { display: flex; flex-direction: column; margin-bottom: 10px;}
label { font-size: 0.85rem; margin-bottom: 5px; color: #4b5563; }
input, select {
    padding: 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 1rem; width: 100%; box-sizing: border-box;
}
button.btn-save {
    background-color: var(--primary); color: white; border: none;
    padding: 12px; border-radius: 6px; cursor: pointer; font-weight: bold;
    width: 100%; transition: background 0.2s; margin-top: 10px;
}
button.btn-save:hover { background-color: #1d4ed8; }

.data-grid {
    background: white; border-radius: 10px; overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.grid-header {
    display: grid;
    /* Ajustado para nueva columna Adicionar en Finanzas */
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr 140px; 
    background-color: #f9fafb;
    font-weight: 600; color: #374151;
    border-bottom: 1px solid var(--border);
}

.grid-header > div { padding: 15px; }

.grid-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr 140px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.grid-row:last-child { border-bottom: none; }
.grid-row:hover { background-color: #f8fafc; }

.grid-cell {
    padding: 15px;
    display: flex; align-items: center; 
    overflow: visible; /* Permitir dropdown */
    text-overflow: ellipsis;
}

.editable-cell { cursor: pointer; position: relative; }
.editable-cell:hover { background-color: #fef3c7; }
.editable-cell input, .editable-cell select { width: 100%; padding: 5px; box-sizing: border-box; }

.status-badge {
    padding: 4px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: bold;
}
.status-pagado { background-color: #d1fae5; color: #065f46; }
.status-pendiente { background-color: #fef3c7; color: #92400e; }

.delete-btn {
    background-color: #fee2e2; color: #991b1b; border: none;
    padding: 6px 10px; border-radius: 4px; cursor: pointer;
}

.actions-cell {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

.btn-collected {
    background-color: #10b981; 
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
}
.btn-collected:hover { background-color: #059669; }

.error-banner { background-color: #fee2e2; color: #991b1b; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #f87171; }

.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.8); z-index: 1000; display: none; justify-content: center; align-items: center; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }

.total-row {
    font-weight: bold;
    background-color: #e5e7eb;
    border-top: 2px solid #9ca3af;
}

.btn-close-balance {
    background-color: #f59e0b; 
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    margin-left: auto;
}
.btn-close-balance:hover { background-color: #d97706; }

.balance-closed-badge {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: auto;
    font-size: 0.85rem;
    display: flex; align-items: center;
}

@media (max-width: 768px) {
    .grid-header { display: none; }
    .grid-row {
        grid-template-columns: 1fr; 
        padding: 10px; gap: 5px;
        border-bottom: 2px solid #e5e7eb;
    }
    .grid-cell { padding: 5px 0; justify-content: space-between; }
    .grid-cell::before {
        content: attr(data-label);
        font-weight: bold; color: #6b7280; margin-right: 10px;
    }
    .actions-cell { justify-content: flex-start; margin-top: 10px; }
}