/* ═══════════════════════════════════════════════════════════════════
 *  UNIDOSSIS ERP — Module Pro Styles v1.1 (2026)
 *  ─────────────────────────────────────────────────────────────────
 *  CSS aditivo para vistas de MÓDULO (detalle con sticky cascade).
 *  Se carga DESPUÉS de styles.css.  No duplica reglas base.
 *
 *  Dependencia:  static/erp/css/styles.css  (variables :root, .data-table,
 *                .detalle-action-bar, .form-tabs, etc.)
 *
 *  Convenciones:
 *    - Variables --sticky-offset-* se actualizan por JS (StickyManager)
 *    - Los defaults hardcoded son fallbacks para primera pintura
 *    - Selectores soportan #detalleGrid (legacy) Y .erp-module-grid
 *  ═══════════════════════════════════════════════════════════════ */

/* ── 0. Variables de Módulo ───────────────────────────────────── */
:root {
    /* Alturas de referencia (fallbacks — StickyManager los sobreescribe) */
    --erp-tab-bar-h:           34px;

    --sticky-offset-tabs:      132px;
    --sticky-offset-action:    177px;
    --sticky-offset-grid:      219px;
    --sticky-offset-filter:    247px;

    /* Colores de superficie del módulo */
    --module-header-bg:        #f4f6f9;
    --module-grid-header-bg:   #f8fafc;
    --module-filter-bg:        #edf2f7;
    --module-action-bg:        #fff;
    --module-data-bg:          #fff;

    /* ── Sistema de espaciado (retícula 4px) ──────────────────────
     * Única fuente de verdad para gutters del módulo. El shell ya usa
     * 16px horizontal (command strip 8px 16px, tech footer 6px 16px);
     * el área de contenido adopta el mismo gutter para alinearse. */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-6: 24px;
    --sp-8: 32px;
    --module-gutter-x: 12px;   /* gutter horizontal del contenido unificado a 12px con cabecera y tabs */
    --module-gutter-y: 6px;    /* respiración vertical del contenido */
}


/* ══════════════════════════════════════════════════════════════════
 *  1. FULL-WIDTH LAYOUT — Flex Column Architecture v2.6
 *  ────────────────────────────────────────────────────────────────
 *  ESTRUCTURA:
 *    .erp-view-wrapper     (flex-column, height calc'd inline)
 *      ├── .erp-command-strip   flex-shrink:0
 *      ├── .module-tabs-bar     flex-shrink:0
 *      ├── .module-main-container  flex:1 overflow:auto
 *      └── .erp-tech-footer     flex-shrink:0
 *  ════════════════════════════════════════════════════════════════ */

/* El body .erp-module activa el modo full-width con encajonamiento exacto */
.erp-module .main-content {
    padding-top:   var(--erp-tab-bar-h, 34px) !important;
    padding-left:  2px !important;
    padding-right: 2px !important;
    padding-bottom: 1px !important;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg, #eef2f6) !important;
    /* v2.7: Flex-column + contener scroll dentro del módulo */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100vh !important;
    position: relative !important;
    z-index: 1 !important;
    border-left: none !important;
    outline: none !important;
}

/* Wrapper maestro del módulo (Odoo Sheet / Tarjeta Flotante) */
.erp-view-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 1;
    background: #ffffff;
    border: 1px solid var(--border-light, #cbd5e1);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 1px 3px rgba(15, 28, 46, 0.05);
    flex: 1 1 0%;
    min-height: 0;
}

/* Contenedor de scroll — único punto de scroll en el módulo.
 * padding: 0  → El grid/tabla ocupa todo el ancho disponible (edge-to-edge).
 *              Igual que Odoo 17 / ERPNext v15.
 * Los formularios de detalle restauran el padding internamente
 * (ver base_detail.html wrapper y las reglas CSS de .card:not(.tab-panel)).
 */
