/* ═══════════════════════════════════════════════════════════════
   BRANDGINEERS SHELL 2.0 — Core v5.0 (18/10/2026)
   Plantilla base de TODOS los proyectos (.NET Core / Blazor).
   Reescritura limpia: reemplaza las capas v1–v4 (sin parches aditivos).

   CÓMO RE-TEMATIZAR UN CLIENTE
   1. Cambia SOLO --brand en :root (sección 1).
      Todo lo demás (tintes, hover, foco, texto sobre marca) se deriva solo.
   2. Reemplaza images/logo.png, images/icono.png (PNG transparentes).
   3. El tema oscuro NO usa el color de marca: es una escala neutra de
      negros, grises y blancos. Solo el logo conserva su color.
   4. MARCA CLARA (amarillo, lima, celeste, naranja claro…): además pon en
      appsettings.json  "Sistema": { "TonoMarca": "claro" }.  AppRoot.razor
      agrega <html data-brand-tone="light"> y se aplica la sección 1c:
      botones de marca con texto negro y tema oscuro "marca sobre negro".

   REGLAS DE COLOR
   - --brand / --p*: acciones e interacción (botón principal, activo, foco).
   - Semánticos (--success, --warning, --danger, --info): SOLO estados.
   - Neutros: todo lo demás (superficies, íconos en reposo, bordes).

   Carga después de bootstrap.min.css y site.css (ver AppRoot.razor).
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ══════════════════════════ 1. TOKENS — TEMA CLARO ══════════════════════════ */
:root {
    /* ▸ PALETA DE MARCAS (colores vivos ya calibrados: texto blanco legible y
         tintes con presencia). Para cada cliente elige UNA en --brand y copia su
         RGB en --brand-rgb. Todo lo demás (botones, activo, tintes, foco, tablas)
         se calcula a partir de --brand.
         Nombre       HEX       RGB            Uso sugerido */
    --marca-indigo:    #4233CE; /* 66, 51, 206   · Índigo Brandgineers (por defecto) — tecnología, institucional */
    --marca-cobalto:   #1D4ED8; /* 29, 78, 216   · Azul cobalto — salud, clínicas, confianza */
    --marca-electrico: #2563EB; /* 37, 99, 235   · Azul eléctrico — educación, servicios, software */
    --marca-turquesa:  #0E7490; /* 14, 116, 144  · Turquesa — odontología, laboratorios, bienestar */
    --marca-teal:      #0F766E; /* 15, 118, 110  · Verde azulado — terapias, psicología, veterinaria */
    --marca-esmeralda: #047857; /* 4, 120, 87    · Verde esmeralda — colegios, ambiental, agro */
    --marca-violeta:   #6D28D9; /* 109, 40, 217  · Violeta — academias, eventos, creatividad */
    --marca-uva:       #7E22CE; /* 126, 34, 206  · Morado uva — salud femenina, estética */
    --marca-fucsia:    #BE185D; /* 190, 24, 93   · Fucsia — belleza, spa, moda */
    --marca-carmesi:   #BE123C; /* 190, 18, 60   · Carmesí — restaurantes, deportes, energía */
    --marca-naranja:   #C2410C; /* 194, 65, 12   · Naranja quemado — restaurantes, delivery, talleres */
    --marca-marino:    #1E3A8A; /* 30, 58, 138   · Azul marino — legal, contable, financiero, giros */
    /* Marcas CLARAS: requieren "TonoMarca": "claro" (sección 1c), texto negro encima. */
    --marca-amarillo:  #FFC20E; /* 255, 194, 14  · Amarillo industrial — maquinaria, construcción, transporte */
    --marca-lima:      #A3E635; /* 163, 230, 53  · Lima — deportes, gimnasios, ecológico */
    --marca-celeste:   #38BDF8; /* 56, 189, 248  · Celeste — piscinas, limpieza, turismo */

    /* Notas: esmeralda se parece al verde de "éxito" y carmesí al rojo de "peligro";
       úsalos solo si son la identidad real del cliente. Si el cliente tiene un color
       propio que no está aquí, ponlo directo en --brand (se normaliza solo, 1b). */

    /* ▸ Marca del cliente: lo ÚNICO que se cambia por proyecto */
    --brand: var(--marca-amarillo);
    /* Legado: RGB de la marca elegida (solo para rgba(var(--brand-rgb), x)). */
    --brand-rgb: 255, 194, 14;

    /* ▸ Color de acción (botones principales, activo, foco, enlaces).
         Por defecto = --brand. Si el color de marca del cliente es muy apagado,
         gris/negro o muy claro (amarillo, celeste), define aquí otro color de su
         paleta: es el ÚNICO otro valor que se puede tocar por proyecto. */
    --accent: var(--brand);

    /* ▸ Rol "acción" (derivado de --accent). En oscuro pasa a neutro.
         Con navegadores actuales se "normaliza" (sección 1b) para que cualquier
         color de cliente tenga saturación y contraste suficientes. */
    --p: var(--accent);
    --on-p: #FFFFFF;
    --p-hover: color-mix(in oklab, var(--p) 84%, #000);
    --p-soft: color-mix(in oklab, var(--p) 13%, #fff);
    --p-soft-2: color-mix(in oklab, var(--p) 22%, #fff);
    --p-text: color-mix(in oklab, var(--p) 90%, #000);
    --p-line: color-mix(in oklab, var(--p) 52%, #E7E2DB);
    --p-ring: color-mix(in srgb, var(--p) 28%, transparent);

    /* ▸ Superficies y texto — NEUTROS CÁLIDOS (Core 3.14)
       Grises «piedra» (leve tinte cálido) en vez de grises azulados: la calidez
       está en los neutros, no en la marca. Fondo con un leve tinte de marca, brillo
       de marca arriba y uno durazno muy tenue abajo; tarjetas y tablas en blanco.
       Los grises fríos de antes siguen disponibles: "Sistema": { "Neutros": "frios" }
       (sección 1d). */
    --body-bg: color-mix(in oklab, var(--brand) 3%, #F4F2EF);
    --body-glow: radial-gradient(1100px 520px at 100% -8%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 70%),
                 radial-gradient(900px 480px at -10% 105%, color-mix(in srgb, var(--calido) 16%, transparent), transparent 70%);
    --sidebar-bg: #FFFEFC;
    --surface: #FFFFFF;
    --surface-2: #F7F5F2;
    --surface-3: #EFEBE6;
    --border: #E7E2DB;
    --border-lite: #EFEBE5;
    --text: #1C1916;
    --text-2: #4F4842;
    --text-muted: #6E665F;
    --icon: #6A625B;
    --text-header: var(--text-2);

    /* ▸ Tono cálido de acompañamiento: SOLO decorativo (ilustraciones, estados
         vacíos, brillo del fondo). Nunca indica un estado ni es un botón. */
    --calido: #E8B48A;
    --calido-soft: #F8E6D6;

    /* ▸ Encabezado de tablas: franja neutra y línea suave de marca
         (la marca fuerte queda para lo que se puede tocar). */
    --th-bg: var(--surface-2);
    --th-text: var(--text-2);
    --th-line: var(--p-line);

    /* ▸ Sombra de color para lo activo (menú, tarjeta seleccionada). */
    --shadow-brand: 0 6px 16px color-mix(in srgb, var(--p) 26%, transparent);

    /* ▸ Core 3.16 · Profundidad de lo que se toca (botón principal, menú activo, KPIs).
         --p-grad: degradado de la acción hacia un tono vecino (1b lo calcula; sin OKLCH es sólido).
         --p-glow: sombra de color bajo el botón principal; --hl: brillo interno de 1px. */
    --p-grad: var(--p);
    --p-grad-hover: var(--p-hover);
    --p-glow: 0 4px 12px color-mix(in srgb, var(--p) 28%, transparent);
    --p-glow-hover: 0 8px 20px color-mix(in srgb, var(--p) 34%, transparent);
    --hl: inset 0 1px 0 rgba(255,255,255,.22);
    --hl-soft: inset 0 1px 0 rgba(255,255,255,.75);

    /* ▸ Semánticos (solo estados) */
    --success: #15803D; --success-bg: #E2F8E9; --success-rgb: 21, 128, 61;
    --warning: #B45309; --warning-bg: #FFF1DE; --warning-rgb: 180, 83, 9;
    --danger:  #C81E1E; --danger-bg:  #FDE3E3; --danger-rgb: 200, 30, 30;
    --info:    #0369A1; --info-bg:    #DDEFFC; --info-rgb: 3, 105, 161;
    --danger-solid: #DC2626;
    --whatsapp: #1FA855;

    /* ▸ Tipografía */
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Consolas, Menlo, monospace;

    /* ▸ Tamaños de texto (REGLAS_UI.md §1c). Todo font-size usa un --fs-*: nunca px sueltos.
       --fs-escala los mueve todos a la vez; el usuario la elige en su menú («Tamaño del texto»)
       y theme-init.js la aplica con [data-text-size] antes de pintar. Para un tamaño fuera de
       la escala (un número grande de portada): calc(56px * var(--fs-escala)). */
    --fs-escala: 1;
    --fs-2xs:  calc(10px * var(--fs-escala));   /* indicadores mínimos, flechas de filtro */
    --fs-xs:   calc(11px * var(--fs-escala));   /* insignias, contadores, notas */
    --fs-sm:   calc(12px * var(--fs-escala));   /* textos secundarios, ayudas */
    --fs-md:   calc(13px * var(--fs-escala));   /* tablas, botones, menús */
    --fs-base: calc(14px * var(--fs-escala));   /* texto normal (html y body) */
    --fs-lg:   calc(15px * var(--fs-escala));   /* campos destacados */
    --fs-xl:   calc(16px * var(--fs-escala));   /* títulos de tarjeta y panel */
    --fs-2xl:  calc(18px * var(--fs-escala));   /* títulos de sección */
    --fs-3xl:  calc(20px * var(--fs-escala));   /* títulos de página en celular */
    --fs-4xl:  calc(24px * var(--fs-escala));   /* títulos de página */
    --fs-5xl:  calc(28px * var(--fs-escala));   /* cifras grandes (KPI) */

    /* ▸ Layout */
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 60px;
    /* Alto máximo del logo en el menú lateral (el logo es el protagonista).
       Cada proyecto puede ajustarlo aquí; la sincronización conserva su valor.
       Logo muy horizontal: lo limita el ancho del menú. Logo cuadrado o alto: suba a 88–110px. */
    --logo-h: 72px;
    --shell-gap: 12px;

    /* ▸ Radios */
    --r-sm: 8px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-xl: 18px;
    --r-full: 999px;

    /* ▸ Sombras (mínimas: la profundidad la dan bordes y superficies) */
    /* Tinte marrón muy tenue (neutros cálidos); los fríos usan azul marino (1d). */
    --shadow-xs: 0 1px 2px rgba(48,32,16,.05);
    --shadow-sm: 0 1px 2px rgba(48,32,16,.05), 0 6px 20px rgba(48,32,16,.06);
    --shadow-md: 0 10px 30px rgba(48,32,16,.09);
    --shadow-lg: 0 20px 60px rgba(40,26,12,.18);
    --overlay: rgba(20,16,12,.45);

    --ease: 160ms cubic-bezier(.4,0,.2,1);

    /* ▸ Alias de compatibilidad (páginas y proyectos existentes) */
    --brand-dark: var(--p-text);
    --brand-light: var(--p-soft);
    --brand-glow: var(--p-ring);
    --brand-glow-hover: var(--p-ring);
    --brand-light-1: var(--p-soft);
    --brand-light-2: var(--p-soft);
    /* --accent es un token propio (sección 1): no se redefine aquí. */
    --accent-dark: var(--p-text);
    --accent-soft: var(--p-soft);
    --accent-glow: var(--p-ring);
    --primary: var(--p);
    --primarydark: var(--p-hover);
    --fondo: var(--body-bg);
    --secondary: #1A1D2E;
    --third: #3b3b3f;

    /* ▸ Puente Bootstrap 5 */
    --bs-body-font-family: var(--font);
    --bs-body-bg: var(--body-bg);
    --bs-body-color: var(--text);
    --bs-secondary-color: var(--text-muted);
    --bs-secondary-bg: var(--surface-2);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-color: var(--border);
    --bs-link-color: var(--p-text);
    --bs-link-hover-color: var(--p-hover);
    --bs-emphasis-color: var(--text);
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 0;
    color-scheme: light;
}

/* ══════════════════════════ 1b. NORMALIZACIÓN DEL COLOR DE ACCIÓN ══════════════════════════
   Garantiza que el color de acción de CUALQUIER cliente:
   - tenga luminosidad media (0.40–0.56 en OKLCH): texto blanco legible encima;
   - tenga saturación mínima (croma ≥ 0.16): se ve vivo y se distingue de los grises de la UI,
     así "activo", "seleccionado" y "botón principal" nunca parecen deshabilitados.
   Conserva el TONO del cliente (azul sigue azul, verde sigue verde).
   Colores ya vivos (p. ej. #4233CE) prácticamente no cambian.
   Si el color es gris/negro puro (sin tono), define --accent con otro color. */
@supports (color: oklch(from red l c h)) {
    :root {
        --p: oklch(from var(--accent) clamp(0.40, l, 0.56) max(c, 0.16) h);
        --p-grad: linear-gradient(135deg, oklch(from var(--p) calc(l + .07) c calc(h + 18)), var(--p) 62%);
        --p-grad-hover: linear-gradient(135deg, oklch(from var(--p-hover) calc(l + .07) c calc(h + 18)), var(--p-hover) 62%);
    }
}

/* ══════════════════════════ 1c. MARCA CLARA — html[data-brand-tone="light"] ══════════════════════════
   Para marcas cuyo color es claro (amarillo, lima, celeste…). Se activa con
   "Sistema": { "TonoMarca": "claro" } en appsettings.json (lo aplica AppRoot.razor).
   - Claro: la marca se mantiene clara y viva; el texto encima es negro (--on-p).
     Los textos "de marca" sobre blanco (--p-text) pasan a un tono oscuro de la misma
     marca (dorado oscuro para amarillo, verde oscuro para lima…) para ser legibles;
     el color se ve en botones, menú activo, foco, tintes, bordes y encabezados.
   - Oscuro: a diferencia del resto de clientes, usa la marca: "marca sobre negro".
   - Advertencia pasa a naranja para no confundirse con una marca amarilla. */
html[data-brand-tone="light"]:not([data-theme="dark"]) {
    --on-p: #111111;
    --p-hover: color-mix(in oklab, var(--p) 90%, #000);
    --p-soft: color-mix(in oklab, var(--p) 16%, #fff);
    --p-soft-2: color-mix(in oklab, var(--p) 30%, #fff);
    --p-text: color-mix(in oklab, var(--p) 22%, #141414);
    --p-line: color-mix(in oklab, var(--p) 75%, #E3E5ED);
    --p-ring: color-mix(in srgb, var(--p) 50%, transparent);
    --th-bg: color-mix(in oklab, var(--p) 24%, #FFFFFF);
    --shadow-brand: 0 6px 16px color-mix(in srgb, var(--p) 40%, transparent);
    --warning: #C2410C; --warning-bg: #FFEDD5; --warning-rgb: 194, 65, 12;
}
html[data-brand-tone="light"][data-theme="dark"] {
    --on-p: #0A0A0A;
    --p-hover: color-mix(in oklab, var(--p) 85%, #fff);
    --p-soft: color-mix(in srgb, var(--p) 9%, transparent);
    --p-soft-2: color-mix(in srgb, var(--p) 16%, transparent);
    --p-text: var(--p);
    --p-line: color-mix(in oklab, var(--p) 45%, #2A2A2A);
    --p-ring: color-mix(in srgb, var(--p) 32%, transparent);
    --warning: #FB923C; --warning-bg: rgba(251,146,60,.13); --warning-rgb: 251, 146, 60;
    --th-line: color-mix(in oklab, var(--p) 55%, #2A2A2A);
}
/* Sin soporte OKLCH relativo, --p queda igual a --accent (el HEX del cliente). */
@supports (color: oklch(from red l c h)) {
    html[data-brand-tone="light"]:not([data-theme="dark"]),
    html[data-brand-tone="light"][data-theme="dark"] {
        --p: oklch(from var(--accent) clamp(0.78, l, 0.90) max(c, 0.15) h);
    }
    /* Texto de marca sobre blanco: mismo tono, oscuro y con color (contraste ≥ 6:1). */
    html[data-brand-tone="light"]:not([data-theme="dark"]) {
        --p-text: oklch(from var(--p) 0.46 min(c, 0.12) h);
    }
}

/* ══════════════════════════ 2. TOKENS — TEMA OSCURO (neutro, sin marca) ══════════════════════════ */
[data-theme="dark"] {
    --p: #EDEDED;
    --on-p: #0A0A0A;
    --p-hover: #FFFFFF;
    --p-soft: rgba(255,255,255,.08);
    --p-soft-2: rgba(255,255,255,.12);
    --p-text: #FFFFFF;
    --p-line: #4A4A4A;
    --p-ring: rgba(255,255,255,.16);

    /* Carbón cálido (los fríos, negro y grises puros, en 1d). */
    --body-bg: #12100E;
    --sidebar-bg: #1A1816;
    --surface: #1D1A17;
    --surface-2: #26221E;
    --surface-3: #2D2925;
    --border: #34302B;
    --border-lite: #2A2622;
    --text: #EEE9E3;
    --text-2: #BEB6AD;
    --text-muted: #978E84;
    --icon: #ABA298;
    --calido: #7A5236;
    --calido-soft: rgba(232,180,138,.10);

    --body-glow: none;
    --th-bg: var(--surface-2);
    --th-text: var(--text-2);
    --th-line: var(--border);
    --shadow-brand: none;
    --p-glow: none;
    --p-glow-hover: 0 6px 16px rgba(0,0,0,.4);
    --hl: none;
    --hl-soft: inset 0 1px 0 rgba(255,255,255,.04);

    --success: #4ADE80; --success-bg: rgba(74,222,128,.12);
    --warning: #FBBF24; --warning-bg: rgba(251,191,36,.12);
    --danger:  #F87171; --danger-bg:  rgba(248,113,113,.13);
    --info:    #60A5FA; --info-bg:    rgba(96,165,250,.12);

    --shadow-xs: none;
    --shadow-sm: 0 8px 24px rgba(0,0,0,.35);
    --shadow-md: 0 14px 40px rgba(0,0,0,.45);
    --shadow-lg: 0 24px 70px rgba(0,0,0,.6);
    --overlay: rgba(8,6,4,.64);

    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b8b8b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    color-scheme: dark;
}

/* ══════════════════════════ 1d. NEUTROS FRÍOS — html[data-neutrals="cool"] ══════════════════════════
   Los grises azulados y el oscuro gris puro de Core ≤ 3.13, para el cliente que los
   prefiera (despachos legales, contables, financieros). Se activa con
   "Sistema": { "Neutros": "frios" } en appsettings.json (lo aplica AppRoot.razor).
   Solo redefine neutros, sombras y encabezado de tablas; la marca no cambia. */
html[data-neutrals="cool"]:not([data-theme="dark"]) {
    --p-line: color-mix(in oklab, var(--p) 52%, #E3E5ED);
    --body-bg: color-mix(in oklab, var(--brand) 4%, #F3F4F8);
    --body-glow: radial-gradient(1100px 520px at 100% -8%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
                 radial-gradient(900px 480px at -10% 105%, color-mix(in srgb, var(--p) 8%, transparent), transparent 70%);
    --sidebar-bg: #FFFFFF;
    --surface-2: #F6F7FA;
    --surface-3: #EEF0F5;
    --border: #E3E5ED;
    --border-lite: #ECEEF3;
    --text: #0D1120;
    --text-2: #454B5F;
    --text-muted: #5F6579;
    --icon: #5B6176;
    --calido: var(--p);
    --calido-soft: var(--p-soft);
    --th-bg: color-mix(in oklab, var(--p) 14%, #FFFFFF);
    --th-text: var(--p-text);
    --th-line: var(--brand);
    --shadow-xs: 0 1px 2px rgba(16,20,40,.04);
    --shadow-sm: 0 1px 2px rgba(16,20,40,.04), 0 6px 20px rgba(16,20,40,.05);
    --shadow-md: 0 10px 30px rgba(16,20,40,.08);
    --shadow-lg: 0 20px 60px rgba(16,20,40,.16);
    --overlay: rgba(10,12,20,.45);
}
html[data-neutrals="cool"][data-theme="dark"] {
    --body-bg: #0A0A0A;
    --sidebar-bg: #141414;
    --surface: #161616;
    --surface-2: #1F1F1F;
    --surface-3: #262626;
    --border: #2A2A2A;
    --border-lite: #222222;
    --text: #EDEDED;
    --text-2: #B8B8B8;
    --text-muted: #8F8F8F;
    --icon: #A3A3A3;
    --calido: #3A3A3A;
    --calido-soft: rgba(255,255,255,.06);
    --overlay: rgba(0,0,0,.62);
}

/* ══════════════════════════ 2b. OSCURO DE MARCA — html[data-dark="brand"] (Core 3.16) ══════════════════════════
   Opción de cada persona en «Mis preferencias» → Tema oscuro: «De marca». Por defecto el oscuro es
   blanco y negro (§2) y esta sección no aplica. Superficies teñidas con el tono de --brand y la acción
   en la marca (texto blanco, contraste AA). Marcas claras (§1c) conservan su «marca sobre negro». */
html[data-dark="brand"][data-theme="dark"] {
    --body-bg: color-mix(in oklab, var(--brand) 12%, #0C0B10);
    --sidebar-bg: color-mix(in oklab, var(--brand) 15%, #121117);
    --surface: color-mix(in oklab, var(--brand) 16%, #14131A);
    --surface-2: color-mix(in oklab, var(--brand) 20%, #1B1A22);
    --surface-3: color-mix(in oklab, var(--brand) 24%, #22212A);
    --border: color-mix(in oklab, var(--brand) 30%, #2A2932);
    --border-lite: color-mix(in oklab, var(--brand) 24%, #212028);
    --text: color-mix(in oklab, var(--brand) 6%, #F2F1F6);
    --text-2: color-mix(in oklab, var(--brand) 12%, #C9C7D3);
    --text-muted: color-mix(in oklab, var(--brand) 16%, #9C99AA);
    --icon: color-mix(in oklab, var(--brand) 18%, #AEABBC);
    --calido: color-mix(in oklab, var(--brand) 40%, #2A2932);
    --calido-soft: color-mix(in srgb, var(--brand) 12%, transparent);
    --body-glow: radial-gradient(1100px 520px at 100% -8%, color-mix(in srgb, var(--brand) 24%, transparent), transparent 70%),
                 radial-gradient(900px 480px at -10% 105%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%);
    --th-bg: var(--surface-2);
    --th-line: var(--p-line);
    --hl: inset 0 1px 0 rgba(255,255,255,.16);
    --overlay: color-mix(in srgb, color-mix(in oklab, var(--brand) 20%, #000) 70%, transparent);
}
html[data-dark="brand"][data-theme="dark"]:not([data-brand-tone="light"]) {
    --p: color-mix(in oklab, var(--accent) 88%, #fff);
    --on-p: #FFFFFF;
    --p-hover: color-mix(in oklab, var(--p) 86%, #fff);
    --p-soft: color-mix(in srgb, var(--p) 20%, transparent);
    --p-soft-2: color-mix(in srgb, var(--p) 30%, transparent);
    --p-text: color-mix(in oklab, var(--p) 45%, #fff);
    --p-line: color-mix(in oklab, var(--p) 55%, #2A2932);
    --p-ring: color-mix(in srgb, var(--p) 42%, transparent);
    --shadow-brand: 0 6px 18px color-mix(in srgb, var(--p) 40%, transparent);
    --p-glow: 0 6px 16px color-mix(in srgb, var(--p) 38%, transparent);
    --p-glow-hover: 0 10px 24px color-mix(in srgb, var(--p) 46%, transparent);
}
@supports (color: oklch(from red l c h)) {
    html[data-dark="brand"][data-theme="dark"]:not([data-brand-tone="light"]) {
        --p: oklch(from var(--accent) 0.52 max(c, 0.15) h);
        --p-hover: oklch(from var(--accent) 0.58 max(c, 0.15) h);
        --p-text: oklch(from var(--accent) 0.84 min(c, 0.11) h);
        --p-grad: linear-gradient(135deg, oklch(from var(--p) calc(l + .07) c calc(h + 18)), var(--p) 62%);
        --p-grad-hover: linear-gradient(135deg, oklch(from var(--p-hover) calc(l + .07) c calc(h + 18)), var(--p-hover) 62%);
    }
}
/* Lo que el oscuro neutro deja gris y en el de marca vuelve a tener color. */
html[data-dark="brand"][data-theme="dark"] .eyebrow { color: var(--p-text); }
html[data-dark="brand"][data-theme="dark"] .dash-hero {
    color: var(--on-p); border: 0; box-shadow: var(--p-glow-hover);
    background: radial-gradient(420px 220px at 92% -10%, rgba(255,255,255,.16), transparent 70%), var(--p-grad), var(--p);
}
html[data-dark="brand"][data-theme="dark"] .dash-hero :is(.page-title, .page-sub, .eyebrow) { color: var(--on-p); }
html[data-dark="brand"][data-theme="dark"] .dash-hero .page-sub { opacity: .86; }
html[data-dark="brand"][data-theme="dark"] .hero-band { background: var(--p-grad), var(--p); color: var(--on-p); }
html[data-dark="brand"][data-theme="dark"] .hero-band :is(h1, h2, h3, h4, h5) { color: var(--on-p); }
html[data-dark="brand"][data-theme="dark"] #brandMenu > li > a.mm-active:not(.has-arrow) {
    background: var(--p-grad), var(--p); color: var(--on-p); box-shadow: var(--shadow-brand), var(--hl);
}
html[data-dark="brand"][data-theme="dark"] #brandMenu > li > a.mm-active:not(.has-arrow) > i:first-child { color: var(--on-p); }
html[data-dark="brand"][data-theme="dark"] .lg-brand { background: var(--p-grad), var(--p); border: 0; }

/* ══════════════════════════ 3. BASE ══════════════════════════ */
/* Tamaño del texto elegido por el usuario (theme-init.js / brandShell.setTextSize). */
:root[data-text-size="grande"] { --fs-escala: 1.1; }
:root[data-text-size="muy-grande"] { --fs-escala: 1.25; }
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs-base); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body {
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.5;
    background: var(--body-bg);
    color: var(--text);
}
body { margin: 0; transition: background var(--ease), color var(--ease); }
/* Brillo de marca sobre el fondo (tema claro); en oscuro --body-glow es none. */
body { background: var(--body-glow), var(--body-bg); background-attachment: fixed; }
a { color: inherit; text-decoration: none; }
a:hover { color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.faq-steps, .content-body ol:not([class]), .content-body ul:not([class]) { list-style: revert; }
h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -.01em; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: var(--fs-base); }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border-lite); opacity: 1; }
strong, b { font-weight: 700; }
.text-muted { color: var(--text-muted) !important; }
h1:focus { outline: none; }

/* Foco visible y consistente (pisa el anillo azul de site.css/Bootstrap). */
:focus-visible { outline: 2px solid var(--p); outline-offset: 2px; }
.btn-link.nav-link:focus,
.form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--p-ring);
    outline: none;
}
/* Botones: el anillo de foco va como outline (Core 3.16), así convive con su sombra de relieve. */
.btn:focus { outline: none; }
.btn:focus-visible { outline: 3px solid var(--p-ring); outline-offset: 1px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Compatibilidad: textos con font-family 'Sora' en línea (Error, PerfilUsuario,
   CambiarClave, 404) usan ahora la tipografía del sistema. */
[style*="Sora"] { font-family: var(--font) !important; }

/* ══════════════════════════ 4. SHELL — SIDEBAR FLOTANTE ══════════════════════════ */
#wrapper { position: relative; min-height: 100vh; }

#sidebar {
    position: fixed;
    top: var(--shell-gap); left: var(--shell-gap); bottom: var(--shell-gap);
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    z-index: 300;
    overflow: hidden;
    transition: width var(--ease);
    /* Sin backdrop-filter: rompería el position:fixed de sus descendientes. */
}
#sidebar.collapsed { width: var(--sidebar-w-collapsed); }

/* Logo: logo.png expandido · icono.png colapsado */
/* Core 3.13: zona propia de --logo-h (antes el alto de la barra superior, 40px). Mismo alto
   expandido y colapsado para que el menú no salte. Recorte el aire del PNG con
   herramientas/recortar_logo.py: si no, el margen transparente se come el tamaño. */
.logo {
    display: flex; align-items: center; gap: 10px;
    height: calc(var(--logo-h) + 28px); padding: 0 16px;
    flex-shrink: 0; overflow: hidden;
}
.logo-text { display: flex; flex-direction: column; min-width: 0; width: 100%; }
.logo-text { align-items: center; }
/* Logo centrado; crece hasta --logo-h de alto o todo el ancho del menú, lo que llegue primero. */
.logo-text img { display: block; width: auto; max-width: 100%; height: auto; max-height: var(--logo-h); }
.logo-text small { display: block; margin-top: 6px; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.logo-mark { display: none; width: 46px; height: 46px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 12px; }
.logo-mark img { display: block; width: 36px; height: 36px; object-fit: contain; }
#sidebar.collapsed .logo { justify-content: center; padding: 0; }
#sidebar.collapsed .logo-mark { display: flex; }
#sidebar.collapsed .logo-text { display: none; }

/* Logo transparente sobre fondo oscuro: sello blanco suave ajustado al logo. */
[data-theme="dark"] .logo-text img { background: rgba(255,255,255,.92); padding: 8px 12px; border-radius: 12px; max-height: calc(var(--logo-h) + 16px); }
[data-theme="dark"] .logo-mark { background: rgba(255,255,255,.92); }

/* Navegación */
/* #sidebar .nav: Bootstrap también define .nav (flex); aquí se fuerza bloque. */
#sidebar .nav { display: block; }
#brandMenu { width: 100%; }
.nav {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 4px 12px 12px;
}
#brandMenu, #brandMenu ul { list-style: none; margin: 0; padding: 0; }
#brandMenu > li { position: relative; margin: 1px 0; }

#brandMenu > li.nav-section {
    margin: 18px 0 6px; padding: 0 10px;
    font-size: var(--fs-xs); font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--text-muted); white-space: nowrap; pointer-events: none;
}
#brandMenu > li:first-child + li.nav-section { margin-top: 14px; }

#brandMenu > li > a {
    display: flex; align-items: center; gap: 12px;
    min-height: 40px; padding: 0 10px;
    border-radius: var(--r-md);
    font-size: var(--fs-base); font-weight: 600; color: var(--text-2);
    white-space: nowrap; overflow: hidden; cursor: pointer; user-select: none;
    transition: background var(--ease), color var(--ease);
}
#brandMenu > li > a > i.nav-ico,
#brandMenu > li > a > i:first-child {
    width: 20px; min-width: 20px; text-align: center;
    font-size: var(--fs-xl); color: var(--icon);
    transition: color var(--ease);
}
#brandMenu > li > a > span.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#brandMenu > li > a.has-arrow::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Pro', 'Font Awesome 6 Free';
    font-weight: 900; font-size: var(--fs-xs); color: var(--text-muted);
    margin-left: auto; flex-shrink: 0;
    transition: transform var(--ease);
}
#brandMenu > li > a[aria-expanded="true"].has-arrow::after { transform: rotate(180deg); }
#brandMenu > li > a:hover { background: var(--surface-2); color: var(--text); }
#brandMenu > li > a:hover > i:first-child { color: var(--text); }

/* Activo: enlace directo (Inicio) con fondo suave; módulo que contiene la
   página activa solo en texto fuerte. */
#brandMenu > li > a.mm-active { background: var(--p-soft); color: var(--p-text); }
#brandMenu > li > a.mm-active > i:first-child { color: var(--p-text); }
#brandMenu > li.mm-active > a.has-arrow { color: var(--text); }
#brandMenu > li.mm-active > a.has-arrow > i:first-child { color: var(--p-text); }
/* Tema claro: el enlace directo activo (Inicio) en sólido de marca. */
html:not([data-theme="dark"]) #brandMenu > li > a.mm-active:not(.has-arrow) {
    background: var(--p-grad), var(--p); color: var(--on-p); box-shadow: var(--shadow-brand), var(--hl);
}

/* Core 3.16.1 · Color por sección: el ícono de cada módulo va en un cuadro con el tono de su
   sección del menú (core-ui.js pone data-tono 1–8; «neutro» para Sistema; «marca» sin sección).
   Solo identifica: la acción sigue siendo la marca. No aplica al menú horizontal. */
#brandMenu > li[data-tono] { --mt-bg: var(--surface-2); --mt-c: var(--icon); }
#brandMenu > li[data-tono="marca"] { --mt-bg: var(--p-soft); --mt-c: var(--p-text); }
/* Paleta de secciones en orden de aparición. Sin verde, ámbar ni rojo: esos son de estados
   (--success, --warning, --danger). Tonos bien separados entre sí. --mt es el color base. */
#brandMenu > li[data-tono="1"] { --mt: #6D28D9; --mt-bg: #EDE9FE; }   /* violeta */
#brandMenu > li[data-tono="2"] { --mt: #0E7490; --mt-bg: #CFFAFE; }   /* turquesa */
#brandMenu > li[data-tono="3"] { --mt: #1D4ED8; --mt-bg: #DBEAFE; }   /* cobalto */
#brandMenu > li[data-tono="4"] { --mt: #A21CAF; --mt-bg: #FAE8FF; }   /* fucsia */
#brandMenu > li[data-tono="5"] { --mt: #9A3412; --mt-bg: #FBE6DA; }   /* terracota */
#brandMenu > li[data-tono="6"] { --mt: #4338CA; --mt-bg: #E0E7FF; }   /* índigo */
#brandMenu > li[data-tono="7"] { --mt: #BE185D; --mt-bg: #FCE7F3; }   /* rosa */
#brandMenu > li[data-tono="8"] { --mt: #334155; --mt-bg: #E2E8F0; }   /* pizarra */
#brandMenu > li[data-tono="fav"] { --mt: #B45309; --mt-bg: #FEF3C7; }
#brandMenu > li[data-tono]:is([data-tono="1"],[data-tono="2"],[data-tono="3"],[data-tono="4"],[data-tono="5"],[data-tono="6"],[data-tono="7"],[data-tono="8"],[data-tono="fav"]) { --mt-c: var(--mt); }
[data-theme="dark"] #brandMenu > li[data-tono]:is([data-tono="1"],[data-tono="2"],[data-tono="3"],[data-tono="4"],[data-tono="5"],[data-tono="6"],[data-tono="7"],[data-tono="8"],[data-tono="fav"]) {
    --mt-bg: color-mix(in srgb, var(--mt) 24%, transparent); --mt-c: color-mix(in oklab, var(--mt) 42%, #fff);
}
html:not([data-menu-layout="horizontal"]) #brandMenu > li[data-tono] > a > i:first-child {
    width: 28px; min-width: 28px; height: 28px; margin-left: -4px;
    display: inline-grid; place-items: center; border-radius: 8px;
    background: var(--mt-bg); color: var(--mt-c); font-size: var(--fs-md);
    /* Íconos duotone: las dos capas en el tono, la segunda más tenue. */
    --fa-primary-color: var(--mt-c); --fa-secondary-color: var(--mt-c); --fa-secondary-opacity: .45;
}
html:not([data-menu-layout="horizontal"]) #brandMenu > li[data-tono] > a:hover > i:first-child,
html:not([data-menu-layout="horizontal"]) #brandMenu > li[data-tono]:is(.mm-active, :has(> ul.mm-show)) > a.has-arrow > i:first-child { color: var(--mt-c); }
#sidebar.collapsed #brandMenu > li[data-tono] > a > i:first-child { margin-left: 0; }
html:not([data-theme="dark"]) #brandMenu > li > a.mm-active:not(.has-arrow) > i:first-child { color: var(--on-p); }

/* Submenú (acordeón) */
#brandMenu > li > ul {
    margin: 2px 0 6px 19px; padding-left: 12px;
    border-left: 1px solid var(--border);
    max-height: 0; overflow: hidden;
    transition: max-height .26s ease;
}
#brandMenu > li > ul:not(.mm-show) { margin-top: 0; margin-bottom: 0; }
#brandMenu > li > ul.mm-show { max-height: 10000px; overflow: visible; }
#brandMenu > li > ul > li { margin: 1px 0; }
#brandMenu > li > ul > li.nav-section {
    padding: 8px 10px 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-muted); pointer-events: none;
}
/* Una sola etiqueta (solo PRINCIPAL o solo CATÁLOGOS) no aporta: se oculta. */
#brandMenu > li > ul:not(:has(> li.nav-section ~ li.nav-section)) > li.nav-section { display: none; }
#brandMenu > li > ul > li > a {
    display: flex; align-items: center;
    min-height: 34px; padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: var(--fs-base); font-weight: 500; color: var(--text-2);
    transition: background var(--ease), color var(--ease);
}
#brandMenu > li > ul > li > a:hover { background: var(--surface-2); color: var(--text); }
#brandMenu > li > ul > li.mm-active > a,
#brandMenu > li > ul > li > a.mm-active { background: var(--p-soft); color: var(--p-text); font-weight: 600; }
/* Core 3.1: contador del enlace «Catálogos» del módulo (Centro de catálogos). */
.nav-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 18px; margin-left: 6px; padding: 0 6px; border-radius: 999px;
    background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-2xs); font-weight: 800;
}
.mm-active > .nav-count, a.mm-active > .nav-count { background: var(--surface); color: var(--p-text); }

/* ── Módulo abierto: bloque gris suave que agrupa sus páginas ──
   Un solo acento de marca: la página activa (pastilla blanca + barra
   lateral) y el ícono del módulo. Lo demás es neutro. */
#brandMenu > li:has(> ul.mm-show) {
    margin: 4px 0;
    padding-bottom: 6px;
    border-radius: 12px;
    background: var(--surface-2);
}
#brandMenu > li:has(> ul.mm-show) > a.has-arrow,
#brandMenu > li:has(> ul.mm-show) > a.has-arrow:hover { background: transparent; color: var(--text); font-weight: 700; }
#brandMenu > li:has(> ul.mm-show) > a.has-arrow > i:first-child { color: var(--p-text); }
#brandMenu > li:has(> ul.mm-show) > a.has-arrow::after { color: var(--text-muted); }
#brandMenu > li:has(> ul.mm-show) > ul { margin: 0 8px 0 19px; border-left-color: var(--border); }
/* Tema claro: el módulo abierto con un tinte de marca en lugar de gris. */
html:not([data-theme="dark"]) #brandMenu > li:has(> ul.mm-show) { background: color-mix(in oklab, var(--p) 8%, #FFFFFF); }
html:not([data-theme="dark"]) #brandMenu > li:has(> ul.mm-show) > ul { border-left-color: color-mix(in oklab, var(--p) 30%, var(--border)); }
#brandMenu > li:has(> ul.mm-show) > ul > li > a { color: var(--text-2); }
#brandMenu > li:has(> ul.mm-show) > ul > li > a:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); }
#brandMenu > li:has(> ul.mm-show) > ul > li.mm-active > a,
#brandMenu > li:has(> ul.mm-show) > ul > li > a.mm-active {
    position: relative;
    background: var(--surface); color: var(--p-text); font-weight: 700;
    box-shadow: 0 1px 2px rgba(16,20,40,.06), 0 2px 8px color-mix(in srgb, var(--p) 10%, transparent);
}
#brandMenu > li:has(> ul.mm-show) > ul > li.mm-active > a::before,
#brandMenu > li:has(> ul.mm-show) > ul > li > a.mm-active::before {
    content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 3px; background: var(--p);
}
[data-theme="dark"] #brandMenu > li:has(> ul.mm-show) > ul > li.mm-active > a,
[data-theme="dark"] #brandMenu > li:has(> ul.mm-show) > ul > li > a.mm-active { background: var(--surface-3); box-shadow: none; }

/* Pie del sidebar: soporte + tema */
.sidebar-footer {
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.support-card {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text);
    transition: border-color var(--ease), background var(--ease);
}
.support-card:hover { border-color: var(--p-line); color: var(--text); }
/* Ícono de soporte: mascota encima; si la imagen no existe se elimina
   (onerror) y queda el ícono de WhatsApp en su color. */
.sc-ic {
    position: relative; flex-shrink: 0; overflow: hidden;
    width: 38px; height: 38px; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--whatsapp); color: #fff; font-size: var(--fs-3xl);
}
.sc-ic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.lg-support .sc-ic { width: 28px; height: 28px; border-radius: 8px; font-size: var(--fs-lg); }
.support-card .sc-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.support-card .sc-title { font-size: var(--fs-md); font-weight: 700; white-space: nowrap; }
.support-card .sc-sub { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.theme-seg {
    display: flex; gap: 2px; padding: 3px;
    border-radius: var(--r-md);
    background: var(--surface-2); border: 1px solid var(--border);
}
.theme-seg button {
    flex: 1; height: 32px; padding: 0 8px; min-width: 0; white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 0; border-radius: var(--r-sm); background: transparent;
    font-size: var(--fs-md); font-weight: 600; color: var(--text-2);
    transition: background var(--ease), color var(--ease);
}
.theme-seg button i { font-size: var(--fs-md); }
/* Fuera del menú lateral (Mis preferencias, Mi perfil) cada botón mide su texto: con «Muy grande» no se sale del recuadro. */
.pf-pref .theme-seg button { flex: 0 0 auto; }
/* Con texto grande, en el pie del menú lateral (ancho fijo) quedan solo las palabras. */
:root:is([data-text-size="grande"], [data-text-size="muy-grande"]) #sidebar:not(.collapsed) .sidebar-footer .theme-seg button:has(.fb-label) i { display: none; }
.theme-seg button:hover { color: var(--text); }
/* Opción activa según el modo guardado (light | dark | auto). */
[data-theme-mode="light"] .theme-seg [data-theme-set="light"],
[data-theme-mode="dark"] .theme-seg [data-theme-set="dark"],
[data-theme-mode="auto"] .theme-seg [data-theme-set="auto"] {
    background: var(--p-soft); color: var(--p-text);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p) 28%, transparent);
}

/* Core 3.12 · Mismos selectores en «Mis preferencias»: el activo lo da el atributo de <html>. */
[data-menu-layout="vertical"] .theme-seg [data-menu-set="vertical"],
[data-menu-layout="horizontal"] .theme-seg [data-menu-set="horizontal"],
:root:not([data-table-density="compacta"]) .theme-seg [data-density-set="comoda"],
:root[data-table-density="compacta"] .theme-seg [data-density-set="compacta"],
:root:not([data-text-size]) .theme-seg [data-text-size-set="normal"],
:root[data-text-size="grande"] .theme-seg [data-text-size-set="grande"],
:root[data-text-size="muy-grande"] .theme-seg [data-text-size-set="muy-grande"],
:root:not([data-neutrals="cool"]) .theme-seg [data-neutrals-set="calido"],
:root[data-neutrals="cool"] .theme-seg [data-neutrals-set="frio"],
:root:not([data-dark="brand"]) .theme-seg [data-dark-set="neutro"],
:root[data-dark="brand"] .theme-seg [data-dark-set="marca"],
:root:not([data-mobile-tables="tabla"]) .theme-seg [data-mobile-tables-set="cards"],
:root[data-mobile-tables="tabla"] .theme-seg [data-mobile-tables-set="tabla"] {
    background: var(--p-soft); color: var(--p-text);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p) 28%, transparent);
}

/* Botón genérico del pie (compatibilidad con proyectos que aún lo usen) */
.footer-btn {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; border: 0; border-radius: var(--r-md); background: none;
    font-size: var(--fs-md); font-weight: 600; color: var(--text-2); text-align: left; white-space: nowrap;
}
.footer-btn:hover { background: var(--surface-2); color: var(--text); }
.footer-btn > i { width: 20px; text-align: center; }

/* ── Sidebar colapsado (desktop) ── */
#sidebar.collapsed .nav { padding: 4px 10px 12px; }
#sidebar.collapsed #brandMenu > li > a { justify-content: center; padding: 0; }
#sidebar.collapsed #brandMenu > li > a > span.nav-text,
#sidebar.collapsed #brandMenu > li > a.has-arrow::after { display: none; }
#sidebar.collapsed #brandMenu > li.mm-active > a.has-arrow { background: var(--p-soft); }
#sidebar.collapsed #brandMenu > li:has(> ul.mm-show) { margin: 1px 0; padding-bottom: 0; background: transparent; }
@media (min-width: 901px) {
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) { margin: 0; padding-bottom: 0; border-radius: var(--r-md); }
}
#sidebar.collapsed #brandMenu > li.nav-section {
    height: 1px; margin: 10px 8px; padding: 0;
    font-size: 0; line-height: 0; overflow: hidden; background: var(--border);
}
#sidebar.collapsed .sidebar-footer { padding: 10px; align-items: center; }
#sidebar.collapsed .support-card { padding: 4px; background: transparent; border-color: transparent; }
#sidebar.collapsed .support-card .sc-txt { display: none; }
#sidebar.collapsed .theme-seg { flex-direction: column; width: 44px; }
#sidebar.collapsed .theme-seg button { padding: 0; }
#sidebar.collapsed .fb-label { display: none; }
@media (min-width: 901px) {
    html:not([data-menu-layout="horizontal"]) #sidebar.collapsed #brandMenu > li > ul { display: none !important; }
}

/* Flyout del sidebar colapsado: portal bajo <body> (shell.js). */
#brandCollapsedFlyout {
    position: fixed; z-index: 2147482000;
    min-width: 224px; max-width: min(320px, calc(100vw - 100px));
    max-height: min(72vh, 680px);
    overflow-y: auto; overflow-x: hidden;
    padding: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateX(-5px);
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}
#brandCollapsedFlyout.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none; }
#brandCollapsedFlyout::before { content: ""; position: absolute; left: -12px; top: 0; width: 14px; height: 100%; }
#brandCollapsedFlyout ul { list-style: none; margin: 0; padding: 0; }
#brandCollapsedFlyout li { margin: 1px 0; }
#brandCollapsedFlyout li.nav-section {
    padding: 8px 10px 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-muted); pointer-events: none;
}
#brandCollapsedFlyout li > a {
    display: flex; align-items: center; min-height: 36px; padding: 6px 10px;
    border-radius: var(--r-sm); font-size: var(--fs-base); font-weight: 500; color: var(--text-2); white-space: nowrap;
}
#brandCollapsedFlyout li > a:hover { background: var(--surface-2); color: var(--text); }
#brandCollapsedFlyout li.mm-active > a { background: var(--p-soft); color: var(--p-text); font-weight: 600; }

/* ══════════════════════════ 5. SHELL — TOPBAR FLOTANTE ══════════════════════════ */
#main {
    margin-left: calc(var(--sidebar-w) + var(--shell-gap) * 2);
    min-height: 100vh; min-width: 0;
    display: flex; flex-direction: column;
    transition: margin-left var(--ease);
}
#wrapper.sb-collapsed #main { margin-left: calc(var(--sidebar-w-collapsed) + var(--shell-gap) * 2); }

/* Los paneles fixed (user-dd, notif-dd) viven fuera de #topbar: por eso
   #topbar puede llevar backdrop-filter sin romper su posición. */
#topbar {
    position: sticky; top: var(--shell-gap); z-index: 250;
    height: var(--topbar-h);
    margin: var(--shell-gap) var(--shell-gap) 0 0;
    display: flex; align-items: center; gap: 12px;
    padding: 0 10px 0 12px;
    background: color-mix(in srgb, var(--sidebar-bg) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}
.tb-toggle, .tb-btn {
    position: relative;
    width: 38px; height: 38px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); color: var(--text-2); font-size: var(--fs-lg);
    transition: background var(--ease), color var(--ease);
}
.tb-toggle:hover, .tb-btn:hover, .tb-btn.open { background: var(--surface-2); color: var(--text); }

.tb-crumb {
    display: flex; align-items: center; gap: 8px; min-width: 0;
    font-size: var(--fs-base); color: var(--text-muted); white-space: nowrap;
}
.tb-crumb span { overflow: hidden; text-overflow: ellipsis; }
.tb-crumb b { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.tb-crumb i { font-size: var(--fs-2xs); flex-shrink: 0; }
/* Core 3.12 · Estrella de favoritos junto al título de la página. */
.tb-fav {
    display: inline-grid; place-items: center; flex-shrink: 0; width: 28px; height: 28px; margin-left: 2px;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
}
.tb-crumb .tb-fav i { font-size: var(--fs-base); }
.tb-fav:hover { background: var(--surface-2); color: var(--text); }
.tb-fav.is-on { color: var(--warning); }

.tb-search {
    flex: 1 1 260px; max-width: 460px; margin: 0 auto;
    display: flex; align-items: center; gap: 10px;
    height: 40px; padding: 0 8px 0 14px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--text-muted);
    font-size: var(--fs-base); cursor: pointer;
    transition: border-color var(--ease);
}
.tb-search:hover { border-color: var(--p-line); }
.tb-search span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-search kbd, .cmdk-input-row kbd {
    font: 600 var(--fs-xs)/1 var(--font-mono);
    padding: 5px 6px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
}

.tb-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

/* Etiqueta «Servidor espejo · Modo prueba» (ModoEspejoBadge): solo en la app del servidor espejo. */
.modo-espejo {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    height: 30px; padding: 0 12px; border-radius: var(--r-full);
    border: 1px solid color-mix(in oklab, var(--warning) 45%, transparent);
    background: var(--warning-bg); color: var(--warning);
    font-size: var(--fs-md); font-weight: 800; letter-spacing: .02em; white-space: nowrap;
}
.modo-espejo--login { margin-right: auto; }
@media (max-width: 760px) {
    .modo-espejo { height: 26px; padding: 0 9px; font-size: var(--fs-sm); }
    .modo-espejo-largo { display: none; }
}
.notif-dot {
    position: absolute; top: 8px; right: 8px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger-solid); border: 2px solid var(--surface);
}

.user-wrap { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 10px 0 5px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); color: var(--text);
    transition: background var(--ease);
}
.user-btn:hover, .user-btn.open { background: var(--surface-2); }
.user-avatar { width: 32px; height: 32px; border-radius: 9px; object-fit: cover; display: block; flex-shrink: 0; background: var(--surface-2); }
.user-info { text-align: left; line-height: 1.25; min-width: 0; }
.user-name { font-size: var(--fs-base); font-weight: 700; color: var(--text); white-space: nowrap; }
.user-role { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.user-chevron { font-size: var(--fs-xs); color: var(--text-muted); transition: transform var(--ease); }
.user-btn.open .user-chevron { transform: rotate(180deg); }

/* Dropdowns (usuario / notificaciones): fixed + clamp en shell.js */
.user-dropdown {
    display: none; position: fixed; z-index: 9999;
    min-width: 240px; max-width: min(300px, calc(100vw - 24px));
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.user-dropdown.open { display: block; }
.dd-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-lite); }
.dd-avatar { width: 40px; height: 40px; border-radius: 11px; object-fit: cover; flex-shrink: 0; }
.dd-name { font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.dd-role { font-size: var(--fs-sm); color: var(--text-muted); }
.dd-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 16px; border: 0; background: none; text-align: left;
    font-size: var(--fs-base); font-weight: 500; color: var(--text-2);
}
.dd-item > i { width: 18px; text-align: center; font-size: var(--fs-base); color: var(--icon); }
.dd-item:hover { background: var(--surface-2); color: var(--text); }
.dd-item.danger, .dd-item.danger > i { color: var(--danger); }
.dd-item.danger:hover { background: var(--danger-bg); }
/* Tamaño del texto en el menú del usuario: tres «A» crecientes; la activa con el tono de la marca. */
.dd-text-size { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px 6px 16px; }
.dd-text-size__label { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-base); font-weight: 500; color: var(--text-2); }
.dd-text-size__label > i { width: 18px; text-align: center; font-size: var(--fs-base); color: var(--icon); }
.text-size-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.text-size-seg button {
    min-width: 30px; height: 28px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent;
    font-weight: 700; line-height: 1; color: var(--text-2); transition: background var(--ease), color var(--ease);
}
/* Tamaños fijos a propósito: cada «A» muestra el tamaño que elige, sin importar la escala actual. */
.text-size-seg [data-text-size-set="normal"] { font-size: 12px; } /* fs-fijo */
.text-size-seg [data-text-size-set="grande"] { font-size: 14px; } /* fs-fijo */
.text-size-seg [data-text-size-set="muy-grande"] { font-size: 16px; } /* fs-fijo */
.text-size-seg button:hover { color: var(--text); }
:root:not([data-text-size]) .text-size-seg [data-text-size-set="normal"],
:root[data-text-size="grande"] .text-size-seg [data-text-size-set="grande"],
:root[data-text-size="muy-grande"] .text-size-seg [data-text-size-set="muy-grande"] {
    background: var(--p-soft); color: var(--p-text);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p) 28%, transparent);
}
.dd-divider { height: 1px; background: var(--border-lite); margin: 4px 0; }

