/* ==========================================================================
   CUSTOM.CSS - MOTOR ESTRUCTURAL LIMPIO (V2.0)
   100% Adaptable a Variables CSS (Dark / Lite)
   0% Redundancia.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

/* ==========================================================================
   1. RESET Y ESTRUCTURA BASE
   ========================================================================== */
body {
    -webkit-font-smoothing: antialiased;
    background-color: var(--md-bg) !important;
    color: var(--md-text-main) !important;
    font-family: var(--font-body) !important;
    overflow-x: hidden !important;
    margin: 0; padding: 0;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--md-bg); }
::-webkit-scrollbar-thumb { background: var(--md-text-sub); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--md-primary); }

/* Protección Autocomplete Chrome */
input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--md-surface-variant) inset !important;
    -webkit-text-fill-color: var(--md-text-main) !important;
    caret-color: var(--md-text-main) !important;
}

@media screen and (min-width: 769px) {
    html, body { height: 100vh !important; width: 100vw !important; overflow: hidden !important; }
    body #main { display: flex !important; flex-wrap: nowrap !important; height: 100vh !important; }

    /* El contenedor principal controla el scroll vertical, prohíbe el horizontal */
    body #main div.module-wrapper {
        flex: 1 1 0px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
}

/* ==========================================================================
   2. NOTIFICACIONES (TOASTS) - SIEMPRE ARRIBA (Z-INDEX SUPREMO)
   ========================================================================== */
.ox-messages-wrapper, .ox-errors-wrapper, .ox-warnings-wrapper, .ox-infos-wrapper {
    position: fixed !important; top: 24px !important; left: 50% !important; transform: translateX(-50%) !important;
    z-index: 100000 !important; /* SUPERA A LA BARRA STICKY */
    display: flex !important; flex-direction: column !important; gap: 12px !important;
    pointer-events: none !important; width: 90vw !important; max-width: 450px !important;
}

.ox-messages div, .ox-errors div, .ox-warnings div, .ox-infos div {
    pointer-events: auto !important; display: flex !important; align-items: center !important;
    /* FIX: Padding derecho en 50px para evitar que el texto monte la X */
    padding: 16px 50px 16px 20px !important;
    border-radius: 12px !important;
    background-color: var(--md-glass-bg) !important;
    backdrop-filter: blur(15px) !important; -webkit-backdrop-filter: blur(15px) !important;

    /* NUEVO FIX: Borde sutil universal (Gris translúcido) perfecto para Dark y Light */
    border: 1px solid rgba(130, 130, 130, 0.3) !important;
    /* NUEVO FIX: Sombra reforzada para que "flote" sobre la tabla oscura */
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4) !important;

    color: var(--md-text-main) !important; font-weight: 600 !important; font-size: 14px !important;
    animation: toast-slide-down 0.4s ease forwards !important;
    position: relative !important; /* FIX: Necesario para anclar la X */
}

