/* ==========================================================================
   CONTA VAN LUIS - ESTILOS VISUALES (PWA MULTIMONEDA & BI)
   Diseño: Apple Dark Minimalist (OLED Negro, Tipografía San Francisco)
   ========================================================================== */

:root {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --card-hover: #262628;
    --card-elevated: #242426;
    --primary: #c93d59;
    --primary-light: rgba(201, 61, 89, 0.15);
    --primary-glow: rgba(201, 61, 89, 0.35);
    --expense: #e74c3c;
    --expense-bg: rgba(231, 76, 60, 0.12);
    --income: #2ecc71;
    --income-bg: rgba(46, 204, 113, 0.12);
    --transf: #007aff;
    --transf-bg: rgba(0, 122, 255, 0.12);
    --warning: #f39c12;
    --text-main: #f5f5f7;
    --text-muted: #8e8e93;
    --border: #2c2c2e;
    --border-light: #38383a;
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-stack);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-top: calc(85px + var(--safe-top));
    padding-bottom: calc(45px + var(--safe-bottom));
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   SEGURIDAD, ENLACE DE BÓVEDA Y ACCESO BIOMÉTRICO (FACE ID / HUELLA / CLAVE)
   ========================================================================== */
#setup-vault-screen, #lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

#lock-screen.unlocking {
    opacity: 0;
    transform: scale(1.04);
    pointer-events: none;
}

.lock-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--card-bg), #2c2c2e);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    margin-bottom: 16px;
    box-shadow: 0 8px 28px rgba(201, 61, 89, 0.25);
}

.lock-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
    text-align: center;
}

.lock-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    text-align: center;
    max-width: 320px;
    line-height: 1.4;
}

.auth-form-container {
    width: 100%;
    max-width: 330px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-input-wrapper {
    position: relative;
    width: 100%;
}

.auth-input-field {
    width: 100%;
    padding: 14px 46px 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: #ffffff;
    font-size: 1.05rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
}

.auth-input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}

.auth-eye-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-eye-btn:hover {
    color: var(--text-main);
}

.auth-btn-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 18px var(--primary-glow);
    transition: transform 0.15s, background 0.15s, opacity 0.2s;
}

.auth-btn-submit:hover {
    background: #e04a6b;
}

.auth-btn-submit:active {
    transform: scale(0.98);
}

.auth-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-error-banner {
    display: none;
    color: #ff453a;
    font-size: 0.85rem;
    text-align: center;
    padding: 10px 14px;
    background: rgba(255, 69, 58, 0.12);
    border-radius: 10px;
    border: 1px solid rgba(255, 69, 58, 0.35);
    line-height: 1.35;
    animation: shake 0.3s ease-in-out;
}

.auth-vault-link-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 20px;
    transition: color 0.2s;
}

.auth-vault-link-btn:hover {
    color: var(--primary);
}

.btn-danger-outline {
    background: rgba(255, 69, 58, 0.08);
    border: 1px solid rgba(255, 69, 58, 0.5);
    color: #ff453a;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, border-color 0.2s;
}

.btn-danger-outline:hover {
    background: rgba(255, 69, 58, 0.18);
    border-color: #ff453a;
}

.btn-danger-outline:active {
    transform: scale(0.98);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* ==========================================================================
   CABECERA FIJA Y NAVEGACIÓN SUPERIOR (STICKY TOP BAR)
   ========================================================================== */
.fixed-header-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(28, 28, 30, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    padding-top: var(--safe-top);
}

.top-bar-rates {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    font-size: 0.72rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: #141416;
}

.rate-ticker-items {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.rate-ticker-items::-webkit-scrollbar {
    display: none;
}

.rate-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-main);
    background: #242426;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.rate-item .val {
    color: var(--income);
    font-weight: 700;
}

.rate-refresh-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rate-refresh-btn:hover {
    color: var(--text-main);
}

.top-nav {
    display: flex;
    overflow-x: auto;
    padding: 0 8px;
    white-space: nowrap;
    scrollbar-width: none;
}

.top-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    flex: 0 0 auto;
    padding: 12px 14px;
    border: none;
    background: transparent;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

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

/* ==========================================================================
   CONTENEDOR DE MÓDULOS
   ========================================================================== */
.main-wrapper {
    max-width: 860px;
    margin: 0 auto;
    padding: 14px;
    transition: max-width 0.25s ease;
}

/* Expansión a pantalla completa en modo Dashboard */
body:has(#mod-analisis.active) .main-wrapper,
.main-wrapper:has(#mod-analisis.active) {
    max-width: 1400px;
    width: 96%;
}

#mod-analisis {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.module {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.module.active {
    display: block;
}

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

.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: -8px;
    margin-bottom: 14px;
}

/* ==========================================================================
   FORMULARIOS, INPUTS Y SELECTORES
   ========================================================================== */
