:root {
    --sidebar-width: 240px;
}

.choices {
    margin-bottom: 0;
}

.choices__inner {
    background: #fff;
    border-color: #dee2e6;
    border-radius: 0.375rem;
    min-height: 38px;
    font-size: 1rem;
}

.choices[data-type*="select-one"] .choices__inner {
    padding-bottom: 0;
}

.choices__list--single .choices__item {
    color: #212529;
}

.choices__list--dropdown .choices__item--selectable {
    padding-right: 12px;
}

body {
    background: #f5f7fb;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: #1b2a4a;
    color: #cfd8e6;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    padding: 0.5rem 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar .nav-link {
    color: #b8c4d8;
    padding: 0.6rem 1.25rem;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: #4f8cff;
}

.contenido {
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    flex: 1;
    max-width: 100%;
}

@media (max-width: 991.98px) {
    .sidebar {
        display: none;
    }
    .contenido {
        margin-left: 0;
    }
}

.card {
    border: none;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

.card-dash {
    border-left: 4px solid #4f8cff;
}

.card-dash.verde { border-left-color: #198754; }
.card-dash.rojo { border-left-color: #dc3545; }
.card-dash.naranja { border-left-color: #fd7e14; }
.card-dash.azul { border-left-color: #0d6efd; }

.card-dash .valor {
    font-size: 1.5rem;
    font-weight: 700;
}

.card-dash .valor-bs {
    font-size: 0.95rem;
    font-weight: 600;
    color: #6b7280;
}

.miniatura {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}

.tabla-cruda {
    width: 100%;
    font-size: 0.92rem;
}

.tabla-cruda th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    background: #f9fafb;
}

.moneda-badge {
    font-size: 0.75rem;
    font-weight: 600;
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1b2a4a 0%, #274a8f 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    border: none;
    border-radius: 16px;
}

.avatar-login {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #1b2a4a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 0.75rem;
}

/* ===================== MÓVIL (tipo app) ===================== */

/* ---- Barra de navegación inferior ---- */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    background: #1b2a4a;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(16, 24, 40, 0.25);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.55rem 0 0.5rem;
    color: #b8c4d8;
    text-decoration: none;
    font-size: 0.7rem;
    background: none;
    border: 0;
    line-height: 1;
    border-top: 2px solid transparent;
    min-height: 0;
}

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

.bottom-nav-item:hover,
.bottom-nav-item:active {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.bottom-nav-item.active {
    color: #fff;
    border-top-color: #4f8cff;
}

@media (max-width: 991.98px) {
    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ---- Contenido y topbar en móvil ---- */
@media (max-width: 575.98px) {
    .contenido {
        padding: 0.75rem 0.9rem calc(72px + env(safe-area-inset-bottom));
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 1020;
        margin: -0.75rem -0.9rem 0.9rem;
        padding: 0.6rem 0.9rem;
        background: rgba(245, 247, 251, 0.92);
        backdrop-filter: blur(6px);
    }

    /* Evita zoom automático de iOS al enfocar */
    .form-control-sm,
    .form-select-sm {
        font-size: 1rem;
    }

    /* Objetivos táctiles cómodos */
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 40px;
    }

    /* Footer de modales: botones apilados a lo ancho */
    .modal-footer {
        display: grid;
        gap: 0.5rem;
        grid-template-columns: 1fr;
    }

    .modal-footer .btn {
        width: 100%;
        min-height: 48px;
        margin: 0;
    }

    /* Repetidor de cuotas: la fecha ocupa su propia línea */
    .fila-cuota {
        flex-wrap: wrap;
    }

    .fila-cuota input[type="date"] {
        flex: 1 1 100%;
    }

    .fila-cuota .form-control {
        white-space: normal;
    }

    /* Modales más compactos en móvil: texto y espaciado menores */
    .modal .modal-title {
        font-size: 1.1rem;
    }

    .modal .form-label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .modal .form-text {
        font-size: 0.75rem;
    }

    .modal-body .row {
        --bs-gutter-y: 0.6rem;
    }
}

@media (max-width: 575.98px) {
    .botones-accion {
        display: grid;
        grid-template-columns: 1fr;
    }
}

/* ---- Tablas → tarjetas apiladas en móvil ---- */
@media (max-width: 767.98px) {
    .table-mobile-cards tbody {
        display: block;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tr {
        display: block;
        border: 1px solid #e9ecef;
        border-radius: 0.75rem;
        padding: 0.4rem 0.75rem;
        margin-bottom: 0.5rem;
        background: #fff;
        box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    }

    .table-mobile-cards tr.table-light {
        background: #f8f9fa;
    }

    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        border: 0;
        padding: 0.2rem 0;
        text-align: right;
    }

    .table-mobile-cards td[data-label]::before {
        content: attr(data-label);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: #6b7280;
        font-weight: 600;
        text-align: left;
        flex-shrink: 0;
    }

    .table-mobile-cards td:not([data-label]) {
        justify-content: flex-end;
    }

    .table-mobile-cards td[colspan] {
        justify-content: center;
        text-align: center;
    }

    /* Fila expandible (cuotas colapsables): conserva el comportamiento de tabla */
    .table-mobile-cards tr.fila-expandible {
        display: table-row;
        border: 0;
        padding: 0;
        margin: 0;
        background: transparent;
        box-shadow: none;
    }

    .table-mobile-cards tr.fila-expandible td {
        display: block;
        padding: 0;
        justify-content: flex-start;
    }

    .table-mobile-cards tr.fila-expandible table {
        margin-top: 0.5rem;
    }

    .table-mobile-cards tr.fila-expandible td .p-3 {
        padding: 0.5rem !important;
    }

    .table-mobile-cards tr.fila-expandible .row {
        --bs-gutter-y: 0.5rem;
    }

    .table-mobile-cards tr.fila-expandible .progress.mb-3 {
        margin-bottom: 0.5rem !important;
    }

    /* El colapso sí debe ocultar la fila de detalles en móvil */
    .table-mobile-cards tr.fila-expandible.collapse {
        display: none;
    }

    .table-mobile-cards tr.fila-expandible.collapse.show {
        display: table-row;
    }
}

/* Despliegue de detalles más ágil (sin sensación de retardo) */
.collapsing {
    transition-duration: 0.15s;
}

/* Efecto táctil al pulsar la fila de cuenta */
tr.cuenta-fila {
    -webkit-tap-highlight-color: rgba(13, 110, 253, 0.12);
    transition: background-color 0.12s ease;
    cursor: pointer;
}

tr.cuenta-fila:hover {
    background-color: #f4f8fc;
}

tr.cuenta-fila:active {
    background-color: #e6eef7;
}

.cuenta-fila .cuenta-chevron {
    display: inline-block;
    margin-left: 0.4rem;
    font-size: 0.7rem;
    color: #6b7280;
    transition: transform 0.2s ease;
}

.cuenta-fila.activo .cuenta-chevron {
    transform: rotate(180deg);
}

/* Detalle de cuenta: contenido centrado y más pequeño */
.detalle-cuenta {
    text-align: center;
}

.detalle-cuenta .progress {
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .detalle-cuenta {
        font-size: 0.82rem;
    }

    .detalle-cuenta .small {
        font-size: 0.62rem;
    }

    .detalle-cuenta .fw-semibold {
        font-size: 0.85rem;
    }

    .detalle-cuenta .btn {
        font-size: 0.72rem;
    }
}

/* ---- Filtros compactos (gastos/ingresos) ---- */
.filtros {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
}

.filtros .input-group {
    flex: 0 1 auto;
    flex-wrap: nowrap;
    min-width: 0;
}

.filtros .input-group .form-control,
.filtros .input-group .form-select {
    min-width: 0;
}

.filtros .filtro-mes {
    flex: 0 1 13rem;
}

.filtros .filtro-mes select[name="periodo"] {
    flex: 0 1 4.6rem;
    min-width: 0;
}

.filtros .filtro-mes input[name="fecha"] {
    flex: 1 1 7rem;
    min-width: 0;
}

.filtros .filtro-cat {
    flex: 0 1 11rem;
}

.filtros .filtro-busqueda {
    flex: 1 1 12rem;
    max-width: 13rem;
}

.filtros .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (min-width: 992px) {
    .fila-filtros {
        flex-wrap: nowrap !important;
    }

    .fila-filtros > .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 575.98px) {
    .filtros {
        flex: 1 1 100%;
        column-gap: 0.4rem;
    }

    .filtros .filtro-mes,
    .filtros .filtro-cat,
    .filtros .filtro-busqueda {
        flex: 1 1 0;
        min-width: 0;
    }

    .filtros .filtro-busqueda {
        max-width: none;
    }

    .filtros .btn {
        flex: 0 0 auto;
    }
}

/* ---- FAB (acción rápida) ---- */
.badge-categoria {
    max-width: 100%;
    white-space: normal;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.fab {
    display: none;
    position: fixed;
    right: 1rem;
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    z-index: 1030;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.3);
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    padding: 0;
}

@media (max-width: 991.98px) {
    .fab {
        display: flex;
    }
}

/* ---- Prevenir desbordes del dashboard ---- */
#etiquetaTasa {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .card-dash .valor {
        font-size: 1.25rem;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .list-group-item {
        min-width: 0;
    }

    .list-group-item > div {
        min-width: 0;
    }

    .list-group-item strong {
        overflow-wrap: anywhere;
    }
}

.sync-pill {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #1b2a4a;
    color: #fff;
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
    border-radius: 2rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    max-width: calc(100vw - 2rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sync-pill.sync-error {
    background: #b02a37;
}

.toast-contenedor {
    position: fixed;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: calc(100vw - 2rem);
    max-width: 380px;
    pointer-events: none;
}

.toast-nota {
    background: #1b2a4a;
    color: #fff;
    font-size: 0.85rem;
    padding: 0.7rem 1rem;
    border-radius: 0.6rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: toast-in 0.25s ease;
}

.toast-nota.toast-error {
    background: #b02a37;
}

.toast-nota.salida {
    opacity: 0;
    transition: opacity 0.4s;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

.offline-page {
    background: #f5f7fb;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.offline-caja {
    text-align: center;
    max-width: 24rem;
}

@media (min-width: 992px) {
    .sync-pill {
        bottom: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .sync-pill {
        bottom: 82px;
    }
}