.ox-errors div { border-left: 6px solid #E74C3C !important; }
.ox-warnings div { border-left: 6px solid #ff9800 !important; }
.ox-messages div { border-left: 6px solid #2ECC71 !important; }

/* FIX: BLINDAJE ABSOLUTO DEL BOTÓN CERRAR "X" */
.ox-messages-wrapper i.mdi-close, .ox-errors-wrapper i.mdi-close, .ox-warnings-wrapper i.mdi-close, .ox-infos-wrapper i.mdi-close,
.ox-messages div i.mdi-close, .ox-errors div i.mdi-close, .ox-warnings div i.mdi-close, .ox-infos div i.mdi-close {
    position: absolute !important;
    top: 50% !important;
    right: 12px !important;
    transform: translateY(-50%) !important;
    font-size: 20px !important;
    color: var(--md-text-sub) !important; /* SIEMPRE GRIS VISIBLE POR DEFECTO */
    opacity: 0.8 !important;
    cursor: pointer !important;
    padding: 6px !important;
    border-radius: 50% !important;
    background-color: transparent !important;
    transition: all 0.2s ease-in-out !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100001 !important;
}

/* Hover sobre la "X": Se vuelve Roja y hace un pequeño zoom */
.ox-messages-wrapper i.mdi-close:hover, .ox-errors-wrapper i.mdi-close:hover, .ox-warnings-wrapper i.mdi-close:hover, .ox-infos-wrapper i.mdi-close:hover,
.ox-messages div i.mdi-close:hover, .ox-errors div i.mdi-close:hover, .ox-warnings div i.mdi-close:hover, .ox-infos div i.mdi-close:hover {
    color: #E74C3C !important; /* Rojo Alerta Intenso */
    opacity: 1 !important;
    background-color: rgba(231, 76, 60, 0.1) !important;
    transform: translateY(-50%) scale(1.15) !important;
}

/* FORZAR visibilidad de la X gris aunque OpenXava aplique hover a la tarjeta completa */
.ox-messages div:hover i.mdi-close, .ox-errors div:hover i.mdi-close, .ox-warnings div:hover i.mdi-close, .ox-infos div:hover i.mdi-close {
    color: var(--md-text-sub) !important;
}

/* Asegurar que el rojo gane si estás sobre la tarjeta Y sobre la X */
.ox-messages div:hover i.mdi-close:hover, .ox-errors div:hover i.mdi-close:hover, .ox-warnings div:hover i.mdi-close:hover, .ox-infos div:hover i.mdi-close:hover {
    color: #E74C3C !important;
}

@keyframes toast-slide-down { 0% { transform: translateY(-40px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
/* ==========================================================================
   3. BARRA SUPERIOR (CRISTAL Y STICKY)
   ========================================================================== */
.ox-button-bar-container {
    position: sticky !important;
    top: 0 !important;
    z-index: 9999 !important; /* ALTO, PERO DEBAJO DE LOS TOASTS */
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   3.5. CUADROS DE DIÁLOGO (POPUPS) - POR ENCIMA DE TODO
   ========================================================================== */
/* El velo oscuro que bloquea la pantalla debe superar a la barra superior */
/* El velo oscuro que bloquea la pantalla debe superar a la barra superior */
.ui-widget-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;  /* Forzamos que ocupe todo el ancho dinámico */
    height: 100vh !important; /* Forzamos que ocupe todo el alto dinámico */
    z-index: 100000 !important; /* Supera el 9999 de la barra */

    /* EFECTO BLUR PRO BLINDADO */
    background: var(--md-overlay-bg, rgba(0, 0, 0, 0.3)) !important; /* Color translúcido variable */
    background-image: none !important;

    /* El truco Pro: Filtro de distorsión avanzado */
    backdrop-filter: blur(12px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(160%) !important;

    animation: fadeInOverlay 0.3s ease-out forwards !important;
}

/* Animación sutil para que el desenfoque aparezca suavemente y no de golpe */
@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* La ventana modal en sí misma */
.ui-dialog {
    z-index: 100001 !important; /* Supera al velo oscuro */
    background-color: var(--md-surface) !important;
    border: 1px solid var(--md-border-strong) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
    border-radius: 12px !important;
    background-color: var(--md-glass-bg) !important;
    backdrop-filter: blur(7px) !important;
    -webkit-backdrop-filter: blur(7px) !important;
    border: 1px solid rgba(130, 130, 130, 0.3) !important;
}

/* La barra de título del popup */
.ui-dialog .ui-dialog-titlebar {
    background-color: var(--md-surface-variant) !important;
    border-bottom: 1px solid var(--md-border-soft) !important;
    color: var(--md-text-main) !important;
    border-radius: 16px 16px 0 0 !important;
    padding: 15px 20px !important;
}

.ox-button-bar {
    background-image: none !important;
    backdrop-filter: blur(15px) !important; -webkit-backdrop-filter: blur(15px) !important;
    border-bottom: 1px solid var(--md-border-soft) !important;
    padding: 8px 24px !important; display: flex !important; justify-content: space-between !important; align-items: center !important;
}

/* ==========================================================================
   3.6. RESTRICCIÓN ADAPTATIVA DE DIÁLOGOS MULTINIVEL (ANTI-EXPANSIÓN PRO)
   ========================================================================== */

/* Forza a todas las ventanas de diálogo a mantenerse simétricas y adaptativas */
body .ui-dialog.ui-widget {
    max-width: 92vw !important;      /* Nunca permitirá que el JavaScript lo expanda fuera del viewport */
    width: 900px !important;         /* Ancho ideal estándar de tu cuarta captura */
    left: 50% !important;            /* Resetea los cálculos negativos de left */
    transform: translateX(-50%) !important; /* Centrado horizontal matemático exacto */
    box-sizing: border-box !important;
}

/* Tratamiento especial para el segundo diálogo o diálogos muy profundos (Z-INDEX superior) */
body .ui-dialog.ui-widget[style*="z-index: 100002"],
body .ui-dialog.ui-widget[style*="z-index: 100003"],
body .ui-dialog.ui-widget[style*="z-index: 100004"] {
    width: 860px !important;         /* Un milímetro más angosto para dar jerarquía de capas */
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6) !important; /* Sombra más pesada por estar más cerca al ojo */
}

/* Asegura que las tablas internas del buscador no desborden el contenedor del modal */
body .ui-dialog .ui-dialog-content .ox-overflow-auto,
body .ui-dialog .ui-dialog-content .ox_comercial_Pedidos__list_scroll {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: auto !important;     /* Si la tabla es muy ancha, añade scroll interno en vez de romper la ventana */
    box-sizing: border-box !important;
}

/* Ajuste fino para los formularios internos del diálogo */
body .ui-dialog .ui-dialog-content .xava_form {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}





/* ====================================================================
   NUCLEO DEFINITIVO: BOTONES MATERIAL DESIGN 3 (GRABAR, NUEVO, ETC.)
   Blindaje Total y Purismo M3
   ==================================================================== */

/* 1. EL BLINDAJE INQUEBRANTABLE (ESTADO NORMAL) */
/* Targetting más específico para ganar a OpenXava. VITAL */
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"],
body:not(.login-mode-active) div.ox-module form.xava_form .ox-button {
    background-color: var(--md-primary) !important; /* Candado al color principal (Naranja) */
    background-image: none !important;
    color: #000000 !important; /* Texto oscuro sobre naranja brillante */
    border: none !important;
    border-radius: 20px !important; /* Píldora perfecta MD3 */
    height: 40px !important;
    padding: 0 24px !important;
    font-family: var(--font-body) !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    box-sizing: border-box !important;
    box-shadow: none !important; /* Plano en normal M3 */
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    /* Transición suave característica de M3 */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    -webkit-appearance: none; appearance: none;
}

/* 2. EL ASESINO DE PSEUDOELEMENTOS (Nuclear Option) */
/* ¡ESTO ES VITAL! Mata cualquier overlay negro de OpenXava (::before, ::after) en normal, hover y focus. */
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]::before,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]::after,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-button::before,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-button::after,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]:hover::before,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]:hover::after {
    display: none !important;
    visibility: hidden !important;
    content: none !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 0 !important;
}

/* 3. EL VERDADERO EFECTO HOVER M3: Capa de Estado y Sombra de Elevación DP2 Nítida */
/* Aquí está la magia purista de M3. */
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]:hover,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-button:hover,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]:focus,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-button:focus {
    background-color: var(--md-primary) !important;
    background-image: none !important;
    color: #000000 !important;

    /* 3A. M3 BRILLANTE: Capa de estado (Overlay blanco al 12%) para brillo purista M3. Mucho mejor que brightness(). */
    background-image: linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)) !important;

    border: none !important;
    outline: none !important;

    /* 3B. M3 ELEVACIÓN (DP2): Sombra de elevación Material Design 3 precisa y nítida. Matamos el "halo neón". */
    /* M3 elevation spec for filled button: increased shadow. Multi-layered. */
    box-shadow: 0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12) !important;

    filter: none !important; /* Desactivamos brightness() para usar la capa de estado */
    transform: translateY(-2px) !important; /* Elevación física suave de 2px M3 */
    opacity: 1 !important;
}

