* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --secondary-color: #2563eb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #f8fafc;
    --darker-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --fijo-color: #8b5cf6;
    --variable-color: #06b6d4;
    --tarjeta-color: #f59e0b;
    --microcredito-color: #ec4899;
    --hover-bg: #f1f5f9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', sans-serif;
    background: #f1f5f9;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: none; /* Oculto por defecto */
    grid-template-columns: 350px 1fr;
    gap: 20px;
    min-height: calc(100vh - 40px);
}

/* Mostrar dashboard cuando el usuario esté autenticado */
body.authenticated .container {
    display: grid;
}

/* Panel Izquierdo - Resumen */
.summary-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    max-height: calc(100vh - 40px);
    border: 1px solid var(--border-color);
}

.summary-panel h1 {
    font-size: 24px;
    margin-bottom: 25px;
    color: var(--text-primary);
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.summary-card {
    background: var(--dark-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.summary-card h3 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    letter-spacing: 0;
}

.summary-card .amount {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.summary-card .amount.large {
    font-size: 32px;
}

.summary-card small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 10px;
    opacity: 0.7;
}

.amount.positive {
    color: var(--success-color);
}

.amount.negative {
    color: var(--danger-color);
}

.summary-card.balance {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: 2px solid var(--primary-color);
    margin-top: 20px;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.15);
}

.summary-card.balance h3,
.summary-card.balance .amount {
    color: white;
}

.summary-card.balance.surplus {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: var(--success-color);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.15);
}

.summary-card.balance.surplus h3,
.summary-card.balance.surplus .amount {
    color: white;
}

.summary-card.balance.deficit {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: var(--danger-color);
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.15);
}

.summary-card.balance.deficit h3,
.summary-card.balance.deficit .amount {
    color: white;
}

.chart-container {
    margin-top: 25px;
    padding: 15px;
    background: var(--dark-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-container h3 {
    font-size: 13px;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 600;
}

.category-breakdown {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.category-breakdown::-webkit-scrollbar {
    width: 6px;
}

.category-breakdown::-webkit-scrollbar-track {
    background: var(--darker-bg);
    border-radius: 3px;
}

.category-breakdown::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.category-breakdown::-webkit-scrollbar-thumb:hover {
    background: #2563eb;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
}

.category-item.fijo {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.03) 100%);
    border: 1px solid rgba(34, 197, 94, 0.12);
}

.category-item.variable {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.08) 0%, rgba(251, 146, 60, 0.03) 100%);
    border: 1px solid rgba(251, 146, 60, 0.12);
}

.category-item.tarjeta {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(139, 92, 246, 0.03) 100%);
    border: 1px solid rgba(139, 92, 246, 0.12);
}

.category-item.microcredito {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.08) 0%, rgba(236, 72, 153, 0.03) 100%);
    border: 1px solid rgba(236, 72, 153, 0.12);
}

.interest-detail {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 8px;
    background: repeating-linear-gradient(
        45deg,
        rgba(20, 184, 166, 0.08),
        rgba(20, 184, 166, 0.08) 3px,
        transparent 3px,
        transparent 6px
    );
    border-radius: 4px;
    font-size: 10px;
    border: 1px dashed rgba(20, 184, 166, 0.3);
}

.interest-detail .interest-icon {
    font-size: 11px;
}

.interest-detail .interest-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.interest-detail .interest-amount {
    color: #14b8a6;
    font-weight: 600;
}

.interest-detail .interest-percent {
    color: var(--text-secondary);
    font-size: 10px;
    opacity: 0.8;
}

.category-item .category-name {
    font-weight: 500;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.2;
}

.category-item .category-stats {
    text-align: right;
}

.category-item .category-amount {
    font-weight: bold;
    font-size: 13px;
    color: var(--primary-color);
}

