/* ══════════════════════════════════════════════════════
   TOKENS (IGSS)
══════════════════════════════════════════════════════ */
:root {
    --igss-blue:    #40a6d7;
    --igss-yellow:  #fcbf00;
    --igss-red:     #d73637;
    --igss-dark:    #1a3a5a;
    --bg-light:     #f4f7f9;

    --blue:         var(--igss-blue);
    --blue-dark:    #1f4b6e;
    --blue-deep:    var(--igss-dark);
    --accent:       var(--igss-yellow);
    --accent-hover: #eab100;
    --danger:       var(--igss-red);
    --success:      #0ca678;

    --surface:      #ffffff;
    --card:         #ffffff;
    --border:       rgba(0,0,0,.08);
    --border-strong: rgba(0,0,0,.14);
    --text:         #0f1c35;
    --text-2:       #4a5878;
    --text-3:       #8a97b0;

    --blue-glow:    rgba(64,166,215,.18);
    --shadow-accent: 0 4px 18px rgba(252,191,0,.45);

    /* ── Layout híbrido ── */
    --topbar-h:     52px;
    --rail-w:       52px;
    --flyout-w:     230px;

    --font:         'Sora', sans-serif;
    --mono:         'JetBrains Mono', monospace;
    --ease:         cubic-bezier(.4,0,.2,1);
    --r-sm:         8px;
    --r-md:         14px;
    --r-lg:         20px;
    --shadow-xs:    0 1px 3px rgba(0,0,0,.06);
    --shadow-sm:    0 2px 8px rgba(0,0,0,.08);
    --shadow-md:    0 6px 24px rgba(26,58,90,.1);
    --shadow-lg:    0 16px 48px rgba(26,58,90,.16);

    /* Legacy: mantiene compatibilidad con código existente que use --nav-h */
    --nav-h:        var(--topbar-h);
}

/* ══════════════════════════════════════════════════════
   BASE
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    display: block;
    min-height: 100vh;
    background: var(--bg-light);
    font-family: var(--font);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    /* Offset por el topbar fijo + rail fijo en desktop */
    padding-top: var(--topbar-h);
    padding-left: var(--rail-w);
}

/* Sin rail en páginas guest/login */
body:not(.has-rail) {
    padding-left: 0;
}

/* ══════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════ */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    z-index: 1041;
    background: var(--igss-blue);
    border-bottom: 2px solid var(--igss-yellow);
    box-shadow: 0 4px 12px rgba(26,58,90,.2);
}

.topbar::after {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--igss-yellow);
    box-shadow: 0 0 8px var(--igss-yellow);
}

.topbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
}

/* Brand */
.topbar-brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; flex-shrink: 0; padding: 0;
}

.topbar-brand-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,.15);
    border: 1.5px solid rgba(255,255,255,.2);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all .3s var(--ease);
    overflow: hidden;
}

.topbar-brand:hover .topbar-brand-icon {
    border-color: var(--igss-yellow);
    transform: rotate(-5deg) scale(1.06);
    box-shadow: 0 0 14px var(--igss-yellow);
}

.topbar-brand-text { display: flex; flex-direction: column; line-height: 1.1; }

.topbar-eyebrow {
    font-size: .58rem; font-weight: 600;
    letter-spacing: .18em; text-transform: uppercase;
    color: rgba(255,255,255,.5);
}

.topbar-title {
    font-size: .92rem; font-weight: 700;
    color: #fff; letter-spacing: -.01em;
}

/* Separador vertical */
.topbar-sep {
    width: 1px; height: 22px;
    background: rgba(255,255,255,.15);
    flex-shrink: 0;
}

/* Buscador */
.topbar-search-btn {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--r-sm);
    color: rgba(255,255,255,.6);
    padding: 6px 12px;
    font-size: .8rem; cursor: pointer;
    transition: all .2s var(--ease);
    font-family: var(--font);
    min-width: 180px;
}

.topbar-search-btn:hover {
    background: rgba(255,255,255,.16);
    color: #fff;
    border-color: rgba(255,255,255,.25);
}