/* 4. EL EFECTO ACTIVE M3 (AL PRESIONAR): Hundido y más oscuro */
body:not(.login-mode-active) div.ox-module form.xava_form .ox-bottom-buttons input[type="button"]:active,
body:not(.login-mode-active) div.ox-module form.xava_form .ox-button:active {
    background-color: var(--md-primary) !important;
    /* M3 ACTIVE: Capa de estado negra al 12% para oscurecer y simular presión. */
    background-image: linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.12)) !important;
    transform: translateY(0) !important;
    box-shadow: none !important; /* Plano al presionar M3 */
    border: none !important;
    color: #000000 !important;
}

.ox-bottom-buttons button[name="xava.DEFAULT_ACTION"] { display: none !important; }

/* ==========================================================================
   4. FORMULARIOS MATERIAL 3 (DISEÑO COMPACTO Y ETIQUETAS ATRAPADAS)
   ========================================================================== */
body:not(.login-mode-active) .ox-layout-detail,
body:not(.login-mode-active) .ox-layout-detail tr {
    display: block !important;
    width: 100% !important; /* Bloques fluidos para matar el efecto goma */
}


/* EN CUSTOM.CSS (Aplica solo a Escritorio) */
body:not(.login-mode-active):not(.mobile) .ox-label {
    display: inline-block !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}


/* LA JAULA: El contenedor del input (Atrapa las etiquetas flotantes) */
body:not(.login-mode-active) .ox-editor-wrapper {
    position: relative !important; /* CRÍTICO: Atrapa el absolute del label */
    display: inline-block !important; /* Fluyen uno al lado del otro */
    vertical-align: top !important;
    width: auto !important;
    min-height: 56px !important;
    margin-right: 2px !important; /* Separación horizontal perfecta */
    margin-bottom: 12px !important;
    padding: 0 !important;
}
body:not(.login-mode-active) .ox-editor-wrapper:last-child { margin-right: 0 !important; }
body:not(.login-mode-active) .ox-editor-wrapper br { display: none !important; }

