:root {
    /* Fondo */
    --fondo: #000000;
    --bg-secundario: #101010;
    --secundario: #080808;

    /* Acento único */
    --azul-electrico: #087CFF;
    --dorado: #087CFF;
    --accent: #087CFF;

    /* Semántica positivo / negativo */
    --verde-ok: #36C77A;
    --positivo: #36C77A;
    --coral: #E94B4B;
    --negativo: #E94B4B;

    --blanco: #FFFFFF;
    --texto-secundario: #9A9A9A;
    --borde: #2A2A2A;
    --sombra: rgba(0, 0, 0, 0.5);

    /* Colores extra solo para la leyenda del calendario financiero */
    --ambar: #F2B84B;
    --violeta: #9A6BFF;
    --teal: #2DD4C7;

    /* Radios */
    --radio-md: 12px;
    --radio-lg: 16px;

    /* Escala de espaciado */
    --sp-1: 8px;
    --sp-2: 16px;
    --sp-3: 24px;
    --sp-4: 32px;

    /* Layout */
    --sidebar-ancho: 240px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--fondo);
    color: var(--blanco);
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
    font-family: 'Poppins', sans-serif;
    margin: 0;
}

button, input, select {
    font-family: 'Inter', sans-serif;
}

.hidden {
    display: none !important;
}

/* ---------- Login ---------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at 50% 0%, var(--bg-secundario), var(--fondo) 70%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(16, 16, 16, 0.7);
    border: 1px solid rgba(8, 124, 255, 0.25);
    border-radius: 20px;
    padding: 36px 28px;
    text-align: center;
    box-shadow: 0 20px 60px var(--sombra);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}

.login-logo h1 {
    font-size: 24px;
}

.login-logo h1 span {
    color: var(--accent);
}

.logo-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.login-sub {
    color: var(--texto-secundario);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.login-form label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.login-form input {
    background: var(--fondo);
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: 10px;
    padding: 14px;
    font-size: 16px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8, 124, 255, 0.18);
}

.login-form button {
    margin-top: 10px;
    background: var(--accent);
    color: var(--blanco);
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.login-form button:hover {
    box-shadow: 0 0 20px rgba(8, 124, 255, 0.35);
}

.login-form button:active {
    transform: scale(0.97);
}

.login-error {
    color: var(--negativo);
    font-size: 13px;
    margin: 0;
}

/* ---------- App shell (sidebar + contenido) ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    display: none;
}

.main-area {
    flex: 1;
    min-width: 0;
}

/* ---------- Layout general ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(16, 16, 16, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--borde);
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-logo h1 {
    font-size: 18px;
}

.topbar-logo h1 span {
    color: var(--accent);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--secundario);
    border: 1px solid var(--borde);
    color: var(--blanco);
    text-decoration: none;
    font-size: 16px;
    transition: border-color 0.15s ease, transform 0.1s ease;
}

.btn-icon:hover {
    border-color: var(--accent);
}

.btn-icon:active {
    transform: scale(0.94);
}

.contenedor {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--sp-2) var(--sp-2) 120px;
}

/* Espaciado consistente entre secciones principales del dashboard */
.filtros-globales,
.resumen-general,
.meta-section,
.movimientos-section,
.ranking-section,
.graficas-section {
    margin-bottom: var(--sp-3);
}

@media (min-width: 640px) {
    .contenedor {
        padding: var(--sp-3) var(--sp-3) 120px;
    }
    .filtros-globales,
    .resumen-general,
    .meta-section,
    .movimientos-section,
    .ranking-section,
    .graficas-section {
        margin-bottom: var(--sp-4);
    }
}

/* ---------- Resumen general (KPIs) ---------- */

.resumen-general {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
}

.resumen-card {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: border-color 0.2s ease;
}

.resumen-card:hover {
    border-color: rgba(8, 124, 255, 0.35);
}

.resumen-card:last-child {
    grid-column: span 2;
}

.resumen-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--texto-secundario);
}

.kpi-icono {
    flex-shrink: 0;
}

.kpi-icono.kpi-dorado { color: var(--positivo); }
.kpi-icono.kpi-coral { color: var(--negativo); }
.kpi-icono.kpi-azul { color: var(--accent); }
.kpi-icono.kpi-neutro { color: var(--texto-secundario); }