/* ══════════════════════════ 6. CONTENIDO, PIE Y OVERLAY ══════════════════════════ */
#content { flex: 1; min-width: 0; }
.content-body { padding: 24px var(--shell-gap) 24px 4px; min-width: 0; }
/* Tablas anchas: en grid y flex, un hijo no se encoge por debajo de su contenido
   (min-width:auto). Si contiene una tabla, la página entera se estira más allá de
   la pantalla y el contenedor con scroll nunca llega a desbordarse. Todo ancestro
   de una tabla puede encogerse, así el scroll horizontal queda dentro de su contenedor. */
.content-body :has(table) { min-width: 0; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.content-body > *:first-child { animation: fade-up 240ms ease both; }

.page-head { margin-bottom: 20px; }
.eyebrow {
    font-size: var(--fs-sm); font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--p-text); margin-bottom: 4px;
}
[data-theme="dark"] .eyebrow { color: var(--text-muted); }
.page-title { margin: 0; font-size: var(--fs-5xl); font-weight: 800; letter-spacing: -.025em; line-height: 1.2; color: var(--text); }
.page-sub { margin-top: 4px; font-size: var(--fs-base); color: var(--text-2); }

#footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px var(--shell-gap) 14px 4px;
    font-size: var(--fs-md); color: var(--text-muted);
}
#footer .copyright { font-size: var(--fs-md); color: var(--text-muted); }
#footer a:hover { color: var(--text); }