/* LA ETIQUETA: Posición exacta dentro de su jaula */
body:not(.login-mode-active) .small-label {
    position: absolute !important;
    top: 8px !important;
    left: 12px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    color: var(--md-text-sub) !important;
    z-index: 10 !important; /* Ya no chocará con el header porque está atrapada */
    pointer-events: none !important;
    transition: color 0.3s !important;
}
/* EL INPUT TIPO TEXTO / NÚMERO (Sin flechas) */
body:not(.login-mode-active) .ox-editor-wrapper input.editor[type="text"],
body:not(.login-mode-active) .ox-editor-wrapper input.editor[type="number"] {
    background-color: var(--md-surface-variant) !important;
    color: var(--md-text-main) !important;
    border: none !important;
    border-bottom: 1px solid var(--md-outline, #8E918F) !important;
    border-radius: 6px 6px 0 0 !important;
    padding: 24px 12px 6px 12px !important; /* Padding normal */
    height: 56px !important;
    font-size: 1rem !important;
    width: auto !important;
    min-width: 130px !important;
    box-sizing: border-box !important;
    transition: all 0.2s !important;
    background-image: none !important; /* Aseguramos que no haya flechas */
}

/* SOLO LOS SELECTS (Combobox con flecha personalizada) */
body:not(.login-mode-active) .ox-editor-wrapper select.editor,
body:not(.login-mode-active) .ox-editor-wrapper select {
    background-color: var(--md-surface-variant) !important;
    color: var(--md-text-main) !important;
    border: none !important;
    border-bottom: 1px solid var(--md-outline, #8E918F) !important;
    border-radius: 6px 6px 0 0 !important;
    padding: 24px 40px 6px 12px !important; /* Padding derecho ancho para no pisar la flecha */
    height: 56px !important;
    font-size: 1rem !important;
    width: auto !important;
    min-width: 130px !important;
    box-sizing: border-box !important;
    transition: all 0.2s !important;

    /* Matar flecha fea del navegador y poner la nuestra */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23909090'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 20px !important;
}

/* Colorear las opciones desplegables del Select nativo */
body:not(.login-mode-active) .ox-editor-wrapper select option {
    background-color: var(--md-surface) !important;
    color: var(--md-text-main) !important;
    padding: 10px !important;
}

/* ==========================================================================
   EFECTO FOCO GLOBAL M3 (BLINDADO CONTRA OTROS CSS)
   ========================================================================== */

/* 1. El Label flotante se vuelve Naranja intenso y negrita al hacer foco */
body:not(.login-mode-active) .ox-editor-wrapper:has(input:focus, select:focus, textarea:focus, .editor:focus) .small-label {
    color: var(--md-primary) !important;
    font-weight: 700 !important;
}
/* 2. Línea inferior Naranja M3. Gana en especificidad listando tipos y clases */
body:not(.login-mode-active) .ox-editor-wrapper input.editor:focus,
body:not(.login-mode-active) .ox-editor-wrapper input[type="text"]:focus,
body:not(.login-mode-active) .ox-editor-wrapper input[type="number"]:focus,
body:not(.login-mode-active) .ox-editor-wrapper input[type="password"]:focus,
body:not(.login-mode-active) .ox-editor-wrapper select.editor:focus,
body:not(.login-mode-active) .ox-editor-wrapper select:focus,
body:not(.login-mode-active) .ox-editor-wrapper textarea.editor:focus,
body:not(.login-mode-active) .ox-editor-wrapper textarea:focus {
    border-bottom: 2px solid var(--md-primary) !important;
    background-color: var(--md-surface-variant) !important; /* Magia: Gris oscuro en Dark, Gris claro en Lite */
    color: var(--md-text-main) !important; /* Magia 2: Obliga a que el texto/puntos se adapten al tema */
    outline: none !important;
}
/* ==========================================================================
   5. CHECKBOXES (BLINDAJE DE TAMAÑO)
   ========================================================================== */
body:not(.login-mode-active) input[type="checkbox"].editor,
body:not(.login-mode-active) input[type="checkbox"] {
    width: 24px !important; height: 24px !important;
    min-width: 24px !important; max-width: 24px !important;
    min-height: 24px !important; max-height: 24px !important;
    accent-color: var(--md-primary) !important;
    cursor: pointer !important;
    border: none !important; background: transparent !important;
    display: inline-block !important; margin: 0 auto !important;
}
/* Espacio reservado para checkbox en cabeceras de formulario (no tablas) */
body:not(.login-mode-active) .ox-editor-wrapper:has(input[type="checkbox"]) { min-width: 140px !important; }
body:not(.login-mode-active) .ox-editor-wrapper input[type="checkbox"] { margin-top: 24px !important; margin-left: 22px !important; }
body:not(.login-mode-active) input[type="checkbox"]:disabled { opacity: 0.8 !important; filter: grayscale(0.2) !important; }

/* ==========================================================================
   6. TABLAS, FILTROS Y FILA DE TOTALES
   ========================================================================== */
.ox-list { border: 1px solid var(--md-border-soft) !important; border-radius: 12px; background-color: var(--md-surface) !important; }
.ox-list-pair td, .ox-list-odd td { padding: 14px 12px !important; color: var(--md-text-sub) !important; border-bottom: 1px solid var(--md-border-soft) !important; }
.ox-list-pair:hover, .ox-list-odd:hover { background-color: var(--md-hover-bg) !important; }
.ox-list-pair:hover td, .ox-list-odd:hover td { color: var(--md-text-main) !important; }

/* Estilo Material Filled para Filtros y Campos de Detalles */
.ox-list-subheader input,
.ox-list-data-cell input.editor[type="text"],
.ox-list-data-cell input.editor[type="number"] {
    background-color: var(--md-surface-variant) !important;
    border: none !important; border-bottom: 1px solid var(--md-text-sub) !important;
    border-radius: 4px 4px 0 0 !important; color: var(--md-text-main) !important;
    height: 36px !important; padding: 6px 12px !important; width: 100% !important; box-sizing: border-box !important;
}
.ox-list-subheader input:focus, .ox-list-data-cell input.editor:focus {
    border-bottom: 2px solid var(--md-primary) !important; background-color: var(--md-hover-bg) !important; outline: none !important;
}

/* Limpieza de fila de Totales */
.ox-total-row td { background-color: var(--md-surface) !important; border-top: 1px solid var(--md-border-strong) !important; color: var(--md-text-main) !important; }
.ox-total-capable-cell a i { color: var(--md-text-sub) !important; font-size: 1.2rem !important; transition: color 0.2s ease !important; }
.ox-total-capable-cell a:hover i { color: var(--md-primary) !important; }

/* ==========================================================================
   6.5. LISTAS DESPLEGABLES (AUTOCOMPLETE / BÚSQUEDA DE REFERENCIAS)
   ========================================================================== */
ul.ui-autocomplete {
    background-color: var(--md-surface) !important;
    border: 1px solid var(--md-border-strong) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6) !important;
    padding: 5px 0 !important;
    z-index: 100005 !important; /* Siempre arriba de popups */
}

ul.ui-autocomplete li.ui-menu-item {
    background-color: transparent !important;
    border: none !important; /* Quitamos bordes feos entre items */
    margin: 0 !important;
    padding: 0 !important;
}

ul.ui-autocomplete li.ui-menu-item a {
    display: block !important;
    padding: 10px 15px !important;
    color: var(--md-text-main) !important;
    font-size: 0.95rem !important;
    text-decoration: none !important;
    border: none !important;
    transition: background-color 0.2s !important;
}

ul.ui-autocomplete li.ui-menu-item a:hover,
ul.ui-autocomplete li.ui-menu-item a.ui-state-focus {
    background-color: var(--md-hover-bg) !important;
    color: var(--md-primary) !important;
    border: none !important;
    margin: 0 !important;
}
/* ==========================================================================
   7. MENÚ LATERAL Y HEADER (ESTRUCTURA TABS M3 CENTRALIZADA)
   ========================================================================== */

/* CONTENEDOR PRINCIPAL: Alineación perfecta */
#module_header {
    padding: 0 0 0 10px !important;
    background-color: var(--md-surface) !important;
    background-image: var(--md-header-pattern) !important;
    background-repeat: repeat-x !important;
    background-position: left center !important;
    height: 54px !important;
    min-height: 54px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: 1px solid var(--module-header-boot-border) !important;
    box-sizing: border-box !important;
}

/* ÁREA DE TABS (IZQUIERDA) */
#module_header_left {
    display: flex !important;
    align-items: center !important;
    flex-grow: 1 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    height: 100% !important;
    scrollbar-width: none !important;
}
#module_header_left::-webkit-scrollbar { display: none !important; }

