/* ============================================================
   CelesteWallet · Sistema visual
   Paleta morada/lila · Poppins
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
    /* Morado como protagonista */
    --morado: #8B5CF6;
    /* PRINCIPAL — violeta */
    --lila: #A78BFA;
    /* secundario, más claro para acentos */
    --morado-oscuro: #7C3AED;
    /* hover / texto fuerte */
    --tinta: #1E1B2E;
    /* títulos y barra móvil, casi negro con tinte morado */

    /* Apoyo y acento */
    --lila-claro: #DDD3FA;
    --celeste: #AFCFEA;
    /* uso mínimo, <5% (marca) */

    /* Fondo y neutros — limpio y luminoso */
    --crema: #F2F1F6;
    --card: #FFFFFF;
    --crema-suave: #F0EDF7;
    /* inset con leve tinte lila */
    --gris: #6B6577;
    --borde: #E6E2EF;

    /* Estados */
    --rojo: #C0492F;
    --rojo-bg: #FAEAE6;
    --ambar: #B98A2E;
    --ambar-bg: #F6EFDD;
    --exito-bg: #E3F1E9;

    /* Formas — redondeo generoso, como los mockups */
    --r-lg: 26px;
    --r-md: 16px;
    --r-sm: 12px;
    --r-full: 999px;

    --sombra: 0 4px 16px rgba(30, 20, 60, .06);
    --sombra-lg: 0 10px 30px rgba(30, 20, 60, .10);

    --fuente: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--fuente);
    background: var(--crema);
    color: var(--tinta);
    line-height: 1.55;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.contenedor {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 28px 20px 96px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.contenedor-pequeno,
.contenedor.pequeno,
.pequeno {
    max-width: 460px;
}

/* ---------- Tipografía ---------- */
h1 {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 4px 0;
    color: var(--tinta);
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--tinta);
}

.etiqueta {
    text-transform: uppercase;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .09em;
    color: var(--morado);
    margin: 0 0 2px;
}

.subtitulo {
    color: var(--gris);
    margin: 6px 0 0;
}

.texto-centro {
    text-align: center;
    color: var(--gris);
}

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

.texto-tenue {
    color: var(--gris);
    font-size: .88rem;
}

a {
    color: var(--morado);
    font-weight: 600;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Tarjetas ---------- */
.tarjeta {
    background: var(--card);
    border: none;
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--sombra);
}

/* El hero es un panel lavanda, como los bloques del mockup */
.tarjeta.hero {
    background: #F3E8FD;
    border: none;
    box-shadow: none;
    padding: 24px;
}

.barra-superior {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- Botones ---------- */
.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--morado);
    color: #fff;
    border: 1px solid var(--morado);
    border-radius: var(--r-full);
    padding: 12px 22px;
    font-family: var(--fuente);
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.boton:hover {
    background: var(--morado-oscuro);
    border-color: var(--morado-oscuro);
    text-decoration: none;
    box-shadow: var(--sombra);
}

.boton:active {
    transform: translateY(1px);
}

/* Secundario delineado con tinta, como los chips del mockup */
.boton.secundario {
    background: transparent;
    color: var(--tinta);
    border: 1.5px solid var(--tinta);
}

.boton.secundario:hover {
    background: var(--crema-suave);
    border-color: var(--tinta);
}

.boton.ancho {
    width: 100%;
}

/* ---------- Acciones ---------- */
.acciones,
.acciones-header,
.acciones-formulario {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.acciones-formulario {
    justify-content: flex-end;
    margin-top: 8px;
}

.acciones-header form {
    margin: 0;
}

/* ---------- Formularios ---------- */
.formulario,
.formulario-presupuesto {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.formulario-presupuesto {
    flex-flow: row wrap;
    align-items: flex-end;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 200px;
}

.campo label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--morado-oscuro);
}

.campo input,
.campo select,
.campo textarea {
    font-family: var(--fuente);
    font-size: 1rem;
    color: var(--tinta);
    background: #fff;
    border: 1.5px solid var(--tinta);
    border-radius: var(--r-sm);
    padding: 12px 14px;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--morado);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .18);
}

.campo textarea {
    resize: vertical;
    min-height: 80px;
}

.campo input[type="color"] {
    padding: 4px;
    height: 46px;
    cursor: pointer;
}

.ayuda {
    display: block;
    font-size: .82rem;
    color: var(--gris);
    margin-top: 2px;
}

.error-campo {
    color: var(--rojo);
    font-size: .82rem;
    font-weight: 600;
}

/* ---------- Grids / resumen ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.resumen .etiqueta {
    margin-bottom: 6px;
}

.resumen h2 {
    font-size: 1.7rem;
    margin: 0 0 6px;
    letter-spacing: -.02em;
}

.resumen p {
    margin: 0;
    color: var(--gris);
    font-size: .88rem;
}

/* ---------- Tablas ---------- */
.tabla-contenedor {
    overflow-x: auto;
    border-radius: var(--r-md);
}

.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.tabla thead th {
    text-align: left;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gris);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 2px solid var(--borde);
    white-space: nowrap;
}

.tabla tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--borde);
    vertical-align: middle;
}

.tabla tbody tr:last-child td {
    border-bottom: none;
}

.tabla tbody tr:hover {
    background: var(--crema-suave);
}

.acciones-tabla {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
}

.form-inline {
    display: inline;
    margin: 0;
}

/* ---------- Badge ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F1E7FD;
    color: var(--morado-oscuro);
    border: none;
    border-radius: var(--r-full);
    padding: 4px 12px;
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ---------- Botones de texto en tablas ---------- */
.link-accion {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--fuente);
    font-size: .9rem;
    font-weight: 700;
    color: var(--morado);
    cursor: pointer;
}

.link-accion:hover {
    text-decoration: underline;
}

.link-accion.peligro {
    color: var(--rojo);
}

/* ---------- Barra de progreso ---------- */
.barra-progreso {
    width: 100%;
    height: 10px;
    background: var(--crema-suave);
    border-radius: var(--r-full);
    overflow: hidden;
    margin: 14px 0;
}

.barra-progreso-interna {
    height: 100%;
    border-radius: var(--r-full);
    background: var(--lila);
    transition: width .4s ease;
}

.barra-progreso-interna.progreso-bueno {
    background: var(--morado);
}

.barra-progreso-interna.progreso-alerta {
    background: var(--ambar);
}

.barra-progreso-interna.progreso-peligro {
    background: var(--rojo);
}

.nota-dashboard {
    color: var(--gris);
    font-size: .9rem;
    margin: 12px 0 0;
}