#overlay {
    display: none; position: fixed; inset: 0; z-index: 299;
    background: var(--overlay); opacity: 0; pointer-events: none;
}
#overlay.active { display: block; opacity: 1; pointer-events: all; }

/* ══════════════════════════ 7. CTRL K — BUSCADOR DE NAVEGACIÓN ══════════════════════════ */
.cmdk-overlay {
    display: none; position: fixed; inset: 0; z-index: 10000;
    align-items: flex-start; justify-content: center; padding-top: 10vh;
    background: var(--overlay); backdrop-filter: blur(2px);
}
.cmdk-overlay.open { display: flex; }
.cmdk-box {
    width: 100%; max-width: 560px; margin: 0 16px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-lite); }
.cmdk-input-row i { color: var(--text-muted); }
.cmdk-input-row input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: var(--fs-lg); }
.cmdk-list { max-height: min(52vh, 400px); overflow-y: auto; padding: 8px; }
.cmdk-group-lbl { padding: 10px 10px 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.cmdk-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--r-md); font-size: var(--fs-base); color: var(--text-2);
}
.cmdk-item:hover { background: var(--surface-2); color: var(--text); }
.cmdk-item .ic3 {
    width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--icon); font-size: var(--fs-md);
}
.cmdk-item:hover .ic3 { background: var(--p-soft); color: var(--p-text); }
.cmdk-item .mod-tag { margin-left: auto; font-size: var(--fs-sm); color: var(--text-muted); }
.cmdk-empty { padding: 30px; text-align: center; font-size: var(--fs-md); color: var(--text-muted); }

