/* ==================== DISEÑO DEL SISTEMA (COBRANZAS MASTER) ==================== */

:root {
    --bg-dark-950: #f8fafc;
    --bg-dark-900: #ffffff;
    --bg-dark-800: #f1f5f9;
    --bg-dark-700: #e2e8f0;
    
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-glow: rgba(16, 185, 129, 0.25);
    
    --accent: #34d399;
    --accent-glow: rgba(52, 211, 153, 0.15);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-dark: #94a3b8;
    
    --glass-bg: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.08);
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    
    --transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease, opacity 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ==================== ESTRUCTURA BASE ==================== */

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark-950);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark-950);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-dark-800);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ==================== LAYOUT DE DOS COLUMNAS (SIDEBAR) ==================== */

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* MENÚ LATERAL (SIDEBAR) */
.app-sidebar {
    width: 280px;
    background-color: #ffffff;
    border-right: 1px solid var(--glass-border);
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
}

.logo span span {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-logo {
    font-size: 1.6rem;
    color: var(--primary);
}

.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
}

/* Navegación del Sidebar */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0 1rem;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.925rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item i {
    font-size: 1.3rem;
}

.nav-item:hover {
    color: var(--primary);
    background: var(--bg-dark-800);
}

.nav-item.active {
    color: var(--primary);
    background: var(--success-bg);
    border-left-color: var(--primary);
    font-weight: 600;
}

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

/* Pie del Sidebar (Perfil de Usuario) */
.sidebar-footer {
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--glass-border);
}

.user-profile-sidebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
}

.profile-info-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-role-sidebar {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.user-name-sidebar {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.15);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    flex-shrink: 0;
}

.btn-logout-sidebar:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

/* Botón Hamburguesa Flotante para Móviles */
.mobile-toggle-btn {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.75rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px var(--primary-glow);
    z-index: 1001;
    transition: var(--transition);
}

.mobile-toggle-btn:hover {
    transform: scale(1.1) translateY(-3px);
}

/* CONTENEDOR DE CONTENIDO PRINCIPAL */
.app-content-wrapper {
    flex: 1;
    min-width: 0; /* Evita que tablas rompan el flexbox */
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding: 2.5rem 2.5rem 0;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ==================== CONTROL DE SECCIONES (MOSTRAR/OCULTAR) ==================== */

.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-header {
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.75rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header h2 i {
    color: var(--primary);
}

.section-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ==================== ANIMACIONES ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header-row .section-header {
    margin-bottom: 0;
}

/* ==================== METAS FINANCIERAS ==================== */

.metas-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.meta-progress-card {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 220px;
    transition: var(--transition);
}

.meta-progress-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-md);
}

.meta-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.meta-title {
    font-size: 1.15rem;
    color: var(--text-main);
    margin-bottom: 0.35rem;
    font-family: 'Outfit', sans-serif;
}

.meta-percent-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
}

.meta-amounts {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-top: 0.85rem;
    margin-bottom: 1.25rem;
}

.meta-amount-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
}

.meta-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 1rem;
    font-size: 0.8rem;
}