.module-main-container {
    width: 100%;
    box-sizing: border-box;
    background: var(--card, #ffffff);
    padding: 0;
}
/* Formularios y vistas de detalle que necesitan respiración (clase opt-in) */
.module-main-container.with-top-pad {
    padding: var(--module-gutter-y, 6px) var(--module-gutter-x, 12px);
}
/* Elementos de formulario standalone dentro del contenedor:
 * cards que NO son tab-panel, forms directos, secciones. */
.module-main-container > .card:not(.tab-panel),
.module-main-container > .form-section {
    padding: var(--module-gutter-y, 6px) var(--module-gutter-x, 12px);
    margin: 0;
    box-sizing: border-box;
}

.module-main-container > form {
    padding: var(--module-gutter-y, 6px) var(--module-gutter-x, 12px) 12px;
    margin: 0;
    box-sizing: border-box;
}

/* Scrollbar custom — alineado con grid-scroll-viewport */
.module-main-container::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
.module-main-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.module-main-container::-webkit-scrollbar-thumb {
    background: #c1cbd6;
    border-radius: 4px;
}
.module-main-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tab panels dentro del scroll container: sin bordes de .card
 * para que el fondo blanco cubra edge-to-edge sin gaps.
 * CRÍTICO: animation y transition se desactivan porque usan transform,
 * lo que crea un containing block que rompe position:sticky en los
 * descendientes (frozen columns + sticky headers). */
.module-main-container > .tab-panel {
    min-width: 0;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: var(--module-gutter-y, 6px) var(--module-gutter-x, 12px) 12px !important;
    background: transparent !important;
    overflow: visible !important;
    animation: none !important;        /* CRÍTICO: evita containing block por transform */
    transition: none !important;       /* CRÍTICO: evita containing block por transition:all */
}

/* Tab panels anidados dentro de form: el form ya proporciona el padding contenedor (12px),
 * por lo que los tab-panels NO deben duplicar padding para que las secciones se alineen
 * exactamente a 12px con la cabecera (command strip) y pestañas (form-tabs). */
.module-main-container form > .tab-panel,
.module-main-container form .tab-panel.card {
    min-width: 0;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    animation: none !important;        /* CRÍTICO: evita containing block por transform */
    transition: none !important;       /* CRÍTICO: evita containing block por transition:all */
}

/* Escape hatch: contenido que SÍ debe ir de borde a borde (grids full-bleed).
 * Anula el gutter del contenedor con márgenes negativos o padding cero. */
.module-main-container > .full-bleed,
.module-main-container > .tab-panel.full-bleed {
    margin: calc(-1 * var(--module-gutter-y, 6px)) calc(-1 * var(--module-gutter-x, 12px)) !important;
}

.module-main-container > #tab-detalle.tab-panel,
.module-main-container > .tab-panel.tab-panel-grid {
    padding: 0 !important;
    margin: 0 !important;
}

#detalleGrid.erp-module-grid {
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

.detalle-action-bar,
.erp-grid-footer {
    display: flex;
    width: 100%;
    box-sizing: border-box;
}

/* Grid scroll viewport: sin padding lateral para que la tabla
 * se extienda de borde a borde, alineada con el command strip */
.module-main-container .grid-scroll-viewport {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Tabs bar del módulo */
.module-tabs-bar {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


/* ══════════════════════════════════════════════════════════════════
 *  1b. GRID SCROLL VIEWPORT — Contenedor de scroll horizontal
 *  ────────────────────────────────────────────────────────────────
 *  Envuelve la data-table para que el scroll horizontal se limite
 *  EXCLUSIVAMENTE a la tabla, sin mover la cabecera ni el footer.
 *  ════════════════════════════════════════════════════════════════ */

.grid-scroll-viewport {
    /* NOTE: overflow y flex:1 se controlan desde base_erp_module.html
     * dentro del contexto .erp-view-wrapper.
     * Aquí solo definimos propiedades visuales de fallback. */
    width: 100%;
    background: var(--card, #ffffff);
    box-sizing: border-box;
}

/* Cuando la tabla está DENTRO del viewport, sticky es relativo al viewport */
.grid-scroll-viewport .data-table thead tr:first-child th,
.grid-scroll-viewport .erp-module-grid thead tr:first-child th {
    top: 0 !important;                    /* v2.5: relativo al viewport container */
    z-index: 100 !important;
}

.grid-scroll-viewport .data-table thead tr.erp_p-filter-row th,
.grid-scroll-viewport .erp-module-grid thead tr.erp_p-filter-row th {
    top: var(--grid-header-h, 24px) !important;  /* v2.6: sincronizado con header */
    z-index: 99 !important;
}

/* Scrollbar styling */
.grid-scroll-viewport::-webkit-scrollbar {
    height: 7px;
}
.grid-scroll-viewport::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.grid-scroll-viewport::-webkit-scrollbar-thumb {
    background: #c1cbd6;
    border-radius: 4px;
}
.grid-scroll-viewport::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* La tabla dentro del viewport debe expandirse al contenido natural */
.grid-scroll-viewport > .data-table,
.grid-scroll-viewport > .erp-module-grid {
    width: max-content;
    min-width: 100%;
}


/* ══════════════════════════════════════════════════════════════════
 *  2. COMMAND STRIP (cabecera de detalle de módulo)
 *  ════════════════════════════════════════════════════════════════ */

.erp-command-strip {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--module-header-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    width: 100%;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-sizing: border-box;
    /* v2.9: z-index alto para que SIEMPRE tape la tabla al hacer scroll.
     * Patron Odoo 17 / ERPNext v15: el command strip es la capa más alta
     * del modulo. La tabla (z-index 120 en frozen cols) debe quedar debajo. */
    position: relative;
    z-index: 200;
    border-left: none !important;
}

/* Row 1: Title + Actions — funciona tanto como hijo de .erp-command-strip
 * como elemento standalone directo en {% block command_strip %} */
.erp-command-strip .cs-row-actions,
.cs-row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    min-height: 30px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-light);
    justify-content: space-between;
    background: var(--module-header-bg, #f4f6f9);
}

/* Mitad izquierda del command strip (titulo + badges) */
.cs-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

/* Mitad derecha del command strip (botones de accion) */
.cs-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1 1 auto;
}

/* Page title dentro del command strip */
.erp-page-title,
.module-section-title {
    font-size: 13px;
    font-weight: var(--fw-bold, 700);
    color: var(--text);
    margin: 0;
    letter-spacing: -.2px;
    line-height: 1.2;
}

/* Row 2: Workflow Progress */
.cs-row-workflow {
    flex-shrink: 0;
    padding: 3px 12px;
    min-height: 27px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

/* Separador vertical */
.erp-cmd-divider,
.cs-divider {
    border-left: 1px solid var(--border);
    height: 16px;
    margin: 0 var(--sp-1, 4px);
    flex-shrink: 0;
    align-self: center;
}

/* ── Filtro compacto tipo "pill" para dropdowns en command strip ── */
.cs-filter-pill {
    appearance: none;
    -webkit-appearance: none;
    width: auto;
    height: 24px;
    padding: 0 20px 0 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary, #475569);
    background: var(--card, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E") no-repeat right 6px center;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 3px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    line-height: 24px;
}
.cs-filter-pill:hover { border-color: var(--primary, #0891b2); }
.cs-filter-pill:focus { outline: none; border-color: var(--primary, #0891b2); box-shadow: 0 0 0 2px rgba(8,145,178,.12); }

/* ── Badge de selección masiva ── */
.cs-sel-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary, #0891b2);
    background: rgba(8, 145, 178, .08);
    border: 1px solid rgba(8, 145, 178, .2);
    letter-spacing: .2px;
}

/* ── Botón extra-pequeño (para el X de limpiar selección) ── */
.btn-cs.btn-xs {
    padding: 2px 6px;
    font-size: 10px;
    height: 22px;
    min-width: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Animación de entrada suave para barra de selección ── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Checkbox-pill para multi-select de estados ── */
.cs-estado-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    background: var(--bg, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    cursor: pointer;
    transition: all .15s ease;
    user-select: none;
    line-height: 1.3;
}
.cs-estado-pill input[type="checkbox"] {
    width: 10px;
    height: 10px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary, #0891b2);
}
.cs-estado-pill:hover {
    border-color: var(--primary, #0891b2);
    background: rgba(8,145,178,.05);
}
.cs-estado-pill:has(input:checked) {
    background: rgba(8,145,178,.1);
    border-color: var(--primary, #0891b2);
    color: var(--primary, #0891b2);
    font-weight: 600;
}

/* ── Segmented Control (Pill Button Group) para selectores mutuamente excluyentes ── */
.erp-segmented-control {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 4px;
    padding: 2px;
    gap: 2px;
    height: 26px;
    box-sizing: border-box;
    width: 100%;
}
.erp-segmented-control .seg-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 20px;
    padding: 0 6px;
    border: none;
    background: transparent;
    color: var(--text-muted, #64748b);
    font-size: 10.5px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    outline: none;
}
.erp-segmented-control .seg-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text, #1e293b);
}
.erp-segmented-control .seg-btn.active {
    background: var(--corp-teal, #0891b2) !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(8, 145, 178, 0.4);
}
.erp-segmented-control .seg-btn.active i {
    color: #ffffff !important;
}
.erp-segmented-control .seg-btn.seg-full.active,
.erp-segmented-control .seg-btn.seg-maquila.active,
.erp-segmented-control .seg-btn.seg-mixta.active {
    background: var(--corp-teal, #0891b2) !important;
    color: #ffffff !important;
}
.erp-segmented-control .seg-btn i {
    font-size: 9.5px;
}

/* ── Info Card — tarjeta de informacion estandar (reemplaza inline bg+border+radius) */
.info-card {
    background: var(--bg, #f8fafc);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    padding: var(--sp-3, 12px) var(--sp-4, 16px);
    transition: border-color .2s, box-shadow .2s;
}

.info-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

/* Cabecera de seccion dentro de una info-card */
.info-card__header {
    font-size: var(--text-md, 13px);
    font-weight: var(--fw-bold, 700);
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: .4px;
    margin-bottom: var(--sp-2, 8px);
    padding-bottom: var(--sp-1, 4px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Campo label + valor estandar */
.info-field__label {
    font-size: var(--text-sm, 11px);
    font-weight: var(--fw-bold, 700);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    display: block;
    margin-bottom: 2px;
}

.info-field__value {
    font-size: var(--text-base, 12px);
    color: var(--text);
}

.info-field__value--lg {
    font-size: var(--text-xl, 16px);
    font-weight: var(--fw-bold, 700);
}

.info-field__value--md {
    font-size: var(--text-lg, 14px);
    font-weight: var(--fw-semibold, 600);
}

/* Grid de campos de informacion */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3, 12px) var(--sp-4, 16px);
}

.info-grid--2col { grid-template-columns: repeat(2, 1fr); }
.info-grid--3col { grid-template-columns: repeat(3, 1fr); }
.info-grid--4col { grid-template-columns: repeat(4, 1fr); }

/* Tabla de detalle estandar (reemplaza table con inline styles) */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.detail-table thead tr {
    background: rgba(248, 250, 252, 0.8);
    border-bottom: 2px solid var(--border);
}

.detail-table thead th {
    padding: var(--sp-3, 12px) var(--sp-4, 16px);
    font-size: var(--text-sm, 11px);
    font-weight: var(--fw-semibold, 600);
    color: var(--text-muted);
    white-space: nowrap;
}

.detail-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.detail-table tbody tr:hover {
    background: var(--bg, #f8fafc);
}

.detail-table tbody td {
    padding: var(--sp-3, 12px) var(--sp-4, 16px);
    font-size: var(--text-base, 12px);
}

/* Contenedor de tarjeta blanca (reemplaza inline background+border+radius) */
.white-card {
    background: var(--card, #ffffff);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    overflow: hidden;
}

.white-card__header {
    padding: var(--sp-3, 12px) var(--sp-4, 16px);
    border-bottom: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.white-card__title {
    margin: 0;
    font-size: var(--text-lg, 14px);
    font-weight: var(--fw-bold, 700);
    color: var(--text);
}

.white-card__body {
    padding: var(--sp-4, 16px);
}


/* v3.0: NO sticky overrides — form-tabs es position:relative en la base.
 * Solo conservamos estilos visuales (fondo, borde, border-radius). */
.erp-module .form-tabs {
    border-radius: 0 !important;
    background: #f8fafc !important;
    box-shadow: none !important;
}

/* Tabs wrapper: sin margin negativo (causaba desalineación) */
.erp-module .tabs-wrapper {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}


/* v2.6: detalle-action-bar es sticky DENTRO del scroll container.
 * Se queda fijo al tope del grid mientras scrolleas, pero desaparece
 * naturalmente al cambiar de tab porque vive dentro de .tab-panel. */
.erp-module .detalle-action-bar {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: var(--module-action-bg, #ffffff) !important;
    margin-bottom: 0 !important;
    padding-bottom: 8px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}


/* ══════════════════════════════════════════════════════════════════
 *  5. GRID ERP_P — Header y Filter Row sticky (v2.6)
 *     Soporta #detalleGrid (legacy) Y .erp-module-grid (nuevo)
 *  ────────────────────────────────────────────────────────────────
 *  --grid-header-h controla la altura exacta del header row.
 *  El filter row se posiciona justo debajo usando esa misma variable.
 *  ════════════════════════════════════════════════════════════════ */

#detalleGrid,
.erp-module-grid {
    --grid-header-h: 22px;       /* Altura exacta del header row */
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: var(--module-data-bg) !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    -webkit-font-smoothing: auto !important;
}

/* thead fondo opaco */
#detalleGrid thead,
.erp-module-grid thead,
#detalleGrid thead tr:first-child,
.erp-module-grid thead tr:first-child {
    background: #f0f0f0 !important;
}

/* ── Header <tr>: tipografía estandarizada nítida Windows (Tahoma 11px) ─── */
#detalleGrid thead tr:first-child,
.erp-module-grid thead tr:first-child {
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    text-transform: none !important;
    letter-spacing: 0px !important;
    color: #111111 !important;
    font-weight: 400 !important;
    height: 22px !important;
    line-height: 20px !important;
}

/* ── Header <th>: padding compacto estandarizado ───────────────── */
#detalleGrid thead tr:first-child th,
.erp-module-grid thead tr:first-child th {
    padding: 2px 6px !important;
    height: 22px !important;
    line-height: 20px !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: 400 !important;
    color: #111111 !important;
    text-transform: none !important;
    letter-spacing: 0px !important;
}

/* ── Tabla: font-size base estandarizado ───────────────────────── */
#detalleGrid,
.erp-module-grid {
    font-size: 11px;
}

/* ── Header <th>: sticky + opaco + z-index:100 ───────────────── */
/* NOTA: :not(.bom-sub-table) excluye la tabla BOM anidada */
#detalleGrid > thead tr:first-child th,
.erp-module-grid > thead tr:first-child th {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    height: var(--grid-header-h, 22px) !important;
    background: #f0f0f0 !important;
    border-bottom: 1px solid #c8c8c8 !important;
    box-shadow: none !important;
    border-right: 1px solid #dcdcdc !important;
    outline: none !important;
}

#detalleGrid > thead tr:first-child th:last-child,
.erp-module-grid > thead tr:first-child th:last-child {
    border-right: none !important;
}

/* ── Filter Row <th>: sticky + opaco + z-index:99 ────────────── */
#detalleGrid > thead tr.erp_p-filter-row,
.erp-module-grid > thead tr.erp_p-filter-row {
    background: var(--module-filter-bg) !important;
    height: 22px !important;
}

#detalleGrid > thead tr.erp_p-filter-row th,
.erp-module-grid > thead tr.erp_p-filter-row th {
    position: sticky !important;
    top: var(--grid-header-h, 22px) !important;  /* v2.6: sincronizado con altura real del header */
    z-index: 99 !important;
    background: var(--module-filter-bg) !important;
    border-top: none !important;
    border-bottom: 1px solid #d0d5dd !important;
    padding: 2px 3px !important;
    height: 22px !important;
    box-shadow: none !important;
}

#detalleGrid > thead tr.erp_p-filter-row input.erp_p-filter-input,
.erp-module-grid > thead tr.erp_p-filter-row input.erp_p-filter-input {
    height: 18px !important;
    padding: 1px 4px !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 10.5px !important;
    line-height: 16px !important;
    color: #000000 !important;
}

/* ── Data rows: estilos estandarizados + Efecto Cebra (Zebra Striping) ── */
/* NOTA: > tbody limita a la tabla directa, no a tablas anidadas */
#detalleGrid > tbody > tr > td,
.erp-module-grid > tbody > tr > td {
    padding: 2px 6px !important;
    height: 24px !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: 400 !important;
    letter-spacing: 0px !important;
    line-height: 1.2 !important;
    color: #000000 !important;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e9eef4;
    vertical-align: middle;
}

#detalleGrid > tbody > tr:not(.bom-row).erp-row-odd > td,
.erp-module-grid > tbody > tr:not(.bom-row).erp-row-odd > td {
    background-color: #ffffff;
}

#detalleGrid > tbody > tr:not(.bom-row).erp-row-even > td,
.erp-module-grid > tbody > tr:not(.bom-row).erp-row-even > td,
#detalleGrid > tbody > tr:not(.bom-row):not(.erp-row-odd):nth-child(even) > td,
.erp-module-grid > tbody > tr:not(.bom-row):not(.erp-row-odd):nth-child(even) > td {
    background-color: #f1f5f9;
}

#detalleGrid tbody td:last-child,
.erp-module-grid tbody td:last-child {
    border-right: none;
}

/* Hover de fila de datos */
#detalleGrid > tbody > tr:not(.bom-row):hover > td,
.erp-module-grid > tbody > tr:not(.bom-row):hover > td {
    background-color: #e0f2fe !important;
}

/* Fila padre con BOM desplegado */
#detalleGrid > tbody > tr.bom-expanded > td,
.erp-module-grid > tbody > tr.bom-expanded > td {
    background-color: #ccfbf1 !important;
}

/* ── Fila de Totales (tfoot) en Grilla Principal ───────────────── */
#detalleGrid > tfoot > tr > td,
.erp-module-grid > tfoot > tr > td {
    padding: 2px 6px !important;
    height: 24px !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    background: #e8eef5 !important;
    color: #000000 !important;
    border-top: 1.5px solid #cbd5e1 !important;
    border-bottom: 1px solid #cbd5e1 !important;
    border-right: 1px solid #dce4ee !important;
    vertical-align: middle !important;
    max-width: none !important;
    overflow: visible !important;
}
#detalleGrid > tfoot > tr > td:last-child,
.erp-module-grid > tfoot > tr > td:last-child {
    border-right: none !important;
}

/* ── Action column: botones Ver Detalle / Editar (Iconos SVG Oficiales Modo 3) ── */
.erp-grid-actions {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.erp-grid-actions .btn-icon {
    width: 20px !important;
    height: 20px !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px !important;
    border: 1px solid #e2e8f0;
    font-size: 9px !important;
    cursor: pointer;
    transition: all 0.14s ease;
    text-decoration: none;
    overflow: hidden;
}

/* Ver Detalle — SVG Oficial (iconos/detalles.svg en Modo 3 #F7F7F7) */
.erp-grid-actions .btn-detalle {
    background: #F7F7F7 url("../icons/detalles.svg") center / 18px 18px no-repeat !important;
    border: 1px solid #cbd5e1 !important;
    color: transparent !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
}
.erp-grid-actions .btn-detalle i,
.erp-grid-actions .btn-editar i {
    display: none !important;
}
.erp-grid-actions .btn-detalle:hover {
    background: #F7F7F7 url("../icons/detalles.svg") center / 18px 18px no-repeat !important;
    border-color: #0393D4 !important;
    box-shadow: 0 2px 5px rgba(3, 147, 212, 0.22) !important;
    transform: scale(1.12);
}
.erp-grid-actions .btn-detalle:active {
    transform: scale(1.0);
}

/* Editar — SVG Oficial (iconos/editar.svg Verde Esmeralda Opción D en Modo 3 #F7F7F7) */
.erp-grid-actions .btn-editar {
    background: #F7F7F7 url("../icons/editar.svg") center / 18px 18px no-repeat !important;
    border: 1px solid #cbd5e1 !important;
    color: transparent !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
}
.erp-grid-actions .btn-editar:hover {
    background: #F7F7F7 url("../icons/editar.svg") center / 18px 18px no-repeat !important;
    border-color: #0D9488 !important;
    box-shadow: 0 2px 5px rgba(13, 148, 136, 0.22) !important;
    transform: scale(1.12);
}
.erp-grid-actions .btn-editar:active {
    transform: scale(1.0);
}

/* Existencias / Almacén — gradiente cyan/teal */
.erp-grid-actions .btn-almacen {
    background: linear-gradient(135deg, #0d9488 0%, #06b6d4 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.30),
                inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.erp-grid-actions .btn-almacen:hover {
    background: linear-gradient(135deg, #0f766e 0%, #0891b2 100%);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.40),
                inset 0 1px 0 rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}
.erp-grid-actions .btn-almacen:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(13, 148, 136, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.20);
}

/* Eliminar — outline rojo (acción destructiva, diferenciada visualmente) */
.erp-grid-actions .btn-eliminar {
    background: var(--card, #fff);
    border: 1px solid var(--border-light, #e2e8f0);
    color: var(--danger, #ef4444);
}
.erp-grid-actions .btn-eliminar:hover {
    background: rgba(239, 68, 68, 0.06);
    border-color: var(--danger, #ef4444);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.15);
}

/* ── Resizer de columnas de grilla interactiva ─────────────────── */
.erp-col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    bottom: 0;
    cursor: col-resize;
    user-select: none;
    z-index: 105;
    transition: background .15s;
}
.erp-col-resizer:hover,
.erp-col-resizer.resizing {
    background: var(--accent, #0891b2) !important;
    opacity: 0.9;
}

/* ── Botones de barra de acciones de detalle ──────────────────── */
.detalle-action-bar .btn-icon:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.12);
}
.detalle-action-bar .btn-icon:active {
    transform: translateY(0);
}


/* ── Botones "próximamente" — patrón honesto para roadmap ────────
   Comunica al usuario que la funcionalidad llegará sin engañarlo
   con un alert("Próximamente"). Botón visible pero deshabilitado
   con tooltip nativo. Estilo grayscale para reducir el peso visual.
   Uso: <button class="btn btn-sm btn-outline btn-coming-soon" disabled
                title="Próximamente">...</button>                    */
.btn-coming-soon {
    opacity: 0.55;
    filter: grayscale(0.6);
    cursor: not-allowed !important;
    position: relative;
}
.btn-coming-soon::after {
    content: '';
    position: absolute;
    top: 2px; right: 2px;
    width: 6px; height: 6px;
    background: var(--corp-blue, #1d4ed8);
    border-radius: 50%;
    box-shadow: 0 0 0 1.5px var(--card, #fff);
    opacity: 0.7;
}
.btn-coming-soon:hover {
    opacity: 0.7;
}

/* ── Breadcrumb trail — navegación contextual para vistas 3+ niveles ──
   Uso: {% block breadcrumbs %}<nav class="erp-breadcrumb-trail">
          <a href="...">Módulo</a>
          <a href="...">Entidad</a>
          <span>Detalle</span>
        </nav>{% endblock %}                                             */
.erp-breadcrumb-trail {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px 16px;
    background: var(--bg, #eef2f6);
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    flex-shrink: 0;
}
.erp-breadcrumb-trail a {
    color: var(--primary, #003134);
    text-decoration: none;
    transition: color .15s;
    font-weight: 600;
}
.erp-breadcrumb-trail a:hover {
    color: var(--accent, #00E28B);
    text-decoration: underline;
}
.erp-breadcrumb-trail a::after,
.erp-breadcrumb-trail span.bc-sep::after {
    content: '›';
    margin: 0 6px;
    color: var(--text-muted, #6b7280);
    opacity: .5;
    font-weight: 400;
}
.erp-breadcrumb-trail > :last-child::after {
    content: none;
}
.erp-breadcrumb-trail > :last-child {
    color: var(--text, #0f1c2e);
    font-weight: 700;
}


/* ── Columna de acciones sticky a la derecha ───────────────────────
   Usar en <th> y <td> de la columna Acciones cuando la tabla tiene
   muchas columnas y desborda horizontalmente.
   Garantiza que los botones siempre sean visibles y clicables.     */
.col-acciones-sticky {
    position: sticky;
    right: 0;
    background: var(--card, #ffffff);
    z-index: 3;
    box-shadow: -3px 0 8px rgba(0, 0, 0, 0.06);
}
thead .col-acciones-sticky {
    background: var(--bg, #eef2f6);
    z-index: 4;
}

/* ── Sistema de columnas fijas (frozen) a la izquierda ─────────────
   Aplica SOLO a tablas con clase .erp-frozen-cols.
   Las primeras 3 columnas se congelan al scrollear horizontalmente.
   
   Los offsets `left` se calculan dinámicamente via JavaScript y se
   inyectan como CSS custom properties en la tabla:
     --fc-left-0: 0px           (siempre 0)
     --fc-left-1: <col0 width>  (calculado)
     --fc-left-2: <col0+col1>   (calculado)
   
   ESPECIFICIDAD: las reglas competidoras que ponen z-index:100 en TODOS
   los th del header son:
     .grid-scroll-viewport .erp-module-grid thead tr:first-child th → (0,3,3)
   Nuestras reglas frozen usan selectores MÁS específicos (0,4,3) para
   asegurar que z-index:120 gane y los encabezados no-frozen pasen POR
   DEBAJO de los frozen.
   ──────────────────────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════════
 *  FROZEN COLUMNS — Arquitectura Odoo 17 / ERPNext v15
 *  ─────────────────────────────────────────────────────────────────
 *  SCROLL: el único contenedor de scroll es .module-main-container (overflow:auto).
 *  El .grid-scroll-viewport tiene overflow:visible para que sticky funcione.
 *
 *  PILA DE Z-INDEX (de mayor a menor):
 *    erp-command-strip          z: 200  ← SIEMPRE encima de todo
 *    frozen thead th            z: 120  ← Encabezados de cols congeladas
 *    regular thead th           z: 100  ← Encabezados normales
 *    frozen filter row          z: 119
 *    frozen tbody td            z: 4    ← Celdas de cols congeladas
 *    col-acciones-sticky        z: 3    ← Columna de acciones derecha
 *
 *  SEPARADOR VISUAL ("divisor de Odoo"):
 *    La última columna frozen tiene box-shadow derecho para indicar
 *    visualmente el límite entre zona frozen y zona scrollable.
 *  ═══════════════════════════════════════════════════════════════ */

/* grid-scroll-viewport: overflow visible para que position:sticky
 * funcione relativo al ancestro .module-main-container (el scroll container) */
.grid-scroll-viewport {
    overflow: visible !important;
}

/* === BODY CELLS (td) — todos los rows =================================
   Especificidad baja es suficiente: ninguna regla competidora pone
   z-index en td's.
   NOTA: border-right NO se pone aquí — lo controla JS dinámicamente
   para que solo la ÚLTIMA columna frozen tenga la línea divisoria. */
.erp-frozen-cols td:nth-child(1) {
    position: sticky !important;
    left: var(--fc-left-0, 0px) !important;
    z-index: 4 !important;
    background: #ffffff !important;
}
.erp-frozen-cols td:nth-child(2) {
    position: sticky !important;
    left: var(--fc-left-1, 36px) !important;
    z-index: 4 !important;
    background: #ffffff !important;
}
/* Última columna frozen: divisor visual ("Odoo divider") */
.erp-frozen-cols td:nth-child(3) {
    position: sticky !important;
    left: var(--fc-left-2, 96px) !important;
    z-index: 4 !important;
    background: #ffffff !important;
    box-shadow: 2px 0 6px rgba(0,0,0,0.07) !important;
}
/* Hover: mantener fondo opaco sobre la zona frozen */
.erp-frozen-cols tbody tr:hover td:nth-child(1),
.erp-frozen-cols tbody tr:hover td:nth-child(2),
.erp-frozen-cols tbody tr:hover td:nth-child(3) {
    background: var(--row-hover-bg, #f0f4f8) !important;
}

/* === HEADER CELLS (th) — primera fila del thead =======================
   Selector: .grid-scroll-viewport .erp-frozen-cols thead tr:first-child th:nth-child(N)
   Especificidad: (0, 4, 3)  ←  GANA vs competidora (0, 3, 3)
   NOTA: border-right lo controla JS. */

/* Col 0: Checkbox header */
.grid-scroll-viewport .erp-frozen-cols thead tr:first-child th:nth-child(1) {
    position: sticky !important;
    left: var(--fc-left-0, 0px) !important;
    z-index: 120 !important;
    background: var(--module-grid-header-bg, #f8fafc) !important;
}
/* Col 1: Acciones header */
.grid-scroll-viewport .erp-frozen-cols thead tr:first-child th:nth-child(2) {
    position: sticky !important;
    left: var(--fc-left-1, 36px) !important;
    z-index: 120 !important;
    background: var(--module-grid-header-bg, #f8fafc) !important;
}
/* Col 2: ID principal header — lleva el divisor visual en el header */
.grid-scroll-viewport .erp-frozen-cols thead tr:first-child th:nth-child(3) {
    position: sticky !important;
    left: var(--fc-left-2, 96px) !important;
    z-index: 120 !important;
    background: var(--module-grid-header-bg, #f8fafc) !important;
    box-shadow: 2px 0 6px rgba(0,0,0,0.07) !important;
}

/* === FILTER ROW ======================================================= */
.grid-scroll-viewport .erp-frozen-cols thead tr.erp_p-filter-row th:nth-child(1) {
    position: sticky !important;
    left: var(--fc-left-0, 0px) !important;
    z-index: 119 !important;
    background: var(--module-filter-bg, #edf2f7) !important;
}
.grid-scroll-viewport .erp-frozen-cols thead tr.erp_p-filter-row th:nth-child(2) {
    position: sticky !important;
    left: var(--fc-left-1, 36px) !important;
    z-index: 119 !important;
    background: var(--module-filter-bg, #edf2f7) !important;
}
.grid-scroll-viewport .erp-frozen-cols thead tr.erp_p-filter-row th:nth-child(3) {
    position: sticky !important;
    left: var(--fc-left-2, 96px) !important;
    z-index: 119 !important;
    background: var(--module-filter-bg, #edf2f7) !important;
    box-shadow: none !important;
}

/* === HOVER en body rows (usa clase .erp-fc para columnas dinámicas) === */
.erp-frozen-cols tbody tr:hover td.erp-fc {
    background: #f0f4f8 !important;
}

/* === ANIMACIÓN: columna recién congelada ==============================
   Efecto de "barrido brillante" (shimmer sweep) de arriba a abajo + flash
   de fondo azul hielo. Se ve como un destello de congelamiento. */
@keyframes frozenSweep {
    0%   { background-position: 0 -100%; }
    40%  { background-position: 0 100%; }
    100% { background-position: 0 100%; }
}
@keyframes frozenBgFlash {
    0%   { background-color: rgba(59, 130, 246, 0.18); }
    30%  { background-color: rgba(147, 197, 253, 0.12); }
    100% { background-color: transparent; }
}
.erp-fc-just-frozen {
    animation: frozenBgFlash 0.8s ease-out !important;
    position: relative;
}
.erp-fc-just-frozen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(59, 130, 246, 0.15) 40%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(59, 130, 246, 0.15) 60%,
        transparent 100%
    );
    background-size: 100% 200%;
    animation: frozenSweep 0.7s ease-out forwards;
    pointer-events: none;
    z-index: 200;
}

/* === INDICADOR: zona de drop frozen ==================================
   Cuando se arrastra una columna cerca de la zona frozen, la última
   columna frozen muestra una línea vertical azul brillante con flechas
   animadas «◂◂» apuntando hacia la zona frozen. */
@keyframes dropArrowBounce {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50%      { transform: translateX(-4px); opacity: 0.6; }
}
@keyframes dropLineGlow {
    0%, 100% { box-shadow: 0 0 6px rgba(59, 130, 246, 0.4); }
    50%      { box-shadow: 0 0 14px rgba(59, 130, 246, 0.7); }
}
.erp-fc-drop-zone {
    border-right: 3px solid #3b82f6 !important;
    animation: dropLineGlow 1s ease-in-out infinite !important;
    position: relative;
}
.erp-fc-drop-zone::after {
    content: '◂◂';
    position: absolute;
    right: -22px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: 700;
    color: #3b82f6;
    letter-spacing: -3px;
    animation: dropArrowBounce 0.6s ease-in-out infinite;
    pointer-events: none;
    z-index: 200;
    text-shadow: 0 0 4px rgba(59, 130, 246, 0.3);
}


/* ══════════════════════════════════════════════════════════════════
 *  6. TAB CONTENT — overflow visible para sticky
 *  ════════════════════════════════════════════════════════════════ */

.erp-module .tab-panel-grid {
    overflow: visible !important;
}


/* ══════════════════════════════════════════════════════════════════
 *  7. WORKFLOW PROGRESS BAR — estilos para la barra de pasos
 *  ════════════════════════════════════════════════════════════════ */

.workflow-step-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    margin: 0 auto 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    transition: all .3s;
}

.workflow-step-circle.done {
    background: #22c55e;
    color: white;
}

.workflow-step-circle.pending {
    background: var(--border);
    color: var(--text-muted);
}

.workflow-step-circle.anulado {
    background: #ef4444;
    color: white;
}

.workflow-step-label {
    font-size: 8.5px;
    line-height: 1.1;
}

.workflow-step-connector {
    flex: 0.3;
    height: 2px;
    transition: all .3s;
}

.workflow-step-connector.done { background: #22c55e; }
.workflow-step-connector.pending { background: var(--border); }
.workflow-step-connector.anulado { background: #ef4444; }


/* ══════════════════════════════════════════════════════════════════
 *  8. RESPONSIVE OVERRIDES
 *  ════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .erp-command-strip .cs-row-actions {
        padding: 6px 10px;
        gap: 6px;
    }
    .erp-command-strip .cs-row-workflow {
        padding: 4px 10px;
    }
}


/* ══════════════════════════════════════════════════════════════════
 *  9. FOOTER TÉCNICO — Barra de estado al pie del módulo
 *  ════════════════════════════════════════════════════════════════
 *  Estructura: 3 zonas (izquierda: paginación, centro: estado,
 *  derecha: info de depuración — solo visible para staff).
 *  ──────────────────────────────────────────────────────────────── */

.erp-tech-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 3px 12px;
    background: #ffffff;                           /* Fondo limpio */
    border-top: 1px solid #e2e8f0;                 /* Borde sutil, no más sombras hacia arriba */
    box-shadow: none;                              /* Modern Odoo/ERPNext style */
    font-size: 10.5px;                             /* Texto micro para barras de estado */
    color: #64748b;
    font-family: 'Manrope', sans-serif;
    line-height: 1;
    min-height: 26px;                              /* Barra extra delgada (status bar type) */
    position: relative;
    box-sizing: border-box;
}

/* ── Status Dot Minimalista (ERPNext style) ── */
.etf-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* ── Zonas ─────────────────────────────────────────────────────── */
.etf-zone {
    display: flex;
    align-items: center;
    gap: 8px;
}
.etf-left  { justify-content: flex-start; }
.etf-center { justify-content: center; }
.etf-right { justify-content: flex-end; }

/* ── Paginación ────────────────────────────────────────────────── */
.etf-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.etf-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border, #d1dde8);
    border-radius: 4px;
    background: var(--card, #ffffff);
    color: var(--text-muted, #6b7280);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.etf-page-btn:hover:not(:disabled) {
    border-color: var(--accent, #0891b2);
    color: var(--accent, #0891b2);
    background: rgba(8,145,178,0.06);
}
.etf-page-btn:active:not(:disabled) {
    transform: scale(0.95);
}
.etf-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.etf-page-info {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    padding: 0 6px;
    white-space: nowrap;
}
.etf-page-info strong {
    font-weight: 700;
    color: var(--text-secondary, #374151);
}

/* ── Selector de filas por página ──────────────────────────────── */
.etf-rows-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    cursor: default;
    white-space: nowrap;
}

.etf-rows-select {
    padding: 3px 6px;
    border: 1px solid var(--border, #d1dde8);
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Manrope', sans-serif;
    background: var(--card, #ffffff);
    color: var(--text-secondary, #374151);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
}
.etf-rows-select:focus {
    border-color: var(--accent, #0891b2);
    box-shadow: 0 0 0 2px rgba(8,145,178,0.10);
}

/* ── Separador vertical ────────────────────────────────────────── */
.etf-separator {
    width: 1px;
    height: 16px;
    background: var(--border, #d1dde8);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ── Estado central ────────────────────────────────────────────── */
.etf-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
}

/* ── Badge del nombre del módulo ───────────────────────────────── */
.etf-module-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--corp-teal, #003134);
    background: rgba(0,49,52,0.06);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Información de depuración (solo staff) ────────────────────── */
.etf-debug {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    color: var(--text-muted, #6b7280);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.2px;
}
.etf-debug i {
    font-size: 10px;
    opacity: 0.6;
}

/* ── Responsive ────────────────────────────────────────────────── */

/* Sidebar collapsed → footer stretches full width */
/* v5.0: sidebar-collapsed ya no necesita override — footer está en flujo flex */

@media (max-width: 768px) {
    .erp-tech-footer {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 8px 12px;
    }
    .etf-center { order: -1; }
    .etf-left  { justify-content: center; }
    .etf-right { justify-content: center; }
}


/* ══════════════════════════════════════════════════════════════════
 *  10. AUDITORÍA — Panel Caja Negra (migrado desde template inline)
 *  ════════════════════════════════════════════════════════════════ */

/* ═══ Caja Negra — Panel de Auditoría ═══ */
.audit-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.audit-header .ah-title {
    display: flex; align-items: center; gap: 12px;
}
.audit-header .ah-title h1 {
    font-size: 22px; font-weight: 800; color: var(--text); margin: 0;
    letter-spacing: -0.3px;
}
.audit-header .ah-title .ah-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--warning);
    box-shadow: 0 4px 12px rgba(0,0,0,0.20);
}
.audit-header .ah-badge {
    font-size: 11px; font-weight: 700; padding: 4px 12px;
    border-radius: var(--radius-full);
    background: rgba(245,158,11,0.12); color: var(--warning);
    display: flex; align-items: center; gap: 5px;
}
.audit-header .ah-badge i { font-size: 8px; }

/* ─── KPI strip ── */
.audit-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.audit-kpi {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; position: relative; overflow: hidden;
    transition: all var(--spring); border-top: 3px solid transparent;
}
.audit-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.audit-kpi.kpi-info    { border-top-color: var(--accent); }
.audit-kpi.kpi-warning { border-top-color: var(--warning); }
.audit-kpi.kpi-error   { border-top-color: var(--danger); }
.audit-kpi.kpi-critical{ border-top-color: var(--line-onco); }
.audit-kpi.kpi-total   { border-top-color: var(--corp-teal); }
.audit-kpi .ak-value {
    font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -1px;
    animation: count-up 0.5s ease;
}
.audit-kpi .ak-label {
    font-size: 10.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.4px; color: var(--text-muted); margin-top: 5px;
}
.audit-kpi.kpi-info .ak-value    { color: var(--accent); }
.audit-kpi.kpi-warning .ak-value { color: var(--warning); }
.audit-kpi.kpi-error .ak-value   { color: var(--danger); }
.audit-kpi.kpi-critical .ak-value{ color: var(--line-onco); }
.audit-kpi.kpi-total .ak-value   { color: var(--corp-teal); }

/* ─── Filter Bar ── */
.audit-filters {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 20px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.audit-filters .af-group { display: flex; flex-direction: column; gap: 3px; }
.audit-filters .af-label {
    font-size: 9.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
}
.audit-filters input, .audit-filters select {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-xs);
    font-size: 12.5px; font-family: inherit; outline: none;
    transition: border-color var(--transition); background: #fff;
}
.audit-filters input:focus, .audit-filters select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
.audit-filters .af-search { flex: 1; min-width: 200px; }

/* ─── Log Table ── */
.log-table-wrap {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-sm);
}
.log-table-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(180deg, #fafbfc 0%, #f8f9fb 100%);
}
.log-table-header h3 {
    font-size: 14px; font-weight: 700; color: var(--text); margin: 0;
    display: flex; align-items: center; gap: 8px;
}
.log-table {
    width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.log-table thead th {
    padding: 10px 14px; text-align: left; font-size: 10.5px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border); background: #f8fafc;
    white-space: nowrap; position: sticky; top: 0;
}
.log-table tbody tr {
    border-bottom: 1px solid #f3f4f6; cursor: pointer;
    transition: background var(--transition);
}
.log-table tbody tr:hover { background: rgba(8,145,178,0.03); }
.log-table tbody td {
    padding: 10px 14px; vertical-align: top;
}

/* Semáforo badges */
.severity-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px;
    white-space: nowrap;
}
.severity-badge .pulse {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
/* INFO = Verde */
.severity-INFO .pulse     { background: var(--success); }
.severity-INFO            { background: var(--success-soft); color: #065f46; }
/* WARNING = Amarillo */
.severity-WARNING .pulse  { background: var(--warning); }
.severity-WARNING         { background: var(--warning-soft); color: #92400e; }
/* ERROR = Rojo */
.severity-ERROR .pulse    { background: var(--danger); }
.severity-ERROR           { background: var(--danger-soft); color: #991b1b; }
/* CRITICAL = Morado pulsante */
.severity-CRITICAL .pulse { background: var(--line-onco); animation: pulse-ring 1.4s ease-out infinite; }
.severity-CRITICAL        { background: rgba(124,58,237,0.12); color: #5b21b6; }
/* FATAL = Negro */
.severity-FATAL .pulse    { background: var(--danger); animation: pulse-ring 0.8s ease-out infinite; }
.severity-FATAL           { background: rgba(15,23,42,0.90); color: #fca5a5; }

.log-timestamp {
    font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
    color: var(--text-secondary); white-space: nowrap;
}
.log-user { font-weight: 600; color: var(--text); white-space: nowrap; }
.log-module {
    font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: var(--radius-full); background: var(--accent-soft);
    color: var(--accent); white-space: nowrap;
}
.log-action {
    max-width: 350px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; color: var(--text-secondary);
}
.log-explain {
    max-width: 300px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-style: italic; color: var(--text-muted);
    font-size: 11.5px;
}
.log-hash {
    font-family: 'JetBrains Mono', monospace; font-size: 10px;
    color: var(--text-muted); max-width: 100px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .audit-kpis { grid-template-columns: repeat(2, 1fr); }
    .audit-filters { flex-direction: column; }
    .log-table { font-size: 11px; }
}


/* ══════════════════════════════════════════════════════════════════
 *  11. BOM SUB-TABLE — Tabla de materiales expandible
 *  ────────────────────────────────────────────────────────────────
 *  Clase dedicada para la tabla BOM anidada dentro de .data-table.
 *  REQUIERE !important porque los selectores padre (.data-table tbody td)
 *  tienen la misma especificidad y aplican por herencia a los <td> hijos.
 *
 *  Contraste WCAG AAA:
 *    Header: #ffffff sobre #003134 → 14.3:1
 *    Body:   #1f2937 sobre #ffffff → 16.0:1
 *  ════════════════════════════════════════════════════════════════ */

.bom-sub-table {
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: collapse !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    border: none !important;
    background: #ffffff !important;
    table-layout: fixed !important;
}

/* Header: ERP High-Density Standard */
.bom-sub-table thead th {
    background: #f0f0f0 !important;
    color: #111111 !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: 0px !important;
    padding: 2px 6px !important;
    height: 22px !important;
    line-height: 18px !important;
    white-space: nowrap !important;
    border-bottom: 1px solid #c8c8c8 !important;
    border-right: 1px solid #dcdcdc !important;
    border-top: none !important;
    box-shadow: none !important;
}
.bom-sub-table thead th:last-child {
    border-right: none !important;
}

/* Body: Alta Densidad 22px, fondo BLANCO, texto NEGRO */
.bom-sub-table tbody td {
    padding: 2px 6px !important;
    height: 22px !important;
    line-height: 1.2 !important;
    color: #000000 !important;
    background: #ffffff !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    font-weight: 400 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-right: 1px solid #f1f5f9 !important;
    vertical-align: middle !important;
    max-width: none !important;
    white-space: nowrap !important;
}
.bom-sub-table tbody td:last-child {
    border-right: none !important;
}

/* Footer (tfoot): sin recorte max-width heredado de .data-table tbody td */
.bom-sub-table tfoot td {
    padding: 3px 6px !important;
    height: 22px !important;
    line-height: 1.2 !important;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
    font-size: 11px !important;
    color: #000000 !important;
    background: #f1f5f9 !important;
    border-top: 1px solid #cbd5e1 !important;
    border-right: 1px solid #e2e8f0 !important;
    border-bottom: none !important;
    vertical-align: middle !important;
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
}
.bom-sub-table tfoot td:last-child {
    border-right: none !important;
}

/* Zebra stripes — sutil */
.bom-sub-table tbody tr:nth-child(even) td {
    background: #f8fafc !important;
}

/* Hover — azul cielo suave */
.bom-sub-table tbody tr:hover td {
    background: #e0f2fe !important;
}

/* Contenedor BOM — Override del padre .data-table */
.bom-row > td {
    background: #f8fafc !important;
    color: #1e293b !important;
    max-width: none !important;
    overflow: visible !important;
}
.bom-row:hover {
    background: transparent !important;
}


/* ══════════════════════════════════════════════════════════════════
 *  ╔═════════════════════════════════════════════════════════════════╗
 *  ║                                                                 ║
 *  ║   SISTEMA DE DISEÑO v3.0 — clases componibles                   ║
 *  ║                                                                 ║
 *  ║   PROMESA DE NO-ROMPER:                                         ║
 *  ║   ─────────────────────                                         ║
 *  ║   • Todas las clases aquí abajo tienen prefijo "erp-"           ║
 *  ║   • NO modifican NINGUNA clase definida arriba                  ║
 *  ║   • Los templates VIEJOS siguen funcionando idénticos           ║
 *  ║   • Solo los templates que se MIGREN explícitamente             ║
 *  ║     usarán estas clases                                         ║
 *  ║                                                                 ║
 *  ║   ROLLBACK: si esta sección causa problemas, eliminar este      ║
 *  ║   bloque entero — el resto del CSS sigue funcionando.           ║
 *  ║                                                                 ║
 *  ╚═════════════════════════════════════════════════════════════════╝
 *  ════════════════════════════════════════════════════════════════ */


/* ── 12.A. Page Header (reemplaza command_strip inline) ───────── */
.erp-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 16px;
    background: var(--card, #fff);
    /* No border-bottom: ya lo aplica .erp-command-strip externamente */
}
.erp-page-header__left,
.erp-page-header__right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.erp-page-header__right { gap: 6px; }

.erp-page-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 800;
    color: var(--text, #0f1c2e);
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.erp-page-title i {
    font-size: 13px;
    color: var(--corp-blue, #1d4ed8);
    opacity: 0.85;
}
.erp-page-subtitle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
}


/* ── 12.B. Pills semánticos (tamaño único, 5 variantes) ──────── */
.erp-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.3;
    white-space: nowrap;
}
.erp-pill .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.erp-pill--success  { background: rgba(5,150,105,.12);    color: #059669; }
.erp-pill--danger   { background: rgba(220,38,38,.12);    color: #dc2626; }
.erp-pill--warning  { background: rgba(245,158,11,.15);   color: #d97706; }
.erp-pill--info     { background: rgba(29,78,216,.12);    color: #1d4ed8; }
.erp-pill--neutral  { background: rgba(107,114,128,.12);  color: #6b7280; }


/* ── 12.C. Contador para tabs (badge circular pequeño) ────────── */
.erp-tab-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    background: var(--corp-blue, #1d4ed8);
    color: #fff;
    border-radius: 9px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    margin-left: 4px;
    font-family: 'Manrope', sans-serif;
}
.erp-tab-counter--zero { background: #9ca3af; }


/* ── 12.D. Divider vertical (entre grupos de botones) ─────────── */
.erp-action-divider {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: var(--border, #e2e8f0);
    margin: 0 6px;
}


/* ── 12.E. Avatar circular (reutilizable) ─────────────────────── */
.erp-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--corp-blue, #1d4ed8), #3b82f6);
    color: #fff;
    font-weight: 800;
    font-family: 'Manrope', sans-serif;
    box-shadow: 0 2px 6px rgba(29,78,216,0.25);
    flex-shrink: 0;
    text-transform: uppercase;
    line-height: 1;
}
.erp-avatar--sm { width: 24px; height: 24px; font-size: 9px;  border-radius: 6px; }
.erp-avatar--md { width: 36px; height: 36px; font-size: 12px; border-radius: 10px; }
.erp-avatar--lg { width: 48px; height: 48px; font-size: 15px; border-radius: 12px; }


/* ── 12.F. Form section v3.0 (con tarjeta + icono enmarcado) ──
   ────────────────────────────────────────────────────────────────
   IMPORTANTE: NO sustituye a .form-section. Coexisten.
   - .form-section       → patrón antiguo, sigue funcionando
   - .erp-form-section   → patrón nuevo, opt-in
   ──────────────────────────────────────────────────────────────── */
.erp-form-section {
    background: var(--card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
}
.erp-form-section__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(90deg, rgba(29,78,216,0.06), transparent 70%);
    border-bottom: 1px solid var(--border-light, #eef2f6);
    font-size: 12px;
    font-weight: 700;
    color: var(--text, #0f1c2e);
}
.erp-form-section__head .erp-form-section__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(29,78,216,0.12);
    color: var(--corp-blue, #1d4ed8);
    font-size: 10px;
    flex-shrink: 0;
}
.erp-form-section__head .erp-form-section__extra {
    margin-left: auto;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
}
.erp-form-section__body {
    padding: 14px;
}


/* ── 12.G. Breadcrumb (mismo look que .erp-breadcrumb-trail
                       pero NO la modifica — alias compatible) ───── */
.erp-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border-light, #eef2f6);
    font-size: 10px;
    color: var(--text-muted, #6b7280);
    flex-wrap: wrap;
}
.erp-breadcrumb a {
    color: var(--corp-blue, #1d4ed8);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.erp-breadcrumb a:hover { text-decoration: underline; }
.erp-breadcrumb .erp-breadcrumb__sep {
    font-size: 7px;
    opacity: 0.4;
    margin: 0 2px;
}
.erp-breadcrumb__current {
    color: var(--text, #0f1c2e);
    font-weight: 600;
}


/* ══════════════════════════════════════════════════════════════════
 *  FIN del Sistema de Diseño v3.0
 *  ════════════════════════════════════════════════════════════════ */
