:root{
    /* ---- Marca (sin cambios) ---- */
    --brand: #859C4C;
    --brand-dark: #6c8040;
    --brand-darker: #3f4c26;
    --brand-light: #BDDBBB;
    --brand-tint: #EEF2E7;

    /* ---- Neutros ---- */
    --ink: #262B1D;          /* texto principal */
    --on-dark: #ffffff;
    --on-light: #333B22;     /* encabezados sobre fondo claro: tinta oscura, no verde puro */
    --muted: #6F775F;        /* texto secundario */
    --border: #E2E6D9;       /* bordes neutros */
    --bg: #F5F6F1;           /* fondo de pagina, plano */
    --surface: #ffffff;      /* fondo de tarjetas */

    /* ---- Sombras y radios ---- */
    --shadow-sm: 0 1px 2px rgba(38,43,29,.05), 0 1px 1px rgba(38,43,29,.04);
    --shadow-md: 0 2px 10px rgba(38,43,29,.07);
    --shadow-lift: 0 6px 20px rgba(38,43,29,.10);
    --radius: 12px;
    --radius-sm: 8px;
    --ease: cubic-bezier(.22,1,.36,1);
}

*{ box-sizing:border-box; }

body{
    background: var(--bg);
    font-family:'Roboto', Arial, sans-serif;
    color: var(--ink);
    font-size: 0.94rem;
    -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6{ font-family:'Roboto', Arial, sans-serif; letter-spacing: -0.01em; }

/* Encabezados y textos de marca sobre fondo claro: tinta oscura legible, no verde saturado */
h3.fw-bold, .card-title{ color: var(--on-light); }

#wrapper{ min-height:100vh; }

/* ============ Sidebar (como estaba originalmente: degradado + botones flotantes) ============ */
.sidebar{
    width:260px; min-width:260px; color:var(--on-dark);
    background: linear-gradient(165deg, var(--brand), var(--brand-dark));
    display:flex; flex-direction:column; position:sticky; top:0; height:100vh;
    border-radius: 0 28px 28px 0;
    box-shadow: 14px 0 40px rgba(30,40,15,.30), 4px 0 12px rgba(30,40,15,.18);
    transition: left .3s var(--ease), width .25s var(--ease), min-width .25s var(--ease);
    overflow: hidden;
}
/* La lista de navegación es la única parte que se desplaza — la marca de arriba y
   el pie de abajo (usuario/salir) quedan siempre fijos y visibles. Sin esto, con
   muchos ítems en el menú (ej. cuenta de administrador) los últimos botones
   quedaban cortados fuera de la pantalla, sin ninguna forma de alcanzarlos. */
.sidebar .nav.flex-column{
    flex: 1 1 auto;
    min-height: 0; /* sin esto, un hijo flex no se encoge por debajo de su
        contenido, y el overflow-y de abajo nunca llega a activarse de verdad */
    flex-wrap: nowrap !important; /* Bootstrap pone flex-wrap:wrap en .nav por
        defecto — combinado con la altura limitada, eso hacía que los botones
        que no cabían se acomodaran en una columna nueva al lado, en vez de
        desplazarse hacia abajo. Esto lo bloquea y fuerza una sola columna. */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
}
.sidebar .nav.flex-column::-webkit-scrollbar{ width:6px; }
.sidebar .nav.flex-column::-webkit-scrollbar-track{ background:transparent; }
.sidebar .nav.flex-column::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.35); border-radius:999px; }
.sidebar .nav.flex-column::-webkit-scrollbar-thumb:hover{ background:rgba(255,255,255,.55); }
.sidebar-brand{
    padding:22px 18px; border-bottom:1px solid rgba(255,255,255,.18);
    display:flex; align-items:center; justify-content:center;
    position: relative;
}
.sidebar-brand img{ max-width:100%; height:auto; max-height:46px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.15)); }
.sidebar-toggle-btn{
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.18); border: none; color:#fff;
    width:28px; height:28px; border-radius:50%; flex-shrink:0;
    display:flex; align-items:center; justify-content:center;
    transition: background .2s var(--ease);
}