label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem; /* iOS no auto-zoom */
    background: #242426;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="date"], input[type="month"], input[type="time"] {
    color-scheme: dark;
}

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

.type-toggle, .sub-tabs {
    display: flex;
    background: #242426;
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

.type-toggle button, .sub-tabs button {
    flex: 1;
    padding: 10px 4px;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.type-toggle button.active[data-type="gasto"] {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.type-toggle button.active[data-type="ingreso"] {
    background: var(--income);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.type-toggle button.active[data-type="transferencia"] {
    background: var(--transf);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.sub-tabs button.active {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.rate-chips {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.rate-chip {
    flex: 1;
    min-width: 70px;
    padding: 8px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #242426;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.rate-chip.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.btn-primary, .btn-save {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--primary-glow);
    transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:active, .btn-save:active {
    transform: scale(0.98);
}

.btn-sec {
    background: #2c2c2e;
    color: var(--text-main);
    box-shadow: none;
    margin-top: 10px;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid var(--border);
}

.btn-sec:hover {
    background: #38383a;
}

.btn-danger {
    background: var(--expense);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* ==========================================================================
   ALERTA DE COMISION PREDICTIVA & DIFERENCIAL
   ========================================================================== */
.commission-preview {
    margin-top: 8px;
    padding: 9px 12px;
    background: #242426;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--warning);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.commission-preview input {
    width: 85px;
    padding: 5px 8px;
    font-size: 0.85rem;
    margin-left: 8px;
    text-align: right;
}

.arbitrage-card {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.12), rgba(0, 122, 255, 0.08));
    border: 1px solid rgba(46, 204, 113, 0.35);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    margin-bottom: 14px;
}

.arbitrage-card h4 {
    font-size: 0.82rem;
    color: var(--income);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.arbitrage-card .monto {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--income);
}

.arbitrage-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================================================
   MODULO BANCOS (CONCILIACIÓN Y PATRIMONIO CONSOLIDADO OLED)
   ========================================================================== */
.total-patrimonio-card {
    background: linear-gradient(145deg, #18181b 0%, #121215 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 22px 20px;
    margin-bottom: 16px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.total-patrimonio-card .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.total-patrimonio-card .val-main {
    font-size: 2.3rem;
    font-weight: 800;
    color: #ffffff;
    margin: 8px 0 4px;
    letter-spacing: -0.5px;
}

.total-patrimonio-card .val-sec {
    font-size: 0.88rem;
    color: #a1a1aa;
    margin-bottom: 12px;
}

/* Grilla de Desglose Consolidado en Tarjeta de Patrimonio */
.patrimonio-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.patrimonio-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}

.patrimonio-pill .p-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.patrimonio-pill .p-val {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patrimonio-pill.item-total .p-val { color: #f4f4f5; }
.patrimonio-pill.item-retenido .p-val { color: #fbbf24; }
.patrimonio-pill.item-libre .p-val { color: #34d399; }

/* Tarjetas individuales de cuentas bancarias */
.bank-account-card {
    background: rgba(26, 26, 30, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.bank-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.bank-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.bank-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.bank-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-delete-bank {
    color: var(--expense);
}

.bank-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

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

.bank-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bank-meta h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.bank-meta p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bank-right {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: right;
}

.bank-balance-box .primary-val {
    font-size: 1.05rem;
    font-weight: 700;
}

.bank-balance-box .secondary-val {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* iOS Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #38383a;
    transition: .25s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--income);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* ==========================================================================
   MODULO HISTORIAL (ACORDEÓN TOSHL Y CATEGORÍAS)
   ========================================================================== */
.history-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.sum-card-toshl {
    background: #242426;
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    margin-bottom: 14px;
    border: 1px solid var(--border);
}

.sum-card-toshl .title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.sum-card-toshl .amount {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 4px;
}

.day-group-accordion {
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.day-group-header {
    background: #262628;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.day-group-header:hover {
    background: #303034;
}

.day-group-header .day-total {
    font-weight: 700;
}

.day-group-header .day-total.negative {
    color: var(--primary);
}

.day-group-header .day-total.positive {
    color: var(--income);
}

.day-group-body {
    background: var(--card-bg);
    display: block;
}

.tx-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.tx-row:last-child {
    border-bottom: none;
}

.tx-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.tx-info h5 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.tx-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.tx-amount {
    text-align: right;
    font-size: 0.95rem;
    font-weight: 700;
}

.tx-amount.gasto { color: var(--primary); }
.tx-amount.ingreso { color: var(--income); }
.tx-amount.transferencia { color: var(--transf); font-weight: 500; }
.tx-amount.diferencial { color: var(--income); }

.tx-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.tx-actions button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
}

.tx-actions button:hover {
    color: var(--text-main);
}

/* ==========================================================================
   MODULO PRESUPUESTO (BARRAS DE PROGRESO CON SEMÁFORO)
   ========================================================================== */
.budget-card-item {
    background: #242426;
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.budget-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.budget-progress-track {
    background: #18181a;
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.budget-progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.budget-progress-bar.green { background: var(--income); }
.budget-progress-bar.yellow { background: var(--warning); }
.budget-progress-bar.red { background: var(--expense); }

.budget-numbers {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ==========================================================================
   DASHBOARD POWER BI SLICERS & GRID
   ========================================================================== */
.bi-slicers-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    background: #242426;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 14px;
}

.bi-slicer select {
    padding: 7px 10px;
    font-size: 0.85rem;
    background: #1c1c1e;
}

.bi-views-filter-bar {
    display: flex;
    overflow-x: auto;
    background: #1e1e20;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
    scrollbar-width: none;
}

.bi-views-filter-bar::-webkit-scrollbar {
    display: none;
}

.bi-views-filter-bar button {
    flex: 1;
    min-width: 140px;
    padding: 9px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.bi-views-filter-bar button.active {
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.bi-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 16px;
    width: 100%;
}

@media (max-width: 500px) {
    .bi-kpi-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1100px) {
    .bi-kpi-grid .span-2 {
        grid-column: span 2;
    }
}

.chart-container-box {
    position: relative;
    width: 100%;
    height: 250px;
    max-height: 260px;
    margin-top: 10px;
}

/* Mini tarjetas KPI internas para ingresos y tasas */
.kpi-mini-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.kpi-mini-card {
    background: #242426;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: center;
}

.kpi-mini-card .kpi-mini-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.kpi-mini-card .kpi-mini-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-mini-card .kpi-mini-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Checkboxes de encendido/apagado de monedas en gráfico cambiario */
.kpi5-currency-toggles {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
    flex-wrap: wrap;
}

.kpi5-currency-toggles label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    cursor: pointer;
    font-size: 0.78rem;
    text-transform: none;
}

.kpi5-currency-toggles input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    margin: 0;
}

/* ==========================================================================
   MODALES DIALOG (CRUD, CONCILIACIÓN, EDICIÓN)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100005;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN / REPORTE PDF
   ========================================================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
    }
    .fixed-header-container, #setup-vault-screen, #lock-screen, .type-toggle, .btn-save, .rate-chips, .modal-overlay {
        display: none !important;
    }
    .card {
        border: 1px solid #cccccc !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    .tx-row {
        border-bottom: 1px solid #eeeeee !important;
    }
}


/* ==========================================================================
   OVERLAY DE CARGA ANIMADO (LAZY LOADING HISTÓRICO / TIME TRAVEL)
   ========================================================================== */
.lazy-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lazy-loading-card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 28px 24px;
    max-width: 440px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.9);
}

.lazy-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(201, 61, 89, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: lazySpin 0.9s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    margin: 0 auto 16px auto;
}

@keyframes lazySpin {
    to { transform: rotate(360deg); }
}

.lazy-loading-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.lazy-loading-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* ==========================================================================
   PANEL DE DIVISIÓN DINÁMICA DE GASTO (SPLIT)
   ========================================================================== */
.split-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 14px;
    margin-bottom: 14px;
}

.split-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.split-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: block;
}

.split-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.split-mode-toggle button {
    background: var(--card-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
}

.split-mode-toggle button.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.split-balance-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid var(--expense);
    font-size: 0.8rem;
    font-weight: 600;
}

.split-balance-bar.balanced {
    background: rgba(46, 204, 113, 0.12);
    border-color: var(--income);
    color: var(--income);
}

.split-line-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 8px;
}

.split-line-item .split-line-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.split-line-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.split-line-del {
    background: transparent;
    border: none;
    color: var(--expense);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

/* ==========================================================================
   MÓDULO DE METAS Y APARTADOS ("SOBRES")
   ========================================================================== */
.metas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.meta-card {
    background: var(--card-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.meta-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.meta-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.meta-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

.meta-bank-tag {
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.meta-progress-box {
    margin: 10px 0;
}

.meta-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.meta-progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.meta-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--income), #27ae60);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.meta-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.meta-actions button {
    flex: 1;
}

/* ==========================================================================
   DESGLOSE TRIPARTITO DE BANCOS (TOTAL, RETENIDO, LIBRE)
   ========================================================================== */
.bank-breakdown-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.bank-breakdown-item {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
}

.bank-breakdown-item .bb-label {
    font-size: 0.66rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.bank-breakdown-item .bb-val {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bb-total { color: #f4f4f5; }
.bb-retenido { color: #fbbf24; }
.bb-libre { color: #34d399; }

@media (max-width: 520px) {
    .patrimonio-summary-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .bank-breakdown-box {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .bank-breakdown-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px;
    }
    .bank-breakdown-item .bb-label {
        margin-bottom: 0;
    }
}

/* Badges especiales en Historial */
.badge-split {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
    border: 1px solid rgba(155, 89, 182, 0.4);
    margin-left: 6px;
    vertical-align: middle;
}