.resumen-valor-fila {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.resumen-valor {
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--blanco);
}

.resumen-valor.dorado,
.resumen-valor.coral {
    color: var(--blanco);
}

.resumen-valor.azul {
    color: var(--accent);
}

.resumen-valor.positivo { color: var(--positivo); }
.resumen-valor.negativo { color: var(--negativo); }

.kpi-variacion {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
}

.kpi-variacion.positiva {
    color: var(--positivo);
    background: rgba(54, 199, 122, 0.14);
}

.kpi-variacion.negativa {
    color: var(--negativo);
    background: rgba(233, 75, 75, 0.14);
}

.kpi-variacion svg {
    flex-shrink: 0;
}

/* ---------- Meta ---------- */

.meta-section {
    background: var(--secundario);
    border: 1px solid rgba(8, 124, 255, 0.2);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.meta-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-1);
}

.meta-header h2 {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
}

.btn-editar-meta {
    background: none;
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.btn-editar-meta:hover {
    border-color: var(--accent);
}

.meta-monto {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: var(--sp-2);
}

.meta-edit-row {
    display: flex;
    gap: var(--sp-1);
    margin-bottom: var(--sp-2);
}

.meta-edit-row input {
    flex: 1;
    background: var(--fondo);
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: 10px;
    padding: 10px;
    font-size: 15px;
}

.meta-edit-row input:focus {
    outline: none;
    border-color: var(--accent);
}

.meta-edit-row button {
    background: var(--accent);
    color: var(--blanco);
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

.meta-edit-row button:hover {
    box-shadow: 0 0 16px rgba(8, 124, 255, 0.4);
}

.barra-grupo {
    margin-bottom: var(--sp-2);
}

.barra-grupo:last-child {
    margin-bottom: 0;
}

.barra-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.85);
}

.barra-fondo {
    height: 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.barra-fill {
    height: 100%;
    border-radius: 20px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.barra-dorada {
    background: var(--accent);
    box-shadow: 0 0 12px rgba(8, 124, 255, 0.5);
}

.barra-azul {
    background: rgba(8, 124, 255, 0.4);
}

.barra-monto {
    display: block;
    font-size: 12px;
    color: var(--texto-secundario);
    margin-top: 4px;
}

/* ---------- Gastos hormiga ---------- */

.contenedor-hormiga {
    max-width: 480px;
}

.hormiga-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--secundario);
    border: 1px solid rgba(233, 75, 75, 0.2);
    border-radius: var(--radio-lg);
    padding: 20px;
    margin-bottom: var(--sp-2);
    text-align: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.hormiga-total-label {
    font-size: 13px;
    color: var(--texto-secundario);
    margin-bottom: 6px;
}

.hormiga-total-valor {
    font-family: 'Poppins', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--negativo);
}

.hormiga-filtro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-1);
    margin-bottom: var(--sp-2);
}

.hormiga-filtro label {
    font-size: 13px;
    color: var(--texto-secundario);
}

.hormiga-filtro select {
    background: var(--secundario);
    color: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 9px 10px;
    font-size: 13px;
    transition: border-color 0.15s ease;
}

.hormiga-filtro select:focus {
    outline: none;
    border-color: var(--accent);
}

.hormiga-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    margin-bottom: var(--sp-3);
}

.hormiga-form input {
    background: var(--secundario);
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: var(--radio-md);
    padding: 16px;
    font-size: 17px;
}

.hormiga-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.hormiga-form button {
    background: var(--accent);
    border: none;
    color: var(--blanco);
    border-radius: var(--radio-md);
    padding: 18px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.hormiga-form button:hover {
    box-shadow: 0 0 20px rgba(8, 124, 255, 0.4);
}

.hormiga-form button:active {
    transform: scale(0.98);
}

/* ---------- Tabs de negocio (Inversiones) ---------- */

.tabs-negocio {
    display: flex;
    gap: var(--sp-1);
    margin-bottom: var(--sp-2);
    overflow-x: auto;
}

.tab-btn {
    flex-shrink: 0;
    min-height: 44px;
    background: var(--secundario);
    border: 1px solid var(--borde);
    color: rgba(255, 255, 255, 0.78);
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
    border-color: var(--accent);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--blanco);
}

/* ---------- Filtros globales ---------- */

