:root {
    /* ---------- Paleta del Escudo (Vino, Amarillo, Azul) ---------- */
    --vino-900: #4A0F1F; 
    --vino-800: #5C1629;
    --vino-700: #6D1B33;
    --vino-600: #802B4A;
    
    --amarillo-500: #D4A24C; 
    --amarillo-400: #E0B869;

    --azul-900: #1E3B47;
    --azul-700: #2E5666;
    --azul-600: #3D6B7D;

    /* ---------- Neutros ---------- */
    --tinta:         #1a1a1a;
    --pizarra-700:   #4A3D42;
    --pizarra-500:   #786A6F;
    --linea:         #EAE3E6;
    --lienzo:        #F8F5F3;
    --blanco:        #FFFFFF;

    /* ---------- Semánticos ---------- */
    --rojo-500: #B94A3D;
    --verde-500: #5A8060;

    /* ---------- Sombras ---------- */
    --sombra-tarjeta: 0 1px 2px rgba(74,15,31,.04), 0 4px 14px -6px rgba(74,15,31,.10);
    --sombra-elevada: 0 2px 4px rgba(74,15,31,.06), 0 12px 28px -10px rgba(74,15,31,.18);
    --sombra-modal: 0 4px 8px rgba(74,15,31,.1), 0 32px 80px -16px rgba(74,15,31,.45);

    /* ---------- Layout ---------- */
    --sidebar-w:            230px;
    --sidebar-w-collapsed:  68px;
    --sidebar-item-h:       38px;
    --topbar-h:             76px;
    --radius-sm:            8px;
    --radius:               12px;
    --transicion:           .22s cubic-bezier(.4, 0, .2, 1);

    /* ---------- Tipografía ---------- */
    --fuente: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* ---------- Bootstrap overrides ---------- */
    --bs-body-font-family: var(--fuente);
    --bs-body-color:       var(--tinta);
    --bs-body-bg:          var(--lienzo);
    --bs-border-color:     var(--linea);
    --bs-primary:          var(--vino-600);
    --bs-primary-rgb:      128, 43, 74;
    --bs-link-color:       var(--vino-600);
    --bs-link-hover-color: var(--vino-800);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--fuente);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--tinta);
    background: var(--lienzo);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--vino-600); text-decoration: none; }
a:hover { color: var(--vino-800); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--fuente);
    font-weight: 700;
    color: var(--vino-800);
    letter-spacing: -.01em;
}

/* ============================================================
   SIDEBAR (Vino sólido con brillo dorado en esquinas)
   ============================================================ */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    
    /* Fondo base vino + Brillos radiales sutiles en esquinas superior e inferior */
    background: 
        radial-gradient(circle at top left, rgba(212, 162, 76, 0.15) 0%, transparent 40%),
        radial-gradient(circle at bottom left, rgba(212, 162, 76, 0.08) 0%, transparent 40%),
        var(--vino-900); 
        
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--transicion), transform var(--transicion);
    overflow: hidden;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 4px 0 24px -10px rgba(0,0,0,.3);
}

/* ---------- Brand ---------- */
.sidebar-brand {
    height: 76px;
    min-height: 76px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    color: #fff;
    text-decoration: none;
    overflow: hidden;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,.08);
    transition: padding var(--transicion), gap var(--transicion);
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }

/* El logo resalta con un borde amarillo del escudo */
.sidebar-brand__mark {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%; 
    background: rgba(255,255,255,.05);
    border: 2px solid var(--amarillo-500); 
    overflow: hidden;
    transition: width var(--transicion), height var(--transicion);
}

.sidebar-brand__logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    display: block;
}

.sidebar-brand__initials {
    display: none;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--amarillo-500);
    line-height: 1;
}
.sidebar-brand__mark.is-placeholder {
    background: var(--vino-800);
}
.sidebar-brand__mark.is-placeholder .sidebar-brand__initials {
    display: block;
}

.sidebar-brand__text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    transition: opacity .18s ease;
}
.sidebar-brand__title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .14em;
    color: #fff;
    line-height: 1.1;
}
.sidebar-brand__sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--amarillo-400); 
    letter-spacing: .06em;
    margin-top: 4px;
}

.sidebar-gold-line { display: none; }

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 0 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.18);
    border-radius: 3px;
}
.sidebar-section {
    padding: 0 8px;
    margin-bottom: 14px;
}
.sidebar-section__label {
    display: block;
    padding: 10px 12px 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    white-space: nowrap;
}

.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--sidebar-item-h);
    padding: 0 12px;
    margin: 3px 0;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.75);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--transicion), color var(--transicion);
    position: relative;
}
.sidebar-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}
.sidebar-item.active {
    background: rgba(212, 162, 76, 0.15);
    color: #fff;
    font-weight: 600;
}
.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--amarillo-500);
    border-radius: 0 3px 3px 0;
}

.sidebar-item__icon {
    font-size: 17px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    color: currentColor;
}