/* ================== TABS MATERIAL 3 ================== */
.module-header-tab {
    position: relative !important;
    display: inline-flex !important;
    height: 100% !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

.module-header-tab a,
.module-header-tab .selected {
    position: relative !important;
    color: var(--md-text-sub) !important;
    padding: 0 5px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    font-family: var(--font-body) !important;
    font-size: 0.875rem !important;
    border: none !important;
    border-bottom: none !important;
    text-shadow: none !important; /* FIX: Mata el texto duplicado/borroso */
    box-shadow: none !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
}

.module-header-tab a:hover {
    background-color: rgba(128, 128, 128, 0.08) !important;
    color: var(--md-text-main) !important;
}

/* ESTADO SELECCIONADO */
.module-header-tab .selected {
    color: var(--md-primary) !important;
    font-weight: 700 !important;
}

/* INDICADOR DE PÍLDORA M3 (Línea Inferior) */
.module-header-tab .selected::after {
    content: '' !important;
    position: absolute !important;
    bottom: 0px !important;
    left: 0 !important;
    width: 100% !important;
    height: 4px !important;
    background-color: var(--md-primary) !important;
    border-radius: 4px 4px 0 0 !important;
}

/* BOTÓN CERRAR (X) CIRCULAR PERFECTO BLINDADO */
.module-header-tab i.mdi-close,
.module-header-tab .close-icon {
    font-size: 14px !important;
    margin-left: 8px !important;
    width: 20px !important;
    height: 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    opacity: 0.5 !important;
    color: inherit !important;
    background-color: transparent !important;
    background-image: none !important; /* FIX: Mata la bola gris nativa */
    box-shadow: none !important;
    text-shadow: none !important; /* FIX: Mata la sombra en la X */
    padding: 0 !important;
    transition: all 0.2s ease !important;
}

/* FIX: Destruir pseudo-elementos fantasma de OpenXava */
.module-header-tab i.mdi-close::after,
.module-header-tab .close-icon::after {
    display: none !important;
    content: none !important;
}

.module-header-tab i.mdi-close:hover,
.module-header-tab .close-icon:hover {
    opacity: 1 !important;
    background-color: rgba(231, 76, 60, 0.15) !important;
    color: #E74C3C !important;
    transform: scale(1.1) !important;
}


/* ÁREA DERECHA (Iconos de sistema) */
#module_header_right {
    height: 54px !important;
    display: flex !important;
    align-items: center !important;
    margin-top: -3px !important;
}

/* TOGGLES LATERALES */
#modules_list_hide, #modules_list_show {
    position: fixed !important; top: 50% !important; transform: translateY(-50%) !important;
    z-index: 1000 !important; background-color: var(--md-surface) !important;
    color: var(--md-text-sub) !important; width: 18px !important; height: 40px !important;
    border-radius: 0 8px 8px 0 !important; border: 1px solid var(--md-border-strong) !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    cursor: pointer !important;
}
#modules_list_hide { left: 220px !important; } #modules_list_show { left: 0 !important; }

/* ==========================================================================
   8. RESPONSIVE Y LOGIN CLEANUP
   ========================================================================== */
@media screen and (max-width: 1120px) {
    #modules_list_hide { display: none !important; }
    #module_header_menu_button { display: inline-block !important; }
}

body.login-mode-active #module_header, body.login-mode-active .ox-button-bar-container { display: none !important; }
#ox_comercial_SignIn__GoSignUp___signUp, input[value='Crear cuenta'], input[title='Crear cuenta'] { display: none !important; visibility: hidden !important; position: absolute !important; z-index: -999 !important; }
body.login-mode-active .hideShowPassword-wrapper { width: 100% !important; display: block !important; position: static !important; margin: 0 !important; }
body.login-mode-active .hideShowPassword-toggle { display: none !important; }

/* ==========================================================================
   RECUPERAR EL COLOR DEL CURSOR (CARET) EN LOS CAMPOS CON FOCO
   ========================================================================== */
body:not(.login-mode-active) .ox-editor-wrapper input:focus,
body:not(.login-mode-active) .ox-editor-wrapper textarea:focus,
body:not(.login-mode-active) .ox-list-subheader input:focus,
body:not(.login-mode-active) .ox-list-data-cell input.editor:focus {
    /* El cursor intermitente toma el color principal (Naranja) */
    caret-color: var(--md-primary) !important;
}

#module_header_right {
    background: var(--module-header-background);
    float: none !important;
    padding: 0 10px !important;
    height: 60px !important;
    display: flex !important;
    align-items: center !important;
    background: -webkit-gradient(linear, left top, right top, from(white), to(black)) !important;
    background-image: linear-gradient(to left, var(--modules-list-background), var(--modules-list-background), var(--modules-list-background), var(--modules-list-background), var(--modules-list-background), transparent) !important;
}

/* ==========================================================================
   FIX: Visualización de Archivos SRI en modo Read-Only para Tema Oscuro
   ========================================================================== */

/* 1. Darle un fondo visible y bordes al contenedor del archivo bloqueado */
.ox-filepond-read-only .filepond--item {
    background-color: #2c2c2c !important; /* Fondo gris oscuro */
    border: 1px solid #555555 !important; /* Borde sutil para delimitar */
    border-radius: 6px !important;
}

/* 2. Forzar que el texto del nombre del archivo (XML/PDF) sea blanco y legible */
.ox-filepond-read-only .filepond--file-info-main,
.ox-filepond-read-only .filepond--file-info-sub {
    color: #ffffff !important;
    text-shadow: none !important;
}

/* 3. Cambiar el cursor a 'pointer' (la manito) para indicar que es descargable */
.ox-filepond-read-only .filepond--file {
    cursor: pointer !important;
}

/* 4. Asegurar que el componente no colapse su altura en el layout */
.ox-filepond-read-only {
    min-height: 50px !important;
    margin-bottom: 15px !important;
}
/* ==========================================================================
   FIX DEFINITIVO: FilePond Adaptable (Dark/Light Mode) y Anti-Colapso
   ========================================================================== */

/* 1. Estructura principal: Evita el colapso (tu fix) y aplica el borde exterior único */
.ox-upload-editor-box .filepond--root {
    min-width: 300px !important; /* Tu medida base "a la brava" para que no desaparezca */
    width: 100% !important;      /* Crecerá si hay más espacio disponible */
    min-height: 76px !important;
    border: 2px dashed rgba(128, 128, 128, 0.5) !important; /* Borde gris semi-transparente adaptable */
    border-radius: 8px !important;
    background-color: transparent !important;
    box-sizing: border-box !important;
}

/* 2. El asesino del BORDE DOBLE: Quitamos bordes internos y damos un fondo de cristal */
.ox-upload-editor-box .filepond--panel-root {
    background-color: rgba(128, 128, 128, 0.08) !important; /* Fondo "vidrio" que respeta el Dark y Light Mode */
    border: none !important; /* Elimina la triplicación de bordes */
}