.meta-date {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ==================== CONTROL DE AHORROS ==================== */

.savings-balance-card {
    padding: 2.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
    border: 1px solid rgba(168, 85, 247, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.savings-balance-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: var(--accent-glow);
    border-radius: 50%;
}

.savings-balance-info {
    position: relative;
    z-index: 2;
}

.savings-balance-info span {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.savings-balance-info h2 {
    font-size: 2.75rem;
    font-weight: 700;
    margin-top: 0.5rem;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
}

.savings-balance-icon {
    font-size: 3.5rem;
    color: #a855f7;
    opacity: 0.8;
    position: relative;
    z-index: 2;
}

/* ==================== ESTILOS GENERALES DE TABLAS Y KPIs ==================== */

.flash-container {
    margin-bottom: 2rem;
}

.flash-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    position: relative;
    border: 1px solid transparent;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.flash-success {
    background-color: var(--success-bg);
    border-color: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.flash-danger {
    background-color: var(--danger-bg);
    border-color: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

.flash-warning {
    background-color: var(--warning-bg);
    border-color: rgba(251, 146, 60, 0.2);
    color: #fb923c;
}

.flash-info {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.btn-close-flash {
    position: absolute;
    right: 1.25rem;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
}

.btn-close-flash:hover {
    opacity: 1;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.kpi-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.color-blue {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}
.color-green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}
.color-orange {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}
.color-red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0.2rem 0;
    color: var(--text-main);
}

.kpi-subtext {
    font-size: 0.75rem;
    color: var(--text-dark);
}

/* Fila de Métricas Secundarias */
.metrics-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 900px) {
    .metrics-row {
        grid-template-columns: 1fr;
    }
}

.metric-progress-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.metric-header h4 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.metric-percent {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.25rem;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--bg-dark-800);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 6px;
    transition: width 0.4s ease;
}

.progress-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Panel de Accesos Rápidos */
.action-card-panel {
    padding: 2rem;
    margin-bottom: 2rem;
}

.action-card-panel h3 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

.quick-action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Botones */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-dark-800);
    color: var(--text-main);
    border: 1px solid var(--bg-dark-700);
}

.btn-success {
    background: var(--success-bg);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--bg-dark-700);
}

@media (hover: hover) {
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px var(--primary-glow);
        filter: brightness(1.1);
    }
    
    .btn-secondary:hover {
        background: var(--bg-dark-700);
        transform: translateY(-2px);
    }
    
    .btn-success:hover {
        background: var(--success);
        color: white;
        box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
    }
    
    .btn-outline:hover {
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-main);
    }
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* Tablas */
.data-section-table {
    padding: 1.5rem;
    overflow: hidden;
}

