/* css/admin-panel.css — Chrome del panel SUPER (admin.kontore.app). Vivía como bloque <style> de admin.html.
   Movido desde el marcado para que lo cubra 'self' en la CSP: un archivo externo no
   necesita 'unsafe-inline' en `style-src-elem` ni un hash que alguien tenga que
   regenerar. El contenido es el MISMO, en el MISMO punto de la cascada. */
        *, *::before, *::after { box-sizing: border-box; }
        /* ATLAS body — ivory papelero + Söhne/Inter (Sprint Brand-ATLAS-Apply) */
        body {
            font-family: var(--font-body);
            font-size: 13px;
            background-color: var(--color-bg);
            color: var(--color-text);
            margin: 0;
        }
        /* Cifras tabulares para columnas de datos (number-tabular) */
        .tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
        code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

        /* ── Scrollbar ── */
        ::-webkit-scrollbar { width: 5px; height: 5px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }
        ::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

        /* ── Focus rings ── */
        :focus-visible { outline: 2px solid #1E2D6B; outline-offset: 2px; }
        button, a, [role="button"], select, input { cursor: pointer; }
        input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"] { cursor: text; }

        /* ── Sidebar nav item ── */
        .nav-item {
            display: flex; align-items: center; gap: 10px;
            padding: 9px 14px; border-radius: 8px;
            color: #94A3B8; font-weight: 600; font-size: 13px;
            transition: background 0.15s ease, color 0.15s ease;
            cursor: pointer; border: none; background: none; width: 100%; text-align: left;
        }
        .nav-item:hover { background: rgba(148,163,184,0.08); color: #CBD5E1; }
        .nav-item.active { background: rgba(30,45,107,0.25); color: #ffffff; }
        .nav-item svg { flex-shrink: 0; }
        .nav-badge { margin-left: auto; background: #DC2626; color: #fff; font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 99px; min-width: 16px; text-align: center; }

        /* ── Skeleton shimmer ── */
        @keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
        .skeleton {
            background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
            background-size: 800px 100%;
            animation: shimmer 1.4s ease-in-out infinite;
            border-radius: 6px;
        }
        @media (prefers-reduced-motion: reduce) {
            .skeleton, .fade-in, .drawer-panel, * { animation: none !important; transition: none !important; }
        }

        /* ── Animations ── */
        @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes slideInTop { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
        .fade-in { animation: fadeIn 0.2s ease-out forwards; }

        /* ── Views ── */
        .admin-view { display: none; }
        .admin-view.active { display: block; animation: fadeIn 0.2s ease-out; }

        /* ── Toast ── */
        #toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
        .toast {
            pointer-events: auto;
            padding: 12px 18px; border-radius: 10px;
            font-size: 13px; font-weight: 600; max-width: 340px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.15);
            animation: slideInTop 0.2s ease-out forwards;
            display: flex; align-items: center; gap: 10px;
        }
        .toast.success { background: #0F172A; color: #4ADE80; border: 1px solid rgba(74,222,128,0.2); }
        .toast.error   { background: #0F172A; color: #F87171; border: 1px solid rgba(248,113,113,0.2); }
        .toast.info    { background: #0F172A; color: #7DD3FC; border: 1px solid rgba(125,211,252,0.2); }

        /* ── Login background ── */
        /* ATLAS login bg — navy-900 → navy-700 → navy-900 */
        #admin-login-screen { background: linear-gradient(145deg, #0E1A3A 0%, #1E2D6B 55%, #0E1A3A 100%); }
        @keyframes blobFloat { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(20px,-15px) scale(1.05); } }
        .login-blob   { animation: blobFloat 8s ease-in-out infinite; }
        .login-blob-2 { animation: blobFloat 10s ease-in-out infinite reverse; }

        /* ── Table sort indicator ── */
        .sortable { cursor: pointer; user-select: none; }
        .sortable:hover { color: #1E2D6B; }
        .sort-asc::after  { content: ' ↑'; color: #1E2D6B; }
        .sort-desc::after { content: ' ↓'; color: #1E2D6B; }

        /* ── Badge base ── */
        .badge {
            display: inline-flex; align-items: center; justify-content: center;
            padding: 2px 8px; border-radius: 99px;
            font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
            white-space: nowrap;
        }

        /* ── Sidebar collapse ── */
        @media (max-width: 1024px) {
            #admin-sidebar { transform: translateX(-100%); transition: transform 0.2s ease; position: fixed; z-index: 200; height: 100%; }
            #admin-sidebar.open { transform: translateX(0); }
            #sidebar-overlay { display: block; }
        }
        @media (min-width: 1025px) {
            #sidebar-overlay { display: none !important; }
            #sidebar-toggle { display: none !important; }
        }

        /* ── Input ── */
        .input-admin {
            width: 100%; padding: 8px 12px;
            background: #F8FAFC; border: 1.5px solid #E2E8F0;
            border-radius: 8px; outline: none;
            font-size: 13px; color: #0F172A;
            font-family: 'Plus Jakarta Sans', sans-serif;
            transition: border-color 0.15s, box-shadow 0.15s;
        }
        .input-admin:focus { background: #fff; border-color: #1E2D6B; box-shadow: 0 0 0 3px rgba(30,45,107,0.1); }
        .input-admin::placeholder { color: #94A3B8; }
        .input-admin:disabled { opacity: 0.6; cursor: not-allowed; }

        /* ── Buttons ── */
        .btn-primary {
            background: #1E2D6B; color: #fff;
            padding: 9px 18px; border-radius: 8px;
            font-weight: 700; font-size: 13px;
            border: none; transition: background 0.15s, transform 0.1s;
        }
        .btn-primary:hover { background: #0E1A3A; transform: translateY(-1px); }
        .btn-primary:active { transform: translateY(0); }
        .btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
        .btn-ghost {
            padding: 8px 14px; border-radius: 8px; border: 1.5px solid #E2E8F0;
            color: #475569; background: #fff; font-weight: 600; font-size: 13px;
            transition: background 0.15s, border-color 0.15s;
        }
        .btn-ghost:hover { background: #F8FAFC; border-color: #CBD5E1; }

        /* ── Table ── */
        .th-admin {
            padding: 10px 14px; font-size: 10px; font-weight: 800;
            color: #64748B; text-transform: uppercase; letter-spacing: 0.06em;
            background: #F8FAFC; border-bottom: 1.5px solid #E2E8F0;
            white-space: nowrap;
        }
        .td-admin { padding: 11px 14px; border-bottom: 1px solid #F1F5F9; color: #334155; vertical-align: middle; }
        .tr-admin:hover { background: #F8FAFC; }
        .tr-admin:last-child td { border-bottom: none; }

        /* ── Drawer derecho (subscripciones — panel lateral legacy) ── */
        #tenant-drawer, #subscription-drawer { transition: opacity 0.2s ease; }
        .drawer-panel { transition: transform 0.25s cubic-bezier(0.16,1,0.3,1); }

        /* ── Detalle de tenant: MODAL centrado + arrastrable (Frente 1) ─────────
           Reemplaza el drawer lateral por una ventana centrada con header
           arrastrable (JS puro), secciones en acordeón y switches deslizables.
           Capas: card blanca → body ivory → secciones blancas (patrón panel-central). */
        .tnt-panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
            width: min(94vw, 34rem); z-index: 1; }
        .tnt-card { display: flex; flex-direction: column; max-height: 86vh;
            background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(15,23,42,0.32);
            overflow: hidden; animation: tntPop 0.22s cubic-bezier(0.16,1,0.3,1); }
        @keyframes tntPop { from { opacity: 0; transform: scale(0.965); } to { opacity: 1; transform: scale(1); } }
        .tnt-drag { cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
        .tnt-drag:active { cursor: grabbing; }
        .tnt-body { background: #FAF8F2; padding: 16px; min-height: 0; }
        /* Botones de ventana (centrar / cerrar) */
        .tnt-winbtn { display: inline-flex; align-items: center; justify-content: center;
            width: 34px; height: 34px; border-radius: 9px; color: #64748B;
            border: none; background: none; transition: background .15s, color .15s; }
        .tnt-winbtn:hover { background: #F1F5F9; color: #0F172A; }

        /* ── Acordeón (secciones colapsables del modal de tenant) ── */
        .acc-sec { background: #fff; border: 1px solid #E9E5DC; border-radius: 12px; overflow: hidden; }
        .acc-sec + .acc-sec { margin-top: 10px; }
        .acc-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
            padding: 12px 14px; background: none; border: none; }
        .acc-head:hover { background: #FCFBF8; }
        .acc-caret { width: 14px; height: 14px; flex-shrink: 0; color: #94A3B8; transition: transform .2s ease; }
        .acc-head[aria-expanded="true"] .acc-caret { transform: rotate(90deg); }
        .acc-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: #334155; }
        .acc-summary { margin-left: auto; font-size: 11px; font-weight: 600; color: #94A3B8; white-space: nowrap;
            overflow: hidden; text-overflow: ellipsis; max-width: 48%; }
        .acc-body-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .24s ease; }
        .acc-body-wrap.open { grid-template-rows: 1fr; }
        .acc-body-inner { overflow: hidden; }
        .acc-body-pad { padding: 2px 14px 12px 14px; }

        /* Fila label / valor dentro de una sección */
        .tnt-row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid #F5F2EA; }
        .tnt-row:last-child { border-bottom: none; }
        .tnt-row .k { font-size: 11px; color: #94A3B8; font-weight: 600; flex-shrink: 0; }
        .tnt-row .v { font-size: 11px; font-weight: 700; color: #334155; text-align: right; word-break: break-word; }
        /* Fila de switch (footer / módulo) */
        .tnt-swrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #F5F2EA; }
        .tnt-swrow:last-child { border-bottom: none; }
        .tnt-swrow .lbl { min-width: 0; }
        .tnt-swrow .lbl-title { font-size: 12px; font-weight: 700; color: #334155; overflow: hidden; text-overflow: ellipsis; }
        .tnt-swrow .lbl-sub { font-size: 10.5px; color: #94A3B8; font-weight: 500; margin-top: 1px; }
        .mod-off-pill { display: inline-block; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
            color: #B45309; background: #FFF7ED; padding: 1px 6px; border-radius: 99px; }

        /* ── Empresas emisoras del tenant (Frente 1 · Lane U) ── */
        .emp-hdr { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
        .emp-count { font-size: 11px; font-weight: 800; color: #64748B; letter-spacing: .02em; }
        .emp-count .warn { color: #B45309; }
        .emp-newbtn { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800;
            color: #1E2D6B; background: #EEF2FF; border: 1px solid #C7D2FE; border-radius: 9px; padding: 6px 11px; cursor: pointer;
            transition: background .15s, opacity .15s; }
        .emp-newbtn:hover:not(:disabled) { background: #E0E7FF; }
        .emp-newbtn:disabled { opacity: .5; cursor: not-allowed; }
        .emp-card { background: #FAF8F2; border: 1px solid #EDE8DE; border-radius: 11px; padding: 11px 12px; }
        .emp-card + .emp-card { margin-top: 9px; }
        .emp-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
        .emp-sigla { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 24px; padding: 0 7px;
            font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 700; color: #1E2D6B; background: #fff;
            border: 1px solid #D7DCEA; border-radius: 7px; letter-spacing: .02em; flex-shrink: 0; }
        .emp-name { font-size: 12.5px; font-weight: 800; color: #1E293B; line-height: 1.2; word-break: break-word; }
        .emp-meta { font-size: 10.5px; color: #94A3B8; font-weight: 600; margin-top: 1px; word-break: break-word; }
        .emp-editbtn { font-size: 11px; font-weight: 700; color: #0369A1; background: none; border: none; cursor: pointer;
            padding: 3px 7px; border-radius: 6px; flex-shrink: 0; }
        .emp-editbtn:hover { background: #E0F2FE; }
        .emp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
        .emp-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9.5px; font-weight: 700; color: #3730A3;
            background: #EEF2FF; border: 1px solid #E0E7FF; border-radius: 6px; padding: 2px 7px; }
        .emp-chip-empty { font-size: 10.5px; color: #94A3B8; font-weight: 600; }
        .emp-modlabel { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #94A3B8; margin: 10px 0 5px; }
        /* Una fila por módulo; el toggle queda PEGADO al título (owner: "al lado del título"). */
        .emp-mod-grid { display: flex; flex-direction: column; gap: 2px; }
        .emp-mod-sw { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 3px 0; }
        .emp-mod-sw .k { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 600; color: #475569;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        /* Switch compacto (reusa .switch/.slider) para los toggles por módulo. */
        .switch.sw-sm { width: 34px; height: 19px; }
        .switch.sw-sm .slider::before { height: 13px; width: 13px; }
        .switch.sw-sm input:checked + .slider::before { transform: translateX(15px); }
        /* Modal Nueva/Editar empresa */
        .emp-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
        @media (max-width: 560px) { .emp-form-grid { grid-template-columns: 1fr; } }
        .emp-form-full { grid-column: 1 / -1; }
        .emp-fld label { display: block; font-size: 11px; font-weight: 700; color: #64748B; margin-bottom: 5px; }
        .emp-fld label .req { color: #DC2626; }
        .emp-modbox { border: 1px solid #E9E5DC; border-radius: 11px; background: #FAF8F2; padding: 11px 12px; }
        .emp-modbox-hint { font-size: 10.5px; color: #94A3B8; font-weight: 600; margin-top: 2px; }
        .emp-loading { display: flex; align-items: center; gap: 8px; color: #94A3B8; font-size: 11px; font-weight: 700; padding: 8px 0; }
        .emp-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #CBD5E1; border-top-color: #1E2D6B;
            border-radius: 50%; animation: empspin .7s linear infinite; }
        @keyframes empspin { to { transform: rotate(360deg); } }
        .emp-foot-spacer { flex: 1 1 auto; }
        @media (max-width: 640px) { .emp-foot-spacer { display: none; } }

        /* ── Modal ── */
        /* Hotfix 2026-06-08: usar :not(.hidden) para que la clase utilitaria
           .hidden (display:none, definida ANTES en la cascada) gane sobre
           .modal-overlay. Sin esto, todos los modales aparecían visibles al
           cargar la página porque .modal-overlay (más reciente en cascade)
           pisaba a .hidden con misma especificidad. */
        .modal-overlay:not(.hidden) { position: fixed; inset: 0; background: rgba(15,23,42,0.55); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
        .modal-box { background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,0.25); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; animation: fadeIn 0.2s ease-out; }

        /* ── Mobile-first tap targets + footer stack (Apple HIG ≥44px) ── */
        /* Cerrar X del modal: padded hit area 44×44 sin agrandar el ícono visible. */
        .modal-close-btn { display: inline-flex; align-items: center; justify-content: center;
            width: 44px; height: 44px; margin: -10px; padding: 10px;
            border-radius: 10px; transition: background-color .15s, color .15s; flex-shrink: 0;
        }
        .modal-close-btn:hover { background: rgba(255,255,255,0.10); }
        .modal-close-btn:focus-visible { outline: 2px solid #7DD3FC; outline-offset: 2px; }
        .modal-close-btn svg { width: 18px; height: 18px; pointer-events: none; }

        /* Inputs en mobile: 16px previene zoom de iOS Safari. */
        @media (max-width: 640px) {
            .input-admin { font-size: 16px !important; padding: 10px 12px !important; }
            .input-admin.tnum { font-size: 16px !important; }
            /* Headers de modales: padding más compacto. */
            .modal-box > div:first-child { padding-left: 16px !important; padding-right: 16px !important; padding-top: 12px !important; padding-bottom: 12px !important; }
            /* Modal forms: padding más compacto y space-y-3 (en vez de space-y-4). */
            .modal-box form.p-6, .modal-box > div.p-6 { padding: 16px !important; }
        }

        /* Footer mobile-first: stack vertical con primary ARRIBA (orden invertido vs DOM)
           Aplica al footer flex normal de los modales. */
        .modal-footer-stack { display: flex; gap: 12px; padding-top: 8px; flex-wrap: wrap; }
        @media (max-width: 640px) {
            .modal-footer-stack { flex-direction: column-reverse; gap: 8px; }
            .modal-footer-stack > button { width: 100%; min-height: 44px; }
        }
        @media (min-width: 641px) {
            .modal-footer-stack > button.flex-1 { flex: 1 1 0%; }
        }

        /* Footer "bar" (grant-flag con counter + 4 botones): stack en mobile. */
        .modal-footer-bar {
            display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
            padding: 14px 24px; border-top: 1px solid #E2E8F0; background: #F8FAFC;
            border-bottom-left-radius: 16px; border-bottom-right-radius: 16px;
        }
        @media (max-width: 640px) {
            .modal-footer-bar { flex-direction: column-reverse; align-items: stretch; padding: 12px 16px; gap: 8px; }
            .modal-footer-bar > button { width: 100%; min-height: 44px; }
            .modal-footer-bar > .footer-counter { width: 100%; text-align: center; padding: 6px 0 2px; order: 999; }
        }

        /* Tap target ≥44px en todos los botones del admin (mobile). */
        @media (max-width: 640px) {
            .btn-primary, .btn-ghost { min-height: 44px; padding: 11px 18px; font-size: 14px; }
        }

        /* Labels clickeables con tap target generoso (checkboxes/radios). */
        .tap-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 4px;
            cursor: pointer; user-select: none; border-radius: 8px; transition: background-color .12s;
        }
        .tap-row:hover { background: #F8FAFC; }
        .tap-row input[type="checkbox"], .tap-row input[type="radio"] {
            width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; accent-color: #1E2D6B;
        }

        /* ── Chips multi-select (reemplaza <select multiple> en mobile + desktop) ── */
        .chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
        .chip-multi {
            display: inline-flex; align-items: center; gap: 6px;
            min-height: 36px; padding: 8px 12px;
            background: #fff; border: 1.5px solid #E2E8F0; border-radius: 999px;
            color: #475569; font-weight: 600; font-size: 12px; line-height: 1;
            cursor: pointer; transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
            white-space: nowrap;
        }
        .chip-multi:hover { background: #F8FAFC; border-color: #CBD5E1; }
        .chip-multi:focus-visible { outline: 2px solid #1E2D6B; outline-offset: 2px; }
        .chip-multi.is-active {
            background: #E0F2FE; border-color: #7DD3FC; color: #075985;
            box-shadow: 0 1px 2px rgba(30,45,107,0.08);
        }
        .chip-multi.is-active::before {
            content: ''; display: inline-block; width: 6px; height: 6px;
            background: #1E2D6B; border-radius: 50%;
        }
        @media (max-width: 640px) {
            .chip-multi { min-height: 40px; padding: 9px 14px; font-size: 13px; }
        }
        .chip-empty-hint { font-size: 11px; color: #94A3B8; font-weight: 600; padding: 6px 2px; }

        /* Grant-flag — sección de la lista de tenants: alto responsive. */
        .grant-flag-section { max-height: 65vh; }
        @media (max-width: 640px) {
            .grant-flag-section { max-height: 55vh; }
        }
        @supports (height: 100dvh) {
            @media (max-width: 640px) {
                .grant-flag-section { max-height: 55dvh; }
            }
        }

        /* ── Empty / error ── */
        .empty-state { text-align: center; padding: 48px 24px; color: #94A3B8; }
        .empty-state svg { margin: 0 auto 12px; opacity: 0.4; }

        /* ── Toggle switch ── */
        .switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
        .switch input { opacity: 0; width: 0; height: 0; }
        .switch .slider { position: absolute; inset: 0; background: #CBD5E1; border-radius: 99px; transition: background 0.2s; }
        .switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
        .switch input:checked + .slider { background: #059669; }
        .switch input:checked + .slider::before { transform: translateX(18px); }
        .switch input:focus-visible + .slider { outline: 2px solid #1E2D6B; outline-offset: 2px; }

        /* ── Password strength meter ── */
        .pw-bar { height: 5px; border-radius: 99px; background: #E2E8F0; overflow: hidden; }
        .pw-bar > div { height: 100%; width: 0; border-radius: 99px; transition: width 0.25s, background 0.25s; }

        /* ── KPI card ── */
        .kpi-card {
            background: #fff; border: 1px solid #E2E8F0; border-radius: 14px;
            padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
            transition: border-color 0.15s, box-shadow 0.15s;
        }
        .kpi-card:hover { border-color: #CBD5E1; box-shadow: 0 4px 14px rgba(15,23,42,0.05); }
        .kpi-label { font-size: 10.5px; font-weight: 800; color: #64748B; text-transform: uppercase; letter-spacing: 0.06em; }
        .kpi-value { font-size: 24px; font-weight: 800; color: #0F172A; line-height: 1.05; }
        .kpi-sub { font-size: 11px; font-weight: 600; color: #94A3B8; }
        .kpi-delta { font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; gap: 2px; }
        .kpi-delta.up   { color: #059669; }
        .kpi-delta.down { color: #DC2626; }
        .kpi-delta.flat { color: #94A3B8; }

        /* ── Health dot ── */
        .health-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
        .health-dot.ok       { background: #059669; box-shadow: 0 0 0 3px rgba(5,150,105,0.15); }
        .health-dot.warning  { background: #D97706; box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }
        .health-dot.critical { background: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.15); animation: pulseDot 1.6s ease-in-out infinite; }
        .health-dot.unknown  { background: #94A3B8; box-shadow: 0 0 0 3px rgba(148,163,184,0.15); }
        @keyframes pulseDot { 0%,100% { box-shadow: 0 0 0 3px rgba(220,38,38,0.15); } 50% { box-shadow: 0 0 0 6px rgba(220,38,38,0.05); } }

        /* ── Notif item ── */
        .notif-item { padding: 13px 16px; border-bottom: 1px solid #F1F5F9; display: flex; gap: 12px; align-items: flex-start; transition: background 0.12s; }
        .notif-item:hover { background: #F8FAFC; }
        .notif-item:last-child { border-bottom: none; }
        .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: #1E2D6B; flex-shrink: 0; margin-top: 5px; }

        /* ── Bell badge ── */
        #notif-bell-wrap { position: relative; }
        .bell-badge {
            position: absolute; top: -4px; right: -4px;
            background: #DC2626; color: #fff; font-size: 9px; font-weight: 800;
            min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
            display: flex; align-items: center; justify-content: center; line-height: 1;
            border: 2px solid #fff;
        }

        /* ── Mobile bottom nav ── */
        #mobile-bottom-nav { display: none; }
        @media (max-width: 768px) {
            #mobile-bottom-nav {
                display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 180;
                background: #0F172A; border-top: 1px solid rgba(255,255,255,0.06);
                padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
                justify-content: space-around;
            }
            .mnav-item {
                flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
                padding: 6px 2px; min-height: 52px; border: none; background: none;
                color: #64748B; font-size: 9.5px; font-weight: 700; border-radius: 8px;
                position: relative;
            }
            .mnav-item.active { color: #7DD3FC; }
            .mnav-item svg { width: 20px; height: 20px; }
            .mnav-badge {
                position: absolute; top: 2px; right: 50%; transform: translateX(16px);
                background: #DC2626; color: #fff; font-size: 8px; font-weight: 800;
                min-width: 14px; height: 14px; padding: 0 3px; border-radius: 99px;
                display: flex; align-items: center; justify-content: center; line-height: 1;
            }
            /* Padding inferior para que la bottom-nav no tape contenido */
            main { padding-bottom: 64px !important; }
        }
        /* En pantallas chicas el sidebar arranca cerrado (ya lo hace), pero también
           ocultamos el toggle del sidebar en <=768 porque usamos bottom-nav. */
        @media (max-width: 768px) {
            #sidebar-toggle { display: inline-flex !important; }
        }

        /* ── Tabla → cards en mobile (regla: tablas que colapsan a cards <=640px) ── */
        @media (max-width: 640px) {
            table.collapse-cards thead { display: none; }
            table.collapse-cards, table.collapse-cards tbody { display: block; min-width: 0 !important; width: 100%; }
            table.collapse-cards tr.tr-admin {
                display: block; border: 1px solid #E2E8F0; border-radius: 12px;
                margin: 0 0 10px; padding: 6px 0; background: #fff;
            }
            table.collapse-cards tr.tr-admin:hover { background: #fff; }
            table.collapse-cards td.td-admin {
                display: flex; justify-content: space-between; align-items: center; gap: 12px;
                border-bottom: 1px solid #F1F5F9; padding: 9px 14px; text-align: right !important;
            }
            table.collapse-cards tr.tr-admin td.td-admin:last-child { border-bottom: none; }
            table.collapse-cards td.td-admin::before {
                content: attr(data-label); text-align: left;
                font-size: 10px; font-weight: 800; color: #94A3B8;
                text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0;
            }
            /* Filas de skeleton/empty/error ocupan ancho completo sin label */
            table.collapse-cards td.td-admin[colspan]::before { content: none; }
            table.collapse-cards td.td-admin[colspan] { justify-content: center; text-align: center !important; }
            /* La celda de acciones se muestra como bloque al final */
            table.collapse-cards td.td-admin.cell-actions { justify-content: flex-end; }
            /* Contenedor de tabla mobile sin scroll horizontal forzado */
            .table-wrap-mobile { overflow-x: visible !important; }
        }
    
