/* ============================================================
   LÁNZALO - Estilos globales
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green:        #1D9E75;
    --green-dark:   #178A64;
    --green-light:  #E1F5EE;
    --green-mid:    #0F6E56;
    --amber:        #BA7517;
    --amber-light:  #FAEEDA;
    --blue:         #378ADD;
    --blue-light:   #E6F1FB;
    --red:          #E24B4A;
    --red-light:    #FCEBEB;
    --gray:         #888780;
    --gray-light:   #F4F2EB;
    --bg-soft:      #F8F7F3;
    --gray-border:  #E0DDD4;
    --text:         #1A1A18;
    --text-mid:     #444441;
    --text-soft:    #6B6965;
    --text-muted:   #9B9890;
    --white:        #FFFFFF;
    --sidebar-w:    210px;
    --topbar-h:     52px;
    --radius-sm:    6px;
    --radius-md:    8px;
    --radius-lg:    12px;
    --radius-xl:    16px;

    /* Sistema de sombras con elevación */
    --shadow-xs: 0 1px 3px rgba(0,0,0,0.05);
    --shadow:    0 2px 12px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.12);

    /* Tipografía escalable — escala 1.25 */
    --fs-2xs:    10px;
    --fs-xs:     12px;
    --fs-sm:     13px;
    --fs-base:   14px;
    --fs-md:     15px;
    --fs-lg:     18px;
    --fs-xl:     20px;
    --fs-2xl:    24px;
    --fs-3xl:    30px;
    --fs-4xl:    36px;
    --fs-5xl:    48px;

    /* Fuentes */
    --font-display: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }

body {
    font-family: var(--font-body);
    background: var(--gray-light);
    color: var(--text);
    line-height: 1.5;
}

/* Reduce motion para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 0.5px solid var(--gray-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 100;
}
.topbar-logo-icon { height: 26px; width: auto; vertical-align: middle; margin-right: 6px; margin-top: -2px; }
.auth-logo-icon  { height: 36px; width: auto; vertical-align: middle; margin-right: 8px; margin-bottom: 2px; }
.topbar-logo {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.4px;
    display: flex;
    align-items: center;
    font-family: var(--font-display);
    margin-right: auto;
}
.topbar-logo span { color: var(--green); }
.topbar-ver {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--gray-light);
    border: .5px solid var(--gray-border);
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 8px;
    line-height: 1;
    vertical-align: middle;
    white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 0.5px solid var(--gray-border);
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
    z-index: 90;
    transition: width 0.25s ease, padding 0.25s ease;
}
/* ── Sidebar collapse (modo iconos) ── */
.main-content { transition: margin-left 0.25s ease; }
body.sb-no-transition .sidebar,
body.sb-no-transition .main-content { transition: none !important; }

/* Colapsado: 52 px — solo iconos */
body.sb-collapsed .sidebar      { width: 52px; }
body.sb-collapsed .main-content { margin-left: 52px; }
body.sb-collapsed .sidebar-label { display: none; }
body.sb-collapsed .sidebar-item  {
    justify-content: center;
    padding: 10px 0 !important;
    font-size: 0 !important;
    gap: 0;
}
body.sb-collapsed .sidebar-item .sidebar-icon {
    font-size: 18px !important;
    width: auto;
    flex-shrink: 0;
}
body.sb-collapsed .sidebar-badge { display: none; }
body.sb-collapsed .sb-toggle    { left: 52px; }

/* Botón toggle — visible con contraste */
.sb-toggle {
    position: fixed;
    top: 50vh;
    left: var(--sidebar-w);
    transform: translateY(-50%);
    z-index: 95;
    width: 18px;
    height: 46px;
    background: #D8D5CC;
    border: 1px solid #B8B5AC;
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #3A3A38;
    padding: 0;
    box-shadow: 2px 0 6px rgba(0,0,0,.15);
    user-select: none;
    transition: left 0.25s ease, background 0.15s, color 0.15s;
}
.sb-toggle:hover { background: var(--green); color: #fff; border-color: var(--green); }
@media (max-width: 1024px) { .sb-toggle { display: none; } }

/* ── Hamburger button (solo visible en móvil) ── */
.sb-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
    border-radius: 6px;
    flex-shrink: 0;
    transition: background 0.1s;
    margin-right: 2px;
}
.sb-hamburger:hover { background: var(--gray-light); }

/* ── Overlay backdrop del drawer ── */
.sb-overlay {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45);
    z-index: 150;
    animation: sb-fadein .2s ease;
}
.sb-overlay.active { display: block; }
@keyframes sb-fadein { from { opacity:0; } to { opacity:1; } }