/* ══════════════════════════ 8. WHATSAPP FLOTANTE (retirado) ══════════════════════════
   El soporte vive en el pie del sidebar (escritorio) y en la hoja "Módulos"
   (móvil). Se oculta por compatibilidad si un proyecto aún tiene el marcado. */
.wa-float { display: none !important; }

/* ══════════════════════════ 9. BOTONES ══════════════════════════ */
.btn {
    --bs-btn-padding-x: 16px;
    --bs-btn-padding-y: 0;
    --bs-btn-font-size: var(--fs-base);
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: var(--r-md);
    --bs-btn-focus-box-shadow: 0 0 0 3px var(--p-ring);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border-radius: var(--r-md);
    font-family: var(--font); font-size: var(--fs-base); font-weight: 600;
    white-space: nowrap; text-decoration: none;
    transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease), box-shadow var(--ease);
}
/* Core 3.16 · Relieve: se eleva 1px al pasar el cursor y se hunde al presionar. */
.btn:not(:disabled):not(.disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):not(.disabled):active { transform: translateY(0) scale(.98); }
.btn-sm { height: 34px; padding: 0 12px; font-size: var(--fs-md); }
.btn-lg { height: 48px; padding: 0 22px; font-size: var(--fs-lg); }
.btn-icon { width: 40px; padding: 0; }
/* Deshabilitado: SIEMPRE gris neutro (no una versión clara del color de acción),
   así se distingue del botón activo con cualquier color de cliente. */
.btn:disabled:not([aria-busy="true"]), .btn[disabled]:not([aria-busy="true"]), .btn.disabled {
    background: var(--surface-3) !important; border-color: var(--border) !important;
    color: var(--text-muted) !important; box-shadow: none !important;
    opacity: 1; cursor: not-allowed; transform: none;
}
.btn:disabled:not([aria-busy="true"]) i, .btn.disabled i { color: inherit !important; }
/* Botón trabajando (spinner en el propio botón): se ve activo, no deshabilitado. */
.btn[aria-busy="true"]:disabled { opacity: .9; cursor: progress; }
.btn .spinner-border-sm { width: 15px; height: 15px; border-width: 2px; }

/* Acción principal: color de marca (en oscuro: blanco con texto negro).
   Incluye el patrón del Core "btn btn-success btn-premium" (Nuevo, Grabar…),
   salvo Exportar a Excel y WhatsApp. */
.btn-primary, .btn-brand,
.btn.btn-success:not(.gvCmdBtn):not(:has(.fa-file-excel)):not(:has(.fa-whatsapp)) {
    --bs-btn-color: var(--on-p);
    --bs-btn-bg: var(--p);
    --bs-btn-border-color: var(--p);
    --bs-btn-hover-color: var(--on-p);
    --bs-btn-hover-bg: var(--p-hover);
    --bs-btn-hover-border-color: var(--p-hover);
    --bs-btn-active-color: var(--on-p);
    --bs-btn-active-bg: var(--p-hover);
    --bs-btn-active-border-color: var(--p-hover);
    --bs-btn-disabled-color: var(--on-p);
    --bs-btn-disabled-bg: var(--p);
    --bs-btn-disabled-border-color: var(--p);
    background: var(--p-grad); background-color: var(--p); color: var(--on-p); border: 1px solid var(--p);
}
.btn.btn-primary, .btn.btn-brand,
.btn.btn-success:not(.gvCmdBtn):not(:has(.fa-file-excel)):not(:has(.fa-whatsapp)) {
    border-color: transparent; box-shadow: var(--p-glow), var(--hl);
}
.btn.btn-primary:hover, .btn.btn-brand:hover,
.btn.btn-success:not(.gvCmdBtn):not(:has(.fa-file-excel)):not(:has(.fa-whatsapp)):hover {
    background: var(--p-grad-hover); background-color: var(--p-hover); border-color: transparent; color: var(--on-p);
    box-shadow: var(--p-glow-hover), var(--hl);
}

/* Secundarios neutros */
.btn-secondary, .btn-outline-secondary, .btn-outline-primary, .btn-light, .btn-dark,
.btn.btn-success.btn-premium:has(.fa-file-excel) {
    --bs-btn-color: var(--text);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-active-color: var(--text);
    --bs-btn-active-bg: var(--surface-3);
    --bs-btn-active-border-color: var(--border);
    --bs-btn-disabled-color: var(--text-muted);
    --bs-btn-disabled-bg: var(--surface);
    --bs-btn-disabled-border-color: var(--border);
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    box-shadow: var(--shadow-xs), var(--hl-soft);
}
.btn.btn-secondary:hover, .btn.btn-outline-secondary:hover, .btn.btn-light:hover, .btn.btn-dark:hover,
.btn.btn-success.btn-premium:has(.fa-file-excel):hover {
    background: var(--surface-2); color: var(--text); border-color: var(--border);
    box-shadow: var(--shadow-sm), var(--hl-soft);
}
.btn.btn-outline-primary { color: var(--p-text); border-color: var(--p-line); }
.btn.btn-outline-primary:hover { background: var(--p-soft); color: var(--p-text); border-color: var(--p-line); }
.btn.btn-success.btn-premium:has(.fa-file-excel) > i { color: var(--p-text); }

/* Peligro / estados */
.btn-danger {
    --bs-btn-color: #fff; --bs-btn-bg: var(--danger-solid); --bs-btn-border-color: var(--danger-solid);
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #B91C1C; --bs-btn-hover-border-color: #B91C1C;
    --bs-btn-active-color: #fff; --bs-btn-active-bg: #991B1B; --bs-btn-active-border-color: #991B1B;
    background: var(--danger-solid); color: #fff; border: 1px solid var(--danger-solid);
}
.btn.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }
.btn-warning {
    --bs-btn-color: #1A1100; --bs-btn-bg: #F59E0B; --bs-btn-border-color: #F59E0B;
    --bs-btn-hover-color: #1A1100; --bs-btn-hover-bg: #D97706; --bs-btn-hover-border-color: #D97706;
    --bs-btn-active-bg: #B45309; --bs-btn-active-border-color: #B45309;
    background: #F59E0B; color: #1A1100; border: 1px solid #F59E0B;
}
.btn-info {
    --bs-btn-color: #fff; --bs-btn-bg: #0369A1; --bs-btn-border-color: #0369A1;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #075985; --bs-btn-hover-border-color: #075985;
    background: #0369A1; color: #fff; border: 1px solid #0369A1;
}
/* WhatsApp conserva su verde en ambos temas (acción de soporte). */
.btn.btn-success:has(.fa-whatsapp) {
    --bs-btn-color: #fff; --bs-btn-bg: var(--whatsapp); --bs-btn-border-color: var(--whatsapp);
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #178A45; --bs-btn-hover-border-color: #178A45;
    --bs-btn-active-bg: #137539;
    background: var(--whatsapp); color: #fff; border: 1px solid var(--whatsapp);
}
.btn-premium { box-shadow: none; }

/* Botón "Nuevo" solo-ícono (title="Nuevo registro"): muestra su texto. */
.btn.btn-icon[title="Nuevo registro"] { width: auto; min-width: 44px; padding: 0 18px; gap: 8px; }
.btn.btn-icon[title="Nuevo registro"]::after { content: "Nuevo"; font-size: var(--fs-base); font-weight: 600; }

/* Barra de acciones CRUD */
.card-body > .clearfix, .page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.card-body > .clearfix::after { display: none; }
.card-body > .clearfix .btn, .page-actions .btn, .page-actions .page-action-btn { height: 44px; min-width: 44px; margin: 0; }
.page-actions .page-action-btn { padding: 0 18px; }

/* Pastillas legado (filtros ACTIVOS/INACTIVOS antiguos) */
.btn3 {
    display: inline-flex; align-items: center; justify-content: center;
    height: 38px; padding: 0 16px; margin-right: 6px;
    border: 1px solid var(--border); border-radius: var(--r-full);
    background: var(--surface); color: var(--text-2);
    font-size: var(--fs-md); font-weight: 700; cursor: pointer;
}
.btn3.btn-dark { background: var(--p); color: var(--on-p); border-color: var(--p); }
.btn3.btn-move { background: var(--success-bg); color: var(--success); border-color: transparent; }

/* Botones de acción por fila (gvCmdBtn): neutros en reposo, color al pasar. */
.gvCmdBtn, .btn2.gvCmdBtn {
    width: 34px; height: 34px; padding: 0; margin: 0 4px 0 0;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); color: var(--text-2);
    font-size: var(--fs-base); line-height: 1; cursor: pointer;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.gvCmdBtn:last-child { margin-right: 0; }
.btn-modify.gvCmdBtn:hover, .btn-view.gvCmdBtn:hover, .btn-success.gvCmdBtn:hover, .btn-move.gvCmdBtn:hover {
    background: var(--p-soft); color: var(--p-text); border-color: var(--p-line);
}
.btn-delete.gvCmdBtn:hover { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ══════════════════════════ 10. FORMULARIOS ══════════════════════════ */
.form-control, .form-select {
    display: block; width: 100%;
    height: 42px; padding: 0 12px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background-color: var(--surface); color: var(--text);
    font-family: var(--font); font-size: var(--fs-base);
    outline: none;
    box-shadow: inset 0 1px 2px rgba(48,32,16,.04);
    transition: border-color var(--ease), box-shadow var(--ease);
}
[data-theme="dark"] :is(.form-control, .form-select) { box-shadow: none; }
.form-select { padding-right: 36px; }
textarea.form-control { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.5; }
/* Fecha / hora: Safari alinea el valor arriba y separa "dd / mm / aaaa".
   Se centra verticalmente y se alinea a la izquierda en todos los navegadores. */
input.form-control[type="date"], input.form-control[type="time"],
input.form-control[type="datetime-local"], input.form-control[type="month"] {
    display: flex; align-items: center; line-height: 1.2;
    -webkit-appearance: none; appearance: none;
}
input.form-control::-webkit-date-and-time-value { text-align: left; margin: 0; }
input.form-control::-webkit-datetime-edit { padding: 0; line-height: 1.2; }
input.form-control::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input.form-control::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
[data-theme="dark"] input.form-control::-webkit-calendar-picker-indicator { filter: invert(1); }
.form-control::placeholder { color: var(--text-muted); opacity: 1; }
.form-control:hover, .form-select:hover { border-color: color-mix(in srgb, var(--text-muted) 45%, var(--border)); }
.form-control:focus, .form-select:focus, .ssel-control:focus-within {
    border-color: var(--p);
    background-color: var(--surface);
    color: var(--text);
    box-shadow: 0 0 0 4px var(--p-ring);
}
.form-control:disabled, .form-control[readonly], .form-select:disabled {
    background-color: var(--surface-2); color: var(--text-2); opacity: 1;
}
.form-label { display: block; margin-bottom: 6px; font-size: var(--fs-md); font-weight: 700; color: var(--text-2); }
.form-check-input { background-color: var(--surface); border-color: var(--border); }
.form-check-input:checked { background-color: var(--p); border-color: var(--p); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--p); }
.text-danger { color: var(--danger) !important; }
.validation-message { color: var(--danger); font-size: var(--fs-sm); }
.invalid { outline: 1px solid var(--danger); }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }

/* Buscador de listados (<input class="form-control" placeholder="Buscar...">):
   medidas y lupa uniformes (pisa estilos en línea de cada página). */
.card-body input.form-control[placeholder^="Buscar"] {
    max-width: 420px !important;
    height: 44px;
    margin: 16px 0 14px !important;
    padding-left: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235F6579' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 14px center; background-size: 16px 16px;
}
[data-theme="dark"] .card-body input.form-control[placeholder^="Buscar"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238F8F8F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
}

/* Formulario Usuarios: DNI + botón de verificación */
.dni-field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.btn-dni-check { min-width: 132px; height: 42px; }

/* ══════════════════════════ 11. TARJETAS, BADGES Y ALERTAS ══════════════════════════ */
.card {
    --bs-card-bg: var(--surface);
    --bs-card-border-color: var(--border);
    --bs-card-color: var(--text);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px;
    background: transparent; color: var(--text);
    border-bottom: 1px solid var(--border-lite);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    font-weight: 700;
}
.card-body { padding: 20px; }
.card-title { margin: 0; font-size: var(--fs-lg); font-weight: 800; color: var(--text); }
.card-body > hr { margin: 16px 0; }
.clearfix + hr, .soft-hr { margin: 16px 0; border: 0; border-top: 1px solid var(--border-lite); height: 0; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 9px; border-radius: var(--r-full);
    font-size: var(--fs-sm); font-weight: 700; line-height: 1.2;
    background: var(--surface-2); color: var(--text-2);
}
.badge-success, .badge.bg-success { background: var(--success-bg) !important; color: var(--success) !important; }
.badge-danger,  .badge.bg-danger  { background: var(--danger-bg) !important;  color: var(--danger) !important; }
.badge-warning, .badge.bg-warning { background: var(--warning-bg) !important; color: var(--warning) !important; }
.badge-info,    .badge.bg-info    { background: var(--info-bg) !important;    color: var(--info) !important; }

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; margin-bottom: 16px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--text); font-size: var(--fs-base);
}
.alert-success { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--text); }
.alert-danger  { background: var(--danger-bg);  border-color: color-mix(in srgb, var(--danger) 30%, transparent);  color: var(--text); }
.alert-warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--text); }
.alert-info    { background: var(--info-bg);    border-color: color-mix(in srgb, var(--info) 30%, transparent);    color: var(--text); }
.alert > i:first-child { margin-top: 2px; }
.alert-success > i:first-child { color: var(--success); }
.alert-danger > i:first-child { color: var(--danger); }
.alert-warning > i:first-child { color: var(--warning); }
.alert-info > i:first-child { color: var(--info); }

/* Mensaje persistente dentro de un panel (los operativos van a toast). */
.core-inline-status {
    display: flex; align-items: flex-start; gap: 10px;
    margin: 0 0 14px; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); color: var(--text-2);
    font-size: var(--fs-md); line-height: 1.45;
}
.core-inline-status > i { margin-top: 2px; color: var(--icon); }
.core-inline-status.is-warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--text); }
.core-inline-status.is-warning > i { color: var(--warning); }

/* ══════════════════════════ 12. TABLAS ══════════════════════════ */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border-lite);
    --bs-table-hover-bg: transparent;
    --bs-table-hover-color: var(--text);
    --bs-table-active-bg: transparent;
    --bs-table-active-color: var(--text);
    --bs-table-striped-bg: transparent;
    width: 100%; min-width: 640px;
    border-collapse: separate; border-spacing: 0;
    margin-bottom: 0;
    font-size: var(--fs-base); color: var(--text);
    /* La tabla es un bloque propio: borde, esquinas y sombra suave. */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}
/* Bootstrap pinta bordes en thead/tbody (incluida una línea oscura bajo el
   encabezado): se anulan, aquí los bordes van por celda. */
.table > :not(caption) > * { border-width: 0; border-color: transparent; }
[data-theme="dark"] .table { box-shadow: none; border-color: var(--border); }