.category-item .category-percent {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Gestión de Base de Datos */
.db-management {
    margin-top: 20px;
    padding: 15px;
    background: var(--dark-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.db-management h3 {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.btn-db {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-db:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-db:active {
    transform: translateY(0);
}

/* Pestañas de Meses */
.month-tabs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* Fila de selectores */
.month-selector-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.selector-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Estilos para selects */
.year-selector,
.month-selector {
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--dark-bg);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 100px;
}

.year-selector:hover,
.month-selector:hover {
    border-color: var(--primary-color);
    background: var(--hover-bg);
}

.year-selector:focus,
.month-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Botones de acción */
.btn-add-month,
.btn-delete-month {
    padding: 10px 20px;
    border-radius: 8px;
    border: 2px solid;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-add-month {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
    width: 100%;
}

.btn-add-month:hover {
    background: #059669;
    border-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.2);
}

.btn-delete-month {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
    padding: 10px 16px;
    font-size: 18px;
}

.btn-delete-month:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-color: var(--danger-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.15);
}

/* Panel Principal */
.main-panel {
    background: transparent;
    border-radius: 12px;
    padding: 0;
    overflow-y: auto;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Secciones */
.section-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.section-large {
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-small {
    border-color: var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Tablas */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    background: var(--darker-bg);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead {
    background: var(--dark-bg);
    border-bottom: 2px solid var(--border-color);
}

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.data-table tbody tr:hover:not(.empty-row) {
    background: var(--hover-bg);
}

.data-table tbody td {
    padding: 12px 16px;
    color: var(--text-primary);
}

.data-table tbody td:first-child {
    font-weight: 600;
}

/* Columna de acciones con ancho mínimo para evitar que se pierdan botones */
.data-table tbody td:last-child {
    min-width: 120px;
    white-space: nowrap;
}

.data-table-large tbody td {
    padding: 15px;
    font-size: 15px;
}

.empty-row {
    background: var(--darker-bg) !important;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 25px !important;
    opacity: 0.5;
}

/* Badges de categoría */
.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-badge:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.category-badge.fijo {
    background: #ede9fe;
    color: #7c3aed;
}

.category-badge.variable {
    background: #cffafe;
    color: #0891b2;
}

.category-badge.tarjeta {
    background: #fef3c7;
    color: #d97706;
}

.category-badge.microcredito {
    background: #fce7f3;
    color: #db2777;
}

/* Badges de estado */
.estado-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.estado-badge:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.estado-badge.pagado {
    background: #d1fae5;
    color: #065f46;
}

.estado-badge.pendiente {
    background: #fee2e2;
    color: #991b1b;
}

/* Formularios Inline */
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
    background: var(--dark-bg);
    border-radius: 8px;
    margin-bottom: 12px;
    align-items: center;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

/* Inputs principales */
.inline-form input[type="text"],
.inline-form input[placeholder*="nombre"],
.inline-form input[placeholder*="Nombre"],
.inline-form input[placeholder*="Descripción"],
.inline-form input[placeholder*="descripción"] {
    flex: 1 1 300px;
    min-width: 200px;
}

/* Inputs numéricos y selects */
.inline-form input[type="number"],
.inline-form select {
    flex: 1 1 150px;
    min-width: 120px;
}

/* Display de intereses (microcréditos) */
.intereses-display {
    flex: 1 1 180px;
    min-width: 150px;
}

/* Botones */
.inline-form .btn-save,
.inline-form .btn-cancel {
    flex: 0 0 auto;
    min-width: 90px;
}

/* Responsive para pantallas medianas (1024px - 768px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .inline-form input,
    .inline-form select {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .inline-form input[type="text"],
    .inline-form input[placeholder*="nombre"],
    .inline-form input[placeholder*="Nombre"] {
        flex: 1 1 250px;
        min-width: 180px;
    }
    
    .inline-form input[type="number"],
    .inline-form select {
        flex: 1 1 130px;
        min-width: 100px;
    }
}

/* Responsive para tablets (768px - 600px) */
@media (max-width: 768px) and (min-width: 601px) {
    .inline-form {
        gap: 10px;
        padding: 14px;
    }
    
    /* Inputs de texto ocupan más espacio */
    .inline-form input[type="text"],
    .inline-form input[placeholder*="nombre"],
    .inline-form input[placeholder*="Nombre"] {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    /* Numéricos y selects comparten fila */
    .inline-form input[type="number"],
    .inline-form select {
        flex: 1 1 calc(50% - 5px);
        min-width: 140px;
    }
    
    /* Display de intereses */
    .intereses-display {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    /* Botones comparten fila */
    .inline-form .btn-save,
    .inline-form .btn-cancel {
        flex: 1 1 calc(50% - 5px);
        min-width: 120px;
    }
}

.inline-form input,
.inline-form select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
    color: var(--text-primary);
    font-family: inherit;
    max-width: 100%;
    box-sizing: border-box;
}

.inline-form input:focus,
.inline-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.intereses-display {
    padding: 10px 12px;
    background: #fef3c7;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    text-align: center;
    border: 1px solid #fbbf24;
}

.intereses-display span {
    display: block;
    font-size: 13px;
    margin-top: 2px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: 2px solid var(--primary-color);
    width: 100%;
}

.btn-primary:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}

.btn-add {
    background: var(--success-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-add:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

.btn-save {
    background: var(--success-color);
    color: white;
    padding: 9px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-save:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

.btn-cancel {
    background: var(--hover-bg);
    color: var(--text-secondary);
    padding: 9px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger-color);
    padding: 8px 16px;
    font-size: 13px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.btn-danger:hover {
    background: var(--danger-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    transition: all 0.2s ease;
    line-height: 1;
    font-weight: 300;
}

.btn-delete:hover {
    color: var(--danger-color);
    transform: scale(1.3);
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.btn-icon:hover {
    transform: scale(1.2);
    color: var(--primary-color);
}

/* Filtros */
.filters-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Headers ordenables */
.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    position: relative;
}

.sortable-header:hover {
    background: var(--hover-bg);
}

.sort-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.4;
    transition: all 0.2s ease;
}

.sort-icon.active {
    opacity: 1;
    color: var(--primary-color);
    font-weight: bold;
}

.sortable-header:hover .sort-icon {
    opacity: 0.7;
}

/* Editable cells */
.editable-cell {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.editable-cell:hover {
    color: var(--secondary-color);
    transform: scale(1.05);
}

.cell-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}



/* Responsive */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }

    .summary-panel {
        max-height: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .summary-panel,
    .main-panel {
        padding: 20px;
        /* Quitar scrolls independientes en móvil */
        overflow-y: visible;
        max-height: none;
    }
    
    /* Forzar layout vertical en móviles */
    .container {
        display: block !important;
    }
    
    /* Ocultar sección de DB management en móvil */
    .db-management {
        display: none !important;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Formularios inline: todos los elementos 100% de ancho */
    .inline-form {
        flex-direction: column !important;
        gap: 12px;
        padding: 16px;
    }
    
    .inline-form input,
    .inline-form select,
    .intereses-display {
        flex: none !important;
        width: 100% !important;
        min-width: 100% !important;
    }
    
    /* Botones en fila al 50% cada uno */
    .inline-form .btn-save,
    .inline-form .btn-cancel {
        flex: none !important;
        width: calc(50% - 6px) !important;
        min-width: 100px;
        display: inline-block;
    }

    .data-table {
        font-size: 12px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .data-table tbody td:last-child {
        position: sticky;
        right: 0;
        background: white;
        box-shadow: -2px 0 4px rgba(0,0,0,0.05);
        z-index: 1;
        min-width: 100px;
    }
    
    .data-table tbody tr:hover td:last-child {
        background: var(--hover-bg);
    }

    .filters-inline {
        width: 100%;
    }
}

/* Responsive para pantallas muy pequeñas (móviles) */
@media (max-width: 480px) {
    .inline-form {
        padding: 14px !important;
    }
    
    .inline-form input,
    .inline-form select {
        padding: 10px 12px !important;
        font-size: 14px !important;
    }
    
    .btn-save,
    .btn-cancel {
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600;
    }
    
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    .form-field input,
    .form-field select {
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* Scrollbar personalizada */
.summary-panel::-webkit-scrollbar,
.main-panel::-webkit-scrollbar {
    width: 8px;
}

.summary-panel::-webkit-scrollbar-track,
.main-panel::-webkit-scrollbar-track {
    background: var(--dark-bg);
    border-radius: 10px;
}

.summary-panel::-webkit-scrollbar-thumb,
.main-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.summary-panel::-webkit-scrollbar-thumb:hover,
.main-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========================================
   FORMULARIO DE CRÉDITOS
   ======================================== */

.credito-form {
    background: var(--dark-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.credito-form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.form-section h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-field input,
.form-field select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-field small {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Ocultar flechas en inputs numéricos del formulario de créditos (Bug fix) */
.credito-form input[type="number"]::-webkit-outer-spin-button,
.credito-form input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.credito-form input[type="number"] {
    -moz-appearance: textfield;
}

/* También ocultar en los campos dinámicos de seguros y cargos */
#segurosContainer input[type="number"]::-webkit-outer-spin-button,
#segurosContainer input[type="number"]::-webkit-inner-spin-button,
#otrosCargosContainer input[type="number"]::-webkit-outer-spin-button,
#otrosCargosContainer input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#segurosContainer input[type="number"],
#otrosCargosContainer input[type="number"] {
    -moz-appearance: textfield;
}

/* Campos dinámicos (seguros y otros cargos) */
.dynamic-field {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--dark-bg);
    border-radius: 6px;
}

.dynamic-field input {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.dynamic-field input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-add-item {
    padding: 8px 14px;
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
}

.btn-add-item:hover {
    background: var(--primary-color);
    color: white;
}

.btn-remove {
    padding: 4px 10px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.btn-remove:hover {
    background: #dc2626;
}

/* Vista Previa */
.preview-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none !important;
}

.preview-section h4 {
    color: white;
    opacity: 0.95;
}

.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.preview-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

.preview-item span {
    font-size: 11px;
    opacity: 0.9;
}

.preview-item strong {
    font-size: 16px;
    font-weight: 700;
}

.preview-item.highlight {
    grid-column: 1 / -1;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.preview-item.highlight strong {
    font-size: 20px;
    color: #ffd700;
}

.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 10px;
}

/* Barra de progreso */
.progress-bar {
    position: relative;
    width: 100%;
    height: 24px;
    background: var(--dark-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #34d399);
    transition: width 0.3s ease;
    border-radius: 12px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    z-index: 1;
}

/* Color para créditos */
.category-item.credito {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(6, 182, 212, 0.03) 100%);
    border: 1px solid rgba(6, 182, 212, 0.12);
}

/* Responsive para formulario de créditos */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .preview-grid {
        grid-template-columns: 1fr;
    }
    
    .dynamic-field {
        grid-template-columns: 1fr;
    }
    
    .btn-remove {
        justify-self: flex-end;
    }
}

/* ========================================
   MODAL DE DETALLES DEL CRÉDITO
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content-credito {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header-credito {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-header-credito h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 32px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-body-credito {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detalle-section {
    background: var(--dark-bg);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.detalle-section h4 {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detalle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detalle-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.detalle-item span {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.detalle-item strong {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 700;
}

.detalle-item.highlight {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.detalle-item.highlight span {
    color: rgba(255, 255, 255, 0.9);
}

.detalle-item.highlight strong {
    color: #ffd700;
    font-size: 20px;
}

/* Barra de progreso grande (para el modal) */
.progress-bar-large {
    position: relative;
    width: 100%;
    height: 36px;
    background: white;
    border-radius: 18px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar-large .progress-fill {
    background: linear-gradient(90deg, var(--success-color), #34d399, #10b981);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.progress-bar-large .progress-text {
    font-size: 14px;
    font-weight: 700;
}

.detalle-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detalle-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.detalle-list-item span {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.detalle-list-item strong {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 600;
}

.detalle-vacio {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 10px;
    font-style: italic;
}

/* Responsive para modal */
@media (max-width: 768px) {
    .modal-content-credito {
        width: 95%;
        max-height: 95vh;
    }
    
    .detalle-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-body-credito {
        padding: 16px;
    }
}