.sidebar-item__label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 901px) {
    html.sidebar-collapsed body .app-sidebar {
        width: var(--sidebar-w-collapsed);
    }
    html.sidebar-collapsed body .sidebar-brand {
        justify-content: center;
        padding: 0;
        gap: 0;
    }
    html.sidebar-collapsed body .sidebar-brand__mark {
        width: 36px;
        height: 36px;
    }
    html.sidebar-collapsed body .sidebar-brand__text {
        opacity: 0;
        width: 0;
        pointer-events: none;
    }
    html.sidebar-collapsed body .sidebar-section {
        padding: 0 6px;
        margin-bottom: 10px;
    }
    html.sidebar-collapsed body .sidebar-section__label {
        opacity: 0;
        height: 0;
        padding: 0;
        overflow: hidden;
    }
    html.sidebar-collapsed body .sidebar-item {
        justify-content: center;
        padding: 0;
        gap: 0;
    }
    html.sidebar-collapsed body .sidebar-item__icon {
        width: auto;
        font-size: 18px;
    }
    html.sidebar-collapsed body .sidebar-item__label {
        display: none;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42,26,32,.5);
    z-index: 1035;
    opacity: 0;
    transition: opacity var(--transicion);
}

@media (max-width: 900px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }
    body.sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }
    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }
    body.sidebar-open { overflow: hidden; }
}

/* ============================================================
   WRAPPER
   ============================================================ */
.app-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transicion);
}

@media (min-width: 901px) {
    html.sidebar-collapsed body .app-wrapper {
        margin-left: var(--sidebar-w-collapsed);
    }
}
@media (max-width: 900px) {
    .app-wrapper { margin-left: 0; }
}

/* ============================================================
   TOPBAR (Vino sólido con brillo dorado en las esquinas)
   ============================================================ */
.app-topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    
    /* Fondo base vino + Brillo radial en la esquina superior derecha (donde está el usuario) */
    background: 
        radial-gradient(circle at top right, rgba(212, 162, 76, 0.2) 0%, transparent 40%),
        radial-gradient(circle at bottom left, rgba(212, 162, 76, 0.05) 0%, transparent 30%),
        var(--vino-900);
    
    border-bottom: 1px solid var(--vino-800);
    border-left: none; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 4px 16px -4px rgba(0,0,0,.2);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1 1 auto;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-toggle-sidebar {
    width: 38px;
    height: 38px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 18px;
    transition: background var(--transicion), color var(--transicion);
    padding: 0;
    flex-shrink: 0;
}
.btn-toggle-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.topbar-heading {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
    overflow: hidden;
}
.topbar-panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #FFFFFF;
    text-shadow: 0 1px 3px rgba(0,0,0,.3);
    letter-spacing: .005em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-panel-sub {
    font-size: 11.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.topbar-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 6px;
}
/* ============================================================
   TOPBAR (Diseño simple y elegante)
   ============================================================ */

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 12px 4px 4px;
    /* Quitamos la caja oscura para que se vea limpio */
    background: transparent; 
    border: none;
}

/* Hacemos el avatar más grande y llamativo, como un sello dorado */
.topbar-user__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff; /* Fondo blanco limpio */
    color: var(--vino-900); /* Letra vino oscuro */
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); /* Sombra más sutil */
}

.topbar-user__info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: left;
    min-width: 0;
}

.topbar-user__name {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.topbar-user__role {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--amarillo-400); /* El rol en color dorado para que resalte */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* El botón de salir ahora se ve como un botón fantasma (transparente con borde) */
.topbar-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    background: transparent; 
    border: 1px solid rgba(255, 255, 255, 0.3); /* Borde un poco más visible */
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transicion);
    margin-left: 8px;
}

.topbar-logout:hover {
    /* Aquí devolvemos el dorado al pasar el mouse */
    background: var(--amarillo-500); 
    color: var(--vino-900); 
    border-color: var(--amarillo-400);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 162, 76, 0.3);
}
.topbar-logout:active {
    transform: translateY(0);
}

.topbar-logout i {
    font-size: 16px;
    line-height: 1;
}

.topbar-logout__label {
    line-height: 1;
}

/* ============================================================
   RESPONSIVE TOPBAR
   ============================================================ */
@media (max-width: 992px) {
    .topbar-panel-sub { display: none; }
    .topbar-user__name { max-width: 120px; }
}

@media (max-width: 768px) {
    .topbar-logout {
        padding: 0;
        width: 38px;
        justify-content: center;
    }
    .topbar-logout__label {
        display: none;
    }
}

@media (max-width: 600px) {
    .topbar-user__info { display: none; }
    .topbar-panel-title { font-size: 14px; }
    .topbar-divider { display: none; }
    .topbar-right { gap: 8px; }
    .topbar-user { padding: 4px; }
}

/* ============================================================
   CONTENIDO
   ============================================================ */
.app-content {
    flex: 1;
    padding: 24px 26px 40px;
    max-width: 1600px;
    width: 100%;
}

@media (max-width: 600px) {
    .app-content { padding: 18px 16px 32px; }
}

.page-head {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--linea);
}
.page-head h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--vino-800);
    margin: 0 0 4px;
    letter-spacing: -.015em;
}
.page-head p {
    font-size: 13.5px;
    color: var(--pizarra-500);
    margin: 0;
}
@media (max-width: 600px) {
    .page-head h1 { font-size: 22px; }
}
.sigba-card {
    background: var(--blanco);
    border-radius: var(--radius);
    box-shadow: var(--sombra-tarjeta);
    border: 1px solid var(--linea);
    padding: 20px;
}