/* 3. Texto dinámico: Se vuelve blanco en Dark Mode y oscuro en Light Mode */
.ox-upload-editor-box .filepond--drop-label {
    color: inherit !important; /* Hereda el color del texto del tema de OpenXava */
    opacity: 0.8 !important;
}

/* 4. Enlace de acción con el color corporativo de Quantica */
.ox-upload-editor-box .filepond--label-action {
    color: #ff9800 !important; /* Ámbar/Naranja */
    text-decoration: none !important;
    font-weight: bold !important;
}

.ox-upload-editor-box .filepond--label-action:hover {
    text-decoration: underline !important;
}

/* ==========================================================================
   FIX: Espaciado entre la Etiqueta (Label) y el recuadro de FilePond
   ========================================================================== */

.ox-editor-wrapper .ox-upload-editor-box {
    margin-top: 28px !important; /* Compensa la posición absoluta del label */
    display: block !important;
}

/* Opcional: Pequeño ajuste para que en modo solo lectura el padding interno no se vea tan apretado */
.ox-filepond-read-only .filepond--file-info {
    transform: translate3d(8px, 0px, 0px) !important;
}

/* ==========================================================================
   4.1. CAMPOS REQUERIDOS Y ERRORES (MATERIAL DESIGN 3)
   ========================================================================== */

/* 1. Línea inferior roja SOLO cuando el sistema arroja un error de validación */
body:not(.login-mode-active) .ox-editor-wrapper .ox-error-editor input.editor,
body:not(.login-mode-active) .ox-editor-wrapper .ox-error-editor select.editor,
body:not(.login-mode-active) .ox-editor-wrapper .ox-error-editor textarea.editor {
    border-bottom: 2px solid var(--error-campo-requerido) !important;
}

/* 2. Colorear el Label flotante de rojo SOLO cuando hay error */
body:not(.login-mode-active) .ox-editor-wrapper:has(.ox-error-editor) .small-label {
    color: var(--error-campo-requerido) !important;
    font-weight: 600 !important;
}

/* 3. Efecto al hacer foco en un campo con error (Mantiene el rojo y da fondo de alerta sutil) */
body:not(.login-mode-active) .ox-editor-wrapper .ox-error-editor input.editor:focus,
body:not(.login-mode-active) .ox-editor-wrapper .ox-error-editor select.editor:focus,
body:not(.login-mode-active) .ox-editor-wrapper .ox-error-editor textarea.editor:focus {
    border-bottom: 2px solid var(--error-campo-requerido) !important;
    background-color: rgba(255, 68, 68, 0.05) !important;
    outline: none !important;
}

.ox-list-info-detail {
    width: 70% !important;
}


/* ==========================================================================
   OPTIMIZACIÓN UX ESCRITORIO: BOTÓN DE RETORNO EN LOGO DE BIENVENIDA
   ========================================================================== */

/* 1. Blindaje e identificación de la caja del Logo en el Carrusel */
body:not(.login-mode-active) #ox_comercial_SignIn__core .hero-slide .inline-flex,
body #ox_comercial_SignIn__core form pre,
#ox_comercial_SignIn__core .hero-slide a,
div:has(> i.fa-box-open),
.hover-trigger { /* Selector elástico según el árbol DOM de tu login */
    display: inline-flex !important;
    align-items: center !important;
    gap: 12px !important;
    background: #ff9800 !important; /* Color primario corporativo */
    padding: 10px 14px !important;
    border-radius: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.2) !important;
    text-decoration: none !important;
}

/* 2. Aniquilación del icono de base de datos / caja e inyección de la flecha */
#ox_comercial_SignIn__core .hero-slide i.fa-box-open,
#ox_comercial_SignIn__core .hero-slide i.fa-database,
div:has(> i.fa-box-open) i,
.hover-trigger i {
    font-size: 18px !important;
    color: #ffffff !important;
    transition: transform 0.3s ease !important;
}

/* Forzamos el cambio del gráfico por la flecha de retorno de FontAwesome Free */
#ox_comercial_SignIn__core .hero-slide i.fa-box-open::before,
#ox_comercial_SignIn__core .hero-slide i.fa-database::before,
div:has(> i.fa-box-open) i::before,
.hover-trigger i::before {
    content: "\f060" !important; /* Código hexadecimal real para fa-arrow-left */
}

/* 3. Comportamiento interactivo HOVER para pantallas de Escritorio */
#ox_comercial_SignIn__core .hero-slide a:hover,
div:has(> i.fa-box-open):hover,
.hover-trigger:hover {
    padding: 10px 22px !important; /* Estira la píldora horizontalmente con suavidad */
    background: #e68a00 !important; /* primary_hover */
    box-shadow: 0 6px 20px rgba(230, 138, 0, 0.45) !important;
}

/* Micro-desplazamiento de la flecha indicando acción de escape */
#ox_comercial_SignIn__core .hero-slide a:hover i,
div:has(> i.fa-box-open):hover i,
.hover-trigger:hover i {
    transform: translateX(-4px) !important;
}

/* 4. Inyección dinámica del micro-texto "Volver al inicio" al pasar el mouse */
#ox_comercial_SignIn__core .hero-slide a::after,
div:has(> i.fa-box-open)::after,
.hover-trigger::after {
    content: "Volver al inicio" !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 0.9rem !important;
    font-family: 'Outfit', sans-serif !important;
    display: block !important;
    max-width: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    transition: max-width 0.4s ease, opacity 0.3s ease 0.1s !important;
}

#ox_comercial_SignIn__core .hero-slide a:hover::after,
div:has(> i.fa-box-open):hover::after,
.hover-trigger:hover::after {
    max-width: 120px !important;
    opacity: 1 !important;
}

/* Limpieza de selectores antiguos y actualización a Home */
#ox_comercial_SignIn__core .hero-slide i.mdi-home-variant-outline,
#ox_comercial_SignIn__core .hero-slide i.mdi-database, /* Mantenemos este por si queda rastro en caché */
div:has(> i.mdi-home-variant-outline) i,
.hover-trigger i {
    font-size: 20px !important;
    color: #ffffff !important;
    transition: transform 0.3s ease !important;
}