.topbar-search-hint {
    flex: 1; text-align: left;
    color: rgba(255,255,255,.4);
}

.topbar-search-kbd {
    display: flex; align-items: center; gap: 3px;
    margin-left: auto;
}

/* Spacer */
.topbar-spacer { flex: 1; }

/* Context buttons (UE, ejercicio) */
.topbar-ctx-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--r-sm);
    color: rgba(255,255,255,.85);
    font-size: .78rem; font-weight: 500;
    padding: 5px 10px; cursor: pointer;
    transition: all .2s var(--ease);
    font-family: var(--font);
    white-space: nowrap;
}

.topbar-ctx-btn:hover {
    background: rgba(255,255,255,.18);
    color: #fff;
    border-color: rgba(255,255,255,.28);
}

.topbar-ctx-green {
    background: rgba(12,166,120,.18);
    border-color: rgba(12,166,120,.3);
    color: #a7f3d0;
}

.topbar-ctx-green:hover {
    background: rgba(12,166,120,.28);
    color: #d1fae5;
}

.topbar-ctx-static {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .78rem; font-weight: 600;
    color: #a7f3d0;
    padding: 5px 10px;
    background: rgba(12,166,120,.15);
    border: 1px solid rgba(12,166,120,.25);
    border-radius: var(--r-sm);
}

/* Badge Admin */
.topbar-badge-admin {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(215,54,55,.2);
    border: 1px solid rgba(215,54,55,.35);
    color: #fca5a5;
    font-size: .72rem; font-weight: 700;
    padding: 4px 9px; border-radius: var(--r-sm);
    white-space: nowrap;
}

/* CTA button */
.btn-cta {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--igss-yellow);
    color: #1a1000 !important;
    font-size: .8rem; font-weight: 700; letter-spacing: .01em;
    padding: 7px 16px; border-radius: 99px;
    text-decoration: none; border: none; white-space: nowrap;
    transition: all .2s var(--ease);
    box-shadow: var(--shadow-accent);
    flex-shrink: 0;
}

.btn-cta:hover {
    background: var(--accent-hover);
    color: #1a1000 !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(252,191,0,.55);
}

.btn-cta:active { transform: translateY(0); }

/* Mobile toggle */
.topbar-mobile-toggle {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--r-sm);
    color: rgba(255,255,255,.8);
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; cursor: pointer;
    transition: all .2s var(--ease);
    flex-shrink: 0;
}

.topbar-mobile-toggle:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ══════════════════════════════════════════════════════
   APP SHELL — contenedor rail + contenido
══════════════════════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: calc(100vh - var(--topbar-h));
    position: relative;
}

.app-content {
    flex: 1;
    min-width: 0; /* evita overflow en flex */
    display: flex;
    flex-direction: column;
}

/* ══════════════════════════════════════════════════════
   RAIL
══════════════════════════════════════════════════════ */
.rail {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--rail-w);
    z-index: 1040;
    background: var(--igss-dark);
    border-right: 1px solid rgba(255,255,255,.07);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 16px;
    gap: 3px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.rail::-webkit-scrollbar { display: none; }

/* Rail items */
.rail-item {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    color: rgba(255,255,255,.45);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all .18s var(--ease);
    border: none; background: transparent;
    text-decoration: none;
    flex-shrink: 0;
}

.rail-item:hover {
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.9);
}

.rail-item.active,
.rail-item.route-active {
    background: rgba(64,166,215,.22);
    color: #fff;
}

.rail-item.panel-open {
    background: rgba(255,255,255,.14);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--igss-yellow);
}

.rail-label {
    font-size: .56rem;
    font-weight: 600;
    letter-spacing: .03em;
    color: inherit;
    line-height: 1;
}

/* Badge de notificación */
.rail-badge {
    position: absolute;
    top: 5px; right: 4px;
    background: var(--igss-yellow);
    color: #1a1000;
    font-size: .55rem; font-weight: 800;
    padding: 1px 4px;
    border-radius: 99px;
    line-height: 1.2;
    min-width: 14px;
    text-align: center;
}