.filtros-globales {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
    background: var(--bg-secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2) var(--sp-2) 10px;
}

.filtros-titulo {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin: 0 0 4px;
}

.filtros-titulo-texto {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filtro-grupo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filtro-grupo-label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filtro-grupo label {
    font-size: 11px;
    color: var(--texto-secundario);
}

.filtro-grupo select {
    background: var(--secundario);
    color: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 9px 8px;
    font-size: 13px;
    transition: border-color 0.15s ease;
}

.filtro-grupo select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Tooltip de ayuda contextual (ícono "i" + popover) */

.info-tooltip {
    position: relative;
    display: inline-flex;
}

.info-tooltip-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--texto-secundario);
    background: transparent;
    color: var(--texto-secundario);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.info-tooltip-btn:hover,
.info-tooltip-btn:focus-visible,
.info-tooltip.abierto .info-tooltip-btn {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}

.info-tooltip-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    max-width: 70vw;
    background: var(--bg-secundario);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    z-index: 40;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

.info-tooltip:not(.abierto) .info-tooltip-popover {
    display: none;
}

.info-tooltip-popover strong {
    color: var(--accent);
}

.analisis-divider {
    display: flex;
    align-items: center;
    margin: var(--sp-4) 0 var(--sp-2);
}

.analisis-divider span {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.58);
    white-space: nowrap;
    padding-right: 12px;
}

.analisis-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--borde);
}

/* ---------- Ranking de cotizaciones ---------- */

.ranking-section {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.ranking-section h2 {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 4px;
}

.ranking-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.58);
    margin: 0 0 var(--sp-2);
}

.ranking-lista {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--borde);
    border-radius: var(--radio-md);
    padding: 10px 12px;
    animation: entrada 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.ranking-num {
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 15px;
    color: var(--accent);
    width: 30px;
    flex-shrink: 0;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-nombre {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-fuente {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.58);
}

.ranking-derecha {
    text-align: right;
    flex-shrink: 0;
}

.ranking-monto {
    display: block;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--accent);
}

.ranking-pct {
    display: block;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.58);
}

/* ---------- Gráficas ---------- */

.graficas-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-2);
}