/* El comportamiento de ocultado sigue siendo el mismo */
.logo-floating:hover .icon-main {
    display: none !important;
}


/***********************************************************************************/
/***********************************************************************************/
/***********************************************************************************/
/* ==========================================================================
9. WELCOME PAGE & TIMELINE (MATERIAL DESIGN 3 ADAPTATIVE)
Blindaje total para Dark (materialEnt) y Lite (materialEntLite)
========================================================================== */
.welcome-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: var(--font-body) !important;
}

/* --- HEADER (Elevated Card con acento primario) --- */
.welcome-header {
    background: linear-gradient(135deg, rgba(255, 153, 0, 0.08) 0%, var(--md-surface) 100%);
    border: 1px solid rgba(255, 153, 0, 0.2);
    border-left: 6px solid var(--md-primary);
    border-radius: 20px;
    padding: 32px 40px;
    color: var(--md-text-main);
    margin-bottom: 40px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}
.welcome-header::after {
    content: '';
    position: absolute;
    right: -50px;
    bottom: -50px;
    width: 200px;
    height: 200px;
    background: rgba(255, 153, 0, 0.04);
    border-radius: 50%;
}
.welcome-header h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--md-text-main);
    letter-spacing: -0.5px;
}
.welcome-header p {
    font-size: 15px;
    color: var(--md-text-sub);
    margin: 0;
}

/* --- TIMELINE ESTRUCTURA --- */
.modern-timeline {
    position: relative;
    padding-left: 32px;
    margin-bottom: 40px;
}
.modern-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    /* Degradado que usa el primario y se funde con el outline del tema */
    background: linear-gradient(to bottom, var(--md-primary) 0%, var(--md-outline) 100%);
    border-radius: 4px;
}

/* --- ITEMS DEL TIMELINE --- */
.timeline-item {
    position: relative;
    margin-bottom: 32px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.timeline-item:nth-child(1) { animation-delay: 0.1s; }
.timeline-item:nth-child(2) { animation-delay: 0.2s; }
.timeline-item:nth-child(3) { animation-delay: 0.3s; }
.timeline-item:nth-child(4) { animation-delay: 0.4s; }
.timeline-item:nth-child(5) { animation-delay: 0.5s; }

/* --- DOT (Punto de conexión M3) --- */
.timeline-dot {
    position: absolute;
    left: -36px;
    top: 24px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--md-surface); /* Se adapta al fondo del tema */
    border: 4px solid var(--md-primary);
    box-shadow: 0 0 0 4px rgba(255, 153, 0, 0.15);
    z-index: 2;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.timeline-item:hover .timeline-dot {
    transform: scale(1.2);
    background: var(--md-primary); /* Se rellena de naranja al hover */
    box-shadow: 0 0 0 6px rgba(255, 153, 0, 0.25);
}

/* --- TARJETA DE CONTENIDO (Surface Container) --- */
.timeline-content {
    background: var(--md-surface);
    border: 1px solid var(--md-outline);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.timeline-content:hover {
    transform: translateY(-4px);
    border-color: var(--md-primary);
    box-shadow: 0 12px 28px -8px rgba(255, 153, 0, 0.2);
}

/* --- METADATOS Y BADGES --- */
.timeline-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.timeline-date {
    font-size: 13px;
    font-weight: 500;
    color: var(--md-text-sub);
}
.timeline-version {
    font-size: 12px;
    font-weight: 700;
    color: var(--md-primary);
    background: rgba(255, 153, 0, 0.12); /* Capa de estado M3 (12% opacidad) */
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 153, 0, 0.3);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- TEXTOS --- */
.timeline-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--md-text-main);
    margin: 0 0 16px 0;
}
.timeline-details {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.timeline-details li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--md-text-sub);
}
.timeline-details li strong {
    color: var(--md-text-main);
    font-weight: 600;
}

/* --- ICONOS DE DETALLES (M3 State Layers) --- */
.timeline-details li i {
    font-size: 16px;
    color: var(--md-primary);
    background: rgba(255, 153, 0, 0.12);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.2s ease;
}
.timeline-details li:hover i {
    background: rgba(255, 153, 0, 0.24);
    transform: scale(1.05);
}

/* --- FOOTER --- */
.welcome-footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: var(--md-text-sub);
    font-size: 14px;
    border-top: 1px solid var(--md-outline);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsivo básico para móviles */
@media (max-width: 768px) {
    .welcome-header { padding: 24px; }
    .welcome-header h1 { font-size: 22px; }
    .modern-timeline { padding-left: 24px; }
    .timeline-dot { left: -24px; width: 14px; height: 14px; }
    .timeline-content { padding: 16px; }
}


.ox-file .filepond--item, .ox-files .filepond--item {
    width: 100% !important;
    cursor: pointer !important;
}

/* ==========================================================================
   Componente Visual: Plan de Accion IA (@PlanAccion)
   ========================================================================== */
