/* ==========================================================================
   Forensica Panel — hoja de estilos única
   Tema claro (por defecto) y oscuro. El tema lo fija un script en el <head>
   (App.razor) sobre <html data-theme="light|dark"> antes del primer pintado:
   el elegido por el usuario (guardado en el navegador) o, si no hay, el del
   sistema operativo / navegador (prefers-color-scheme).
   Estado de la interfaz en atributos de <html> (data-sidebar, data-nav,
   data-menu, data-palette, data-confirm, data-progress): el DOM de la página lo
   re-sincroniza Blazor en cada navegación, el de <html> no.
   ========================================================================== */

@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-latin-wght-normal.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ===== TOKENS ===== */
:root {
    color-scheme: light;

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --content-px: 2rem;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    /* Superficies */
    --bg: #F3F6FA;
    --surface: #FFFFFF;
    --surface-2: #F7F9FC;
    --hover: #EDF2F8;
    --border: #DDE4EE;
    --border-strong: #C3CDDB;
    --input-bg: #FFFFFF;

    /* Texto */
    --text: #061833;
    --text-2: #3C4C63;
    --text-muted: #5B6B82;
    --text-faint: #8593A8;

    /* Marca y acción: Azul oscuro (rigor técnico) en claro; Azul eléctrico en oscuro */
    --accent: #0D4EA6;
    --accent-hover: #0A3F86;
    --on-accent: #FFFFFF;
    --accent-soft: rgba(13, 78, 166, .10);
    --accent-ring: rgba(13, 78, 166, .22);
    --link: #0D4EA6;

    /* Barra lateral */
    --sidebar-bg: #FFFFFF;
    --nav-text: #4B5B72;
    --nav-hover: #EDF2F8;
    --nav-active-bg: rgba(13, 78, 166, .10);
    --nav-active-text: #0D4EA6;

    /* Tablas */
    --thead-bg: #0D4EA6;
    --thead-text: #FFFFFF;
    --row-hover: #F3F7FC;

    /* Semánticos (no son de marca) */
    --success: #15803D;  --success-bg: #DCFCE7;  --success-border: #A7E3BC;
    --warning: #B45309;  --warning-bg: #FEF3C7;  --warning-border: #F3D58A;
    --danger:  #B91C1C;  --danger-bg:  #FEE2E2;  --danger-border:  #F3B4B4;  --danger-solid: #B91C1C;  --danger-solid-hover: #991B1B;
    --info:    #0D4EA6;  --info-bg:    #E6F0FC;  --info-border:    #B7D2F2;

    --shadow-xs: 0 1px 2px rgba(6, 24, 51, .05);
    --shadow-sm: 0 1px 3px rgba(6, 24, 51, .08), 0 1px 2px rgba(6, 24, 51, .04);
    --shadow-md: 0 8px 24px rgba(6, 24, 51, .10);
    --shadow-lg: 0 24px 64px rgba(6, 24, 51, .18);
    --overlay: rgba(6, 24, 51, .45);

    /* Degradados de fondo de las páginas (mismo lenguaje que el login) */
    --glow-1: rgba(13, 78, 166, .17);
    --glow-2: rgba(0, 162, 255, .18);
    --glow-3: rgba(88, 130, 165, .16);

    --ease: cubic-bezier(.2, .8, .2, 1);

    /* Alias heredados (algunas páginas los usan en línea) */
    --color-body-bg: var(--bg);
    --color-border: var(--border);
    --color-text: var(--text);
    --color-text-muted: var(--text-muted);
    --color-sidebar-hover: var(--hover);
    --color-card-bg: var(--surface);
    --color-accent: var(--accent);
    --color-danger: var(--danger);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0B0F14;
    --surface: #151B23;
    --surface-2: #121820;
    --hover: #1A212A;
    --border: #262E39;
    --border-strong: #3A4452;
    --input-bg: #0B0F14;

    --text: #E7EAEE;
    --text-2: #C2C9D2;
    --text-muted: #8791A0;
    --text-faint: #5A6472;

    --accent: #00A2FF;
    --accent-hover: #00E0FF;
    --on-accent: #0B0F14;
    --accent-soft: rgba(0, 162, 255, .14);
    --accent-ring: rgba(0, 162, 255, .30);
    --link: #00A2FF;

    --sidebar-bg: #151B23;
    --nav-text: #A0A9B5;
    --nav-hover: #1A212A;
    --nav-active-bg: rgba(0, 162, 255, .14);
    --nav-active-text: #00A2FF;

    --thead-bg: #1A212A;
    --thead-text: #C2C9D2;
    --row-hover: #171E27;

    --success: #4ADE80;  --success-bg: rgba(34, 197, 94, .15);  --success-border: rgba(34, 197, 94, .32);
    --warning: #FBBF24;  --warning-bg: rgba(245, 158, 11, .15); --warning-border: rgba(245, 158, 11, .32);
    --danger:  #F87171;  --danger-bg:  rgba(239, 68, 68, .14);  --danger-border:  rgba(239, 68, 68, .32);  --danger-solid: #DC2626;  --danger-solid-hover: #B91C1C;
    --info:    #00A2FF;  --info-bg:    rgba(0, 162, 255, .12);  --info-border:    rgba(0, 162, 255, .30);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .20);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, .40);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, .55);
    --overlay: rgba(5, 8, 12, .66);

    --glow-1: rgba(13, 78, 166, .26);
    --glow-2: rgba(0, 162, 255, .09);
    --glow-3: rgba(92, 211, 255, .05);
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

html, body { min-height: 100%; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}

/* Fondo con degradados suaves: fijo, detrás de todo, sin animación ni filtros (barato de pintar) */
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(48% 42% at 12% 8%, var(--glow-1), transparent 70%),
        radial-gradient(46% 40% at 92% 14%, var(--glow-2), transparent 70%),
        radial-gradient(60% 46% at 60% 100%, var(--glow-3), transparent 70%);
}