.graficas-comparativas {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grafica-card {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    position: relative;
    min-height: 260px;
    min-width: 0;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.grafica-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.grafica-card h3 {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 10px;
}

.grafica-header h3 {
    margin-bottom: 0;
}

.toggle-cotizacion {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
}

.grafica-vacio,
.lista-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: rgba(255, 255, 255, 0.62);
    font-size: 13px;
    padding: 32px 16px;
    gap: 10px;
}

.icono-vacio {
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 2px;
}

.icono-vacio.positivo {
    color: var(--positivo);
}

.btn-cta-vacio {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn-cta-vacio:hover {
    box-shadow: 0 0 14px rgba(8, 124, 255, 0.3);
}

.btn-cta-vacio:active {
    background: rgba(8, 124, 255, 0.14);
}

/* ---------- Movimientos ---------- */

.movimientos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: var(--sp-1);
    flex-wrap: wrap;
}

.movimientos-section h2 {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0;
}

.movimientos-header select {
    background: var(--secundario);
    color: var(--blanco);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 7px 8px;
    font-size: 12px;
    transition: border-color 0.15s ease;
}

.movimientos-header select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-cargar-mas {
    display: block;
    width: 100%;
    background: transparent;
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: var(--radio-md);
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: var(--sp-1);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-cargar-mas:hover {
    border-color: var(--accent);
    background: rgba(8, 124, 255, 0.06);
}

.btn-cargar-mas:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Deuda e inversiones (debajo del ranking) ---------- */

.deuda-inversion-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.deuda-inversion-card {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.deuda-inversion-nota {
    font-size: 11px;
    color: var(--texto-secundario);
    margin: 8px 0 0;
    line-height: 1.4;
}

.lista-movimientos {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.mov-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-md);
    padding: 12px 14px;
    cursor: pointer;
    animation: entrada 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    transition: border-color 0.15s ease, transform 0.1s ease;
}

.mov-item:hover {
    border-color: rgba(8, 124, 255, 0.35);
}

.mov-item:active {
    transform: scale(0.98);
    border-color: rgba(255, 255, 255, 0.25);
}

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

.mov-icono {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.mov-icono.ingreso {
    background: rgba(54, 199, 122, 0.16);
    color: var(--positivo);
}

.mov-icono.gasto {
    background: rgba(233, 75, 75, 0.16);
    color: var(--negativo);
}

.mov-info {
    flex: 1;
    min-width: 0;
}

.mov-nombre {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mov-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 2px;
}

.mov-etiqueta {
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

.mov-etiqueta.ganado { background: rgba(54, 199, 122, 0.16); color: var(--positivo); }
.mov-etiqueta.cotizacion { background: rgba(8, 124, 255, 0.16); color: var(--accent); }
.mov-etiqueta.pagado { background: rgba(54, 199, 122, 0.16); color: var(--positivo); }
.mov-etiqueta.pendiente { background: rgba(233, 75, 75, 0.16); color: var(--negativo); }

.mov-monto {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.mov-monto.ingreso { color: var(--positivo); }
.mov-monto.gasto { color: var(--negativo); }

/* ---------- FAB ---------- */

.fab-nuevo {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--blanco);
    border: none;
    font-size: 30px;
    line-height: 1;
    box-shadow: 0 10px 30px rgba(8, 124, 255, 0.45);
    cursor: pointer;
    z-index: 30;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, box-shadow 0.2s ease;
}

.fab-nuevo:hover {
    box-shadow: 0 0 30px rgba(8, 124, 255, 0.6);
}

.fab-nuevo:active {
    transform: scale(0.92);
}

.fab-nuevo.fab-oculto {
    transform: translateY(96px);
    opacity: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .fab-nuevo {
        transition: none;
    }
}

/* ---------- Modales tipo bottom-sheet ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.2s ease;
}

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

.modal-sheet {
    background: var(--bg-secundario);
    border: 1px solid var(--borde);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    padding: 14px 20px 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-sheet-sm {
    padding-bottom: 20px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--borde);
    border-radius: 4px;
    margin: 0 auto 16px;
}

.modal-sheet h2 {
    font-size: 18px;
    margin-bottom: var(--sp-2);
}

.tipo-opciones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: var(--sp-2);
}

.tipo-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 12px;
    border-radius: var(--radio-lg);
    border: 1px solid var(--borde);
    background: var(--secundario);
    color: var(--blanco);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.tipo-btn:hover {
    border-color: var(--accent);
}

.tipo-icono {
    font-size: 26px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tipo-ingreso .tipo-icono { background: rgba(54, 199, 122, 0.18); color: var(--positivo); }
.tipo-gasto .tipo-icono { background: rgba(233, 75, 75, 0.18); color: var(--negativo); }

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

.modal-sheet form label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 8px;
}

.modal-sheet form input,
.modal-sheet form select,
.modal-sheet form textarea {
    background: var(--secundario);
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: 10px;
    padding: 12px;
    font-size: 16px;
    width: 100%;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.15s ease;
}

.modal-sheet form input:focus,
.modal-sheet form select:focus,
.modal-sheet form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.estado-toggle {
    display: flex;
    gap: 8px;
}

.estado-btn {
    flex: 1;
    min-height: 44px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--borde);
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.estado-btn:hover {
    border-color: var(--accent);
}

.estado-btn.active {
    background: var(--positivo);
    border-color: var(--positivo);
    color: #06210f;
    font-weight: 700;
}

#form-gasto .estado-btn.active {
    background: var(--negativo);
    border-color: var(--negativo);
    color: var(--blanco);
}

.form-acciones {
    display: flex;
    gap: 10px;
    margin-top: var(--sp-3);
}

.btn-cancelar {
    flex: 1;
    background: transparent;
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: 10px;
    padding: 13px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 10px;
    transition: border-color 0.15s ease;
}

.btn-cancelar:hover {
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-guardar {
    flex: 2;
    background: var(--accent);
    border: none;
    color: var(--blanco);
    border-radius: 10px;
    padding: 13px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-guardar:hover {
    box-shadow: 0 0 18px rgba(8, 124, 255, 0.4);
}

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

.btn-guardar:disabled,
.btn-cancelar:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.accion-btn {
    display: block;
    width: 100%;
    background: var(--secundario);
    border: 1px solid var(--borde);
    color: var(--blanco);
    border-radius: 10px;
    padding: 14px;
    font-size: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.accion-btn:hover {
    border-color: var(--accent);
}

.accion-eliminar {
    color: var(--negativo);
}

.accion-eliminar:hover {
    border-color: var(--negativo);
}

/* ---------- Calendario financiero ---------- */

.calendario-section {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    margin-bottom: var(--sp-3);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.calendario-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: var(--sp-2);
}

.calendario-header h2 {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
}

.calendario-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blanco);
}

.btn-cal-nav {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--borde);
    color: var(--blanco);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.btn-cal-nav:hover {
    border-color: var(--accent);
}

.calendario-leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: var(--sp-2);
}

.cal-leyenda-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--texto-secundario);
}