.pa-dashboard-wrapper {
    display: flex;
    gap: 15px;
    background-color: var(--md-surface, #1e1e1e);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--md-outline-variant, #333);
    font-family: inherit;
    align-items: stretch;
    /* Aumentamos de 5px a 25px para darle espacio a la etiqueta de OpenXava */
    margin-top: 25px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Permite bajar a la siguiente línea en pantallas pequeñas */
    width: 100%;
    box-sizing: border-box;
}

.pa-header-box {
    background-color: var(--md-surface-variant, #2d2d2d);
    border: 1px solid var(--md-outline-variant, #404040);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1.2 1 250px; /* Crece, se encoge, tamaño base */
    min-width: 0; /* Evita que rompa el contenedor padre */
}

.pa-icon-box {
    background-color: var(--md-surface, #1e1e1e);
    color: var(--md-primary, #ff6b6b);
    width: 40px;
    height: 40px;
    min-width: 40px; /* Fija el tamaño del icono */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 22px;
    border: 1px solid var(--md-outline-variant, #404040);
}

.pa-header-texts {
    flex: 1;
    min-width: 0;
}

.pa-header-texts h4 {
    /* FIX: Hereda el color nativo del tema (negro en lite, blanco en dark) */
    color: inherit;
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: normal !important;
}

.pa-subtitle {
    /* FIX: Usamos el color nativo pero con opacidad para darle efecto de "subtítulo" */
    color: inherit;
    opacity: 0.65;
    font-size: 12px;
    line-height: 1.4;
    display: block;
    white-space: normal !important;
    word-wrap: break-word;
}

.pa-action-box {
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center; /* Centra verticalmente el número y el texto */
    gap: 12px;
    flex: 1 1 200px;
    min-width: 0; /* TRUCO FLEXBOX: Permite que el texto salte de línea */
    transition: transform 0.2s ease;
}

.pa-action-box:hover {
    transform: translateY(-2px);
}

.pa-badge {
    width: 26px;
    height: 26px;
    min-width: 26px; /* Fija el tamaño del círculo */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pa-action-text {
    /* FIX: Hereda el color del tema, destruyendo el gris claro estático */
    color: inherit;
    font-size: 13px;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
    white-space: normal !important;
    word-break: break-word;
}


/* ==========================================================================
   Componente Premium: Tarjetas KPI Adaptativas (@TarjetaKPI)
   ========================================================================== */
.ind-card {
    background-color: var(--md-surface, #1e1e1e);

    /* FIX 1: Borde universal semi-transparente.
       En Dark es casi invisible, en Lite es un contorno gris ultra suave. */
    border: 1px solid rgba(130, 130, 130, 0.2);

    border-radius: 12px;
    padding: 18px 20px;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    position: relative;

    /* FIX 2: Sombra más amplia pero más suave para el efecto flotante */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);

    font-family: inherit;
    margin-right: 15px;
    margin-bottom: 15px;
    box-sizing: border-box;
}

/* El punto de estado */
.ind-dot {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.ind-title {
    color: var(--md-on-surface-variant, #a0a0a0);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ind-value {
    color: var(--md-on-surface, #ffffff);
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.1;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.ind-subtitle {
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Empuja el ojo a la derecha si existe */
    width: 100%;
    font-weight: 500;
    color: var(--md-on-surface-variant, #a0a0a0);

    /* TRUCO DE ALINEACIÓN: Fija la altura del subtítulo.
       Si el ojo se oculta por "mostrarDato=0", la tarjeta no varía ni un solo píxel de alto. */
    min-height: 24px;
    box-sizing: border-box;
}

.ind-progress-track {
    /* FIX 3: La pista de la barra hereda un tono sutil del tema actual */
    background-color: var(--md-surface-variant, rgba(150, 150, 150, 0.2));
    height: 6px;
    border-radius: 4px;
    width: 100%;
    overflow: hidden;
    margin-bottom: 12px;
}

.ind-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-in-out;
}

.ind-footer {
    display: flex;
    justify-content: space-between;
    color: var(--md-on-surface-variant, #888888);
    font-size: 11px;
    font-weight: 500;
}

.ind-footer-right {
    font-weight: 700;
    text-transform: uppercase;
}

/* El icono de ojo del Dashboard */
.kpi-privacy-eye {
    color: var(--md-on-surface-variant, #a0a0a0);
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.kpi-privacy-eye:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* --- Temas de Colores Sincronizados con tus Donuts --- */
/* --- NUEVO TEMA: Naranja Material UI ---
   Este color (#f97316 / #ff9800) hace match perfecto con tu gráfico de barras inferior */
.ind-theme-orange .ind-dot { background-color: #f97316; }
.ind-theme-orange .ind-value { color: #f97316; }
.ind-theme-orange .ind-subtitle i { color: #f97316; }
.ind-theme-orange .ind-footer-right { color: #f97316; }
.ind-theme-orange .ind-progress-fill { background-color: #f97316; }
/* Verde: Mismo tono del anillo exterior de tu Donut */
.ind-theme-green .ind-dot { background-color: #00E396; }
.ind-theme-green .ind-value { color: #00E396; }
.ind-theme-green .ind-subtitle i { color: #00E396; } /* Pinta el icono */
.ind-theme-green .ind-footer-right { color: #00E396; }
.ind-theme-green .ind-progress-fill { background-color: #00E396; }

/* Amarillo/Naranja: Mismo tono de tu Donut de Facturas */
.ind-theme-yellow .ind-dot { background-color: #FFA500; }
.ind-theme-yellow .ind-value { color: #FFA500; }
.ind-theme-yellow .ind-subtitle i { color: #FFA500; }
.ind-theme-yellow .ind-footer-right { color: #FFA500; }
.ind-theme-yellow .ind-progress-fill { background-color: #FFA500; }

/* Rojo: Para alertas críticas */
.ind-theme-red .ind-dot { background-color: #ef4444; }
.ind-theme-red .ind-value { color: #ef4444; }
.ind-theme-red .ind-subtitle i { color: #ef4444; }
.ind-theme-red .ind-footer-right { color: #ef4444; }
.ind-theme-red .ind-progress-fill { background-color: #ef4444; }

/* Azul: Información estándar */
/* Mantenemos el azul para los clientes, pero un tono más "Google" */
.ind-theme-blue .ind-dot { background-color: #1a73e8; }
.ind-theme-blue .ind-value { color: #1a73e8; }
.ind-theme-blue .ind-subtitle i { color: #1a73e8; }
.ind-theme-blue .ind-footer-right { color: #1a73e8; }
.ind-theme-blue .ind-progress-fill { background-color: #1a73e8; }

/* Morado: Ideal para métricas diarias o de rendimiento en tiempo real */
.ind-theme-purple .ind-dot { background-color: #a855f7; }
.ind-theme-purple .ind-value { color: #a855f7; }
.ind-theme-purple .ind-subtitle i { color: #a855f7; }
.ind-theme-purple .ind-footer-right { color: #a855f7; }
.ind-theme-purple .ind-progress-fill { background-color: #a855f7; }