/* Cambio de tema suave, solo mientras se conmuta (el script pone data-theme-anim un instante) */
html[data-theme-anim] *, html[data-theme-anim] *::before, html[data-theme-anim] *::after {
    transition: background-color .25s ease, border-color .25s ease, color .25s ease, fill .25s ease, box-shadow .25s ease !important;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
h1:focus { outline: none; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

::selection { background: var(--accent-soft); }

/* Barras de desplazamiento discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; border: 2px solid transparent; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== ESTRUCTURA ===== */
.app-shell { display: flex; min-height: 100vh; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content {
    flex: 1;
    padding: 1.5rem var(--content-px) 3rem;
}

/* ===== BARRA LATERAL ===== */
.sidebar {
    position: sticky; top: 0;
    flex: none;
    width: var(--sidebar-w);
    height: 100vh;
    display: flex; flex-direction: column;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    z-index: 60;
    transition: width .22s var(--ease), transform .28s var(--ease);
}

.sidebar-brand {
    flex: none;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
/* El logo ocupa todo el ancho disponible de la barra y queda centrado */
.sidebar-brand .sidebar-logo-full { display: block; width: 85%; height: auto; max-height: 50px; object-fit: contain; }
.sidebar-logo-mark { display: none !important; height: 34px; width: 34px; border-radius: 8px; }

/* Logo según tema: .logo-light en claro, .logo-dark en oscuro */
.sidebar-brand .logo-dark { display: none; }
:root[data-theme="dark"] .sidebar-brand .logo-light { display: none; }
:root[data-theme="dark"] .sidebar-brand .logo-dark { display: block; }
.reconnect-logo { display: flex; justify-content: center; margin-bottom: 4px; }
.reconnect-logo img { display: block; height: 36px; width: auto; }
.reconnect-logo .logo-dark { display: none; }
:root[data-theme="dark"] .reconnect-logo .logo-light { display: none; }
:root[data-theme="dark"] .reconnect-logo .logo-dark { display: block; }
.confirm-card:focus, .confirm-card:focus-visible, #blazor-error-ui:focus-visible { outline: none; }
.login-logo .logo-dark { display: none; }
:root[data-theme="dark"] .login-logo .logo-light { display: none; }
:root[data-theme="dark"] .login-logo .logo-dark { display: inline; }

/* El menú hace scroll si la ventana es baja; el logo se queda arriba */
.nav-scrollable {
    flex: 1; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 6px 12px 16px;
}

.sidebar-section-label {
    color: var(--text-muted);
    font-size: 10.5px; font-weight: 600;
    letter-spacing: .09em; text-transform: uppercase;
    padding: 18px 12px 6px;
    white-space: nowrap;
}
.sidebar-section-label:first-child { padding-top: 12px; }

.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    height: 42px;
    padding: 0 12px;
    margin: 1px 0;
    color: var(--nav-text);
    font-size: 14px; font-weight: 500;
    border-radius: 10px;
    white-space: nowrap;
    transition: background-color .15s, color .15s;
}
.nav-item:hover { background: var(--nav-hover); color: var(--text); text-decoration: none; }

.nav-item svg { width: 20px; height: 20px; flex: none; opacity: .85; transition: opacity .15s; }
.nav-item:hover svg { opacity: 1; }

.nav-item.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
    content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
    background: var(--accent); border-radius: 0 3px 3px 0;
    animation: nav-bar .28s var(--ease) both;
}
@keyframes nav-bar { from { transform: scaleY(.2); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

.sidebar-foot {
    flex: none;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
    color: var(--text-faint); font-size: 11.5px;
}
.sidebar-foot kbd { margin-left: auto; }
.sidebar-foot svg { width: 16px; height: 16px; flex: none; }
.chev svg, .search-icon svg { display: block; width: 100%; height: 100%; }

kbd {
    display: inline-block;
    padding: 1px 6px;
    font: 600 11px/1.5 'Inter', system-ui, sans-serif;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
}

/* Barra lateral contraída (escritorio) */
@media (min-width: 901px) {
    html[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-w-collapsed); }
    html[data-sidebar="collapsed"] .sidebar-brand { padding: 0; justify-content: center; }
    html[data-sidebar="collapsed"] .sidebar-logo-full { display: none !important; }
    html[data-sidebar="collapsed"] .sidebar-logo-mark.logo-light { display: block !important; }
    html[data-sidebar="collapsed"][data-theme="dark"] .sidebar-logo-mark.logo-light { display: none !important; }
    html[data-sidebar="collapsed"][data-theme="dark"] .sidebar-logo-mark.logo-dark { display: block !important; }
    html[data-sidebar="collapsed"] .nav-scrollable { padding-left: 14px; padding-right: 14px; overflow: visible; overflow-y: auto; }
    html[data-sidebar="collapsed"] .nav-label,
    html[data-sidebar="collapsed"] .sidebar-foot span,
    html[data-sidebar="collapsed"] .sidebar-foot kbd { display: none; }
    html[data-sidebar="collapsed"] .sidebar-section-label {
        font-size: 0; height: 1px; padding: 0; margin: 12px 8px; background: var(--border);
    }
    html[data-sidebar="collapsed"] .sidebar-section-label:first-child { display: none; }
    html[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 0; }
    html[data-sidebar="collapsed"] .nav-item.active::before { left: -14px; }
    html[data-sidebar="collapsed"] .sidebar-foot { justify-content: center; }

    /* Etiqueta emergente de cada opción cuando solo se ven los iconos */
    html[data-sidebar="collapsed"] .nav-item::after {
        content: attr(data-tip);
        position: fixed;
        left: calc(var(--sidebar-w-collapsed) + 8px);
        padding: 6px 10px;
        background: var(--text); color: var(--bg);
        font-size: 12.5px; font-weight: 500;
        border-radius: 8px;
        box-shadow: var(--shadow-md);
        opacity: 0; transform: translateX(-4px); pointer-events: none;
        transition: opacity .15s, transform .15s;
        z-index: 200;
    }
    html[data-sidebar="collapsed"] .nav-item:hover::after { opacity: 1; transform: none; }
}

/* ===== BARRA SUPERIOR ===== */
.topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 var(--content-px);
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: 1px solid var(--border);
}

.icon-btn {
    flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: none; background: none;
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color .15s, color .15s, transform .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; }
.topbar .icon-btn:first-child { margin-left: -10px; }

.topbar-spacer { flex: 1; }

/* Acceso rápido a la búsqueda de la aplicación */
.palette-trigger {
    display: none;
    align-items: center; gap: 10px;
    height: 40px; min-width: 280px;
    padding: 0 8px 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.palette-trigger:hover { border-color: var(--border-strong); background: var(--surface); }
.palette-trigger svg { width: 16px; height: 16px; flex: none; }
.palette-trigger span { flex: 1; text-align: left; }
@media (min-width: 720px) { .palette-trigger { display: inline-flex; } }

/* Conmutador de tema: tres iconos, se ve el del modo elegido */
.theme-toggle .ti { display: none; }
:root[data-theme-pref="auto"] .theme-toggle .ti-auto,
:root[data-theme-pref="light"] .theme-toggle .ti-light,
:root[data-theme-pref="dark"] .theme-toggle .ti-dark { display: block; animation: spin-in .4s var(--ease); }
:root:not([data-theme-pref]) .theme-toggle .ti-auto { display: block; }
@keyframes spin-in { from { transform: rotate(-70deg) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }

/* Menú de usuario */
.user-menu { position: relative; }
.user-trigger {
    display: flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 8px 0 4px;
    border: none; background: none; border-radius: 12px;
    color: var(--text); cursor: pointer;
    transition: background-color .15s;
}
.user-trigger:hover, html[data-menu="user"] .user-trigger { background: var(--hover); }
.user-avatar {
    flex: none; width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #00A2FF);
    color: #fff; font-weight: 700; font-size: 13px;
}
:root[data-theme="dark"] .user-avatar { background: linear-gradient(135deg, #0D4EA6, #00A2FF); }
/* Si el usuario tiene imagen, tapa la inicial (si no carga, el <img> se quita con onerror y se ve la inicial). */
.user-avatar { position: relative; overflow: hidden; }
.user-avatar img, .avatar-lg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Avatar grande de la página «Mi perfil». */
.avatar-lg {
    position: relative; overflow: hidden; flex: none; width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: linear-gradient(135deg, var(--accent), #00A2FF);
    color: #fff; font-weight: 700; font-size: 26px;
}
.user-trigger-name { display: none; font-size: 13.5px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-trigger .chev { width: 14px; height: 14px; color: var(--text-muted); transition: transform .2s var(--ease); display: none; }
@media (min-width: 720px) { .user-trigger-name, .user-trigger .chev { display: block; } }
html[data-menu="user"] .user-trigger .chev { transform: rotate(180deg); }

.dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top right;
    transition: opacity .16s, transform .2s var(--ease), visibility 0s .2s;
    z-index: 80;
}
html[data-menu="user"] .dropdown { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.dropdown-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-mail { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-role { margin-top: 8px; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    height: 40px; padding: 0 12px;
    border: none; background: none; border-radius: 8px;
    color: var(--text-2); font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
    transition: background-color .15s, color .15s;
}
.dropdown-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.dropdown-item svg { width: 18px; height: 18px; flex: none; }
.dropdown-item.danger:hover { background: var(--danger-bg); color: var(--danger); }
.dropdown form { margin: 0; }

/* ===== CABECERA DE PÁGINA (fija bajo la barra superior) ===== */
.page-header {
    position: sticky; top: var(--topbar-h); z-index: 30;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: .75rem 1rem;
    margin: -1.5rem calc(var(--content-px) * -1) 1.5rem;
    padding: 1rem var(--content-px);
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .25s;
    animation: header-in .35s var(--ease) both;
}
html[data-scrolled] .page-header { box-shadow: var(--shadow-md); }
@keyframes header-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.page-header-main { min-width: 0; }
.page-header h1 { font-size: 1.5rem; margin: 0; overflow-wrap: anywhere; }

.breadcrumb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin-top: 2px; font-size: 12.5px; color: var(--text-muted); }
.breadcrumb-row a { color: var(--text-muted); }
.breadcrumb-row a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb-row .sep { margin: 0 .45rem; color: var(--text-faint); }
.breadcrumb-row .current { color: var(--text-2); font-weight: 500; }

.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.page-actions .btn, .page-actions .btn-sm { height: 40px; padding-top: 0; padding-bottom: 0; }

/* Mensaje (error / éxito) dentro de la cabecera: se ve siempre, aunque se haya hecho scroll */
.page-header .alert-cabecera {
    flex: 0 0 100%; margin: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    animation: rise .25s var(--ease) both;
}
.alert-cerrar { background: none; border: 0; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .25rem; opacity: .7; }
.alert-cerrar:hover { opacity: 1; }

.page-intro { color: var(--text-muted); font-size: 13.5px; margin: -.5rem 0 1.25rem; max-width: 70ch; }

/* ===== TARJETAS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    animation: rise .38s var(--ease) both;
}
.card:has(> .table-wrapper:first-child) { padding: 0; overflow: hidden; }

.content > .card:nth-of-type(2) { animation-delay: .04s; }
.content > .card:nth-of-type(3) { animation-delay: .08s; }
.content > .card:nth-of-type(n+4) { animation-delay: .12s; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { font-size: 13.5px; color: var(--text-muted); margin-bottom: 1.25rem; }

/* ===== BOTONES ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    font-size: 13.5px; font-weight: 600; line-height: 1.2;
    border-radius: 10px; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .12s;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(6, 24, 51, .18); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--on-accent); box-shadow: 0 4px 14px var(--accent-ring); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--hover); border-color: var(--text-faint); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }

.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-solid-hover); color: #fff; box-shadow: 0 4px 14px rgba(185, 28, 28, .3); }

.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn-min-w { min-width: 120px; }

/* Botones de acción de fila (editar / eliminar / ver) */
.btn-icon {
    min-height: 0; width: 34px; height: 34px; padding: 0;
    border: 1px solid var(--border); background: var(--surface); color: var(--accent);
    border-radius: 9px;
}
.btn-icon.btn-ghost, .btn-icon.btn-sm { min-height: 0; padding: 0; }
.btn-icon:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.btn-danger-ghost { color: var(--danger); }
.btn-icon.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-danger-ghost:not(.btn-icon):hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ===== FORMULARIOS ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }

.form-control {
    display: block; width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    font-family: inherit; font-size: 14px;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.form-control:hover { border-color: var(--text-faint); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.form-control::placeholder { color: var(--text-faint); }
.form-control[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea.form-control { min-height: 0; resize: vertical; line-height: 1.5; }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2394A3B8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    appearance: none;
    cursor: pointer;
}

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 1rem; }

/* Buscador de las cabeceras */
.search-box { position: relative; display: flex; align-items: center; flex: 1 1 15rem; min-width: 12rem; max-width: 22rem; }
.search-box .search-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; transition: color .15s; }
.search-box:focus-within .search-icon { color: var(--accent); }
.search-input {
    width: 100%; height: 40px;
    padding: 0 36px 0 36px;
    font-family: inherit; font-size: 13.5px; color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search-input::placeholder { color: var(--text-faint); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-clear {
    position: absolute; right: 6px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; border-radius: 50%;
    color: var(--text-faint); cursor: pointer;
    opacity: 0; pointer-events: none; transition: opacity .15s, background-color .15s;
}
.search-clear svg { width: 14px; height: 14px; }
.search-box.has-value .search-clear { opacity: 1; pointer-events: auto; }
.search-clear:hover { background: var(--hover); color: var(--text); }

/* ===== EDITOR DE TEXTO ENRIQUECIDO ===== */
.rte {
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    overflow: hidden;
    background: var(--input-bg);
    transition: border-color .15s, box-shadow .15s;
}
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.rte-toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.rte-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 7px;
    border: 1px solid transparent; border-radius: 7px;
    background: transparent; color: var(--text-2);
    font-size: 13px; cursor: pointer; transition: background-color .15s, border-color .15s;
}
.rte-btn:hover { background: var(--hover); border-color: var(--border); }
.rte-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.rte-content { min-height: 140px; max-height: 420px; overflow-y: auto; padding: 10px 12px; font-size: 14px; color: var(--text); outline: none; }
.rte-content:empty::before { content: attr(data-placeholder); color: var(--text-faint); }
.rte-content p { margin: 0 0 8px; }
.rte-content ul, .rte-content ol { margin: 0 0 8px; padding-left: 24px; }

.html-content { font-size: 14px; color: var(--text); }
.html-content p { margin: 0 0 8px; }
.html-content p:last-child { margin-bottom: 0; }
.html-content ul, .html-content ol { margin: 0 0 8px; padding-left: 24px; }

/* ===== TABLAS ===== */
.table-wrapper { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.data-table th {
    padding: 12px 16px; text-align: left;
    font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--thead-text); background: var(--thead-bg);
    white-space: nowrap;
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tbody tr { transition: background-color .12s; }
.data-table tbody tr:hover { background: var(--row-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table a { font-weight: 500; }
/* Primera celda de las listas: un icono del tipo de fila en una cápsula con el tono de acción. */
.data-table th.cell-icon, .data-table td.cell-icon { width: 1%; padding-right: 0; }
.row-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--hover); color: var(--accent); vertical-align: middle; }
.row-icon svg { width: 20px; height: 20px; }
/* Filtro por tipología (chips con contador) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip span { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.chip:hover { background: var(--hover); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.active span { color: inherit; opacity: .8; }
.row-icon.row-icon-danger { background: var(--danger-bg); color: var(--danger); }

/* Tabla anidada dentro de otra tarjeta: marco propio */
.card .table-wrapper:not(:first-child) { border: 1px solid var(--border); border-radius: var(--radius-sm); }

.table-footer { padding: 10px 16px; font-size: 12.5px; color: var(--text-muted); border-top: 1px solid var(--border); background: var(--surface-2); }

/* ===== INSIGNIAS ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; line-height: 1.6; background: var(--hover); color: var(--text-2); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--accent-soft); color: var(--accent); }

/* ===== ALERTAS ===== */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 1rem; border: 1px solid transparent; animation: rise .3s var(--ease) both; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: var(--overlay);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    animation: fade-in .2s ease both;
}
.modal {
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    animation: modal-in .28s var(--ease) both;
}
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.modal-body { padding: 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 16px 16px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* ===== CARGA: spinner y esqueletos ===== */
.spinner {
    width: 20px; height: 20px; display: inline-block;
    border: 2px solid var(--border-strong); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton, .sk-line {
    border-radius: 8px;
    background: linear-gradient(90deg, var(--hover) 25%, var(--surface-2) 37%, var(--hover) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}
.sk-line { height: 14px; }
.sk-row { display: flex; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: none; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Esqueleto de página mientras llega el circuito interactivo: solo si tarda (no parpadea en cargas rápidas) */
.page-boot { opacity: 0; animation: fade-in .3s ease .25s forwards; }
.content:has(.page-header) .page-boot, .content:has(.page-ready) .page-boot { display: none; }

/* ===== ESTADO VACÍO ===== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3rem 1.5rem; gap: .5rem; }
/* Ilustración sin caja: crece con la pantalla (de 80 a 128 px) */
.empty-state-icon { display: flex; align-items: center; justify-content: center; color: var(--accent); opacity: .9; margin-bottom: .75rem; }
.empty-state-icon svg { width: clamp(80px, 9vw, 128px); height: clamp(80px, 9vw, 128px); }
.empty-state h2 { font-size: 1.05rem; }
.empty-state p { color: var(--text-muted); max-width: 42ch; }
.empty-state .btn { margin-top: .75rem; }

/* ===== INICIO (panel) ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi-card { display: flex; align-items: center; gap: 18px; padding: 1.1rem 1.25rem; margin-bottom: 0; color: inherit; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
a.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); text-decoration: none; }
.kpi-icon { flex: none; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.kpi-icon svg { width: 52px; height: 52px; }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 13px; color: var(--text-muted); }

.home-hello { font-size: 13.5px; color: var(--text-muted); margin: -.5rem 0 1.25rem; }
.home-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1100px) { .home-cols { grid-template-columns: 1fr; } }
.quick-list { display: flex; flex-direction: column; gap: 6px; margin-top: .75rem; }
.quick-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; transition: background-color .15s, transform .15s; }
.quick-link:hover { background: var(--hover); text-decoration: none; transform: translateX(2px); }
.quick-link svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.quick-link .chev { margin-left: auto; width: 14px; height: 14px; color: var(--text-faint); }

/* ----- Dashboard: gráficos en CSS puro (una sola tonalidad de marca, rejilla discreta) ----- */
.kpi-card.kpi-warn .kpi-icon, .kpi-card.kpi-warn .kpi-value { color: var(--warning); }
.dash-row { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; align-items: stretch; }
.dash-row > .card { margin-bottom: 0; min-width: 0; }
.dash-row-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dash-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1200px) { .dash-row-3 { grid-template-columns: 1fr 1fr; } .dash-row-3 > :last-child { grid-column: 1 / -1; } }
@media (max-width: 900px)  { .dash-row-2-1, .dash-row-3 { grid-template-columns: 1fr; } }

.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 1rem; }
.chart-head .card-title { margin: 0; }
.chart-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.chart-empty { color: var(--text-muted); font-size: 13.5px; display: flex; align-items: center; gap: 8px; padding: 1.5rem 0; }
.chart-empty svg { width: 18px; height: 18px; }
.chart-ok svg { color: var(--success); }

.chart-plot { position: relative; height: 180px; padding-left: 28px; }
.chart-plot-sm { height: 140px; }
.chart-grid { position: absolute; inset: 0; pointer-events: none; }
.chart-grid span { position: absolute; left: 0; right: 0; bottom: var(--y); border-top: 1px solid var(--border); }
.chart-grid span:last-child { border-top-color: var(--border-strong); }
.chart-grid i { position: absolute; left: 0; top: -8px; width: 22px; text-align: right; font-style: normal; font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.cols { position: relative; height: 100%; display: flex; align-items: flex-end; gap: 3px; }
.cols-wide { gap: 14px; padding: 0 6px; }
.col { position: relative; flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.col-bar { display: block; width: 100%; max-width: 24px; min-height: 3px; background: var(--accent); border-radius: 4px 4px 0 0; transform-origin: bottom; animation: bar-grow .5s var(--ease) both; transition: filter .15s; }
.col:hover .col-bar { filter: brightness(1.25); }
.col-val { font-size: 11.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; margin-bottom: 3px; }
@keyframes bar-grow { from { transform: scaleY(0); } }

.chart-x { display: flex; justify-content: space-between; padding-left: 28px; margin-top: 6px; font-size: 11px; color: var(--text-faint); }
.chart-x-even { padding: 6px 6px 0 28px; gap: 14px; }
.chart-x-even span { flex: 1; text-align: center; text-transform: capitalize; }

/* Aviso al pasar el cursor: igual en columnas y en barras horizontales */
.col[data-tip]::after, .hbar-row[data-tip]::after {
    content: attr(data-tip); position: absolute; z-index: 20; pointer-events: none; white-space: nowrap;
    padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 500;
    background: var(--text); color: var(--bg); box-shadow: var(--shadow-md);
    opacity: 0; transition: opacity .12s;
}
.col[data-tip]::after { bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%); }
.hbar-row[data-tip]::after { bottom: 100%; left: 30%; }
.col:hover::after, .hbar-row:hover::after { opacity: 1; }

.chart-table { margin-top: .75rem; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--text-muted); width: max-content; }
.chart-table summary:hover { color: var(--text); }
.chart-table .data-table { margin-top: .5rem; }

.hbars { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.hbar-row { position: relative; display: grid; grid-template-columns: minmax(70px, 34%) minmax(0, 1fr) 28px; align-items: center; gap: 10px; }
.hbar-label { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; transform-origin: left; animation: hbar-grow .5s var(--ease) both; }
@keyframes hbar-grow { from { transform: scaleX(0); } }
.hbar-row-wide { grid-template-columns: minmax(56px, 34%) minmax(0, 1fr) 64px; }
.hbars-tight { gap: 11px; }

/* Almacenamiento: total, reparto vídeo / resto en una barra apilada (mismo tono de marca, dos intensidades) */
.dash-row-storage { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.25fr) minmax(0, 1fr); }
.storage-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 14px; }
.storage-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stack { position: relative; display: flex; gap: 2px; height: 14px; }
.stack-seg { position: relative; display: block; height: 100%; min-width: 4px; }
.stack-seg:first-child { border-radius: 7px 0 0 7px; }
.stack-seg:last-child { border-radius: 0 7px 7px 0; }
.stack-seg:only-child { border-radius: 7px; }
.stack-a { background: var(--accent); }
.stack-b { background: color-mix(in srgb, var(--accent) 38%, var(--surface)); }
.stack-seg[data-tip]::after {
    content: attr(data-tip); position: absolute; z-index: 20; pointer-events: none; white-space: nowrap;
    bottom: calc(100% + 6px); left: 0; padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 500;
    background: var(--text); color: var(--bg); box-shadow: var(--shadow-md); opacity: 0; transition: opacity .12s;
}
.stack-seg:hover::after { opacity: 1; }
.stack-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 18px; font-size: 12.5px; color: var(--text-muted); }
.stack-legend strong { color: var(--text-2); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.chart-mini-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 0 0 10px; }

/* ----- Pestañas de los formularios (Datos / Propiedades / Auditoría) ----- */
.tab-strip { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab-strip button {
    appearance: none; background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 10px 16px; font: inherit; font-weight: 500; color: var(--text-muted); cursor: pointer; white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.tab-strip button:hover { color: var(--text); }
.tab-strip button.active { color: var(--accent); border-bottom-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

/* Propiedades: quién creó y modificó */
.props-list { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px 20px; margin: 0; padding: 14px 16px; }
.props-list dt { color: var(--text-muted); font-size: 16px; font-weight: 600; }
.props-list dd { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
@media (max-width: 600px) { .props-list { grid-template-columns: 1fr; gap: 2px 0; } .props-list dd { margin-bottom: 10px; } }

/* Auditoría */
.audit-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 1rem; }
.audit-filters .form-group { margin: 0; min-width: 150px; }
.audit-filters .form-control { min-height: 38px; }
.audit-row { cursor: pointer; }
.audit-row:hover td { background: var(--hover); }
.audit-row td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit-detail > td { background: var(--surface-2); padding: 14px 18px !important; }
.audit-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; margin: 0 0 12px; }
.audit-meta dt { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.audit-meta dd { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.audit-changes { width: 100%; font-size: 13px; border-collapse: collapse; }
.audit-changes th, .audit-changes td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.audit-changes th { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.audit-old { color: var(--danger); }
.audit-new { color: var(--success); }
.badge-src { background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.audit-more { display: flex; justify-content: center; padding: 14px; }
@media (max-width: 1200px) { .dash-row-storage { grid-template-columns: 1fr 1fr; } .dash-row-storage > :last-child { grid-column: 1 / -1; } }
@media (max-width: 900px) { .dash-row-storage { grid-template-columns: 1fr; } }
.hbar-value { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.event { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 8px; margin: 0 -8px; border-radius: 9px; color: var(--text); transition: background-color .15s; }
.event:hover { background: var(--hover); text-decoration: none; }
.event-main { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.event-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-main .text-muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-time { flex: none; font-size: 12px; color: var(--text-faint); }
.quick-count { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.quick-count + .chev { margin-left: 8px; }
@media (prefers-reduced-motion: reduce) { .col-bar, .hbar-fill { animation: none; } }

/* ===== UTILIDADES ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* Vista previa de una imagen de marca (logotipo de la organización) sobre el fondo de la página. */
.logo-preview {
    display: inline-block;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--bg);
}
.logo-preview img { display: block; max-width: 280px; max-height: 120px; }
.pt-3 { padding-top: 12px; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 12.5px; }
.w-full { width: 100%; }

/* ===== PROGRESO DE NAVEGACIÓN ===== */
.nav-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000; pointer-events: none; opacity: 0; }
.nav-progress::before {
    content: ""; display: block; height: 100%; width: 100%;
    background: linear-gradient(90deg, var(--accent), #00E0FF);
    box-shadow: 0 0 10px var(--accent);
    transform-origin: left; transform: scaleX(0);
}
html[data-progress="loading"] .nav-progress { opacity: 1; }
html[data-progress="loading"] .nav-progress::before { animation: progress-run 8s cubic-bezier(.1, .6, .2, 1) forwards; }
html[data-progress="done"] .nav-progress { opacity: 0; transition: opacity .35s ease .12s; }
html[data-progress="done"] .nav-progress::before { transform: scaleX(1); transition: transform .15s ease-out; }
@keyframes progress-run { 0% { transform: scaleX(0); } 20% { transform: scaleX(.55); } 100% { transform: scaleX(.92); } }

/* ===== BÚSQUEDA RÁPIDA (Ctrl+K) Y CONFIRMACIÓN ===== */
.palette, .confirm {
    position: fixed; inset: 0; z-index: 1500;
    display: none; align-items: flex-start; justify-content: center;
    padding: 12vh 16px 16px;
    background: var(--overlay);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.confirm { align-items: center; padding: 16px; }
html[data-palette="open"] .palette, html[data-confirm="open"] .confirm { display: flex; animation: fade-in .16s ease both; }

.palette-card {
    width: 100%; max-width: 560px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow-lg);
    animation: modal-in .24s var(--ease) both;
}
.palette-input-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input-row svg { width: 18px; height: 18px; color: var(--text-faint); flex: none; }
.palette-input { flex: 1; height: 54px; border: none; outline: none; background: none; color: var(--text); font-family: inherit; font-size: 15px; }
.palette-input::placeholder { color: var(--text-faint); }
.palette-list { list-style: none; max-height: 52vh; overflow-y: auto; padding: 8px; }
.palette-group { padding: 10px 12px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); }
.palette-item { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; color: var(--text-2); cursor: pointer; }
.palette-item svg { width: 18px; height: 18px; flex: none; color: var(--text-muted); }
.palette-item .hint { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.palette-item[aria-selected="true"] svg { color: var(--accent); }
.palette-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--text-faint); font-size: 12px; }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

.confirm-card {
    width: 100%; max-width: 420px; padding: 28px 28px 22px; text-align: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; box-shadow: var(--shadow-lg);
    animation: modal-in .26s var(--ease) both;
}
.confirm-icon { width: 52px; height: 52px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--danger-bg); color: var(--danger); }
.confirm-icon svg { width: 26px; height: 26px; }
.confirm-card h2 { font-size: 1.1rem; margin-bottom: 8px; }
.confirm-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; overflow-wrap: anywhere; }
.confirm-actions { display: flex; flex-direction: column; gap: 8px; }
.confirm-actions .btn { width: 100%; min-height: 42px; }
@media (min-width: 420px) { .confirm-actions { flex-direction: row; } }

/* ===== VOLVER ARRIBA ===== */
/* Pequeño y translúcido, pegado a la esquina: no tapa el contenido y solo aparece tras bajar unos 400 px. */
.scroll-top {
    position: fixed; right: 20px; bottom: 20px; z-index: 90;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; border: 1px solid var(--border-strong); cursor: pointer;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    color: var(--text-2); box-shadow: var(--shadow-md);
    opacity: 0; visibility: hidden; transform: translateY(8px);
    transition: opacity .2s, transform .2s var(--ease), visibility 0s .2s, background-color .15s, color .15s, border-color .15s;
}
.scroll-top svg { width: 18px; height: 18px; }
html[data-scroll-top] .scroll-top { opacity: .92; visibility: visible; transform: none; transition-delay: 0s; }
html[data-scroll-top] .scroll-top:hover { opacity: 1; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scroll-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== AVISOS EMERGENTES ===== */
/* Los avisos se apilan por encima del botón de volver arriba */
.toasts { position: fixed; right: 20px; bottom: 76px; z-index: 1600; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
    display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 360px;
    padding: 12px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 500;
    background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
    animation: toast-in .3s var(--ease) both;
}
.toast.out { animation: toast-out .25s ease forwards; }
.toast svg { width: 18px; height: 18px; flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }

/* ===== LOGIN ===== */
.login-page {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: #F4F6FF;
}
:root[data-theme="dark"] .login-page { background: #0B0F14; }

.login-page::before {
    content: ""; position: absolute; inset: -20%;
    background:
        radial-gradient(40% 40% at 20% 25%, rgba(13, 78, 166, .35), transparent 70%),
        radial-gradient(45% 45% at 85% 20%, rgba(0, 162, 255, .28), transparent 70%),
        radial-gradient(50% 50% at 50% 90%, rgba(88, 130, 165, .25), transparent 70%);
    filter: blur(60px);
    animation: aurora-drift 20s ease-in-out infinite alternate;
}
:root[data-theme="dark"] .login-page::before {
    background:
        radial-gradient(40% 40% at 20% 25%, rgba(13, 78, 166, .38), transparent 70%),
        radial-gradient(45% 45% at 85% 20%, rgba(0, 162, 255, .20), transparent 70%),
        radial-gradient(50% 50% at 50% 90%, rgba(92, 211, 255, .10), transparent 70%);
}
@keyframes aurora-drift { 0% { transform: translate3d(0, 0, 0) scale(1); } 100% { transform: translate3d(2%, -2%, 0) scale(1.05); } }

.login-theme { position: absolute; top: 16px; right: 16px; z-index: 2; }

.login-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 24rem;
    padding: 2.5rem 2.5rem 2.25rem;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 1.1rem;
    box-shadow: var(--shadow-lg);
    animation: rise .6s var(--ease) both;
}
:root[data-theme="dark"] .login-card { background: rgba(21, 27, 35, .78); border-color: rgba(255, 255, 255, .08); }

.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo-img { height: 46px; width: auto; margin-bottom: 10px; vertical-align: middle; }
.login-logo-sub { font-size: 13px; color: var(--text-muted); }
.login-card .form-control { background: rgba(255, 255, 255, .7); }
:root[data-theme="dark"] .login-card .form-control { background: rgba(11, 15, 20, .6); }
.login-card .btn-primary { min-height: 44px; margin-top: .5rem; }

/* ===== BLAZOR ===== */
#blazor-error-ui {
    display: none; position: fixed; left: 0; bottom: 0; width: 100%; z-index: 2100;
    padding: .7rem 1.25rem;
    background: var(--danger-bg); color: var(--danger);
    border-top: 1px solid var(--danger-border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .15);
}
#blazor-error-ui .reload { color: inherit; font-weight: 600; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .6rem; }

.blazor-error-boundary { padding: 1rem 1rem 1rem 1rem; background: var(--danger-bg); color: var(--danger); border-radius: 10px; }
.blazor-error-boundary::after { content: "Se ha producido un error."; }

/* ===== PANTALLAS PEQUEÑAS: barra lateral como cajón ===== */
@media (max-width: 900px) {
    :root { --content-px: 1rem; }
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-102%); box-shadow: var(--shadow-lg); width: min(var(--sidebar-w), 86vw); }
    html[data-nav="open"] .sidebar { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 55; background: var(--overlay); opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }
    html[data-nav="open"] .sidebar-backdrop { opacity: 1; visibility: visible; transition-delay: 0s; }
    html[data-nav="open"] body { overflow: hidden; }
    .page-header { padding: .85rem var(--content-px); }
    .sidebar-foot kbd { display: none; }
    .page-header h1 { font-size: 1.25rem; }
    .search-box { max-width: none; flex-basis: 100%; order: 5; }
    .page-actions { width: 100%; }
    .modal-body { padding: 18px; }
    .toasts { left: 16px; right: 16px; bottom: 68px; }
    .scroll-top { right: 16px; bottom: 16px; }
}
@media (min-width: 901px) { .sidebar-backdrop { display: none; } }

/* En móvil la cabecera no se fija: con buscador, selector y botón ocuparía media pantalla */
@media (max-width: 640px) {
    .page-header { position: static; }
}

/* ===== MOVIMIENTO REDUCIDO ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
    body::before { display: none; }
    .sidebar, .topbar, .nav-progress, .palette, .confirm, .toasts, .scroll-top { display: none !important; }
    .page-header { position: static; box-shadow: none; }
    .card { box-shadow: none; animation: none; }
}

/* Resumen de la suscripción (pestaña «Resumen» de la organización) */
.summary-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 28px; margin: 0; flex: 1; max-width: 640px; }
.summary-facts dt { font-size: .78rem; color: var(--text-muted); font-weight: 500; }
.summary-facts dd { margin: 2px 0 0; font-weight: 600; color: var(--text); }
.offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 6px; }
.offer { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; }
.offer-name { font-weight: 700; font-size: 1.02rem; }
.offer-price { font-size: 1.5rem; font-weight: 700; margin: 4px 0 2px; color: var(--text); }
.offer .btn { align-self: flex-start; margin-top: auto; }