.cal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-dot-ingreso { background: var(--positivo); }
.cal-dot-gasto { background: var(--negativo); }
.cal-dot-gasto-pendiente { background: var(--ambar); }
.cal-dot-cotizacion { background: var(--accent); }
.cal-dot-deuda { background: var(--violeta); }
.cal-dot-inversion { background: var(--teal); }

.calendario-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-header {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--texto-secundario);
    padding-bottom: 6px;
}

.cal-dia {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: var(--fondo);
    border: 1px solid var(--borde);
    border-radius: 8px;
    color: var(--blanco);
    font-size: 11px;
    cursor: default;
    padding: 2px;
    transition: border-color 0.15s ease;
}

.cal-dia-vacio {
    background: transparent;
    border-color: transparent;
}

.cal-dia-activo {
    cursor: pointer;
    background: var(--secundario);
}

.cal-dia-activo:hover {
    border-color: var(--accent);
}

.cal-dia-num {
    font-weight: 600;
}

.cal-dots {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.cal-popover {
    position: absolute;
    z-index: 45;
    width: 240px;
    max-width: 80vw;
    background: var(--bg-secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-md);
    padding: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    font-size: 12px;
}

.cal-popover-fecha {
    font-weight: 700;
    color: var(--blanco);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--borde);
}

.cal-popover-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.cal-popover-item:last-child {
    margin-bottom: 0;
}

.cal-popover-nombre {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.85);
}

.cal-popover-monto {
    font-weight: 700;
    color: var(--blanco);
    white-space: nowrap;
}

@media (max-width: 480px) {
    .cal-header {
        font-size: 9px;
    }
    .cal-dia {
        font-size: 10px;
    }
    .cal-dot {
        width: 6px;
        height: 6px;
    }
}

/* ---------- Toast de confirmación ---------- */

#toast-container {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 80;
    pointer-events: none;
    width: 100%;
    padding: 0 16px;
}

.toast {
    background: var(--bg-secundario);
    border: 1px solid rgba(54, 199, 122, 0.35);
    color: var(--blanco);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 90vw;
    text-align: center;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-error {
    border-color: rgba(233, 75, 75, 0.4);
}

@media (min-width: 1024px) {
    #toast-container {
        bottom: 32px;
    }
}

/* ---------- Bolsillos ---------- */

.bolsillos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--sp-2);
}

.bolsillo-card {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.bolsillo-card:hover {
    border-color: rgba(8, 124, 255, 0.35);
}

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

.bolsillo-nombre {
    font-size: 15px;
    font-weight: 700;
}

.bolsillo-cuenta {
    font-size: 11px;
    color: var(--texto-secundario);
    white-space: nowrap;
}

.bolsillo-montos {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 10px 0 6px;
}

.bolsillo-ahorrado {
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--accent);
}

.bolsillo-objetivo {
    font-size: 12px;
    color: var(--texto-secundario);
}

.bolsillo-barra-fondo {
    height: 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin-bottom: 6px;
}

.bolsillo-barra-fill {
    height: 100%;
    border-radius: 20px;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(8, 124, 255, 0.5);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.bolsillo-barra-fill.completo {
    background: var(--positivo);
    box-shadow: 0 0 10px rgba(54, 199, 122, 0.5);
}

.bolsillo-pie {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--texto-secundario);
}

.bolsillo-etiqueta-estado {
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.bolsillo-etiqueta-estado.activo { background: rgba(8, 124, 255, 0.14); color: var(--accent); }
.bolsillo-etiqueta-estado.completado { background: rgba(54, 199, 122, 0.16); color: var(--positivo); }

/* ---------- Deudas ---------- */

.deudas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--sp-2);
}