/* Cualquier tabla dentro de .card-body hace scroll horizontal por sí sola. */
.card-body:has(table.table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Encabezado: franja tintada con el color de marca, texto con peso y línea de marca
   (tokens --th-*; en oscuro son neutros). */
.table thead th {
    padding: 13px 14px;
    background: var(--th-bg);
    color: var(--th-text);
    font-size: var(--fs-sm); font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
    text-align: left; white-space: nowrap; user-select: none;
    border: 0; border-bottom: 2px solid var(--th-line);
}
[data-theme="dark"] .table thead th { border-bottom-width: 1px; }

/* Cuerpo: separadores finos; el hover (tinte + indicador lateral) da la guía visual. */
.table tbody td {
    padding: 12px 14px; vertical-align: middle;
    color: var(--text); background: var(--surface);
    border: 0; border-bottom: 1px solid var(--border-lite);
    transition: background var(--ease);
}
.table tbody tr:last-child > td { border-bottom: 0; }
/* Densidad compacta («Mis preferencias»): filas más bajas, misma letra. */
:root[data-table-density="compacta"] .table thead th { padding-top: 8px; padding-bottom: 8px; }
:root[data-table-density="compacta"] .table tbody td { padding-top: 5px; padding-bottom: 5px; }
:root[data-table-density="compacta"] .table td .gvCmdBtn { width: 30px; height: 30px; border-radius: 8px; }
.table tbody tr:hover > td { background: var(--p-soft); }
.table tbody tr:hover > td:first-child { box-shadow: inset 3px 0 0 var(--p); }
.table tbody tr.table-active > td { background: var(--p-soft-2) !important; }
.table tbody tr.table-active > td:first-child { box-shadow: inset 3px 0 0 var(--p); }
.table tbody td strong { font-weight: 700; color: var(--text); }

/* Core 3.16 · Celdas legibles (REGLAS_UI.md §1d).
   td-num / th-num: importes y cantidades a la derecha, cifras alineadas, sin salto de línea.
   td-nowrap: fechas, documentos y códigos en una línea (core-ui.js la pone sola en celdas que
   solo tienen una fecha o un número). td-sub: segunda línea gris dentro de la celda. */
.table :is(th.th-num, td.td-num) { text-align: right; white-space: nowrap; }
.table td.td-nowrap { white-space: nowrap; }
.table td .td-sub { display: block; margin-top: 1px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); white-space: nowrap; }

/* Columna de acciones: siempre en una sola línea. */
.table td:has(> .gvCmdBtn) { white-space: nowrap; width: 1%; }
.table td .gvCmdBtn { width: 36px; height: 36px; margin-right: 6px; font-size: var(--fs-lg); border-radius: 10px; }
.table td .gvCmdBtn:last-child { margin-right: 0; }

/* Acciones siempre visibles en escritorio y táctil; conserva disabled y permisos. */
@media (hover: hover) and (pointer: fine) {
    .table tbody td .gvCmdBtn { opacity: 1; transition: opacity 120ms ease, background var(--ease), color var(--ease), border-color var(--ease); }
    .table tbody tr:hover td .gvCmdBtn,
    .table tbody tr:focus-within td .gvCmdBtn,
    .table tbody tr.table-active td .gvCmdBtn { opacity: 1; }
}

/* Selección de filas (casillas): columna angosta, fila marcada con tinte de marca. */
.table :is(th, td):is(.th-select, .td-select) { width: 44px; text-align: center; padding-left: 10px; padding-right: 10px; }
.row-check { width: 18px; height: 18px; margin: 0; vertical-align: middle; accent-color: var(--p); cursor: pointer; }
.table tbody tr.row-selected > td { background: var(--p-soft); }
.table tbody tr.row-selected:hover > td { background: var(--p-soft-2); }

/* Fila de filtros por columna (ColumnFilterSelect) */
.table thead tr.column-filter-row th {
    padding: 8px 10px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    text-transform: none; letter-spacing: 0; font-weight: 600;
}
.column-filter { width: 100%; min-width: 92px; }
.column-filter-trigger {
    width: 100%; min-width: 0; height: 34px; padding: 0 10px;
    display: flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--surface); color: var(--text-2);
    font: 600 var(--fs-md) var(--font); cursor: pointer;
}
.column-filter-trigger:hover { border-color: var(--p-line); color: var(--text); }
.column-filter-trigger.active { background: var(--p-soft); border-color: var(--p-line); color: var(--p-text); }
.column-filter-trigger > i { font-size: var(--fs-2xs); color: var(--text-muted); flex-shrink: 0; }
.column-filter-caption { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.column-filter-count {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--p); color: var(--on-p); font-size: var(--fs-xs); font-weight: 700;
}
.column-filter-panel { min-width: 260px; }
.column-filter-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-lite); flex: 0 0 auto; }
.column-filter-search i { color: var(--text-muted); font-size: var(--fs-sm); }
.column-filter-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: var(--fs-base) var(--font); }
.column-filter-search input::placeholder { color: var(--text-muted); opacity: 1; }
.column-filter-options { min-height: 48px; max-height: 230px; overflow-y: auto; padding: 6px; }
.column-filter-option {
    display: flex; align-items: center; gap: 9px; padding: 8px 9px;
    border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-md); cursor: pointer; user-select: none;
}
.column-filter-option:hover { background: var(--surface-2); color: var(--text); }
.column-filter-option.selected { background: var(--p-soft); color: var(--p-text); font-weight: 700; }
.column-filter-option input { width: 15px; height: 15px; accent-color: var(--p); flex-shrink: 0; }
.column-filter-footer { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--border-lite); background: var(--surface-2); }
.column-filter-footer .btn { margin-left: auto; }
.column-filter-link { padding: 4px 2px; border: 0; background: transparent; color: var(--p-text); font-size: var(--fs-md); font-weight: 700; cursor: pointer; }
.column-filter-link.danger { color: var(--danger); }
.column-filter-link:disabled { opacity: .45; cursor: not-allowed; }
.column-filter-clear-all {
    display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
    border: 0; background: transparent; color: var(--danger); font-size: var(--fs-md); font-weight: 700; cursor: pointer;
}
.column-filter-clear-all:disabled { display: none; }

/* ══════════════════════════ 13. FILTROS ACTIVOS / INACTIVOS ══════════════════════════ */
.filter-stats { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; max-width: 520px; }
/* Cada tarjeta lleva el color de su estado: franja lateral, ícono y, al estar
   seleccionada, fondo degradado y anillo de ese color. */
.filter-stat-card {
    --fsc-c: var(--success); --fsc-bg: var(--success-bg);
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px 14px 19px; text-align: left;
    border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); color: var(--text);
    cursor: pointer; transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.filter-stat-card.inactivos { --fsc-c: var(--text-muted); --fsc-bg: var(--surface-3); }
.filter-stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--fsc-c); opacity: .55; }
.filter-stat-card:hover { border-color: color-mix(in oklab, var(--fsc-c) 45%, var(--border)); }
.filter-stat-card.selected {
    border-color: var(--fsc-c);
    background: linear-gradient(120deg, var(--fsc-bg), var(--surface) 75%);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fsc-c) 22%, transparent);
}
.filter-stat-card.selected::before { opacity: 1; }
.fsc-icon { width: 42px; height: 42px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--r-md); font-size: var(--fs-2xl); }
.filter-stat-card .fsc-icon { background: var(--fsc-bg); color: var(--fsc-c); }
.filter-stat-card.selected .fsc-icon { background: var(--fsc-c); color: var(--surface); }
[data-theme="dark"] .filter-stat-card.selected { background: var(--surface); }
.fsc-text { display: flex; flex-direction: column; }
.fsc-text small { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.fsc-text strong { font-size: var(--fs-4xl); font-weight: 800; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }

/* ══════════════════════════ 14. MODALES (gxModal) ══════════════════════════ */
.gxModal {
    display: none; position: fixed; inset: 0; z-index: 200000;
    align-items: center; justify-content: center;
    padding: 16px; overflow-y: auto;
    background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.gxModal.gxModal--open { display: flex; }
/* Core 3.16 · El popup entra con un leve acercamiento (en celular, core-ui.css lo sube como hoja). */
.gxModal.gxModal--open .gxModal__content { animation: core-modal-in .2s cubic-bezier(.2,.9,.3,1.1) both; }
@keyframes core-modal-in { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.gxModal__dialog { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; }
.gxModal__content {
    position: relative; display: flex; flex-direction: column;
    width: 100%; min-height: 0; overflow: hidden;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
}
.gxModal__header {
    flex-shrink: 0;
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    min-height: 64px; padding: 18px 96px 16px 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-lite);
}
.gxModal__title { margin: 0; font-size: var(--fs-2xl); font-weight: 800; line-height: 1.3; color: var(--text); }
.gxModal__header .text-muted { color: var(--text-muted) !important; }
.gxModal__body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 20px 22px; color: var(--text-2); font-size: var(--fs-base);
    background: var(--surface);
}
.gxModal__body .row.g-3 > [class*="col-"] { margin-bottom: 4px; }
.gxModal__footer {
    flex-shrink: 0;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 14px 22px;
    background: var(--surface-2); border-top: 1px solid var(--border-lite);
}
/* Pie anidado dentro del body (patrón de varias páginas del Core) */
.gxModal__body .gxModal__footer { margin: 20px -22px -20px; }
.gxModal__footer .btn { min-width: 120px; }

/* Cerrar + maximizar (este último lo inyecta modal-manager.js) */
.gxModal button[aria-label="Cerrar"],
.gxModal .popup-toolbar-btn {
    position: absolute; z-index: 2;
    width: 34px; height: 34px; padding: 0; margin: 0;
    display: inline-grid; place-items: center;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); color: var(--text-2); font-size: var(--fs-base);
    cursor: pointer; transition: background var(--ease), color var(--ease);
}
.gxModal button[aria-label="Cerrar"] { top: 15px; right: 16px; }
.gxModal__header .popup-maximize-btn { top: 15px; right: 56px; }
.gxModal button[aria-label="Cerrar"]:hover,
.gxModal .popup-toolbar-btn:hover { background: var(--surface-2); color: var(--text); }

/* Diálogo de confirmación (ConfirmDialogHost): ahora usa CoreModal; estilos en core-ui.css. */

/* Auditoría estándar: debajo del encabezado del modal */
.core-audit-strip {
    display: grid; gap: 7px;
    padding: 10px 22px;
    background: var(--surface-2); border-bottom: 1px solid var(--border-lite);
    color: var(--text-2); font-size: var(--fs-md);
}
.core-audit-item { display: flex; align-items: center; gap: 9px; min-width: 0; }
.core-audit-icon { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--icon); }
.core-audit-item strong { color: var(--text); }

