/* ==========================================================
   Presupuesto Familiar — sistema de diseño
   Paleta: verdes de crecimiento + ámbar de compromiso.
   El elemento distintivo: la barra de 3 estados del dinero.
   ========================================================== */
:root {
    --pf-fondo: #f7f8f5;
    --pf-tinta: #16241d;
    --pf-primario: #1b4332;      /* verde profundo: dinero sano */
    --pf-primario-suave: #d8e8df;
    --pf-pres: #b9c0c7;          /* presupuestado: gris neutral */
    --pf-comp: #e9a820;          /* comprometido: ámbar de alerta amable */
    --pf-pag: #2d6a4f;           /* pagado: verde firme */
    --pf-exceso: #c1121f;        /* sobregiro */
    --pf-carta: #ffffff;
    --pf-borde: #e3e6df;
    --pf-radio: 14px;
}

body {
    background: var(--pf-fondo);
    color: var(--pf-tinta);
    font-family: 'Inter', system-ui, sans-serif;
    display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }
h1, h2, h3, h4, h5, .pf-brand { font-family: 'Sora', 'Inter', sans-serif; }
h1 { font-size: 1.6rem; font-weight: 700; }

/* ---- Navegación ---- */
.pf-navbar { background: var(--pf-primario); }
.pf-navbar .nav-link, .pf-brand { color: #eef4f0 !important; }
.pf-navbar .nav-link:hover { color: #ffffff !important; text-decoration: underline; text-underline-offset: 4px; }
.pf-brand-mark {
    display: inline-grid; place-items: center;
    width: 1.7em; height: 1.7em; border-radius: 50%;
    background: var(--pf-comp); color: var(--pf-primario);
    font-weight: 700; margin-right: .35rem;
}
.pf-demo-banner {
    background: #fdf3d8; color: #6b4e00; border-bottom: 1px solid #f1dc9f;
    padding: .45rem 1rem; text-align: center; font-size: .9rem;
}
.pf-demo-banner a { color: #6b4e00; font-weight: 600; }

/* ---- Tarjetas ---- */
.pf-carta {
    background: var(--pf-carta); border: 1px solid var(--pf-borde);
    border-radius: var(--pf-radio); padding: 1.1rem 1.25rem;
}
.pf-kpi { font-family: 'Sora', sans-serif; font-size: 1.5rem; font-weight: 700; }
.pf-kpi-sub { font-size: .8rem; color: #5b6b62; text-transform: uppercase; letter-spacing: .05em; }
.pf-negativo { color: var(--pf-exceso); }
.pf-positivo { color: var(--pf-pag); }

/* ---- Barra de 3 estados (elemento distintivo) ----
   Fondo gris = presupuesto; encima, pagado (verde) y comprometido (ámbar).
   Si el real rebasa el presupuesto, aparece franja roja. */
.pf-barra {
    position: relative; height: 18px; border-radius: 9px;
    background: repeating-linear-gradient(45deg, #eceff1, #eceff1 6px, #e3e7ea 6px, #e3e7ea 12px);
    overflow: hidden;
}
.pf-barra .pagado { position: absolute; inset: 0 auto 0 0; background: var(--pf-pag); }
.pf-barra .comprometido { position: absolute; top: 0; bottom: 0; background: var(--pf-comp); }
.pf-barra .exceso { position: absolute; top: 0; bottom: 0; right: 0; background: var(--pf-exceso); width: 6px; }
.pf-fila-rubro { padding: .55rem 0; border-bottom: 1px dashed var(--pf-borde); }
.pf-fila-rubro:last-child { border-bottom: 0; }
.pf-rubro-nombre { font-weight: 600; }
.pf-prioridad-etiqueta {
    font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: #51604f; background: var(--pf-primario-suave);
    border-radius: 20px; padding: .15rem .6rem; display: inline-block;
}

/* ---- Puntos de leyenda ---- */
.pf-dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; }
.pf-dot-pres { background: var(--pf-pres); }
.pf-dot-comp { background: var(--pf-comp); }
.pf-dot-pag  { background: var(--pf-pag); }

/* ---- Escalera de metas ---- */
.pf-meta { border-left: 5px solid var(--pf-borde); }
.pf-meta.activa { border-left-color: var(--pf-comp); }
.pf-meta.completa { border-left-color: var(--pf-pag); }
.pf-meta .progress { height: 12px; border-radius: 6px; }
.pf-meta .progress-bar { background: var(--pf-pag); }
.pf-meta.bloqueada { opacity: .55; }
.pf-meta-orden {
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.2rem;
    color: var(--pf-primario);
}

/* ---- Tablas y formularios ---- */
.table { --bs-table-bg: transparent; }
.pf-estado { font-size: .75rem; font-weight: 600; border-radius: 20px; padding: .15rem .55rem; }
.pf-estado-0 { background: #eceff1; color: #4d5a63; }
.pf-estado-1 { background: #fdf3d8; color: #8a6400; }
.pf-estado-2 { background: #ddeee5; color: #1b4332; }
.btn-pf { background: var(--pf-primario); color: #fff; border: 0; }
.btn-pf:hover { background: #143527; color: #fff; }

/* Distintivo de partida a meses fijos (MSI): avance k/N */
.pf-msi-badge { background: #fdf3d8; color: #8a6400; font-weight: 600; font-size: .7rem; }

/* Campo con autoguardado confirmado: verde = ya está guardado */
.pf-guardado, select.pf-guardado, input.pf-guardado {
    border-color: var(--pf-pag) !important;
    background-color: #eaf5ef !important;
    box-shadow: 0 0 0 2px rgba(45, 106, 79, .15);
    transition: background-color .2s ease, border-color .2s ease;
}

/* Enlaces de filtrado rápido en tablas: un clic filtra por esa columna/valor */
a.pf-filtro-col {
    color: inherit; text-decoration: none;
    border-bottom: 1px dotted #9aa79f; cursor: pointer;
}
a.pf-filtro-col:hover { color: var(--pf-primario); border-bottom-color: var(--pf-primario); }

/* Chip del tipo de cuenta (sección Cuentas) */
.pf-cuenta-chip {
    display: inline-block; background: var(--pf-primario-suave); color: var(--pf-primario);
    border-radius: 20px; padding: .1rem .6rem; font-size: .78rem; font-weight: 600; white-space: nowrap;
}

.pf-footer {
    border-top: 1px solid var(--pf-borde); padding: .8rem 0; margin-top: 2rem;
    font-size: .82rem; color: #5b6b62; background: #f0f2ec;
}

/* ---- Pantalla de login ---- */
.pf-login-body { background: linear-gradient(160deg, #1b4332 0%, #2d6a4f 55%, #40916c 100%); }
.pf-login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.pf-login-card { width: 100%; max-width: 380px; box-shadow: 0 18px 48px rgba(0,0,0,.25); }
.pf-login-mark {
    display: inline-grid; place-items: center;
    width: 3rem; height: 3rem; border-radius: 50%;
    background: var(--pf-comp); color: var(--pf-primario);
    font-weight: 700; font-size: 1.5rem; margin-bottom: .5rem;
}

/* ---- Usuario en la barra ---- */
.pf-usuario { color: #dfeee6; font-size: .85rem; }
.pf-usuario-link { text-decoration: none; }
.pf-usuario-link:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.pf-logout-btn {
    background: transparent; border: 1px solid rgba(255,255,255,.4);
    color: #eef4f0; border-radius: 20px; padding: .15rem .8rem; font-size: .85rem;
}
.pf-logout-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---- Menú "Configuración" tipo información ---- */
.pf-navbar .dropdown-toggle.nav-link { color: #eef4f0 !important; }
.pf-menu-config {
    width: 320px; max-width: 92vw; padding: .35rem; border: 1px solid var(--pf-borde);
    border-radius: var(--pf-radio); box-shadow: 0 16px 40px rgba(0,0,0,.18);
}
.pf-menu-config .dropdown-header {
    font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: #8a978f; padding: .4rem .6rem .2rem;
}
.pf-menu-item {
    display: flex; gap: .65rem; align-items: flex-start;
    padding: .5rem .6rem; border-radius: 10px; white-space: normal;
}
.pf-menu-item:hover, .pf-menu-item:focus { background: var(--pf-primario-suave); }
.pf-menu-ico {
    flex: 0 0 auto; width: 2rem; height: 2rem; display: inline-grid; place-items: center;
    border-radius: 8px; background: #f4f7f3; font-size: 1.05rem;
}
.pf-menu-text { display: flex; flex-direction: column; line-height: 1.25; }
.pf-menu-title { font-weight: 600; color: var(--pf-tinta); }
.pf-menu-desc { font-size: .78rem; color: #5b6b62; }

/* ---- Centro de notificaciones (campana) ---- */
.pf-notif-btn {
    position: relative; display: inline-grid; place-items: center;
    width: 2.1rem; height: 2.1rem; border-radius: 50%;
    background: transparent; border: 1px solid rgba(255,255,255,.28);
    color: #eef4f0; cursor: pointer; padding: 0;
}
.pf-notif-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.pf-notif-badge {
    position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
    padding: 0 4px; border-radius: 9px; background: var(--pf-comp); color: var(--pf-primario);
    font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px var(--pf-primario);
}
.pf-notif-panel {
    width: 340px; max-width: 92vw; padding: 0; border: 1px solid var(--pf-borde);
    border-radius: var(--pf-radio); box-shadow: 0 16px 40px rgba(0,0,0,.18); overflow: hidden;
}
.pf-notif-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem .9rem; font-family: 'Sora', sans-serif; font-weight: 700;
    color: var(--pf-primario); border-bottom: 1px solid var(--pf-borde); background: #f4f7f3;
}
.pf-notif-total {
    background: var(--pf-primario-suave); color: var(--pf-primario);
    border-radius: 20px; padding: .05rem .5rem; font-size: .72rem; font-weight: 700;
}
.pf-notif-scroll { max-height: 60vh; overflow-y: auto; }
.pf-notif-section {
    padding: .4rem .9rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: #8a978f; background: #fafbf9;
}
.pf-notif-section-nueva { color: #8a6400; }
.pf-notif-item {
    display: flex; gap: .6rem; align-items: flex-start;
    padding: .55rem .9rem; border-bottom: 1px solid var(--pf-borde);
}
.pf-notif-item:last-child { border-bottom: 0; }
.pf-notif-item.nueva { background: #fdf9ec; border-left: 3px solid var(--pf-comp); }
.pf-notif-ico {
    flex: 0 0 auto; width: 1.9rem; height: 1.9rem; display: inline-grid; place-items: center;
    border-radius: 50%; background: var(--pf-primario-suave); font-size: 1rem;
}
.pf-notif-body { min-width: 0; }
.pf-notif-titulo { font-weight: 600; font-size: .88rem; color: var(--pf-tinta); }
.pf-notif-msg { font-size: .8rem; color: #5b6b62; word-break: break-word; }
.pf-notif-time { font-size: .72rem; color: #9aa79f; margin-top: .1rem; }
.pf-notif-empty { padding: 1.4rem .9rem; text-align: center; color: #7c8a81; font-size: .85rem; line-height: 1.45; }
/* El panel se ancla a la derecha del botón (sin Popper: data-bs-display="static"). */
.pf-notif .pf-notif-panel { right: 0; left: auto; }

/* En pantallas chicas el panel se fija centrado bajo la barra:
   anclado al botón se salía de la resolución de la pantalla. */
@media (max-width: 991.98px) {
    .pf-notif { position: static; }
    .pf-notif .pf-notif-panel {
        position: fixed;
        top: 4.4rem;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(94vw, 380px);
        max-width: 94vw;
    }
    .pf-notif-scroll { max-height: 55vh; }
    /* En móvil no hay doble menú: al abrir la hamburguesa, el menú
       "Configuración" ya viene desplegado completo. Su encabezado queda
       como etiqueta de sección, no como botón. */
    .pf-menu-config {
        display: block; position: static;
        width: 100%; border: 0; box-shadow: none; margin: 0;
    }
    .pf-navbar .navbar-nav .nav-item.dropdown > .dropdown-toggle { pointer-events: none; opacity: .85; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