.rail-sep {
    width: 28px; height: 1px;
    background: rgba(255,255,255,.08);
    margin: 4px 0;
    flex-shrink: 0;
}

/* Tooltip nativo del rail (title) mejorado */
.rail-item[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(var(--rail-w) + 6px);
    top: 50%; transform: translateY(-50%);
    background: var(--igss-dark);
    color: #fff;
    font-size: .72rem; font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    pointer-events: none;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255,255,255,.08);
}

/* ══════════════════════════════════════════════════════
   FLYOUT PANELS
══════════════════════════════════════════════════════ */
.flyout-panel {
    position: fixed;
    top: var(--topbar-h);
    left: var(--rail-w);
    bottom: 0;
    width: var(--flyout-w);
    z-index: 1039;
    background: var(--card);
    border-right: 1px solid var(--border-strong);
    box-shadow: 4px 0 24px rgba(26,58,90,.12);
    transform: translateX(calc(-1 * var(--flyout-w) - 4px));
    transition: transform .22s var(--ease);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #c8d3e8 transparent;
    display: none; /* oculto por defecto; JS lo muestra */
}

.flyout-panel.open {
    display: block;
    transform: translateX(0);
    animation: flyoutIn .22s var(--ease);
}

@keyframes flyoutIn {
    from { transform: translateX(-12px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

/* Header del panel */
.flyout-header {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    background: var(--card);
    z-index: 1;
}

.flyout-icon {
    width: 28px; height: 28px;
    background: #eef6fc;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; color: var(--blue);
    flex-shrink: 0;
}

.flyout-title {
    font-size: .82rem; font-weight: 700;
    color: var(--text); flex: 1;
    letter-spacing: -.01em;
}

.flyout-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: .9rem; padding: 4px;
    border-radius: var(--r-sm); transition: all .15s;
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
}

.flyout-close:hover { background: #f1f5f9; color: var(--text); }

/* Grupos dentro del panel */
.flyout-group {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

.flyout-group:last-child { border-bottom: none; }

.flyout-group-label {
    font-size: .65rem; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-3);
    padding: 6px 6px 4px;
}

/* Items del flyout */
.flyout-item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 8px;
    border-radius: var(--r-sm);
    font-size: .82rem; font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    transition: all .15s;
    cursor: pointer;
}

.flyout-item i {
    font-size: .9rem; color: var(--text-3);
    flex-shrink: 0; width: 16px; text-align: center;
    transition: color .15s;
}

.flyout-item:hover {
    background: #f0f6ff;
    color: var(--blue);
}

.flyout-item:hover i { color: var(--blue); }

.flyout-item.active {
    background: #eff6ff;
    color: var(--blue);
    font-weight: 600;
}

.flyout-item.active i { color: var(--blue); }

/* Badge dentro del flyout */
.flyout-badge {
    background: var(--igss-yellow);
    color: #1a1000;
    font-size: .65rem; font-weight: 800;
    padding: 1px 6px; border-radius: 99px;
    flex-shrink: 0;
}

/* Overlay (cierra panel al clic fuera) */
.flyout-overlay {
    display: none;
    position: fixed; inset: 0;
    z-index: 1038;
    background: transparent;
}

.flyout-overlay.visible { display: block; }

/* ══════════════════════════════════════════════════════
   DROPDOWN (Bootstrap — heredado, sin cambios)
══════════════════════════════════════════════════════ */
.dropdown-menu {
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 6px; min-width: 250px;
    margin-top: 8px !important;
    animation: dropFade .18s var(--ease);
}

@keyframes dropFade {
    from { opacity: 0; transform: scale(.96) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--r-sm);
    font-size: .875rem; font-weight: 500;
    color: var(--text); transition: all .15s;
}

.dropdown-item .di-icon {
    width: 32px; height: 32px;
    background: #eef2ff; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem; color: var(--blue);
    transition: all .15s; flex-shrink: 0;
}

.dropdown-item:hover { background: #f0f6ff; color: var(--blue); }
.dropdown-item:hover .di-icon { background: var(--blue); color: #fff; }
.dropdown-item.active { background: #f0f6ff !important; color: var(--blue) !important; }
.dropdown-item.active .di-icon { background: var(--blue) !important; color: #fff !important; }
.dropdown-divider { margin: 5px 0; border-color: var(--border); }
.dropdown-item-logout { color: var(--danger) !important; }
.dropdown-item-logout .di-icon { background: #fff1f3 !important; color: var(--danger) !important; }
.dropdown-item-logout:hover { background: #fff1f3 !important; color: var(--danger) !important; }

/* ══════════════════════════════════════════════════════
   USER PILL
══════════════════════════════════════════════════════ */
.user-pill {
    display: flex; align-items: center; gap: 9px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.13);
    border-radius: 99px;
    padding: 4px 12px 4px 4px;
    cursor: pointer; transition: all .2s var(--ease);
    text-decoration: none;
}

.user-pill:hover {
    background: rgba(255,255,255,.16);
    border-color: rgba(255,255,255,.25);
}

.user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--igss-yellow);
    display: flex; align-items: center; justify-content: center;
    font-size: .68rem; font-weight: 800;
    color: #1a1000; flex-shrink: 0; letter-spacing: -.5px;
}

.user-info { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-size: .76rem; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.user-role { font-size: .6rem; font-weight: 500; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .06em; }

.user-dropdown-menu { min-width: 260px; }

.user-dropdown-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.user-dropdown-name { font-size: .88rem; font-weight: 700; color: var(--text); }
.user-dropdown-email { font-size: .75rem; color: var(--text-3); }

.user-role-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    padding: 2px 8px; border-radius: 99px;
    transition: all .2s;
}

.user-role-badge i { font-size: .6rem; }
.role-administrador { background: #fef3c7; color: #92400e; }
.role-compras        { background: #dbeafe; color: #1e40af; }
.role-finanzas       { background: #d1fae5; color: #065f46; }
.role-supervisor     { background: #ede9fe; color: #5b21b6; }
.role-viewer         { background: #f1f5f9; color: #475569; }

/* ══════════════════════════════════════════════════════
   SEARCH BAR — command palette con panel de resultados
══════════════════════════════════════════════════════ */
.search-bar-wrapper {
    position: fixed;
    top: var(--topbar-h);
    left: var(--rail-w);
    right: 0;
    background: var(--blue-dark);
    border-bottom: 1px solid rgba(255,255,255,.06);
    overflow: visible; /* permite que el panel salga */
    max-height: 0;
    /* clip-path oculta el contenido cuando está cerrado sin cortar el panel */
    clip-path: inset(0 0 100% 0);
    transition: max-height .3s var(--ease), clip-path .3s var(--ease), padding .3s var(--ease);
    z-index: 1042;
}

.search-bar-wrapper.open {
    max-height: min(560px, 85vh);
    clip-path: inset(0 0 -200px 0); /* expone el panel que cuelga hacia abajo */
    padding: 10px 0 0;
}

.search-inner { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; }
.search-field-wrap { position: relative; flex: 1; }

.search-field-wrap i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: rgba(255,255,255,.35); font-size: .95rem; pointer-events: none;
}

.search-input {
    width: 100%; background: rgba(255,255,255,.07);
    border: 1.5px solid rgba(255,255,255,.12);
    border-radius: var(--r-sm); color: #fff;
    font-family: var(--font); font-size: .9rem;
    padding: 9px 14px 9px 38px; outline: none; transition: all .2s;
}

.search-input::placeholder { color: rgba(255,255,255,.35); }
.search-input:focus { border-color: var(--igss-yellow); background: rgba(255,255,255,.1); box-shadow: 0 0 0 3px rgba(252,191,0,.12); }

.search-kbd { display: flex; align-items: center; gap: 4px; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.kbd { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); border-radius: 4px; padding: 1px 6px; font-size: .7rem; color: rgba(255,255,255,.5); font-family: var(--mono); }

.search-close-btn {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--r-sm); color: rgba(255,255,255,.6);
    padding: 8px 14px; font-size: .82rem; cursor: pointer;
    transition: all .2s; font-family: var(--font); white-space: nowrap;
}

.search-close-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Panel de resultados ── */
.search-results-panel {
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: #c8d3e8 transparent;
    margin: 0 0 12px;
}
.search-results-panel:empty { display: none; }
.search-results-panel::-webkit-scrollbar { width: 4px; }
.search-results-panel::-webkit-scrollbar-thumb { background: #c8d3e8; border-radius: 99px; }

.search-section-label {
    font-size: .63rem; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--text-3);
    padding: 8px 10px 3px;
}

.search-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: var(--r-sm);
    text-decoration: none; color: var(--text);
    font-size: .82rem; font-weight: 500;
    transition: background .1s; cursor: pointer;
}

.search-item:hover,
.search-item.active {
    background: #f0f6ff; color: var(--blue);
}

.search-item:hover .search-item-icon,
.search-item.active .search-item-icon {
    background: var(--blue); color: #fff;
}

.search-item:hover .search-item-enter,
.search-item.active .search-item-enter { opacity: 1; }

.search-item-accent .search-item-icon { background: #fef3c7; color: #92400e; }
.search-item-accent:hover .search-item-icon,
.search-item-accent.active .search-item-icon { background: var(--igss-yellow); color: #1a1000; }

.search-item-icon {
    width: 28px; height: 28px; border-radius: 7px;
    background: #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    font-size: .88rem; color: var(--text-2); flex-shrink: 0;
    transition: background .1s, color .1s;
}

.search-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.search-item-label { font-size: .82rem; font-weight: 500; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item-sublabel { font-size: .72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item:hover .search-item-sublabel,
.search-item.active .search-item-sublabel { color: var(--blue); opacity: .75; }

/* Loading */
.search-loading {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 14px; color: var(--text-3); font-size: .82rem;
}
.search-spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--border-strong);
    border-top-color: var(--blue);
    animation: spin .6s linear infinite;
    flex-shrink: 0;
}
.search-item-enter { font-size: .72rem; color: var(--text-3); opacity: 0; transition: opacity .1s; flex-shrink: 0; }

.search-empty {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 14px; color: var(--text-3); font-size: .82rem;
}
.search-empty i { font-size: 1.1rem; }

.search-tip {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px 10px; font-size: .73rem; color: var(--text-3);
}
.search-tip i { color: var(--igss-yellow); }

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 16px);
    right: 20px;
    z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}

.toast-item {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--card); border-radius: var(--r-md);
    padding: 14px 16px;
    min-width: 300px; max-width: 380px;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border);
    pointer-events: all; position: relative; overflow: hidden;
    animation: toastIn .3s var(--ease);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px) scale(.97); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast-item.hiding { animation: toastOut .28s var(--ease) forwards; }

@keyframes toastOut {
    to { opacity: 0; transform: translateX(24px) scale(.95); }
}

.toast-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.toast-success .toast-stripe { background: var(--success); }
.toast-danger  .toast-stripe { background: var(--danger); }
.toast-warning .toast-stripe { background: var(--accent); }
.toast-info    .toast-stripe { background: var(--blue); }

.toast-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.toast-success .toast-icon { background: #ecfdf5; color: var(--success); }
.toast-danger  .toast-icon { background: #fff1f3; color: var(--danger); }
.toast-warning .toast-icon { background: #fffbeb; color: var(--accent); }
.toast-info    .toast-icon { background: #eff6ff; color: var(--blue); }

.toast-body  { flex: 1; min-width: 0; }
.toast-title { font-size: .84rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.toast-msg   { font-size: .8rem; color: var(--text-2); line-height: 1.4; }

.toast-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 1rem; padding: 2px; transition: color .15s; flex-shrink: 0; }
.toast-close:hover { color: var(--text); }

.toast-progress {
    position: absolute; bottom: 0; left: 4px; right: 0;
    height: 2.5px; border-radius: 99px;
    transform-origin: left; animation: toastProgress 8s linear forwards;
}

.toast-success .toast-progress { background: var(--success); }
.toast-danger  .toast-progress { background: var(--danger); }
.toast-warning .toast-progress { background: var(--accent); }
.toast-info    .toast-progress { background: var(--blue); }

@keyframes toastProgress {
    from { transform: scaleX(1); } to { transform: scaleX(0); }
}

/* ══════════════════════════════════════════════════════
   MAIN & CARDS
══════════════════════════════════════════════════════ */
main {
    flex: 1; padding: 2rem 0 3rem;
    animation: pageFade .4s var(--ease);
}

@keyframes pageFade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card {
    border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs); background: var(--card);
    transition: box-shadow .2s var(--ease);
}

.card:hover { box-shadow: var(--shadow-md); }

/* ══════════════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════════════ */
.pagination { gap: 4px; flex-wrap: wrap; justify-content: center; margin: 1.5rem 0 .5rem; }
.pagination .page-link { padding: 6px 13px; font-size: .83rem; font-weight: 500; color: var(--blue); border: 1px solid var(--border-strong); border-radius: var(--r-sm) !important; min-width: 36px; text-align: center; background: var(--card); transition: all .15s var(--ease); }
.pagination .page-link:hover { background: #eef3ff; border-color: var(--blue); color: var(--blue-dark); transform: translateY(-1px); }
.pagination .page-item.active .page-link { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; box-shadow: 0 2px 10px var(--blue-glow); }
.pagination .page-item.disabled .page-link { background: var(--surface); border-color: var(--border); color: var(--text-3); opacity: .65; }

/* ══════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════ */
footer { background: var(--card); border-top: 1px solid var(--border); padding: 1.5rem 0; }
.footer-brand { font-size: .9rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.footer-meta  { font-size: .8rem; color: var(--text-3); margin-top: 4px; }
.footer-meta a { color: var(--blue); text-decoration: none; }
.footer-meta a:hover { text-decoration: underline; }

.footer-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 99px; padding: 5px 14px; font-size: .78rem; color: var(--text-3); font-weight: 500; }
.live-dot { width: 7px; height: 7px; background: var(--success); border-radius: 50%; animation: pulse 2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .6; transform: scale(.8); }
}

.version-chip { font-family: var(--mono); font-size: .72rem; background: var(--blue); color: #fff; border-radius: 99px; padding: 1px 8px; }

/* ══════════════════════════════════════════════════════
   PAGE LOADER
══════════════════════════════════════════════════════ */
.page-loader { position: fixed; inset: 0; z-index: 9999; background: var(--surface); display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
.page-loader.active { opacity: 1; pointer-events: all; }
.loader-spinner { width: 36px; height: 36px; border: 3px solid var(--border-strong); border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Back to top */
.back-to-top { position: fixed; bottom: 28px; right: 24px; z-index: 900; width: 40px; height: 40px; background: var(--blue); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; text-decoration: none; box-shadow: 0 4px 14px rgba(64,166,215,.4); opacity: 0; transform: translateY(10px); pointer-events: none; transition: all .25s var(--ease); }
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: all; }
.back-to-top:hover   { background: var(--blue-dark); color: #fff; transform: translateY(-2px); }

/* ══════════════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8d3e8; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #a0b0cc; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (< 992px)
══════════════════════════════════════════════════════ */
@media (max-width: 991px) {

    body.has-rail {
        padding-left: 0;
    }

    /* Rail oculto en mobile por defecto */
    .rail {
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
        z-index: 1045;
        top: var(--topbar-h);
    }

    .rail.mobile-open {
        transform: translateX(0);
    }

    /* Flyout en mobile: ocupa pantalla completa desde el rail */
    .flyout-panel {
        left: var(--rail-w);
        width: calc(100vw - var(--rail-w));
        max-width: 320px;
    }

    /* Search bar ocupa ancho completo en mobile */
    .search-bar-wrapper {
        left: 0;
    }

    /* Toasts */
    .toast-container { right: 12px; left: 12px; top: calc(var(--topbar-h) + 10px); }
    .toast-item { min-width: unset; max-width: 100%; }

    /* Overlay cubre todo en mobile */
    .flyout-overlay.visible {
        background: rgba(0,0,0,.45);
    }
}

@media (max-width: 480px) {
    .topbar-search-btn { display: none !important; }
}