/* ══════════════════════════ 15. PÁGINAS DE ESTADO Y BLOQUES ══════════════════════════ */
/* Encabezado de marca (CambiarClave, PerfilUsuario, Error) */
.hero-band { background: color-mix(in oklab, var(--brand) 86%, #0A0C13); color: #fff; }
.hero-band h1, .hero-band h2, .hero-band h3, .hero-band h4, .hero-band h5 { color: #fff; }
[data-theme="dark"] .hero-band { background: var(--surface-3); color: var(--text); }
[data-theme="dark"] .hero-band h1, [data-theme="dark"] .hero-band h2, [data-theme="dark"] .hero-band h3,
[data-theme="dark"] .hero-band h4, [data-theme="dark"] .hero-band h5 { color: var(--text); }
.card-header.hero-band { border-bottom: 0; }

/* Acceso restringido */
.access-denied-shell {
    max-width: 760px; margin: 48px auto; padding: 28px;
    display: flex; gap: 20px; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
}
.access-denied-icon { width: 58px; height: 58px; flex: 0 0 58px; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: var(--warning-bg); color: var(--warning); font-size: var(--fs-4xl); }
.access-denied-copy h1 { margin: 0 0 8px; font-size: var(--fs-4xl); font-weight: 800; color: var(--text); }
.access-denied-copy p { margin: 0; color: var(--text-2); }
.access-denied-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* Estado vacío genérico */
.empty-state { padding: 44px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--text-muted); }
.empty-state i { width: 56px; height: 56px; margin-bottom: 6px; display: flex; align-items: center; justify-content: center; border-radius: 16px; font-size: var(--fs-4xl); color: var(--p-text);
    /* Mosaico de marca con un sol cálido en la esquina (decorativo, --calido). */
    background: radial-gradient(circle at 76% 24%, var(--calido) 0 5px, transparent 5.5px), var(--p-soft); }
.empty-state strong { font-size: var(--fs-lg); color: var(--text); }
.empty-state span { font-size: var(--fs-md); }

/* ══════════════════════════ 16. TABLERO (Principal.razor) ══════════════════════════ */
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dash-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Core 3.16 · Banda de bienvenida: malla de la acción con el tono cálido de acompañamiento.
   Texto con --on-p (negro en marcas claras). En oscuro neutro es una superficie gris;
   en oscuro de marca (§2b) vuelve el degradado. */
.dash-hero {
    position: relative; overflow: hidden; isolation: isolate;
    padding: 26px 28px; border-radius: var(--r-xl);
    color: var(--on-p);
    background:
        radial-gradient(420px 220px at 92% -10%, rgba(255,255,255,.22), transparent 70%),
        radial-gradient(520px 260px at -5% 130%, color-mix(in srgb, var(--calido) 55%, transparent), transparent 70%),
        var(--p-grad), var(--p);
    box-shadow: var(--p-glow-hover);
}
.dash-hero .eyebrow { color: color-mix(in srgb, var(--on-p) 78%, transparent); }
.dash-hero .page-title { color: var(--on-p); }
.dash-hero .page-sub { color: color-mix(in srgb, var(--on-p) 84%, transparent); }
[data-theme="dark"] .dash-hero { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
[data-theme="dark"] .dash-hero .page-title { color: var(--text); }
[data-theme="dark"] .dash-hero .page-sub { color: var(--text-2); }
[data-theme="dark"] .dash-hero .eyebrow { color: var(--text-muted); }
@media (max-width: 640px) { .dash-hero { padding: 20px 18px; } }

/* KPIs (Core 3.16): tarjetas separadas con relieve; el ícono en degradado según su tono.
   .dash-kpis--compacta conserva la franja única con divisores de antes. */
.dash-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    gap: 14px; margin-bottom: 20px;
}
@media (max-width: 640px) {
    .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dash-kpis > .dash-kpi { padding: 14px; }
    .dash-kpis .dash-kpi-val { font-size: var(--fs-4xl); }
}
.dash-kpi {
    display: flex; flex-direction: column; gap: 6px;
    padding: 18px 20px; min-width: 0;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border-lite); border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}
a.dash-kpi:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.dash-kpis--compacta {
    display: flex; flex-wrap: wrap; gap: 1px; overflow: hidden;
    background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.dash-kpis--compacta > .dash-kpi { flex: 1 1 165px; border: 0; border-radius: 0; box-shadow: none; transform: none; }
.dash-kpis--compacta > a.dash-kpi:hover { background: var(--surface-2); box-shadow: none; transform: none; }
.dash-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dash-kpi-lbl { font-size: var(--fs-md); font-weight: 600; color: var(--text-2); }
/* Ícono del indicador: tinte de marca por defecto; tonos de estado abajo. */
.dash-kpi-ic {
    --kc: var(--p);
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-md); font-size: var(--fs-lg);
    background: var(--p-grad), var(--p); color: var(--on-p);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--kc) 30%, transparent), var(--hl);
}
.dash-kpi-val { font-size: var(--fs-5xl); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-kpi-det { font-size: var(--fs-md); color: var(--text-muted); }
/* Mini gráfico de tendencia (DashKpiVM.Tendencia): línea de marca, área tenue y punto final. */
.dash-kpi-spark { width: 100%; height: 32px; margin-top: 6px; display: block; }
.dash-kpi-spark__area { stroke: none; }
.dash-kpi-spark__stop { stop-color: var(--p); stop-opacity: .26; }
.dash-kpi-spark__stop--fin { stop-opacity: 0; }
/* Variación (DashKpiVM.Variacion): pastilla verde si es buena noticia, roja si no. */
.dash-kpi-delta {
    display: inline-flex; align-items: center; gap: 5px; width: fit-content;
    padding: 2px 9px; border-radius: var(--r-full);
    font-size: var(--fs-xs); font-weight: 800; font-variant-numeric: tabular-nums;
}
.dash-kpi-delta.is-good { background: var(--success-bg); color: var(--success); }
.dash-kpi-delta.is-bad { background: var(--danger-bg); color: var(--danger); }
.dash-kpi-spark__linea { fill: none; stroke: var(--p); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.dash-kpi-spark__fin { fill: var(--p); }
.dash-kpi.tone-success .dash-kpi-ic { --kc: var(--success); background: linear-gradient(135deg, color-mix(in oklab, var(--success) 75%, #fff), var(--success)); color: #fff; }
.dash-kpi.tone-warning .dash-kpi-ic { --kc: var(--warning); background: linear-gradient(135deg, color-mix(in oklab, var(--warning) 70%, #fff), var(--warning)); color: #fff; }
.dash-kpi.tone-danger  .dash-kpi-ic { --kc: var(--danger);  background: linear-gradient(135deg, color-mix(in oklab, var(--danger) 75%, #fff), var(--danger)); color: #fff; }
.dash-kpi.tone-info    .dash-kpi-ic { --kc: var(--info);    background: linear-gradient(135deg, color-mix(in oklab, var(--info) 75%, #fff), var(--info)); color: #fff; }
/* Oscuro neutro: íconos en tinte (sin degradados ni sombras de color). */
[data-theme="dark"] .dash-kpi-ic { background: var(--p-soft); color: var(--p-text); box-shadow: none; }
[data-theme="dark"] .dash-kpi.tone-success .dash-kpi-ic { background: var(--success-bg); color: var(--success); }
[data-theme="dark"] .dash-kpi.tone-warning .dash-kpi-ic { background: var(--warning-bg); color: var(--warning); }
[data-theme="dark"] .dash-kpi.tone-danger  .dash-kpi-ic { background: var(--danger-bg);  color: var(--danger); }
[data-theme="dark"] .dash-kpi.tone-info    .dash-kpi-ic { background: var(--info-bg);    color: var(--info); }
.dash-kpi.tone-success .dash-kpi-det { color: var(--success); }
.dash-kpi.tone-warning .dash-kpi-det { color: var(--warning); }
.dash-kpi.tone-danger  .dash-kpi-det { color: var(--danger); font-weight: 600; }

.dash-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.dash-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.dash-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.dash-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; min-width: 0; }
.dash-panel-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px; }
.dash-panel-head p { margin: 0; font-size: var(--fs-md); color: var(--text-muted); }
.dash-panel-title { margin: 0; font-size: var(--fs-xl); font-weight: 800; color: var(--text); }
.dash-panel-count {
    min-width: 22px; height: 20px; padding: 0 7px; border-radius: var(--r-full);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--danger-bg); color: var(--danger); font-size: var(--fs-sm); font-weight: 700;
}
.dash-item { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-top: 1px solid var(--border-lite); color: var(--text); }
a.dash-item:hover { background: var(--surface-2); color: var(--text); }
.dash-item-ic {
    width: 38px; height: 38px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 11px; background: var(--surface-2); color: var(--icon); font-size: var(--fs-lg);
}
.dash-item.tone-danger  .dash-item-ic { background: var(--danger-bg);  color: var(--danger); }
.dash-item.tone-warning .dash-item-ic { background: var(--warning-bg); color: var(--warning); }
.dash-item.tone-info    .dash-item-ic { background: var(--info-bg);    color: var(--info); }
.dash-item.tone-success .dash-item-ic { background: var(--success-bg); color: var(--success); }
.dash-item-txt { flex: 1; min-width: 0; }
.dash-item-title { font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.dash-item-sub { font-size: var(--fs-md); color: var(--text-muted); }
.dash-item-link { padding: 6px 10px; border-radius: var(--r-sm); font-size: var(--fs-md); font-weight: 700; color: var(--p-text); white-space: nowrap; }
.dash-item-link:hover { background: var(--p-soft); color: var(--p-text); }
.dash-item-chev { font-size: var(--fs-sm); color: var(--text-muted); }
.dash-item.is-quiet { padding-top: 11px; padding-bottom: 11px; }
.dash-item.is-quiet .dash-item-ic { width: 34px; height: 34px; border-radius: 10px; font-size: var(--fs-base); }
.dash-item.is-quiet .dash-item-title { font-weight: 600; }
.dash-help { margin-top: 0; }

/* Accesos directos */
.qa-shell { padding: 18px 20px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.qa-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.qa-head .ic-badge { display: none; }
.qa-head h3 { margin: 0; font-size: var(--fs-xl); font-weight: 800; color: var(--text); }
.qa-head p { margin: 0; font-size: var(--fs-md); color: var(--text-muted); }
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.qa-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
    padding: 16px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    transition: border-color var(--ease), background var(--ease);
    opacity: 0; animation: qaIn .4s ease forwards;
}
.qa-card:nth-child(2) { animation-delay: .04s; } .qa-card:nth-child(3) { animation-delay: .08s; }
.qa-card:nth-child(4) { animation-delay: .12s; } .qa-card:nth-child(5) { animation-delay: .16s; }
.qa-card:nth-child(n+6) { animation-delay: .2s; }
@keyframes qaIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.qa-card:hover { border-color: var(--p-line); background: var(--p-soft); color: var(--text); }
.qa-ic-wrap {
    width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 11px; background: var(--p-soft); color: var(--p-text); font-size: var(--fs-2xl);
}
.qa-card:hover .qa-ic-wrap { background: var(--surface); }
.qa-label { font-size: var(--fs-base); font-weight: 700; line-height: 1.3; }

/* Módulos destacados (lk-module-*, usado por proyectos con tarjetas de módulo) */
.lk-home-card { background: transparent !important; border: 0 !important; box-shadow: none !important; margin-bottom: 0; }
.lk-home-card > .card-body { padding: 0; }
.lk-module-link { display: flex; flex-direction: column; height: 100%; width: 100%; }
.lk-module-card {
    flex: 1; display: flex; flex-direction: column; gap: 6px;
    min-height: 140px; padding: 18px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    transition: border-color var(--ease), background var(--ease);
}
.lk-module-link:hover .lk-module-card { border-color: var(--p-line); }
.lk-module-ico { width: 40px; height: 40px; margin-bottom: 4px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--p-soft); color: var(--p-text); }
.lk-module-ico i { font-size: var(--fs-2xl); }
.lk-module-title { margin: 0; font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.lk-module-sub { flex: 1; margin: 0; font-size: var(--fs-md); line-height: 1.45; color: var(--text-muted); }
.lk-module-cta { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; width: fit-content; font-size: var(--fs-md); font-weight: 700; color: var(--p-text); }

/* Preguntas frecuentes (FAQ) */
.faq-shell { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.faq-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.faq-ic { width: 40px; height: 40px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--surface-2); color: var(--icon); }
.faq-title { margin: 0; font-size: var(--fs-xl); font-weight: 800; color: var(--text); }
.faq-subtitle { margin: 2px 0 0; font-size: var(--fs-md); color: var(--text-muted); }
.faq-acc { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 992px) { .faq-acc { grid-template-columns: 1fr 1fr; } }
.faq-acc details { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; transition: border-color var(--ease); }
.faq-acc details:hover, .faq-acc details[open] { border-color: var(--p-line); }
.faq-acc summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 16px; font-size: var(--fs-base); font-weight: 700; color: var(--text);
}
.faq-acc summary::-webkit-details-marker { display: none; }
.faq-chip {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    padding: 5px 10px; border-radius: var(--r-full);
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); white-space: nowrap;
}
.faq-acc details[open] .faq-chip { background: var(--p-soft); border-color: var(--p-line); color: var(--p-text); }
.faq-body { padding: 14px 16px 16px; font-size: var(--fs-base); line-height: 1.6; color: var(--text-2); border-top: 1px solid var(--border-lite); }
.faq-body a:not(.btn) { color: var(--p-text); text-decoration: underline; text-underline-offset: 2px; }
.faq-steps { margin: 8px 0 0 18px; padding: 0; }
.faq-steps li { margin-bottom: 4px; }
.faq-note { margin-top: 10px; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border-lite); font-size: var(--fs-md); color: var(--text-2); }

/* ══════════════════════════ 17. GESTIÓN DE PERMISOS ══════════════════════════ */
.perm-grid { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 16px; }
.perm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.perm-card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-lite); font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.perm-card-head .ic { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface-2); color: var(--icon); font-size: var(--fs-md); }
.perm-card-body { padding: 12px; max-height: 420px; overflow-y: auto; }

.perm-mod-item, .perm-menu-row {
    width: 100%; border: 0; background: transparent; text-align: left;
    font-family: inherit; color: var(--text-2); cursor: pointer;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.perm-mod-item { display: block; padding: 10px 12px; margin-bottom: 4px; border-radius: var(--r-md); font-size: var(--fs-base); }
.perm-mod-item:hover { background: var(--surface-2); color: var(--text); }
.perm-mod-item.sel { background: var(--p-soft); color: var(--p-text); font-weight: 700; }

.perm-menu-row {
    position: relative; display: flex; align-items: center; justify-content: flex-start; gap: 10px;
    padding: 11px 12px; margin-bottom: 4px;
    border: 1px solid transparent; border-radius: var(--r-md); font-size: var(--fs-base);
}
.perm-menu-row:hover { background: var(--surface-2); color: var(--text); }
.perm-menu-row .name { font-weight: 600; }
.perm-menu-row .link { margin-left: auto; font-size: var(--fs-sm); color: var(--text-muted); }
.perm-menu-row.granted::after { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--success); }
.perm-menu-row.selected { background: var(--p-soft); border-color: var(--p-line); color: var(--p-text); font-weight: 700; }
.perm-menu-row.selected .name::before {
    content: '\f00c'; margin-right: 8px;
    font-family: 'Font Awesome 6 Pro', 'Font Awesome 6 Free'; font-weight: 900; font-size: var(--fs-2xs); color: var(--p-text);
}

.perm-toggles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.perm-chip {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 13px; border-radius: var(--r-full);
    background: var(--surface-2); border: 1px solid var(--border);
    font-family: inherit; font-size: var(--fs-md); font-weight: 600; color: var(--text-2);
    cursor: pointer; transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.perm-chip:hover:not(:disabled) { border-color: color-mix(in srgb, var(--text-muted) 45%, var(--border)); }
.perm-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.perm-chip.on { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.perm-chip.on .dot { background: var(--success); }
.perm-chip:disabled { opacity: .55; cursor: not-allowed; }
.perm-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: var(--fs-md); color: var(--text-muted); }
.perm-note strong { color: var(--text-2); }
.perm-readonly {
    display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); border-radius: var(--r-md);
    background: var(--warning-bg); color: var(--text-2); font-size: var(--fs-md); line-height: 1.4;
}

/* ══════════════════════════ 18. CATÁLOGO DE ÍCONOS (GestionMenu) ══════════════════════════ */
.icon-search { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 0 14px; height: 42px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-base); }
.icon-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: var(--fs-base); }
.icon-cat-lbl { margin: 16px 0 8px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.icon-cat-lbl:first-child { margin-top: 0; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.icon-cell {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 4px; border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); font-family: inherit; cursor: pointer;
    transition: border-color var(--ease), background var(--ease);
}
.icon-cell:hover { border-color: var(--p-line); }
.icon-cell i { font-size: var(--fs-2xl); color: var(--text-2); }
.icon-cell span { font-size: var(--fs-2xs); line-height: 1.2; text-align: center; color: var(--text-muted); }
.icon-cell.picked { border-color: var(--p); background: var(--p-soft); }
.icon-cell.picked i { color: var(--p-text); }

/* ══════════════════════════ 19. SELECT CON BUSCADOR (SearchableSelect) ══════════════════════════ */
.ssel { position: relative; }
.ssel-trigger { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; background: var(--surface); color: var(--text); }
.ssel-trigger .ssel-ico { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--surface-2); color: var(--icon); font-size: var(--fs-md); }
.ssel-trigger .ssel-trigger-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
/* No usar .placeholder: Bootstrap la convierte en barra gris de carga. */
.ssel-trigger .ssel-trigger-text.ssel-placeholder { color: var(--text-muted); opacity: 1; background: transparent; }
.ssel-trigger > i.fa-chevron-down { flex-shrink: 0; font-size: var(--fs-xs); color: var(--text-muted); transition: transform var(--ease); }
.ssel-trigger.open > i.fa-chevron-down { transform: rotate(180deg); }
.ssel-panel {
    position: fixed; inset: auto; margin: 0; padding: 0; z-index: 2147483000;
    width: var(--ssel-panel-width, 280px); max-width: calc(100vw - 16px);
    max-height: var(--ssel-panel-max-height, min(360px, calc(100vh - 16px)));
    flex-direction: column; overflow: hidden;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.ssel-panel:popover-open { display: flex; }
.ssel-panel::backdrop { background: transparent; }
.ssel-search { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-lite); }
.ssel-search i { color: var(--text-muted); font-size: var(--fs-md); }
.ssel-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: var(--fs-base); }
.ssel-search input::placeholder { color: var(--text-muted); opacity: 1; }
.ssel-list { flex: 1 1 auto; min-height: 0; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.ssel-item {
    width: 100%; display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: transparent;
    text-align: left; font-size: var(--fs-base); color: var(--text-2); cursor: pointer;
    transition: background var(--ease), color var(--ease);
}
.ssel-item:hover { background: var(--surface-2); color: var(--text); }
.ssel-item.active { background: var(--surface-2); outline: 2px solid var(--p-ring); outline-offset: -2px; }
.ssel-item.picked { background: var(--p-soft); color: var(--p-text); font-weight: 700; }
.ssel-item .ssel-ico { width: 24px; height: 24px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--surface-2); color: var(--icon); font-size: var(--fs-sm); }
.ssel-empty { padding: 22px; text-align: center; font-size: var(--fs-md); color: var(--text-muted); }
.ssel-empty--error { color: var(--danger); }
.ssel-loading { margin-left: auto; color: var(--p) !important; }

/* ══════════════════════════ 20. CARGA GLOBAL ══════════════════════════ */
.loading-overlay {
    position: fixed; inset: 0; z-index: 20050;
    display: flex; align-items: center; justify-content: center;
    background: var(--overlay); backdrop-filter: blur(2px);
}
.loading-card {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    min-width: 280px; max-width: min(520px, calc(100vw - 32px)); min-height: 80px;
    padding: 20px 24px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
    animation: fade-up 180ms ease both;
}
.loading-card .spinner-border { color: var(--p) !important; }
.loading-text { font-size: var(--fs-base); font-weight: 700; color: var(--text); }

/* ══════════════════════════ 21. PAGINADOR ══════════════════════════ */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 10px 2px; }
.pager-info { font-size: var(--fs-md); color: var(--text-muted); }
.pager-controls { display: flex; align-items: center; gap: 8px; }
.pager-page { min-width: 110px; text-align: center; font-size: var(--fs-base); font-weight: 600; color: var(--text); }
.pager-btn {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text-2);
    cursor: pointer; transition: background var(--ease);
}
.pager-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ══════════════════════════ 22. TOASTS (brandShell.toast) ══════════════════════════ */
[data-toast-scope] { position: relative; }
.bt-toast-stack { display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.bt-toast-stack--page {
    position: fixed; z-index: 300000;
    top: calc(var(--shell-gap) + var(--topbar-h) + 12px); right: calc(var(--shell-gap) + 4px);
    width: min(380px, calc(100vw - 24px));
}
.bt-toast-stack--anchored { position: absolute; top: 14px; right: 14px; width: min(360px, calc(100% - 28px)); z-index: 30; }
.bt-toast {
    --bt-c: var(--success); --bt-bg: var(--success-bg);
    position: relative; pointer-events: auto;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 12px 16px 14px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-lg); overflow: hidden;
    animation: bt-toast-in .3s cubic-bezier(.21,1.02,.73,1) both;
}
.bt-toast--success { --bt-c: var(--success); --bt-bg: var(--success-bg); }
.bt-toast--error   { --bt-c: var(--danger);  --bt-bg: var(--danger-bg); }
.bt-toast--warning { --bt-c: var(--warning); --bt-bg: var(--warning-bg); }
.bt-toast--info    { --bt-c: var(--info);    --bt-bg: var(--info-bg); }
.bt-toast__ic { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--bt-bg); color: var(--bt-c); font-size: var(--fs-xl); }
.bt-toast__txt { flex: 1; min-width: 0; padding-top: 1px; }
.bt-toast__title { font-size: var(--fs-base); font-weight: 700; line-height: 1.3; color: var(--text); }
.bt-toast__msg { margin-top: 2px; font-size: var(--fs-md); line-height: 1.45; color: var(--text-2); overflow-wrap: anywhere; }
.bt-toast__close { width: 28px; height: 28px; margin: -4px -2px 0 0; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; }
.bt-toast__close:hover { background: var(--surface-2); color: var(--text); }
.bt-toast__bar { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: var(--bt-c); opacity: .55; transform-origin: left center; animation: bt-toast-bar var(--bt-ms, 4000ms) linear forwards; }
.bt-toast.is-paused .bt-toast__bar { animation-play-state: paused; }
.bt-toast.is-leaving { animation: bt-toast-out .22s ease forwards; }
@keyframes bt-toast-in  { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes bt-toast-out { to { opacity: 0; transform: translateX(16px) scale(.97); } }
@keyframes bt-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.brand-toast, .toast-brand { border: 1px solid var(--border) !important; box-shadow: var(--shadow-lg) !important; }

/* ══════════════════════════ 23. LABORATORIO FACTILIZA (TestFactiliza.razor) ══════════════════════════ */
.factiliza-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.factiliza-grid .card { min-width: 0; }
.factiliza-field { margin-bottom: 16px; }
.factiliza-field label { display: block; margin-bottom: 6px; font-size: var(--fs-md); font-weight: 700; color: var(--text-2); }
.factiliza-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.factiliza-result { padding: 14px; max-height: 460px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md); font-family: var(--font-mono); font-size: var(--fs-sm); }

.fl-hero { display: flex; align-items: center; gap: 18px; padding: 24px; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.fl-hero-icon { width: 56px; height: 56px; flex: 0 0 56px; display: grid; place-items: center; border-radius: 16px; background: var(--p-soft); color: var(--p-text); font-size: var(--fs-4xl); }
.fl-hero-copy { flex: 1; min-width: 0; }
.fl-hero-copy h1 { margin: 4px 0 6px; font-size: var(--fs-5xl); font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.fl-hero-copy p { margin: 0; font-size: var(--fs-base); color: var(--text-2); }
.fl-hero-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; background: var(--success-bg); color: var(--success); font-size: var(--fs-md); font-weight: 700; white-space: nowrap; }

.fl-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-bottom: 20px; overflow: hidden; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg); }
.fl-overview-item { display: flex; align-items: center; gap: 12px; padding: 18px; min-width: 0; background: var(--surface); }
.fl-overview-item div { flex: 1; min-width: 0; }
.fl-overview-item small { display: block; margin-bottom: 3px; font-size: var(--fs-md); color: var(--text-muted); }
.fl-overview-item strong { font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.fl-overview-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); color: var(--icon); font-size: var(--fs-2xl); }
.fl-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px var(--warning-bg); }
.fl-dot.is-ready { background: var(--success); box-shadow: 0 0 0 4px var(--success-bg); }