/* ── Tablet (769px–1024px): sidebar automático en modo íconos ── */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar,
    body.sb-collapsed .sidebar       { width: 52px !important; }
    .main-content,
    body.sb-collapsed .main-content  { margin-left: 52px !important; }
    .sidebar-label,
    body.sb-collapsed .sidebar-label { display: none !important; }
    .sidebar-item,
    body.sb-collapsed .sidebar-item  {
        justify-content: center !important;
        padding: 10px 0 !important;
        font-size: 0 !important;
        gap: 0 !important;
    }
    .sidebar-item .sidebar-icon,
    body.sb-collapsed .sidebar-item .sidebar-icon {
        font-size: 18px !important;
        width: auto !important;
        flex-shrink: 0;
    }
    .sidebar-badge,
    body.sb-collapsed .sidebar-badge { display: none !important; }
}
.sidebar-section { margin-bottom: 1.25rem; }
.sidebar-label {
    font-size: var(--fs-2xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 0 1rem 0.4rem;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 1rem;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text-soft);
    text-decoration: none;
    cursor: pointer;
    border-right: 2px solid transparent;
    transition: background 0.1s, color 0.1s;
}
.sidebar-item:hover { background: var(--gray-light); color: var(--text); }
.sidebar-item.active {
    background: var(--green-light);
    color: var(--green-mid);
    font-weight: 500;
    border-right-color: var(--green);
}
.sidebar-icon { width: 16px; text-align: center; font-size: var(--fs-md); }
.sidebar-badge {
    margin-left: auto;
    background: var(--gray-light);
    color: var(--text-soft);
    font-size: var(--fs-xs);
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 10px;
}
.sidebar-badge.alerta { background: var(--red-light); color: var(--red); }

/* ============================================================
   CONTENIDO PRINCIPAL
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
}

/* ============================================================
   CABECERA DE PÁGINA
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 10px;
}
.page-title { font-size: var(--fs-xl); font-weight: 700; color: var(--text); font-family: var(--font-display); letter-spacing: -0.3px; }
.page-subtitle { font-size: var(--fs-base); font-weight: 500; color: var(--text-soft); margin-top: 2px; }

/* ============================================================
   CARDS DE MÉTRICAS
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.metric-card {
    background: var(--white);
    border: 0.5px solid var(--gray-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
}
.metric-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-soft); margin-bottom: 6px; }
.metric-value { font-size: var(--fs-2xl); font-weight: 600; color: var(--text); line-height: 1.2; }
.metric-sub { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); margin-top: 4px; }
.metric-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 4px;
}

/* ============================================================
   CARDS GENERALES
   ============================================================ */
.card {
    background: var(--white);
    border: 0.5px solid var(--gray-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card.hoverable:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.card-title { font-size: var(--fs-md); font-weight: 700; color: var(--text); margin-bottom: 1rem; font-family: var(--font-display); }

/* ============================================================
   BARRA DE PROGRESO
   ============================================================ */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-light);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--green);
    transition: width 0.3s;
}

/* ============================================================
   BADGES / ETIQUETAS
   ============================================================ */