.sidebar .nav-link, .sidebar-user-btn{
    background: linear-gradient(135deg, #ffffff, #eef3e6);
    color: var(--brand-dark);
    border: 1px solid rgba(255,255,255,.6);
    padding:12px 18px; margin:6px 12px; border-radius:999px;
    box-shadow: 0 6px 16px rgba(0,0,0,.18);
    transition: box-shadow .3s var(--ease), transform .2s var(--ease), background .3s var(--ease);
    white-space: nowrap;
}
.sidebar .nav-link i, .sidebar-user-btn i{ margin-right:8px; color: inherit; }
.sidebar .nav-link:hover, .sidebar .nav-link:focus,
.sidebar-user-btn:hover, .sidebar-user-btn:focus{
    background: linear-gradient(135deg, #ffffff, var(--brand-light));
    color: var(--brand-dark);
    box-shadow: 0 10px 22px rgba(0,0,0,.24);
    transform: translateY(-2px);
}
.sidebar .nav-link.active{
    background: linear-gradient(135deg, #ffffff, var(--brand-light));
    box-shadow: 0 10px 22px rgba(0,0,0,.24);
}
.sidebar-footer{ margin-top:auto; padding:16px 18px; border-top:1px solid rgba(255,255,255,.18); white-space: nowrap; }
.sidebar-user-btn{
    display:flex; align-items:center; text-decoration:none; width:100%; margin:6px 0 10px;
}
.sidebar-user-btn img{ box-shadow:0 2px 8px rgba(0,0,0,.15); }
.sidebar-footer .btn-outline-light{
    border-radius:999px; border-color:rgba(255,255,255,.6);
    transition: all .25s var(--ease);
}
.sidebar-footer .btn-outline-light:hover{ background:#fff; color:var(--brand-dark); transform: translateY(-2px); }

.sidebar-toggle-btn:hover{ background: rgba(255,255,255,.32); }

/* Sidebar oculto (solo en escritorio): se colapsa a 0, el botón para volver a mostrarlo queda flotando */
@media (min-width: 992px){
    body.sidebar-collapsed .sidebar{ width:0; min-width:0; border-radius:0; box-shadow:none; }
    body.sidebar-collapsed .content-area > main{ padding-left: 4.2rem !important; }
}
#btnExpandirSidebar{
    display:none; position:fixed; top:20px; left:16px; z-index:1040;
    width:34px; height:34px; border-radius:50%; align-items:center; justify-content:center;
    background: var(--brand); color:#fff; border:none; box-shadow: var(--shadow-md);
    transition: background .2s var(--ease);
}
#btnExpandirSidebar:hover{ background: var(--brand-dark); }
body.sidebar-collapsed #btnExpandirSidebar{ display:flex; }

.content-area{ min-width:0; }

/* ============ Tarjetas: superficie solida, borde fino, sombra sutil ============ */
.card, .card-stat{
    border:1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s var(--ease);
}
.card:hover, .card-stat:hover{
    box-shadow: var(--shadow-md);
}
.card-stat{ padding: 1rem 1.1rem; }

/* ============ Botones: esquinas moderadas, sin gradientes ni desplazamiento ============ */
.btn{
    border-radius: var(--radius-sm) !important;
    font-weight:500;
    font-size: 0.9rem;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn-sm{ border-radius: 7px !important; }

.btn-brand{
    background: var(--brand);
    color: var(--on-dark);
    border: 1px solid var(--brand);
}
.btn-brand:hover, .btn-brand:focus{
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: var(--on-dark);
}

.btn-outline-secondary{
    color: var(--on-light); border:1px solid var(--border);
    background: var(--surface);
}
.btn-outline-secondary:hover{
    background: var(--brand-tint); border-color: var(--brand-light); color:var(--brand-darker);
}

/* ============ Enlaces ============ */
a{ color: var(--brand-dark); text-decoration: none; transition: color .15s var(--ease); }
a:hover{ color: var(--brand-darker); text-decoration: underline; }

/* ============ Badges: siguen en pildora (es una convencion estandar para estados) ============ */
.badge{ border-radius:999px !important; padding:.4em .85em; font-weight:500; font-size: 0.74rem; }
.badge.bg-primary{ background: var(--brand) !important; color:var(--on-dark) !important; }
.badge.bg-secondary{ background: var(--brand-tint) !important; color:var(--brand-darker) !important; }

/* ============ Formularios ============ */
.form-control, .form-select{
    border-radius: var(--radius-sm); border:1px solid var(--border);
    background: var(--surface);
    font-size: 0.9rem;
    transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.form-control:focus, .form-select:focus{
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(133,156,76,.15);
}
.form-label{ font-size: 0.83rem; font-weight: 500; color: var(--on-light); margin-bottom: 4px; }
.form-text{ font-size: 0.78rem; }

/* ============ Tablas: compactas, bordes limpios (herramienta interna = mas datos visibles) ============ */
.table{ font-size: 0.88rem; }
.table thead th{
    border-bottom:1px solid var(--border); border-top: none;
    color:var(--muted); font-weight:600; font-size: 0.72rem;
    text-transform: uppercase; letter-spacing: .04em;
    background: transparent;
    padding-top: .55rem; padding-bottom: .55rem;
}
.table tbody td{ padding-top: .55rem; padding-bottom: .55rem; vertical-align: middle; }
.table tbody tr{ transition: background .12s var(--ease); }
.table tbody tr:hover{ background: var(--brand-tint); }
.table-light{ background: transparent; }

/* Evita que los menus desplegables (dropdown) dentro de tablas queden recortados
   por el contenedor de scroll horizontal o por el propio redondeado de la tabla */
.table-responsive{ overflow-y: visible; }
.card{ overflow: visible; }

.nav-tabs{ border-bottom-color: var(--border); }
.nav-tabs .nav-link{ border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--muted); border: none; font-size: 0.9rem; }
.nav-tabs .nav-link.active{ color:var(--on-light); border-bottom:2px solid var(--brand); background: transparent; font-weight: 500; }

/* ============ Login ============ */
.login-wrapper{
    min-height:100vh; display:flex; align-items:center; justify-content:center;
    background: var(--brand-darker);
    position:relative;
}
.login-card{
    max-width:380px; width:100%; text-align:center;
    border-radius: 16px;
    background: var(--surface);
    border:1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0,0,0,.20);
}
.login-card img{ max-width:190px; height:auto; margin-bottom:8px; }

.navbar.bg-white{
    background: var(--surface) !important;
    box-shadow: var(--shadow-sm);
}
.navbar-brand-logo{ height:30px; width:auto; }

.alert{ border-radius: var(--radius-sm); border:1px solid transparent; box-shadow: none; font-size: 0.88rem; }
.alert-light{ background: var(--brand-tint); border-color: var(--border); color: var(--on-light); }

/* Modales: coherentes con las tarjetas */
.modal-content{ border-radius: var(--radius); border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.modal-header{ border-bottom-color: var(--border); }
.modal-footer{ border-top-color: var(--border); }

/* Progreso (barra de avance de cartera) */
.progress{ border-radius: 999px; background: var(--brand-tint); }

@media (max-width: 991px){
    .sidebar{ position:fixed; left:-260px; z-index:1050; }
    .sidebar.show{ left:0; }
    .sidebar-toggle-btn, #btnExpandirSidebar{ display:none !important; }
}

/* ============ Overlay de carga (mariposa animada) ============ */
#overlayCarga{
    position: fixed; inset: 0; z-index: 3000;
    background: rgba(245,246,241,.94);
    display: none; align-items: center; justify-content: center; flex-direction: column;
}
#overlayCarga.mostrar{ display: flex; }
#overlayCarga img{
    width: 84px; height: auto;
    animation: mariposa-flutter 1.3s ease-in-out infinite;
}
#overlayCarga .texto-carga{
    margin-top: 16px; color: var(--on-light); font-weight: 500;
    font-size: .88rem; letter-spacing: .03em;
}
@keyframes mariposa-flutter{
    0%, 100% { transform: scale(1) rotate(-4deg); opacity: .5; }
    50%      { transform: scale(1.12) rotate(4deg); opacity: 1; }
}