.fl-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); }
.fl-tab { flex: 1; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 10px 14px; border: 0; border-radius: 12px; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.fl-tab > i { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); color: var(--icon); font-size: var(--fs-lg); }
.fl-tab span { font-size: var(--fs-base); font-weight: 700; }
.fl-tab span small { display: block; margin-top: 2px; font-size: var(--fs-sm); font-weight: 400; color: var(--text-muted); }
.fl-tab:hover { color: var(--text); }
.fl-tab.is-active, .fl-tab.is-active:hover { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.fl-tab.is-active > i { background: var(--p); color: var(--on-p); }
.fl-tab:disabled { opacity: .65; cursor: wait; }

.fl-workspace { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.fl-form, .fl-result-card { min-width: 0; }
.fl-result-card { position: sticky; top: calc(var(--topbar-h) + var(--shell-gap) * 2); }
.fl-workspace.fl-config { grid-template-columns: minmax(0, 1fr); }
.fl-config .fl-form { width: 100%; max-width: none; }
.fl-workspace .card { overflow: hidden; }
.fl-workspace .card-header { padding: 16px 20px; font-size: var(--fs-lg); font-weight: 700; }
.fl-workspace .card-body { padding: 22px; }
.fl-card-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--icon); font-size: var(--fs-base); }
.fl-workspace input.form-control, .fl-workspace select.form-select { height: 44px; }
.fl-workspace textarea.form-control { min-height: 80px; }
.fl-workspace #fe-json, .fe-json { min-height: 300px; font-family: var(--font-mono); font-size: var(--fs-sm); }
.fl-workspace .btn { min-height: 42px; }
.fl-workspace .factiliza-result { max-height: 65vh; margin-bottom: 0; }
.fl-status { color: var(--text-2); overflow-wrap: anywhere; }
.fl-data { margin: 0; }
.fl-data-row { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(0, 1.3fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-lite); }
.fl-data-row:last-child { border-bottom: 0; }
.fl-data dt { font-size: var(--fs-md); font-weight: 500; color: var(--text-muted); }
.fl-data dd { margin: 0; font-weight: 600; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.fl-empty { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; color: var(--text-muted); }
.fl-empty i { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 18px; background: var(--p-soft); color: var(--p-text); font-size: var(--fs-4xl); }
.fl-empty span { max-width: 340px; font-size: var(--fs-base); line-height: 1.5; }
.fl-json { margin-top: 16px; color: var(--text-2); }
.fl-json summary { cursor: pointer; padding: 8px 0; }
.fl-settings-note { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border-lite); border-radius: 12px; }
.fl-settings-note > i { padding-top: 3px; color: var(--icon); }
.fl-settings-note strong { font-size: var(--fs-md); color: var(--text); }
.fl-settings-note p { margin: 4px 0 0; font-size: var(--fs-md); color: var(--text-muted); }
.fl-config-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.fl-config-group { min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.fl-config-group legend { float: none; width: auto; margin: 0 0 8px; padding: 0; font-size: var(--fs-lg); font-weight: 700; color: var(--text); }
.fl-config-group legend i { margin-right: 7px; color: var(--icon); }
.fl-config-group > p { margin-bottom: 18px; font-size: var(--fs-md); color: var(--text-muted); }
.fl-config-billing { grid-column: 1 / -1; }
.fl-billing-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; }
.fl-wide { grid-column: 1 / -1; }
.fl-service-badge, .fl-storage-badge, .fl-result-badge { padding: 5px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
.fl-storage-badge, .fl-result-badge { margin-left: auto; }
.fl-result-badge.is-success { background: var(--success-bg); color: var(--success); }
.fl-result-badge.is-error { background: var(--danger-bg); color: var(--danger); }
.fl-result-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border-lite); font-size: var(--fs-sm); color: var(--text-muted); }
.fl-switch-row { display: flex; align-items: center; gap: 10px; padding: 13px; border-radius: 10px; background: var(--surface-2); }
.fl-switch-row input { width: 18px; height: 18px; accent-color: var(--p); }
.fl-switch-row strong { display: block; font-size: var(--fs-md); color: var(--text); }
.fl-switch-row small { display: block; margin-top: 3px; font-size: var(--fs-sm); color: var(--text-muted); }
.fl-save-bar { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--border-lite); }
.fl-save-bar > span { display: block; margin-top: 12px; font-size: var(--fs-sm); color: var(--text-muted); }
.fl-audit-head { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border); }
.fl-audit-head h2 { font-size: var(--fs-xl); font-weight: 700; color: var(--text); }
.fl-audit-head p, .fl-audit-empty { font-size: var(--fs-md); color: var(--text-muted); }
.fl-audit-table { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.fl-audit-table table { margin: 0; font-size: var(--fs-md); }
.fl-audit-table td, .fl-audit-table th { padding: 12px; white-space: normal; vertical-align: top; }

/* ══════════════════════════ 24. LOGIN (Login.razor) ══════════════════════════
   Dos paneles flotantes: marca (izquierda) y formulario (derecha).
   La figura del panel de marca es el icono.png del cliente en silueta blanca:
   funciona para cualquier cliente sin diseñar nada nuevo. */
.lg-page {
    min-height: 100vh; display: flex; flex-wrap: wrap; gap: var(--shell-gap);
    padding: var(--shell-gap); background: var(--body-bg);
}
.lg-brand {
    position: relative; overflow: hidden;
    flex: 1 1 440px; min-height: 260px;
    display: flex; flex-direction: column;
    padding: 40px;
    border-radius: 22px;
    background: color-mix(in oklab, var(--brand) 82%, #0A0C13);
    color: #fff;
}
[data-theme="dark"] .lg-brand { background: #141414; border: 1px solid var(--border); }
/* Marca clara (1c): panel negro con acentos de marca (identidad amarillo + negro). */
html[data-brand-tone="light"] .lg-brand { background: #111111; }
html[data-brand-tone="light"][data-theme="dark"] .lg-brand { background: #141414; }
.lg-dots {
    position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1.5px);
    background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(135deg, #000 0%, transparent 55%);
    mask-image: linear-gradient(135deg, #000 0%, transparent 55%);
}
.lg-watermark {
    position: absolute; right: -150px; bottom: -170px;
    width: 640px; height: auto; max-width: none;
    filter: brightness(0) invert(1); opacity: .09;
    transform: rotate(-10deg); pointer-events: none;
}
[data-theme="dark"] .lg-watermark { opacity: .06; }
.lg-seal {
    position: relative; align-self: flex-start;
    display: inline-flex; align-items: center;
    padding: 10px 16px; border-radius: 14px;
    background: rgba(255,255,255,.94);
}
.lg-seal img { display: block; height: 32px; width: auto; }
.lg-copy { position: relative; margin-top: auto; padding-top: 48px; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.lg-eyebrow { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.75); }
.lg-system { margin: 0; font-size: calc(36px * var(--fs-escala)); font-weight: 800; line-height: 1.15; letter-spacing: -.025em; color: #fff; }
html[data-brand-tone="light"] .lg-dots { background-image: radial-gradient(color-mix(in srgb, var(--p) 40%, transparent) 1px, transparent 1.5px); }
html[data-brand-tone="light"] .lg-watermark { opacity: .06; }
html[data-brand-tone="light"] .lg-eyebrow { color: var(--p); }
html[data-brand-tone="light"] .lg-system::after { content: ""; display: block; width: 56px; height: 5px; margin-top: 14px; border-radius: 3px; background: var(--p); }
.lg-lead { margin: 0; font-size: var(--fs-lg); line-height: 1.55; color: rgba(255,255,255,.82); }

.lg-panel {
    flex: 1 1 440px;
    display: flex; flex-direction: column;
    padding: 24px 32px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
}
.lg-top { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.lg-theme {
    width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface); color: var(--icon);
}
.lg-theme:hover { background: var(--surface-2); color: var(--text); }
.lg-theme .fa-sun { display: none; }
[data-theme="dark"] .lg-theme .fa-sun { display: inline-block; }
[data-theme="dark"] .lg-theme .fa-moon { display: none; }

.lg-form { width: 100%; max-width: 400px; margin: auto; padding: 24px 0; display: flex; flex-direction: column; gap: 20px; animation: fade-up 260ms ease both; }
.lg-title { margin: 0; font-size: var(--fs-5xl); font-weight: 800; letter-spacing: -.025em; color: var(--text); }
.lg-sub { margin: 6px 0 0; color: var(--text-2); }
.lg-field { display: flex; flex-direction: column; gap: 8px; }
.lg-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.lg-label { font-size: var(--fs-md); font-weight: 700; color: var(--text-2); }
.lg-link { font-size: var(--fs-md); font-weight: 700; color: var(--p-text); }
.lg-link:hover { color: var(--p-hover); text-decoration: underline; }
[data-theme="dark"] .lg-link:hover { color: #fff; }
.lg-input-wrap {
    display: flex; align-items: center; gap: 10px;
    height: 50px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--icon);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.lg-input-wrap:focus-within { border-color: var(--p); box-shadow: 0 0 0 4px var(--p-ring); }
.lg-input-wrap > i { width: 18px; text-align: center; }
.lg-input {
    flex: 1; min-width: 0; height: 100%;
    border: 0; outline: 0; background: transparent;
    color: var(--text); font: 500 var(--fs-lg) var(--font);
}
.lg-input::placeholder { color: var(--text-muted); }
.lg-eye {
    width: 36px; height: 36px; margin-right: -8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 8px; background: transparent; color: var(--icon);
}
.lg-eye:hover { background: var(--surface-2); color: var(--text); }
.lg-btn {
    width: 100%; height: 50px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: 12px;
    background: var(--p); color: var(--on-p);
    font: 700 var(--fs-lg) var(--font);
    transition: background var(--ease);
}
.lg-btn:hover { background: var(--p-hover); }
.lg-btn:disabled { opacity: .8; cursor: progress; }
.lg-alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 12px;
    background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--text); font-size: var(--fs-base);
}
.lg-alert > i { margin-top: 2px; color: var(--danger); }
.lg-divider { display: flex; align-items: center; gap: 12px; font-size: var(--fs-md); color: var(--text-muted); }
.lg-divider::before, .lg-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.lg-support {
    width: 100%; height: 48px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text);
    font-size: var(--fs-base); font-weight: 600;
}
.lg-support:hover { background: var(--surface-2); color: var(--text); }
.lg-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: var(--fs-md); color: var(--text-muted); }

/* ══════════════════════════ 25. MENÚ HORIZONTAL (desktop, data-menu-layout) ══════════════════════════
   La misma estructura del sidebar se reutiliza como barra horizontal
   debajo del topbar. No se duplica el menú.
   Core 3.7.1: módulo activo con barra de marca, submenú animado (dos columnas
   si es largo), botón «Más» para los módulos que no entran, barra compacta al
   bajar y navegación con teclado (shell.js, «Menú horizontal»). */
.hm-mas { display: none; }
@media (min-width: 901px) {
    html[data-menu-layout="horizontal"] { --hm-alto: 60px; --hm-link: 40px; }
    html[data-menu-layout="horizontal"][data-hm-compacto] { --hm-alto: 50px; --hm-link: 36px; }

    html[data-menu-layout="horizontal"] #sidebar {
        top: calc(var(--shell-gap) * 2 + var(--topbar-h));
        left: var(--shell-gap); right: var(--shell-gap); bottom: auto;
        width: auto; height: var(--hm-alto);
        flex-direction: row; align-items: center;
        padding: 0 8px; overflow: visible;
        border-radius: var(--r-lg);
        /* Mismo vidrio que el topbar: las dos barras se leen como una sola pieza.
           En horizontal no hay descendientes fixed, así que el blur no estorba. */
        background: color-mix(in srgb, var(--sidebar-bg) 92%, transparent);
        backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        transition: height var(--ease), box-shadow var(--ease);
    }
    html[data-menu-layout="horizontal"] #topbar { margin: var(--shell-gap); z-index: 310; transition: box-shadow var(--ease); }
    /* Al bajar: la barra se compacta y ambas se elevan sobre el contenido. */
    html[data-menu-layout="horizontal"][data-hm-compacto] #sidebar,
    html[data-menu-layout="horizontal"][data-hm-compacto] #topbar { box-shadow: var(--shadow-sm); }

    /* Logo */
    html[data-menu-layout="horizontal"] #sidebar .logo {
        height: 100%; padding: 0 18px 0 10px; margin-right: 8px;
        border-right: 1px solid var(--border);
    }
    html[data-menu-layout="horizontal"] #sidebar .logo-text { display: flex !important; max-width: 240px; }
    html[data-menu-layout="horizontal"] #sidebar .logo-text img { height: 44px; max-height: none; transition: height var(--ease); }
    html[data-menu-layout="horizontal"][data-hm-compacto] #sidebar .logo-text img { height: 36px; }
    html[data-menu-layout="horizontal"][data-theme="dark"] #sidebar .logo-text img { height: 50px; padding: 5px 9px; }
    html[data-menu-layout="horizontal"][data-theme="dark"][data-hm-compacto] #sidebar .logo-text img { height: 42px; padding: 4px 8px; }
    html[data-menu-layout="horizontal"] #sidebar .logo-mark { display: none !important; }

    /* Barra de módulos */
    html[data-menu-layout="horizontal"] #sidebar .nav { flex: 1 1 auto; min-width: 0; height: 100%; padding: 0 4px; overflow: visible; }
    html[data-menu-layout="horizontal"] #brandMenu { display: flex; align-items: center; gap: 4px; height: 100%; white-space: nowrap; }
    html[data-menu-layout="horizontal"] #brandMenu > li { flex: 0 0 auto; margin: 0; }
    html[data-menu-layout="horizontal"] #brandMenu > li.nav-section,
    html[data-menu-layout="horizontal"] #brandMenu > li[data-hm-oculto] { display: none; }
    html[data-menu-layout="horizontal"] #brandMenu > li > a,
    html[data-menu-layout="horizontal"] .hm-mas-btn {
        position: relative; overflow: visible;
        min-height: var(--hm-link); padding: 0 12px; gap: 8px;
        transition: background var(--ease), color var(--ease), min-height var(--ease);
    }
    html[data-menu-layout="horizontal"] #brandMenu > li > a.has-arrow::after { margin-left: 2px; }

    /* Módulo que contiene la página actual: fondo de marca suave y barra de
       marca pegada al borde inferior de la barra (equivale al bloque abierto
       del menú vertical). Inicio conserva su pastilla sólida. */
    html[data-menu-layout="horizontal"] #brandMenu > li.mm-active > a.has-arrow,
    html[data-menu-layout="horizontal"] #sidebar[data-hm-mas="activo"] .hm-mas-btn { background: var(--p-soft); color: var(--p-text); }
    html[data-menu-layout="horizontal"] #brandMenu > li.mm-active > a.has-arrow > i:first-child,
    html[data-menu-layout="horizontal"] #sidebar[data-hm-mas="activo"] .hm-mas-btn > i:first-child { color: var(--p-text); }
    html[data-menu-layout="horizontal"] #brandMenu > li.mm-active > a.has-arrow::before,
    html[data-menu-layout="horizontal"] #sidebar[data-hm-mas="activo"] .hm-mas-btn::before {
        content: ''; position: absolute; left: 12px; right: 12px;
        bottom: calc((var(--hm-link) - var(--hm-alto)) / 2 + 1px);
        height: 3px; border-radius: 3px 3px 0 0; background: var(--p);
    }

    /* Módulo abierto: sin el bloque del acordeón vertical; solo el disparador resaltado. */
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) { margin: 0; padding-bottom: 0; border-radius: var(--r-md); background: transparent; }
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > a.has-arrow,
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > a.has-arrow:hover,
    html[data-menu-layout="horizontal"] .hm-mas-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
    html[data-menu-layout="horizontal"] #brandMenu > li.mm-active:has(> ul.mm-show) > a.has-arrow,
    html[data-menu-layout="horizontal"] #brandMenu > li.mm-active:has(> ul.mm-show) > a.has-arrow:hover,
    html[data-menu-layout="horizontal"] #sidebar[data-hm-mas="activo"] .hm-mas-btn[aria-expanded="true"] { background: var(--p-soft); color: var(--p-text); }

    /* Submenú desplegable: solo por clic (.mm-show) */
    html[data-menu-layout="horizontal"] #brandMenu > li > ul,
    html[data-menu-layout="horizontal"] .hm-mas-panel {
        display: none !important;
        position: absolute; top: calc(100% + (var(--hm-alto) - var(--hm-link)) / 2 + 6px); left: 0;
        min-width: 240px; max-width: 320px; max-height: min(70vh, 560px);
        margin: 0; padding: 8px;
        overflow-y: auto; overflow-x: hidden;
        background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
        z-index: 12000; transition: none;
    }
    html[data-menu-layout="horizontal"] #brandMenu > li > ul.mm-show,
    html[data-menu-layout="horizontal"] .hm-mas[data-abierto] .hm-mas-panel {
        display: block !important;
        transform-origin: top left;
        animation: hmBajar .16s cubic-bezier(.2,.8,.2,1) both;
    }
    /* Anula el sangrado y el borde lateral del acordeón vertical. */
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > ul { margin: 0; border-left-color: var(--border); }
    /* Módulos a la derecha de la pantalla: el submenú se alinea a su borde derecho. */
    html[data-menu-layout="horizontal"] #brandMenu > li[data-hm-derecha] > ul { left: auto; right: 0; transform-origin: top right; }
    @keyframes hmBajar { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

    /* Submenú largo (más de 10 filas): dos columnas en lugar de una lista con scroll. */
    html[data-menu-layout="horizontal"] #brandMenu > li > ul:has(> li:nth-child(11)) { columns: 2; column-gap: 8px; min-width: 480px; max-width: 560px; }
    html[data-menu-layout="horizontal"] #brandMenu > li > ul:has(> li:nth-child(11)) > li { break-inside: avoid; }
    html[data-menu-layout="horizontal"] #brandMenu > li > ul > li.nav-section { break-after: avoid; }
    html[data-menu-layout="horizontal"] #brandMenu > li > ul > li.nav-section:not(:first-child) { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }

    /* Páginas del submenú: la actual con fondo de marca y la barrita lateral del menú vertical. */
    html[data-menu-layout="horizontal"] #brandMenu > li > ul > li > a { position: relative; white-space: normal; padding: 8px 12px; }
    html[data-menu-layout="horizontal"] #brandMenu > li > ul > li > a:hover { background: var(--surface-2); color: var(--text); }
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > ul > li.mm-active > a,
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > ul > li > a.mm-active,
    html[data-menu-layout="horizontal"] .hm-mas-lista > li.mm-active > a,
    html[data-menu-layout="horizontal"] .hm-mas-lista > li > a.mm-active { background: var(--p-soft); color: var(--p-text); font-weight: 600; box-shadow: none; }
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > ul > li.mm-active > a::before,
    html[data-menu-layout="horizontal"] #brandMenu > li:has(> ul.mm-show) > ul > li > a.mm-active::before,
    html[data-menu-layout="horizontal"] .hm-mas-lista > li.mm-active > a::before,
    html[data-menu-layout="horizontal"] .hm-mas-lista > li > a.mm-active::before {
        content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
        width: 3px; border-radius: 0 3px 3px 0; background: var(--p);
    }

    /* «Más»: los módulos que no entran en la barra, agrupados por módulo. */
    html[data-menu-layout="horizontal"] #sidebar[data-hm-mas] .hm-mas {
        position: relative; display: flex; align-items: center; flex-shrink: 0;
        height: 100%; padding-left: 8px; margin-left: 4px;
        border-left: 1px solid var(--border);
    }
    html[data-menu-layout="horizontal"] .hm-mas-btn {
        display: inline-flex; align-items: center;
        border: 0; border-radius: var(--r-md); background: transparent; cursor: pointer;
        font: inherit; font-size: var(--fs-base); font-weight: 600; color: var(--text-2); white-space: nowrap;
    }
    html[data-menu-layout="horizontal"] .hm-mas-btn > i:first-child { width: 20px; text-align: center; font-size: var(--fs-lg); color: var(--icon); transition: color var(--ease); }
    html[data-menu-layout="horizontal"] .hm-mas-btn:hover { background: var(--surface-2); color: var(--text); }
    html[data-menu-layout="horizontal"] .hm-mas-panel {
        left: auto; right: 0; transform-origin: top right;
        width: min(560px, calc(100vw - 48px)); max-width: none; padding: 10px;
        columns: 2 220px; column-gap: 12px;
    }
    html[data-menu-layout="horizontal"] .hm-mas-grupo { break-inside: avoid; padding: 2px 0 8px; }
    html[data-menu-layout="horizontal"] .hm-mas-tit {
        display: flex; align-items: center; gap: 8px; padding: 6px 10px 4px;
        font-size: var(--fs-xs); font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted);
    }
    html[data-menu-layout="horizontal"] .hm-mas-tit > i { width: 18px; text-align: center; font-size: var(--fs-md); color: var(--icon); }
    html[data-menu-layout="horizontal"] .hm-mas-grupo.is-activo .hm-mas-tit,
    html[data-menu-layout="horizontal"] .hm-mas-grupo.is-activo .hm-mas-tit > i { color: var(--p-text); }
    html[data-menu-layout="horizontal"] .hm-mas-lista { list-style: none; margin: 0; padding: 0; }
    html[data-menu-layout="horizontal"] .hm-mas-lista > li.nav-section { display: none; }
    html[data-menu-layout="horizontal"] .hm-mas-lista > li > a {
        position: relative; display: flex; align-items: center;
        min-height: 34px; padding: 6px 10px 6px 36px; border-radius: var(--r-sm);
        font-size: var(--fs-base); font-weight: 500; color: var(--text-2);
        transition: background var(--ease), color var(--ease);
    }
    html[data-menu-layout="horizontal"] .hm-mas-lista > li > a:hover { background: var(--surface-2); color: var(--text); }

    /* En horizontal todo el ancho es para los módulos. El tema se cambia desde
       el menú de usuario ("Cambiar tema") y el soporte queda en el pie de
       página y en Inicio. */
    html[data-menu-layout="horizontal"] .sidebar-footer { display: none; }
    html[data-menu-layout="horizontal"] #sidebar .theme-seg .fb-label { display: none; }
    html[data-menu-layout="horizontal"] #main,
    html[data-menu-layout="horizontal"] #wrapper.sb-collapsed #main { margin-left: 0; }
    html[data-menu-layout="horizontal"] #content { padding-top: 72px; }
    html[data-menu-layout="horizontal"] .content-body,
    html[data-menu-layout="horizontal"] #footer { padding-left: var(--shell-gap); }
    html[data-menu-layout="horizontal"] #wrapper.hm-collapsed #sidebar { display: none; }
    html[data-menu-layout="horizontal"] #wrapper.hm-collapsed #content { padding-top: 0; }
}
@media (min-width: 901px) and (prefers-reduced-motion: reduce) {
    html[data-menu-layout="horizontal"] #brandMenu > li > ul.mm-show,
    html[data-menu-layout="horizontal"] .hm-mas[data-abierto] .hm-mas-panel { animation: none; }
}