.table-container {
    overflow-x: auto;
    width: 100%;
    max-width: 100vw;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th {
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--bg-dark-700);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

td {
    padding: 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
    vertical-align: middle;
    white-space: nowrap;
}

@media (hover: hover) {
    tr:hover td {
        background: var(--bg-dark-800);
    }
}

.concept-cell {
    display: flex;
    flex-direction: column;
}

.primary-text {
    font-weight: 600;
    color: var(--text-main);
}

.secondary-text {
    font-size: 0.75rem;
    color: var(--text-dark);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-green {
    color: #4ade80;
}

.text-orange {
    color: #fb923c;
}

.text-danger {
    color: #f87171;
}

.text-muted {
    color: var(--text-dark);
}

.ident-code {
    background: var(--bg-dark-800);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
    border: 1px solid var(--bg-dark-700);
}

.method-tag {
    background: var(--bg-dark-800);
    border: 1px solid var(--bg-dark-700);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.note-text {
    font-style: italic;
    color: var(--text-muted);
}

.empty-table {
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1rem;
}

.empty-table i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

/* Badges de Estado */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-pendiente {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-activa {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-pagada {
    background: var(--success-bg);
    color: var(--success);
}

.badge-cumplida {
    background: var(--success-bg);
    color: var(--success);
}

.badge-vencida {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-outline {
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

/* ==================== VISTA LOGIN SIMPLE ==================== */

.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 100px);
}

.auth-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 3rem 2.5rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
    z-index: 0;
    pointer-events: none;
}

.auth-card * {
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px var(--primary-glow);
}

.auth-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ==================== FORMULARIOS / INPUTS ==================== */

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.input-group input, .input-group select {
    background: #ffffff;
    border: 1px solid var(--bg-dark-700);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    width: 100%;
}

.input-group input::placeholder {
    color: var(--text-dark);
}

.input-group select {
    cursor: pointer;
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 18px;
    width: 18px;
    background-color: #ffffff;
    border: 1px solid var(--bg-dark-700);
    border-radius: 4px;
    display: inline-block;
    position: relative;
    transition: var(--transition);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

/* ==================== MODALES ==================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.6);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
    
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    width: calc(100% - 2rem);
    max-width: 550px;
    padding: 1.5rem;
    margin: 2rem auto 4rem auto; /* Space at top and bottom */
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    background: #ffffff;
    border-radius: var(--radius-md);
}

@media (min-width: 768px) {
    .modal-card {
        padding: 2.25rem;
        margin: 4rem auto;
    }
}

.modal-backdrop.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.35rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
    transform: scale(1.1);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.row {
    display: flex;
    gap: 1rem;
}

.col {
    flex: 1;
}

@media (max-width: 600px) {
    .row {
        flex-direction: column;
        gap: 1.25rem;
    }
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.25rem;
}

.pago-target-info {
    background: var(--bg-dark-800);
    border: 1px solid var(--bg-dark-700);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.pago-target-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.pago-target-info p:last-child {
    margin-bottom: 0;
}

.pago-target-info strong {
    color: var(--text-main);
}

/* ==================== FOOTER ==================== */

.app-footer {
    text-align: center;
    padding: 2.5rem 2rem;
    font-size: 0.8rem;
    color: var(--text-dark);
    border-top: 1px solid var(--glass-border);
    margin-top: 4rem;
}

/* ==================== RESPONSIVIDAD PARA SIDEBAR (MÓVILES) ==================== */

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 900;
}

.btn-logout-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    text-decoration: none;
}

@media (max-width: 992px) {
    .app-layout {
        flex-direction: column;
    }
    
    .mobile-topbar {
        display: flex;
        justify-content: center;
        position: relative;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: 70px;
        flex-direction: row;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
        border-right: none;
        border-top: 1px solid var(--glass-border);
        z-index: 1000;
        background: #ffffff;
    }
    
    .sidebar-header, .sidebar-footer {
        display: none;
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        align-items: center;
        padding: 0 0.5rem;
        gap: 0.25rem;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }
    
    .nav-item {
        padding: 0.5rem;
        flex-direction: column;
        justify-content: center;
        min-width: 60px;
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 0;
        flex: 1 0 auto;
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary);
        background: transparent;
    }
    
    .nav-item.active i {
        transform: scale(1.1);
        color: var(--primary);
    }
    
    .nav-item i {
        font-size: 1.6rem;
    }
    
    .mobile-close-btn {
        display: none;
    }
    
    .mobile-toggle-btn {
        display: none;
    }
    
    .app-content-wrapper {
        padding-bottom: 80px;
    }
    
    .app-main {
        padding: 1.5rem 1.5rem 2rem;
    }
}

/* ==================== ANIMACIONES ==================== */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ==================== MEJORAS RESPONSIVAS (MOVIL, TABLET, PC) ==================== */

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .app-main {
        padding: 1.25rem 1rem 0;
    }
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
    }
    .metas-container {
        grid-template-columns: 1fr;
    }
    .metrics-row {
        grid-template-columns: 1fr;
    }
    .action-card-panel {
        padding: 1.25rem;
    }
    .quick-action-buttons {
        flex-direction: column;
    }
    .quick-action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    .modal-card {
        width: calc(100% - 2rem);
        padding: 1.25rem;
        margin: 1.5rem auto 3rem auto;
    }
    .row {
        flex-direction: column;
        gap: 1rem;
    }
    .section-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .section-header-row .btn {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    .table-container {
        border-radius: var(--radius-md);
    }
    th, td {
        padding: 1rem 0.75rem;
    }
    .auth-card {
        padding: 2.5rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .savings-balance-card {
        padding: 1.5rem;
        flex-direction: column;
        text-align: center;
        gap: 1.25rem;
    }
    .savings-balance-info h2 {
        font-size: 2.1rem;
    }
    .modal-footer {
        flex-direction: column;
    }
    .modal-footer .btn {
        width: 100%;
    }
    .auth-logo {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
    }

    .logo {
        font-size: 1.2rem;
    }
}

/* ==================== LOGIN / AUTHENTICATION ==================== */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 4rem);
    padding: 2rem;
}
.auth-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 440px;
    animation: fadeIn 0.5s ease-out;
}
.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}
.auth-logo {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
    font-size: 2rem;
    margin-bottom: 1.5rem;
}
.auth-header h2 {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}
.auth-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}
.auth-form .input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}
.btn-auth {
    width: 100%;
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 600;
    font-size: 1rem;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.btn-auth:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    background: var(--success);
}
.auth-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.auth-footer a:hover {
    text-decoration: underline;
}
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
