/* ========================================================
   VARIABLES Y RESET
   ======================================================== */
:root {
    --primary:      #2ecc71;
    --primary-dark: #27ae60;
    --background:   #f5f7fa;
    --card-bg:      #ffffff;
    --bg-card:      #ffffff;
    --text:         #2c3e50;
    --text-light:   #7f8c8d;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 5vh 20px 20px;
    overflow-x: hidden;
    width: 100%;
}

/* ========================================================
   CUSTOM SELECT (dropdown bonito para todos los <select>)
   ======================================================== */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}
.custom-select-wrapper select {
    display: none !important;
}
.custom-select-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    padding: 0 40px 0 14px;
    border-radius: 12px;
    border: 1.5px solid rgba(128,128,128,0.2);
    background: var(--bg-card, #fff);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}
.custom-select-trigger:hover,
.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,204,113,0.12);
}
.custom-select-trigger .cs-icon {
    color: var(--primary);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.custom-select-trigger .cs-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-select-trigger .cs-arrow {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    color: var(--text-light);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    pointer-events: none;
}
.custom-select-wrapper.open .cs-arrow {
    transform: translateY(-50%) rotate(180deg);
}
.custom-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card, #fff);
    border: 1.5px solid rgba(46,204,113,0.25);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 9999;
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
    animation: csDropIn 0.15s ease;
}
.custom-select-wrapper.open .custom-select-dropdown {
    display: block;
}
@keyframes csDropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.custom-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid rgba(128,128,128,0.07);
}
.custom-select-option:last-child { border-bottom: none; }
.custom-select-option:hover {
    background: rgba(46,204,113,0.08);
    color: var(--primary);
}
.custom-select-option.selected {
    background: rgba(46,204,113,0.12);
    color: var(--primary);
    font-weight: 700;
}
.custom-select-option .cs-opt-badge {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    background: rgba(46,204,113,0.15);
    color: var(--primary);
    white-space: nowrap;
}
.custom-select-option .cs-opt-badge.cerrado {
    background: rgba(128,128,128,0.1);
    color: var(--text-light);
}
/* scrollbar del dropdown */
.custom-select-dropdown::-webkit-scrollbar { width: 4px; }
.custom-select-dropdown::-webkit-scrollbar-track { background: transparent; }
.custom-select-dropdown::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.2); border-radius: 4px; }

/* dark mode */
body.dark-mode .custom-select-trigger { background: var(--bg-card); }
body.dark-mode .custom-select-dropdown { background: var(--bg-card); border-color: rgba(46,204,113,0.2); box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
body.dark-mode .custom-select-option:hover { background: rgba(46,204,113,0.1); }

/* ========================================================
   LOGIN
   ======================================================== */
.login-container {
    background-color: var(--card-bg);
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 400px;
}

.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { color: var(--primary); font-size: 2.2rem; margin-bottom: 8px; }
.login-header p  { color: var(--text-light); font-size: 0.95rem; }

.login-footer { text-align: center; margin-top: 25px; font-size: 0.9rem; }
.login-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.login-footer a:hover { text-decoration: underline; }
.login-footer p { margin-top: 10px; color: var(--text-light); }

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

/* Contenedor vertical normal (label arriba, input abajo) */
.input-group {
    margin-bottom: 20px;
    position: relative;
    width: 100%;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Fila horizontal para el input de descripción + botón IA */
.input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
    position: relative;
    margin-bottom: 20px;
}

.input-group input,
.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.input-group input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,204,113,0.15);
}

.form-control {
    padding: 10px;
    font-size: 14px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
}

.select-modern {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}
.checkbox-group input { width: 18px; height: 18px; accent-color: var(--primary); }

.monto-input  { transition: background-color 0.3s ease; }
.bg-gasto     { background-color: #fdeaea !important; border-color: #e74c3c !important; }
.bg-ingreso   { background-color: #e8f8f0 !important; border-color: #27ae60 !important; }

/* Input de descripción dentro del .input-row */
#descGasto {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
    min-width: 0;
}
#descGasto:focus { border-color: #8e44ad; }

/* ========================================================
   BOTONES
   ======================================================== */
.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}
.btn-primary:hover { background-color: var(--primary-dark); }