/* ══════════════════════════ 26. MÓVIL Y TABLET VERTICAL (≤900px; Core 3.18, antes 1024) ══════════════════════════ */
#bottomNav { display: none; }
.bn-pop { display: none; }
.sheet-handle { display: none; }
.tb-logo { display: none; }
/* Core 3.18: «‹ Módulos» de la hoja de Módulos; solo existe en celular. */
#brandMenu .nav-back { display: none; }

@media (max-width: 900px) {
    /* ── Hoja inferior «Módulos» (#sidebar). Se oculta con display:none (no transform). ── */
    #sidebar {
        display: none;
        top: auto; left: 0; right: 0; bottom: calc(78px + env(safe-area-inset-bottom));
        width: 100%; max-height: 72vh;
        padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
        border-radius: 18px 18px 0 0;
        z-index: 10050; overflow-y: auto;
        transition: transform .2s ease;
    }
    #sidebar.mobile-open { display: flex; box-shadow: var(--shadow-lg); animation: sheetUp .26s cubic-bezier(.4,0,.2,1) both; }
    @keyframes sheetUp { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
    #overlay { display: block; }
    #overlay.active { z-index: 10040; }
    /* La rayita: zona táctil amplia para deslizar hacia abajo (shell.js, bindSheetSwipe). */
    .sheet-handle { display: block; flex: 0 0 auto; height: 22px; position: relative; cursor: grab; touch-action: none; }
    .sheet-handle::before { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--border); }
    #sidebar > .logo { display: none; }
    #sidebar .nav { padding: 0 12px 10px; }

    /* Cuadrícula de módulos (ningún módulo abierto). Inicio ya está en la barra inferior. */
    #brandMenu:not(.has-open) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    #brandMenu > li.nav-inicio { display: none; }
    #brandMenu:not(.has-open) > li { margin: 0; }
    #brandMenu:not(.has-open) > li.nav-section { grid-column: 1 / -1; margin: 10px 0 2px; padding: 0 4px; }
    #brandMenu:not(.has-open) > li:nth-child(2).nav-section,
    #brandMenu:not(.has-open) > li.nav-inicio + li.nav-section { margin-top: 2px; }
    #brandMenu:not(.has-open) > li > a {
        flex-direction: column; justify-content: flex-start; gap: 6px;
        min-height: 88px; height: 100%; padding: 10px 4px 8px;
        border-radius: var(--r-lg); white-space: normal; text-align: center;
        font-size: var(--fs-sm); line-height: 1.2;
    }
    /* #sidebar delante: le gana a los íconos con tono del menú vertical. */
    #sidebar #brandMenu:not(.has-open) > li > a > i:first-child,
    #sidebar #brandMenu:not(.has-open) > li[data-tono] > a > i:first-child {
        width: 44px; min-width: 44px; height: 44px; margin: 0;
        display: inline-grid; place-items: center; border-radius: 13px;
        background: var(--mt-bg, var(--surface-2)); color: var(--mt-c, var(--p-text)); font-size: var(--fs-2xl);
    }
    #brandMenu:not(.has-open) > li.mm-active > a > i:first-child { box-shadow: 0 0 0 2px var(--p); }
    #brandMenu:not(.has-open) > li > a > span.nav-text {
        flex: 0 1 auto; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
        overflow: hidden; overflow-wrap: anywhere;
    }
    #brandMenu:not(.has-open) > li > a.has-arrow::after { display: none; }
    #brandMenu:not(.has-open) > li > ul { display: none; }

    /* Un módulo abierto: solo sus páginas, con «‹ Módulos» arriba. */
    #brandMenu.has-open > li:not(.is-open) { display: none; }
    #sidebar #brandMenu.has-open > li.is-open { margin: 0; padding: 0; background: transparent; border-radius: 0; }
    #brandMenu.has-open > li.is-open > a.has-arrow { display: none; }
    #brandMenu.has-open > li.is-open > ul { margin: 0; padding: 0; border-left: 0; }
    #brandMenu.has-open > li.is-open > ul > li > a { min-height: 46px; padding: 10px 12px; font-size: var(--fs-md); }
    #brandMenu .nav-back {
        display: flex; align-items: center; gap: 10px;
        position: sticky; top: 0; z-index: 1; margin: 0 0 6px; padding: 4px 0 8px;
        background: var(--sidebar-bg); border-bottom: 1px solid var(--border-lite);
    }
    #brandMenu .nav-back button {
        display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
        min-height: 36px; padding: 0 12px 0 8px; border: 0; border-radius: 999px;
        background: var(--surface-2); color: var(--p-text); font-size: var(--fs-sm); font-weight: 700;
    }
    #brandMenu .nav-back b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); color: var(--text); }

    /* Pie compacto: soporte en una línea y el tema al lado. */
    .sidebar-footer { flex-direction: row; align-items: center; padding-top: 8px; padding-bottom: 10px; }
    .support-card { flex: 1; min-width: 0; padding: 6px 8px; }
    .support-card .sc-sub { display: none; }
    .theme-seg { flex: 0 0 auto; }
    .theme-seg .fb-label { display: none; }

    /* ── Barra superior: logo en lugar de la hamburguesa (Módulos ya está abajo) y sin avatar (Perfil está abajo). ── */
    #main, #wrapper.sb-collapsed #main { margin-left: 0 !important; }
    #main { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
    #topbar { margin: var(--shell-gap); padding: 0 8px; }
    .tb-toggle, .tb-search, .user-wrap { display: none; }
    .tb-logo { display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; }
    .tb-logo img { width: 28px; height: 28px; object-fit: contain; }
    [data-theme="dark"] .tb-logo { background: rgba(255,255,255,.92); }
    .tb-crumb { flex: 1; }
    .content-body { padding: 8px var(--shell-gap) calc(110px + env(safe-area-inset-bottom)); }
    #footer { padding: 4px var(--shell-gap) calc(96px + env(safe-area-inset-bottom)); }
    .dd-solo-escritorio { display: none; }

    /* ── Barra inferior flotante (backdrop-filter: sus paneles viven fuera, a nivel raíz) ── */
    #bottomNav {
        display: flex; align-items: center; justify-content: space-around;
        position: fixed; z-index: 9998;
        left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
        bottom: calc(14px + env(safe-area-inset-bottom));
        height: 64px; padding: 0 6px; border-radius: 20px;
        background: color-mix(in srgb, var(--sidebar-bg) 92%, transparent);
        backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border: 1px solid var(--border); box-shadow: var(--shadow-md);
    }
    .bn-slot { position: relative; flex: 1; display: flex; justify-content: center; min-width: 0; }
    .bn-slot-fab { flex: 0 0 auto; }
    .bn-btn {
        display: flex; flex-direction: column; align-items: center; gap: 3px;
        min-width: 56px; padding: 6px 8px; border: 0; border-radius: 12px; background: none;
        font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted);
    }
    .bn-btn i { font-size: var(--fs-2xl); }
    .bn-btn.active-tab { color: var(--p-text); }
    .bn-btn.open { background: var(--p-soft); color: var(--p-text); }
    .bn-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; border: 1.5px solid transparent; }
    .bn-btn.open .bn-avatar, .bn-btn.active-tab .bn-avatar { border-color: var(--p); }
    /* Buscar: el botón central y elevado (antes el logo, que repetía Inicio). */
    .bn-fab {
        width: 52px; height: 52px; margin-top: -24px; flex-shrink: 0;
        display: flex; align-items: center; justify-content: center;
        border: 0; border-radius: 16px; background: var(--p); color: var(--on-p);
        font-size: var(--fs-2xl); box-shadow: var(--shadow-md);
    }
    .bn-fab:active { transform: scale(.96); }

    .bn-pop {
        display: none; position: fixed; z-index: 9999;
        min-width: 200px; max-width: min(280px, calc(100vw - 24px));
        padding: 6px;
        background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
    }
    .bn-pop.open { display: block; animation: fade-up 160ms ease both; }
    .bn-pop-item {
        display: flex; align-items: center; gap: 9px; width: 100%;
        padding: 10px 11px; border: 0; border-radius: 10px; background: none;
        font-size: var(--fs-base); font-weight: 600; color: var(--text-2); text-align: left;
    }
    .bn-pop-item:hover { background: var(--surface-2); color: var(--text); }
    .bn-pop-item.danger { color: var(--danger); }
    .bn-pop-empty { display: flex; gap: 10px; align-items: flex-start; padding: 10px 11px; font-size: var(--fs-sm); color: var(--text-muted); }
    .bn-pop-empty i { margin-top: 2px; color: var(--warning); }


    .gxModal { align-items: flex-start; padding: 20px 12px calc(90px + env(safe-area-inset-bottom)); }
    .gxModal__dialog { max-height: calc(100vh - 110px); }

    .lg-brand { padding: 28px; }
    .lg-system { font-size: var(--fs-5xl); }
    .lg-panel { padding: 20px; }
}

@media (max-width: 992px) {
    .perm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
    .fl-workspace { grid-template-columns: minmax(0, 1fr); }
    .fl-result-card { position: static; }
    .fl-tab { flex: 1 1 130px; justify-content: center; }
}
@media (max-width: 900px) {
    .factiliza-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .table thead tr.column-filter-row th { min-width: 132px; }
    .table thead tr.column-filter-row th:first-child { min-width: 72px; }
    .pager { justify-content: center; text-align: center; }
}
@media (max-width: 760px) {
    .fl-hero { flex-wrap: wrap; align-items: flex-start; padding: 18px; }
    .fl-hero-copy h1 { font-size: var(--fs-4xl); }
    .fl-overview { grid-template-columns: 1fr; }
    .fl-tab { flex: 1 1 40%; }
    .fl-config-grid, .fl-billing-fields { grid-template-columns: 1fr; }
    .fl-workspace .card-body { padding: 16px; }
}
@media (max-width: 640px) {
    .access-denied-shell { margin: 20px 0; padding: 20px; flex-direction: column; }
    .bt-toast-stack--page { left: 12px; right: 12px; width: auto; }
    .lg-brand { min-height: 200px; }
    .lg-copy { padding-top: 28px; }
    .lg-lead { display: none; }
}
@media (max-width: 576px) {
    .filter-stats { grid-template-columns: 1fr; max-width: 100%; }
    .page-actions { width: 100%; }
    .page-actions .page-action-btn { flex: 1 1 0; }
    .dni-field-row { grid-template-columns: 1fr; }
    .btn-dni-check { width: 100%; }
    .dash-kpi-val { font-size: var(--fs-5xl); }
    .page-title { font-size: var(--fs-4xl); }
}
@media (max-width: 480px) {
    .fl-data-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ══════════════════════════ 27. MOVIMIENTO REDUCIDO ══════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .qa-card { opacity: 1; }
    .bt-toast__bar { display: none; }
    /* Core 3.16: sin elevación de botones ni tarjetas. */
    .btn:not(:disabled):not(.disabled):hover, .btn:not(:disabled):not(.disabled):active, a.dash-kpi:hover { transform: none; }
}

/* Correcciones compartidas 2026-10-25. Solo celdas que contienen acciones;
   no cambia columnas, permisos ni alineación de importes. */
table :is(td,th):has(.gvCmdBtn),
[role="grid"] [role="gridcell"]:has(.gvCmdBtn) { text-align:left !important; }
table :is(td,th):has(.gvCmdBtn) > :is(div,span):has(.gvCmdBtn),
[role="grid"] [role="gridcell"]:has(.gvCmdBtn) > :is(div,span):has(.gvCmdBtn) {
    justify-content:flex-start !important; justify-items:start;
    text-align:left !important; margin-left:0 !important; margin-right:auto;
}
.table .gvCmdBtn:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
/* El formulario puede ser un hijo flex del contenido del diálogo. */
.gxModal__dialog, .gxModal__content { min-width:0; min-height:0; }
.gxModal__content > form {
    display:flex; flex-direction:column; flex:1 1 auto;
    min-width:0; min-height:0; overflow:hidden;
}
.gxModal__body { overscroll-behavior:contain; container-type:inline-size; }
.gxModal__body :is(input,select,textarea,.ssel) { min-width:0; max-width:100%; box-sizing:border-box; }
.gxModal__footer { flex-wrap:wrap; }
@supports (height:100dvh) {
    .gxModal__dialog { max-height:calc(100dvh - 32px); }
    @media(max-width:900px) {
        .gxModal__dialog { max-height:calc(100dvh - 78px - 32px); }
    }
}
/* Superficie y espacio propio para texto e iconos del selector existente. */
.ssel, .ssel-trigger, .ssel-trigger-text, .ssel-search input { min-width:0; }
.ssel-trigger { width:100%; box-sizing:border-box; }
.ssel-search > i { pointer-events:none; flex-shrink:0; }
.ssel-panel, .ssel-item { background:var(--surface); }
.ssel-item > span:last-child { min-width:0; overflow-wrap:anywhere; }

/* Core: tabla reusable con filtros, ordenación, paginación y exportación. */
.core-data-grid .table-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin:16px 0; }
.core-data-grid .search-box { display:flex; align-items:center; gap:10px; padding:0 12px; min-width:180px; flex:1; border:1px solid var(--border); border-radius:var(--r-md); background:var(--surface); }
.core-data-grid .search-box > i { color:var(--text-muted); pointer-events:none; }
.core-data-grid .search-box input { min-width:0; width:100%; padding:10px 0; border:0; background:transparent; color:var(--text); font:inherit; outline:none; }
.core-data-grid .search-box:focus-within { border-color:var(--p); box-shadow:0 0 0 2px var(--p-soft); }
.core-data-grid .grid-sort { display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; padding:0; border:0; color:inherit; background:transparent; font:inherit; text-align:inherit; cursor:pointer; }
.core-data-grid .grid-sort:focus-visible { outline:2px solid var(--p); outline-offset:4px; }
.core-data-grid .table { min-width:680px; }
@media(max-width:700px) { .core-data-grid .table-toolbar .search-box { flex-basis:100%; } }