/* ---------- Alertas ---------- */
.alerta {
    border-radius: var(--r-md);
    padding: 13px 16px;
    font-size: .92rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.alerta.exito {
    background: var(--exito-bg);
    color: var(--morado-oscuro);
    border-color: #CFE0C5;
}

.alerta.error {
    background: var(--rojo-bg);
    color: #8A2E1B;
    border-color: #F0CFC6;
}

.alerta.aviso {
    background: var(--ambar-bg);
    color: #6E5417;
    border-color: #E7D9B4;
}

/* ---------- Estado vacío ---------- */
.estado-vacio {
    text-align: center;
    padding: 32px 20px;
    color: var(--gris);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.estado-vacio h2 {
    margin: 0;
}

/* ---------- Lista de detalle (estado del sistema) ---------- */
.detalle {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 20px;
    margin: 20px 0;
}

.detalle dt {
    font-weight: 700;
    color: var(--morado-oscuro);
}

.detalle dd {
    margin: 0;
    color: var(--gris);
}

/* ---------- Accesibilidad y responsive ---------- */
:focus-visible {
    outline: 2px solid var(--morado);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    h1 {
        font-size: 1.6rem;
    }

    .tarjeta {
        padding: 18px;
    }

    .barra-superior {
        flex-direction: column;
    }

    .acciones-header {
        width: 100%;
    }

    .formulario-presupuesto {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* ============================================================
   NAVEGACIÓN RESPONSIVE  ·  móvil = barra abajo · PC = sidebar
   ============================================================ */

/* Barra móvil: anclada al borde inferior, oscura, esquinas superiores redondeadas */
.barra-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 76px;
    background: var(--tinta);
    border-top: none;
    border-radius: 26px 26px 0 0;
    display: flex;
    align-items: center;
    padding: 0 18px env(safe-area-inset-bottom, 0px);
    z-index: 50;
    box-shadow: 0 -8px 24px rgba(30, 20, 60, .16);
}

.nav-marca,
.nav-nuevo,
.sidebar-perfil {
    display: none;
}

.nav-links {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 0 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: rgba(255, 255, 255, .58);
    font-size: .7rem;
    font-weight: 700;
    text-decoration: none;
}

/* En la píldora móvil solo se ven los íconos */
.nav-item span {
    display: none;
}

.nav-item:hover {
    color: #fff;
    text-decoration: none;
}

.nav-item.activo {
    color: #fff;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* El ítem activo lleva su ícono dentro de un círculo claro, como el mockup */
.nav-item.activo svg {
    width: 46px;
    height: 46px;
    padding: 12px;
    border-radius: 50%;
    background: var(--lila-claro);
    color: var(--tinta);
}

.nav-fab {
    position: fixed;
    right: 18px;
    bottom: 94px;
    width: 56px;
    height: 56px;
    border-radius: var(--r-full);
    background: var(--morado);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    line-height: 1;
    text-decoration: none;
    box-shadow: var(--sombra-lg);
    z-index: 51;
    transition: transform .1s ease, background .15s ease;
}

.nav-fab:hover {
    background: var(--morado-oscuro);
    text-decoration: none;
    transform: translateY(-2px);
}

/* Página de ajustes */
.lista-ajustes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-ajuste {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--borde);
    border-radius: var(--r-md);
    text-decoration: none;
    color: var(--tinta);
    font-weight: 700;
    transition: border-color .15s ease, background .15s ease;
}

.item-ajuste:hover {
    border-color: var(--lila);
    background: var(--crema-suave);
    text-decoration: none;
}

.item-ajuste .flecha {
    color: var(--gris);
    font-weight: 400;
}

/* ============================================================
   DASHBOARD FINTECH
   ============================================================ */

/* Tarjeta de balance (héroe) */
.tarjeta-destacada {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
    border: none;
    color: #fff;
    padding: 28px;
}

.tarjeta-destacada::before {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    right: -90px;
    top: -140px;
    background: radial-gradient(circle, rgba(175, 207, 234, .38), transparent 70%);
    pointer-events: none;
}

.tarjeta-destacada::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    left: -60px;
    bottom: -120px;
    background: radial-gradient(circle, rgba(255, 255, 255, .08), transparent 70%);
    pointer-events: none;
}

.tarjeta-destacada>* {
    position: relative;
    z-index: 1;
}

.etiqueta-clara {
    text-transform: uppercase;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .09em;
    color: rgba(255, 255, 255, .82);
    margin: 0 0 6px;
}

.monto-grande {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -.03em;
    margin: 0 0 20px;
    line-height: 1;
}

.barra-clara {
    background: rgba(255, 255, 255, .22);
    margin: 0 0 12px;
    height: 8px;
}

.destacada-pie {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: .85rem;
    color: rgba(255, 255, 255, .88);
    font-weight: 600;
}

.destacada-pie strong {
    font-weight: 800;
    color: #fff;
}

/* Stats con chip de ícono */
.tarjeta.resumen {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Círculo de color, como los stats del mockup */
.stat-icono {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F1E7FD;
    color: var(--morado);
    margin-bottom: 14px;
}

.stat-icono svg {
    width: 21px;
    height: 21px;
}

.stat-icono.acento {
    background: #E8F1FA;
    color: #3E6E97;
}

/* acento celeste, mínimo */

.resumen .etiqueta {
    margin-bottom: 4px;
}

.resumen h2 {
    font-size: 1.85rem;
    margin: 0 0 4px;
    letter-spacing: -.02em;
}

.resumen .stat-texto {
    font-size: 1.1rem;
    line-height: 1.3;
}

.resumen p {
    margin: 0;
    color: var(--gris);
    font-size: .85rem;
}

/* Gráficos */
.grid-graficos {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grafico-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 16px;
}

.grafico-head h2 {
    margin: 0;
}

.grafico-sub {
    font-size: .82rem;
    color: var(--gris);
}

.contenedor-grafico {
    position: relative;
    height: 260px;
}

/* Deudas */
.deudas-resumen {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 4px;
}

.deuda-celda {
    background: var(--crema-suave);
    border-radius: var(--r-md);
    padding: 16px;
}

.deuda-celda .etiqueta {
    margin: 0 0 6px;
}

.deuda-valor {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.02em;
}

.deuda-valor.positivo {
    color: var(--tinta);
}

.deuda-valor.negativo {
    color: var(--rojo);
}

/* Recientes */
.lista-recientes {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
}

.lista-recientes li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--borde);
}

.lista-recientes li:last-child {
    border-bottom: none;
}

.reciente-chip {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 13px;
    background: var(--crema-suave);
    color: var(--morado);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
}

.reciente-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.reciente-desc {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reciente-cat {
    font-size: .8rem;
    color: var(--gris);
}

.reciente-monto {
    font-weight: 800;
    white-space: nowrap;
}

.seccion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.seccion-head h2 {
    margin: 0;
}

/* ============================================================
   ESCRITORIO (≥1000px): sidebar + perfil + bento amplio
   ============================================================ */
@media (min-width: 1000px) {

    .nav-fab {
        display: none;
    }

    .barra-nav {
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: 248px;
        height: 100vh;
        flex-direction: column;
        align-items: stretch;
        background: var(--card);
        border-radius: 0;
        border-top: none;
        border-right: 1px solid var(--borde);
        box-shadow: none;
        padding: 22px 16px;
        gap: 6px;
    }

    .nav-marca {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 4px 8px 18px;
    }

    .nav-logo {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        background: var(--morado);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 800;
        font-size: 1.1rem;
    }

    .nav-marca-texto {
        font-weight: 800;
        font-size: 1.05rem;
        color: var(--tinta);
    }

    .nav-nuevo {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        background: var(--morado);
        color: #fff;
        font-weight: 700;
        padding: 11px;
        border-radius: var(--r-md);
        text-decoration: none;
        margin-bottom: 10px;
        transition: background .15s ease;
    }

    .nav-nuevo:hover {
        background: var(--morado-oscuro);
        text-decoration: none;
    }

    .nav-links {
        flex-direction: column;
        justify-content: flex-start;
        gap: 4px;
        padding: 0;
    }

    .nav-item {
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        height: auto;
        color: var(--gris);
        font-size: .95rem;
        padding: 11px 12px;
        border-radius: var(--r-md);
        position: relative;
    }

    /* En el sidebar de PC sí se ven las etiquetas */
    .nav-item span {
        display: inline;
    }

    .nav-item:hover {
        color: var(--morado);
    }

    .nav-item svg,
    .nav-item.activo svg {
        width: 20px;
        height: 20px;
        padding: 0;
        border-radius: 0;
        background: transparent;
        color: inherit;
    }

    .nav-item:hover {
        background: var(--crema-suave);
    }

    .nav-item.activo {
        background: var(--crema-suave);
        color: var(--morado);
    }

    .nav-item.activo::before {
        content: '';
        position: absolute;
        left: 0;
        top: 9px;
        bottom: 9px;
        width: 3px;
        border-radius: 3px;
        background: var(--morado);
    }

    /* Perfil abajo del sidebar */
    .sidebar-perfil {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: auto;
        padding: 10px;
        border-radius: var(--r-md);
        background: var(--crema-suave);
    }

    .perfil-avatar {
        width: 38px;
        height: 38px;
        flex: none;
        border-radius: 50%;
        background: var(--morado);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 800;
    }

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

    .perfil-nombre {
        font-weight: 700;
        font-size: .9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .perfil-correo {
        font-size: .74rem;
        color: var(--gris);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .perfil-logout {
        background: none;
        border: none;
        color: var(--gris);
        cursor: pointer;
        padding: 7px;
        border-radius: 9px;
        display: flex;
        flex: none;
        transition: color .15s ease, background .15s ease;
    }

    .perfil-logout:hover {
        color: var(--rojo);
        background: #fff;
    }

    .perfil-logout svg {
        width: 18px;
        height: 18px;
    }

    /* Contenido a la derecha del sidebar */
    body:has(.barra-nav) {
        padding-left: 248px;
    }

    body:has(.barra-nav) .contenedor:not(.contenedor-pequeno):not(.pequeno) {
        max-width: 1280px;
        padding: 38px 44px 56px;
    }

    /* Bento */
    .panel-dashboard {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 22px;
        align-items: start;
    }

    .panel-dashboard>.alerta {
        grid-column: 1 / -1;
    }

    .d-saludo {
        grid-column: 1 / -1;
    }

    .d-destacada {
        grid-column: span 7;
    }

    .d-stats {
        grid-column: span 5;
    }

    .d-presupuesto {
        grid-column: span 7;
    }

    .d-deudas {
        grid-column: span 5;
    }

    .d-graficos {
        grid-column: 1 / -1;
    }

    .d-recientes {
        grid-column: 1 / -1;
    }

    .d-stats {
        align-self: stretch;
    }
}

@media (max-width: 520px) {
    .monto-grande {
        font-size: 2.3rem;
    }

    .deudas-resumen {
        grid-template-columns: 1fr;
    }
}

/* Top categorías dentro de la tarjeta de balance */
.destacada-divisor {
    height: 1px;
    background: rgba(255, 255, 255, .18);
    margin: 22px 0 18px;
}

.destacada-titulo {
    text-transform: uppercase;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .09em;
    color: rgba(255, 255, 255, .8);
    margin: 0 0 14px;
}

.destacada-vacio {
    color: rgba(255, 255, 255, .8);
    font-size: .9rem;
}

.top-categorias {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.top-cat-fila {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.top-cat-nombre {
    font-weight: 700;
    font-size: .92rem;
    color: #fff;
}

.top-cat-monto {
    font-weight: 700;
    font-size: .88rem;
    color: rgba(255, 255, 255, .9);
}

.top-cat-barra {
    height: 7px;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, .2);
    overflow: hidden;
}

.top-cat-relleno {
    height: 100%;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, .9);
    transition: width .4s ease;
}

/* Resumen dentro de la tarjeta de presupuesto */
.presupuesto-resumen {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--borde);
}

.pr-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pr-icono {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    background: var(--crema-suave);
    color: var(--morado);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pr-icono svg {
    width: 19px;
    height: 19px;
}

.pr-label {
    font-size: .74rem;
    color: var(--gris);
    margin: 0 0 2px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.pr-valor {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.01em;
}

@media (max-width: 560px) {
    .presupuesto-resumen {
        grid-template-columns: 1fr;
    }

    .pr-item {
        justify-content: flex-start;
    }
}

/* Igualar alturas de las tarjetas que comparten fila en el bento */
@media (min-width: 1000px) {

    .d-destacada,
    .d-stats,
    .d-presupuesto,
    .d-deudas {
        height: 100%;
    }

    .d-stats {
        display: grid;
    }

    .d-stats .tarjeta.resumen {
        height: 100%;
    }

    .d-presupuesto {
        display: flex;
        flex-direction: column;
    }
}

/* ===== Ajuste de bento: sin duplicación, filas parejas ===== */
@media (min-width: 1000px) {
    .panel-dashboard {
        align-items: stretch;
    }

    .panel-dashboard>.alerta {
        align-self: start;
    }

    /* Fila inferior simétrica */
    .d-presupuesto {
        grid-column: span 6;
    }

    .d-deudas {
        grid-column: span 6;
    }

    /* Las stats 2x2 llenan la altura de la tarjeta de balance */
    .panel-dashboard .d-stats {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 1fr;
    }

    /* Deudas centra sus celdas para emparejar con el formulario */
    .d-deudas {
        display: flex;
        flex-direction: column;
    }

    .d-deudas .deudas-resumen {
        flex: 1;
    }

    .d-deudas .deuda-celda {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* ============================================================
   PANTALLA DE ACCESO (login / registro) — responsive por alto
   ============================================================ */
.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vh, 40px) 20px;
    position: relative;
    overflow: hidden;
}

.auth-wrap::before {
    content: '';
    position: absolute;
    width: 540px;
    height: 540px;
    top: -240px;
    right: -200px;
    background: radial-gradient(circle, rgba(33, 115, 70, .10), transparent 70%);
    pointer-events: none;
}

.auth-wrap::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    bottom: -180px;
    left: -150px;
    background: radial-gradient(circle, rgba(175, 207, 234, .14), transparent 70%);
    pointer-events: none;
}

.auth-zona {
    width: 100%;
    max-width: 410px;
    position: relative;
    z-index: 1;
}

/* La tarjeta es la protagonista: sin marca arriba */
.auth-card {
    padding: clamp(26px, 4vh, 40px) clamp(24px, 3vw, 36px);
    box-shadow: var(--sombra-lg);
}

.auth-sobretitulo {
    color: var(--gris);
    font-size: .9rem;
    font-weight: 600;
    margin: 0 0 6px;
}

.auth-card h1 {
    font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.1rem);
    margin: 0 0 clamp(18px, 3vh, 28px);
    letter-spacing: -.02em;
}

/* Campos cómodos al estilo de la referencia */
.auth-card .formulario {
    gap: clamp(14px, 2vh, 18px);
}

.auth-card .campo {
    flex: none;
}

.auth-card .campo input {
    padding: 13px 15px;
    font-size: 16px;
}

.auth-card .boton.ancho {
    margin-top: clamp(6px, 1.5vh, 12px);
    padding: 14px;
    font-size: 1rem;
}

.auth-error {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cara-triste {
    width: 24px;
    height: 24px;
    flex: none;
    color: var(--rojo);
}

.auth-pie {
    text-align: center;
    color: var(--gris);
    font-size: .92rem;
    margin: clamp(18px, 3vh, 24px) 0 0;
}

/* Sacudida en login inválido */
.sacudir {
    animation: sacudida .45s cubic-bezier(.36, .07, .19, .97);
}

@keyframes sacudida {

    10%,
    90% {
        transform: translateX(-2px);
    }

    20%,
    80% {
        transform: translateX(4px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-7px);
    }

    40%,
    60% {
        transform: translateX(7px);
    }
}

/* Overlay "Entrando..." */
.overlay-cargando {
    position: fixed;
    inset: 0;
    background: rgba(251, 250, 247, .82);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.cargando-caja {
    text-align: center;
    color: var(--morado);
    font-weight: 700;
}

.spinner {
    display: block;
    width: 42px;
    height: 42px;
    margin: 0 auto 14px;
    border: 4px solid var(--crema-suave);
    border-top-color: var(--morado);
    border-radius: 50%;
    animation: girar .7s linear infinite;
}

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

/* ============================================================
   BIENVENIDA (login exitoso, en el dashboard)
   ============================================================ */
.overlay-bienvenida {
    position: fixed;
    inset: 0;
    background: rgba(251, 250, 247, .92);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity .35s ease;
}

.overlay-bienvenida.activo {
    opacity: 1;
}

.overlay-bienvenida.saliendo {
    opacity: 0;
}

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

.bienvenida-texto {
    margin: 18px 0 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--tinta);
}

.check-svg {
    width: 84px;
    height: 84px;
}

.check-circulo {
    stroke: var(--morado);
    stroke-width: 3;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: dibujar-circulo .5s ease forwards;
}

.check-tic {
    stroke: var(--morado);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: dibujar-tic .35s .45s ease forwards;
}

@keyframes dibujar-circulo {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes dibujar-tic {
    to {
        stroke-dashoffset: 0;
    }
}

/* El atributo hidden debe ganar sobre el display:flex de los overlays */
.overlay-cargando[hidden],
.overlay-bienvenida[hidden] {
    display: none;
}

/* Los campos del login no deben estirarse verticalmente */
.auth-card .campo {
    flex: none;
}

/* ---------- Gastos: método de pago y moneda ---------- */
.badge-pago {
    display: inline-flex;
    align-items: center;
    background: #F1E7FD;
    color: var(--morado-oscuro);
    border: none;
    border-radius: var(--r-full);
    padding: 3px 11px;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

/* SINPE usa el acento celeste (uso mínimo) */
.badge-pago.sinpe {
    background: #E8F1FA;
    color: #3E6E97;
    border-color: #D3E5F4;
}

.pago-dest {
    display: block;
    font-size: .78rem;
    color: var(--gris);
    margin-top: 3px;
}

.monto-crc {
    font-weight: 700;
    white-space: nowrap;
}

.badge-usd {
    display: inline-block;
    margin-left: 6px;
    background: var(--crema-suave);
    color: var(--gris);
    border-radius: var(--r-full);
    padding: 2px 8px;
    font-size: .74rem;
    font-weight: 700;
    white-space: nowrap;
}

/* La tabla nunca debe exceder su tarjeta */
.tabla {
    width: 100%;
    table-layout: auto;
}

/* Que las celdas de monto/pago no se estiren de más */
.tabla td,
.tabla th {
    word-break: normal;
}

/* La columna de descripción cede espacio; las demás se ajustan a su contenido */
.tabla .col-descripcion {
    width: 100%;
}

.tabla .col-ajuste {
    white-space: nowrap;
    width: 1%;
}

/* ---------- Lista de movimientos (gastos) ---------- */
.lista-movimientos {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lista-movimientos li {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 4px;
    border-bottom: 1px solid var(--borde);
}

.lista-movimientos li:last-child {
    border-bottom: none;
}

.mov-chip {
    width: 46px;
    height: 46px;
    flex: none;
    border-radius: 14px;
    background: var(--crema-suave);
    color: var(--morado);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
}

.mov-centro {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mov-desc {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mov-meta {
    font-size: .8rem;
    color: var(--gris);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mov-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.mov-dest {
    font-size: .78rem;
    color: var(--gris);
}

/* Zona del monto: ancho fijo para que todos los montos queden alineados */
.mov-monto-bloque {
    flex: none;
    min-width: 140px;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.mov-monto {
    font-weight: 800;
    font-size: 1.1rem;
    white-space: nowrap;
}

/* Acciones como botones de ícono, en su propia columna */
.mov-acciones {
    flex: none;
    display: flex;
    gap: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--borde);
}

.icono-accion {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    border: none;
    background: var(--crema-suave);
    color: var(--gris);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.icono-accion svg {
    width: 18px;
    height: 18px;
}

.icono-accion:hover {
    background: #E4EADD;
    color: var(--morado);
    text-decoration: none;
}

.icono-accion.peligro:hover {
    background: var(--rojo-bg);
    color: var(--rojo);
}

/* Teléfono: monto y acciones bajan a una segunda fila */
@media (max-width: 560px) {
    .lista-movimientos li {
        flex-wrap: wrap;
        row-gap: 12px;
    }

    .mov-chip {
        width: 42px;
        height: 42px;
    }

    .mov-meta {
        white-space: normal;
    }

    .mov-monto-bloque {
        flex: 1 1 auto;
        min-width: 0;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        order: 3;
        text-align: left;
    }

    .mov-acciones {
        order: 4;
        margin-left: auto;
        border-left: none;
        padding-left: 0;
    }
}

/* ---------- Formulario centrado (nuevo/editar) ---------- */
.form-estrecho {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.volver-link {
    display: inline-block;
    font-size: .85rem;
    font-weight: 700;
    color: var(--gris);
    margin-bottom: 8px;
}

.volver-link:hover {
    color: var(--morado);
    text-decoration: none;
}

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

.form-grid .col-full {
    grid-column: 1 / -1;
}

.form-grid .acciones-formulario {
    grid-column: 1 / -1;
    margin-top: 4px;
}

@media (max-width: 560px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .col-full {
        grid-column: auto;
    }
}

/* ---------- Deudas y personas ---------- */
.mov-monto.pos {
    color: var(--tinta);
}

.mov-monto.neg {
    color: var(--rojo);
}

.bal-valor {
    font-weight: 800;
    font-size: 1.05rem;
    white-space: nowrap;
}

.bal-valor.pos {
    color: var(--tinta);
}

.bal-valor.neg {
    color: var(--rojo);
}

.bal-neutro {
    color: var(--gris);
    font-weight: 700;
}

.badge.estado-saldada {
    background: var(--exito-bg);
    color: var(--morado-oscuro);
    border-color: #CFE0C5;
}

.mov-saldada {
    opacity: .6;
}

.boton.mini {
    padding: 8px 14px;
    font-size: .85rem;
}

.resumen h2.pos {
    color: var(--tinta);
}

.resumen h2.neg {
    color: var(--rojo);
}

/* ---------- Landing pública ---------- */
.landing {
    max-width: 940px;
}

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

.landing-hero .auth-marca {
    margin-bottom: 16px;
}

.landing-hero .acciones {
    justify-content: center;
    margin-top: 20px;
}

.feature-icono {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: var(--crema-suave);
    color: var(--morado);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.feature-icono svg {
    width: 22px;
    height: 22px;
}

.feature-card h2 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.feature-card p {
    margin: 0;
    color: var(--gris);
    font-size: .9rem;
}

/* Estado del sistema: indicador */
.estado-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: .9rem;
    padding: 7px 14px;
    border-radius: var(--r-full);
}

.estado-pill.ok {
    background: var(--exito-bg);
    color: var(--morado-oscuro);
}

.estado-pill.fail {
    background: var(--rojo-bg);
    color: #8A2E1B;
}

.estado-punto {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================================
   SIDEBAR REFINADO (PC)
   ============================================================ */
@media (min-width: 1000px) {

    /* Marca: alineada con el resto, más prolija */
    .nav-marca {
        padding: 6px 10px 20px;
        border-bottom: 1px solid var(--borde);
        margin-bottom: 14px;
    }

    .nav-logo {
        width: 36px;
        height: 36px;
        border-radius: 11px;
        font-size: 1.15rem;
    }

    .nav-marca-texto {
        font-size: 1.1rem;
    }

    /* Botón Nuevo gasto: más destacado, con ícono y sombra */
    .nav-nuevo {
        gap: 8px;
        padding: 13px;
        font-size: .98rem;
        font-weight: 800;
        box-shadow: 0 4px 12px rgba(139, 92, 246, .30);
        margin-bottom: 18px;
    }

    .nav-nuevo svg {
        width: 18px;
        height: 18px;
    }

    .nav-nuevo:hover {
        box-shadow: 0 6px 16px rgba(139, 92, 246, .38);
        transform: translateY(-1px);
    }

    /* Ítems de nav: ocupan todo el ancho, más altos */
    .nav-links {
        gap: 6px;
    }

    .nav-item {
        width: 100%;
        padding: 12px 14px;
        font-size: .97rem;
        gap: 14px;
    }

    .nav-item svg {
        width: 21px;
        height: 21px;
    }

    /* Perfil rediseñado: más limpio, avatar con borde */
    .sidebar-perfil {
        padding: 12px;
        gap: 11px;
        border: 1px solid var(--borde);
        background: var(--card);
    }

    .perfil-avatar {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        /* cuadrado redondeado, no círculo */
        font-size: 1.05rem;
    }

    .perfil-nombre {
        font-size: .92rem;
        text-transform: capitalize;
    }

    .perfil-correo {
        font-size: .76rem;
    }
}

/* Saludo del dashboard */
/* Saludo del dashboard: encabezado discreto, no panel */
.tarjeta.hero.d-saludo {
    background: transparent;
    box-shadow: none;
    padding: 4px 4px 0;
}

.saludo-titulo {
    font-size: 1.5rem;
    margin: 2px 0 0;
}

/* En móvil el saludo es una línea compacta */
@media (max-width: 999px) {
    .tarjeta.hero.d-saludo {
        padding: 0;
    }

    .saludo-titulo {
        font-size: 1.1rem;
    }

    .d-saludo .etiqueta {
        font-size: .62rem;
        margin: 0;
    }

    .d-saludo .mov-tags {
        margin-top: 8px;
    }

    .d-saludo .mov-tags .boton.mini {
        padding: 6px 14px;
        font-size: .78rem;
    }
}

@media (min-width: 1000px) {
    .saludo-bloque {
        padding: 4px 0;
    }
}

/* Lista de movimientos sin chip (más minimalista) */
.lista-movimientos li {
    gap: 0;
}

.lista-movimientos .mov-centro {
    padding-left: 2px;
}

.lista-movimientos .mov-monto-bloque {
    margin-left: auto;
    padding-right: 18px;
}

/* ---------- Pestañas (Deudas / Personas) ---------- */
.tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--crema-suave);
    border: 1px solid var(--borde);
    border-radius: var(--r-full);
    padding: 4px;
    margin-top: 6px;
}

.tab {
    padding: 9px 22px;
    border-radius: var(--r-full);
    font-weight: 700;
    font-size: .92rem;
    color: var(--gris);
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.tab:hover {
    color: var(--morado);
    text-decoration: none;
}

.tab.activa {
    background: var(--morado);
    color: #fff;
}

/* Subtítulo de grupo dentro de una tarjeta */
.grupo-titulo {
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--gris);
    margin: 0 0 4px;
}

.grupo-titulo:not(:first-child) {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--borde);
}

/* ---------- Reportes compacto ---------- */
.contenedor-grafico.chico {
    height: 220px;
}

@media (min-width: 1000px) {
    .panel-reportes {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 18px;
        align-items: start;
    }

    .panel-reportes>.r-titulo,
    .panel-reportes>.r-ancho,
    .panel-reportes>.r-filtros {
        grid-column: 1 / -1;
    }

    /* Las 3 mini-stats en una fila de 4 columnas cada una */
    .r-s1 {
        grid-column: span 4;
    }

    .r-s2 {
        grid-column: span 4;
    }

    .r-s3 {
        grid-column: span 4;
    }

    /* Gráfico y detalle lado a lado */
    .r-grafico {
        grid-column: span 5;
    }

    .r-detalle {
        grid-column: span 7;
    }

    /* Si no hay gráfico (sin datos), el detalle ocupa todo */
    .r-grafico+.r-detalle:last-child {
        grid-column: span 7;
    }
}

/* Lista compacta para el detalle */
.lista-movimientos.compacta li {
    padding: 11px 2px;
}

/* ---------- Detalle por categoría (acordeón) ---------- */
.lista-categorias {
    display: flex;
    flex-direction: column;
}

.cat-item {
    border-bottom: 1px solid var(--borde);
}

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

.cat-resumen {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 2px;
    cursor: pointer;
    list-style: none;
    /* quita la flechita nativa */
}

.cat-resumen::-webkit-details-marker {
    display: none;
}

.cat-flecha {
    flex: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gris);
    transition: transform .2s ease;
}

.cat-flecha svg {
    width: 18px;
    height: 18px;
}

.cat-item[open] .cat-flecha {
    transform: rotate(90deg);
    color: var(--morado);
}

.cat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cat-nombre {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--tinta);
}

.cat-cantidad {
    font-size: .8rem;
    color: var(--gris);
}

.cat-total {
    font-weight: 800;
    font-size: 1.05rem;
    white-space: nowrap;
}

/* Gastos individuales desplegados */
.cat-gastos {
    list-style: none;
    margin: 0;
    padding: 0 2px 10px 36px;
    /* sangría para alinear bajo el nombre */
}

.cat-gastos li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px dashed var(--borde);
}

.cat-gastos li:first-child {
    border-top: none;
}

.gasto-linea {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gasto-desc {
    font-size: .9rem;
    color: var(--gris);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gasto-fecha {
    font-size: .76rem;
    color: var(--gris);
    opacity: .8;
}

.gasto-monto {
    font-size: .88rem;
    font-weight: 700;
    color: var(--gris);
    white-space: nowrap;
}

/* Simetría: gráfico y detalle a la misma altura */
@media (min-width: 1000px) {
    .panel-reportes {
        align-items: stretch;
    }

    .panel-reportes .r-grafico,
    .panel-reportes .r-detalle {
        height: 100%;
    }

    /* El gráfico se centra en su tarjeta para no quedar arriba con hueco abajo */
    .r-grafico {
        display: flex;
        flex-direction: column;
    }

    .r-grafico .contenedor-grafico.chico {
        flex: 1;
        height: auto;
        min-height: 220px;
    }
}

/* ===== Gráfico de reportes: versión final (dona compacta + leyenda al lado) ===== */
.contenedor-grafico.chico {
    height: 260px !important;
    max-width: 560px;
    margin: 0 auto;
    flex: none !important;
}

/* ===== Reportes: layout final (stats + dona arriba, detalle abajo) ===== */
@media (min-width: 1000px) {
    .panel-reportes {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 18px;
        align-items: start;
    }

    .panel-reportes>.r-titulo,
    .panel-reportes>.r-ancho,
    .panel-reportes>.r-filtros {
        grid-column: 1 / -1;
    }

    /* Fila de arriba: 3 stats + dona, repartidos en 12 columnas (3 cada uno) */
    .panel-reportes>.r-s1 {
        grid-column: span 3;
    }

    .panel-reportes>.r-s2 {
        grid-column: span 3;
    }

    .panel-reportes>.r-s3 {
        grid-column: span 3;
    }

    .panel-reportes>.r-grafico {
        grid-column: span 3;
    }

    /* Detalle solo, ancho completo abajo */
    .panel-reportes>.r-detalle {
        grid-column: 1 / -1;
    }
}

/* La dona dentro de su tarjeta angosta: sin leyenda al lado (no cabe), compacta */
.r-grafico .contenedor-grafico.chico {
    height: 180px !important;
    max-width: none;
    margin: 0;
    flex: none !important;
}

/* ============================================================
   REPORTES — LAYOUT DEFINITIVO (anula reglas previas)
   ============================================================ */
@media (min-width: 1000px) {
    .panel-reportes {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        gap: 18px;
        align-items: start;
    }

    /* Ancho completo: título, error, filtros y detalle */
    .panel-reportes>.r-titulo,
    .panel-reportes>.r-ancho,
    .panel-reportes>.r-filtros,
    .panel-reportes>.r-detalle {
        grid-column: 1 / -1 !important;
    }

    /* Fila de arriba: 3 stats + dona, cada uno 3 columnas */
    .panel-reportes>.r-s1,
    .panel-reportes>.r-s2,
    .panel-reportes>.r-s3,
    .panel-reportes>.r-grafico {
        grid-column: span 3 !important;
        height: 100%;
    }
}

/* Dona compacta dentro de su tarjeta angosta */
.r-grafico .contenedor-grafico.chico {
    height: 190px !important;
    max-width: none !important;
    margin: 0 !important;
    flex: none !important;
}

/* ===== Reportes: 3 stats arriba (sin dona) + detalle ancho ===== */
@media (min-width: 1000px) {

    .panel-reportes>.r-s1,
    .panel-reportes>.r-s2,
    .panel-reportes>.r-s3 {
        grid-column: span 4 !important;
        /* 3 stats reparten las 12 columnas */
        height: auto;
    }
}

/* ===== Ajustes: ítems compactos con ícono chico ===== */
.lista-ajustes {
    gap: 10px;
}

.item-ajuste {
    padding: 12px 16px !important;
    align-items: center;
}

.item-izq {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 14px;
}

.item-icono {
    width: 40px !important;
    height: 40px !important;
    flex: none;
    border-radius: 11px;
    background: var(--crema-suave);
    color: var(--morado);
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-icono svg {
    width: 20px !important;
    height: 20px !important;
}

.item-ajuste .flecha {
    font-size: 1.3rem;
    color: var(--gris);
}

/* ---------- Lista de personas (minimalista, clickeable) ---------- */
.lista-personas li {
    padding: 0;
}

.persona-fila {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 16px 4px;
    text-decoration: none;
    color: inherit;
    border-radius: var(--r-sm);
    transition: background .15s ease;
}

.persona-fila:hover {
    background: var(--crema-suave);
    text-decoration: none;
}

.persona-fila .mov-centro {
    flex: 1 1 auto;
    min-width: 0;
}

.persona-fila .mov-monto-bloque {
    margin-left: auto;
}

.persona-flecha {
    flex: none;
    font-size: 1.3rem;
    color: var(--gris);
    padding-left: 4px;
}

/* ===== Perfil del sidebar rediseñado (sin avatar, logout abajo en rojo) ===== */
@media (min-width: 1000px) {
    .sidebar-perfil {
        display: block !important;
        margin-top: auto;
        padding: 14px;
        border: 1px solid var(--borde);
        border-radius: var(--r-md);
        background: var(--card);
    }

    .sidebar-perfil .perfil-info {
        margin-bottom: 12px;
    }

    .perfil-nombre {
        font-weight: 700;
        font-size: .92rem;
        color: var(--tinta);
        text-transform: capitalize;
        white-space: normal;
        /* nombre completo, sin cortar */
        overflow: visible;
        text-overflow: clip;
        line-height: 1.3;
    }

    .perfil-correo {
        font-size: .78rem;
        color: var(--gris);
        white-space: normal;
        /* correo completo, sin cortar */
        overflow: visible;
        text-overflow: clip;
        word-break: break-all;
        /* parte el correo si es muy largo */
        margin: 2px 0 0;
    }

    .sidebar-perfil form {
        margin: 0;
    }

    .perfil-logout-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 9px;
        background: var(--rojo-bg);
        color: var(--rojo);
        border: 1px solid transparent;
        border-radius: var(--r-sm);
        font-family: var(--fuente);
        font-size: .85rem;
        font-weight: 700;
        cursor: pointer;
        transition: background .15s ease, border-color .15s ease;
    }

    .perfil-logout-btn svg {
        width: 16px;
        height: 16px;
    }

    .perfil-logout-btn:hover {
        background: #F5DBD4;
        border-color: #E8B9AC;
    }
}

/* Landing: bloque de cierre */
.landing-cierre {
    text-align: center;
    background: linear-gradient(135deg, var(--morado), var(--morado-oscuro));
    border: none;
    color: #fff;
}

.landing-cierre h2 {
    color: #fff;
}

.landing-cierre .subtitulo {
    color: rgba(255, 255, 255, .85);
}

.landing-cierre .acciones {
    justify-content: center;
    margin-top: 16px;
}

.landing-cierre .boton {
    background: #fff;
    color: var(--morado);
    border-color: #fff;
}

.landing-cierre .boton:hover {
    background: var(--crema-suave);
    border-color: var(--crema-suave);
}

.auth-enlace-olvido {
    text-align: center;
    margin: 14px 0 0;
    font-size: .9rem;
}

/* ============================================================
   AJUSTES MÓVIL (≤ 999px)
   ============================================================ */
@media (max-width: 999px) {

    /* Stats compactas: ícono a la izquierda, texto al lado */
    .tarjeta.resumen {
        padding: 16px;
    }

    .panel-dashboard .d-stats .tarjeta.resumen {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        column-gap: 14px;
        align-items: center;
    }

    .panel-dashboard .d-stats .stat-icono {
        grid-row: 1 / 3;
        margin-bottom: 0;
    }

    .panel-dashboard .d-stats .etiqueta {
        align-self: end;
        margin: 0;
    }

    .panel-dashboard .d-stats .resumen h2 {
        margin: 0;
    }

    .panel-dashboard .d-stats .resumen p,
    .panel-dashboard .d-stats .resumen .stat-texto {
        grid-column: 1 / -1;
        margin-top: 4px;
    }

    /* Las 4 stats en 2x2 */
    .panel-dashboard .d-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Tarjeta de balance más compacta */
    .tarjeta-destacada {
        padding: 22px;
    }

    .monto-grande {
        font-size: 2.4rem;
        margin-bottom: 16px;
    }

    /* Presupuesto: altura natural, campo + botón apilados */
    section.d-presupuesto.tarjeta {
        height: auto !important;
        display: block !important;
    }

    .d-presupuesto .formulario-presupuesto {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
    }

    .d-presupuesto .formulario-presupuesto .campo {
        flex: none !important;
        width: 100%;
    }

    .d-presupuesto .formulario-presupuesto .boton {
        width: 100%;
        margin: 0 !important;
    }

    /* Barra inferior: íconos más grandes */
    .barra-nav {
        height: 76px;
    }
}

@media (max-width: 480px) {
    .panel-dashboard .d-stats {
        gap: 10px;
    }

    .panel-dashboard .d-stats .tarjeta.resumen {
        padding: 14px;
    }

    .panel-dashboard .d-stats .resumen h2 {
        font-size: 1.4rem;
    }
}

/* ============================================================
   LISTA DE MOVIMIENTOS EN MÓVIL (≤ 560px) — botones verticales
   ============================================================ */
@media (max-width: 560px) {
    .lista-movimientos li {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        column-gap: 12px;
        row-gap: 6px;
        padding: 14px 2px !important;
        align-items: center;
    }

    .lista-movimientos .mov-centro {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
        gap: 4px;
    }

    .lista-movimientos .mov-monto-bloque {
        grid-column: 1;
        grid-row: 2;
        margin-left: 0 !important;
        padding-right: 0 !important;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        text-align: left;
    }

    .lista-movimientos .badge-usd {
        margin-left: 0;
    }

    .lista-movimientos .mov-acciones {
        grid-column: 2;
        grid-row: 1 / 3;
        flex-direction: column;
        align-self: center;
        margin-left: 0;
        border-left: none;
        padding-left: 0;
        gap: 8px;
    }

    .lista-movimientos .icono-accion {
        width: 44px !important;
        height: 44px !important;
    }

    .lista-movimientos .icono-accion svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Botones de acción de texto (Saldar, Reabrir, Activar) más táctiles */
    .boton.mini {
        padding: 11px 18px;
        font-size: .92rem;
    }

    /* Tarjetas más compactas */
    .tarjeta {
        padding: 16px;
    }

    /* ----- Lista de personas (una fila compacta) ----- */
    .lista-personas {
        margin: -4px 0;
    }

    .persona-fila {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
        padding: 12px 4px !important;
    }

    .persona-fila .mov-centro {
        flex: 1 1 auto;
        min-width: 0;
        gap: 2px;
    }

    .persona-fila .persona-flecha {
        flex: none;
        order: 2;
        color: var(--gris);
    }

    .persona-fila .mov-monto-bloque {
        flex: none;
        order: 3;
        grid-column: auto;
        grid-row: auto;
        margin-left: 0 !important;
        text-align: right;
        align-items: flex-end;
    }

    .persona-fila .bal-valor,
    .persona-fila .bal-neutro {
        white-space: nowrap !important;
        font-size: .88rem;
    }
}

@media (max-width: 560px) {

    /* Ajustes: ítems más compactos */
    .lista-ajustes {
        gap: 8px;
    }

    .item-ajuste {
        padding: 11px 14px !important;
    }

    .item-icono {
        width: 36px !important;
        height: 36px !important;
    }

    .item-icono svg {
        width: 18px !important;
        height: 18px !important;
    }

    .item-izq {
        gap: 12px;
    }
}

/* Elementos que solo se muestran en móvil */
.solo-movil {
    display: none;
}

@media (max-width: 999px) {
    .solo-movil {
        display: inline-flex;
    }

    /* El botón de nuevo gasto en el header, separado del subtítulo */
    .tarjeta.hero .solo-movil.ancho {
        width: 100%;
        margin-top: 14px;
    }
}

/* Botón del hero que también se ve en PC (Ingresos: la barra lateral solo tiene CTA de gastos) */
@media (min-width: 1000px) {
    .tarjeta.hero .hero-nuevo {
        display: inline-flex;
        width: auto;
        margin-top: 14px;
    }
}

/* ============================================================
   Calendario financiero
   ============================================================ */
.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.cal-titulo {
    font-weight: 800;
    font-size: 1.05rem;
    text-transform: capitalize;
    letter-spacing: -.01em;
}

.cal-cabecera,
.cal-semana {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-semana {
    margin-top: 6px;
}

.cal-cabecera span {
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    color: var(--gris);
    padding: 4px 0;
}

.cal-dia {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px 2px 6px;
    min-height: 52px;
    border-radius: var(--r-md);
    background: var(--crema-suave);
    text-decoration: none;
    color: inherit;
    font-size: .9rem;
    transition: background .15s ease;
}

a.cal-dia:hover {
    background: #EAE6F2;
}

.cal-dia.fuera {
    background: transparent;
    color: var(--gris);
    opacity: .45;
}

.cal-dia.hoy {
    outline: 2px solid var(--morado);
    outline-offset: -2px;
    font-weight: 800;
}

.cal-dia.seleccionado {
    background: var(--morado);
    color: #fff;
}

.cal-numero {
    line-height: 1.2;
}

.cal-puntos {
    display: flex;
    gap: 3px;
    min-height: 6px;
}

.cal-punto {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.cal-punto.ingreso {
    background: var(--morado);
}

.cal-dia.seleccionado .cal-punto.ingreso {
    background: #fff;
}

.cal-punto.fijo {
    background: var(--rojo);
}

.cal-punto.gasto {
    background: #A7ADA5;
}

.cal-punto.deuda {
    background: var(--ambar);
}

/* Rediseño: la barra inferior necesita espacio libre abajo en móvil */
@media (max-width: 999px) {
    .contenedor {
        padding-bottom: 110px;
    }
}

/* ============================================================
   Tarjetas plegables (details/summary nativo, sin JS)
   ============================================================ */
details.plegable summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    user-select: none;
}

details.plegable summary::-webkit-details-marker {
    display: none;
}

details.plegable summary h2 {
    margin: 0;
    font-size: 1.1rem;
}

details.plegable summary .grafico-sub {
    display: block;
    margin-top: 2px;
}

/* Chevron que rota al abrir */
details.plegable summary::after {
    content: '';
    flex: none;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-right: 2.5px solid var(--gris);
    border-bottom: 2.5px solid var(--gris);
    transform: rotate(45deg);
    transition: transform .15s ease;
}

details.plegable[open] summary::after {
    transform: rotate(-135deg);
}

details.plegable[open] summary {
    margin-bottom: 16px;
}

details.plegable+details.plegable {
    margin-top: 18px;
}

/* ============================================================
   Acciones rápidas (speed-dial móvil + menú del sidebar)
   ============================================================ */
.qa-flotante {
    position: fixed;
    right: 18px;
    bottom: 94px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.qa-menu {
    display: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.qa-flotante.abierto .qa-menu {
    display: flex;
}

.qa-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.qa-item:hover {
    text-decoration: none;
}

.qa-etiqueta {
    background: var(--tinta);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: var(--r-full);
    box-shadow: var(--sombra);
    white-space: nowrap;
}

.qa-mini {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    color: var(--morado);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sombra-lg);
}

.qa-mini svg {
    width: 20px;
    height: 20px;
}

.qa-fab {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--morado);
    color: #fff;
    border: none;
    font-size: 1.9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sombra-lg);
    cursor: pointer;
    transition: transform .18s ease, background .18s ease;
}

/* Al abrir, el + rota a × y el botón se oscurece */
.qa-flotante.abierto .qa-fab {
    transform: rotate(45deg);
    background: var(--tinta);
}

/* El menú del sidebar solo existe en PC */
.qa-sidebar {
    display: none;
}

@media (min-width: 1000px) {
    .qa-flotante {
        display: none;
    }

    .qa-sidebar {
        display: block;
    }

    .qa-sidebar button.nav-nuevo {
        width: 100%;
        border: none;
        font-family: var(--fuente);
        font-size: .98rem;
        cursor: pointer;
    }

    .qa-menu-pc {
        display: none;
        flex-direction: column;
        gap: 2px;
        margin: -8px 0 10px;
        background: var(--crema-suave);
        border-radius: var(--r-md);
        padding: 8px;
    }

    .qa-sidebar.abierto .qa-menu-pc {
        display: flex;
    }

    .qa-menu-pc a {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: var(--r-sm);
        color: var(--tinta);
        font-weight: 600;
        font-size: .92rem;
        text-decoration: none;
    }

    .qa-menu-pc a:hover {
        background: #fff;
        color: var(--morado);
        text-decoration: none;
    }

    .qa-menu-pc svg {
        width: 18px;
        height: 18px;
    }
}

.cal-leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 16px;
    font-size: .8rem;
    color: var(--gris);
}

.cal-leyenda span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 480px) {
    .cal-dia {
        min-height: 44px;
        font-size: .82rem;
        padding: 6px 1px 5px;
    }

    .cal-nav .boton.mini {
        padding: 8px 10px;
    }
}
/* Logo como imagen (landing + sidebar) */
.marca-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    display: block;
    margin: 0 auto 4px;
}
.nav-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 10px;
}
.landing-hero .auth-marca {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
@media (max-width: 560px) {
    .feature-card { padding: 16px; }
    .feature-icono {
        width: 38px;
        height: 38px;
        margin-bottom: 8px;
    }
    .feature-card h2 { font-size: 1rem; margin-bottom: 4px; }
    .feature-card p { font-size: .86rem; }
    .landing-hero h1 { margin-bottom: 8px; }
}