.badge {
    display: inline-block;
    font-size: var(--fs-xs);
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 10px;
    white-space: nowrap;
}
.badge-green  { background: var(--green-light);  color: var(--green-mid); }
.badge-amber  { background: var(--amber-light);  color: #633806; }
.badge-blue   { background: var(--blue-light);   color: #0C447C; }
.badge-red    { background: var(--red-light);    color: #A32D2D; }
.badge-gray   { background: var(--gray-light);   color: var(--text-mid); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(0px) !important; }
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(29,158,117,0.35);
}
.btn-secondary {
    background: var(--white);
    color: var(--text-mid);
    border: 0.5px solid var(--gray-border);
}
.btn-secondary:hover {
    background: var(--gray-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-xs);
}
.btn-danger { background: var(--red-light); color: #A32D2D; }
.btn-danger:hover { background: #F5C6C6; transform: translateY(-1px); }
.btn-sm { padding: 5px 12px; font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Focus visible accesible para teclado */
:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.form-hint { font-size: var(--fs-xs); font-weight: 500; color: var(--text-soft); margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    color: var(--text);
    background: #FAFAF8;
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--green);
    background: var(--white);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}
thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 0.5px solid var(--gray-border);
    background: var(--gray-light);
}
tbody td {
    padding: 11px 12px;
    border-bottom: 0.5px solid var(--gray-border);
    color: var(--text);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF8; }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    margin-bottom: 1rem;
}
.alert-success { background: var(--green-light); color: var(--green-mid); border: 1px solid #9FE1CB; }
.alert-error   { background: var(--red-light);   color: #A32D2D;          border: 1px solid #F5C6C6; }
.alert-warning { background: var(--amber-light);  color: #633806;          border: 1px solid #EBC97A; }
.alert-info    { background: var(--blue-light);   color: #0C447C;          border: 1px solid #A8CEEE; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green-mid);
    font-size: var(--fs-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ============================================================
   NOTIFICACIÓN (campana)
   ============================================================ */
.notif-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-soft);
    padding: 4px;
}
.notif-count {
    position: absolute;
    top: 0; right: 0;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   CHIPS DE ROL
   ============================================================ */
.role-chip {
    display: inline-block;
    font-size: var(--fs-2xs);
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--gray-light);
    color: var(--text-soft);
    margin: 1px;
}

/* ============================================================
   GRIDS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.modal-title { font-size: calc(var(--fs-md) + 1px); font-weight: 600; color: var(--text); }
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-soft);
    cursor: pointer;
    padding: 2px 6px;
}
.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    /* Drawer lateral */
    .sidebar {
        width: 82% !important;
        max-width: 300px !important;
        transform: translateX(-100%);
        transition: transform 0.25s ease !important;
        z-index: 160;
        box-shadow: 4px 0 24px rgba(0,0,0,.18);
    }
    .sidebar.open { transform: translateX(0); }

    /* Restaurar estilos normales del sidebar (sin modo colapso) */
    body.sb-collapsed .sidebar          { width: 82% !important; max-width: 300px !important; }
    body.sb-collapsed .main-content     { margin-left: 0 !important; }
    body.sb-collapsed .sidebar-label    { display: block !important; }
    body.sb-collapsed .sidebar-item     {
        justify-content: flex-start !important;
        padding: 8px 1rem !important;
        font-size: var(--fs-base) !important;
        gap: 10px !important;
    }
    body.sb-collapsed .sidebar-item .sidebar-icon { font-size: var(--fs-md) !important; width: 16px !important; }
    body.sb-collapsed .sidebar-badge    { display: inline-flex !important; }

    .main-content { margin-left: 0 !important; padding: 1rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }

    /* Mostrar hamburger */
    .sb-hamburger { display: flex !important; }

    /* Topbar: dar espacio al hamburger */
    .topbar-logo { font-size: var(--fs-base); }
}

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

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-amber  { color: var(--amber); }
.text-soft   { color: var(--text-soft);  font-weight: 500; }
.text-muted  { color: var(--text-muted); font-weight: 500; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: var(--fs-sm); }
.text-xs     { font-size: var(--fs-xs); font-weight: 500; }
.fw-500      { font-weight: 500; }
.fw-600      { font-weight: 600; }
.mt-1        { margin-top: 0.5rem; }
.mt-2        { margin-top: 1rem; }
.mt-3        { margin-top: 1.5rem; }
.mb-1        { margin-bottom: 0.5rem; }
.mb-2        { margin-bottom: 1rem; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-1       { gap: 0.5rem; }
.gap-2       { gap: 1rem; }
.flex-1      { flex: 1; }
.hidden      { display: none; }

/* ============================================================
   ANIMACIONES DE SCROLL (Impeccable)
   ============================================================ */
.fade-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}
.fade-up:nth-child(2) { transition-delay: 0.08s; }
.fade-up:nth-child(3) { transition-delay: 0.16s; }
.fade-up:nth-child(4) { transition-delay: 0.24s; }
.fade-up:nth-child(5) { transition-delay: 0.32s; }

/* ============================================================
   TOAST NOTIFICATIONS (lanzalo-badges.js)
   ============================================================ */
#lz-toast-box {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 360px;
    width: calc(100vw - 48px);
}
.lz-toast {
    pointer-events: all;
    background: #1E1E24;
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.28);
    overflow: hidden;
    animation: lz-toast-in .3s ease forwards;
}
.lz-toast.lz-toast-out {
    animation: lz-toast-out .25s ease forwards;
}

/* Header de la notificación */
.lz-toast-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 8px;
}
.lz-toast-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.lz-toast-info { flex: 1; min-width: 0; }
.lz-toast-titulo {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: rgba(255,255,255,.55);
    margin-bottom: 1px;
}
.lz-toast-remitente {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lz-toast-sub { font-weight: 400; color: rgba(255,255,255,.6); font-size: 12px; }

/* Texto del mensaje */
.lz-toast-mensaje {
    font-size: 13px;
    color: rgba(255,255,255,.8);
    line-height: 1.5;
    padding: 0 14px 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Botón Ver mensaje */
.lz-toast-btn {
    display: block;
    background: var(--green);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
    text-align: center;
    transition: background .15s;
}
.lz-toast-btn:hover { background: var(--green-dark, #1A8A5A); color: #fff; }

/* Cerrar */
.lz-toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.5);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s;
}
.lz-toast-close:hover { color: #fff; }

@keyframes lz-toast-in {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes lz-toast-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(8px) scale(.97); }
}

/* ============================================================
   MODO OSCURO
   ============================================================ */
.dark-mode {
    --gray-light:  #18181B;
    --bg-soft:     #1C1C1F;
    --gray-border: #2E2E33;
    --white:       #1F1F22;
    --text:        #E8E8ED;
    --text-mid:    #C2C2CA;
    --text-soft:   #8A8A95;
    --text-muted:  #606068;
    --green-light: rgba(29,158,117,.2);
    --blue-light:  rgba(55,138,221,.18);
    --amber-light: rgba(186,117,23,.18);
    --red-light:   rgba(226,75,74,.18);
    --shadow-xs:   0 1px 3px rgba(0,0,0,.35);
    --shadow:      0 2px 12px rgba(0,0,0,.4);
    --shadow-md:   0 4px 20px rgba(0,0,0,.45);
    --shadow-lg:   0 8px 32px rgba(0,0,0,.5);
}

/* Transición suave al cambiar tema */
body, .topbar, .sidebar, .card, .metric-card, .dash-card,
.btn-secondary, .form-control, input, select, textarea,
.modal, .panel-body, .tcard, .wsp-camp-card, .wsp-card,
.sidebar-item, .range-chip, .week-header, .cal-cell-v2 {
    transition: background-color .2s ease, border-color .2s ease, color .15s ease;
}

/* Overrides modo oscuro */
.dark-mode .btn-primary                { color: #fff; }
.dark-mode .btn-secondary              { background: #252528; color: var(--text); border-color: var(--gray-border); }
.dark-mode .sidebar-item:hover         { background: #2A2A2E; }
.dark-mode .sidebar-item.active        { background: rgba(29,158,117,.15); }
.dark-mode .sb-toggle                  { background: #2A2A2E; border-color: #3A3A3F; color: var(--text-soft); }
.dark-mode .progress-bar               { background: var(--gray-border); }
.dark-mode .form-control,
.dark-mode input[type="text"],
.dark-mode input[type="email"],
.dark-mode input[type="password"],
.dark-mode input[type="date"],
.dark-mode input[type="number"],
.dark-mode input[type="search"],
.dark-mode select,
.dark-mode textarea                    { background: #252528; color: var(--text); border-color: var(--gray-border); }
.dark-mode .form-control::placeholder,
.dark-mode input::placeholder,
.dark-mode textarea::placeholder       { color: var(--text-muted); }
.dark-mode .badge-amber                { color: #E9A84C; }
.dark-mode .badge-blue                 { color: #79B4F0; }
.dark-mode .badge-red                  { color: #F47C7C; }
.dark-mode .badge-gray                 { background: #2A2A2E; }
.dark-mode .panel-item                 { border-bottom-color: var(--gray-border); }
.dark-mode .modal-overlay              { background: rgba(0,0,0,.72); }
.dark-mode .modal                      { background: var(--white); }
.dark-mode .lz-toast                   { background: #2A2A2E; }
.dark-mode table th                    { background: var(--bg-soft); }
.dark-mode table td, .dark-mode table th { border-color: var(--gray-border); }
.dark-mode .tcard                      { background: var(--bg-soft); }
.dark-mode .tcard:hover                { background: var(--white); }
.dark-mode .wsp-mini-stat              { background: var(--bg-soft); }
.dark-mode .week-header                { background: var(--bg-soft); }
.dark-mode .alert-error                { background: rgba(226,75,74,.15); border-color: rgba(226,75,74,.35); }
.dark-mode .alert-success              { background: rgba(29,158,117,.15); border-color: rgba(29,158,117,.35); }

/* ─── Toggle de tema (switch deslizable) ─── */
.theme-toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: .5px solid var(--gray-border);
    background: none;
    transition: border-color .15s, background .15s;
    font-size: 11px;
    color: var(--text-soft);
    line-height: 1;
}
.theme-toggle-wrap:hover { border-color: var(--text-muted); background: var(--gray-light); }
.theme-switch {
    position: relative;
    width: 32px;
    height: 17px;
    background: #C5C3B8;
    border-radius: 9px;
    transition: background .22s ease;
    flex-shrink: 0;
}
.dark-mode .theme-switch { background: var(--green); }
.theme-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .22s ease;
}
.dark-mode .theme-switch::after { transform: translateX(15px); }

/* ─── Botón Salir ─── */
.topbar-right a[href*="logout"] {
    color: var(--red) !important;
    border-color: rgba(220,56,55,.3) !important;
    background: rgba(220,56,55,.07) !important;
}
.topbar-right a[href*="logout"]:hover {
    background: var(--red) !important;
    color: #fff !important;
    border-color: var(--red) !important;
}