.deuda-card {
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg);
    padding: var(--sp-2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.deuda-card:hover {
    border-color: rgba(233, 75, 75, 0.35);
}

.deuda-proxima-fila,
.deuda-cierre-fila {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--texto-secundario);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--borde);
}

.deuda-proxima-monto {
    font-weight: 700;
    color: var(--coral);
}

.deuda-cierre {
    font-style: italic;
}

.label-opcional {
    font-size: 11px;
    font-weight: 400;
    color: var(--texto-secundario);
    text-transform: none;
}

.preview-calculo {
    font-size: 12px;
    color: var(--accent);
    background: rgba(8, 124, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 6px 0;
}

.checkbox-fila {
    background: var(--fondo);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blanco);
    cursor: pointer;
    margin-top: 0 !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    margin-top: 2px;
    accent-color: var(--accent);
}

.checkbox-fila .label-opcional {
    margin: 6px 0 0;
}

/* ---------- Tarjetas de crédito / Compras a cuotas ---------- */

.tarjetas-fila {
    display: flex;
    gap: var(--sp-1);
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 8px;
}

.tarjeta-card {
    flex: 0 0 auto;
    min-width: 180px;
    background: var(--secundario);
    border: 1px solid var(--borde);
    border-left: 4px solid;
    border-radius: var(--radio-md);
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tarjeta-card.inactiva {
    opacity: 0.5;
}

.tarjeta-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.tarjeta-nombre {
    font-size: 13px;
    font-weight: 700;
}

.tarjeta-cupo {
    font-size: 15px;
    font-weight: 800;
    font-family: 'Poppins', sans-serif;
}

.tarjeta-cupo small {
    font-size: 11px;
    font-weight: 500;
    color: var(--texto-secundario);
}

.tarjeta-fechas {
    font-size: 10px;
    color: var(--texto-secundario);
}

.btn-nueva-tarjeta {
    margin-bottom: var(--sp-2);
}

/* ---------- Sidebar (desktop ≥1024px) ---------- */

@media (min-width: 1024px) {
    .topbar {
        display: none;
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        position: sticky;
        top: 0;
        height: 100vh;
        width: var(--sidebar-ancho);
        flex-shrink: 0;
        background: var(--bg-secundario);
        border-right: 1px solid var(--borde);
        padding: var(--sp-3) var(--sp-2);
    }

    .sidebar-logo {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 var(--sp-1);
        margin-bottom: var(--sp-4);
    }

    .sidebar-logo h1 {
        font-size: 18px;
    }

    .sidebar-logo h1 span {
        color: var(--accent);
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .sidebar-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 11px 12px;
        border-radius: var(--radio-md);
        color: var(--texto-secundario);
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .sidebar-link svg {
        flex-shrink: 0;
    }

    .sidebar-link:hover {
        background: rgba(255, 255, 255, 0.04);
        color: var(--blanco);
    }

    .sidebar-link.activo {
        background: rgba(8, 124, 255, 0.12);
        color: var(--accent);
        box-shadow: inset 0 0 0 1px rgba(8, 124, 255, 0.3);
    }

    .sidebar-footer {
        margin-top: auto;
        padding-top: var(--sp-2);
        border-top: 1px solid var(--borde);
    }

    .sidebar-saludo {
        font-size: 12px;
        color: var(--texto-secundario);
        padding: 0 12px;
        margin: 0 0 var(--sp-1);
    }

    .sidebar-saludo strong {
        color: var(--blanco);
    }

    .main-area {
        padding: var(--sp-4) 0;
    }

    .contenedor,
    .contenedor-hormiga {
        max-width: 1100px;
        padding-left: var(--sp-4);
        padding-right: var(--sp-4);
    }

    .fab-nuevo {
        right: var(--sp-4);
    }
}

/* ---------- Tablet / desktop pequeño (720–1023px) ---------- */

@media (min-width: 720px) {
    .filtros-globales {
        grid-template-columns: repeat(3, 1fr);
        align-items: end;
    }
    .resumen-general {
        grid-template-columns: repeat(6, 1fr);
    }
    .resumen-card:last-child {
        grid-column: auto;
    }
    .graficas-section {
        grid-template-columns: 1fr 1fr;
    }
}