.btn-secondary {
    background-color: #bdc3c7;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}
.btn-secondary:hover { background-color: #aeb6bc; }

.btn-small {
    background: #edf2f7;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-small.primary { background: var(--primary); color: white; }

.btn-icon  { background: none; border: none; font-size: 1.2rem; color: #e74c3c; cursor: pointer; }

.btn-edit {
    color: #3498db;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    margin-right: 12px;
    transition: transform 0.2s, color 0.2s;
}
.btn-edit:hover { color: #2980b9; transform: scale(1.1); }

.btn-delete {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.95rem;
    transition: color 0.2s;
}
.btn-delete:hover { color: #e74c3c; }

.btn-unificado {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}
.btn-save        { background-color: #27ae60; color: white; }
.btn-save:hover  { background-color: #219150; }
.btn-cancel      { background-color: #e0e0e0; color: #444; }
.btn-cancel:hover{ background-color: #d0d0d0; }

.btn-ia {
    background: linear-gradient(135deg, #8e44ad, #3498db);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(142,68,173,0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.btn-ia i { font-size: 1.1rem; }
.btn-ia:hover  { transform: translateY(-2px) scale(1.05); box-shadow: 0 4px 10px rgba(142,68,173,0.5); }
.btn-ia:active { transform: scale(0.95); }

.btn-icon-small {
    background: rgba(46,204,113,0.2);
    color: #1b5e20;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}
.btn-icon-small:hover { background: #2ecc71; color: white; transform: scale(1.1); }

.action-icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.info-icon         { color: #3498db; }
.info-icon:hover   { color: #2980b9; background-color: rgba(52,152,219,0.1); }
.logout-icon       { color: var(--text-light); }
.logout-icon:hover { color: #e74c3c; background-color: rgba(231,76,60,0.1); }

#btnRefreshIA {
    background: #3b82f6 !important;
    color: #ffffff !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-shadow: 0 4px 6px rgba(59,130,246,0.3) !important;
    transition: all 0.3s ease !important;
}
#btnRefreshIA:hover {
    background: #2563eb !important;
    box-shadow: 0 6px 12px rgba(59,130,246,0.4) !important;
    transform: translateY(-2px) !important;
}

/* ========================================================
   TOASTS
   ======================================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
}

.toast {
    background: #333;
    color: white;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 320px;
    transform: translateY(100px);
    opacity: 0;
    animation: slideIn 0.3s forwards, fadeOut 0.3s 3.7s forwards;
}
.toast.success { background-color: var(--primary); }
.toast.error   { background-color: #e74c3c; }
.toast.info    { background-color: #3498db; }

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

/* ========================================================
   DASHBOARD
   ======================================================== */
.dashboard-container {
    width: 95%;
    max-width: 600px;
    background: var(--card-bg);
    min-height: 90vh;
    border-radius: 24px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-x: hidden;
}

.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf2f7;
}
.dashboard-header h1 { font-size: 1.4rem; color: var(--text); }

.badge-periodo {
    background: #e8f8f0;
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85rem;
}

.header-divisor {
    width: 1px;
    height: 24px;
    background-color: #e2e8f0;
    margin: 0 5px;
    flex-shrink: 0;
}

.select-historico {
    border: none;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
}
.select-historico:hover { background: #d4f0e2; }

/* ========================================================
   RESUMEN FINANCIERO
   ======================================================== */
.resumen-financiero-box { display: flex; flex-direction: column; gap: 12px; }

.indicador-destacado.sueldo-base {
    background: #e1f7ec;
    border: 2px solid var(--primary);
    padding: 20px;
    border-radius: 18px;
    text-align: center;
}
.indicador-destacado.sueldo-base p  { color: var(--primary-dark); font-weight: bold; font-size: 0.95rem; margin-bottom: 5px; }
.indicador-destacado.sueldo-base h3 { font-size: 1.8rem; color: #1b5e20; font-weight: 800; transition: filter 0.3s ease; }

.sueldo-header { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 5px; }
.leyenda-aumento { display: block; margin-top: 10px; font-size: 0.8rem; color: #27ae60; font-weight: 600; }

.vista-previa-aumento {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
    margin: 15px 0;
    color: var(--text-light);
}
.vista-previa-aumento strong { color: var(--primary); font-size: 1.3rem; display: block; margin-top: 5px; }

.fila-mini-indicadores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.mini-card { padding: 15px; border-radius: 16px; text-align: center; border: 1px solid #e2e8f0; }
.mini-card p    { font-size: 0.8rem; color: var(--text-light); margin-bottom: 4px; }
.mini-card span { font-size: 1.1rem; font-weight: 700; transition: filter 0.3s ease; }

.mini-card.gasto {
    background-color: #fff5f5;
    border: 1px solid #ffe3e3;
    box-shadow: 0 4px 10px rgba(224,92,92,0.08);
}
.mini-card.gasto p                 { color: #a57d7d; }
.mini-card.gasto span,
.mini-card.gasto button            { color: #e05c5c; }

.mini-card.disponible {
    background-color: #f0fdf4;
    border: 1px solid #dcfce7;
    box-shadow: 0 4px 10px rgba(46,204,113,0.08);
}
.mini-card.disponible p            { color: #648a70; }
.mini-card.disponible span,
.mini-card.disponible button       { color: #27ae60; }

/* ========================================================
   TABS
   ======================================================== */
.tabs-container {
    display: flex;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs-container::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 1;
    min-width: max-content;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-weight: 700;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 0.9rem;
}
.tab-btn.active { background: white; color: var(--primary); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }

.tab-content         { display: none !important; min-height: 320px; }
.tab-content.active  { display: block !important; animation: fadeIn 0.3s; }

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

/* ========================================================
   MOVIMIENTOS
   ======================================================== */
.movimientos-section { display: flex; flex-direction: column; gap: 15px; }
.section-title       { display: flex; justify-content: space-between; align-items: center; }
.lista-movimientos   { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }

.movimiento-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 14px 16px;
    border-radius: 14px;
    gap: 10px;
    transition: transform 0.2s;
}
.movimiento-item:hover { transform: translateY(-2px); }

.movimiento-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.movimiento-info h4 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 2px;
}
.movimiento-info small { color: var(--text-light); font-size: 0.8rem; }

.movimiento-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.movimiento-icon.gasto   { background: #fde8e8; color: #e74c3c; }
.movimiento-icon.ingreso { background: #e1f7ec; color: #2ecc71; }

.movimiento-acciones { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }

.movimiento-monto { font-weight: 700; font-size: 1rem; white-space: nowrap; transition: filter 0.3s ease; }
.movimiento-monto.gasto   { color: #e74c3c; }
.movimiento-monto.ingreso { color: #2ecc71; }

.text-vacio { text-align: center; color: var(--text-light); font-size: 0.9rem; margin-top: 20px; }

/* ==========================================
   HISTORIAL - CHIPS DE FILTRO
   ========================================== */
#tab-historial { min-height: 60vh; }
#tab-graficos  { min-height: 60vh; }

/* Prevenir salto cuando el custom dropdown se abre */
.custom-select-wrapper { contain: layout; }
.custom-select-dropdown { position: absolute; }

/* ==========================================
   HISTORIAL - CHIPS DE FILTRO
   ========================================== */
.historial-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid rgba(128,128,128,0.2);
    background: transparent;
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
}
.historial-chip:hover { border-color: var(--primary); color: var(--primary); }
.historial-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.historial-chip.ingreso:hover { border-color: #2ecc71; color: #2ecc71; }
.historial-chip.ingreso.active { background: #2ecc71; border-color: #2ecc71; color: #fff; }
.historial-chip.gasto:hover { border-color: #e74c3c; color: #e74c3c; }
.historial-chip.gasto.active { background: #e74c3c; border-color: #e74c3c; color: #fff; }
.historial-chip.fijo:hover { border-color: #3498db; color: #3498db; }
.historial-chip.fijo.active { background: #3498db; border-color: #3498db; color: #fff; }

/* ========================================================
   MODALES
   ======================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    padding: 20px;
    box-sizing: border-box;
}
.modal.open { display: flex; }

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}
.modal-overlay.open .modal-content { transform: scale(1); }

.modal-icon { font-size: 3rem; color: var(--primary); margin-bottom: 15px; }
.modal-content h2 { color: var(--text); font-size: 1.4rem; margin-bottom: 10px; }
.modal-content p  { color: var(--text-light); font-size: 0.95rem; line-height: 1.4; }

.modal-sugerencia { margin-top: 10px; background: #f7fafc; padding: 12px; border-radius: 12px; border-left: 4px solid var(--primary); }
.modal-actions            { display: flex; flex-direction: column; gap: 10px; margin-top: 25px; }
.modal-actions-container  { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions-horizontal { display: flex; gap: 10px; margin-top: 20px; }

.text-left   { text-align: left   !important; }
.text-center { text-align: center !important; }

.modal-overlay-custom {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 998;
    backdrop-filter: blur(3px);
}

/* ========================================================
   AUTOCOMPLETE
   ======================================================== */
.custom-datalist,
#sugerencias-custom {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #a0aec0;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    margin-top: 5px;
    box-shadow: 0 12px 25px rgba(0,0,0,0.2);
}

.custom-option {
    padding: 10px 15px;
    cursor: pointer;
    color: #2c3e50;
    font-size: 0.95rem;
    border-bottom: 1px solid #f1f2f6;
    transition: background 0.2s, color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.custom-option:last-child { border-bottom: none; }
.custom-option:hover      { background-color: #f8f9fa; color: #27ae60; font-weight: bold; }

/* ========================================================
   AVATAR Y PERFIL
   ======================================================== */
.user-profile-box { display: flex; align-items: center; gap: 15px; }

.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(52,152,219,0.3);
    overflow: hidden;
    user-select: none;
    flex-shrink: 0;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }

@keyframes aparecerTarjeta {
    from { opacity: 0; transform: translateY(-15px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0)     scale(1);    }
}
.tarjeta-animada { animation: aparecerTarjeta 0.25s cubic-bezier(0.175,0.885,0.32,1.275) forwards; transform-origin: top right; }
#btnCerrarSesion { transition: all 0.2s ease; }
#btnCerrarSesion:hover { background: #e74c3c !important; color: #ffffff !important; }

/* ========================================================
   METAS
   ======================================================== */
.meta-card { background: var(--card-bg); border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; margin-bottom: 12px; transition: 0.3s; }

.meta-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.meta-titulo { font-weight: 700; color: var(--text); font-size: 1.1rem; word-break: break-word; }
.meta-porcentaje { font-weight: 700; color: var(--primary); background: rgba(46,204,113,0.1); padding: 4px 8px; border-radius: 8px; white-space: nowrap; flex-shrink: 0; }

.progress-bar-bg   { width: 100%; height: 14px; background-color: #e2e8f0; border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.progress-bar-fill { height: 100%; background-color: var(--primary); border-radius: 10px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }

.meta-montos { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-light); font-weight: 500; flex-wrap: wrap; gap: 4px; }

/* ========================================================
   SWITCHES
   ======================================================== */
.ios-switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.ios-switch input { opacity: 0; width: 0; height: 0; }
.ios-switch .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 34px; }
.ios-switch .slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.ios-switch input:checked + .slider { background-color: var(--primary); }
.ios-switch input:checked + .slider:before { transform: translateX(22px); }

.admin-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.admin-switch input { opacity: 0; width: 0; height: 0; }
.admin-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .3s; border-radius: 22px; }
.admin-slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.admin-switch input:checked + .admin-slider { background-color: #2ecc71; }
.admin-switch input:checked + .admin-slider:before { transform: translateX(18px); }

.btn-theme { background: none; border: none; font-size: 1.3rem; color: var(--text-light); cursor: pointer; transition: transform 0.3s, color 0.3s; }
.btn-theme:hover { transform: scale(1.1); }

/* ========================================================
   ADMIN PANEL
   ======================================================== */
.admin-tabs-container { display: flex; gap: 10px; margin-bottom: 25px; background: #f8fafc; padding: 6px; border-radius: 12px; border: 1px solid rgba(128,128,128,0.2); }
.sub-tab-btn { flex: 1; padding: 10px; border: none; border-radius: 8px; background: transparent; font-weight: 600; color: var(--text-light); cursor: pointer; transition: all 0.3s ease; font-size: 0.85rem; white-space: nowrap; }
.sub-tab-btn.active { background: white; color: var(--primary); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

.admin-ia-card { text-align: center; padding: 40px 20px; background: #f8fafc; border: 1px dashed rgba(128,128,128,0.3); border-radius: 12px; }
.admin-ia-card h3 { margin: 0 0 10px 0; color: var(--text); }
.admin-ia-card p  { color: var(--text-light); font-size: 0.95rem; margin-bottom: 25px; max-width: 500px; margin-left: auto; margin-right: auto; }

#listaUsuarios { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

/* ========================================================
   EFECTOS VARIOS
   ======================================================== */
button[id^="btnToggle"] i,
button[onclick="toggleMonto(this)"] i { transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1); }
button[id^="btnToggle"]:hover i,
button[onclick="toggleMonto(this)"]:hover i { transform: scale(1.15); color: var(--primary); }

.header-actions { display: flex; align-items: center; gap: 15px; }

/* ========================================================
   MODO OSCURO
   ======================================================== */
body.dark-mode {
    --background: #0f1117;
    --card-bg:    #1a1d27;
    --bg-card:    #1a1d27;
    --text:       #e8eaf0;
    --text-light: #8b92a8;
}

/* Fondo general */
body.dark-mode { background-color: var(--background); color: var(--text); }

/* Todos los h1/h2/h3/h4/h5/p/span heredan la variable */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode p:not(.toast *):not(.movimiento-monto) {
    color: var(--text);
}

/* Contenedor principal */
body.dark-mode .dashboard-container {
    background-color: #13161f;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

/* Header */
body.dark-mode .dashboard-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

/* Resumen financiero */
body.dark-mode .resumen-financiero-box {
    background: transparent;
}
body.dark-mode .indicador-destacado.sueldo-base {
    background: linear-gradient(135deg, #0d2318 0%, #122b1e 100%);
    border: 1px solid rgba(46,204,113,0.2);
}
body.dark-mode .indicador-destacado.sueldo-base h3 { color: #2ecc71; }
body.dark-mode .indicador-destacado.sueldo-base p,
body.dark-mode .leyenda-aumento { color: #5a8a6a; }

body.dark-mode .mini-card {
    border-color: rgba(255,255,255,0.07) !important;
}
body.dark-mode .mini-card.gasto {
    background: linear-gradient(135deg,rgba(231,76,60,0.1),rgba(192,57,43,0.06)) !important;
    border-color: rgba(231,76,60,0.2) !important;
}
body.dark-mode .mini-card.gasto p { color: #c08080 !important; }
body.dark-mode .mini-card.gasto span,
body.dark-mode .mini-card.gasto button { color: #e57373 !important; }

body.dark-mode .mini-card.disponible {
    background: linear-gradient(135deg,rgba(46,204,113,0.1),rgba(39,174,96,0.06)) !important;
    border-color: rgba(46,204,113,0.2) !important;
}
body.dark-mode .mini-card.disponible p { color: #6aaa82 !important; }
body.dark-mode .mini-card.disponible span,
body.dark-mode .mini-card.disponible button { color: #4bd886 !important; }

/* Tabs */
body.dark-mode .tabs-container {
    background: #13161f;
    border-color: rgba(255,255,255,0.07);
}
body.dark-mode .tab-btn {
    color: var(--text-light);
}
body.dark-mode .tab-btn.active {
    background: #1a1d27;
    color: var(--primary);
    border-color: rgba(46,204,113,0.3);
}

/* Movimientos */
body.dark-mode .movimiento-item {
    background: #1a1d27;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
body.dark-mode .movimiento-item:hover {
    background: #1f2235;
}
body.dark-mode .movimiento-item h4 {
    color: var(--text);
}
body.dark-mode .movimiento-info small {
    color: var(--text-light);
}
body.dark-mode .btn-edit {
    background: rgba(52,152,219,0.15) !important;
    color: #5dade2 !important;
    border-color: rgba(52,152,219,0.2) !important;
}
body.dark-mode .btn-delete {
    background: rgba(231,76,60,0.12) !important;
    color: #e57373 !important;
    border-color: rgba(231,76,60,0.2) !important;
}
body.dark-mode .btn-icon-small {
    background: rgba(46,204,113,0.1) !important;
    color: #2ecc71 !important;
    border-color: rgba(46,204,113,0.2) !important;
}

/* Inputs y selects */
body.dark-mode .form-control,
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode textarea {
    background: #22263a !important;
    color: var(--text) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
body.dark-mode .form-control:focus,
body.dark-mode input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(46,204,113,0.12) !important;
}
body.dark-mode .bg-gasto   { background: #2a1818 !important; border-color: rgba(231,76,60,0.4) !important; color: #e8eaf0 !important; }
body.dark-mode .bg-ingreso { background: #162312 !important; border-color: rgba(46,204,113,0.4) !important; color: #e8eaf0 !important; }

/* Custom select dropdown */
body.dark-mode .custom-select-trigger {
    background: #22263a;
    border-color: rgba(255,255,255,0.1);
    color: var(--text);
}
body.dark-mode .custom-select-trigger:hover,
body.dark-mode .custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,204,113,0.12);
}
body.dark-mode .custom-select-dropdown {
    background: #22263a;
    border-color: rgba(46,204,113,0.2);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
body.dark-mode .custom-select-option {
    color: var(--text);
    border-bottom-color: rgba(255,255,255,0.05);
}
body.dark-mode .custom-select-option:hover {
    background: rgba(46,204,113,0.1);
    color: var(--primary);
}
body.dark-mode .custom-select-option.selected {
    background: rgba(46,204,113,0.15);
    color: var(--primary);
}

/* Modales */
body.dark-mode .modal-overlay { background: rgba(0,0,0,0.75); }
body.dark-mode .modal-content {
    background: #1a1d27;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}
body.dark-mode .modal-content h2,
body.dark-mode .modal-content h3 { color: var(--text); }
body.dark-mode .modal-content label { color: var(--text-light); }

/* Autocompletado IA */
body.dark-mode #sugerencias-custom,
body.dark-mode .custom-datalist {
    background: #22263a;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
body.dark-mode .custom-option {
    color: var(--text);
    border-bottom-color: rgba(255,255,255,0.05);
}
body.dark-mode .custom-option:hover { background: rgba(46,204,113,0.1); }

/* Metas */
body.dark-mode .meta-card {
    background: #1a1d27;
    border-color: rgba(255,255,255,0.07);
}
body.dark-mode .progress-bar-bg { background: rgba(255,255,255,0.08); }

/* Switches */
body.dark-mode .ios-switch .slider { background: #3a3f55; }
body.dark-mode .ios-switch input:checked + .slider { background: var(--primary); }
body.dark-mode .admin-slider { background: #3a3f55; }
body.dark-mode .admin-switch input:checked + .admin-slider { background: var(--primary); }

/* Admin panel */
body.dark-mode .admin-tabs-container {
    background: #13161f;
    border-color: rgba(255,255,255,0.07);
}
body.dark-mode .sub-tab-btn { color: var(--text-light); }
body.dark-mode .sub-tab-btn.active {
    background: #1a1d27;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
body.dark-mode .admin-ia-card {
    background: #1a1d27;
    border-color: rgba(255,255,255,0.08);
}

/* Header misc */
body.dark-mode .header-divisor { background: rgba(255,255,255,0.1); }
body.dark-mode .info-icon   { color: #5dade2; }
body.dark-mode .logout-icon { color: #8b92a8; }
body.dark-mode .logout-icon:hover { color: #e57373; }

/* Historial chips en dark */
body.dark-mode .historial-chip {
    border-color: rgba(255,255,255,0.1);
    color: var(--text-light);
}
body.dark-mode .historial-chip:hover { color: var(--primary); border-color: var(--primary); }

/* Buscador historial */
body.dark-mode #historialBuscador {
    background: #22263a !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: var(--text) !important;
}

/* Cards de gráficos */
body.dark-mode #tab-graficos .movimientos-section > div {
    background: #1a1d27;
    border-color: rgba(255,255,255,0.07);
}

/* Tabla de usuarios admin */
body.dark-mode #listaUsuarios table { color: var(--text); }
body.dark-mode #listaUsuarios tr { border-bottom-color: rgba(255,255,255,0.05) !important; }
body.dark-mode #listaUsuarios tr:hover { background: rgba(255,255,255,0.03); }
body.dark-mode #buscadorUsuarios {
    background: #22263a !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: var(--text) !important;
}

/* Elementos con color hardcodeado que no respetan variables */
body.dark-mode .section-title h3,
body.dark-mode .movimientos-section h3,
body.dark-mode .movimiento-info h4,
body.dark-mode .modal-content h2,
body.dark-mode .modal-content h3,
body.dark-mode .modal-content label,
body.dark-mode .modal-content p,
body.dark-mode .input-group label,
body.dark-mode .checkbox-group {
    color: var(--text) !important;
}

/* Botones cancelar/guardar en dark */
body.dark-mode .btn-cancel {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
body.dark-mode .btn-cancel:hover {
    background: rgba(255,255,255,0.14);
}

/* Vista previa aumento */
body.dark-mode .vista-previa-aumento {
    background: #22263a;
    color: var(--text-light);
}

/* btn-small en dark */
body.dark-mode .btn-small:not(.primary) {
    background: rgba(255,255,255,0.07);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.1);
}
body.dark-mode .btn-small:not(.primary):hover {
    background: rgba(255,255,255,0.12);
}

/* Tarjeta de usuario */
body.dark-mode #tarjetaUsuario {
    background: #1a1d27;
    border-color: rgba(255,255,255,0.08);
}
body.dark-mode #tarjetaUsuario > div:last-child > div:first-child {
    background: #22263a;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 4px 18px rgba(0,0,0,0.3);
}
body.dark-mode #cardNombre { color: var(--text) !important; }
body.dark-mode #cardEmail  { color: var(--text-light) !important; }
body.dark-mode #editNombre,
body.dark-mode #editEmail,
body.dark-mode #editPassword {
    background: #13161f !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: var(--text) !important;
}

/* ========================================================
   RESPONSIVE — 600px
   ======================================================== */
@media (max-width: 600px) {
    body { padding: 10px 10px 20px; }

    .dashboard-container { padding: 16px; border-radius: 16px; width: 100%; gap: 14px; }

    .dashboard-header { gap: 10px; }
    .app-logo h2      { font-size: 1.1rem !important; }
    .header-divisor   { display: none; }

    .indicador-destacado.sueldo-base h3 { font-size: 1.5rem; }
    .fila-mini-indicadores { gap: 8px; }
    .mini-card             { padding: 12px; }
    .mini-card span        { font-size: 0.95rem; }

    .tabs-container { gap: 4px; padding: 4px; }
    .tab-btn        { padding: 8px 10px; font-size: 0.82rem; }

    .movimiento-item    { padding: 10px 12px; gap: 8px; }
    .movimiento-info h4 { font-size: 0.88rem; }
    .movimiento-monto   { font-size: 0.88rem; }
    .movimiento-icon    { width: 30px; height: 30px; font-size: 0.85rem; }

    .btn-ia { width: 38px; height: 38px; min-width: 38px; }

    /* Modales desde abajo */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-overlay .modal-content { border-radius: 20px 20px 0 0; max-width: 100%; padding: 24px 16px 32px; }

    .meta-card   { padding: 12px; }
    .meta-titulo { font-size: 1rem; }
    .meta-montos { font-size: 0.78rem; }

    .sub-tab-btn { padding: 8px 6px; font-size: 0.78rem; }

    .toast-container { right: 10px; left: 10px; bottom: 10px; }
    .toast           { width: 100%; max-width: 100%; }

    .login-container { padding: 28px 20px; border-radius: 12px; }
    .login-header h1 { font-size: 1.9rem; }

    #tarjetaUsuario {
        position: fixed    !important;
        top:  50%          !important;
        left: 50%          !important;
        transform: translate(-50%, -50%) !important;
        width: 85%         !important;
        max-width: 320px   !important;
        right: auto        !important;
        margin: 0          !important;
    }
}

/* ========================================================
   RESPONSIVE — 360px
   ======================================================== */
@media (max-width: 360px) {
    .dashboard-container { padding: 10px; }
    .fila-mini-indicadores { grid-template-columns: 1fr; }
    .movimiento-monto   { font-size: 0.82rem; }
    .movimiento-info h4 { font-size: 0.82rem; }
    .tab-btn            { padding: 7px 8px; font-size: 0.76rem; }
    .indicador-destacado.sueldo-base h3 { font-size: 1.3rem; }
}
