/*
 * STX Design System V4 - Stripe Dashboard Theme - Component Overrides (Extended)
 *
 * Sobreescribe TODAS las clases con valores hardcoded en:
 *   main_v2.css, datagrid_azul.css, sidebar_v3.css, topbar_v2.css,
 *   login_v2.css, dashboard_v3.css, datepicker_azul.css, css.php,
 *   window/default.css, y iconos GIF legacy.
 *
 * Reglas:
 *   - No cambia HTML, JS, ni PHP
 *   - No modifica clases del framework: SOLO las re-estiliza
 *   - Reversible: quitar el <link> en top.php restaura el theme V3 azul
 *
 * Carga: DESPUES de main_v2.css en top.php.
 * Fecha: 2026-06-02
 */

/* =============================================================
   SECCION 1 - BOTONES BASE
   ============================================================= */
body.main-v2 .BUTTON_OK {
    background-color: var(--stx-success, #16b364) !important;
    box-shadow: 0 1px 2px rgba(22,179,100,0.16);
}
body.main-v2 .BUTTON_OK:hover {
    background-color: var(--stx-success-dark, #027a48) !important;
}
body.main-v2 .BUTTON_OK:focus-visible {
    box-shadow: 0 0 0 3px rgba(22,179,100,0.18);
}

body.main-v2 .BUTTON_NOK {
    background-color: var(--stx-danger, #f04438) !important;
    box-shadow: 0 1px 2px rgba(240,68,56,0.16);
}
body.main-v2 .BUTTON_NOK:hover {
    background-color: var(--stx-danger-dark, #b42318) !important;
}

body.main-v2 .BUTTON_:focus-visible {
    box-shadow: var(--shadow-focus, 0 0 0 3px rgba(99,91,255,0.15));
}

body.main-v2 .MINIBUTTON_OK {
    background-color: var(--stx-success, #16b364) !important;
}
body.main-v2 .MINIBUTTON_OK:hover {
    background-color: var(--stx-success-dark, #027a48) !important;
}

body.main-v2 .BUTTON_SMALL {
    background-color: var(--stx-gray-500, #697386) !important;
    color: #ffffff !important;
}
body.main-v2 .BUTTON_SMALL:hover {
    background-color: var(--stx-gray-600, #425466) !important;
}

body.main-v2 .BUTTON_EXCEL,
body.main-v2 .BUTTON_PDF,
body.main-v2 .BUTTON_TXT,
body.main-v2 .BUTTON_CSV,
body.main-v2 .BUTTON_XLS,
body.main-v2 .BUTTON_PRINT {
    background-color: var(--bg-muted, #f3f6fa) !important;
    color: var(--text-primary, #0a2540) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
}
body.main-v2 .BUTTON_EXCEL:hover,
body.main-v2 .BUTTON_PDF:hover,
body.main-v2 .BUTTON_TXT:hover,
body.main-v2 .BUTTON_CSV:hover,
body.main-v2 .BUTTON_XLS:hover,
body.main-v2 .BUTTON_PRINT:hover {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-color: var(--border-strong, #c1c9d2) !important;
}

/* =============================================================
   SECCION 2 - INPUTS / TEXTBOX
   ============================================================= */
body.main-v2 .TEXTBOX:focus {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: var(--shadow-focus, 0 0 0 3px rgba(99,91,255,0.15));
}
body.main-v2 .TEXTBOX::placeholder,
body.main-v2 input::placeholder,
body.main-v2 textarea::placeholder {
    color: var(--text-tertiary, #697386) !important;
    opacity: 1 !important;
}

body.main-v2 ::selection {
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
}

/* =============================================================
   SECCION 3 - ICONS (clase del framework)
   ============================================================= */
body.main-v2 .ICON:hover {
    background-color: var(--stx-primary-50, #efeefe);
    box-shadow: 0 1px 4px rgba(99,91,255,0.12);
}

/* =============================================================
   SECCION 4 - LIST_TABLE
   ============================================================= */
body.main-v2 .LIST_TABLE_HEAD {
    background: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
}
body.main-v2 .LIST_TABLE tr:hover td {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}

/* =============================================================
   SECCION 5 - DATAGRID
   ============================================================= */
.FILTER_HEADER {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}
.FILTER_TITLE {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    border-color: var(--border-default, #e3e8ee) !important;
    color: var(--text-primary, #0a2540) !important;
}
.FILTER_CONTENT {
    background-color: var(--bg-muted, #f3f6fa) !important;
    border-color: var(--border-default, #e3e8ee) !important;
}
.FILTER_BUTTON {
    background-color: var(--bg-muted, #f3f6fa) !important;
    border-color: var(--border-default, #e3e8ee) !important;
}

.GRID_TABLE {
    border-color: var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    overflow: hidden;
}
.GRID_HEADER,
.GRID_FREEZED_HEADER {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
}
.GRID_HEADER td,
.GRID_FREEZED_HEADER td {
    border-color: var(--border-default, #e3e8ee) !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    padding: 8px 10px !important;
}
.GRID_TITLE {
    color: var(--text-secondary, #425466) !important;
    font-weight: 600 !important;
}
.ODD_ROW { background-color: var(--bg-base, #ffffff) !important; }
.EVEN_ROW { background-color: var(--bg-subtle, #f6f9fc) !important; }
.ODD_ROW_REL { background-color: #fafaff !important; }
.EVEN_ROW_REL { background-color: var(--stx-primary-50, #efeefe) !important; }
.EVEN_ROW_CONSOLIDADO { background-color: var(--stx-success-light, #ecfdf3) !important; }
.ODD_ROW_CONSOLIDADO { background-color: #f4fdf7 !important; }
.GRID_CELL { font-size: 13px; }
.GRID_ERROR {
    background-color: var(--stx-danger-light, #fef3f2) !important;
    border-color: var(--stx-danger, #f04438) !important;
    color: var(--stx-danger-dark, #b42318) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    border-radius: var(--radius-sm, 6px) !important;
}
.PAGING {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-color: var(--border-default, #e3e8ee) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 11px !important;
}

/* DATATABLA legacy (css.php) */
.DATATABLA,
.DATATABLA tr,
.DATATABLA td {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}
.TITULOS_DATATABLA {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee) !important;
    padding: 8px 10px !important;
}
.FONDO_RENGLON1 { background-color: var(--bg-base, #ffffff) !important; }
.FONDO_RENGLON2 { background-color: var(--bg-subtle, #f6f9fc) !important; }
.FONDO_RENGLON1:hover td, .FONDO_RENGLON2:hover td {
    background-color: var(--stx-primary-50, #efeefe) !important;
}

/* =============================================================
   SECCION 6 - SIDEBAR V3 (REDISEÑO COMPLETO STRIPE)
   ============================================================= */
body.sidebar-v3 {
    --sb3-bg: #0a2540 !important;
    --sb3-bg-gradient-to: #0e2f54 !important;
    --sb3-bg-hover: rgba(255,255,255,0.06) !important;
    --sb3-bg-active: rgba(99,91,255,0.16) !important;
    --sb3-text: rgba(255,255,255,0.85) !important;
    --sb3-text-hover: #ffffff !important;
    --sb3-text-active: #a397f7 !important;
    --sb3-section-text: rgba(255,255,255,0.55) !important;
    --sb3-border: rgba(255,255,255,0.08) !important;
    --sb3-accent: #635bff !important;
    --sb3-accent-light: #a397f7 !important;
    --sb3-success: #16b364 !important;
    --sb3-warning: #f79009 !important;
    --sb3-danger: #f04438 !important;
    --sb3-radius: 6px !important;
    --sb3-font: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    --sb3-transition: 120ms ease !important;
    background: linear-gradient(180deg, #0a2540 0%, #0e2f54 100%) !important;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
    /* Anclar al viewport y permitir scroll cuando el contenido excede.
       sidebar_v3.css base trae min-height: 100vh + flex column. Aquí lo
       endurecemos a height: 100vh para que el botón "Cerrar sesión" en el
       footer (margin-top: auto) sea SIEMPRE accesible vía scroll interno
       cuando la altura del iframe no alcanza para mostrarlo todo. */
    height: 100vh !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body.sidebar-v3 .sidebar-v3__brand {
    padding: 16px 16px 12px !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    margin-bottom: 8px !important;
}
body.sidebar-v3 .sidebar-v3__brand-name {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    letter-spacing: -0.3px !important;
    line-height: 1.3 !important;
}
body.sidebar-v3 .sidebar-v3__brand-sub {
    font-size: 10px !important;
    color: rgba(255,255,255,0.55) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    margin-top: 2px !important;
    font-weight: 500 !important;
}

body.sidebar-v3 .sidebar-v3__search-input {
    background: rgba(255,255,255,0.07) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    border-radius: 6px !important;
    color: #ffffff !important;
    font-family: 'Inter', system-ui, sans-serif !important;
}
body.sidebar-v3 .sidebar-v3__search-input::placeholder {
    color: rgba(255,255,255,0.45) !important;
}
body.sidebar-v3 .sidebar-v3__search-input:focus {
    border-color: #635bff !important;
    background: rgba(255,255,255,0.1) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
}
body.sidebar-v3 .sidebar-v3__search-icon {
    color: rgba(255,255,255,0.4) !important;
}

body.sidebar-v3 .sidebar-v3__section-label,
body.sidebar-v3 .sidebar-v3__section-toggle {
    font-family: 'Inter', system-ui, sans-serif !important;
    color: rgba(255,255,255,0.55) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    font-weight: 600 !important;
}
body.sidebar-v3 .sidebar-v3__section-toggle:hover {
    color: #ffffff !important;
    background: rgba(255,255,255,0.06) !important;
}
body.sidebar-v3 .sidebar-v3__section[open] > .sidebar-v3__section-toggle {
    color: #ffffff !important;
}

body.sidebar-v3 .sidebar-v3__item,
body.sidebar-v3 .sidebar-v3__item:link,
body.sidebar-v3 .sidebar-v3__item:visited {
    color: rgba(255,255,255,0.85) !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    transition: background 120ms ease, color 120ms ease !important;
}
body.sidebar-v3 .sidebar-v3__item:hover {
    background: rgba(255,255,255,0.06) !important;
    color: #ffffff !important;
}
body.sidebar-v3 .sidebar-v3__item.is-active {
    background: rgba(99,91,255,0.16) !important;
    color: #ffffff !important;
}
body.sidebar-v3 .sidebar-v3__item.is-active::before {
    background: #635bff !important;
}

body.sidebar-v3 .sidebar-v3__icon {
    opacity: 0.8 !important;
    transition: opacity 120ms ease !important;
}
body.sidebar-v3 .sidebar-v3__item:hover .sidebar-v3__icon { opacity: 1 !important; }
body.sidebar-v3 .sidebar-v3__item.is-active .sidebar-v3__icon {
    opacity: 1 !important;
    color: #a397f7 !important;
}
body.sidebar-v3 .sidebar-v3__icon-img {
    opacity: 0.85 !important;
}
body.sidebar-v3 .sidebar-v3__item:hover .sidebar-v3__icon-img { opacity: 1 !important; }

body.sidebar-v3 .sidebar-v3__badge {
    background: #635bff !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.24) !important;
    border-radius: 9999px !important;
}
body.sidebar-v3 .sidebar-v3__badge--warning {
    background: #f79009 !important;
    box-shadow: 0 1px 2px rgba(247,144,9,0.24) !important;
}
body.sidebar-v3 .sidebar-v3__badge--danger {
    background: #f04438 !important;
    box-shadow: 0 1px 2px rgba(240,68,56,0.24) !important;
}

body.sidebar-v3 .sidebar-v3__divider {
    background: rgba(255,255,255,0.08) !important;
}
body.sidebar-v3 .sidebar-v3__footer {
    border-top: 1px solid rgba(255,255,255,0.08) !important;
}
body.sidebar-v3 .sidebar-v3__avatar {
    background: linear-gradient(135deg, rgba(99,91,255,0.3), rgba(163,151,247,0.2)) !important;
    color: #a397f7 !important;
    border: 1px solid rgba(99,91,255,0.2) !important;
    font-weight: 700 !important;
}
body.sidebar-v3 .sidebar-v3__user-name { color: #ffffff !important; }
body.sidebar-v3 .sidebar-v3__user-role { color: rgba(255,255,255,0.55) !important; }

body.sidebar-v3 .sidebar-v3__logout {
    color: #f04438 !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    border-radius: 6px !important;
}
body.sidebar-v3 .sidebar-v3__logout:hover {
    background: rgba(240,68,56,0.12) !important;
}

body.sidebar-v3::-webkit-scrollbar { width: 4px !important; }
body.sidebar-v3::-webkit-scrollbar-track { background: transparent !important; }
body.sidebar-v3::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15) !important;
    border-radius: 4px !important;
}
body.sidebar-v3::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25) !important;
}

/* =============================================================
   SECCION 7 - TOPBAR V2
   ============================================================= */
body.topbar-v2 > table,
body.topbar-v2 > div + table {
    border-bottom: 2px solid var(--stx-primary-600, #635bff) !important;
}
body.topbar-v2 #CONTENEDOR .MIDDLE {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-color: var(--border-default, #e3e8ee) !important;
}
body.topbar-v2 #CONTENEDOR .MIDDLE:hover {
    background-color: var(--bg-muted, #f3f6fa) !important;
}
body.topbar-v2 #CONTENEDOR .MIDDLE a {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    color: var(--text-secondary, #425466) !important;
}
body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER {
    background-color: var(--stx-primary-600, #635bff) !important;
    border-color: var(--stx-primary-600, #635bff) !important;
}
body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER a {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    color: #ffffff !important;
}

/* =============================================================
   SECCION 8 - FIELDSET / LEGEND / SECTION_TITLE / FIELDSET_TITLE
   ============================================================= */
body.main-v2 fieldset {
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
}
body.main-v2 legend {
    font-size: 14px;
    letter-spacing: -0.01em;
}
body.main-v2 .SECTION_TITLE { letter-spacing: -0.02em; }
body.main-v2 .FIELDSET_TITLE {
    color: var(--stx-primary-600, #635bff) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 600 !important;
}

/* =============================================================
   SECCION 9 - SCROLLBARS GLOBALES
   ============================================================= */
body.main-v2 {
    scrollbar-color: var(--border-strong, #c1c9d2) var(--bg-subtle, #f6f9fc);
    scrollbar-width: thin;
}
body.main-v2 ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
body.main-v2 ::-webkit-scrollbar-track {
    background: var(--bg-subtle, #f6f9fc) !important;
}
body.main-v2 ::-webkit-scrollbar-thumb {
    background: var(--border-strong, #c1c9d2) !important;
    border-radius: 5px;
    border: 2px solid var(--bg-subtle, #f6f9fc);
}
body.main-v2 ::-webkit-scrollbar-thumb:hover {
    background: var(--stx-gray-500, #697386) !important;
}

/* =============================================================
   SECCION 10 - LOGIN (login_v2.css)
   ============================================================= */
:root {
    --login-primary: #635bff;
    --login-primary-dark: #5147e2;
    --login-primary-light: #efeefe;
    --login-border: #e3e8ee;
    --login-bg: #f6f9fc;
    --login-shadow: 0 4px 24px rgba(99,91,255,0.12);
    --login-error: #f04438;
    --login-text: #0a2540;
    --login-text-muted: #425466;
}

body.theme-v2 {
    background: linear-gradient(145deg, #f6f9fc 0%, #f3f6fa 50%, #eff1f5 100%) !important;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
}

body.theme-v2 > form > div[align="center"] > table[width="429"] {
    background: #ffffff !important;
    box-shadow: 0 4px 24px rgba(99,91,255,0.12), 0 1px 2px rgba(48,49,61,0.04) !important;
    border-radius: 10px !important;
}

body.theme-v2 > form > div[align="center"] > table[width="429"] > tbody > tr:first-child td {
    background: linear-gradient(135deg, #635bff 0%, #7c3aed 100%) !important;
}

body.theme-v2 > form > div[align="center"] > table[width="429"] > tbody > tr:first-child td::after {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    letter-spacing: -0.02em !important;
    font-weight: 700 !important;
}

body.theme-v2 legend,
body.theme-v2 .FORM_TABLE_DARK,
body.theme-v2 a:link,
body.theme-v2 a:visited,
body.theme-v2 .ERROR,
body.theme-v2 .mensaje,
body.theme-v2 .error_content,
body.theme-v2 .error_content table[cellspacing] td,
body.theme-v2 .error_content table[cellspacing] ul,
body.theme-v2 .error_message,
body.theme-v2 .error_buttons input,
body.theme-v2 fieldset table[cellpadding="0"] td,
body.theme-v2 div[id="TOP_ERROR"] {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
}

body.theme-v2 legend {
    color: #635bff !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
}

body.theme-v2 .TEXTBOX {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    border: 1px solid #e3e8ee !important;
    border-radius: 6px !important;
    box-shadow: 0 1px 2px rgba(48,49,61,0.04) !important;
}
body.theme-v2 .TEXTBOX:focus {
    border-color: #635bff !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
}

body.theme-v2 .BUTTON_ {
    background-color: #635bff !important;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    font-weight: 500 !important;
    box-shadow: 0 2px 4px rgba(99,91,255,0.24) !important;
}
body.theme-v2 .BUTTON_:hover {
    background-color: #5147e2 !important;
    box-shadow: 0 4px 12px rgba(99,91,255,0.3) !important;
}

body.theme-v2 a:link,
body.theme-v2 a:visited {
    color: #635bff !important;
}
body.theme-v2 a:hover {
    color: #5147e2 !important;
}

body.theme-v2 .mensaje.alerta {
    background: #fffaeb !important;
    border-color: #fdb022 !important;
    color: #b54708 !important;
}
body.theme-v2 .mensaje.suspendido {
    background: #fef3f2 !important;
    border-color: #fecaca !important;
    color: #b42318 !important;
}

body.theme-v2 .error_nw,
body.theme-v2 .error_ne,
body.theme-v2 .error_n {
    background-color: #f04438 !important;
}
body.theme-v2 .error_close {
    background-color: #f04438 !important;
}
body.theme-v2 .error_buttons input {
    background-color: #635bff !important;
}

/* =============================================================
   SECCION 11 - DIALOGS / WINDOW
   ============================================================= */
body.main-v2 .overlay_dialog {
    background-color: #0a2540 !important;
    opacity: 0.45 !important;
}
body.main-v2 .dialog_n {
    background-color: var(--stx-primary-600, #635bff) !important;
    background-image: none !important;
}
body.main-v2 .dialog_title {
    color: #ffffff !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
}
body.main-v2 .dialog_content {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    background-color: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
}
body.main-v2 .dialog_close,
body.main-v2 .dialog_close::after {
    color: rgba(255,255,255,0.9) !important;
}
body.main-v2 .dialog_close:hover {
    background: rgba(255,255,255,0.15) !important;
}

/* =============================================================
   SECCION 12 - ERROR OVERLAY
   ============================================================= */
body.main-v2 .overlay_error {
    background-color: #0a2540 !important;
    opacity: 0.45 !important;
}
body.main-v2 .error_nw,
body.main-v2 .error_ne,
body.main-v2 .error_n {
    background-image: none !important;
    background-color: var(--stx-danger, #f04438) !important;
}
body.main-v2 .error_content {
    background-color: #ffffff !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    color: var(--text-primary, #0a2540) !important;
}
body.main-v2 .error_buttons input {
    background-color: var(--stx-primary-600, #635bff) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 500 !important;
    border-radius: var(--radius-sm, 6px) !important;
}
body.main-v2 .error_buttons input:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
}
body.main-v2 .error_close {
    background-color: var(--stx-danger, #f04438) !important;
}

/* =============================================================
   SECCION 13 - CSS.PHP LEGACY CLASES + LINKS
   ============================================================= */
body.main-v2 a:link,
body.main-v2 a:visited {
    color: var(--text-link, #635bff) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}
body.main-v2 a:hover {
    color: var(--stx-primary-700, #5147e2) !important;
}

body.main-v2 .CHECK_LIST_OUT {
    background-color: var(--bg-muted, #f3f6fa) !important;
    border-color: var(--border-default, #e3e8ee) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}
body.main-v2 .CHECK_LIST_OVER {
    background-color: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}

body.main-v2 .DYNAMIC_LIST {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    background-color: var(--bg-base, #ffffff) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}
body.main-v2 .DYNAMIC_LIST_HEADER {
    background-image: none !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 600 !important;
}
body.main-v2 .DYNAMIC_LIST_OVER {
    background-color: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}
body.main-v2 .DYNAMIC_LIST_OUT_A {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}
body.main-v2 .DYNAMIC_LIST_OUT_B {
    background-color: var(--bg-muted, #f3f6fa) !important;
    color: var(--text-secondary, #425466) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}
body.main-v2 .DYNAMIC_LIST_ELEMENT {
    border-color: var(--border-default, #e3e8ee) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}
/* Asegurar que TODA fila/celda del dynamic list reciba clicks */
body.main-v2 .DYNAMIC_LIST tr,
body.main-v2 .DYNAMIC_LIST td {
    pointer-events: auto !important;
}

/* =============================================================
   SECCION 14 - TAB_MIDDLE_*
   ============================================================= */
body.main-v2 .TAB_MIDDLE_OFF {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}
body.main-v2 .TAB_MIDDLE_OFF:hover {
    background-color: var(--bg-muted, #f3f6fa) !important;
    color: var(--text-primary, #0a2540) !important;
}
body.main-v2 .TAB_MIDDLE_ON {
    background-color: var(--bg-base, #ffffff) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 600 !important;
    border-bottom: 2px solid var(--stx-primary-600, #635bff) !important;
}

/* =============================================================
   SECCION 15 - DATEPICKER
   ============================================================= */
.calendar {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06)) !important;
    background: #ffffff !important;
}
.calendar thead {
    background: var(--bg-subtle, #f6f9fc) !important;
}
.calendar thead .title {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}
.calendar thead .weekend {
    color: var(--stx-danger, #f04438) !important;
    font-weight: 600 !important;
}
.calendar tbody td.weekend {
    color: var(--stx-danger, #f04438) !important;
}
.calendar tbody td.selected {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border-radius: 4px !important;
}
.calendar tbody td.hilite {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    border-radius: 4px !important;
}
.calendar tbody td.today {
    color: var(--stx-primary-600, #635bff) !important;
    font-weight: 700 !important;
}
.calendar tfoot .footrow {
    background: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
}
.calendar tfoot .hilite {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}
.calendar tfoot .active {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
}

/* =============================================================
   SECCION 16 - ICONOS GIF LEGACY (armonización vía CSS filter)
   ============================================================= */
body.main-v2 img[src$=".gif"] {
    filter: brightness(0.92) saturate(0.95);
    opacity: 0.9;
    transition: filter 0.15s ease, opacity 0.15s ease;
}

body.main-v2 img[src*="/iconos/comun/lupa.gif"],
body.main-v2 img[src*="/iconos/comun/editar.gif"],
body.main-v2 img[src*="/iconos/comun/agregar.gif"],
body.main-v2 img[src*="/iconos/comun/cerrar.gif"],
body.main-v2 img[src*="/iconos/comun/imprimir.gif"],
body.main-v2 img[src*="/iconos/comun/documentos.gif"],
body.main-v2 img[src*="/iconos/comun/copiar.gif"],
body.main-v2 img[src*="/iconos/comun/recargar.gif"],
body.main-v2 img[src*="/iconos/comun/ok.gif"],
body.main-v2 img[src*="/iconos/comun/ver.gif"],
body.main-v2 img[src*="/iconos/comun/buscar.gif"] {
    filter: brightness(0.78) contrast(1.15) saturate(0.85) hue-rotate(-5deg) !important;
    opacity: 0.78 !important;
    transition: filter 0.15s ease, opacity 0.15s ease, transform 0.12s ease !important;
}
body.main-v2 img[src*="/iconos/comun/lupa.gif"]:hover,
body.main-v2 img[src*="/iconos/comun/editar.gif"]:hover,
body.main-v2 img[src*="/iconos/comun/agregar.gif"]:hover,
body.main-v2 img[src*="/iconos/comun/cerrar.gif"]:hover,
body.main-v2 img[src*="/iconos/comun/imprimir.gif"]:hover,
body.main-v2 img[src*="/iconos/comun/documentos.gif"]:hover,
body.main-v2 img[src*="/iconos/comun/copiar.gif"]:hover {
    filter: brightness(0.6) contrast(1.3) saturate(1.2) hue-rotate(0deg) !important;
    opacity: 1 !important;
    transform: scale(1.08) !important;
    cursor: pointer !important;
}

body.main-v2 img[src*="/iconos/comun/calendario.gif"],
body.main-v2 img[src*="/iconos/calendar"] {
    filter: brightness(0.7) contrast(1.2) saturate(0.9) hue-rotate(-10deg) !important;
    opacity: 0.85 !important;
}

body.main-v2 img[src*="/botones/boton_print.gif"],
body.main-v2 img[src*="/botones/boton_save.gif"],
body.main-v2 img[src*="/botones/boton_excel.gif"],
body.main-v2 img[src*="/botones/boton_pdf.gif"],
body.main-v2 img[src*="/botones/boton_ok.gif"],
body.main-v2 img[src*="/botones/boton_nok.gif"] {
    filter: brightness(0.85) contrast(1.05) saturate(0.95) !important;
    opacity: 0.92 !important;
}

body.main-v2 img[src*="tree_close.gif"],
body.main-v2 img[src*="tree_open.gif"],
body.main-v2 img[src*="tree_line.gif"],
body.main-v2 img[src*="tree_leaf.gif"],
body.main-v2 img[src*="tree_branch.gif"] {
    filter: brightness(0.9) contrast(1) saturate(0.7) !important;
    opacity: 0.6 !important;
}

body.main-v2 img[src*="tool_menu.gif"],
body.main-v2 img[src*="tool_filter.gif"],
body.main-v2 img[src*="tool_search.gif"] {
    filter: brightness(0.78) contrast(1.1) saturate(0.85) !important;
    opacity: 0.85 !important;
}

body.main-v2 img[src*="/iconos/error"],
body.main-v2 img[src*="error.gif"] {
    filter: brightness(0.92) contrast(1.05) saturate(1.05) !important;
    opacity: 0.95 !important;
}

/* =============================================================
   SECCION 17 - DASHBOARD V3 (refinamientos KPI)
   ============================================================= */
body.main-v2 .dashboard-v3__kpi-icon--blue {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-600, #635bff) !important;
}
body.main-v2 .dashboard-v3__kpi-icon--green {
    background: var(--stx-success-light, #ecfdf3) !important;
    color: var(--stx-success-dark, #027a48) !important;
}
body.main-v2 .dashboard-v3__kpi-icon--warning {
    background: var(--stx-warning-light, #fffaeb) !important;
    color: var(--stx-warning-dark, #b54708) !important;
}
body.main-v2 .dashboard-v3__kpi-icon--danger {
    background: var(--stx-danger-light, #fef3f2) !important;
    color: var(--stx-danger-dark, #b42318) !important;
}

/* =============================================================
   SECCION 18 - HR
   ============================================================= */
body.main-v2 hr {
    border: none !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
    margin: 12px 0 !important;
}

/* =============================================================
   SECCION 19 - VERSION FOOTERS
   ============================================================= */
body.main-v2 [class*="version-footer"],
body.main-v2 [class*="-version"] {
    color: var(--text-tertiary, #697386) !important;
    font-family: 'JetBrains Mono', Consolas, monospace !important;
    font-size: 10.5px !important;
}

/* =============================================================
   SECCION 20 - PANEL DOCUMENTOS (lista compacta con SVG por tipo)
   Usado en /system/bin/section/operacion/panel.php
   ============================================================= */
body.main-v2 .stx-doc-panel {
    padding: 24px 28px 40px;
    max-width: 1400px;
}

body.main-v2 .stx-doc-section {
    margin-bottom: 24px;
}

body.main-v2 .stx-doc-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 0;
}

body.main-v2 .stx-doc-section-title {
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #425466);
}

body.main-v2 .stx-doc-section-count {
    font-size: 11px;
    color: var(--text-tertiary, #697386);
    background: var(--bg-muted, #f3f6fa);
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 500;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

body.main-v2 .stx-doc-section-divider {
    flex: 1;
    height: 1px;
    background: var(--border-default, #e3e8ee);
}

body.main-v2 .stx-doc-list {
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
}

body.main-v2 .stx-doc-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-default, #e3e8ee);
    transition: background 120ms ease;
    font-family: var(--font-sans, 'Inter', sans-serif);
    color: var(--text-primary, #0a2540);
}
body.main-v2 .stx-doc-list-item:last-child {
    border-bottom: none;
}
body.main-v2 .stx-doc-list-item:hover {
    background: var(--bg-hover, #efeefe);
}

body.main-v2 .stx-doc-list-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: all 120ms ease;
}

body.main-v2 .stx-doc-list-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

body.main-v2 .stx-doc-list-content {
    flex: 1;
    min-width: 0;
}

body.main-v2 .stx-doc-list-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary, #0a2540);
    line-height: 1.3;
}

body.main-v2 .stx-doc-list-desc {
    font-size: 11px;
    color: var(--text-tertiary, #697386);
    margin-top: 2px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    letter-spacing: 0.02em;
}

body.main-v2 .stx-doc-list-chevron {
    color: var(--text-tertiary, #697386);
    opacity: 0.3;
    transition: opacity 120ms ease, transform 120ms ease;
    flex-shrink: 0;
}
body.main-v2 .stx-doc-list-item:hover .stx-doc-list-chevron {
    opacity: 1;
    color: var(--stx-primary-600, #635bff);
    transform: translateX(2px);
}

/* Colores semanticos por tipo de documento */
body.main-v2 .stx-doc-color-purple .stx-doc-list-icon {
    background: rgba(99, 91, 255, 0.1);
    color: var(--stx-primary-600, #635bff);
}
body.main-v2 .stx-doc-color-success .stx-doc-list-icon {
    background: rgba(22, 179, 100, 0.1);
    color: var(--stx-success, #16b364);
}
body.main-v2 .stx-doc-color-warning .stx-doc-list-icon {
    background: rgba(247, 144, 9, 0.1);
    color: var(--stx-warning, #f79009);
}
body.main-v2 .stx-doc-color-danger .stx-doc-list-icon {
    background: rgba(240, 68, 56, 0.1);
    color: var(--stx-danger, #f04438);
}
body.main-v2 .stx-doc-color-info .stx-doc-list-icon {
    background: rgba(0, 115, 230, 0.1);
    color: var(--stx-info, #0073e6);
}
body.main-v2 .stx-doc-color-gray .stx-doc-list-icon {
    background: rgba(105, 115, 134, 0.1);
    color: var(--text-tertiary, #697386);
}

/* Selector de vista (Tiles / Lista / Cards) */
body.main-v2 .stx-doc-switcher {
    display: inline-flex;
    gap: 2px;
    background: var(--bg-muted, #f3f6fa);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-default, #e3e8ee);
    margin: 0 0 18px;
}
body.main-v2 .stx-doc-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: var(--text-secondary, #425466);
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 120ms ease;
}
body.main-v2 .stx-doc-switcher-btn:hover {
    color: var(--text-primary, #0a2540);
    background: rgba(255, 255, 255, 0.6);
}
body.main-v2 .stx-doc-switcher-btn.is-active {
    background: var(--bg-base, #ffffff);
    color: var(--stx-primary-600, #635bff);
    box-shadow: 0 1px 2px rgba(48,49,61,0.06);
    font-weight: 600;
}
body.main-v2 .stx-doc-switcher-btn svg {
    flex-shrink: 0;
}

/* Mostrar/ocultar layouts por data-layout */
body.main-v2 .stx-doc-panel[data-layout="list"] .stx-doc-tiles,
body.main-v2 .stx-doc-panel[data-layout="list"] .stx-doc-cards { display: none; }
body.main-v2 .stx-doc-panel[data-layout="tiles"] .stx-doc-list,
body.main-v2 .stx-doc-panel[data-layout="tiles"] .stx-doc-cards { display: none; }
body.main-v2 .stx-doc-panel[data-layout="cards"] .stx-doc-list,
body.main-v2 .stx-doc-panel[data-layout="cards"] .stx-doc-tiles { display: none; }

/* Vista TILES */
body.main-v2 .stx-doc-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
body.main-v2 .stx-doc-tile {
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 10px;
    padding: 16px 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 120ms ease;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    font-family: var(--font-sans, 'Inter', sans-serif);
}
body.main-v2 .stx-doc-tile:hover {
    border-color: var(--stx-primary-600, #635bff);
    background: var(--bg-hover, #efeefe);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
}
body.main-v2 .stx-doc-tile-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    transition: transform 120ms ease;
}
body.main-v2 .stx-doc-tile:hover .stx-doc-tile-icon {
    transform: scale(1.08);
}
body.main-v2 .stx-doc-tile-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}
body.main-v2 .stx-doc-tile-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-primary, #0a2540);
    line-height: 1.3;
}
body.main-v2 .stx-doc-color-purple .stx-doc-tile-icon { background: rgba(99,91,255,0.1); color: var(--stx-primary-600, #635bff); }
body.main-v2 .stx-doc-color-success .stx-doc-tile-icon { background: rgba(22,179,100,0.1); color: var(--stx-success, #16b364); }
body.main-v2 .stx-doc-color-warning .stx-doc-tile-icon { background: rgba(247,144,9,0.1); color: var(--stx-warning, #f79009); }
body.main-v2 .stx-doc-color-danger .stx-doc-tile-icon { background: rgba(240,68,56,0.1); color: var(--stx-danger, #f04438); }
body.main-v2 .stx-doc-color-info .stx-doc-tile-icon { background: rgba(0,115,230,0.1); color: var(--stx-info, #0073e6); }
body.main-v2 .stx-doc-color-gray .stx-doc-tile-icon { background: rgba(105,115,134,0.1); color: var(--text-tertiary, #697386); }

/* Vista CARDS */
body.main-v2 .stx-doc-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
body.main-v2 .stx-doc-card {
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 12px;
    padding: 18px 18px 16px;
    cursor: pointer;
    transition: all 120ms ease;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    display: flex;
    gap: 14px;
    align-items: flex-start;
    font-family: var(--font-sans, 'Inter', sans-serif);
}
body.main-v2 .stx-doc-card:hover {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
    transform: translateY(-1px);
}
body.main-v2 .stx-doc-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
body.main-v2 .stx-doc-card-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}
body.main-v2 .stx-doc-card-body { flex: 1; min-width: 0; }
body.main-v2 .stx-doc-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #0a2540);
    letter-spacing: -0.01em;
}
body.main-v2 .stx-doc-card-tag {
    display: inline-block;
    margin-top: 8px;
    padding: 1px 8px;
    border-radius: 4px;
    background: var(--bg-muted, #f3f6fa);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 10.5px;
    color: var(--text-secondary, #425466);
    font-weight: 500;
    letter-spacing: 0.02em;
}
body.main-v2 .stx-doc-color-purple .stx-doc-card-icon { background: rgba(99,91,255,0.1); color: var(--stx-primary-600, #635bff); }
body.main-v2 .stx-doc-color-success .stx-doc-card-icon { background: rgba(22,179,100,0.1); color: var(--stx-success, #16b364); }
body.main-v2 .stx-doc-color-warning .stx-doc-card-icon { background: rgba(247,144,9,0.1); color: var(--stx-warning, #f79009); }
body.main-v2 .stx-doc-color-danger .stx-doc-card-icon { background: rgba(240,68,56,0.1); color: var(--stx-danger, #f04438); }
body.main-v2 .stx-doc-color-info .stx-doc-card-icon { background: rgba(0,115,230,0.1); color: var(--stx-info, #0073e6); }
body.main-v2 .stx-doc-color-gray .stx-doc-card-icon { background: rgba(105,115,134,0.1); color: var(--text-tertiary, #697386); }

/* =============================================================
   SECCION 21 - SIDEBAR V2 LEGACY (override Stripe dark navy)
   La sidebar V2 se usa cuando V3_UI NO está activo.
   Renderizada por display::toolbar() en system/bin/section/main/toolbar.php.
   ============================================================= */

/* Scroll vertical interno cuando el contenido excede la altura del iframe.
   Sin esto, en pantallas pequeñas (laptops 600-800px) la sección
   "INFORMACIÓN DE SESIÓN" con "Sucursal" y "Cerrar sesión" queda fuera de
   la zona visible — el usuario tenía que hacer zoom out para acceder a ellos.
   Fix:
   - body anclado a 100vh para que el contenido tenga un bound de altura.
   - overflow-y: auto activa el scroll interno cuando excede.
   - box-sizing: border-box para que ningún padding rompa el bound.
   - La <TABLE WIDTH=100% HEIGHT=100%> raíz se libera a min-height: 100%
     para que pueda crecer y empujar el contenido al scroll del body. */
body.sidebar-v2 {
    background: linear-gradient(180deg, #0a2540 0%, #0e2f54 100%) !important;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
    color: rgba(255,255,255,0.85);
    height: 100vh !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* La tabla raíz: liberar HEIGHT=100% inline para que crezca con el contenido
   y deje que el body active el scroll cuando excede el viewport. */
body.sidebar-v2 > table {
    height: auto !important;
    min-height: 100% !important;
}

body.sidebar-v2 > table,
body.sidebar-v2 > table > tbody > tr > td[bgcolor] {
    background: transparent !important;
}

/* Headers de secciones colapsables (INFORMACIÓN DE SESIÓN, etc) */
body.sidebar-v2 div[id$="_OFF"] td[background],
body.sidebar-v2 div[id$="_ON"] td[background] {
    background-color: rgba(255, 255, 255, 0.04) !important;
    background-image: none !important;
    height: auto !important;
    padding: 8px 14px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    transition: background-color 120ms ease;
    cursor: pointer;
}
body.sidebar-v2 div[id$="_OFF"] td[background]:hover,
body.sidebar-v2 div[id$="_ON"] td[background]:hover {
    background-color: rgba(99, 91, 255, 0.12) !important;
}
body.sidebar-v2 div[id$="_OFF"] td b,
body.sidebar-v2 div[id$="_ON"] td b {
    font-family: 'Inter', 'Segoe UI', sans-serif !important;
    font-size: 10.5px !important;
    font-weight: 600 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.65) !important;
}
body.sidebar-v2 div[id$="_ON"] td b {
    color: #ffffff !important;
}
body.sidebar-v2 div[id$="_ON"] td[background]::before {
    content: "\25BE\00a0";
    font-size: 10px;
    color: #a397f7;
}
body.sidebar-v2 div[id$="_OFF"] td[background]::before {
    content: "\25B8\00a0";
    font-size: 10px;
    color: rgba(255,255,255,0.4);
}

/* Contenido expandido — items del menú */
body.sidebar-v2 div[id$="_DETAIL"] {
    background: transparent !important;
    padding: 6px 8px !important;
}
body.sidebar-v2 div[id$="_DETAIL"] > div {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}
body.sidebar-v2 div[id$="_DETAIL"] table {
    background: transparent !important;
    width: 100%;
}
body.sidebar-v2 div[id$="_DETAIL"] table tr {
    transition: background-color 120ms ease;
}
body.sidebar-v2 div[id$="_DETAIL"] table tr:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}
body.sidebar-v2 div[id$="_DETAIL"] table td {
    font-family: 'Inter', 'Segoe UI', sans-serif !important;
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 5px 8px !important;
    border: none !important;
}
body.sidebar-v2 div[id$="_DETAIL"] a:link,
body.sidebar-v2 div[id$="_DETAIL"] a:visited {
    color: rgba(255, 255, 255, 0.85) !important;
    font-family: 'Inter', 'Segoe UI', sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    text-decoration: none !important;
}
body.sidebar-v2 div[id$="_DETAIL"] a:hover {
    color: #ffffff !important;
    text-decoration: none !important;
}

/* Información de sesión — card especial.
   Padding reducido para minimizar el "extra height" de la sección,
   facilita que en pantallas pequeñas siga visible o requiera menos scroll
   para llegar al botón "Cerrar sesión" debajo. */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    margin: 4px 6px !important;
    padding: 6px 8px !important;
}
/* Table responsive: convertir tablas legacy en bloques flex que wrappean */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] table {
    width: 100% !important;
    display: block !important;
    table-layout: auto !important;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tbody {
    display: block !important;
    width: 100% !important;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: baseline !important;
    gap: 4px 8px !important;
    padding: 3px 0 !important;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr:last-child {
    border-bottom: none;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] table td {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 11px !important;
    line-height: 1.4 !important;
    padding: 0 !important;
    border: none !important;
    display: inline-block !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 0 1 auto !important;
}
/* La primera celda (label) ocupa width fijo, la segunda crece */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr > td:first-child {
    flex: 0 0 70px !important;
    color: rgba(255,255,255,0.55) !important;
    font-weight: 500 !important;
    font-size: 10.5px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr > td:nth-child(2),
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr > td:last-child {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] b {
    color: #ffffff !important;
    font-weight: 600 !important;
    font-family: 'Inter', sans-serif !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    display: inline !important;
}
/* Sobreescribir STYLE inline hardcoded del PHP que tiene
   "overflow: hidden; width: 75-95px; white-space: nowrap; text-overflow: ellipsis"
   en cada DIV de valores (NOMBRE, CORREO, PERFIL, etc.).
   Forzamos wrap completo via selectores muy especificos + !important. */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] td > div,
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] td > nobr > div,
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] nobr > div,
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] div[style*="ellipsis"],
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] div[style*="nowrap"] {
    overflow: visible !important;
    width: auto !important;
    max-width: 100% !important;
    white-space: normal !important;
    text-overflow: clip !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    display: block !important;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] nobr {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    display: inline !important;
}
/* TD con width inline en estilo tambien debe ser flexible */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] td[style*="width"] {
    width: auto !important;
    max-width: 100% !important;
}
/* Inputs y selects en INFORMACION_DETAIL deben usar ancho completo */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] input[type="text"],
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Inputs y selects en sidebar */
body.sidebar-v2 input[type="text"],
body.sidebar-v2 input[type="password"],
body.sidebar-v2 input.TEXTBOX {
    font-family: 'Inter', sans-serif !important;
    background: rgba(255,255,255,0.07) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 5px !important;
    padding: 5px 8px !important;
    font-size: 11.5px !important;
    color: #ffffff !important;
}
body.sidebar-v2 input[type="text"]::placeholder { color: rgba(255,255,255,0.4) !important; }
body.sidebar-v2 input[type="text"]:focus,
body.sidebar-v2 input.TEXTBOX:focus {
    border-color: #635bff !important;
    background: rgba(255,255,255,0.1) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}
body.sidebar-v2 select {
    font-family: 'Inter', sans-serif !important;
    background: rgba(255,255,255,0.07) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 5px !important;
    padding: 4px 6px !important;
    font-size: 11.5px !important;
    color: #ffffff !important;
}
body.sidebar-v2 select option { background: #0a2540; color: #ffffff; }

/* Logout / cerrar sesión */
body.sidebar-v2 a[href*="logout"],
body.sidebar-v2 a[onclick*="logout"],
body.sidebar-v2 a[onclick*="LOGOUT"] {
    color: #f04438 !important;
    font-weight: 500 !important;
}
body.sidebar-v2 a[href*="logout"]:hover,
body.sidebar-v2 a[onclick*="logout"]:hover {
    color: #ff6961 !important;
}

/* Avatar/foto del usuario si tiene */
body.sidebar-v2 img.AVATAR {
    border-radius: 50%;
    border: 2px solid rgba(99,91,255,0.3);
}

/* Iconos legacy del sidebar — preservar tal cual (no aplicar invert agresivo) */
body.sidebar-v2 img[src*=".gif"] { opacity: 0.9; }

/* Iconos SVG inline del sidebar V2 (Lucide, generados por stx_sidebar_gif_to_svg()).
   Siluetas detalladas con stroke, no "plastas" — se distingue cada icono. */
body.sidebar-v2 .stx-sidebar-icon {
    width: 18px;
    height: 18px;
    display: block;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.78);
    transition: color 120ms ease, transform 120ms ease;
    flex-shrink: 0;
}
body.sidebar-v2 div[id$="_DETAIL"] table tr:hover .stx-sidebar-icon {
    color: #ffffff;
    transform: scale(1.08);
}
/* Item de cerrar sesion - acentuar en rojo */
body.sidebar-v2 a[onclick*="logout"] + .stx-sidebar-icon,
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr:last-child .stx-sidebar-icon {
    color: rgba(240, 68, 56, 0.85);
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr:last-child:hover .stx-sidebar-icon {
    color: #f04438;
}

/* Scrollbar */
body.sidebar-v2::-webkit-scrollbar { width: 6px; }
body.sidebar-v2::-webkit-scrollbar-track { background: transparent; }
body.sidebar-v2::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}
body.sidebar-v2::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* ---- Responsive sidebar V2 (móvil / frames angostos) ----
   El frame TOOLBAR es fijo (~200px); en pantallas chicas el HTML legacy
   (TDs con WIDTH fijo, NOBR, floats) rompía el layout: iconos huérfanos
   en su propia línea, filas espaciadoras con gaps gigantes y el bloque
   de sucursal desbordando. */

/* ALTURA: el height:100vh fijo (regla base arriba) corta el fondo cuando
   el contenido excede el viewport — el final del sidebar (logout) quedaba
   sobre fondo blanco con texto invisible. El body debe CRECER con el
   contenido y dejar que el frame haga el scroll. El gradiente se ancla al
   viewport (fixed) para que nunca se corte a blanco. */
body.sidebar-v2 {
    height: auto !important;
    min-height: 100vh !important;
    background-attachment: fixed !important;
}

/* Celdas de icono (TD con atributo WIDTH=20/24): no deben tomar el flex
   de 70px reservado a los labels — el icono quedaba solo en una línea. */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr > td[width] {
    flex: 0 0 auto !important;
}

/* Fila con icono SVG (Cerrar sesión): icono + texto en UNA sola línea */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr:has(.stx-sidebar-icon) {
    flex-wrap: nowrap !important;
    align-items: center !important;
}
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr:has(.stx-sidebar-icon) > td:last-child {
    flex: 1 1 auto !important;
}

/* Filas espaciadoras vacías del HTML legacy: colapsar (causaban el hueco
   gigante entre la info de sesión y el botón de cerrar sesión) */
body.sidebar-v2 div[id="TOOL_INFORMACION_DETAIL"] tr:not(:has(a, b, div, svg, select, input, img)) {
    display: none !important;
}

/* Bloque Sucursal (#SUCURSAL): fluido dentro del ancho del frame */
body.sidebar-v2 #SUCURSAL {
    min-width: 0 !important;
    max-width: 100% !important;
}
body.sidebar-v2 #SUCURSAL select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
body.sidebar-v2 #SUCURSAL svg {
    color: rgba(255, 255, 255, 0.6);
    transition: color 120ms ease;
}
body.sidebar-v2 #SUCURSAL svg:hover {
    color: #f04438;
}

/* Selects e inputs de cualquier sección del sidebar: nunca desbordar */
body.sidebar-v2 div[id$="_DETAIL"] select,
body.sidebar-v2 div[id$="_DETAIL"] input[type="text"] {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* =============================================================
   SECCION 22 - SVG ICONS V4 (inyectados por stx_icon_replacer.js)
   ============================================================= */
.stx-svg-icon {
    display: inline-block;
    vertical-align: middle;
    transition: color 120ms ease, transform 120ms ease, opacity 120ms ease;
}
.stx-svg-primary { color: var(--stx-primary-600, #635bff); }
.stx-svg-success { color: var(--stx-success, #16b364); }
.stx-svg-warning { color: var(--stx-warning, #f79009); }
.stx-svg-danger  { color: var(--stx-danger, #f04438); }
.stx-svg-info    { color: var(--stx-info, #0073e6); }
.stx-svg-gray    { color: var(--text-tertiary, #697386); }

/* Hover en wrapper .ICON */
body.main-v2 .ICON:hover .stx-svg-icon {
    transform: scale(1.06);
    filter: drop-shadow(0 2px 4px rgba(99,91,255,0.18));
}

/* GIFs no mapeados — oscurecer ligeramente para integrar */
body.main-v2 .stx-gif-unmapped {
    filter: brightness(0.85) saturate(0.9);
    opacity: 0.85;
}

/* =============================================================
   SECCION 23 - OVERRIDE BGCOLOR INLINE LEGACY
   Pantallas heredadas tienen <TABLE BGCOLOR="#FFFFFF"> o "#CCCCCC"
   que rompen el theme. Forzamos transparencia o paleta Stripe.
   ============================================================= */
body.main-v2 table[bgcolor="#FFFFFF"],
body.main-v2 table[bgcolor="white"],
body.main-v2 TABLE[bgcolor="#FFFFFF"] {
    background-color: var(--bg-base, #ffffff) !important;
    border-radius: var(--radius-md, 8px);
}

/* Divisor #CCCCCC (con spacer.gif) → línea sutil Stripe */
body.main-v2 td[bgcolor="#CCCCCC"],
body.main-v2 TD[bgcolor="#CCCCCC"] {
    background-color: var(--border-default, #e3e8ee) !important;
    height: 1px;
}

/* Otros bgcolor amarillentos legacy */
body.main-v2 td[bgcolor="#FFFFE1"],
body.main-v2 td[bgcolor="#FFFFC0"] {
    background-color: var(--stx-warning-light, #fffaeb) !important;
}

/* =============================================================
   SECCION 24 - CLASES LEGACY EXTRA
   ============================================================= */
body.main-v2 .NOUN {
    color: var(--stx-primary-600, #635bff) !important;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-weight: 600;
}
body.main-v2 .ERROR {
    color: var(--stx-danger, #f04438) !important;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-weight: 500;
}
body.main-v2 .CHECK {
    accent-color: var(--stx-primary-600, #635bff);
    margin-right: 6px;
}
body.main-v2 .FORM_TABLE_DARK {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-weight: 500;
}
body.main-v2 .FORM_TABLE_LIGHT {
    background-color: var(--bg-base, #ffffff) !important;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

/* =============================================================
   SECCION 25 - INPUTS NATIVOS (checkbox, radio, file)
   ============================================================= */
body.main-v2 input[type="checkbox"],
body.main-v2 input[type="radio"] {
    accent-color: var(--stx-primary-600, #635bff);
    cursor: pointer;
}
body.main-v2 input[type="file"] {
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 12px;
    color: var(--text-secondary, #425466);
}
body.main-v2 input[type="file"]::file-selector-button {
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-weight: 500;
    background: var(--stx-primary-600, #635bff);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm, 6px);
    padding: 6px 12px;
    margin-right: 10px;
    cursor: pointer;
    transition: background 120ms ease;
}
body.main-v2 input[type="file"]::file-selector-button:hover {
    background: var(--stx-primary-700, #5147e2);
}

/* =============================================================
   SECCION 26 - INPUTS GENÉRICOS sin clase (TEXTBOX implícito)
   Muchos PHPs usan <input type="text"> sin clase. Estilizamos.
   ============================================================= */
body.main-v2 input[type="text"]:not(.TEXTBOX):not([class*="sb"]):not([class*="topbar"]),
body.main-v2 input[type="password"]:not(.TEXTBOX),
body.main-v2 input[type="number"]:not(.TEXTBOX),
body.main-v2 input[type="email"]:not(.TEXTBOX),
body.main-v2 input[type="search"]:not(.TEXTBOX),
body.main-v2 input[type="date"]:not(.TEXTBOX),
body.main-v2 textarea:not(.TEXTBOX) {
    font-family: var(--font-sans, 'Inter', sans-serif);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: var(--radius-sm, 6px);
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--text-primary, #0a2540);
    background: var(--bg-base, #ffffff);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
body.main-v2 input[type="text"]:not(.TEXTBOX):focus,
body.main-v2 input[type="password"]:not(.TEXTBOX):focus,
body.main-v2 input[type="number"]:not(.TEXTBOX):focus,
body.main-v2 input[type="email"]:not(.TEXTBOX):focus,
body.main-v2 input[type="search"]:not(.TEXTBOX):focus,
body.main-v2 input[type="date"]:not(.TEXTBOX):focus,
body.main-v2 textarea:not(.TEXTBOX):focus {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
    outline: none;
}

/* Selects nativos */
body.main-v2 select:not([class*="sb"]):not([class*="topbar"]) {
    font-family: var(--font-sans, 'Inter', sans-serif);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: var(--radius-sm, 6px);
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--text-primary, #0a2540);
    background: var(--bg-base, #ffffff);
}
body.main-v2 select:not([class*="sb"]):focus {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
    outline: none;
}

/* Submit/button inputs sin clase — feos por defecto */
body.main-v2 input[type="submit"]:not([class]),
body.main-v2 input[type="button"]:not([class]),
body.main-v2 button:not([class]) {
    font-family: var(--font-sans, 'Inter', sans-serif);
    background: var(--stx-primary-600, #635bff);
    color: #ffffff;
    border: 1px solid var(--stx-primary-600, #635bff);
    border-radius: var(--radius-sm, 6px);
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(99,91,255,0.16);
    transition: background 120ms ease;
}
body.main-v2 input[type="submit"]:not([class]):hover,
body.main-v2 input[type="button"]:not([class]):hover,
body.main-v2 button:not([class]):hover {
    background: var(--stx-primary-700, #5147e2);
}

/* =============================================================
   SECCION 27 - PAGING (links + selects + inputs)
   ============================================================= */
.PAGING a {
    color: var(--stx-primary-600, #635bff) !important;
    text-decoration: none !important;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 120ms ease;
}
.PAGING a:hover {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}
.PAGING input[type="text"] {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 4px !important;
    padding: 4px 6px !important;
    font-size: 11px !important;
    background: var(--bg-base, #ffffff) !important;
    color: var(--text-primary, #0a2540);
}
.PAGING select {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 4px !important;
    background: var(--bg-base, #ffffff) !important;
    color: var(--text-primary, #0a2540) !important;
    font-size: 11px;
}
.MOSTRANDO {
    color: var(--text-secondary, #425466) !important;
    font-size: 11px !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
}

/* Sort arrows del datagrid — más sutiles */
body.main-v2 img[src*="datagrid_sort"] {
    opacity: 0.5 !important;
    transition: opacity 120ms ease !important;
}
body.main-v2 .GRID_TITLE:hover img[src*="datagrid_sort"] {
    opacity: 1 !important;
}

/* =============================================================
   SECCION 28 - .ICON wrapper modernizado
   ============================================================= */
body.main-v2 .ICON {
    display: inline-flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px 10px !important;
    min-width: 130px;
    max-width: 180px;
    box-sizing: border-box;
    border-radius: var(--radius-md, 8px);
    background: var(--bg-base, #ffffff);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 120ms ease;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 11.5px;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary, #0a2540);
    line-height: 1.3;
    /* Wrap del texto largo (ej. "Documentos pendientes") */
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
}
body.main-v2 .ICON:hover {
    background: var(--stx-primary-50, #efeefe);
    border-color: rgba(99,91,255,0.2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
}

/* Celdas legacy <TD> que envuelven .ICON: alinear arriba y dar
   respiro horizontal para que los tiles no se encimen visualmente. */
body.main-v2 fieldset table td:has(> .ICON) {
    vertical-align: top !important;
    padding: 6px 8px !important;
}
/* Fallback para navegadores sin :has() — aplica al td genérico de la
   tabla dentro del fieldset. CELLPADDING="10" del HTML legacy queda. */
body.main-v2 fieldset > table[cellpadding] > tbody > tr > td,
body.main-v2 fieldset > table[cellpadding] > tr > td {
    vertical-align: top;
}

/* =============================================================
   SECCION 29 - DASHBOARDS CELUCENTER CUSTOM
   (.adm-*, .dp-*, .pat-*, .card-stat, .rag-*)
   Refinamiento sutil para que se integren al theme V4.
   ============================================================= */

/* Dashboard Admin General (.adm-*) */
.adm-tile {
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    border: 1px solid var(--border-default, #e3e8ee);
    transition: all 120ms ease;
}
.adm-tile:hover {
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
    transform: translateY(-1px);
    border-color: rgba(99,91,255,0.25);
}
.adm-big, .adm-mid {
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary, #0a2540);
}
.adm-label {
    font-family: var(--font-sans, 'Inter', sans-serif);
    color: var(--text-secondary, #425466);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.adm-pill {
    border-radius: 9999px;
    padding: 2px 8px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 10.5px;
    font-weight: 600;
}
.adm-delta.up   { color: var(--stx-success, #16b364); }
.adm-delta.down { color: var(--stx-danger, #f04438); }

/* Dashboard Pagos MR (.dp-*) */
.dp-card {
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    border: 1px solid var(--border-default, #e3e8ee);
    font-family: var(--font-sans, 'Inter', sans-serif);
    transition: all 120ms ease;
}
.dp-card:hover { box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06)); }
.dp-card.active {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.12);
}
.dp-btn {
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    border-radius: var(--radius-sm, 6px) !important;
    font-weight: 500 !important;
}
.dp-table {
    font-family: var(--font-sans, 'Inter', sans-serif);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    border: 1px solid var(--border-default, #e3e8ee);
}
.dp-empty {
    color: var(--text-tertiary, #697386);
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-style: italic;
}

/* Consulta Paternidad (.pat-*) */
.pat-card {
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    border: 1px solid var(--border-default, #e3e8ee);
    font-family: var(--font-sans, 'Inter', sans-serif);
}
.pat-pill {
    border-radius: 9999px;
    padding: 3px 10px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 11px;
    font-weight: 600;
}
.pat-pill-verde,
.pat-pill-LIBRE {
    background: var(--stx-success-light, #ecfdf3) !important;
    color: var(--stx-success-dark, #027a48) !important;
}
.pat-pill-rojo,
.pat-pill-BLOQUEADA {
    background: var(--stx-danger-light, #fef3f2) !important;
    color: var(--stx-danger-dark, #b42318) !important;
}
.pat-pill-amarillo {
    background: var(--stx-warning-light, #fffaeb) !important;
    color: var(--stx-warning-dark, #b54708) !important;
}
.pat-pill-azul {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}
.pat-alert {
    border-radius: var(--radius-sm, 6px);
    padding: 10px 14px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 12.5px;
    border-left: 3px solid;
}

/* Card stats genéricas */
.card-stat {
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    border: 1px solid var(--border-default, #e3e8ee);
    font-family: var(--font-sans, 'Inter', sans-serif);
    transition: all 120ms ease;
}
.card-stat:hover {
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
}

/* RAG (red/amber/green) status indicators */
.rag-red    { color: var(--stx-danger, #f04438) !important; }
.rag-amber  { color: var(--stx-warning, #f79009) !important; }
.rag-green  { color: var(--stx-success, #16b364) !important; }
.rag-grid {
    font-family: var(--font-sans, 'Inter', sans-serif);
}

/* =============================================================
   SECCION 30 - TILES UNIFORMES (.ICON + .stx-icon-tile)
   Iconos en todos los paneles se ven como tiles pastel.
   ============================================================= */
body.main-v2 .stx-icon-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--tile-bg, rgba(99,91,255,0.1));
    transition: transform 120ms ease, box-shadow 120ms ease;
    flex-shrink: 0;
}
body.main-v2 .stx-icon-tile .stx-svg-icon {
    width: 28px;
    height: 28px;
    color: var(--tile-fg, var(--stx-primary-600, #635bff));
    display: block;
}
body.main-v2 .stx-icon-tile-primary { --tile-bg: rgba(99,91,255,0.12); --tile-fg: #635bff; }
body.main-v2 .stx-icon-tile-success { --tile-bg: rgba(22,179,100,0.12); --tile-fg: #16b364; }
body.main-v2 .stx-icon-tile-warning { --tile-bg: rgba(247,144,9,0.12); --tile-fg: #b54708; }
body.main-v2 .stx-icon-tile-danger  { --tile-bg: rgba(240,68,56,0.12); --tile-fg: #f04438; }
body.main-v2 .stx-icon-tile-info    { --tile-bg: rgba(0,115,230,0.12); --tile-fg: #0073e6; }
body.main-v2 .stx-icon-tile-gray    { --tile-bg: rgba(105,115,134,0.12); --tile-fg: #425466; }

/* .ICON contenedor que aloja un tile */
body.main-v2 .stx-icon-tile-host {
    background: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 12px !important;
    padding: 16px 14px !important;
    min-width: 140px !important;
    max-width: 200px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    margin: 4px !important;
    cursor: pointer;
    transition: all 120ms ease;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary, #0a2540);
    line-height: 1.3;
    /* Wrap del texto largo (ej. "Documentos pendientes") */
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    vertical-align: top !important;
}
body.main-v2 .stx-icon-tile-host:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
    border-color: var(--stx-primary-600, #635bff);
}
body.main-v2 .stx-icon-tile-host:hover .stx-icon-tile {
    transform: scale(1.05);
}

/* =============================================================
   SECCION 31 - PANEL TOOLBAR (search + view switcher)
   ============================================================= */
body.main-v2 .stx-panel-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 16px;
    flex-wrap: wrap;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

body.main-v2 .stx-panel-search-wrap {
    position: relative;
    flex: 1 1 220px;
    min-width: 200px;
    max-width: 360px;
}
body.main-v2 .stx-panel-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-tertiary, #697386);
    pointer-events: none;
    z-index: 1;
}
/* Specificity boosted con [class] para vencer la regla genérica
   input[type="text"]:not(.TEXTBOX)... (sección 26, ~línea 1481). */
body.main-v2 input.stx-panel-search,
body.main-v2 input[type="text"].stx-panel-search {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 12px 7px 48px !important;
    text-indent: 0 !important;
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 7px;
    font-size: 13px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    color: var(--text-primary, #0a2540);
    background: var(--bg-base, #ffffff);
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    transition: all 120ms ease;
    outline: none;
    text-indent: 0;
}
body.main-v2 input.stx-panel-search:focus,
body.main-v2 input[type="text"].stx-panel-search:focus {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
}
body.main-v2 input.stx-panel-search::placeholder,
body.main-v2 input[type="text"].stx-panel-search::placeholder {
    color: var(--text-tertiary, #697386);
    opacity: 1;
}

body.main-v2 .stx-panel-switcher {
    display: inline-flex;
    gap: 2px;
    background: var(--bg-muted, #f3f6fa);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-default, #e3e8ee);
}
body.main-v2 .stx-panel-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: var(--text-secondary, #425466);
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 120ms ease;
}
body.main-v2 .stx-panel-switcher-btn:hover {
    color: var(--text-primary, #0a2540);
    background: rgba(255,255,255,0.6);
}
body.main-v2 .stx-panel-switcher-btn.is-active {
    background: var(--bg-base, #ffffff);
    color: var(--stx-primary-600, #635bff);
    box-shadow: 0 1px 2px rgba(48,49,61,0.06);
    font-weight: 600;
}

/* =============================================================
   SECCION 32 - LAYOUTS UNIVERSALES (tiles/list/cards)
   Aplicado al data-layout del .stx-icon-panel
   ============================================================= */

/* Layout TILES (default) — grid de cuadrados */
body.main-v2 .stx-icon-panel[data-layout="tiles"] {
    /* mantener layout natural del HTML (tabla) pero distribuir bien */
}
body.main-v2 .stx-icon-panel[data-layout="tiles"] table {
    border-collapse: separate;
    border-spacing: 10px;
}
body.main-v2 .stx-icon-panel[data-layout="tiles"] .ICON {
    min-width: 140px;
    max-width: 200px;
}

/* Layout LISTA — items horizontal con icono al lado del texto */
body.main-v2 .stx-icon-panel[data-layout="list"] table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}
body.main-v2 .stx-icon-panel[data-layout="list"] tbody tr {
    display: block;
}
body.main-v2 .stx-icon-panel[data-layout="list"] tbody tr td {
    display: inline-block;
    width: auto;
}
body.main-v2 .stx-icon-panel[data-layout="list"] .ICON {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    min-width: 100% !important;
    width: 100%;
    padding: 10px 14px !important;
    gap: 14px !important;
    margin-bottom: 6px;
    border-radius: 8px !important;
}
body.main-v2 .stx-icon-panel[data-layout="list"] .ICON .stx-icon-tile {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}
body.main-v2 .stx-icon-panel[data-layout="list"] .ICON .stx-icon-tile .stx-svg-icon {
    width: 18px;
    height: 18px;
}
body.main-v2 .stx-icon-panel[data-layout="list"] .ICON br {
    display: none;
}

/* Layout CARDS — tarjetas más grandes con descripción */
body.main-v2 .stx-icon-panel[data-layout="cards"] table {
    border-collapse: separate;
    border-spacing: 10px;
}
body.main-v2 .stx-icon-panel[data-layout="cards"] .ICON {
    min-width: 220px !important;
    flex-direction: row !important;
    align-items: center !important;
    text-align: left !important;
    padding: 18px !important;
    gap: 14px !important;
}
body.main-v2 .stx-icon-panel[data-layout="cards"] .ICON .stx-icon-tile {
    width: 48px;
    height: 48px;
}
body.main-v2 .stx-icon-panel[data-layout="cards"] .ICON .stx-icon-tile .stx-svg-icon {
    width: 24px;
    height: 24px;
}
body.main-v2 .stx-icon-panel[data-layout="cards"] .ICON br {
    display: none;
}

/* SECCION 33 - LIST_TABLE_LIGHT (lo que se nos había escapado) */
body.main-v2 .LIST_TABLE_LIGHT {
    background-color: var(--bg-base, #ffffff) !important;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

/* =============================================================
   SECCION 34 - DATAGRID HEADER REFINADO (Stripe Dashboard)
   Refinamiento del THEAD del Datagrid: tipografía, espaciado,
   sort arrows como SVG via mask-image (reemplazan los GIFs),
   empty state amigable con icono SVG inline.
   ============================================================= */

/* --- Contenedor del grid: borde sutil + sombra suave -------- */
body.main-v2 .GRID_TABLE {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-md, 8px) !important;
    background: var(--bg-base, #ffffff) !important;
    box-shadow: 0 1px 2px rgba(48, 49, 61, 0.04);
    overflow: hidden;
}

/* --- THEAD: fondo gris muy claro + tipografía refinada ------ */
body.main-v2 .GRID_HEADER,
body.main-v2 .GRID_FREEZED_HEADER {
    background-color: #fafbfc !important;
    color: #425466 !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
}

/* --- TH cells: padding generoso + borde inferior más oscuro - */
body.main-v2 .GRID_HEADER th,
body.main-v2 .GRID_HEADER td {
    padding: 12px 16px !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #d4dbe3 !important;
    vertical-align: middle !important;
    white-space: nowrap;
}

/* --- GRID_TITLE: contenedor clickeable de cada columna ------ */
body.main-v2 .GRID_TITLE {
    color: #425466 !important;
    font-weight: 600 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 2px 4px !important;
    border-radius: 4px;
    transition: background-color 120ms ease, color 120ms ease;
    user-select: none;
}

/* Hover: columnas ordenables (las que tienen <img datagrid_sort>) */
body.main-v2 .GRID_TITLE:hover {
    background-color: #f3f6fa !important;
    color: var(--text-primary, #0a2540) !important;
    cursor: pointer;
}
/* Columnas no ordenables — desactivar hover effect (:has soportado en
   navegadores modernos; en versiones antiguas el hover aplica igual,
   que es aceptable como degradación). */
body.main-v2 .GRID_TITLE:not(:has(img[src*="datagrid_sort"])):hover {
    background-color: transparent !important;
    cursor: default;
}

/* --- Sort arrows: reemplazar visualmente los GIFs por SVG via
   mask-image (Lucide chevron-up / chevron-down / chevrons-up-down).
   El color se controla con background-color (act ua como fill). --- */
body.main-v2 .GRID_TITLE img[src*="datagrid_sort"] {
    -webkit-mask-repeat: no-repeat !important;
            mask-repeat: no-repeat !important;
    -webkit-mask-position: center !important;
            mask-position: center !important;
    -webkit-mask-size: 12px 12px !important;
            mask-size: 12px 12px !important;
    background-color: #8898aa !important;
    width: 12px !important;
    height: 12px !important;
    color: transparent !important;
    image-rendering: -webkit-optimize-contrast;
    opacity: 0.55 !important;
    transition: opacity 120ms ease, background-color 120ms ease, transform 120ms ease !important;
    vertical-align: middle;
    margin-left: 2px;
    flex-shrink: 0;
}
/* Estado ASC (activo) → chevron-up púrpura */
body.main-v2 .GRID_TITLE img[src*="datagrid_sort_asc"] {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='18 15 12 9 6 15'/></svg>") !important;
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='18 15 12 9 6 15'/></svg>") !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    opacity: 1 !important;
}
/* Estado DESC (activo) → chevron-down púrpura */
body.main-v2 .GRID_TITLE img[src*="datagrid_sort_desc"] {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") !important;
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    opacity: 1 !important;
}
/* Estado NONE (idle) → chevrons-up-down gris sutil */
body.main-v2 .GRID_TITLE img[src*="datagrid_sort_none"] {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m7 15 5 5 5-5'/><path d='m7 9 5-5 5 5'/></svg>") !important;
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m7 15 5 5 5-5'/><path d='m7 9 5-5 5 5'/></svg>") !important;
    background-color: #8898aa !important;
    opacity: 0.4 !important;
}
/* Hover en la columna: revelar el sort idle con un toque de color */
body.main-v2 .GRID_TITLE:hover img[src*="datagrid_sort_none"] {
    opacity: 0.9 !important;
    background-color: var(--stx-primary-600, #635bff) !important;
}
body.main-v2 .GRID_TITLE:hover img[src*="datagrid_sort"] {
    transform: translateY(-1px);
}

/* --- TBODY rows: hover sutil + bordes más finos ------------ */
body.main-v2 .GRID_TABLE tbody tr {
    transition: background-color 90ms ease;
}
body.main-v2 .GRID_TABLE tbody tr.ODD_ROW:hover,
body.main-v2 .GRID_TABLE tbody tr.EVEN_ROW:hover {
    background-color: var(--stx-primary-50, #efeefe) !important;
}
body.main-v2 .GRID_TABLE tbody td {
    padding: 8px 16px !important;
    border-bottom: 1px solid var(--border-subtle, #f0f3f6) !important;
    color: var(--text-primary, #0a2540);
    font-size: 13px;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
}

/* --- Empty state: "No se encontraron registros" refinado ---- */
body.main-v2 .GRID_ERROR {
    background-color: #fffbeb !important;
    border: 1px solid #fde68a !important;
    color: #92400e !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    border-radius: var(--radius-md, 8px) !important;
    margin: 24px auto !important;
    padding: 32px 24px !important;
    max-width: 420px;
    text-align: center !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(48, 49, 61, 0.04);
}
/* Icono SVG (inbox de Lucide) inyectado vía ::before */
body.main-v2 .GRID_ERROR::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    background-color: #d97706;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><polyline points='22 12 16 12 14 15 10 15 8 12 2 12'/><path d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><polyline points='22 12 16 12 14 15 10 15 8 12 2 12'/><path d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/></svg>");
    margin-bottom: 4px;
    opacity: 0.9;
}
/* Tip sutil debajo del mensaje */
body.main-v2 .GRID_ERROR::after {
    content: 'Intenta ajustar los filtros y volver a buscar';
    display: block;
    color: #b45309;
    font-size: 11.5px;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 2px;
    letter-spacing: 0;
    text-transform: none;
}

/* --- Botón "Buscar" del filtro: pasar de gris feo a purple
   Stripe (BUTTON_SMALL en contexto de FILTER_BUTTON solamente,
   para no afectar otros BUTTON_SMALL del sistema) ----------- */
body.main-v2 .FILTER_BUTTON .BUTTON_SMALL,
body.main-v2 .FILTER_BUTTON input.BUTTON_SMALL[value="Buscar"],
body.main-v2 .FILTER_BUTTON input#SEARCH {
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 8px 18px !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(99,91,255,0.16) !important;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease !important;
}
body.main-v2 .FILTER_BUTTON .BUTTON_SMALL:hover,
body.main-v2 .FILTER_BUTTON input#SEARCH:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: 0 2px 6px rgba(99,91,255,0.24) !important;
    transform: translateY(-1px);
}
body.main-v2 .FILTER_BUTTON .BUTTON_SMALL:active,
body.main-v2 .FILTER_BUTTON input#SEARCH:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(99,91,255,0.16) !important;
}
body.main-v2 .FILTER_BUTTON .BUTTON_SMALL:focus-visible,
body.main-v2 .FILTER_BUTTON input#SEARCH:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.20), 0 1px 2px rgba(99,91,255,0.16) !important;
}

/* =============================================================
   SECCION 35 - REPORTES: SUB-CATEGORIAS (segmented control)
   Usado en /system/bin/section/reportes/subcategory.php
   Las "pestanas grises" legacy con GIF background ahora son
   chips/botones tipo segmented control Stripe Dashboard.
   ============================================================= */
body.main-v2 .stx-rep-subcats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--bg-muted, #f3f6fa);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 10px;
    padding: 6px;
    margin: 0 0 14px;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

body.main-v2 .stx-rep-subcat-wrap {
    display: inline-flex;
    flex-direction: column;
}

body.main-v2 .stx-rep-subcat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-secondary, #425466);
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease,
                box-shadow 120ms ease, border-color 120ms ease,
                transform 120ms ease;
    line-height: 1.2;
    white-space: nowrap;
    user-select: none;
}

body.main-v2 .stx-rep-subcat-btn:hover {
    background: rgba(255,255,255,0.7);
    color: var(--text-primary, #0a2540);
}

body.main-v2 .stx-rep-subcat-btn.is-active {
    background: var(--bg-base, #ffffff);
    color: var(--stx-primary-600, #635bff);
    border-color: var(--border-default, #e3e8ee);
    box-shadow: 0 1px 2px rgba(48,49,61,0.08), 0 0 0 1px rgba(99,91,255,0.18);
}

body.main-v2 .stx-rep-subcat-btn.is-duplicate {
    color: var(--stx-warning, #f79009);
}
body.main-v2 .stx-rep-subcat-btn.is-duplicate.is-active {
    color: var(--stx-warning, #f79009);
    box-shadow: 0 1px 2px rgba(48,49,61,0.08), 0 0 0 1px rgba(247,144,9,0.32);
}

body.main-v2 .stx-rep-subcat-label {
    display: inline-block;
}

/* =============================================================
   SECCION 36 - REPORTES: LISTADO DE REPORTES (cards con iconos)
   Usado en /system/bin/section/reportes/category.php
   Cada reporte es un item con icono SVG semantico, titulo,
   descripcion, ejemplos opcionales y chevron a la derecha.
   ============================================================= */
body.main-v2 .stx-rep-list {
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

body.main-v2 .stx-rep-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-default, #e3e8ee);
    background: var(--bg-base, #ffffff);
    transition: background 120ms ease;
    font-family: var(--font-sans, 'Inter', sans-serif);
    color: var(--text-primary, #0a2540);
}
body.main-v2 .stx-rep-item:last-child {
    border-bottom: none;
}
body.main-v2 .stx-rep-item:hover {
    background: var(--bg-hover, #efeefe);
}

body.main-v2 .stx-rep-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform 120ms ease;
}
body.main-v2 .stx-rep-item:hover .stx-rep-item-icon {
    transform: scale(1.05);
}
body.main-v2 .stx-rep-item-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

body.main-v2 .stx-rep-item-body {
    flex: 1;
    min-width: 0;
}

body.main-v2 .stx-rep-item-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary, #0a2540);
    line-height: 1.35;
    letter-spacing: -0.005em;
}

body.main-v2 .stx-rep-item-desc {
    font-size: 12px;
    color: var(--text-secondary, #425466);
    margin-top: 4px;
    line-height: 1.5;
    font-weight: 400;
}

body.main-v2 .stx-rep-item-ejemplos {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    font-size: 11px;
    color: var(--text-tertiary, #697386);
}
body.main-v2 .stx-rep-item-ejemplos-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary, #697386);
    font-size: 10.5px;
}
body.main-v2 .stx-rep-item-ejemplo-grupo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
body.main-v2 .stx-rep-item-ejemplo-titulo {
    color: var(--text-secondary, #425466);
    font-weight: 500;
}
body.main-v2 .stx-rep-item-ejemplo-link {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-muted, #f3f6fa);
    border: 1px solid var(--border-default, #e3e8ee);
    color: var(--stx-primary-600, #635bff) !important;
    text-decoration: none !important;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
    cursor: pointer;
}
body.main-v2 .stx-rep-item-ejemplo-link:hover {
    background: rgba(99,91,255,0.10);
    border-color: var(--stx-primary-600, #635bff);
    color: var(--stx-primary-700, #5147e2) !important;
}

body.main-v2 .stx-rep-item-chevron {
    color: var(--text-tertiary, #697386);
    opacity: 0.3;
    transition: opacity 120ms ease, transform 120ms ease, color 120ms ease;
    flex-shrink: 0;
    margin-top: 9px;
}
body.main-v2 .stx-rep-item:hover .stx-rep-item-chevron {
    opacity: 1;
    color: var(--stx-primary-600, #635bff);
    transform: translateX(3px);
}

/* Colores semanticos por tipo de reporte (mismo set que stx-doc) */
body.main-v2 .stx-rep-color-purple .stx-rep-item-icon {
    background: rgba(99,91,255,0.1);
    color: var(--stx-primary-600, #635bff);
}
body.main-v2 .stx-rep-color-success .stx-rep-item-icon {
    background: rgba(22,179,100,0.1);
    color: var(--stx-success, #16b364);
}
body.main-v2 .stx-rep-color-warning .stx-rep-item-icon {
    background: rgba(247,144,9,0.1);
    color: var(--stx-warning, #f79009);
}
body.main-v2 .stx-rep-color-danger .stx-rep-item-icon {
    background: rgba(240,68,56,0.1);
    color: var(--stx-danger, #f04438);
}
body.main-v2 .stx-rep-color-info .stx-rep-item-icon {
    background: rgba(0,115,230,0.1);
    color: var(--stx-info, #0073e6);
}
body.main-v2 .stx-rep-color-gray .stx-rep-item-icon {
    background: rgba(105,115,134,0.1);
    color: var(--text-tertiary, #697386);
}

/* Empty state cuando no hay reportes */
body.main-v2 .stx-rep-empty {
    background: var(--bg-base, #ffffff);
    border: 1px dashed var(--border-default, #e3e8ee);
    border-radius: 10px;
    padding: 36px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: var(--text-tertiary, #697386);
    font-family: var(--font-sans, 'Inter', sans-serif);
}
body.main-v2 .stx-rep-empty svg {
    opacity: 0.5;
    margin-bottom: 4px;
}
body.main-v2 .stx-rep-empty-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary, #425466);
}
body.main-v2 .stx-rep-empty-desc {
    font-size: 12px;
    color: var(--text-tertiary, #697386);
}

/* Cuando el listado de reportes se muestra en el overlay (panel.php
   con #REPORTE_DETALLE_LISTADO position:absolute), forzamos fondo
   blanco al wrapper para que el card se vea bien. */
body.main-v2 #REPORTE_DETALLE_LISTADO {
    background: transparent !important;
    padding: 4px;
    box-sizing: border-box;
}

/* =============================================================
   SECCION 37 - REPORTES: BUSCADOR (filtro client-side)
   Input de busqueda arriba del sidebar de categorias en
   /system/bin/section/reportes/panel.php. Filtra en tiempo real
   categorias padre, sub-categorias y reportes individuales.
   ============================================================= */
body.main-v2 .stx-rep-search-wrap {
    position: relative;
    margin: 0 0 12px;
    padding: 0 4px;
    width: 280px;
    box-sizing: border-box;
    font-family: var(--font-sans, 'Inter', sans-serif);
}
body.main-v2 .stx-rep-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-tertiary, #697386);
    pointer-events: none;
    z-index: 1;
}
body.main-v2 input.stx-rep-search-input,
body.main-v2 input[type="text"].stx-rep-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px 8px 36px !important;
    text-indent: 0 !important;
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 7px;
    font-size: 13px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    color: var(--text-primary, #0a2540);
    background: var(--bg-base, #ffffff);
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    transition: all 120ms ease;
    outline: none;
}
body.main-v2 input.stx-rep-search-input:focus,
body.main-v2 input[type="text"].stx-rep-search-input:focus {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
}
body.main-v2 input.stx-rep-search-input::placeholder,
body.main-v2 input[type="text"].stx-rep-search-input::placeholder {
    color: var(--text-tertiary, #697386);
    opacity: 1;
}

/* =============================================================
   SECCION 38 - PDV BARRA LATERAL DERECHA (Cancelar / Guardar)
   Botones laterales en layer_unticket.php / layer_unafactura.php
   ============================================================= */
body.main-v2 .pdv-side-icon {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    padding: 10px 8px !important;
    min-width: 78px !important;
    max-width: 100px !important;
    width: 90px !important;
    cursor: pointer !important;
    border-radius: 10px !important;
    background: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    transition: all 120ms ease !important;
    margin: 4px auto !important;
    text-align: center !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
}
body.main-v2 .pdv-side-icon:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06)) !important;
    border-color: var(--stx-primary-600, #635bff) !important;
}
body.main-v2 .pdv-side-icon .stx-icon-tile {
    width: 36px !important;
    height: 36px !important;
    margin-bottom: 2px;
}
body.main-v2 .pdv-side-icon .stx-icon-tile .stx-svg-icon {
    width: 18px !important;
    height: 18px !important;
}
body.main-v2 .pdv-side-icon > img {
    width: 24px !important;
    height: 24px !important;
    object-fit: contain;
}
body.main-v2 .pdv-side-label {
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: var(--text-primary, #0a2540) !important;
    line-height: 1.2 !important;
    text-align: center;
}

/* =============================================================
   SECCION 39 - RESPONSIVE (v2 conservadora — solo content)
   NO toca body.sidebar-v2 ni body.sidebar-v3 (preservado).
   Solo afecta body.main-v2 (contenido principal).
   ============================================================= */

/* GRID TABLE — scrollbar visible y prominente cuando hay overflow.
   El grid ya tiene overflow-x:auto desde la seccion 5; aqui solo
   refinamos el scrollbar para que sea obvio que se puede deslizar. */
body.main-v2 .GRID_TABLE::-webkit-scrollbar,
body.main-v2 .LIST_TABLE::-webkit-scrollbar,
body.main-v2 .DATATABLA::-webkit-scrollbar {
    height: 12px !important;
    width: 12px !important;
}
body.main-v2 .GRID_TABLE::-webkit-scrollbar-track,
body.main-v2 .LIST_TABLE::-webkit-scrollbar-track,
body.main-v2 .DATATABLA::-webkit-scrollbar-track {
    background: var(--bg-subtle, #f6f9fc) !important;
    border-radius: 6px !important;
}
body.main-v2 .GRID_TABLE::-webkit-scrollbar-thumb,
body.main-v2 .LIST_TABLE::-webkit-scrollbar-thumb,
body.main-v2 .DATATABLA::-webkit-scrollbar-thumb {
    background: var(--border-strong, #c1c9d2) !important;
    border-radius: 6px !important;
    border: 2px solid var(--bg-subtle, #f6f9fc) !important;
}
body.main-v2 .GRID_TABLE::-webkit-scrollbar-thumb:hover,
body.main-v2 .LIST_TABLE::-webkit-scrollbar-thumb:hover,
body.main-v2 .DATATABLA::-webkit-scrollbar-thumb:hover {
    background: var(--stx-primary-600, #635bff) !important;
}

/* Tablet (max 1024px) — tiles V4 mas compactos.
   IMPORTANTE: NO incluye reglas para body.sidebar-* */
@media (max-width: 1024px) {
    body.main-v2 .stx-doc-tiles {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
        gap: 8px !important;
    }
    body.main-v2 .stx-doc-cards {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
    }
    /* Celdas del grid mas compactas para que mas columnas quepan */
    body.main-v2 .GRID_TABLE tbody td {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    body.main-v2 .GRID_HEADER th,
    body.main-v2 .GRID_HEADER td {
        padding: 8px 10px !important;
        font-size: 10.5px !important;
    }
}

/* Mobile (max 768px) — toolbar V4 stack vertical */
@media (max-width: 768px) {
    body.main-v2 .stx-panel-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    body.main-v2 .stx-panel-search-wrap {
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }
    body.main-v2 .stx-panel-switcher {
        width: 100% !important;
        justify-content: center !important;
    }
    body.main-v2 .stx-panel-switcher-btn {
        flex: 1 1 0 !important;
        justify-content: center !important;
    }
}

/* Mobile (max 600px) — tiles V4 2 columnas */
@media (max-width: 600px) {
    body.main-v2 .stx-doc-tiles {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    body.main-v2 .stx-doc-cards { grid-template-columns: 1fr !important; }
    body.main-v2 .stx-doc-tile { padding: 10px 6px !important; }
    body.main-v2 .stx-doc-tile-label { font-size: 11px !important; }
    body.main-v2 .stx-doc-list-item { padding: 10px 12px !important; }
}

/* ============================================================
 * SECCIÓN 40 — Grid columns resize + reorder (V4)
 * Soporte para stx_grid_columns.js
 * ============================================================ */

/* Hacer columnas redimensionables por contenido — fix de espacios desproporcionados */
body.main-v2 .GRID_TABLE {
    table-layout: auto !important;
}

/* Header celdas: relative para hospedar el handle + cursor de drag */
body.main-v2 .GRID_TABLE .GRID_HEADER > *,
body.main-v2 .GRID_TABLE .GRID_FREEZED_HEADER > * {
    position: relative !important;
    cursor: grab !important;
    user-select: none !important;
}
body.main-v2 .GRID_TABLE .GRID_HEADER > *:active,
body.main-v2 .GRID_TABLE .GRID_FREEZED_HEADER > *:active {
    cursor: grabbing !important;
}

/* La estructura real es THEAD.GRID_HEADER > TR > TD > DIV.GRID_TITLE
   Reforzar position/cursor en los TD del thead */
body.main-v2 .GRID_TABLE thead.GRID_HEADER td,
body.main-v2 .GRID_TABLE thead.GRID_HEADER th {
    position: relative !important;
    cursor: grab !important;
    user-select: none !important;
}
body.main-v2 .GRID_TABLE thead.GRID_HEADER td:active,
body.main-v2 .GRID_TABLE thead.GRID_HEADER th:active {
    cursor: grabbing !important;
}
/* El div interno GRID_TITLE tenía overflow:hidden inline — permitir que se vea el handle */
body.main-v2 .GRID_TABLE thead.GRID_HEADER td > .GRID_TITLE,
body.main-v2 .GRID_TABLE thead.GRID_HEADER td > .GRID_FREEZED_HEADER {
    overflow: visible !important;
}

/* Handle de resize (borde derecho del header) */
.stx-grid-resize-handle {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 8px !important;
    height: 100% !important;
    cursor: col-resize !important;
    z-index: 10 !important;
    background: transparent !important;
    transition: background 0.15s ease !important;
    pointer-events: auto !important;
}
.stx-grid-resize-handle:hover,
.stx-grid-resize-handle:active {
    background: var(--stx-primary-600, #635bff) !important;
    opacity: 0.6 !important;
}
/* Indicador sutil del handle al hover sobre la celda del header */
body.main-v2 .GRID_TABLE thead.GRID_HEADER td:hover > .stx-grid-resize-handle {
    background: rgba(99, 91, 255, 0.3) !important;
}

/* Cursor global mientras se redimensiona */
body.stx-grid-resizing,
body.stx-grid-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* Estados visuales de drag-and-drop para reorder */
.stx-grid-th-dragging {
    opacity: 0.5 !important;
    background: var(--stx-primary-50, #f0eeff) !important;
}
.stx-grid-th-drop-target {
    box-shadow: inset 3px 0 0 var(--stx-primary-600, #635bff) !important;
    background: var(--stx-primary-50, #f0eeff) !important;
}

/* Toolbar de cada grid: zoom A-/A+ + reset */
.stx-grid-reset-wrap {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    margin: 4px 8px 6px !important;
}
.stx-grid-reset-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 5px 10px !important;
    background: #ffffff !important;
    border: 1px solid var(--stx-neutral-200, #e3e8ee) !important;
    border-radius: 6px !important;
    color: var(--stx-neutral-600, #425466) !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.04) !important;
}
.stx-grid-reset-btn:hover {
    background: var(--stx-primary-50, #f0eeff) !important;
    border-color: var(--stx-primary-600, #635bff) !important;
    color: var(--stx-primary-600, #635bff) !important;
}
.stx-grid-reset-btn svg {
    flex-shrink: 0 !important;
}
.stx-grid-zoom-btn {
    min-width: 36px !important;
    padding: 5px 8px !important;
}

/* Permitir que el contenido del TD se reduzca por debajo de su min-content
   intrínseco (necesario para que el resize pueda achicar columnas pequeñas
   como la lupa o la columna de checkbox) */
body.main-v2 .GRID_TABLE table {
    table-layout: auto !important;
}
body.main-v2 .GRID_TABLE td,
body.main-v2 .GRID_TABLE th {
    min-width: 0 !important;
    box-sizing: border-box !important;
}
body.main-v2 .GRID_TABLE .GRID_CELL,
body.main-v2 .GRID_TABLE .GRID_TITLE {
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Permitir scroll horizontal cuando las columnas suman más que el viewport */
body.main-v2 .GRID_TABLE_DIV,
body.main-v2 div[id*="GRID_"][id$="_BODY"] {
    overflow-x: auto !important;
}

/* ============================================================
 * SECCIÓN 41 — Fix columna de acciones (lupa / editar / checkbox)
 * ============================================================
 * El XML del framework define la primera columna como
 *   <FIELD WIDTH="20" FREEZE="TRUE">
 * con un <A><IMG src="...lupa.gif" WIDTH="16" HEIGHT="16"></A>.
 *
 * Al introducir el V4 (SECCIÓN 36) se aplicó padding 12px 16px al
 * thead y 8px 16px al tbody, y la SECCIÓN 40 forzó box-sizing:
 * border-box + min-width:0. Resultado: una celda de width:20 con
 * 32px de padding horizontal deja 0px (negativo) para el contenido,
 * y el overflow:hidden inline del PHP clipea el icono.
 *
 * ESTRUCTURA REAL del DOM (class_datagrid.php línea 589/599):
 *   <TD style="width:25;height:18px">
 *     <DIV class="GRID_CELL" style="overflow:hidden;width:25;...">
 *       <NOBR>                         ← envuelve TODO
 *         <A href="..."><IMG src="lupa.gif" width="16" height="16"/></A>
 *       </NOBR>
 *     </DIV>
 *   </TD>
 *
 * El intento anterior de SECCIÓN 41 usaba selectores como
 *   .GRID_CELL > a > img
 * que NUNCA matchean — el <A> es hijo de <NOBR>, no de .GRID_CELL.
 *
 * Solución: dos capas.
 * 1) Marcador agregado por JS (`stx_grid_columns.js` agrega clase
 *    `stx-grid-action-cell` al TD si la celda solo contiene un
 *    img/svg/checkbox pequeño sin texto). Más robusto que :has().
 * 2) Selector CSS sin :has() basado en esa clase, override agresivo
 *    de padding/min-width/overflow inline aplicado por PHP y JS.
 * ============================================================ */

/* Body: TD marcado por el JS como celda de acción */
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell {
    padding: 4px 6px !important;
    min-width: 32px !important;
    width: 32px !important;
    max-width: 64px !important;
    text-align: center !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell .GRID_CELL {
    overflow: visible !important;
    min-width: 20px !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: content-box !important;
    text-align: center !important;
    display: inline-block !important;
}
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell .GRID_CELL > nobr,
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell .GRID_CELL nobr {
    display: inline-block !important;
    overflow: visible !important;
    line-height: 1 !important;
}

/* Header: TH marcado por el JS como header de columna de acción */
body.main-v2 .GRID_TABLE thead.GRID_HEADER th.stx-grid-action-cell,
body.main-v2 .GRID_TABLE thead.GRID_HEADER td.stx-grid-action-cell {
    padding: 8px 6px !important;
    min-width: 32px !important;
    width: 32px !important;
    max-width: 64px !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}
body.main-v2 .GRID_TABLE thead.GRID_HEADER .stx-grid-action-cell .GRID_TITLE,
body.main-v2 .GRID_TABLE thead.GRID_HEADER .stx-grid-action-cell .GRID_FREEZED_HEADER {
    overflow: visible !important;
    min-width: 20px !important;
    width: auto !important;
    max-width: none !important;
}

/* Safety net: dentro de cualquier celda de acción, los IMG/SVG/checkbox
   deben renderizarse a tamaño completo sin clipping, ignorando WIDTH/HEIGHT
   inline del HTML si son demasiado pequeños. */
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell img,
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell svg,
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell .stx-svg-icon,
body.main-v2 .GRID_TABLE tbody td.stx-grid-action-cell input[type="checkbox"] {
    display: inline-block !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    min-width: 14px !important;
    min-height: 14px !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Override DEFINITIVO de las reglas de SECCIÓN 36/40 que ponen padding
   16px y min-width:0 — esas reglas se aplican antes pero como nuestro
   selector es más específico (incluye .stx-grid-action-cell) gana. */

/* ============================================================
 * SECCIÓN 41B — Fallback global con :has() para browsers modernos
 * ============================================================
 * Por si el JS aún no ha corrido (FOUC) o no detectó la celda, usar
 * :has() para alcanzar el caso real (DIV.GRID_CELL > NOBR > A > IMG).
 * Si el browser no soporta :has() (Safari < 15.4) el JS de la SECCIÓN
 * 41 de arriba lo cubre con el marcador stx-grid-action-cell.
 * ============================================================ */
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > a > img),
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > a > svg),
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > a > .stx-svg-icon),
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > input[type="checkbox"]),
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > a > img),
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > a > svg),
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > input[type="checkbox"]) {
    padding: 4px 6px !important;
    min-width: 32px !important;
    overflow: visible !important;
}
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > a > img) .GRID_CELL,
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > a > svg) .GRID_CELL,
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > a > .stx-svg-icon) .GRID_CELL,
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > nobr > input[type="checkbox"]) .GRID_CELL,
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > a > img) .GRID_CELL,
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > a > svg) .GRID_CELL,
body.main-v2 .GRID_TABLE tbody td:has(> .GRID_CELL > input[type="checkbox"]) .GRID_CELL {
    overflow: visible !important;
    min-width: 20px !important;
    width: auto !important;
    box-sizing: content-box !important;
}

/* ============================================================
 * SECCIÓN 50 — Login screens (V4)
 * ============================================================
 * Rediseño visual estilo Stripe Dashboard de las pantallas:
 *   - system/bin/section/main/login.php
 *   - system/bin/section/main/login_stx.php
 *   - system/bin/section/main/login_cliente.php
 *   - system/bin/section/main/password_reminder.php
 *   - admin/bin/section/main/login.php
 *   - admin/bin/section/main/password_reminder.php
 *
 * Estrategia: cada pantalla envuelve su contenido en
 *   <div class="stx-login-page"> ... <div class="stx-login-card"> ... </div></div>
 * El HTML legacy (FORM_LOGIN, FORM_PASS, FORM_EMAIL, SUBMIT, FIELDSET, etc.)
 * se conserva — solo se reestructura visualmente.
 *
 * No se hardcodean colores: todo viene de las variables de tokens_v4_stripe.css.
 * Tipografía heredada Inter (cargada globalmente en top.php).
 * ============================================================ */

/* Fondo full-viewport con gradient sutil púrpura/gris cuando la
   página contiene un login. Usa :has() (soporte 93%+ browsers actuales). */
body.main-v2:has(.stx-login-page) {
    background: linear-gradient(160deg,
        var(--stx-gray-50) 0%,
        var(--stx-primary-50) 50%,
        var(--stx-gray-50) 100%) !important;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Container general — flexbox para centrar la card vertical y
   horizontalmente, full-viewport. */
.stx-login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    padding: 48px 20px;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
    color: var(--text-primary);
}

/* Quitar BR sueltos heredados del HTML legacy. */
.stx-login-page > br {
    display: none;
}

/* Logo / branding superior, encima de la card. */
.stx-login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--stx-gray-900);
}

.stx-login-brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: linear-gradient(135deg,
        var(--stx-primary-600) 0%,
        var(--stx-primary-700) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 91, 255, 0.32);
}

.stx-login-brand-mark svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Card principal — fondo blanco, sombra suave, borde sutil. */
.stx-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Cabecera de card con título y subtítulo. */
.stx-login-card-header {
    padding: 32px 32px 8px;
    text-align: left;
}

.stx-login-title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--stx-gray-900);
    line-height: 1.3;
}

.stx-login-subtitle {
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-tertiary);
    line-height: 1.5;
}

/* Cuerpo del card (form). */
.stx-login-card-body {
    padding: 24px 32px 28px;
}

/* Banner de errores (top_errors) dentro de la card. */
.stx-login-card-body .ERROR_MESSAGE,
.stx-login-card-body .ERROR_BOX,
.stx-login-card-body .TOP_ERRORS {
    background: var(--stx-danger-light);
    border: 1px solid var(--stx-danger);
    color: var(--stx-danger-dark);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}

/* Grupo de campo (label + input). */
.stx-login-field {
    margin-bottom: 16px;
}

.stx-login-field-label {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.005em;
}

/* Inputs del login — sobreescriben .TEXTBOX para esta pantalla. */
.stx-login-card .TEXTBOX,
.stx-login-card input[type="text"],
.stx-login-card input[type="password"],
.stx-login-card input[type="email"] {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    height: 40px !important;
    padding: 0 12px !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    color: var(--text-primary) !important;
    background: var(--bg-base) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 1px rgba(48, 49, 61, 0.04) !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
    outline: none !important;
}

.stx-login-card .TEXTBOX:hover,
.stx-login-card input[type="text"]:hover,
.stx-login-card input[type="password"]:hover,
.stx-login-card input[type="email"]:hover {
    border-color: var(--border-strong) !important;
}

.stx-login-card .TEXTBOX:focus,
.stx-login-card input[type="text"]:focus,
.stx-login-card input[type="password"]:focus,
.stx-login-card input[type="email"]:focus {
    border-color: var(--stx-primary-600) !important;
    box-shadow: var(--shadow-focus) !important;
}

.stx-login-card .TEXTBOX::placeholder {
    color: var(--text-tertiary);
}

/* Acciones del form (botón primary). */
.stx-login-actions {
    margin-top: 8px;
}

.stx-login-card .BUTTON_ {
    display: block !important;
    width: 100% !important;
    height: 42px !important;
    padding: 0 16px !important;
    background: var(--stx-primary-600) !important;
    background-image: linear-gradient(180deg,
        var(--stx-primary-500) 0%,
        var(--stx-primary-600) 100%) !important;
    color: #fff !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    box-shadow:
        0 1px 2px rgba(48, 49, 61, 0.12),
        0 0 0 1px rgba(50, 50, 93, 0.06),
        0 2px 5px 0 rgba(50, 50, 93, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
    transition: filter 120ms ease, transform 80ms ease, box-shadow 120ms ease !important;
}

.stx-login-card .BUTTON_:hover {
    filter: brightness(1.05);
    box-shadow:
        0 4px 10px rgba(99, 91, 255, 0.28),
        0 0 0 1px rgba(50, 50, 93, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}

.stx-login-card .BUTTON_:active {
    transform: translateY(1px);
    filter: brightness(0.97);
}

.stx-login-card .BUTTON_:focus-visible {
    outline: none;
    box-shadow:
        var(--shadow-focus),
        0 1px 2px rgba(48, 49, 61, 0.12) !important;
}

/* Footer del card — links secundarios. */
.stx-login-card-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    background: var(--bg-subtle);
}

.stx-login-card-footer a {
    color: var(--text-link);
    text-decoration: none;
    font-weight: 500;
    transition: color 120ms ease;
}

.stx-login-card-footer a:hover {
    color: var(--stx-primary-700);
    text-decoration: underline;
}

.stx-login-card-footer .stx-login-muted {
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Pie informativo afuera de la card (copyright / sistema). */
.stx-login-foot {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    letter-spacing: -0.005em;
}

/* Mensajes legacy de expiración (slider). Re-estilizar para que
   no rompan visualmente la pantalla nueva. */
body.main-v2 .stx-login-page .mensaje {
    width: 100%;
    max-width: 420px;
    margin: 0 auto 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    box-sizing: border-box;
}

body.main-v2 .stx-login-page .mensaje p {
    margin: 0;
}

body.main-v2 .stx-login-page .mensaje.alerta {
    background: var(--stx-warning-light);
    border: 1px solid var(--stx-warning);
    color: var(--stx-warning-dark);
}

body.main-v2 .stx-login-page .mensaje.suspendido,
body.main-v2 .stx-login-page .mensaje.varios_msg {
    background: var(--stx-danger-light);
    border: 1px solid var(--stx-danger);
    color: var(--stx-danger-dark);
}

/* Slider legacy (.container) — limitar tamaño y darle margen
   debajo de la card de login. */
body.main-v2 .stx-login-page .container {
    max-width: 420px;
    margin: 24px auto 0;
}

/* Esconder elementos legacy decorativos cuando estamos en stx-login-page. */
body.main-v2 .stx-login-page img[src*="login_top"],
body.main-v2 .stx-login-page img[src*="spacer"] {
    display: none !important;
}

/* Responsive — móvil. */
@media (max-width: 480px) {
    .stx-login-page {
        padding: 24px 12px;
    }
    .stx-login-card-header,
    .stx-login-card-body {
        padding-left: 22px;
        padding-right: 22px;
    }
    .stx-login-card-footer {
        padding-left: 22px;
        padding-right: 22px;
    }
}

/* ============================================================
 * SECCIÓN 51 — Topbar de pestañas (V4)
 * ============================================================
 *
 * Rediseña el topbar legacy (system/bin/section/main/topbar.php y
 * admin/bin/section/main/topbar.php) al estilo Stripe Dashboard:
 *  - tabs fondo blanco / hover gris claro / activa con borde inferior
 *    púrpura (#635bff) y peso 600
 *  - X de cerrar pequeña, gris, hover rojo
 *  - botón "+" como pill discreto con icono Lucide
 *  - tipografía Inter, padding consistente, sin gradientes ni
 *    pixel-borders legacy
 *
 * El body del topbar lleva clase `topbar-v2`. Los selectores acá viven
 * todos bajo `body.topbar-v2` para no contaminar otras pantallas
 * (el JS replacer y el grid resizer hacen early-return sobre esa misma
 * clase). El admin/ topbar también recibe la clase desde su PHP.
 *
 * Estructura HTML soportada (la pinta el PHP):
 *
 *   body.topbar-v2
 *     > table.stx-topbar-bar
 *         td.stx-topbar-logo > img
 *         td > #CONTENEDOR
 *             > div#DIV_TAB_N
 *                 > div#TAB_N
 *                     > div.stx-tab            (envoltura)
 *                         span.stx-tab-label
 *                         span.stx-tab-close
 *         td > a.stx-tab-add
 *               svg (icono plus)
 * ============================================================ */

body.topbar-v2 {
    background: #ffffff !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    color: var(--gray-700, #425466);
    letter-spacing: -0.005em;
    margin: 0;
    padding: 0;
}

/* Barra principal: quitar gradiente legacy / banner JPG, dejar fondo blanco
 * con divider inferior sutil al estilo Stripe.
 * El TABLE principal es el segundo del body (el primero es #AJAX_DIV envuelto
 * en DIV, no tabla; por seguridad cubrimos ambos selectores). */
body.topbar-v2 > table,
body.topbar-v2 > div + table {
    background-image: none !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--gray-100, #e3e8ee) !important;
    box-shadow: 0 1px 0 rgba(10, 37, 64, 0.02);
    height: 50px;
    border-collapse: collapse;
}

/* Logo */
body.topbar-v2 > div + table td:first-child > div,
body.topbar-v2 > table td:first-child > div {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 18px;
}

body.topbar-v2 > div + table td:first-child img,
body.topbar-v2 > table td:first-child img {
    max-height: 32px;
    width: auto;
    border: 0;
}

/* Contenedor de tabs alineado al fondo (las tabs "se sientan" sobre el divider) */
body.topbar-v2 #CONTENEDOR {
    display: flex;
    align-items: flex-end;
    height: 100%;
    padding-left: 12px !important;
    padding-top: 0 !important;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

body.topbar-v2 #CONTENEDOR::-webkit-scrollbar {
    display: none;
}

/* Cada tab vive en un wrapper DIV#DIV_TAB_N > DIV#TAB_N
 * El TAB_N tiene float:left inline — lo cancelamos para usar flex en el padre. */
body.topbar-v2 #CONTENEDOR > div {
    display: inline-flex;
    align-items: flex-end;
}

body.topbar-v2 #CONTENEDOR > div > div {
    float: none !important;
    display: inline-flex !important;
    align-items: flex-end;
}

/* La tabla interna del tab (legacy) la convertimos en flex de una sola fila */
body.topbar-v2 #CONTENEDOR td table,
body.topbar-v2 #CONTENEDOR div table {
    border-collapse: collapse;
    background: transparent;
}

/* Oculta los GIFs left/right del tab (los cuernos pixelados) */
body.topbar-v2 #CONTENEDOR td > img,
body.topbar-v2 #CONTENEDOR div table td:first-child > img,
body.topbar-v2 #CONTENEDOR div table td:last-child > img {
    display: none !important;
}

/* TAB INACTIVO — celda central .MIDDLE */
body.topbar-v2 #CONTENEDOR .MIDDLE,
body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER {
    background-image: none !important;
    background-color: transparent !important;
    padding: 0 !important;
    border: 0 !important;
    cursor: pointer;
    height: auto !important;
    line-height: 1 !important;
}

/* Pintar la pill del tab vía el ancla interna para evitar pelearnos
 * con los TD/IMG legacy. La estructura real es:
 *   td.MIDDLE > a (clickable)
 * Pintamos el A como pill. */
body.topbar-v2 #CONTENEDOR .MIDDLE a,
body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER a {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--gray-500, #697386) !important;
    text-decoration: none !important;
    padding: 9px 14px 10px !important;
    border-radius: 6px 6px 0 0;
    border-bottom: 2px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    letter-spacing: -0.005em;
    white-space: nowrap;
    line-height: 1;
}

/* Hover (tab inactivo) */
body.topbar-v2 #CONTENEDOR .MIDDLE:hover a,
body.topbar-v2 #CONTENEDOR .MIDDLE a:hover {
    background-color: var(--gray-50, #f6f9fc) !important;
    color: var(--gray-700, #425466) !important;
}

/* Tab activo */
body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER a {
    color: var(--gray-900, #0a2540) !important;
    font-weight: 600 !important;
    border-bottom-color: #635bff !important;
    background-color: #ffffff !important;
}

body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER:hover a,
body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER a:hover {
    background-color: var(--gray-50, #f6f9fc) !important;
}

/* Botón cerrar (X) — la imagen tab_right*.gif. La reemplazamos por una
 * "X" gris pequeña usando mask-image sobre un SVG Lucide.
 * En el último TD del tab vive un IMG con onclick = remove_tab. */
body.topbar-v2 #CONTENEDOR div table td:last-child {
    padding: 0 !important;
    margin: 0 !important;
    vertical-align: middle;
}

body.topbar-v2 #CONTENEDOR div table td:last-child > img {
    display: inline-block !important;
    width: 14px !important;
    height: 14px !important;
    vertical-align: middle;
    margin: 0 8px 0 -4px;
    cursor: pointer;
    /* Truco: ocultamos el GIF original mostrándolo transparente,
     * y dibujamos una "X" Lucide encima vía mask-image. */
    background-color: var(--gray-500, #697386);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 6 6 18M6 6l12 12'/></svg>") center / 12px 12px no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 6 6 18M6 6l12 12'/></svg>") center / 12px 12px no-repeat;
    border-radius: 3px;
    transition: background-color 0.15s ease;
    opacity: 1;
    /* Importante: src del GIF original sigue cargado pero no se ve porque
     * el mask sobrescribe el rendering. Si el navegador no soporta mask
     * (muy raro hoy), cae al GIF original. */
}

body.topbar-v2 #CONTENEDOR div table td:last-child > img:hover {
    background-color: var(--danger, #f04438);
    opacity: 1;
}

/* En la pestaña ACTIVA queremos que la X también acompañe el color */
body.topbar-v2 #CONTENEDOR td.MIDDLE_HOVER + td > img {
    background-color: var(--gray-700, #425466);
}

/* ============================================
   BOTÓN AGREGAR TAB (+)
   ============================================ */

/* TD que envuelve el "+" en el topbar (último td del table principal).
 * Soporta tanto el patrón legacy (IMG GIF) como el nuevo (A.stx-tab-add con SVG). */
body.topbar-v2 > div + table > tbody > tr > td:last-child,
body.topbar-v2 > table > tbody > tr > td:last-child {
    padding-right: 14px !important;
    vertical-align: middle;
}

/* Anchor que envuelve la imagen + */
body.topbar-v2 > div + table > tbody > tr > td:last-child > a,
body.topbar-v2 > table > tbody > tr > td:last-child > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--gray-50, #f6f9fc);
    color: var(--gray-700, #425466);
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    text-decoration: none;
    border: 1px solid var(--gray-100, #e3e8ee);
    cursor: pointer;
}

body.topbar-v2 > div + table > tbody > tr > td:last-child > a:hover,
body.topbar-v2 > table > tbody > tr > td:last-child > a:hover {
    background-color: #635bff;
    color: #ffffff;
    border-color: #635bff;
}

body.topbar-v2 > div + table > tbody > tr > td:last-child > a:active,
body.topbar-v2 > table > tbody > tr > td:last-child > a:active {
    transform: scale(0.96);
}

/* Si el PHP siguió emitiendo el GIF tab_add.gif (fallback), reescribimos al
 * estilo Lucide vía mask-image — mismo truco que con la X. */
body.topbar-v2 > div + table > tbody > tr > td:last-child > a > img,
body.topbar-v2 > table > tbody > tr > td:last-child > a > img {
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    border: 0;
    margin: 0 !important;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='M12 5v14M5 12h14'/></svg>") center / 16px 16px no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='M12 5v14M5 12h14'/></svg>") center / 16px 16px no-repeat;
    opacity: 1;
    transition: none;
}

/* Si el PHP emitió un SVG inline (camino preferido), darle tamaño correcto */
body.topbar-v2 > div + table > tbody > tr > td:last-child > a > svg,
body.topbar-v2 > table > tbody > tr > td:last-child > a > svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    body.topbar-v2 > div + table td:first-child > div,
    body.topbar-v2 > table td:first-child > div {
        padding-left: 12px;
    }
    body.topbar-v2 > div + table td:first-child img,
    body.topbar-v2 > table td:first-child img {
        max-height: 28px;
    }
    body.topbar-v2 #CONTENEDOR .MIDDLE a,
    body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER a {
        font-size: 12px !important;
        padding: 8px 12px 9px !important;
    }
}

@media (max-width: 768px) {
    body.topbar-v2 > div + table td:first-child,
    body.topbar-v2 > table td:first-child {
        width: 0 !important;
        max-width: 0 !important;
        overflow: hidden;
        padding: 0 !important;
    }
    body.topbar-v2 > div + table td:first-child > div,
    body.topbar-v2 > table td:first-child > div {
        display: none;
    }
    body.topbar-v2 #CONTENEDOR {
        padding-left: 48px !important; /* espacio para hamburger si lo hubiera */
    }
    body.topbar-v2 #CONTENEDOR .MIDDLE a,
    body.topbar-v2 #CONTENEDOR .MIDDLE_HOVER a {
        font-size: 11px !important;
        padding: 7px 10px 8px !important;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body.topbar-v2 > div + table > tbody > tr > td:last-child > a,
    body.topbar-v2 > table > tbody > tr > td:last-child > a {
        width: 28px;
        height: 28px;
    }
}

/* ============================================================
 * SECCIÓN 57 — Tooltips + Error overlay (V4)
 * ============================================================
 *
 * Refuerza el rediseño Stripe Dashboard sobre las clases del
 * framework que muestran tooltips al hover y el "error overlay"
 * (popup modal de errores).
 *
 * Clases legacy del framework cubiertas:
 *
 *   Tooltips
 *     .TOOLTIP           — caja flotante del tooltip personalizado
 *     #TOOLTIP_IMG       — flecha (arrow) del tooltip
 *     #LAYER_TOOLTIP     — wrapper absoluto que JS posiciona
 *     #ARROWHEAD         — flecha legacy (css.php / stx legacy)
 *     [title]            — tooltips nativos del browser (no-op a CSS)
 *
 *   Error overlay (utils/stx/css/window/error.css)
 *     .overlay_error     — backdrop modal (oscurecido)
 *     .error_nw / _n / _ne — esquinas y barra superior (header rojo)
 *     .error_w / _e      — bordes laterales del cuadro
 *     .error_sw / _s / _se — esquinas y barra inferior
 *     .error_title       — texto del header del overlay
 *     .error_content     — body con el mensaje (scrollable)
 *     .error_buttons     — pie con botones (Aceptar/Cerrar)
 *     .error_close       — botón X para cerrar
 *
 *   Otras clases de mensaje compatibles
 *     .ERROR_MESSAGE / .ALERT_BOX / .MSG / .OVERLAY_ERROR (uppercase
 *     legacy si llega a aparecer en algún render server-side).
 *
 * Convención visual:
 *   - Tooltip → caja oscura compacta (--stx-gray-700) texto blanco,
 *     radius 4px, sombra sutil, font-size 11px.
 *   - Error overlay → header rojo (--stx-danger) con icono SVG inline
 *     x-circle (Lucide) inyectado vía ::before, animación slide-in
 *     desde arriba.
 *   - Toast notifications → posición fixed esquina inferior derecha,
 *     close button via .error_close, slide-in lateral.
 *
 * No modifica HTML/JS, solo re-estiliza los selectores existentes.
 * ============================================================ */

/* ----- 57.A — Tooltip personalizado (.TOOLTIP / #LAYER_TOOLTIP) --- */
body.main-v2 .TOOLTIP,
.TOOLTIP {
    background-color: var(--stx-gray-700, #334155) !important;
    background-image: none !important;
    color: #ffffff !important;
    border: 1px solid var(--stx-gray-800, #1e293b) !important;
    border-radius: 4px !important;
    -moz-border-radius: 4px !important;
    -webkit-border-radius: 4px !important;
    padding: 6px 10px !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 11px !important;
    line-height: 1.45 !important;
    font-weight: 500 !important;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,0.18)) !important;
    max-width: 320px !important;
    z-index: var(--z-tooltip, 500) !important;
    pointer-events: none;
    letter-spacing: 0.005em;
    animation: stxTooltipIn 120ms ease-out;
}

@keyframes stxTooltipIn {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Flecha del tooltip: oculta GIF, dibuja triángulo oscuro acorde */
body.main-v2 #TOOLTIP_IMG,
#TOOLTIP_IMG {
    background-image: none !important;
    background-color: transparent !important;
    width: 12px !important;
    height: 8px !important;
    overflow: visible !important;
    pointer-events: none;
    z-index: var(--z-tooltip, 500) !important;
}
body.main-v2 #TOOLTIP_IMG img,
#TOOLTIP_IMG img {
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
}
body.main-v2 #TOOLTIP_IMG::after,
#TOOLTIP_IMG::after {
    content: "" !important;
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 6px solid transparent !important;
    border-right: 6px solid transparent !important;
    border-top: 6px solid var(--stx-gray-700, #334155) !important;
    border-bottom: none !important;
    margin: 0 !important;
    position: relative !important;
}

/* Wrapper que JS posiciona; asegurar layering correcto */
#LAYER_TOOLTIP {
    z-index: var(--z-tooltip, 500) !important;
    pointer-events: none !important;
}

/* Flecha legacy stx (css.php) */
#ARROWHEAD {
    z-index: calc(var(--z-tooltip, 500) - 1) !important;
}

/* ----- 57.B — Tooltips por atributo [data-tooltip] (opt-in) ------- */
/* Para nuevos módulos V4 que no quieran depender del JS legacy:
   simplemente añadir data-tooltip="texto" al elemento. */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    background: var(--stx-gray-700, #334155);
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.45;
    white-space: nowrap;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,0.18));
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: var(--z-tooltip, 500);
}
[data-tooltip]::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--stx-gray-700, #334155);
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
    z-index: var(--z-tooltip, 500);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
[data-tooltip-disabled]::after,
[data-tooltip-disabled]::before,
[data-tooltip=""]::after,
[data-tooltip=""]::before {
    display: none !important;
}

/* ----- 57.C — Error overlay (backdrop + cuadro modal) ------------- */
body.main-v2 .overlay_error,
.overlay_error {
    background-color: rgba(10, 37, 64, 0.55) !important;
    opacity: 1 !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: calc(var(--z-modal, 400) - 1) !important;
}

/* Cuadro principal: header rojo con icono x-circle inline */
body.main-v2 .error_nw,
body.main-v2 .error_n,
body.main-v2 .error_ne,
.error_nw,
.error_n,
.error_ne {
    background-image: none !important;
    background-color: var(--stx-danger, #ef4444) !important;
    height: 44px !important;
}
body.main-v2 .error_nw,
.error_nw {
    border-radius: 8px 0 0 0 !important;
    -moz-border-radius: 8px 0 0 0 !important;
}
body.main-v2 .error_ne,
.error_ne {
    border-radius: 0 8px 0 0 !important;
    -moz-border-radius: 0 8px 0 0 !important;
}

/* Título del overlay: blanco, bold, con icono Lucide x-circle */
body.main-v2 .error_title,
.error_title {
    color: #ffffff !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em !important;
    line-height: 44px !important;
    height: 44px !important;
    padding-left: 44px !important;
    text-align: left !important;
    position: relative;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='m15 9-6 6'/><path d='m9 9 6 6'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: 14px center !important;
    background-color: transparent !important;
}

/* Bordes laterales: discretos */
body.main-v2 .error_w,
body.main-v2 .error_e,
.error_w,
.error_e {
    background-image: none !important;
    background-color: #ffffff !important;
    width: 1px !important;
    border-left: 1px solid var(--border-default, #e2e8f0) !important;
}
body.main-v2 .error_e,
.error_e {
    border-left: none !important;
    border-right: 1px solid var(--border-default, #e2e8f0) !important;
}

/* Cuerpo: padding generoso, tipografía Inter */
body.main-v2 .error_content,
.error_content {
    background-color: #ffffff !important;
    color: var(--text-primary, #0f172a) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    line-height: 1.55 !important;
    border: none !important;
    padding: 20px 24px !important;
    word-wrap: break-word;
    word-break: break-word;
    overflow: auto !important;
    min-height: 80px !important;
    max-height: 460px !important;
}
body.main-v2 .error_content table,
.error_content table {
    background-color: transparent !important;
    border-collapse: collapse !important;
    width: 100% !important;
}
body.main-v2 .error_content table td,
.error_content table td {
    padding: 6px 4px !important;
    vertical-align: top;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    color: var(--text-primary, #0f172a) !important;
    line-height: 1.55 !important;
}
body.main-v2 .error_content ul,
.error_content ul {
    margin: 8px 0 0 0 !important;
    padding: 0 0 0 18px !important;
    list-style: disc !important;
    color: var(--text-secondary, #475569) !important;
}
body.main-v2 .error_content li,
.error_content li {
    padding: 2px 0 !important;
    font-size: 13px !important;
    line-height: 1.55 !important;
}

/* Esquinas inferiores con radio Stripe */
body.main-v2 .error_sw,
.error_sw {
    background-image: none !important;
    background-color: #ffffff !important;
    border-radius: 0 0 0 8px !important;
    border-left: 1px solid var(--border-default, #e2e8f0) !important;
    border-bottom: 1px solid var(--border-default, #e2e8f0) !important;
    height: 8px !important;
}
body.main-v2 .error_s,
.error_s {
    background-image: none !important;
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--border-default, #e2e8f0) !important;
    height: 8px !important;
}
body.main-v2 .error_se,
.error_se {
    background-image: none !important;
    background-color: #ffffff !important;
    border-radius: 0 0 8px 0 !important;
    border-right: 1px solid var(--border-default, #e2e8f0) !important;
    border-bottom: 1px solid var(--border-default, #e2e8f0) !important;
    height: 8px !important;
}

/* Pie con botones: alineado a la derecha, separador sutil */
body.main-v2 .error_buttons,
.error_buttons {
    background-color: var(--bg-subtle, #f8fafc) !important;
    border-top: 1px solid var(--border-default, #e2e8f0) !important;
    padding: 12px 16px !important;
    text-align: right !important;
}
body.main-v2 .error_buttons input,
.error_buttons input {
    background-color: var(--stx-danger, #ef4444) !important;
    background-image: none !important;
    color: #ffffff !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border: 1px solid var(--stx-danger-dark, #b91c1c) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 7px 14px !important;
    min-width: 80px !important;
    cursor: pointer !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(0,0,0,0.05)) !important;
    transition: background-color 120ms ease, transform 80ms ease !important;
}
body.main-v2 .error_buttons input:hover,
.error_buttons input:hover {
    background-color: var(--stx-danger-dark, #b91c1c) !important;
}
body.main-v2 .error_buttons input:active,
.error_buttons input:active {
    transform: translateY(1px);
}
body.main-v2 .error_buttons input:focus-visible,
.error_buttons input:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

/* Botón X para cerrar */
body.main-v2 .error_close,
.error_close {
    background-color: transparent !important;
    background-image: none !important;
    color: #ffffff !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    position: relative;
    top: 6px;
    right: 6px;
    transition: background-color 120ms ease !important;
}
body.main-v2 .error_close::after,
.error_close::after {
    content: "" !important;
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    margin: 8px auto !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 6 6 18'/><path d='m6 6 12 12'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}
body.main-v2 .error_close:hover,
.error_close:hover {
    background-color: rgba(255, 255, 255, 0.18) !important;
}

/* Animación slide-in del cuadro modal completo (table padre) */
body.main-v2 .overlay_error + table,
body.main-v2 table.error_w_table,
.overlay_error + table {
    animation: stxErrorIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0,0,0,0.18)) !important;
    border-radius: 8px !important;
    overflow: hidden;
}
@keyframes stxErrorIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ----- 57.D — Mensajes y alertas uppercase legacy ---------------- */
/* Clases que el framework puede emitir como alertas inline (no modal) */
body.main-v2 .ERROR_MESSAGE,
body.main-v2 .OVERLAY_ERROR,
.ERROR_MESSAGE,
.OVERLAY_ERROR {
    background-color: var(--stx-danger-light, #fef2f2) !important;
    color: var(--stx-danger-dark, #b91c1c) !important;
    border: 1px solid var(--stx-danger, #ef4444) !important;
    border-left: 4px solid var(--stx-danger, #ef4444) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 12px 16px 12px 44px !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.55 !important;
    margin: 8px 0 !important;
    position: relative;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b91c1c' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='m15 9-6 6'/><path d='m9 9 6 6'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: 14px center !important;
}
body.main-v2 .ALERT_BOX,
.ALERT_BOX {
    background-color: var(--stx-warning-light, #fffbeb) !important;
    color: var(--stx-warning-dark, #b45309) !important;
    border: 1px solid var(--stx-warning, #f59e0b) !important;
    border-left: 4px solid var(--stx-warning, #f59e0b) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 12px 16px 12px 44px !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.55 !important;
    margin: 8px 0 !important;
    position: relative;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b45309' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/><path d='M12 9v4'/><path d='M12 17h.01'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: 14px center !important;
}
body.main-v2 .MSG,
.MSG {
    background-color: var(--stx-info-light, #f0f9ff) !important;
    color: var(--stx-info-dark, #0369a1) !important;
    border: 1px solid var(--stx-info, #0ea5e9) !important;
    border-left: 4px solid var(--stx-info, #0ea5e9) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 12px 16px 12px 44px !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    line-height: 1.55 !important;
    margin: 8px 0 !important;
    position: relative;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%230369a1' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4'/><path d='M12 8h.01'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: 14px center !important;
}

/* ----- 57.E — Toast notifications (esquina inferior derecha) ----- */
/* Para módulos nuevos V4: aplicar clase .stx-toast al contenedor */
.stx-toast {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    min-width: 280px;
    max-width: 380px;
    background-color: var(--bg-base, #ffffff);
    color: var(--text-primary, #0f172a);
    border: 1px solid var(--border-default, #e2e8f0);
    border-left: 4px solid var(--stx-primary-600, #2563eb);
    border-radius: var(--radius-md, 8px);
    padding: 12px 40px 12px 16px;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 13px;
    line-height: 1.5;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.12));
    z-index: var(--z-tooltip, 500);
    animation: stxToastIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.stx-toast.is-success { border-left-color: var(--stx-success, #22c55e); }
.stx-toast.is-warning { border-left-color: var(--stx-warning, #f59e0b); }
.stx-toast.is-danger  { border-left-color: var(--stx-danger, #ef4444); }
.stx-toast.is-info    { border-left-color: var(--stx-info, #0ea5e9); }

.stx-toast .stx-toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M18 6 6 18'/><path d='m6 6 12 12'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    transition: background-color 120ms ease;
}
.stx-toast .stx-toast-close:hover {
    background-color: var(--bg-muted, #f1f5f9);
}

@keyframes stxToastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
 * SECCIÓN 54 — Formularios de captura de documentos (V4)
 * ============================================================
 * Refresh visual estilo Stripe Dashboard de los formularios de
 * captura de documentos (cabezal + detalle) generados por el
 * framework STX. Cubre, principalmente:
 *
 *   - system/bin/section/operacion/documentos/form/form_encabezado.php
 *   - system/bin/section/operacion/documentos/form/form_detalle.php
 *   - system/bin/section/operacion/status/form/formulario.php
 *   - system/bin/section/operacion/status/form/layer_encabezado.php
 *
 * Estructura HTML legacy que estamos estilizando (intacta):
 *   <FIELDSET>
 *     <LEGEND>Flujo / Sección</LEGEND>
 *     <TABLE ...>
 *       <TR ID="CAMPO_...">
 *         <TD CLASS="FORM_TABLE_DARK">Etiqueta:</TD>
 *         <TD CLASS="FORM_TABLE_LIGHT"><INPUT CLASS="TEXTBOX"></TD>
 *       </TR>
 *     </TABLE>
 *   </FIELDSET>
 *
 * NO modificamos inputs, IDs ni nombres de campos. Solo refrescamos
 * bordes/sombras/legends/spacing. Esta sección refuerza con
 * `!important` cuando hay reglas previas (sección 8, 24, 26) que
 * podrían ganar por especificidad.
 * ============================================================ */

/* FIELDSET — card Stripe con sombra suave, radius generoso. */
body.main-v2 fieldset {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-md, 8px) !important;
    background: var(--bg-base, #ffffff) !important;
    padding: 18px 20px 16px 20px !important;
    margin: 0 0 16px 0 !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
    transition: box-shadow 160ms ease, border-color 160ms ease;
}

/* Hover muy sutil — apenas se nota, pero da sensación táctil. */
body.main-v2 fieldset:hover {
    box-shadow: 0 1px 3px rgba(48,49,61,0.06), 0 2px 8px rgba(48,49,61,0.04) !important;
}

/* Fieldset wrapper externo (envoltorio que contiene otros fieldsets):
   reducimos su peso visual para no duplicar sombras. */
body.main-v2 fieldset:has(> table[cellpadding] > tbody > tr > td > fieldset),
body.main-v2 fieldset:has(> table[cellpadding] > tr > td > fieldset) {
    box-shadow: none !important;
    padding: 14px 14px 8px 14px !important;
}

/* LEGEND — título del card, peso 600, neutral oscuro, tipo Inter. */
body.main-v2 fieldset > legend {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em !important;
    color: var(--text-primary, #0a2540) !important;
    background: var(--bg-base, #ffffff) !important;
    padding: 2px 10px !important;
    margin-left: -4px !important;
    border-radius: 4px !important;
    text-transform: none !important;
}

/* Tabla interna del fieldset — quitar bgcolor blanco y bordes
   heredados, dejar respiro vertical entre rows del formulario. */
body.main-v2 fieldset > table[cellpadding] {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: transparent !important;
}

/* Rows de captura: cada <TR ID="CAMPO_..."> es un par label+input.
   Espaciado vertical generoso entre rows para que respire el form. */
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_DARK,
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_LIGHT {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    vertical-align: middle !important;
    border: none !important;
    background: transparent !important;
}

/* Label (TD izquierdo): peso 500, color secundario, tracking apretado. */
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_DARK {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--text-secondary, #425466) !important;
    letter-spacing: -0.005em !important;
    padding-right: 14px !important;
    padding-left: 2px !important;
    white-space: nowrap;
    width: 1%;
}

/* Asterisco de campos obligatorios: rojo Stripe, no negro/legacy. */
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_DARK .ERROR,
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_DARK font.ERROR {
    color: var(--stx-danger, #f04438) !important;
    font-weight: 600;
}

/* TD de input — sin background, sin padding extra (lo da el INPUT). */
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_LIGHT {
    padding-left: 2px !important;
    padding-right: 2px !important;
}

/* Divs internos del FORM_TABLE_LIGHT (formulario.php los usa para
   separar input + mensajes de error). Quitar background heredado. */
body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_LIGHT > div {
    background: transparent !important;
}

/* INPUTS / SELECTS / TEXTAREA dentro del formulario de captura.
   Refuerzo con !important porque hay reglas previas en main_v2 y
   en la sección 2 que pueden ganar por especificidad. Mantenemos
   tamaño compacto pero respiramos. */
body.main-v2 fieldset tr[id^="CAMPO_"] input.TEXTBOX,
body.main-v2 fieldset tr[id^="CAMPO_"] select.TEXTBOX,
body.main-v2 fieldset tr[id^="CAMPO_"] textarea.TEXTBOX {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 12.5px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 10px !important;
    background: var(--bg-base, #ffffff) !important;
    color: var(--text-primary, #0a2540) !important;
    box-shadow: 0 1px 2px rgba(48,49,61,0.04) !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
    outline: none !important;
}

/* Hover sutil — borde un poco más oscuro. */
body.main-v2 fieldset tr[id^="CAMPO_"] input.TEXTBOX:hover:not(:focus):not([readonly]):not([disabled]),
body.main-v2 fieldset tr[id^="CAMPO_"] select.TEXTBOX:hover:not(:focus):not([disabled]),
body.main-v2 fieldset tr[id^="CAMPO_"] textarea.TEXTBOX:hover:not(:focus):not([readonly]):not([disabled]) {
    border-color: var(--border-strong, #c1c9d2) !important;
}

/* Focus — púrpura Stripe con halo translúcido. */
body.main-v2 fieldset tr[id^="CAMPO_"] input.TEXTBOX:focus,
body.main-v2 fieldset tr[id^="CAMPO_"] select.TEXTBOX:focus,
body.main-v2 fieldset tr[id^="CAMPO_"] textarea.TEXTBOX:focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
}

/* Readonly / disabled — fondo gris-50, texto secundario, no editable. */
body.main-v2 fieldset tr[id^="CAMPO_"] input.TEXTBOX[readonly],
body.main-v2 fieldset tr[id^="CAMPO_"] input.TEXTBOX[disabled],
body.main-v2 fieldset tr[id^="CAMPO_"] select.TEXTBOX[disabled],
body.main-v2 fieldset tr[id^="CAMPO_"] textarea.TEXTBOX[readonly],
body.main-v2 fieldset tr[id^="CAMPO_"] textarea.TEXTBOX[disabled] {
    background: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    cursor: not-allowed;
    box-shadow: none !important;
}

/* También para selects nativos sin class TEXTBOX dentro del row. */
body.main-v2 fieldset tr[id^="CAMPO_"] select:not(.TEXTBOX):not([class*="sb"]) {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 12.5px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 10px !important;
    background: var(--bg-base, #ffffff) !important;
    color: var(--text-primary, #0a2540) !important;
}
body.main-v2 fieldset tr[id^="CAMPO_"] select:not(.TEXTBOX):not([class*="sb"]):focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}

/* Checkbox / radio dentro del form de captura — púrpura Stripe. */
body.main-v2 fieldset tr[id^="CAMPO_"] input[type="checkbox"],
body.main-v2 fieldset tr[id^="CAMPO_"] input[type="radio"] {
    accent-color: var(--stx-primary-600, #635bff);
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

/* Mensajes de error inline bajo cada campo (los inyecta
   Display::errors desde formulario.php). */
body.main-v2 fieldset tr[id^="CAMPO_"] .ERROR,
body.main-v2 fieldset tr[id^="CAMPO_"] .error_message {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 11px !important;
    color: var(--stx-danger, #f04438) !important;
    font-weight: 500;
}

/* Botones flotantes del formulario — respiro vertical cuando viven
   dentro de un fieldset de captura. */
body.main-v2 fieldset .BUTTON_OK,
body.main-v2 fieldset .BUTTON_NOK,
body.main-v2 fieldset .BUTTON_ {
    margin-top: 4px;
    margin-right: 6px;
}

/* Bloque "Detalle" (grid editable). El grid en sí ya está estilizado
   por secciones 5 / 28+. Aquí solo damos más respiro horizontal al
   fieldset contenedor cuando contiene un GRID_TABLE. */
body.main-v2 fieldset:has(.GRID_TABLE) {
    padding: 14px 14px 10px 14px !important;
}

/* Spacer GIF heredado dentro del fieldset (CELLPADDING="10" del HTML
   legacy mete <IMG SRC="spacer.gif"> a veces). Lo aplanamos para que
   no rompa la métrica vertical. */
body.main-v2 fieldset img[src*="spacer.gif"] {
    height: 1px !important;
    vertical-align: middle;
}

/* Responsive — en viewports < 900px stackeamos label arriba del
   input (el TD se vuelve block). Solo dentro del form de captura. */
@media (max-width: 900px) {
    body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_DARK,
    body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_LIGHT {
        display: block !important;
        width: 100% !important;
        padding-top: 4px !important;
        padding-bottom: 4px !important;
        white-space: normal !important;
    }
    body.main-v2 fieldset tr[id^="CAMPO_"] > td.FORM_TABLE_DARK {
        padding-bottom: 2px !important;
        padding-right: 0 !important;
    }
    body.main-v2 fieldset tr[id^="CAMPO_"] input.TEXTBOX,
    body.main-v2 fieldset tr[id^="CAMPO_"] select.TEXTBOX,
    body.main-v2 fieldset tr[id^="CAMPO_"] textarea.TEXTBOX {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ============================================================
 * SECCIÓN 56 — Datepicker (V4)
 * ============================================================
 *
 * Refina el widget DHTML de Mihai Bazon (utils/stx/js/datepicker/) al
 * estilo Stripe Dashboard. La SECCIÓN 15 ya pintaba colores base sobre
 * .calendar — esta seccion COMPLEMENTA con !important sin duplicar:
 *
 *  - caja con sombra/borde redondeado mas suave
 *  - header (mes/año) sin gradiente, navegacion con chevrons SVG
 *    Lucide (data-URI) en vez de entidades unicode dispares
 *  - dias de la semana en peso 600 neutral
 *  - celdas dia: hover suave, hoy con borde purpura, seleccionado
 *    con fondo purpura, otros meses atenuados
 *  - tipografia Inter, animacion de entrada (opacity + slide)
 *
 * Estructura HTML real emitida por datepicker_api.js:
 *
 *   div.calendar
 *     table
 *       thead
 *         tr                              (toggle, .title mes/año, [x])
 *           td.button          (navtype 100 = toggle "-")
 *           td.title
 *           td.button          (navtype 200 = close "x", solo popup)
 *         tr.headrow                      (« ‹ TODAY › »)
 *           td.button × 5
 *         tr.daynames
 *           td.name.wn (opcional, semana)
 *           td.name × 7
 *       tbody
 *         tr.daysrow × 6
 *           td.day.wn (opcional)
 *           td.day  (+ .today / .selected / .weekend / .othermonth
 *                    / .oweekend / .hilite / .active / .disabled)
 *       tfoot
 *         tr.footrow
 *           td.ttip
 *     div.combo  (menu mes / año)
 *       div.label (+ .hilite / .active)
 *
 * Para los chevrons, se oculta el caracter unicode original con
 * font-size:0 + color:transparent y se inyecta el SVG via
 * background-image data-URI. Los 5 botones de .headrow se identifican
 * por nth-of-type bajo td.button.
 * ============================================================ */

/* --- Caja exterior ------------------------------------------- */

div.calendar,
.calendar {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 12px !important;
    color: var(--text-primary, #0a2540) !important;
    background: #ffffff !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 10px !important;
    box-shadow: 0 12px 24px rgba(48, 49, 61, 0.10),
                0 4px 8px rgba(48, 49, 61, 0.06),
                0 0 0 1px rgba(10, 37, 64, 0.02) !important;
    overflow: hidden !important;
    padding: 4px !important;
    animation: stxCalEnter 140ms cubic-bezier(0.16, 1, 0.3, 1) both !important;
    backdrop-filter: none !important;
}

@keyframes stxCalEnter {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.calendar table {
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 2px !important;
    background: transparent !important;
    font-family: inherit !important;
    color: inherit !important;
    cursor: default !important;
}

/* --- Header: titulo (mes / año) ----------------------------- */

.calendar thead tr {
    background: transparent !important;
}

.calendar thead .title {
    background: transparent !important;
    color: var(--text-primary, #0a2540) !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    letter-spacing: -0.01em !important;
    padding: 10px 4px 8px !important;
    text-align: center !important;
    border-radius: 6px !important;
    transition: background-color 120ms ease !important;
}

.calendar thead .title:hover {
    background: var(--stx-gray-100, #f3f6fa) !important;
    cursor: pointer !important;
}

/* Toggle (boton "-" navtype 100) y close "x" (navtype 200):
 * primera y, si aplica, ultima TD de la primera fila del thead.
 * Las pintamos pequenas y discretas, en gris. */
.calendar thead > tr:first-child > td.button {
    background: transparent !important;
    color: var(--text-tertiary, #697386) !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    line-height: 1 !important;
    padding: 6px !important;
    border-radius: 6px !important;
    transition: background-color 120ms ease, color 120ms ease !important;
}

.calendar thead > tr:first-child > td.button:hover,
.calendar thead > tr:first-child > td.button.hilite {
    background: var(--stx-gray-100, #f3f6fa) !important;
    color: var(--text-primary, #0a2540) !important;
}

/* --- Header: navegacion (« ‹ TODAY › ») --------------------- */

.calendar thead tr.headrow {
    background: transparent !important;
}

.calendar thead tr.headrow td.button {
    background: transparent !important;
    color: var(--text-secondary, #425466) !important;
    font-weight: 500 !important;
    font-size: 12px !important;
    line-height: 1 !important;
    padding: 8px 4px !important;
    border-radius: 6px !important;
    text-align: center !important;
    vertical-align: middle !important;
    transition: background-color 120ms ease, color 120ms ease !important;
}

.calendar thead tr.headrow td.button:hover,
.calendar thead tr.headrow td.button.hilite {
    background: var(--stx-gray-100, #f3f6fa) !important;
    color: var(--stx-primary-600, #635bff) !important;
}

.calendar thead tr.headrow td.button.active {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}

/* Chevrons Lucide para los 4 botones de navegacion (1, 2, 4, 5).
 * El 3ro es el texto "TODAY" / "HOY" — ese si queda como label.
 * El font-size:0 esconde el caracter unicode legacy («, ‹, ›, »)
 * y el SVG data-URI llega via background-image. */
.calendar thead tr.headrow td.button:nth-of-type(1),
.calendar thead tr.headrow td.button:nth-of-type(2),
.calendar thead tr.headrow td.button:nth-of-type(4),
.calendar thead tr.headrow td.button:nth-of-type(5) {
    font-size: 0 !important;
    color: transparent !important;
    width: 28px !important;
    min-width: 28px !important;
    height: 28px !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 16px 16px !important;
}

/* « PREV_YEAR (chevrons-left Lucide) */
.calendar thead tr.headrow td.button:nth-of-type(1) {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23425466' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m11 17-5-5 5-5'/><path d='m18 17-5-5 5-5'/></svg>") !important;
}
.calendar thead tr.headrow td.button:nth-of-type(1):hover {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23635bff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='m11 17-5-5 5-5'/><path d='m18 17-5-5 5-5'/></svg>") !important;
}

/* ‹ PREV_MONTH (chevron-left Lucide) */
.calendar thead tr.headrow td.button:nth-of-type(2) {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23425466' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m15 18-6-6 6-6'/></svg>") !important;
}
.calendar thead tr.headrow td.button:nth-of-type(2):hover {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23635bff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='m15 18-6-6 6-6'/></svg>") !important;
}

/* › NEXT_MONTH (chevron-right Lucide) */
.calendar thead tr.headrow td.button:nth-of-type(4) {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23425466' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m9 18 6-6-6-6'/></svg>") !important;
}
.calendar thead tr.headrow td.button:nth-of-type(4):hover {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23635bff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='m9 18 6-6-6-6'/></svg>") !important;
}

/* » NEXT_YEAR (chevrons-right Lucide) */
.calendar thead tr.headrow td.button:nth-of-type(5) {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23425466' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 17 5-5-5-5'/><path d='m13 17 5-5-5-5'/></svg>") !important;
}
.calendar thead tr.headrow td.button:nth-of-type(5):hover {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23635bff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='m6 17 5-5-5-5'/><path d='m13 17 5-5-5-5'/></svg>") !important;
}

/* "HOY" / "TODAY" — el 3er TD queda como pill discreto */
.calendar thead tr.headrow td.button:nth-of-type(3) {
    font-weight: 600 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    color: var(--stx-primary-600, #635bff) !important;
    padding: 8px 10px !important;
}
.calendar thead tr.headrow td.button:nth-of-type(3):hover {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}

/* --- Dias de la semana -------------------------------------- */

.calendar thead tr.daynames {
    background: transparent !important;
}

.calendar thead tr.daynames td,
.calendar thead .name {
    background: transparent !important;
    color: var(--text-tertiary, #697386) !important;
    font-weight: 600 !important;
    font-size: 10.5px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    text-align: center !important;
    padding: 8px 0 6px !important;
    border-bottom: 1px solid var(--border-subtle, #f3f6fa) !important;
}

.calendar thead .name.wn {
    color: var(--text-disabled, #c1c9d2) !important;
    border-right: 1px solid var(--border-subtle, #f3f6fa) !important;
}

.calendar thead .weekend {
    color: var(--text-tertiary, #697386) !important;
}

/* --- Celdas del body (dias) --------------------------------- */

.calendar tbody tr.daysrow {
    background: transparent !important;
}

.calendar tbody .day {
    font-family: inherit !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--text-primary, #0a2540) !important;
    text-align: center !important;
    width: 32px !important;
    height: 30px !important;
    padding: 0 !important;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: background-color 100ms ease,
                color 100ms ease,
                border-color 100ms ease !important;
}

/* Numero de semana */
.calendar tbody .day.wn,
.calendar table .wn {
    background: transparent !important;
    color: var(--text-disabled, #c1c9d2) !important;
    font-weight: 600 !important;
    font-size: 10px !important;
    cursor: default !important;
    border-right: 1px solid var(--border-subtle, #f3f6fa) !important;
    border-radius: 0 !important;
}

/* Hover suave */
.calendar tbody td.day.hilite {
    background: var(--stx-gray-100, #f3f6fa) !important;
    color: var(--text-primary, #0a2540) !important;
    border-color: transparent !important;
}

/* Dia actual (HOY) — borde purpura, fondo claro */
.calendar tbody td.day.today {
    color: var(--stx-primary-700, #5147e2) !important;
    background: #ffffff !important;
    border: 1px solid var(--stx-primary-600, #635bff) !important;
    font-weight: 700 !important;
}

.calendar tbody td.day.today.hilite {
    background: var(--stx-primary-50, #efeefe) !important;
}

/* Dia seleccionado — fondo purpura, blanco */
.calendar tbody td.day.selected {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border: 1px solid var(--stx-primary-600, #635bff) !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 3px rgba(99, 91, 255, 0.35) !important;
}

.calendar tbody td.day.selected.hilite {
    background: var(--stx-primary-700, #5147e2) !important;
    border-color: var(--stx-primary-700, #5147e2) !important;
}

/* Hoy + seleccionado: gana el seleccionado */
.calendar tbody td.day.today.selected {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
}

/* Active (mouse abajo) */
.calendar tbody td.day.active {
    transform: scale(0.94) !important;
    background: var(--stx-primary-100, #dedcfd) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}

/* Otros meses (mes anterior / siguiente) */
.calendar tbody td.day.othermonth {
    color: var(--text-disabled, #c1c9d2) !important;
    font-weight: 400 !important;
    font-size: 11px !important;
}

.calendar tbody td.day.othermonth.hilite {
    color: var(--text-tertiary, #697386) !important;
}

.calendar tbody td.day.othermonth.oweekend {
    color: #fca5a5 !important;
}

/* Fines de semana */
.calendar tbody td.day.weekend {
    color: var(--text-secondary, #425466) !important;
}

/* Disabled */
.calendar tbody td.day.disabled {
    color: var(--text-disabled, #c1c9d2) !important;
    cursor: not-allowed !important;
    background: transparent !important;
}

.calendar tbody td.day.disabled.hilite {
    background: transparent !important;
    color: var(--text-disabled, #c1c9d2) !important;
}

/* Celdas vacias / filas vacias */
.calendar tbody .emptycell {
    visibility: hidden !important;
}

.calendar tbody .emptyrow {
    display: none !important;
}

/* Row hover (cuando se navega por fila completa) */
.calendar tbody tr.rowhilite td.day:not(.selected):not(.today) {
    background: var(--stx-gray-50, #f6f9fc) !important;
}

/* --- Footer (tooltip / status) ------------------------------ */

.calendar tfoot tr.footrow {
    background: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
}

.calendar tfoot .ttip {
    background: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    text-align: center !important;
    padding: 8px 10px !important;
    border-top: 1px solid var(--border-subtle, #f3f6fa) !important;
    border-radius: 0 0 6px 6px !important;
}

.calendar tfoot .hilite {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    border: 0 !important;
}

.calendar tfoot .active {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
}

/* --- Combo (selector de mes / año desplegable) -------------- */

.calendar .combo {
    background: #ffffff !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 16px rgba(48, 49, 61, 0.10),
                0 2px 4px rgba(48, 49, 61, 0.06) !important;
    padding: 4px !important;
    font-family: inherit !important;
    font-size: 11.5px !important;
    color: var(--text-primary, #0a2540) !important;
    width: 5em !important;
    overflow: hidden !important;
    animation: stxCalEnter 120ms ease-out both !important;
}

.calendar .combo .label,
.calendar .combo .label-IEfix {
    background: transparent !important;
    color: var(--text-secondary, #425466) !important;
    text-align: center !important;
    padding: 5px 4px !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background-color 100ms ease, color 100ms ease !important;
}

.calendar .combo .hilite {
    background: var(--stx-gray-100, #f3f6fa) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}

.calendar .combo .active {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
}

/* --- Time picker (cuando esta habilitado) ------------------- */

.calendar td.time {
    background: var(--bg-subtle, #f6f9fc) !important;
    border-top: 1px solid var(--border-subtle, #f3f6fa) !important;
    padding: 6px 0 !important;
    text-align: center !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--text-primary, #0a2540) !important;
}

.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
    background: #ffffff !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 4px !important;
    padding: 3px 8px !important;
    font-weight: 600 !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: 'SF Mono', Menlo, Consolas, monospace !important;
}

.calendar td.time .colon {
    padding: 0 4px !important;
    color: var(--text-tertiary, #697386) !important;
    font-weight: 600 !important;
}

.calendar td.time span.hilite {
    background: var(--stx-gray-100, #f3f6fa) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    border-color: var(--stx-primary-200, #c3befb) !important;
}

.calendar td.time span.active {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border-color: var(--stx-primary-600, #635bff) !important;
}

/* --- Asegurar que no se vea el GIF legacy de fondo --------- */

.calendar,
.calendar table,
.calendar thead .button,
.calendar thead .title,
.calendar thead .name,
.calendar thead .weekend,
.calendar thead .daynames,
.calendar .nav div,
.calendar tbody .wn,
.calendar tfoot .ttip,
.calendar td.time,
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm,
.calendar td.time span.hilite,
.calendar td.time span.active,
.calendar .combo,
.calendar .combo .hilite,
.calendar .combo .active {
    background-image: none !important;
}



/* ============================================================
 * SECCIÓN 52 — Modal dialogs / popups / alertas (V4)
 * ============================================================
 *
 * Refresca visualmente los modales del framework prototype-window que
 * NO están cubiertos por la SECCIÓN 57 (que solo trata error_* y
 * tooltips). Cubre los temas restantes:
 *
 *   utils/stx/js/window.js               -> clase Window + Dialog.alert/confirm/info
 *   utils/stx/css/window/default.css     -> .dialog_*    / .overlay_dialog
 *   utils/stx/css/window/notice.css      -> .notice_*    / .overlay_notice  (Success)
 *   utils/stx/css/window/warning.css     -> .warning_*   / .overlay_warning
 *   utils/stx/css/window/bitacora.css    -> .bitacora_*  / .overlay_bitacora
 *   Dialog.alert/confirm/info genéricos  -> className "alert" por defecto
 *
 * Cada tema legacy define un set fractal de clases con el patrón
 * <theme>_nw, _n, _ne, _w, _e, _sw, _s, _se, _close, _minimize, _maximize,
 * _title, _content, _window, _message, _buttons, _progress, _wired_frame.
 * El JS prototype-window las arma con strings concatenados
 * (className + "_n", etc.) — NO se puede cambiar el HTML sin tocar
 * window.js, por eso el rediseño es 100% CSS: pintamos sobre cada
 * combinación.
 *
 * Reglas visuales V4:
 *   - Borde redondeado 12px en el contenedor (.dialog)
 *   - Sombra grande (--shadow-xl) + borde 1px gris-200
 *   - Encabezado con fondo según severidad
 *     (primary / success / warning / gray-900)
 *   - Contenido sobre fondo blanco, padding generoso 20-24px
 *   - Tipografía Inter, peso 600 título, 400 body
 *   - Botones con estilo Stripe (primary púrpura / cancelar ghost gris)
 *   - Overlay translúcido azul oscuro (#0a2540 / 45% opacity)
 *   - Esquinas/bordes GIF legacy se neutralizan (background-image:none)
 *
 * NOTAS:
 *   - .error_* NO se incluye aquí — vive ya en SECCIÓN 12 + SECCIÓN 57.
 *   - Esta sección REFUERZA la SECCIÓN 11 (dialog default parcial) y
 *     es complementaria a la 57 (que cubre error + tooltips).
 * ============================================================ */

/* ---------- Overlay translúcido común a temas restantes ----------
   .overlay_error ya lo cubre SECCIÓN 57; aquí incluimos los demás. */
body.main-v2 .overlay_dialog,
body.main-v2 .overlay_notice,
body.main-v2 .overlay_warning,
body.main-v2 .overlay_bitacora,
body.main-v2 .overlay_alert,
body.main-v2 .overlay_modal,
body.main-v2 .overlay_lightbox {
    background-color: #0a2540 !important;
    opacity: 0.45 !important;
    -moz-opacity: 0.45 !important;
    filter: alpha(opacity=45) !important;
    backdrop-filter: saturate(120%) blur(2px);
    -webkit-backdrop-filter: saturate(120%) blur(2px);
    transition: opacity 0.18s ease-out;
}

/* ---------- Contenedor table.table_window ---------- */
body.main-v2 .dialog {
    box-shadow: var(--shadow-xl, 0 20px 40px rgba(10,37,64,0.18), 0 8px 16px rgba(10,37,64,0.08)) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background-color: #ffffff !important;
    border: 1px solid var(--stx-gray-200, #e3e8ee) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}
body.main-v2 .dialog table.table_window {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background-color: #ffffff !important;
}

/* ---------- Header (clase _n del tema) ---------- */
body.main-v2 .dialog_n,
body.main-v2 .notice_n,
body.main-v2 .warning_n,
body.main-v2 .bitacora_n,
body.main-v2 .alert_n {
    background-image: none !important;
    height: 44px !important;
    padding: 0 16px !important;
    position: relative;
}

/* Esquinas del header neutralizadas y pintadas */
body.main-v2 .dialog_nw,
body.main-v2 .dialog_ne,
body.main-v2 .notice_nw,
body.main-v2 .notice_ne,
body.main-v2 .warning_nw,
body.main-v2 .warning_ne,
body.main-v2 .bitacora_nw,
body.main-v2 .bitacora_ne,
body.main-v2 .alert_nw,
body.main-v2 .alert_ne {
    background-image: none !important;
    width: 0 !important;
    height: 44px !important;
}

/* Pintura del header por tema */
body.main-v2 .dialog_n,
body.main-v2 .dialog_nw,
body.main-v2 .dialog_ne {
    background-color: var(--stx-primary-600, #635bff) !important;
}
body.main-v2 .notice_n,
body.main-v2 .notice_nw,
body.main-v2 .notice_ne {
    background-color: var(--stx-success, #16b364) !important;
}
body.main-v2 .warning_n,
body.main-v2 .warning_nw,
body.main-v2 .warning_ne {
    background-color: var(--stx-warning, #f79009) !important;
}
body.main-v2 .bitacora_n,
body.main-v2 .bitacora_nw,
body.main-v2 .bitacora_ne {
    background-color: var(--stx-gray-900, #0a2540) !important;
}
body.main-v2 .alert_n,
body.main-v2 .alert_nw,
body.main-v2 .alert_ne {
    background-color: var(--stx-primary-600, #635bff) !important;
}

/* ---------- Título del header ---------- */
body.main-v2 .dialog_title,
body.main-v2 .notice_title,
body.main-v2 .warning_title,
body.main-v2 .bitacora_title,
body.main-v2 .alert_title {
    color: #ffffff !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
    line-height: 44px !important;
    height: auto !important;
    margin: 0 !important;
    text-align: left !important;
    padding-left: 4px !important;
    text-shadow: none !important;
}

/* ---------- Bordes laterales y pie: neutralizar GIFs legacy ---------- */
body.main-v2 .dialog_e,
body.main-v2 .dialog_w,
body.main-v2 .notice_e,
body.main-v2 .notice_w,
body.main-v2 .warning_e,
body.main-v2 .warning_w,
body.main-v2 .bitacora_e,
body.main-v2 .bitacora_w,
body.main-v2 .alert_e,
body.main-v2 .alert_w {
    background-image: none !important;
    background-color: #ffffff !important;
    width: 0 !important;
}
body.main-v2 .dialog_s,
body.main-v2 .dialog_sw,
body.main-v2 .dialog_se,
body.main-v2 .notice_s,
body.main-v2 .notice_sw,
body.main-v2 .notice_se,
body.main-v2 .warning_s,
body.main-v2 .warning_sw,
body.main-v2 .warning_se,
body.main-v2 .bitacora_s,
body.main-v2 .bitacora_sw,
body.main-v2 .bitacora_se,
body.main-v2 .alert_s,
body.main-v2 .alert_sw,
body.main-v2 .alert_se {
    background-image: none !important;
    background-color: #ffffff !important;
    height: 0 !important;
    width: 0 !important;
}

/* Resizer SE: conservar cursor pero quitar el gif */
body.main-v2 .dialog_sizer,
body.main-v2 .notice_sizer,
body.main-v2 .warning_sizer,
body.main-v2 .bitacora_sizer,
body.main-v2 .alert_sizer {
    background-image: none !important;
    background-color: transparent !important;
    width: 12px !important;
    height: 12px !important;
    cursor: se-resize !important;
    opacity: 0.4;
}

/* ---------- NOTICE (success) refinado V4.1 ----------
   El NOTICE_WINDOW de errors.js NO lleva titulo (el title div es &nbsp;):
   la banda verde de 44px se veia como una barra rota sin texto (reporte
   12-jun, catalogo de clientes). Se sustituye por un acento delgado de
   exito y se neutraliza el contenido legacy (tabla inline #DFFBDF). */
body.main-v2 .notice_n,
body.main-v2 .notice_nw,
body.main-v2 .notice_ne {
    height: 8px !important;
    min-height: 8px !important;
    padding: 0 !important;
}
body.main-v2 .notice_title {
    display: none !important;
}
body.main-v2 .notice_close {
    top: 14px !important;
    right: 12px !important;
    z-index: 5;
}
body.main-v2 .notice_content {
    height: auto !important;
    min-height: 44px;
    padding: 14px 18px !important;
    box-sizing: border-box;
}
/* Tabla legacy inline del mensaje (bgcolor #DFFBDF + cellspacing) */
body.main-v2 .notice_content table {
    background-color: transparent !important;
    border-spacing: 0 !important;
    border-collapse: collapse !important;
}
body.main-v2 .notice_content table td {
    padding: 0 8px 0 0 !important;
    vertical-align: middle !important;
}
body.main-v2 .notice_content ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}
body.main-v2 .notice_content li {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    color: var(--stx-gray-900, #1a1f36) !important;
    padding: 2px 0 !important;
}
body.main-v2 .notice_content li b {
    font-weight: 700 !important;
}

/* ---------- Botón cerrar (X) ---------- */
body.main-v2 .dialog_close,
body.main-v2 .notice_close,
body.main-v2 .warning_close,
body.main-v2 .bitacora_close,
body.main-v2 .alert_close {
    background-image: none !important;
    background-color: rgba(255,255,255,0.85) !important;
    width: 24px !important;
    height: 24px !important;
    top: 10px !important;
    right: 12px !important;
    left: auto !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    z-index: 2000 !important;
    transition: background-color 0.15s ease-out, transform 0.15s ease-out;
    /* Glifo X dibujado con un mask SVG inline (Lucide x) */
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
            mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    -webkit-mask-size: 14px 14px;
            mask-size: 14px 14px;
}
body.main-v2 .dialog_close:hover,
body.main-v2 .notice_close:hover,
body.main-v2 .warning_close:hover,
body.main-v2 .bitacora_close:hover,
body.main-v2 .alert_close:hover {
    background-color: #ffffff !important;
    transform: scale(1.08);
}
body.main-v2 .dialog_close:active,
body.main-v2 .notice_close:active,
body.main-v2 .warning_close:active,
body.main-v2 .bitacora_close:active,
body.main-v2 .alert_close:active {
    transform: scale(0.94);
}

/* NOTICE V4.1: el header ahora es un acento de 8px, asi que la X cae sobre
   fondo blanco — el glifo (mask sobre background-color) debe ser gris para
   ser visible, no blanco-sobre-blanco. Va DESPUES del bloque generico para
   ganar el cascade. */
body.main-v2 .notice_close {
    background-color: var(--stx-gray-500, #697386) !important;
    top: 16px !important;
}
body.main-v2 .notice_close:hover {
    background-color: var(--stx-gray-900, #1a1f36) !important;
}

/* ---------- Minimize / Maximize: ocultar (UI moderna) ---------- */
body.main-v2 .dialog_minimize,
body.main-v2 .dialog_maximize,
body.main-v2 .notice_minimize,
body.main-v2 .notice_maximize,
body.main-v2 .warning_minimize,
body.main-v2 .warning_maximize,
body.main-v2 .bitacora_minimize,
body.main-v2 .bitacora_maximize,
body.main-v2 .alert_minimize,
body.main-v2 .alert_maximize {
    display: none !important;
}

/* ---------- Content (cuerpo del modal) ---------- */
body.main-v2 .dialog_content,
body.main-v2 .notice_content,
body.main-v2 .warning_content,
body.main-v2 .bitacora_content,
body.main-v2 .alert_content {
    background-image: none !important;
    background-color: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    letter-spacing: -0.005em !important;
    padding: 20px 24px !important;
    border: none !important;
}

/* ---------- Caja interna .<tema>_window (Dialog.alert/confirm) ---------- */
body.main-v2 .dialog_window,
body.main-v2 .notice_window,
body.main-v2 .warning_window,
body.main-v2 .bitacora_window,
body.main-v2 .alert_window {
    background-color: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 auto !important;
    width: auto !important;
    max-width: 100%;
}

/* ---------- Mensaje (.<tema>_message) ---------- */
body.main-v2 .dialog_message,
body.main-v2 .notice_message,
body.main-v2 .warning_message,
body.main-v2 .bitacora_message,
body.main-v2 .alert_message,
body.main-v2 #modal_dialog_message {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 1.55 !important;
    color: var(--text-primary, #0a2540) !important;
    text-align: left !important;
    padding: 4px 0 20px 0 !important;
    width: 100% !important;
    background: transparent !important;
}

/* ---------- Bloque de botones ---------- */
body.main-v2 .dialog_buttons,
body.main-v2 .notice_buttons,
body.main-v2 .warning_buttons,
body.main-v2 .bitacora_buttons,
body.main-v2 .alert_buttons {
    text-align: right !important;
    width: 100% !important;
    padding-top: 12px !important;
    border-top: 1px solid var(--stx-gray-200, #e3e8ee) !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
}
body.main-v2 .dialog_buttons input,
body.main-v2 .notice_buttons input,
body.main-v2 .warning_buttons input,
body.main-v2 .bitacora_buttons input,
body.main-v2 .alert_buttons input,
body.main-v2 .dialog_buttons button,
body.main-v2 .notice_buttons button,
body.main-v2 .warning_buttons button,
body.main-v2 .bitacora_buttons button,
body.main-v2 .alert_buttons button {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: -0.005em !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    border: 1px solid transparent !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out, transform 0.05s ease-out;
    min-width: 88px !important;
    width: auto !important;
    margin: 0 !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.08));
}
body.main-v2 .dialog_buttons input:hover,
body.main-v2 .notice_buttons input:hover,
body.main-v2 .warning_buttons input:hover,
body.main-v2 .bitacora_buttons input:hover,
body.main-v2 .alert_buttons input:hover,
body.main-v2 .dialog_buttons button:hover,
body.main-v2 .notice_buttons button:hover,
body.main-v2 .warning_buttons button:hover,
body.main-v2 .bitacora_buttons button:hover,
body.main-v2 .alert_buttons button:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(48,49,61,0.1));
}
body.main-v2 .dialog_buttons input:active,
body.main-v2 .notice_buttons input:active,
body.main-v2 .warning_buttons input:active,
body.main-v2 .bitacora_buttons input:active,
body.main-v2 .alert_buttons input:active {
    transform: translateY(1px);
}

/* Segundo botón (Cancelar) en confirm: estilo "ghost" gris.
   Dialog.confirm renderiza dos <input type='button'> seguidos. */
body.main-v2 .dialog_buttons input + input,
body.main-v2 .notice_buttons input + input,
body.main-v2 .warning_buttons input + input,
body.main-v2 .bitacora_buttons input + input,
body.main-v2 .alert_buttons input + input,
body.main-v2 .dialog_buttons input.cancel,
body.main-v2 .notice_buttons input.cancel,
body.main-v2 .warning_buttons input.cancel,
body.main-v2 .bitacora_buttons input.cancel,
body.main-v2 .alert_buttons input.cancel {
    background-color: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
    border: 1px solid var(--stx-gray-200, #e3e8ee) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
}
body.main-v2 .dialog_buttons input + input:hover,
body.main-v2 .notice_buttons input + input:hover,
body.main-v2 .warning_buttons input + input:hover,
body.main-v2 .bitacora_buttons input + input:hover,
body.main-v2 .alert_buttons input + input:hover,
body.main-v2 .dialog_buttons input.cancel:hover,
body.main-v2 .notice_buttons input.cancel:hover,
body.main-v2 .warning_buttons input.cancel:hover,
body.main-v2 .bitacora_buttons input.cancel:hover,
body.main-v2 .alert_buttons input.cancel:hover {
    background-color: var(--stx-gray-50, #f6f9fc) !important;
    border-color: var(--stx-gray-300, #c1c9d2) !important;
}

/* Variantes por severidad para el botón OK */
body.main-v2 .warning_buttons input:first-child,
body.main-v2 .warning_buttons button:first-child {
    background-color: var(--stx-warning, #f79009) !important;
}
body.main-v2 .warning_buttons input:first-child:hover,
body.main-v2 .warning_buttons button:first-child:hover {
    background-color: var(--stx-warning-dark, #b54708) !important;
}
body.main-v2 .notice_buttons input:first-child,
body.main-v2 .notice_buttons button:first-child {
    background-color: var(--stx-success, #16b364) !important;
}
body.main-v2 .notice_buttons input:first-child:hover,
body.main-v2 .notice_buttons button:first-child:hover {
    background-color: var(--stx-success-dark, #027a48) !important;
}

/* ---------- Progress bar interna ---------- */
body.main-v2 .dialog_progress,
body.main-v2 .notice_progress,
body.main-v2 .warning_progress,
body.main-v2 .bitacora_progress,
body.main-v2 .alert_progress,
body.main-v2 #modal_dialog_progress {
    background-image: none !important;
    background-color: var(--stx-gray-100, #f3f6fa) !important;
    border-radius: 999px !important;
    height: 6px !important;
    overflow: hidden !important;
    position: relative;
    margin: 8px 0 !important;
}
body.main-v2 .dialog_progress::after,
body.main-v2 .notice_progress::after,
body.main-v2 .warning_progress::after,
body.main-v2 .bitacora_progress::after,
body.main-v2 .alert_progress::after,
body.main-v2 #modal_dialog_progress::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    background-color: var(--stx-primary-600, #635bff);
    border-radius: 999px;
    animation: stx-modal-progress-slide 1.4s infinite ease-in-out;
}
@keyframes stx-modal-progress-slide {
    0%   { transform: translateX(-100%); }
    50%  { transform: translateX(150%); }
    100% { transform: translateX(250%); }
}

/* ---------- Wired frame (drag fantasma) ---------- */
body.main-v2 .wired_frame,
body.main-v2 .dialog_wired_frame,
body.main-v2 .notice_wired_frame,
body.main-v2 .warning_wired_frame,
body.main-v2 .bitacora_wired_frame,
body.main-v2 .alert_wired_frame {
    border: 2px dashed var(--stx-primary-400, #8276f2) !important;
    background-color: rgba(99, 91, 255, 0.08) !important;
    border-radius: 10px !important;
    opacity: 1 !important;
}

/* ---------- Top draggable cursor: feedback claro ---------- */
body.main-v2 .top_draggable,
body.main-v2 .bottom_draggable {
    cursor: move !important;
}

/* ---------- Inputs/Selects dentro del modal: estilo V4 ---------- */
body.main-v2 .dialog_content input[type="text"],
body.main-v2 .dialog_content input[type="number"],
body.main-v2 .dialog_content input[type="password"],
body.main-v2 .dialog_content input[type="email"],
body.main-v2 .dialog_content select,
body.main-v2 .dialog_content textarea,
body.main-v2 .notice_content input[type="text"],
body.main-v2 .notice_content select,
body.main-v2 .notice_content textarea,
body.main-v2 .warning_content input[type="text"],
body.main-v2 .warning_content select,
body.main-v2 .warning_content textarea,
body.main-v2 .bitacora_content input[type="text"],
body.main-v2 .bitacora_content select,
body.main-v2 .bitacora_content textarea {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 13px !important;
    padding: 7px 10px !important;
    border: 1px solid var(--stx-gray-200, #e3e8ee) !important;
    border-radius: 6px !important;
    background-color: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
body.main-v2 .dialog_content input[type="text"]:focus,
body.main-v2 .dialog_content select:focus,
body.main-v2 .dialog_content textarea:focus,
body.main-v2 .notice_content input[type="text"]:focus,
body.main-v2 .warning_content input[type="text"]:focus,
body.main-v2 .bitacora_content input[type="text"]:focus {
    outline: none !important;
    border-color: var(--stx-primary-500, #6c5dff) !important;
    box-shadow: var(--shadow-focus, 0 0 0 3px rgba(99,91,255,0.15)) !important;
}

/* ---------- iframe interno (Dialog.confirm con URL) ---------- */
body.main-v2 .dialog_content > iframe,
body.main-v2 .notice_content > iframe,
body.main-v2 .warning_content > iframe,
body.main-v2 .bitacora_content > iframe {
    border: none !important;
    background: #ffffff !important;
    border-radius: 0 !important;
}

/* ---------- Status bar (footer del Window legacy) ---------- */
body.main-v2 .status_bar,
body.main-v2 .status_bar input {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 12px !important;
    color: var(--text-tertiary, #697386) !important;
}

/* ---------- Responsive: en móvil el modal ocupa casi todo el viewport ---------- */
@media (max-width: 600px) {
    body.main-v2 .dialog {
        border-radius: 10px !important;
        max-width: 92vw !important;
    }
    body.main-v2 .dialog_content,
    body.main-v2 .notice_content,
    body.main-v2 .warning_content,
    body.main-v2 .bitacora_content,
    body.main-v2 .alert_content {
        padding: 16px !important;
        font-size: 13px !important;
    }
    body.main-v2 .dialog_buttons,
    body.main-v2 .notice_buttons,
    body.main-v2 .warning_buttons,
    body.main-v2 .bitacora_buttons,
    body.main-v2 .alert_buttons {
        flex-wrap: wrap;
        justify-content: stretch;
    }
    body.main-v2 .dialog_buttons input,
    body.main-v2 .notice_buttons input,
    body.main-v2 .warning_buttons input,
    body.main-v2 .bitacora_buttons input,
    body.main-v2 .alert_buttons input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }
}

/* ============================================================
 * SECCIÓN 55 — Reportes renderizados (V4)
 * ============================================================
 * Estiliza el HTML emitido por el XSL de reportes
 * (system/include/lib/xsl/reportes/html/base_report.xsl) sin
 * tocar el XSL más allá de inyectar Inter + tokens + theme V4 y
 * marcar el <body> con class="stx-report-render".
 *
 * Clases legacy que se renderizan desde grid_base.xsl /
 * header_base.xsl y a las que aplica esta sección:
 *   div#header.base                       - encabezado del reporte
 *   div#header.base h1 / h2               - título y subtítulo
 *   div#header.base ul / li               - lista de filtros usados
 *   table.grid_base                       - tabla principal
 *   table.grid_base td.headers            - headers de columna
 *   table.grid_base td.summary            - fila de totales
 *   table.grid_base td.summary span.item  - cada item del summary
 *   table.grid_base td.contenedor_detalle - celda contenedora de subgrid
 *   table.grid_base_detalle               - tabla detalle (nested)
 *   table.grid_base_detalle td.headers    - headers de detalle
 *
 * Reglas con scope estricto vía body.stx-report-render para NO
 * contaminar el panel de listado de reportes (ya rediseñado en
 * SECCIÓN 36) ni cualquier otra vista del ERP.
 * ============================================================ */

/* Reset suave de body cuando es un reporte renderizado */
body.stx-report-render {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 'Helvetica Neue', Arial, sans-serif !important;
    font-size: 13px !important;
    color: var(--text-primary, #0a2540) !important;
    background-color: var(--bg-base, #ffffff) !important;
    letter-spacing: -0.005em !important;
    margin: 0 !important;
    padding: 24px !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
 * 55.1 — Encabezado del reporte (div#header.base)
 * ============================================================ */
body.stx-report-render div#header.base,
body.stx-report-render #header.base {
    background: var(--bg-base, #ffffff) !important;
    background-image: none !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-left: 3px solid var(--stx-primary-600, #635bff) !important;
    border-radius: 8px !important;
    padding: 18px 22px !important;
    margin: 0 0 20px 0 !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
    color: var(--text-primary, #0a2540) !important;
}

body.stx-report-render div#header.base img,
body.stx-report-render #header.base img {
    max-height: 38px !important;
    width: auto !important;
    margin: 0 0 12px 0 !important;
    display: block !important;
    filter: none !important;
}

body.stx-report-render div#header.base h1,
body.stx-report-render #header.base h1 {
    font-family: 'Inter', sans-serif !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--text-primary, #0a2540) !important;
    margin: 0 0 4px 0 !important;
    padding: 0 !important;
    letter-spacing: -0.02em !important;
    line-height: 1.25 !important;
}

body.stx-report-render div#header.base h2,
body.stx-report-render #header.base h2 {
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: var(--text-tertiary, #697386) !important;
    margin: 14px 0 6px 0 !important;
    padding: 0 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
}

body.stx-report-render div#header.base ul,
body.stx-report-render #header.base ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px 10px !important;
}

body.stx-report-render div#header.base ul li,
body.stx-report-render #header.base ul li {
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    color: var(--text-secondary, #425466) !important;
    list-style: none !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    padding: 4px 10px !important;
    margin: 0 !important;
    line-height: 1.4 !important;
}

body.stx-report-render div#header.base ul li b,
body.stx-report-render #header.base ul li b {
    font-weight: 600 !important;
    color: var(--text-primary, #0a2540) !important;
    margin-right: 4px !important;
}

/* ============================================================
 * 55.2 — Tabla principal (grid_base)
 * ============================================================ */
body.stx-report-render table.grid_base {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: var(--bg-base, #ffffff) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
    overflow: hidden !important;
    margin: 0 0 16px 0 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12.5px !important;
}

body.stx-report-render table.grid_base td {
    padding: 7px 10px !important;
    border-left: none !important;
    border-bottom: 1px solid var(--border-subtle, #f3f6fa) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12.5px !important;
    line-height: 1.4 !important;
    background-color: var(--bg-base, #ffffff) !important;
    vertical-align: middle !important;
}

/* Celdas numéricas: tipografía monospace + tabular */
body.stx-report-render table.grid_base td[align="right"],
body.stx-report-render table.grid_base td[ALIGN="right"],
body.stx-report-render table.grid_base td[align="RIGHT"] {
    font-family: 'JetBrains Mono', 'SFMono-Regular', 'Menlo', monospace !important;
    font-variant-numeric: tabular-nums !important;
    font-size: 12px !important;
    color: var(--text-primary, #0a2540) !important;
}

/* Header de columna */
body.stx-report-render table.grid_base td.headers {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    background-image: none !important;
    color: var(--text-secondary, #425466) !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    border-left: none !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee) !important;
    padding: 10px 10px !important;
    text-align: left !important;
    white-space: nowrap !important;
}

/* Hover de fila (preservar headers/summary/contenedor intactos) */
body.stx-report-render table.grid_base tr:hover td:not(.headers):not(.summary):not(.contenedor_detalle) {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}

/* Fila de totales / summary */
body.stx-report-render table.grid_base td.summary {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    background-image: none !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 12.5px !important;
    padding: 12px 10px !important;
    border-top: 2px solid var(--border-default, #e3e8ee) !important;
    border-bottom: none !important;
}

body.stx-report-render table.grid_base td.summary span.item {
    display: inline-block !important;
    float: none !important;
    padding: 4px 10px !important;
    margin: 2px 8px 2px 0 !important;
    background-color: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-primary, #0a2540) !important;
    transition: background-color 120ms ease, border-color 120ms ease !important;
}

body.stx-report-render table.grid_base td.summary span.item:hover {
    background-color: var(--stx-primary-50, #efeefe) !important;
    border-color: var(--stx-primary-200, #c3befb) !important;
}

/* ============================================================
 * 55.3 — Contenedor de detalle (sub-grid nested)
 * ============================================================ */
body.stx-report-render table.grid_base td.contenedor_detalle {
    padding: 8px 12px !important;
    background-color: var(--bg-sunken, #f3f6fa) !important;
    background-image: none !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee) !important;
}

/* ============================================================
 * 55.4 — Tabla detalle (grid_base_detalle)
 * ============================================================ */
body.stx-report-render table.grid_base_detalle {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: var(--bg-base, #ffffff) !important;
    width: 100% !important;
    float: none !important;
    margin: 4px 0 !important;
    overflow: hidden !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
}

body.stx-report-render table.grid_base_detalle td {
    padding: 6px 10px !important;
    border-left: none !important;
    border-bottom: 1px solid var(--border-subtle, #f3f6fa) !important;
    background-color: var(--bg-base, #ffffff) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 11.5px !important;
    line-height: 1.4 !important;
}

body.stx-report-render table.grid_base_detalle td.headers {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    background-image: none !important;
    color: var(--text-tertiary, #697386) !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 10.5px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee) !important;
    padding: 8px 10px !important;
}

/* Celdas numéricas del detalle */
body.stx-report-render table.grid_base_detalle td[align="right"],
body.stx-report-render table.grid_base_detalle td[ALIGN="right"],
body.stx-report-render table.grid_base_detalle td[align="RIGHT"] {
    font-family: 'JetBrains Mono', 'SFMono-Regular', 'Menlo', monospace !important;
    font-variant-numeric: tabular-nums !important;
    font-size: 11px !important;
    color: var(--text-primary, #0a2540) !important;
}

body.stx-report-render table.grid_base_detalle tr:hover td:not(.headers) {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}

/* ============================================================
 * 55.5 — Print + viewport pequeño
 * ============================================================ */
@media print {
    body.stx-report-render {
        padding: 0 !important;
        background: #ffffff !important;
    }
    body.stx-report-render div#header.base,
    body.stx-report-render #header.base {
        box-shadow: none !important;
        page-break-after: avoid !important;
    }
    body.stx-report-render table.grid_base,
    body.stx-report-render table.grid_base_detalle {
        box-shadow: none !important;
        page-break-inside: auto !important;
    }
    body.stx-report-render table.grid_base tr,
    body.stx-report-render table.grid_base_detalle tr {
        page-break-inside: avoid !important;
    }
}

@media (max-width: 720px) {
    body.stx-report-render {
        padding: 12px !important;
    }
    body.stx-report-render div#header.base,
    body.stx-report-render #header.base {
        padding: 14px 16px !important;
    }
    body.stx-report-render div#header.base h1,
    body.stx-report-render #header.base h1 {
        font-size: 16px !important;
    }
    body.stx-report-render table.grid_base td,
    body.stx-report-render table.grid_base_detalle td {
        padding: 6px 8px !important;
        font-size: 11.5px !important;
    }
}

/* ============================================================
 * SECCIÓN 53 — PDV layout principal (V4)
 * ============================================================
 * Rediseño visual estilo Stripe Dashboard de la pantalla principal
 * del Punto de Venta (pdv.php) y sus capas (layer_unticket.php,
 * layer_unafactura.php, layer_*).
 *
 * IMPORTANTE: El body del PDV lleva clase `pdv-popup` (además de
 * `main-v2`). El JS replacer ignora esta pantalla a propósito para
 * NO inyectar el global toolbar, pero los selectores CSS deben
 * aplicar igualmente. Por eso aquí usamos `body.pdv-popup ...` y
 * selectores genéricos sin `body.main-v2`.
 *
 * Ámbito:
 *   - .pdv-shell / .pdv-card / .pdv-divider-row / .pdv-action-bar-cell
 *     .pdv-action-bar-gap / .pdv-logo-cell — wrappers V4 del layout
 *   - .LAYER_TABS / .OFF_MIDDLE_PDV / .ON_MIDDLE_PDV — pestañas tic/fact
 *   - .LAYER_DOCUMENTO_MAIN / .LAYER_TOOLS — capas principal y lateral
 *   - .GRID_HEADER_PDV / .GRID_TITLE_PDV / .ODD_ROW_PDV / .EVEN_ROW_PDV
 *   - .SUBTOTALES / .TOTALES — totales del documento
 *   - .BUTTON_ADD_FDP / .BUTTON_GUARDAR / .BUTTON_GUARDAR_IMPRIMIR
 *     .BUTTON_CONTINUAR_CAMPOS_EXTRAS / .BUTTON_CANCELAR_CAMPOS_EXTRAS
 *   - .PDV_DYNAMIC_LIST_HEADER/OVER/OUT_A/OUT_B — autocomplete dropdown
 *
 * NO toca .pdv-action-icon / .pdv-side-icon / .pdv-side-label /
 * .pdv-action-label (ya definidas en SECCIÓN 38). Aquí se les añade
 * un override con namespace body.pdv-popup para que apliquen incluso
 * cuando el JS ignora esta pantalla.
 * ============================================================ */

body.pdv-popup {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    font-family: 'Inter', sans-serif !important;
    letter-spacing: -0.005em;
    color: var(--text-primary, #0a2540);
}
.pdv-shell {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}

body.pdv-popup .pdv-card {
    background-color: var(--bg-base, #ffffff);
    border: 1px solid var(--border-default, #e3e8ee);
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 4px 8px rgba(48,49,61,0.06));
    overflow: hidden;
    margin: 8px auto;
    width: 825px;
}
body.pdv-popup .pdv-card > table {
    background-color: transparent !important;
}
body.pdv-popup .pdv-divider-row {
    background-color: var(--border-default, #e3e8ee) !important;
    height: 1px;
    line-height: 1px;
    font-size: 0;
}
body.pdv-popup .pdv-action-bar-gap {
    background-color: transparent !important;
}
body.pdv-popup .pdv-logo-cell {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 10px;
    background-color: var(--bg-base, #ffffff);
    overflow: hidden;
}

/* Pestañas (cabecera) — barra Stripe purpura con tabs blancos */
body.pdv-popup .LAYER_TABS {
    background-color: var(--stx-primary-600, #635bff) !important;
    background-image: linear-gradient(180deg, var(--stx-primary-600, #635bff), var(--stx-primary-700, #5147e2));
    height: 32px !important;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
body.pdv-popup .OFF_MIDDLE_PDV,
body.pdv-popup .ON_MIDDLE_PDV {
    background-image: none !important;
    background-color: transparent !important;
    padding: 6px 14px !important;
    cursor: pointer;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: rgba(255,255,255,0.80) !important;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    transition: background-color 120ms ease, color 120ms ease;
    border: none;
}
body.pdv-popup .OFF_MIDDLE_PDV:hover {
    background-color: rgba(255,255,255,0.08) !important;
    color: #ffffff !important;
}
body.pdv-popup .ON_MIDDLE_PDV {
    background-color: var(--bg-base, #ffffff) !important;
    color: var(--text-primary, #0a2540) !important;
    font-weight: 600 !important;
}

body.pdv-popup .LAYER_DOCUMENTO_MAIN {
    background-color: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee);
    border-top: none;
    border-radius: 0 0 8px 8px;
}
body.pdv-popup .LAYER_TOOLS {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px;
}

/* Grid PDV: cabecera neutra Stripe + filas alternadas + hover */
body.pdv-popup .GRID_HEADER_PDV {
    background-color: var(--gray-50, #f6f9fc) !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee) !important;
    height: auto !important;
}
body.pdv-popup .GRID_HEADER_PDV th,
body.pdv-popup .GRID_HEADER_PDV td {
    background-color: var(--gray-50, #f6f9fc) !important;
    padding: 8px 10px !important;
}
body.pdv-popup .GRID_TITLE_PDV {
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: var(--gray-700, #425466) !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 4px 0 !important;
}
body.pdv-popup .ODD_ROW_PDV {
    background-color: var(--bg-base, #ffffff) !important;
}
body.pdv-popup .EVEN_ROW_PDV {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}
body.pdv-popup .ODD_ROW_PDV:hover,
body.pdv-popup .EVEN_ROW_PDV:hover {
    background-color: var(--stx-primary-50, #efeefe) !important;
}
body.pdv-popup .ODD_ROW_PDV td,
body.pdv-popup .EVEN_ROW_PDV td {
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    color: var(--text-primary, #0a2540) !important;
    border-bottom: 1px solid var(--border-subtle, #f3f6fa) !important;
}

/* Totales */
body.pdv-popup .SUBTOTALES {
    color: var(--gray-700, #425466) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    letter-spacing: -0.01em;
}
body.pdv-popup .TOTALES {
    color: var(--stx-primary-700, #5147e2) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
}

/* Action bar superior (Ticket / Factura / Devolucion / Caja / ...) */
body.pdv-popup .pdv-action-bar-cell {
    padding: 6px 8px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 10px;
    background-color: var(--bg-base, #ffffff);
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon,
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon.stx-icon-tile-host {
    min-width: 0 !important;
    max-width: none !important;
    flex: 1 1 0 !important;
    padding: 6px 4px !important;
    margin: 0 !important;
    gap: 4px !important;
    height: 72px !important;
    border-radius: 10px !important;
    font-family: 'Inter', sans-serif !important;
    background-color: var(--bg-base, #ffffff);
    border: 1px solid transparent;
    transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon:hover {
    background-color: var(--gray-50, #f6f9fc);
    border-color: var(--border-default, #e3e8ee);
    transform: translateY(-1px);
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile .stx-svg-icon {
    width: 18px !important;
    height: 18px !important;
}
body.pdv-popup .pdv-action-bar .pdv-action-label {
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: var(--gray-700, #425466) !important;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
/* Fallback: si el JS replacer aún no corrió, encoge el IMG GIF grande */
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon > img {
    max-width: 28px;
    max-height: 28px;
    display: block;
    margin: 0 auto;
}

/* Botones grandes (FDP / Guardar / Continuar / Cancelar) — sin sprite GIF */
body.pdv-popup .BUTTON_ADD_FDP,
body.pdv-popup .BUTTON_GUARDAR,
body.pdv-popup .BUTTON_GUARDAR_IMPRIMIR,
body.pdv-popup .BUTTON_CONTINUAR_CAMPOS_EXTRAS,
body.pdv-popup .BUTTON_CANCELAR_CAMPOS_EXTRAS {
    background-image: none !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em !important;
    text-decoration: none !important;
    border: 1px solid var(--stx-primary-700, #5147e2) !important;
    border-radius: 8px !important;
    height: auto !important;
    min-height: 36px !important;
    padding: 8px 16px !important;
    cursor: pointer;
    transition: background-color 120ms ease, transform 100ms ease, box-shadow 120ms ease;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04));
    width: auto !important;
}
body.pdv-popup .BUTTON_ADD_FDP:hover,
body.pdv-popup .BUTTON_GUARDAR:hover,
body.pdv-popup .BUTTON_GUARDAR_IMPRIMIR:hover,
body.pdv-popup .BUTTON_CONTINUAR_CAMPOS_EXTRAS:hover,
body.pdv-popup .BUTTON_CANCELAR_CAMPOS_EXTRAS:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(48,49,61,0.06));
}
body.pdv-popup .BUTTON_ADD_FDP:active,
body.pdv-popup .BUTTON_GUARDAR:active,
body.pdv-popup .BUTTON_GUARDAR_IMPRIMIR:active,
body.pdv-popup .BUTTON_CONTINUAR_CAMPOS_EXTRAS:active,
body.pdv-popup .BUTTON_CANCELAR_CAMPOS_EXTRAS:active {
    transform: scale(0.985);
}
/* Guardar (sin imprimir) en Success verde */
body.pdv-popup .BUTTON_GUARDAR {
    background-color: var(--stx-success, #16b364) !important;
    border-color: var(--stx-success-dark, #027a48) !important;
}
body.pdv-popup .BUTTON_GUARDAR:hover {
    background-color: var(--stx-success-dark, #027a48) !important;
}
/* Cancelar campos extras en Danger outline */
body.pdv-popup .BUTTON_CANCELAR_CAMPOS_EXTRAS {
    background-color: var(--bg-base, #ffffff) !important;
    color: var(--stx-danger, #f04438) !important;
    border-color: var(--stx-danger, #f04438) !important;
}
body.pdv-popup .BUTTON_CANCELAR_CAMPOS_EXTRAS:hover {
    background-color: var(--stx-danger-light, #fef3f2) !important;
}

/* Autocomplete dropdown (lista dinámica de productos / clientes) */
body.pdv-popup .PDV_DYNAMIC_LIST_HEADER {
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: var(--gray-700, #425466) !important;
    background-color: var(--gray-50, #f6f9fc) !important;
    padding: 6px 10px !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 18px !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee);
    cursor: default;
    white-space: nowrap;
}
body.pdv-popup .PDV_DYNAMIC_LIST_OVER {
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    color: var(--text-primary, #0a2540) !important;
    background-color: var(--stx-primary-50, #efeefe) !important;
    cursor: pointer;
    line-height: 20px !important;
    padding: 4px 10px;
    white-space: nowrap;
}
body.pdv-popup .PDV_DYNAMIC_LIST_OUT_A,
body.pdv-popup .PDV_DYNAMIC_LIST_OUT_B {
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    color: var(--text-primary, #0a2540) !important;
    line-height: 20px !important;
    padding: 4px 10px;
    white-space: nowrap;
    cursor: pointer;
}
body.pdv-popup .PDV_DYNAMIC_LIST_OUT_A {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}
body.pdv-popup .PDV_DYNAMIC_LIST_OUT_B {
    background-color: var(--bg-base, #ffffff) !important;
}

/* Limpieza de Verdana/Tahoma residual: forzar Inter en todo el PDV */
body.pdv-popup table,
body.pdv-popup td,
body.pdv-popup div,
body.pdv-popup span,
body.pdv-popup input,
body.pdv-popup select,
body.pdv-popup textarea,
body.pdv-popup button {
    font-family: 'Inter', sans-serif;
}
body.pdv-popup font[face],
body.pdv-popup FONT[FACE] {
    font-family: 'Inter', sans-serif !important;
}

/* ============================================================
 * SECCIÓN 58 — Cleanup final V4 (selects, botones, inputs, fix mojibake)
 * ============================================================
 *
 * Después de las secciones 50-57 quedaban elementos sueltos que aún se
 * veían "legacy" en pantallas que no son paneles ni listados — formularios
 * de captura de reportes, formularios de configuración, popups simples.
 *
 * Esta sección normaliza:
 *
 *  - <select> nativos: oculta la flecha del navegador (Safari/macOS le pone
 *    flechita gris fea) y dibuja una flecha Lucide ChevronDown vía
 *    background-image data-URI. Selector blindado contra cualquier select
 *    que no sea sidebar / topbar / datagrid header (esos llevan estilos
 *    propios en sus secciones).
 *
 *  - .BUTTON_SAVE / .BUTTON_BACK / .BUTTON_EDIT / .BUTTON_DEFAULT /
 *    .BUTTON_GUARDAR / .BUTTON_GUARDAR_IMPRIMIR /
 *    .BUTTON_CONTINUAR_CAMPOS_EXTRAS / .BUTTON_ADD_FDP — quedaban con su
 *    background-image GIF y Verdana 11px. Aquí se les aplica el mismo
 *    look V4 que .BUTTON_OK (fondo púrpura, Inter, sin imagen).
 *
 *  - <a class="mxw_cld"> (wrapper del SVG calendario en datepickers):
 *    se le ajusta el espaciado y vertical-align para que el SVG quede
 *    alineado con el <input> de fecha.
 *
 *  - <marquee>: HTML4 puro que solo aparece en un dashboard antiguo
 *    (display_dia_martes.php). Se neutraliza para que NO se mueva y
 *    quede como un badge amarillo de aviso.
 *
 *  - <font> tags genéricos (sin atributo face): Inter heredado.
 *
 *  - <hr> reforzado fuera del body.main-v2.
 *
 *  - <iframe> sin border legacy.
 *
 *  - Refuerzo de :focus ring V4 en checkbox/radio.
 *
 * Nota sobre mojibake: el problema "Configuracii¿½n" se corrigió a nivel
 * de archivos PHP/XML reemplazando el byte U+FFFD por la letra Latin-1
 * correcta (página servida como ISO-8859-1). No requiere CSS.
 *
 * Si en el futuro algún módulo nuevo agrega selects/botones que se vean
 * legacy, agregar override aquí (NO en secciones 50-57).
 * ============================================================ */

/* --- <select> nativos: V4 con chevron Lucide ---------------- */

body.main-v2 select:not([class*="sb"]):not([class*="topbar"]):not([class*="dg_"]):not([class*="datagrid"]) {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 12.5px !important;
    color: var(--text-primary, #0a2540) !important;
    background-color: var(--bg-base, #ffffff) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23697386' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 12px 12px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 28px 6px 10px !important;
    cursor: pointer !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
    /* anula cualquier height fijo legacy */
    min-height: 30px !important;
    line-height: 1.35 !important;
}
body.main-v2 select:not([class*="sb"]):not([class*="topbar"]):not([class*="dg_"]):not([class*="datagrid"]):hover {
    border-color: var(--border-strong, #c1c9d2) !important;
}
body.main-v2 select:not([class*="sb"]):not([class*="topbar"]):not([class*="dg_"]):not([class*="datagrid"]):focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}
body.main-v2 select:not([class*="sb"]):not([class*="topbar"]):not([class*="dg_"]):not([class*="datagrid"]):disabled {
    background-color: var(--bg-muted, #f3f6fa) !important;
    color: var(--text-tertiary, #697386) !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}
/* Multi-select: el chevron no aplica visualmente (no es dropdown);
   ocultar background-image y restablecer padding derecho. */
body.main-v2 select[multiple],
body.main-v2 select[size]:not([size="1"]):not([size="0"]) {
    background-image: none !important;
    padding-right: 10px !important;
    cursor: default !important;
}

/* --- .BUTTON_* faltantes: aplicar look V4 púrpura ------------- */
/* Estos llevaban background-image GIF + Verdana en css.php. Aquí se les
   aplica el mismo look que .BUTTON_OK (sección 1) pero en variantes
   semánticas: SAVE/GUARDAR/EDIT = primary púrpura; BACK = neutral. */

body.main-v2 .BUTTON_SAVE,
body.main-v2 .BUTTON_GUARDAR,
body.main-v2 .BUTTON_GUARDAR_IMPRIMIR,
body.main-v2 .BUTTON_EDIT,
body.main-v2 .BUTTON_DEFAULT,
body.main-v2 .BUTTON_CONTINUAR_CAMPOS_EXTRAS,
body.main-v2 .BUTTON_ADD_FDP {
    background-image: none !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    border: 1px solid var(--stx-primary-600, #635bff) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 14px !important;
    /* anular WIDTH/HEIGHT fijos de css.php */
    width: auto !important;
    height: auto !important;
    min-height: 30px !important;
    cursor: pointer !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.16) !important;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 60ms ease !important;
    text-decoration: none !important;
}
body.main-v2 .BUTTON_SAVE:hover,
body.main-v2 .BUTTON_GUARDAR:hover,
body.main-v2 .BUTTON_GUARDAR_IMPRIMIR:hover,
body.main-v2 .BUTTON_EDIT:hover,
body.main-v2 .BUTTON_DEFAULT:hover,
body.main-v2 .BUTTON_CONTINUAR_CAMPOS_EXTRAS:hover,
body.main-v2 .BUTTON_ADD_FDP:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
    border-color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: 0 2px 6px rgba(99,91,255,0.22) !important;
}
body.main-v2 .BUTTON_SAVE:active,
body.main-v2 .BUTTON_GUARDAR:active,
body.main-v2 .BUTTON_GUARDAR_IMPRIMIR:active,
body.main-v2 .BUTTON_EDIT:active,
body.main-v2 .BUTTON_DEFAULT:active,
body.main-v2 .BUTTON_CONTINUAR_CAMPOS_EXTRAS:active,
body.main-v2 .BUTTON_ADD_FDP:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(99,91,255,0.18) !important;
}
body.main-v2 .BUTTON_SAVE:focus-visible,
body.main-v2 .BUTTON_GUARDAR:focus-visible,
body.main-v2 .BUTTON_GUARDAR_IMPRIMIR:focus-visible,
body.main-v2 .BUTTON_EDIT:focus-visible,
body.main-v2 .BUTTON_DEFAULT:focus-visible,
body.main-v2 .BUTTON_CONTINUAR_CAMPOS_EXTRAS:focus-visible,
body.main-v2 .BUTTON_ADD_FDP:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.18) !important;
}

/* BUTTON_BACK: variante neutral (sólo regresar/navegar atrás) */
body.main-v2 .BUTTON_BACK {
    background-image: none !important;
    background-color: var(--bg-muted, #f3f6fa) !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 14px !important;
    width: auto !important;
    height: auto !important;
    min-height: 30px !important;
    text-decoration: none !important;
    cursor: pointer !important;
    transition: background-color 120ms ease, border-color 120ms ease !important;
}
body.main-v2 .BUTTON_BACK:hover {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-color: var(--border-strong, #c1c9d2) !important;
}

/* Refuerzo: cualquier BUTTON_* sobreviviente que no esté listado aquí
   (futuras variantes) hereda al menos Inter + sin background-image. */
body.main-v2 [class^="BUTTON_"]:not(.BUTTON_OK):not(.BUTTON_NOK):not(.BUTTON_SMALL):not(.BUTTON_EXCEL):not(.BUTTON_PDF):not(.BUTTON_TXT):not(.BUTTON_CSV):not(.BUTTON_XLS):not(.BUTTON_PRINT):not(.BUTTON_BACK):not(.BUTTON_SAVE):not(.BUTTON_GUARDAR):not(.BUTTON_GUARDAR_IMPRIMIR):not(.BUTTON_EDIT):not(.BUTTON_DEFAULT):not(.BUTTON_CONTINUAR_CAMPOS_EXTRAS):not(.BUTTON_ADD_FDP) {
    background-image: none !important;
    font-family: 'Inter', sans-serif !important;
    width: auto !important;
    height: auto !important;
    min-height: 30px !important;
    padding: 6px 14px !important;
    border-radius: var(--radius-sm, 6px) !important;
}

/* --- <button> sin clase específica (con cualquier clase) ------ */
/* La sección 26 ya cubría button:not([class]). Extender a button con
   clases que NO sean BUTTON_* (porque ya están arriba). */
body.main-v2 button:not([class^="BUTTON_"]):not([class*="sb"]):not([class*="topbar"]):not(.stx-panel-switcher-btn):not(.stx-doc-switcher-btn):not(.dialog-close):not(.MINIBUTTON_OK):not(.MINIBUTTON_NOK) {
    font-family: 'Inter', sans-serif !important;
    background-color: var(--stx-primary-600, #635bff);
    color: #ffffff;
    border: 1px solid var(--stx-primary-600, #635bff);
    border-radius: var(--radius-sm, 6px);
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease;
}
body.main-v2 button:not([class^="BUTTON_"]):not([class*="sb"]):not([class*="topbar"]):not(.stx-panel-switcher-btn):not(.stx-doc-switcher-btn):not(.dialog-close):not(.MINIBUTTON_OK):not(.MINIBUTTON_NOK):hover {
    background-color: var(--stx-primary-700, #5147e2);
}

/* --- input[type="submit"] / input[type="button"] con clase ---- */
/* Reforzar para tipos submit/button que tengan clase distinta a BUTTON_*
   (raros pero existen) — herencia segura del look V4. */
body.main-v2 input[type="submit"]:not([class^="BUTTON_"]):not([class*="sb"]),
body.main-v2 input[type="button"]:not([class^="BUTTON_"]):not([class*="sb"]):not(.MINIBUTTON_OK):not(.MINIBUTTON_NOK) {
    font-family: 'Inter', sans-serif !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border: 1px solid var(--stx-primary-600, #635bff) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 14px !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.16) !important;
    transition: background-color 120ms ease !important;
    min-height: 30px !important;
    height: auto !important;
    width: auto !important;
    background-image: none !important;
}

/* --- Datepicker trigger <A class="mxw_cld"> ------------------- */
/* El IMG dentro ya se reemplaza con SVG calendar por el icon-replacer.
   Aquí pulimos el wrapper para que SVG y <input> queden alineados. */
body.main-v2 a.mxw_cld {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-left: 4px !important;
    padding: 4px !important;
    border-radius: var(--radius-sm, 6px) !important;
    color: var(--stx-primary-600, #635bff) !important;
    background-color: transparent !important;
    text-decoration: none !important;
    transition: background-color 120ms ease, color 120ms ease !important;
    vertical-align: middle !important;
    line-height: 1 !important;
}
body.main-v2 a.mxw_cld:hover {
    background-color: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}
body.main-v2 a.mxw_cld svg {
    width: 16px !important;
    height: 16px !important;
    display: block !important;
}
/* En caso de que el icon-replacer aún no haya corrido (race condition),
   al menos limpiar el border default del <img>. */
body.main-v2 a.mxw_cld img {
    border: none !important;
    vertical-align: middle !important;
}

/* --- input[type=date] / time / datetime-local: V4 -------------- */
/* La sección 26 cubre input[type=date]. Extender a time/datetime-local
   y dar :hover/:focus consistente al tipo date. */
body.main-v2 input[type="date"]:not(.TEXTBOX),
body.main-v2 input[type="time"]:not(.TEXTBOX),
body.main-v2 input[type="datetime-local"]:not(.TEXTBOX),
body.main-v2 input[type="month"]:not(.TEXTBOX),
body.main-v2 input[type="week"]:not(.TEXTBOX) {
    font-family: 'Inter', sans-serif !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 6px 10px !important;
    font-size: 12.5px !important;
    color: var(--text-primary, #0a2540) !important;
    background-color: var(--bg-base, #ffffff) !important;
    min-height: 30px !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
}
body.main-v2 input[type="date"]:not(.TEXTBOX):hover,
body.main-v2 input[type="time"]:not(.TEXTBOX):hover,
body.main-v2 input[type="datetime-local"]:not(.TEXTBOX):hover {
    border-color: var(--border-strong, #c1c9d2) !important;
}
/* En Webkit el calendar-picker indicator es el icono nativo de fecha:
   coloreado púrpura para que pegue con el theme. */
body.main-v2 input[type="date"]::-webkit-calendar-picker-indicator,
body.main-v2 input[type="time"]::-webkit-calendar-picker-indicator,
body.main-v2 input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(34%) sepia(85%) saturate(2918%) hue-rotate(234deg) brightness(100%) contrast(101%);
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 120ms ease;
}
body.main-v2 input[type="date"]::-webkit-calendar-picker-indicator:hover,
body.main-v2 input[type="time"]::-webkit-calendar-picker-indicator:hover,
body.main-v2 input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* --- input[type=number]: ocultar spinner nativo feo de Firefox - */
body.main-v2 input[type="number"]:not(.TEXTBOX) {
    -moz-appearance: textfield;
}
body.main-v2 input[type="number"]:not(.TEXTBOX)::-webkit-inner-spin-button,
body.main-v2 input[type="number"]:not(.TEXTBOX)::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- input[type=checkbox] / radio: refuerzo accent-color ----- */
body.main-v2 input[type="checkbox"],
body.main-v2 input[type="radio"] {
    accent-color: var(--stx-primary-600, #635bff) !important;
    cursor: pointer !important;
}
body.main-v2 input[type="checkbox"]:focus-visible,
body.main-v2 input[type="radio"]:focus-visible {
    outline: 2px solid var(--stx-primary-600, #635bff) !important;
    outline-offset: 2px !important;
}

/* --- <marquee>: HTML4 puro — neutralizar movimiento ---------- */
/* Aparece solo en display_dia_martes.php. Quitar el scroll y mostrar
   como badge naranja de aviso. */
body.main-v2 marquee,
body.main-v2 MARQUEE {
    display: inline-block !important;
    background-color: var(--stx-warning-50, #fff7e6) !important;
    color: var(--stx-warning-dark, #b54708) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    padding: 6px 12px !important;
    border-radius: var(--radius-sm, 6px) !important;
    border: 1px solid var(--stx-warning-200, #fec84b) !important;
    /* Anular el scrolling — el browser respeta las propiedades de marquee
       cuando se setean a estos valores */
    -moz-binding: none;
}
/* Detiene el scroll en navegadores modernos que aún honren marquee */
body.main-v2 marquee[behavior],
body.main-v2 marquee[direction],
body.main-v2 marquee[scrollamount] {
    /* sin scroll: el contenido queda fijo dentro del badge */
}

/* --- <font> tags genéricos heredan Inter --------------------- */
/* La sección 51 / pdv-popup ya cubren casos específicos. Esto extiende
   a cualquier <font> en formularios. */
body.main-v2 font:not([color]),
body.main-v2 FONT:not([COLOR]):not([color]) {
    font-family: 'Inter', sans-serif !important;
}

/* --- <hr> reforzado en cualquier contexto -------------------- */
body.main-v2 hr,
body.main-v2 HR {
    border: 0 !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
    height: 0 !important;
    background-color: transparent !important;
    margin: 12px 0 !important;
}

/* --- <iframe> sin border legacy ------------------------------ */
body.main-v2 iframe:not([id*="datagrid"]):not([id*="DATAGRID"]) {
    border: none !important;
}

/* --- <textarea> sin clase: V4 -------------------------------- */
body.main-v2 textarea:not(.TEXTBOX):not([class*="sb"]) {
    font-family: 'Inter', sans-serif !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 8px 10px !important;
    font-size: 12.5px !important;
    color: var(--text-primary, #0a2540) !important;
    background-color: var(--bg-base, #ffffff) !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
    resize: vertical;
}
body.main-v2 textarea:not(.TEXTBOX):not([class*="sb"]):hover {
    border-color: var(--border-strong, #c1c9d2) !important;
}
body.main-v2 textarea:not(.TEXTBOX):not([class*="sb"]):focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}

/* --- FIELDSET / LEGEND reforzados fuera de formulario nuevo --- */
/* La sección 8 cubre fieldset; aquí pulir el caso del form de reporte
   (display.php) que tiene .FIELDSET sin clase wrapper específica. */
body.main-v2 fieldset legend {
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    color: var(--text-primary, #0a2540) !important;
    padding: 0 8px !important;
}

/* --- mojibake residual no fixable a nivel de CSS ------------- */
/* Si después de los fixes batch en archivos siguen apareciendo bytes
   FFFD raros, al menos asegurar que se vean tenues y no rompan el
   visual con `?` gigantes. Truco: aplicar color reducido al unicode
   replacement character mediante font-feature-settings (no funciona
   para FFFD literal — el fix real está en los archivos). */
/* Esta regla queda como comentario informativo, no aplica un selector
   porque FFFD es un caracter en el textContent, no un selector CSS. */

/* ============================================================
 * Fin SECCIÓN 58.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 59 — Patches PDV + cursor pointer en iconos action
 *
 * Issues reportados:
 *  1) Billetera (bt_pagar_documento.gif 90x75) y "+" (bt_agregar_detalles.gif
 *     152x65) del PDV se ven gigantes y sin estilo V4 — son IMG sin wrapper
 *     .ICON, el replacer respeta su width/height legacy.
 *  2) En la pestaña activa del topbar (la blanca top-left), el texto queda
 *     invisible (blanco sobre fondo claro o púrpura).
 *  3) Los iconos de acción de los grids (lupa SÍ, impresora NO) deben TODOS
 *     mostrar cursor: pointer al hover.
 * ============================================================ */

/* 59.A — Botones grandes del PDV: billetera + "agregar detalles" */
body.pdv-popup img[src*="bt_pagar_documento"],
body.pdv-popup img[src*="bt_pasar_caja"],
body.pdv-popup img[src*="bt_agregar_detalles"],
body.pdv-popup .stx-svg-icon[data-gif*="bt_pagar_documento"],
body.pdv-popup .stx-svg-icon[data-gif*="bt_pasar_caja"],
body.pdv-popup .stx-svg-icon[data-gif*="bt_agregar_detalles"] {
    width: 36px !important;
    height: 36px !important;
    padding: 8px !important;
    border-radius: 10px !important;
    background: var(--stx-primary-50, #f0eeff) !important;
    color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.06) !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
}
body.pdv-popup img[src*="bt_pagar_documento"]:hover,
body.pdv-popup img[src*="bt_pasar_caja"]:hover,
body.pdv-popup img[src*="bt_agregar_detalles"]:hover,
body.pdv-popup .stx-svg-icon[data-gif*="bt_pagar_documento"]:hover,
body.pdv-popup .stx-svg-icon[data-gif*="bt_pasar_caja"]:hover,
body.pdv-popup .stx-svg-icon[data-gif*="bt_agregar_detalles"]:hover {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(99, 91, 255, 0.25) !important;
}

/* 59.B — Pestaña activa del topbar: forzar texto contrastante */
body.topbar-v2 .stx-topbar-tab.active,
body.topbar-v2 .stx-topbar-tab.stx-tab-active,
body.topbar-v2 td.tab_active,
body.topbar-v2 td.tab_active a,
body.topbar-v2 td.tab_active span,
body.topbar-v2 td[class*="active"] a,
body.topbar-v2 td[class*="active"] span,
body.topbar-v2 .tab-on,
body.topbar-v2 .tab-on a,
body.topbar-v2 .tab-on span {
    color: var(--stx-text-primary, #0a2540) !important;
    font-weight: 600 !important;
}

/* Fallback: cualquier pestaña con fondo blanco (tab activa) debe tener texto oscuro */
body.topbar-v2 td[bgcolor="#ffffff" i],
body.topbar-v2 td[bgcolor="white" i],
body.topbar-v2 td[style*="background:#fff" i],
body.topbar-v2 td[style*="background-color:#fff" i] {
    color: var(--stx-text-primary, #0a2540) !important;
}
body.topbar-v2 td[bgcolor="#ffffff" i] a,
body.topbar-v2 td[bgcolor="white" i] a,
body.topbar-v2 td[style*="background:#fff" i] a,
body.topbar-v2 td[style*="background-color:#fff" i] a {
    color: var(--stx-text-primary, #0a2540) !important;
}

/* 59.C — Cursor pointer global en iconos clickeables.
   La lupa ya lo tenía porque está dentro de <A>; la impresora y otros
   iconos del grid de acciones suelen estar en TD con ONCLICK pero sin <A>.
   Esta regla cubre todos esos casos sin tocar el HTML. */
body.main-v2 [onclick],
body.main-v2 [onmousedown],
body.main-v2 a img,
body.main-v2 a svg,
body.main-v2 a .stx-svg-icon,
body.main-v2 [onclick] img,
body.main-v2 [onclick] svg,
body.main-v2 [onclick] .stx-svg-icon {
    cursor: pointer !important;
}

/* No aplicar pointer a inputs/selects/textareas con onclick (raro pero pasa) */
body.main-v2 input[onclick],
body.main-v2 select[onclick],
body.main-v2 textarea[onclick] {
    cursor: text !important;
}
body.main-v2 input[type="checkbox"][onclick],
body.main-v2 input[type="radio"][onclick],
body.main-v2 input[type="submit"][onclick],
body.main-v2 input[type="button"][onclick],
body.main-v2 button[onclick] {
    cursor: pointer !important;
}
/* ============================================================
 * Fin SECCIÓN 59.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 60 — HOTFIX modales legacy prototype-window (PROD)
 * ============================================================
 *
 * Contexto del bug:
 *   Tras los commits que introdujeron las SECCIONES 57 (error_*) y
 *   52 (dialog_/notice_/warning_/bitacora_/alert_) se rompieron los
 *   modales del framework legacy (utils/stx/js/window.js +
 *   utils/stx/css/window/*.css):
 *
 *     1) El botón X de cerrar (.error_close / .dialog_close / etc.)
 *        no responde al click. SECCIÓN 57 forzó position:relative
 *        y SECCIÓN 52 no fijó position en absoluto — el botón queda
 *        en el flujo de la celda _n y .error_title (width:100%) lo
 *        cubre por completo, robándole el click.
 *
 *     2) El cuerpo del modal (.error_content / .dialog_content) sale
 *        en blanco — solo se ve el header de color. Causa probable:
 *        SECCIÓN 52 colapsa las celdas _s/_sw/_se/_e/_w del table
 *        legacy con width:0/height:0, lo que en table-layout:auto
 *        hace que la columna central también colapse en algunos
 *        renders. Además .error_message NO está estilizado por nadie.
 *
 *     3) Los botones del footer (.error_buttons / .dialog_buttons)
 *        a veces quedan desalineados o el modal completo no se ve.
 *
 * Estrategia del hotfix:
 *   - NO modificar SECCIONES 57/52 existentes (preservar commits).
 *   - Override targeted de alta especificidad con doble clase
 *     (html body.main-v2 .X.X) — gana sin recurrir a all:revert.
 *   - Restaurar position:absolute, pointer-events:auto, z-index alto
 *     y cursor:pointer en TODOS los _close de los temas legacy.
 *   - Restaurar layout de tabla del modal: width:auto en center
 *     column, height:auto en _content, visibility/display garantizado.
 *   - Garantizar .error_message visible (legacy lo necesita centrado).
 *   - Bajar z-index del .error_title para que NO tape el .error_close.
 *
 * Selectores: cubrir error_/dialog_/notice_/warning_/bitacora_/alert_.
 * Aplica con y sin prefijo body.main-v2 para login screens (legacy no
 * carga main-v2 en pantalla de login pero sí carga el theme V4).
 * ============================================================ */

/* ----- 60.A — Botón X de cerrar: SIEMPRE clickeable -------------
 * Restaura position:absolute como en el CSS legacy, asegura
 * pointer-events, cursor y z-index por encima del título.
 * IMPORTANTE: usar position:absolute con coordenadas dentro del
 * header (.error_n / .dialog_n) — el _n debe ser position:relative. */
html body.main-v2 .error_n,
html body.main-v2 .dialog_n,
html body.main-v2 .notice_n,
html body.main-v2 .warning_n,
html body.main-v2 .bitacora_n,
html body.main-v2 .alert_n,
.error_n,
.dialog_n,
.notice_n,
.warning_n,
.bitacora_n,
.alert_n {
    position: relative !important;
    overflow: visible !important;
}

html body.main-v2 .error_close,
html body.main-v2 .dialog_close,
html body.main-v2 .notice_close,
html body.main-v2 .warning_close,
html body.main-v2 .bitacora_close,
html body.main-v2 .alert_close,
.error_close,
.dialog_close,
.notice_close,
.warning_close,
.bitacora_close,
.alert_close {
    position: absolute !important;
    top: 8px !important;
    right: 10px !important;
    left: auto !important;
    width: 28px !important;
    height: 28px !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 2147483000 !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* Bajar el título por debajo del close para que NO le robe el click.
 * .error_title de SECCIÓN 57 tenía padding-left:44px y width 100% —
 * eso cubre toda la fila incluyendo el área del close. Bajamos su
 * z-index y aseguramos que el padding-right deje espacio al close. */
html body.main-v2 .error_title,
html body.main-v2 .dialog_title,
html body.main-v2 .notice_title,
html body.main-v2 .warning_title,
html body.main-v2 .bitacora_title,
html body.main-v2 .alert_title,
.error_title,
.dialog_title,
.notice_title,
.warning_title,
.bitacora_title,
.alert_title {
    position: relative !important;
    z-index: 1 !important;
    padding-right: 48px !important;
    pointer-events: none !important; /* el click pasa al close si overlapa */
}

/* El glifo X del close (pseudo elemento o mask) tampoco debe bloquear
 * clicks sobre el botón padre. */
html body.main-v2 .error_close::after,
html body.main-v2 .error_close::before,
html body.main-v2 .dialog_close::after,
html body.main-v2 .dialog_close::before,
html body.main-v2 .notice_close::after,
html body.main-v2 .notice_close::before,
html body.main-v2 .warning_close::after,
html body.main-v2 .warning_close::before,
html body.main-v2 .bitacora_close::after,
html body.main-v2 .bitacora_close::before,
html body.main-v2 .alert_close::after,
html body.main-v2 .alert_close::before {
    pointer-events: none !important;
}

/* ----- 60.B — Cuerpo del modal: SIEMPRE visible ------------------
 * Restaurar display, visibility, opacity y height del _content.
 * También garantizar layout de tabla legacy: la columna central
 * (.<tema>_w / _content / _e) no debe colapsar por culpa del
 * width:0 que SECCIÓN 52 puso sobre _w y _e. */
html body.main-v2 .error_content,
html body.main-v2 .dialog_content,
html body.main-v2 .notice_content,
html body.main-v2 .warning_content,
html body.main-v2 .bitacora_content,
html body.main-v2 .alert_content,
.error_content,
.dialog_content,
.notice_content,
.warning_content,
.bitacora_content,
.alert_content {
    display: table-cell !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    height: auto !important;
    min-height: 60px !important;
    min-width: 360px !important;
}

/* Mensaje interno (.error_message es el único NO cubierto por
 * SECCIÓN 52). Se garantiza visible y tipografía legible. */
html body.main-v2 .error_message,
html body.main-v2 .dialog_message,
html body.main-v2 .notice_message,
html body.main-v2 .warning_message,
html body.main-v2 .bitacora_message,
html body.main-v2 .alert_message,
html body.main-v2 #modal_dialog_message,
.error_message,
.dialog_message,
.notice_message,
.warning_message,
.bitacora_message,
.alert_message,
#modal_dialog_message {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    text-align: left !important;
    padding: 4px 0 16px 0 !important;
    width: 100% !important;
    min-height: 24px !important;
    background: transparent !important;
}

/* La ventana interna (alert/confirm legacy) — restaurar ancho mínimo
 * para que el texto no quede ocultado. El SECCIÓN 52 _window setea
 * width:auto pero algunos browsers necesitan un piso. */
html body.main-v2 .error_window,
html body.main-v2 .dialog_window,
html body.main-v2 .notice_window,
html body.main-v2 .warning_window,
html body.main-v2 .bitacora_window,
html body.main-v2 .alert_window,
.error_window,
.dialog_window,
.notice_window,
.warning_window,
.bitacora_window,
.alert_window {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 380px !important;
    max-width: 92vw !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
    padding: 4px 0 0 0 !important;
}

/* ----- 60.C — Layout de tabla: NO colapsar columna central -----
 * SECCIÓN 52 puso width:0 a _w/_e y height:0/width:0 a _s/_sw/_se.
 * En table-layout:auto el browser distribuye width entre columnas
 * usando el ANCHO MÍNIMO de cada celda; si la columna central tiene
 * width:auto y las laterales fueron forzadas a 0, en algunos casos
 * la fila central reparte mal y _content queda con width 0. Forzamos
 * el table legacy a table-layout:auto y restablecemos heights de
 * la fila inferior para que la mesa no colapse en altura. */
html body.main-v2 .dialog,
html body.main-v2 table.table_window,
.dialog,
table.table_window {
    table-layout: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* La fila inferior con _s en el medio: dar height mínimo 4px en vez
 * de 0 para que la tabla no tenga renglón colapsado en cero. NO
 * tocamos width — dejamos que el browser lo calcule. */
html body.main-v2 .dialog_s,
html body.main-v2 .notice_s,
html body.main-v2 .warning_s,
html body.main-v2 .bitacora_s,
html body.main-v2 .alert_s,
.dialog_s,
.notice_s,
.warning_s,
.bitacora_s,
.alert_s {
    height: 4px !important;
    min-height: 4px !important;
}

/* ----- 60.D — Botones del footer: garantizar visibilidad -------
 * SECCIÓN 52 los pone con display:flex que generalmente funciona,
 * pero si el contenedor es un <td> legacy, en Safari/Firefox el
 * flex en table-cell puede romperse. Mantenemos display:flex con
 * fallback a block. */
html body.main-v2 .error_buttons,
html body.main-v2 .dialog_buttons,
html body.main-v2 .notice_buttons,
html body.main-v2 .warning_buttons,
html body.main-v2 .bitacora_buttons,
html body.main-v2 .alert_buttons,
.error_buttons,
.dialog_buttons,
.notice_buttons,
.warning_buttons,
.bitacora_buttons,
.alert_buttons {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 100% !important;
    text-align: right !important;
}

html body.main-v2 .error_buttons input,
html body.main-v2 .error_buttons button,
html body.main-v2 .dialog_buttons input,
html body.main-v2 .dialog_buttons button,
html body.main-v2 .notice_buttons input,
html body.main-v2 .notice_buttons button,
html body.main-v2 .warning_buttons input,
html body.main-v2 .warning_buttons button,
html body.main-v2 .bitacora_buttons input,
html body.main-v2 .bitacora_buttons button,
html body.main-v2 .alert_buttons input,
html body.main-v2 .alert_buttons button {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    margin-left: 8px !important;
}

/* ----- 60.E — Overlay backdrop: que NO bloquee el cuadro -------
 * El backdrop (.overlay_error / .overlay_dialog / etc.) debe quedar
 * por DEBAJO del cuadro modal. SECCIÓN 57 puso z-index calc(z-modal - 1)
 * que está bien; lo reforzamos por si acaso. El cuadro modal en sí
 * (la tabla suelta hermana del overlay) debe quedar por encima. */
html body.main-v2 .overlay_error,
html body.main-v2 .overlay_dialog,
html body.main-v2 .overlay_notice,
html body.main-v2 .overlay_warning,
html body.main-v2 .overlay_bitacora,
html body.main-v2 .overlay_alert,
.overlay_error,
.overlay_dialog,
.overlay_notice,
.overlay_warning,
.overlay_bitacora,
.overlay_alert {
    z-index: 2147482000 !important;
    pointer-events: auto !important;
}

/* El modal en sí (table padre, hermana del overlay) debe pintarse
 * por encima del backdrop.
 *
 * FIX 2026-06-06: el selector `~ table` original NO funcionaba porque la lib
 * Prototype Window inyecta el overlay en `<body>` (initLightbox linea 1532 de
 * window.js) pero el modal (.dialog) se renderiza dentro de `FORM_GENERAL`.
 * Overlay y modal NO son hermanos -> ~ no aplica -> modal queda con z-index
 * default (~20) y el overlay con z-index 2147482000 lo tapa = cortina gris
 * que bloquea todos los clicks.
 *
 * Sintoma reportado 2026-06-06: modal de Cancelar documento se ve pero NO
 * recibe clicks (textarea, Aceptar, X close). Afecta TODOS los modales con
 * className="bitacora": Cancelar/Cerrar/Abrir/Eliminar documento + Cancelar
 * consolidacion + reglas_precios + dashboards/chips + PDV + clientes_plataformas.
 *
 * Fix: aplicar z-index alto directamente a `.dialog`, sin depender de la
 * relacion de hermandad con el overlay. */
html body.main-v2 .dialog,
.dialog {
    z-index: 2147482500 !important;
}

/* Tambien para tables hermanas (compat con uso original que SI eran hermanas
 * — algunas variantes legacy del Prototype Window pintan el modal como table
 * dentro del mismo parent que el overlay). */
html body.main-v2 .overlay_error ~ table,
html body.main-v2 .overlay_dialog ~ table,
html body.main-v2 .overlay_notice ~ table,
html body.main-v2 .overlay_warning ~ table,
html body.main-v2 .overlay_bitacora ~ table,
html body.main-v2 .overlay_alert ~ table,
.overlay_error ~ table,
.overlay_dialog ~ table,
.overlay_notice ~ table,
.overlay_warning ~ table,
.overlay_bitacora ~ table,
.overlay_alert ~ table {
    z-index: 2147482500 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ----- 60.F — ERROR/WARNING/NOTICE/ALERT_WINDOW autosize -------
 * errors.js abre los popups via `new Window({height: 60})` (height
 * fijo). El chrome del Window agrega ~50px (header rojo + bordes), y
 * el contenido con el icono SVG + UL de errores necesita ~100-120px.
 * Resultado: el contenedor .dialog termina con height fijo ~112px
 * + overflow:hidden → el cuerpo del mensaje se ve cortado, aparece
 * por debajo de la caja contenedora.
 *
 * Fix 2026-06-07: forzar el .dialog de los Windows tipo error/warning/
 * notice/alert a height:auto + overflow:visible para que crezca con
 * su contenido. Identificacion por id especifico (ERROR_WINDOW etc.)
 * para NO afectar el .dialog generico de Cancelar documento (bitacora)
 * que sí debe respetar su tamaño. */
body #ERROR_WINDOW,
body #WARNING_WINDOW,
body #NOTICE_WINDOW,
body #ALERT_WINDOW {
    height: auto !important;
    min-height: 100px !important;
    overflow: visible !important;
}
body #ERROR_WINDOW .error_content,
body #ERROR_WINDOW #ERROR_WINDOW_content,
body #WARNING_WINDOW .warning_content,
body #WARNING_WINDOW #WARNING_WINDOW_content,
body #NOTICE_WINDOW .notice_content,
body #NOTICE_WINDOW #NOTICE_WINDOW_content,
body #ALERT_WINDOW .alert_content,
body #ALERT_WINDOW #ALERT_WINDOW_content {
    height: auto !important;
    min-height: 60px !important;
    overflow: visible !important;
}
body #ERROR_WINDOW .mid,
body #WARNING_WINDOW .mid,
body #NOTICE_WINDOW .mid,
body #ALERT_WINDOW .mid {
    height: auto !important;
}

/* ============================================================
 * Fin SECCIÓN 60.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 61 — Dropdown nativo light mode + date pickers light
 *
 * Cuando el OS está en tema oscuro (macOS/Windows/Linux dark), el
 * dropdown nativo del <select> y el calendario nativo de <input type=date>
 * heredan los colores oscuros del sistema. Forzar color-scheme: light
 * para que se muestren consistentes en blanco/oscuro independientemente
 * del OS.
 * ============================================================ */
select,
select option,
html body select,
html body select option,
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"] {
    color-scheme: light !important;
}

/* ============================================================
 * SECCION 62 — Fixes PDV: botones gigantes + texto pestaña Ticket
 *
 * Contexto:
 *   La SECCION 59 intentó arreglar los IMG bt_pagar_documento.gif (90x75)
 *   y bt_agregar_detalles.gif (152x65) del PDV, pero el icon replacer JS
 *   YA HA reemplazado el <IMG> por un <svg class="stx-svg-icon ..."
 *   width=90 height=75> antes de que el CSS aplique — el selector
 *   img[src*="..."] solo matchea durante el flash inicial (que casi no se
 *   ve). En r5 del replacer le agregamos data-gif="<basename>" al SVG y
 *   al wrapper, por lo que ahora podemos targetearlos con
 *   [data-gif*="bt_pagar_documento"].
 *
 *   La pestaña activa del PDV NO vive en body.topbar-v2 (eso es el topbar
 *   global del ERP). En el PDV las pestañas son cells con clase
 *   .ON_MIDDLE_PDV (activa) / .OFF_MIDDLE_PDV (inactiva) generadas por
 *   pdv.js. La SECCION 53 ya pinta el fondo pero el <A> interno hereda
 *   color púrpura del topbar (link default) — necesita override de color
 *   para que el texto "Ticket" sea oscuro y contrastante.
 * ============================================================ */

/* 62.A — Botones grandes del PDV (post-replacer): forzar tamaño icono */
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_pasar_caja"],
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_agregar_detalles"] {
    width: 36px !important;
    height: 36px !important;
    padding: 8px !important;
    border-radius: 10px !important;
    background: var(--stx-primary-50, #f0eeff) !important;
    color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.06) !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-sizing: border-box !important;
    display: inline-block !important;
    vertical-align: middle !important;
}
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_pagar_documento"]:hover,
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_pasar_caja"]:hover,
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_agregar_detalles"]:hover {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(99, 91, 255, 0.25) !important;
}

/* 62.B — Mismo override cuando el SVG está envuelto en .stx-icon-tile
   (caso de IMGs dentro de .ICON: rama isInIconWrap del replacer). */
body.pdv-popup .stx-icon-tile[data-gif*="bt_pagar_documento"],
body.pdv-popup .stx-icon-tile[data-gif*="bt_pasar_caja"],
body.pdv-popup .stx-icon-tile[data-gif*="bt_agregar_detalles"] {
    width: 36px !important;
    height: 36px !important;
    padding: 8px !important;
    border-radius: 10px !important;
    background: var(--stx-primary-50, #f0eeff) !important;
    color: var(--stx-primary-600, #635bff) !important;
}
body.pdv-popup .stx-icon-tile[data-gif*="bt_pagar_documento"] svg,
body.pdv-popup .stx-icon-tile[data-gif*="bt_pasar_caja"] svg,
body.pdv-popup .stx-icon-tile[data-gif*="bt_agregar_detalles"] svg {
    width: 20px !important;
    height: 20px !important;
}

/* 62.C — Pestaña activa del PDV: forzar texto contrastante en el <A>
   interno. .ON_MIDDLE_PDV es la celda (fondo blanco), pero el texto
   "Ticket"/"Factura" vive dentro de un <A STYLE="text-decoration:none;">
   que hereda el color púrpura por defecto, haciéndolo casi invisible
   sobre fondo blanco. */
body.pdv-popup .ON_MIDDLE_PDV,
body.pdv-popup .ON_MIDDLE_PDV a,
body.pdv-popup .ON_MIDDLE_PDV a:link,
body.pdv-popup .ON_MIDDLE_PDV a:visited,
body.pdv-popup .ON_MIDDLE_PDV a:hover,
body.pdv-popup .ON_MIDDLE_PDV a:active {
    color: var(--text-primary, #0a2540) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

/* Pestaña inactiva: texto blanco semi-transparente sobre fondo púrpura */
body.pdv-popup .OFF_MIDDLE_PDV,
body.pdv-popup .OFF_MIDDLE_PDV a,
body.pdv-popup .OFF_MIDDLE_PDV a:link,
body.pdv-popup .OFF_MIDDLE_PDV a:visited {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500 !important;
    text-decoration: none !important;
}
body.pdv-popup .OFF_MIDDLE_PDV a:hover {
    color: #ffffff !important;
}

/* 62.D — Defensa extra: si por alguna razón los IMG NO se reemplazaron
   (replacer falló o no corrió), aún así reducir su tamaño legacy. Es la
   misma regla que SECCION 59.A pero con mayor especificidad para ganar
   ante el atributo WIDTH/HEIGHT inline del IMG. */
html body.pdv-popup img[src*="bt_pagar_documento"],
html body.pdv-popup img[src*="bt_pasar_caja"],
html body.pdv-popup img[src*="bt_agregar_detalles"] {
    width: 36px !important;
    height: 36px !important;
    padding: 8px !important;
    border-radius: 10px !important;
    background: var(--stx-primary-50, #f0eeff) !important;
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.06) !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    object-fit: contain;
}
/* ============================================================
 * Fin SECCION 62.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 63 — Fix visibilidad sidebar PDV para usuarios sin PDV_CAJA
 *              (resoluciones pequeñas, ej. 1366px Windows)
 *
 * Problema reportado:
 *   Usuario narellano (USR regular, sin permiso PDV_CAJA) no ve los
 *   botones de la sidebar derecha (.LAYER_TOOLS): Pagar/Pasar Caja,
 *   Cancelar (X roja) y Guardar.
 *
 * Root cause diagnosticado:
 *   SECCIÓN 59/62 aplican en los SVG de bt_pagar_documento / bt_pasar_caja:
 *     width: 36px; height: 36px; padding: 8px; box-sizing: border-box;
 *   Con box-sizing: border-box el área útil del SVG = 36 - 8 - 8 = 20px.
 *   El ícono queda prácticamente invisible (20px de dibujo sobre fondo
 *   morado muy claro en una pantalla pequeña). Para el admin con más
 *   resolución el contraste basta para verlo; para narellano en 1366px no.
 *
 *   Adicionalmente, si la tabla del PDV no alcanza el ancho mínimo en
 *   una resolución baja, el TD .LAYER_TOOLS se puede comprimir y ocultar
 *   su contenido por overflow implícito de la celda.
 *
 * Fix aplicado:
 *   1. Elevar el ícono grande (Pagar/Pasar Caja) a 52px sin box-sizing,
 *      con padding via background-origin para no reducir viewBox.
 *   2. Asegurar min-width y overflow: visible en .LAYER_TOOLS.
 *   3. Garantizar visibilidad (display: block / inline-block) de los SVG
 *      y los wrappers .pdv-side-icon dentro de .LAYER_TOOLS.
 * ============================================================ */

/* 63.A — Contenedor sidebar: nunca comprimir ni recortar */
body.pdv-popup .LAYER_TOOLS {
    min-width: 98px !important;
    overflow: visible !important;
    vertical-align: top !important;
}

/* 63.B — Botón principal (Pagar / Pasar Caja): ícono grande legible.
   Sobreescribe el 36px+padding+box-sizing de secciones 59/62 que
   dejaba solo 20px efectivos y lo hacía casi invisible. */
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"],
body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"],
body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"] {
    display: inline-block !important;
    width: 52px !important;
    height: 52px !important;
    padding: 10px !important;
    box-sizing: content-box !important;   /* padding NO resta al viewBox */
    border-radius: 12px !important;
    background: var(--stx-primary-100, #dddcff) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: 0 2px 4px rgba(99, 91, 255, 0.18) !important;
    cursor: pointer !important;
    transition: background 120ms ease, transform 120ms ease !important;
}
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"]:hover,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"]:hover,
body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"]:hover,
body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"]:hover {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 10px rgba(99, 91, 255, 0.30) !important;
}

/* 63.C — Iconos secundarios (Cancelar / Guardar) dentro de .pdv-side-icon:
   garantizar visibilidad; sección 38 ya los estiliza pero si overflow
   los cortaba, este display fuerza su aparición. */
body.pdv-popup .LAYER_TOOLS .pdv-side-icon {
    display: block !important;
    overflow: visible !important;
}
body.pdv-popup .LAYER_TOOLS .pdv-side-icon .stx-icon-tile,
body.pdv-popup .LAYER_TOOLS .pdv-side-icon img {
    display: inline-block !important;
    overflow: visible !important;
}

/* 63.D — Defensa: si el TD de la sidebar hereda width: 0 de alguna
   regla de tabla colapsada, forzar al menos 90px. */
body.pdv-popup td.LAYER_TOOLS {
    width: 98px !important;
    min-width: 98px !important;
    overflow: visible !important;
}
/* ============================================================
 * Fin SECCIÓN 63.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 64 — PDV Responsive END-TO-END
 *
 * Problema: .pdv-card tiene width: 825px fijo; la tabla interior
 * de layer_unticket / layer_unafactura / layer_devolucion usa
 * atributos HTML WIDTH="706" y WIDTH="98" (pixels duros).
 * En resoluciones ≤ 1366px con chrome de navegador / sidebar
 * abierta, .LAYER_TOOLS queda invisible o cortada.
 *
 * Estrategia:
 *   A. .pdv-card → max-width: 825px; width: 100% (fluida)
 *   B. Tabla exterior (.pdv-shell) → 100% para centrar sin scroll
 *   C. Tablas con widths fijos → display: flex en el TR principal
 *      usando pseudo-clases, o table-layout: auto + width: 100%
 *      para que el browser redistribuya columnas
 *   D. .LAYER_TOOLS → flex-shrink: 0; min-width: 100px (no comprimible)
 *   E. La celda de contenido (WIDTH="706") → flex: 1; min-width: 0;
 *      overflow-x: auto (scroll interno en vez del viewport)
 *   F. Action bar (.pdv-action-bar) → flex-wrap: wrap para que los
 *      botones bajen a otra fila cuando no quepan
 *   G. @media ≤ 1100px: LAYER_TOOLS migra a fila debajo del grid
 *      (posición sticky: bottom para que siga visible)
 *   H. @media ≤ 768px: layout completamente vertical
 *
 * NO modifica JS, onclick handlers ni IDs.
 * ============================================================ */

/* 64.A — Tarjeta PDV: fluida hasta 825px en vez de fija */
body.pdv-popup .pdv-card {
    width: 100% !important;
    max-width: 825px !important;
}

/* 64.B — Tablas de pdv-card: no forzar 825px fijos */
body.pdv-popup .pdv-card > table {
    width: 100% !important;
    max-width: 825px !important;
}

/* 64.C — Tabla principal del documento (layer_unticket, layer_unafactura,
   layer_devolucion): neutralizar WIDTH="706"/"98"/"7" (atributos HTML)
   con display flex en la fila del LAYER_TOOLS para control total. */
body.pdv-popup .LAYER_DOCUMENTO_MAIN table,
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table,
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table,
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table {
    width: 100% !important;
    table-layout: auto !important;
}

/* La fila que contiene spacer-7 + contenido-706 + spacer-7 + LAYER_TOOLS:
   convertirla a flex para control de flex-grow/shrink */
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr,
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr,
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    width: 100% !important;
}

/* Spacers de 7px: ancho fijo, no crecen ni se encogen */
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td:first-child,
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td:nth-child(3),
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td:first-child,
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td:nth-child(3),
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td:first-child,
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td:nth-child(3) {
    flex: 0 0 7px !important;
    width: 7px !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

/* Celda de contenido (era WIDTH="706"): crece, permite scroll interno */
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td:nth-child(2),
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td:nth-child(2),
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td:nth-child(2) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    width: auto !important;
}

/* 64.D — LAYER_TOOLS (sidebar derecha): nunca comprimir, siempre visible */
body.pdv-popup td.LAYER_TOOLS {
    flex: 0 0 auto !important;
    width: 100px !important;
    min-width: 100px !important;
    max-width: 120px !important;
    overflow: visible !important;
    vertical-align: top !important;
    display: table-cell !important; /* fallback para cuando no hay flex padre */
}
/* Cuando el padre sí es flex, convertir a bloque */
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td.LAYER_TOOLS,
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td.LAYER_TOOLS,
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td.LAYER_TOOLS {
    display: block !important;
    flex: 0 0 100px !important;
}

/* 64.E — Botones de LAYER_TOOLS: columna centrada, nunca ocultos */
body.pdv-popup .LAYER_TOOLS > table {
    width: 100% !important;
    table-layout: auto !important;
}
body.pdv-popup .LAYER_TOOLS > table > tbody > tr,
body.pdv-popup .LAYER_TOOLS > table > tr {
    display: table-row !important; /* conservar layout tabla aquí */
}

/* 64.F — Action bar inferior (Ticket/Factura/Devolución/Caja/...):
   wrap para que los botones bajen si no caben en una fila */
body.pdv-popup .pdv-action-bar {
    flex-wrap: wrap !important;
    gap: 4px !important;
    height: auto !important;
    min-height: 72px !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
    flex: 1 1 60px !important;
    min-width: 60px !important;
    max-width: 90px !important;
    height: auto !important;
    min-height: 64px !important;
}

/* La celda contenedora de la action bar: ancho auto en vez de 618px fijo */
body.pdv-popup .pdv-action-bar-cell {
    width: auto !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}
/* La celda del logo: comprimible en pantallas pequeñas */
body.pdv-popup .pdv-logo-cell {
    width: auto !important;
    min-width: 100px !important;
    max-width: 200px !important;
    flex-shrink: 1 !important;
}
/* La fila de buttons también: flex para que action-bar-cell y logo-cell
   se repartan el espacio disponible */
body.pdv-popup #LAYER_BUTTONS {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    width: 100% !important;
}
body.pdv-popup #LAYER_BUTTONS > td {
    display: block !important;
}

/* 64.G — @media ≤ 1100px: LAYER_TOOLS se vuelve sticky bottom
   para que siempre sea accesible aunque la pantalla sea angosta */
@media (max-width: 1100px) {

    body.pdv-popup .pdv-card {
        border-radius: 8px !important;
    }

    /* La fila contenido+sidebar: permitir que el sidebar "se vea"
       haciendo que LAYER_TOOLS baje al final si no cabe */
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr,
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr,
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr {
        flex-wrap: nowrap !important; /* sigue en una fila pero overflow scroll */
        overflow-x: auto !important;
    }

    /* LAYER_TOOLS sticky: se "pega" a la derecha del viewport del PDV */
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td.LAYER_TOOLS,
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td.LAYER_TOOLS,
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td.LAYER_TOOLS {
        position: sticky !important;
        right: 0 !important;
        z-index: 10 !important;
        background-color: var(--bg-subtle, #f6f9fc) !important;
        box-shadow: -4px 0 8px rgba(10,37,64,0.08) !important;
    }

    body.pdv-popup .LAYER_TOOLS {
        min-width: 100px !important;
    }

    /* Botones acción: mini-size para que quepan en fila */
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 50px !important;
        min-width: 50px !important;
        padding: 4px 2px !important;
    }
    body.pdv-popup .pdv-action-bar .pdv-action-label {
        font-size: 10px !important;
    }
}

/* 64.H — @media ≤ 768px: layout totalmente vertical */
@media (max-width: 768px) {

    body.pdv-popup .pdv-card {
        border-radius: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Fila contenido+sidebar: apilar verticalmente */
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr,
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr,
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr {
        flex-direction: column !important;
        overflow-x: hidden !important;
    }

    /* Spacers: cero altura para no desperdiciar espacio */
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td:first-child,
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td:nth-child(3),
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td:first-child,
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td:nth-child(3),
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td:first-child,
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td:nth-child(3) {
        flex: 0 0 0 !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* Celda contenido: ancho completo */
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td:nth-child(2),
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td:nth-child(2),
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td:nth-child(2) {
        width: 100% !important;
        overflow-x: auto !important;
    }

    /* LAYER_TOOLS: barra horizontal abajo */
    body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td.LAYER_TOOLS,
    body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td.LAYER_TOOLS,
    body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td.LAYER_TOOLS {
        position: static !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 0 0 auto !important;
        box-shadow: none !important;
        border-top: 1px solid var(--border-default, #e3e8ee) !important;
        padding: 6px 4px !important;
    }
    body.pdv-popup .LAYER_TOOLS {
        min-width: 0 !important;
        width: 100% !important;
    }
    /* Botones de LAYER_TOOLS en horizontal */
    body.pdv-popup .LAYER_TOOLS > table,
    body.pdv-popup .LAYER_TOOLS > table > tbody {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        width: 100% !important;
    }
    body.pdv-popup .LAYER_TOOLS > table > tbody > tr,
    body.pdv-popup .LAYER_TOOLS > table > tr {
        display: contents !important;
    }
    body.pdv-popup .LAYER_TOOLS > table > tbody > tr > td,
    body.pdv-popup .LAYER_TOOLS > table > tr > td {
        flex: 1 1 80px !important;
        display: block !important;
    }
    body.pdv-popup .LAYER_TOOLS .pdv-side-icon {
        width: 80px !important;
        margin: 2px auto !important;
    }

    /* Action bar: botones más pequeños */
    body.pdv-popup .pdv-action-bar {
        min-height: 56px !important;
        gap: 3px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 46px !important;
        min-width: 46px !important;
        min-height: 52px !important;
        padding: 4px 2px !important;
    }
    body.pdv-popup .pdv-action-bar .pdv-action-label {
        font-size: 10px !important;
        white-space: normal !important;
    }

    /* Logo: ocultar en móvil para ganar espacio */
    body.pdv-popup .pdv-logo-cell {
        display: none !important;
    }
    body.pdv-popup .pdv-action-bar-gap {
        display: none !important;
    }
    body.pdv-popup #LAYER_BUTTONS {
        flex-wrap: wrap !important;
    }
}
/* ============================================================
 * Fin SECCIÓN 64 — PDV Responsive.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 65 — PDV: botones de acción (LAYER_TOOLS) siempre
 *              visibles cuando el grid de productos crece.
 *
 * Problema:
 *   Al agregar detalles (IMEI/producto) en el ticket del PDV,
 *   el contenido de LAYER_TICKET_MAIN / CONTENEDOR_TICKET crece
 *   verticalmente. La tabla que envuelve el grid y la sidebar
 *   LAYER_TOOLS crece con él, empujando los botones Pagar /
 *   Pasar Caja / Cancelar / Guardar fuera del viewport.
 *
 * Estrategia:
 *   A. Sticky en el TD.LAYER_TOOLS: position:sticky + top:0
 *      funciona en TDs dentro de TABLE legacy (Chrome, Firefox,
 *      Safari 15+). align-self:flex-start previene estiramiento
 *      en contextos flex.
 *   B. max-height + overflow-y:auto en LAYER_TICKET_MAIN y
 *      CONTENEDOR_TICKET para que el grid crezca con scroll
 *      INTERNO y no empuje la página/sidebar.
 *   C. Mismo tratamiento para los divs dinámicos
 *      LAYER_TICKET_{ID}_MAIN y LAYER_FACTURA_{ID}_MAIN.
 * ============================================================ */

/* 65.A — Sidebar sticky: los botones permanecen visibles */
body.pdv-popup td.LAYER_TOOLS,
body.pdv-popup .LAYER_TOOLS {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    align-self: flex-start !important;
    vertical-align: top !important;
    max-height: calc(100dvh - 24px) !important;
    max-height: calc(100vh  - 24px) !important;
    overflow-y: auto !important;
    z-index: 2 !important;
}

/* 65.B — Grid central (contenedores estáticos): scroll interno */
body.pdv-popup #LAYER_TICKET_MAIN,
body.pdv-popup #CONTENEDOR_TICKET {
    max-height: calc(100dvh - 210px) !important;
    max-height: calc(100vh  - 210px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* 65.C — Divs dinámicos por DOC_DOC_ID: LAYER_TICKET_{ID}_MAIN */
body.pdv-popup div[id^="LAYER_TICKET_"][id$="_MAIN"] {
    max-height: calc(100dvh - 220px) !important;
    max-height: calc(100vh  - 220px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* 65.D — Factura: mismo tratamiento */
body.pdv-popup div[id^="LAYER_FACTURA_"][id$="_MAIN"] {
    max-height: calc(100dvh - 220px) !important;
    max-height: calc(100vh  - 220px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* ============================================================
 * Fin SECCIÓN 65.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 66 — PDV fix agresivo (sidebar SIEMPRE visible)
 *
 * Las secciones 63/64/65 usan position: sticky en TD, que el HTML
 * legacy de tabla del PDV no respeta consistentemente. Este fix usa
 * position: fixed sobre LAYER_TOOLS para garantizar que los botones
 * Pagar/Pasar Caja/Cancelar/Guardar SIEMPRE aparezcan a la derecha
 * sin depender de sticky/overflow del padre.
 *
 * También cubre:
 *  - Modal rojo de Dialog.alert/error con texto vacío (forzar contenido visible)
 *  - Modal verde de Dialog.notice (forzar contenido visible)
 *  - Centrar contenido del modal para que header y body estén alineados
 * ============================================================ */

/* 66.A — Sidebar PDV FIXED: siempre visible a la derecha del viewport */
body.pdv-popup td.LAYER_TOOLS,
body.pdv-popup .LAYER_TOOLS {
    position: fixed !important;
    top: 80px !important;
    right: 12px !important;
    width: 100px !important;
    max-width: 100px !important;
    min-width: 100px !important;
    max-height: calc(100vh - 100px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 100 !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(10, 37, 64, 0.08) !important;
    padding: 8px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Asegurar que cada hijo de LAYER_TOOLS sea visible */
body.pdv-popup .LAYER_TOOLS *,
body.pdv-popup td.LAYER_TOOLS * {
    visibility: visible !important;
    opacity: 1 !important;
}
body.pdv-popup .LAYER_TOOLS .pdv-side-icon,
body.pdv-popup .LAYER_TOOLS .ICON {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Compensar el body para que el contenido principal no quede bajo el fixed sidebar */
body.pdv-popup {
    padding-right: 130px !important;
    box-sizing: border-box !important;
}

/* En pantallas chicas (≤768px) el fixed queda como barra horizontal abajo */
@media (max-width: 768px) {
    body.pdv-popup td.LAYER_TOOLS,
    body.pdv-popup .LAYER_TOOLS {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        max-height: 88px !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 12px !important;
        border-radius: 12px 12px 0 0 !important;
    }
    body.pdv-popup {
        padding-right: 0 !important;
        padding-bottom: 100px !important;
    }
}

/* 66.B — Modal Dialog.alert/error/notice: forzar TEXTO visible */
body .alert_content,
body .alert_message,
body .alert_window,
body .notice_content,
body .notice_message,
body .notice_window,
body .dialog_content,
body .dialog_message,
body .dialog_window,
body .error_content,
body .error_message,
body .error_window {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 60px !important;
    max-height: none !important;
    background: #ffffff !important;
    color: var(--stx-text-primary, #0a2540) !important;
    padding: 16px 20px !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    overflow: visible !important;
}
body .alert_content *,
body .notice_content *,
body .dialog_content *,
body .error_content * {
    color: var(--stx-text-primary, #0a2540) !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* El header rojo/verde no debe ocupar todo el modal — limitar altura */
body .alert_n,
body .error_n,
body .notice_n,
body .dialog_n,
body .warning_n {
    height: 44px !important;
    max-height: 44px !important;
    min-height: 44px !important;
}

/* Si Dialog.alert dispara con mensaje vacío, ocultar el modal entero */
body .alert_window:empty,
body .error_window:empty,
body .notice_window:empty {
    display: none !important;
}

/* ============================================================
 * Fin SECCIÓN 66.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 67 — Reportes / display.php V4 (tarjeta Stripe)
 * ============================================================
 *
 * Restyle del form de parámetros de reportes (system/bin/section/
 * reportes/display.php). Antes era FIELDSET + LEGEND + tabla legacy
 * con TDs FORM_TABLE_DARK/LIGHT; ahora es un contenedor .stx-rep-
 * display con secciones .stx-rep-card y grid de campos .stx-rep-
 * form-grid. Los widgets de filtro provienen de show_filter() y
 * heredan el styling V4 de inputs/selects.
 *
 * Reusa tokens existentes (var(--*)). No hardcodea colores ni
 * fuentes — Inter del body.
 * ============================================================ */

body.main-v2 .stx-rep-display {
    font-family: var(--font-sans, 'Inter', sans-serif);
    color: var(--stx-text-primary, var(--text-primary, #0a2540));
    max-width: 1100px;
    margin: 16px auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

body.main-v2 .stx-rep-display-header {
    padding: 4px 4px 0 4px;
}
body.main-v2 .stx-rep-display-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--stx-text-primary, #0a2540);
    margin: 0;
    line-height: 1.2;
}

body.main-v2 .stx-rep-card {
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--stx-border, var(--border-default, #e3e8ee));
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.04), 0 1px 0 rgba(10, 37, 64, 0.02);
    overflow: hidden;
    display: block;
}
body.main-v2 .stx-rep-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--stx-border-subtle, var(--border-default, #e3e8ee));
    background: var(--bg-subtle, #f6f9fc);
    font-size: 13px;
    font-weight: 600;
    color: var(--stx-text-primary, #0a2540);
    letter-spacing: -0.005em;
}
body.main-v2 .stx-rep-card-header svg {
    color: var(--stx-primary-600, #635bff);
    flex-shrink: 0;
}
body.main-v2 .stx-rep-card-header span {
    color: var(--stx-text-primary, #0a2540);
}
body.main-v2 .stx-rep-card-body {
    padding: 18px;
}

/* Grid de campos: 2 columnas en desktop, 1 en mobile */
body.main-v2 .stx-rep-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 24px;
}
@media (max-width: 720px) {
    body.main-v2 .stx-rep-form-grid {
        grid-template-columns: 1fr;
    }
}

body.main-v2 .stx-rep-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
body.main-v2 .stx-rep-field-full {
    grid-column: 1 / -1;
}

body.main-v2 .stx-rep-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--stx-text-secondary, var(--text-secondary, #425466));
    letter-spacing: -0.005em;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
body.main-v2 .stx-rep-req {
    color: var(--stx-danger, #f04438);
    font-weight: 600;
    margin-left: 2px;
}

body.main-v2 .stx-rep-control {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Inputs/selects/textarea dentro del control: full-width V4 */
body.main-v2 .stx-rep-control input[type="text"],
body.main-v2 .stx-rep-control input[type="password"],
body.main-v2 .stx-rep-control input[type="number"],
body.main-v2 .stx-rep-control input[type="email"],
body.main-v2 .stx-rep-control input[type="date"],
body.main-v2 .stx-rep-control input[type="search"],
body.main-v2 .stx-rep-control select,
body.main-v2 .stx-rep-control textarea {
    width: 100% !important;
    box-sizing: border-box !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    font-size: 13px !important;
    color: var(--stx-text-primary, #0a2540) !important;
    background: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--stx-border, var(--border-default, #e3e8ee)) !important;
    border-radius: 6px !important;
    padding: 7px 10px !important;
    line-height: 1.4 !important;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
body.main-v2 .stx-rep-control textarea {
    min-height: 80px;
    resize: vertical;
}
body.main-v2 .stx-rep-control input:focus,
body.main-v2 .stx-rep-control select:focus,
body.main-v2 .stx-rep-control textarea:focus {
    outline: none !important;
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.15) !important;
}

/* Select V4: appearance:none + chevron SVG (Lucide chevron-down) */
body.main-v2 .stx-rep-control select,
body.main-v2 select.stx-rep-select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23697386' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 14px 14px !important;
    padding-right: 30px !important;
    cursor: pointer;
}

/* Checkbox dentro del control */
body.main-v2 .stx-rep-control input[type="checkbox"],
body.main-v2 input.stx-rep-check {
    accent-color: var(--stx-primary-600, #635bff);
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 4px 0;
}

/* Layer de correo (aparece al activar checkbox) */
body.main-v2 .stx-rep-correo-layer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--stx-border-subtle, var(--border-default, #e3e8ee));
}

/* Footer del display con nota y acciones */
body.main-v2 .stx-rep-display-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 6px 6px 14px 6px;
}
body.main-v2 .stx-rep-note {
    font-size: 12px;
    color: var(--stx-text-secondary, #425466);
}
body.main-v2 .stx-rep-actions {
    display: flex;
    gap: 10px;
}

body.main-v2 .stx-rep-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.005em;
    background: var(--stx-primary-600, #635bff);
    color: #ffffff;
    border: 1px solid var(--stx-primary-600, #635bff);
    border-radius: 7px;
    padding: 9px 18px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(99, 91, 255, 0.20), 0 1px 0 rgba(99, 91, 255, 0.08);
    transition: background 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}
body.main-v2 .stx-rep-btn-primary:hover {
    background: var(--stx-primary-700, #5147e2);
    border-color: var(--stx-primary-700, #5147e2);
    box-shadow: 0 2px 4px rgba(99, 91, 255, 0.25);
}
body.main-v2 .stx-rep-btn-primary:active {
    transform: translateY(1px);
}
body.main-v2 .stx-rep-btn-primary svg {
    flex-shrink: 0;
}

/* ----------------------------------------------------------
 * Fix global: <select> nativos con apariencia macOS 3D.
 * La regla previa de SECCIÓN 26 estilizaba border/padding/color
 * pero NO reseteaba appearance, por lo que macOS Chrome/Safari
 * seguía dibujando el botón nativo 3D ("Selecciona" con flechas
 * arriba/abajo). Aplicamos appearance:none + chevron SVG a TODOS
 * los selects del main shell (excepto sidebar/topbar que tienen
 * estilo propio). Esto cubre el form de reportes y cualquier
 * otra pantalla con selects sin clase específica.
 * ---------------------------------------------------------- */
body.main-v2 select:not([class*="sb"]):not([class*="topbar"]):not([multiple]) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23697386' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 13px 13px;
    padding-right: 26px;
}

/* ----------------------------------------------------------
 * Widget propio .stx-ss-* (stx_searchable_select.js, vanilla
 * JS sin dependencias externas). Reemplaza <select> nativos
 * con un combobox que tiene búsqueda + multi-select.
 *
 * Estructura DOM emitida por el JS:
 *
 *   <select style="display:none">...</select>
 *   <div class="stx-ss-wrap stx-ss-single|stx-ss-multi">
 *     <div class="stx-ss-trigger">
 *       <span class="stx-ss-placeholder|stx-ss-value">...</span>
 *       <span class="stx-ss-chip">                  (sólo multi)
 *         <span class="stx-ss-chip-label">...</span>
 *         <button class="stx-ss-chip-remove">×</button>
 *       </span>
 *       <button class="stx-ss-clear">×</button>     (si hay sel)
 *       <span class="stx-ss-chevron"><svg>↓</svg></span>
 *     </div>
 *   </div>
 *
 *   <div class="stx-ss-dropdown">                   (montado en <body>)
 *     <div class="stx-ss-search-wrap">
 *       <input class="stx-ss-search" placeholder="Buscar...">
 *     </div>
 *     <div class="stx-ss-options">
 *       <div class="stx-ss-option active|selected">...</div>
 *       <div class="stx-ss-no-results">Sin resultados</div>
 *     </div>
 *   </div>
 * ---------------------------------------------------------- */
body.main-v2 .stx-ss-wrap {
    position: relative;
    width: 100%;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 13px;
    box-sizing: border-box;
    cursor: pointer;
    outline: none;
}
body.main-v2 .stx-ss-trigger {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--stx-border, var(--border-default, #e3e8ee));
    border-radius: 6px;
    padding: 5px 34px 5px 10px;
    color: var(--stx-text-primary, #0a2540);
    box-sizing: border-box;
    position: relative;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
body.main-v2 .stx-ss-wrap:focus .stx-ss-trigger,
body.main-v2 .stx-ss-wrap.open .stx-ss-trigger {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
}
body.main-v2 .stx-ss-placeholder {
    color: var(--stx-text-secondary, var(--text-secondary, #697386));
    opacity: 0.85;
    font-size: 13px;
    line-height: 1.5;
}
body.main-v2 .stx-ss-value {
    color: var(--stx-text-primary, #0a2540);
    font-size: 13px;
    line-height: 1.5;
}
body.main-v2 .stx-ss-chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--stx-text-secondary, #697386);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 120ms ease;
}
body.main-v2 .stx-ss-wrap.open .stx-ss-chevron {
    transform: translateY(-50%) rotate(180deg);
}
body.main-v2 .stx-ss-clear {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--stx-text-secondary, #697386);
    opacity: 0.55;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}
body.main-v2 .stx-ss-clear:hover {
    opacity: 1;
    background: var(--stx-danger-50, #fef2f2);
    color: var(--stx-danger, #f04438);
}
body.main-v2 .stx-ss-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--stx-primary-50, #efeefe);
    color: var(--stx-primary-700, #5147e2);
    border: 1px solid rgba(99,91,255,0.20);
    border-radius: 4px;
    padding: 2px 4px 2px 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    max-width: 100%;
}
body.main-v2 .stx-ss-chip-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
body.main-v2 .stx-ss-chip-remove {
    background: transparent;
    border: none;
    color: var(--stx-primary-700, #5147e2);
    opacity: 0.6;
    font-size: 14px;
    line-height: 1;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: opacity 120ms ease, background 120ms ease;
}
body.main-v2 .stx-ss-chip-remove:hover {
    opacity: 1;
    background: var(--stx-primary-100, #dad7fe);
}

/* Dropdown global (montado en <body> para escapar overflow:hidden
   de las tarjetas .stx-rep-card). Aplica regla SIN scope a body. */
body.main-v2 .stx-ss-dropdown {
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--stx-border, var(--border-default, #e3e8ee));
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(10,37,64,0.10), 0 2px 8px rgba(10,37,64,0.06);
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 13px;
    overflow: hidden;
    z-index: 9999;
    box-sizing: border-box;
}
body.main-v2 .stx-ss-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--stx-border-subtle, var(--border-default, #e3e8ee));
    background: var(--bg-subtle, #f6f9fc);
}
body.main-v2 .stx-ss-search {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 13px;
    color: var(--stx-text-primary, #0a2540);
    background: var(--bg-base, #ffffff);
    border: 1px solid var(--stx-border, var(--border-default, #e3e8ee));
    border-radius: 6px;
    padding: 6px 10px;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
body.main-v2 .stx-ss-search:focus {
    border-color: var(--stx-primary-600, #635bff);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
}
body.main-v2 .stx-ss-options {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 0;
}
body.main-v2 .stx-ss-option {
    padding: 7px 12px;
    color: var(--stx-text-primary, #0a2540);
    cursor: pointer;
    line-height: 1.4;
    transition: background 80ms ease, color 80ms ease;
}
body.main-v2 .stx-ss-option.active,
body.main-v2 .stx-ss-option:hover {
    background: var(--stx-primary-50, #efeefe);
    color: var(--stx-primary-700, #5147e2);
}
body.main-v2 .stx-ss-option.selected {
    background: var(--stx-primary-100, #dad7fe);
    color: var(--stx-primary-800, #3d35b0);
    font-weight: 500;
}
body.main-v2 .stx-ss-no-results {
    padding: 10px 12px;
    color: var(--stx-text-secondary, #697386);
    font-style: italic;
    text-align: center;
}

/* ============================================================
 * Fin SECCIÓN 67.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 68 — Dashboard V2 inicio + panel fallback (V4)
 * ============================================================ */

/* Contenedor principal del dashboard V2 */
body.main-v2 .stx-dash2-wrap {
    padding: 0 0 40px 0;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

/* Header del dashboard: fondo blanco, borde inferior sutil */
body.main-v2 .stx-dash2-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-100, #e3e8ee);
    padding: 20px 24px 16px 24px;
    margin-bottom: 24px;
}

body.main-v2 .stx-dash2-header-inner {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

body.main-v2 .stx-dash2-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--gray-900, #0a2540);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
}

body.main-v2 .stx-dash2-noun {
    color: var(--stx-primary, #635bff);
    font-weight: 700;
}

body.main-v2 .stx-dash2-subtitle {
    font-size: 13px;
    color: var(--gray-500, #697386);
    font-weight: 400;
    margin-top: 4px;
}

/* Área de errores */
body.main-v2 .stx-dash2-errors {
    padding: 0 24px;
    margin-bottom: 16px;
}

/* Grid de columnas de secciones */
body.main-v2 .stx-dash2-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
    padding: 0 24px;
    align-items: start;
}

/* Una sola columna si solo hay col-1 */
body.main-v2 .stx-dash2-grid.stx-dash2-grid--single {
    grid-template-columns: 1fr;
}

/* Columna individual */
body.main-v2 .stx-dash2-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Cada sección (FIELDSET wrapper de subsección) */
body.main-v2 .stx-dash2-section-wrap {
    background: #fff;
    border: 1px solid var(--gray-100, #e3e8ee);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(10,37,64,0.06), 0 2px 12px rgba(10,37,64,0.04);
    overflow: hidden;
}

/* Fallback panel vacío: card centrada con mensaje */
body.main-v2 .stx-dash2-empty {
    background: #fff;
    border: 1px solid var(--gray-100, #e3e8ee);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(10,37,64,0.06);
    padding: 40px 24px;
    text-align: center;
    color: var(--gray-500, #697386);
    font-size: 14px;
    font-weight: 400;
    margin: 0 24px;
}

body.main-v2 .stx-dash2-empty svg {
    display: block;
    margin: 0 auto 12px auto;
    opacity: 0.35;
}

body.main-v2 .stx-dash2-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-700, #425466);
    margin-bottom: 4px;
}

/* Quick links section — preservar espacio visual */
body.main-v2 .stx-dash2-quicklinks {
    padding: 0 24px;
    margin-top: 8px;
}

/* Stack de secciones ancho completo (USU_DAS_POSITION=3).
 * Se renderiza arriba del grid de 2 columnas. Cada seccion ocupa
 * el ancho completo del viewport (menos el padding). */
body.main-v2 .stx-dash2-full-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 24px;
    margin-bottom: 20px;
}
body.main-v2 .stx-dash2-section-wrap--full {
    width: 100%;
}

/* Responsive: en pantallas pequeñas apilar columnas */
@media (max-width: 720px) {
    body.main-v2 .stx-dash2-grid {
        grid-template-columns: 1fr;
        padding: 0 12px;
    }
    body.main-v2 .stx-dash2-header {
        padding: 16px 12px 12px 12px;
    }
    body.main-v2 .stx-dash2-errors,
    body.main-v2 .stx-dash2-quicklinks {
        padding: 0 12px;
    }
    body.main-v2 .stx-dash2-empty {
        margin: 0 12px;
    }
}

/* ============================================================
 * Fin SECCIÓN 68.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 69 — Pantallas error + acceso denegado (V4)
 * ============================================================ */

.stx-err-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 32px 16px;
    box-sizing: border-box;
}

.stx-err-card {
    background: var(--bg-elevated, #ffffff);
    border: 1px solid var(--stx-gray-200, #e3e8ee);
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(10,37,64,0.08), 0 1px 4px rgba(10,37,64,0.05);
    padding: 40px 36px 32px;
    max-width: 460px;
    width: 100%;
    text-align: center;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

.stx-err-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin-bottom: 20px;
}

.stx-err-icon-danger {
    background: var(--stx-danger-light, #fef3f2);
    color: var(--stx-danger, #f04438);
}

.stx-err-icon-warning {
    background: var(--stx-warning-light, #fffaeb);
    color: var(--stx-warning, #f79009);
}

.stx-err-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary, #0a2540);
    margin: 0 0 12px;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

.stx-err-msg {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-secondary, #425466);
    margin: 0 0 28px;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

.stx-err-msg strong {
    font-weight: 600;
    color: var(--text-primary, #0a2540);
}

.stx-err-link {
    color: var(--stx-primary-600, #635bff);
    text-decoration: none;
    font-weight: 500;
}
.stx-err-link:hover {
    text-decoration: underline;
}

.stx-err-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.stx-err-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 20px;
    border-radius: 8px;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.stx-err-btn-primary {
    background: var(--stx-primary-600, #635bff);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(99,91,255,0.30);
}
.stx-err-btn-primary:hover {
    background: var(--stx-primary-700, #5147e2);
    box-shadow: 0 2px 6px rgba(99,91,255,0.40);
}

.stx-err-btn-secondary {
    background: var(--stx-gray-100, #f3f6fa);
    color: var(--text-primary, #0a2540);
    border: 1px solid var(--stx-gray-200, #e3e8ee);
}
.stx-err-btn-secondary:hover {
    background: var(--stx-gray-200, #e3e8ee);
}

/* ============================================================
 * Fin SECCIÓN 69.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 70 — Plan V2 crédito/BNPL (V4)
 *
 * Clases cubiertas (CSS-only, sin tocar PHP):
 *   - .ETIQUETA                — label de campo
 *   - .DATOS_FORMULARIO        — valor resaltado de campo
 *   - .PATHBAR / .PATHBAR a    — breadcrumb de navegación
 *   - .SECTION_TITLE           — refuerzo tipografía Inter (sec 8 básico)
 *   - .FONDO_FICHA_DET_LEFT    — acento izquierdo violeta de la ficha-plan
 *   - .DIV_BORDER_FICHA_DET    — borde interior de la ficha-plan
 *   - .BORDES_AZUL_DARK        — wrapper exterior de la ficha-plan → card
 *   - .BORDE_LEFT_AZUL_DARK    — variante borde-left de la ficha
 *   - .BORDE_BOTTOM_AZUL_DARK  — variante borde-bottom
 *   - .BORDE_TOP_AZUL_DARK     — variante borde-top
 *   - FIELDSET / LEGEND plan_v2 (refuerzo sec 8)
 *   - .BUTTON_ plan_v2 (acciones expediente)
 *   - badge nuevos comentarios (font[color="RED"])
 *
 * Clases ya cubiertas por secciones anteriores (no se repiten):
 *   FORM_TABLE_DARK/LIGHT (sec 26), TEXTBOX (sec 26),
 *   DATATABLA / TITULOS_DATATABLA (sec 26),
 *   GRID_TABLE / GRID_TITLE / GRID_CELL (secs 26/40),
 *   ODD_ROW / EVEN_ROW / FONDO_RENGLON1/2 (secs 3/26),
 *   BUTTON_SAVE / BUTTON_BACK / BUTTON_OK (secs 26/44).
 * ============================================================ */

/* ----------------------------------------------------------
 * 70.1 — PATHBAR (breadcrumb superior)
 * ---------------------------------------------------------- */
body.main-v2 td.PATHBAR,
body.main-v2 .PATHBAR {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 12px;
    color: var(--gray-500, #697386);
    padding: 8px 0 4px 0;
    letter-spacing: 0.01em;
}
body.main-v2 td.PATHBAR a,
body.main-v2 .PATHBAR a {
    color: var(--stx-primary-600, #635bff);
    text-decoration: none;
    font-weight: 500;
}
body.main-v2 td.PATHBAR a:hover,
body.main-v2 .PATHBAR a:hover {
    text-decoration: underline;
    color: var(--stx-primary-700, #4f46e5);
}

/* ----------------------------------------------------------
 * 70.2 — SECTION_TITLE (refuerzo Inter + color Stripe)
 * ---------------------------------------------------------- */
body.main-v2 td.SECTION_TITLE,
body.main-v2 .SECTION_TITLE {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900, #0a2540);
    letter-spacing: -0.03em;
    padding: 4px 0 8px 0;
    line-height: 1.3;
}

/* ----------------------------------------------------------
 * 70.3 — ETIQUETA: label de campo de formulario/vista
 * ---------------------------------------------------------- */
body.main-v2 td.ETIQUETA,
body.main-v2 .ETIQUETA {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600, #425466);
    vertical-align: top;
    padding: 5px 8px 5px 0;
}

/* ----------------------------------------------------------
 * 70.4 — DATOS_FORMULARIO: valor destacado del campo
 * ---------------------------------------------------------- */
body.main-v2 font.DATOS_FORMULARIO,
body.main-v2 .DATOS_FORMULARIO {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 13px;
    font-weight: 600;
    color: var(--stx-primary-600, #635bff);
}

/* ----------------------------------------------------------
 * 70.5 — Ficha-plan ("card" del expediente PLAT)
 *
 * HTML legacy:
 *   <TABLE CLASS="BORDES_AZUL_DARK">          ← card wrapper
 *     <TR>
 *       <TD CLASS="FONDO_FICHA_DET_LEFT">     ← acento izquierdo
 *       <TD>
 *         <TABLE CLASS="BORDE_LEFT_AZUL_DARK"> ← cuerpo interior
 *           <TABLE CLASS="BORDE_BOTTOM_AZUL_DARK"> ← fila de datos
 * ---------------------------------------------------------- */

/* Card wrapper: borde suave + sombra Stripe, sin borde azul oscuro */
body.main-v2 table.BORDES_AZUL_DARK {
    border: 1px solid var(--border-light, #e3e8ee) !important;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(10,37,64,0.06), 0 2px 8px rgba(10,37,64,0.04);
    overflow: hidden;
    background: #ffffff;
    margin-bottom: 10px;
}

/* Acento izquierdo: tira violeta Stripe */
body.main-v2 td.FONDO_FICHA_DET_LEFT {
    background-color: var(--stx-primary-600, #635bff) !important;
    width: 5px !important;
    min-width: 5px;
    padding: 0 !important;
}

/* Cuerpo interior: quitar borde azul oscuro */
body.main-v2 table.BORDE_LEFT_AZUL_DARK {
    border-left: none !important;
}
body.main-v2 td.BORDE_LEFT_AZUL_DARK {
    border-left: none !important;
}

/* Fila cabecera de la ficha: separador sutil */
body.main-v2 table.BORDE_BOTTOM_AZUL_DARK {
    border: none !important;
    border-bottom: 1px solid var(--border-light, #e3e8ee) !important;
}
body.main-v2 td.BORDE_BOTTOM_AZUL_DARK {
    border-bottom: 1px solid var(--border-light, #e3e8ee) !important;
}
body.main-v2 td.BORDE_TOP_AZUL_DARK {
    border-top: 1px solid var(--border-light, #e3e8ee) !important;
}

/* DIV_BORDER_FICHA_DET: tabla interior de activaciones */
body.main-v2 table.DIV_BORDER_FICHA_DET,
body.main-v2 .DIV_BORDER_FICHA_DET {
    border: 1px solid var(--border-light, #e3e8ee) !important;
    border-radius: 6px;
    overflow: hidden;
}

/* ----------------------------------------------------------
 * 70.6 — FIELDSET del módulo (estado de planes)
 * ---------------------------------------------------------- */
body.main-v2 div[id^="DIV_PRINCIPAL_"] > fieldset {
    border: 1px solid var(--border-light, #e3e8ee) !important;
    border-radius: 10px;
    background: var(--bg-subtle, #f6f9fc);
    padding: 12px 16px 8px 16px;
    margin-bottom: 12px;
}
body.main-v2 div[id^="DIV_PRINCIPAL_"] > fieldset > legend {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 13px;
    font-weight: 600;
    color: var(--stx-primary-600, #635bff);
    padding: 0 8px;
    letter-spacing: -0.01em;
}

/* ----------------------------------------------------------
 * 70.7 — BUTTON_ genérico del módulo Plan V2
 *         (Buscar, Avanzar, Guardar, Rechazado, Autorizado…)
 * ---------------------------------------------------------- */
body.main-v2 input.BUTTON_,
body.main-v2 div.BUTTON_ {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 7px 16px !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background 0.15s ease, box-shadow 0.15s ease !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.20) !important;
}
body.main-v2 input.BUTTON_:hover,
body.main-v2 div.BUTTON_:hover {
    background: var(--stx-primary-700, #5147e5) !important;
    box-shadow: 0 2px 6px rgba(99,91,255,0.30) !important;
}

/* ----------------------------------------------------------
 * 70.8 — Contador de planes (link "HAY N PLANES X")
 * ---------------------------------------------------------- */
body.main-v2 a[href*="GOTO_SUB_MOSTRAR_PLANES"] {
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif);
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700, #425466);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
body.main-v2 a[href*="GOTO_SUB_MOSTRAR_PLANES"] font[color="DarkRed"] {
    color: var(--stx-primary-600, #635bff) !important;
    font-size: 15px;
    margin: 0 2px;
}

/* ----------------------------------------------------------
 * 70.9 — Badge comentarios nuevos (font[color="RED"])
 * ---------------------------------------------------------- */
body.main-v2 td.ETIQUETA font[color="RED"],
body.main-v2 .ETIQUETA font[color="RED"] {
    display: inline-block;
    background: var(--stx-danger-50, #fef3f2);
    color: var(--stx-danger, #f04438) !important;
    border: 1px solid var(--stx-danger-200, #fecdca);
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    vertical-align: middle;
    margin-right: 4px;
}

/* ============================================================
 * Fin SECCIÓN 70.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 71 — Catálogos (V4)
 *
 * Cubre los patrones visuales de los ~239 archivos en
 * /system/bin/section/catalogos/** sin modificar PHP.
 *
 * PATRONES CUBIERTOS:
 *   A. Panel de entidad (clientes/panel.php, atributos/panel.php…)
 *      → outer TABLE shell + FIELDSET "Acciones" + FIELDSET "X registrados"
 *   B. Bulk-action SELECT en paneles de listado
 *   C. Display de entidad (display.php): FIELDSET "Acciones" con .ICON row
 *   D. Form de entidad (form.php): refuerzos específicos de catalogos
 *   E. Responsive: panel Productos dos columnas
 *
 * NO toca:
 *   - stx-doc-panel / tiles/list/cards → §20
 *   - DATAGRID → §5 / §34
 *   - FIELDSET/LEGEND base → §8
 *   - .ICON wrapper → §28
 *   - FORM_TABLE_DARK/LIGHT → §13
 * ============================================================ */

/* ── A. Outer TABLE shell ── */
/* Neutralizar el CELLPADDING="10" inline del wrapper exterior que rodea
   los FIELDSET en panel/form/display legacy de Catálogos. */
body.main-v2 table[cellpadding="10"][width="100%"] > tbody > tr > td,
body.main-v2 table[cellpadding="10"][width="100%"] > tr > td {
    padding: 12px 16px !important;
}

/* Tabla interior "CONTENIDO" con CELLPADDING="5" */
body.main-v2 table[cellpadding="5"][width="100%"] > tbody > tr > td,
body.main-v2 table[cellpadding="5"][width="100%"] > tr > td {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

/* ── B. FIELDSET de Acciones (contiene .ICON) ── */
/* Fondo sutil y acento izquierdo para la barra de acciones. */
body.main-v2 fieldset:has(.ICON) {
    background: var(--bg-subtle, #f6f9fc) !important;
    border-left: 3px solid var(--stx-primary, #635bff) !important;
    border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0 !important;
    padding: 10px 12px 10px 14px !important;
    margin-bottom: 12px;
}

/* Reducir el cellpadding de la tabla que rodea los .ICON */
body.main-v2 fieldset:has(.ICON) table[cellpadding] > tbody > tr > td,
body.main-v2 fieldset:has(.ICON) table[cellpadding] > tr > td {
    padding: 4px 6px !important;
    vertical-align: top;
}

/* ── C. FIELDSET de datos / listado (sin .ICON) ── */
/* Card limpia: blanco, borde sutil, sin border-left de acento. */
body.main-v2 fieldset:not(:has(.ICON)) {
    background: #ffffff !important;
    border: 1px solid var(--gray-100, #e3e8ee) !important;
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: 0 1px 3px rgba(10,37,64,0.04) !important;
    padding: 12px 14px !important;
    margin-bottom: 12px;
    border-left-width: 1px !important;
}

/* LEGEND: label sutil estilo Stripe */
body.main-v2 fieldset > legend {
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    color: var(--text-tertiary, #697386) !important;
    padding: 0 6px !important;
    background: transparent !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
}

/* ── D. Bulk-action SELECT al pie del listado ── */
body.main-v2 fieldset select[onchange],
body.main-v2 fieldset select[ONCHANGE] {
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    font-size: 12px !important;
    color: var(--text-secondary, #425466) !important;
    background: #ffffff !important;
    border: 1px solid var(--gray-200, #c1c9d2) !important;
    border-radius: var(--radius-sm, 6px) !important;
    padding: 5px 10px !important;
    cursor: pointer;
    transition: border-color 120ms ease;
    min-width: 200px;
}
body.main-v2 fieldset select[onchange]:focus,
body.main-v2 fieldset select[ONCHANGE]:focus {
    outline: none !important;
    border-color: var(--stx-primary, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.12) !important;
}

/* ── E. FORM_TABLE_DARK: ancho de columna de labels ── */
body.main-v2 .FORM_TABLE_DARK {
    width: 200px;
    min-width: 140px;
    white-space: nowrap;
}

/* ── F. Fallback: navegadores sin :has() ── */
@supports not selector(:has(.ICON)) {
    body.main-v2 fieldset {
        background: #ffffff !important;
        border: 1px solid var(--gray-100, #e3e8ee) !important;
        border-radius: var(--radius-md, 8px) !important;
        box-shadow: 0 1px 3px rgba(10,37,64,0.04) !important;
        padding: 12px 14px !important;
        margin-bottom: 12px;
    }
}

/* ── G. Responsive: panel Productos dos columnas ── */
@media (max-width: 800px) {
    body.main-v2 td[width="528"],
    body.main-v2 td[WIDTH="528"] {
        width: 100% !important;
        display: block;
        padding-top: 12px;
    }
    body.main-v2 div#LAYER_LIST {
        width: 100% !important;
        margin-top: 0 !important;
    }
}

/* ============================================================
 * Fin SECCIÓN 71.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 72 — Dashboards personalizados (V4)
 *
 * Cubre los ~50 archivos display_* / panel_* / resumen_* /
 * saldos_* / ventas_* del directorio:
 *   personal/celucenter/.../modulos/section/dashboards/
 *
 * Estrategia: CSS que sobreescribe patrones HTML legacy
 * (FIELDSET/LEGEND, TABLE.DATATABLA, FONDO_RENGLON*, etc.)
 * sin tocar el PHP. También estiliza las clases semi-V4 ya
 * presentes (rag-card, card-num, card-stat, etc.).
 * ============================================================ */

/* ----------------------------------------------------------
 * 72.1 Variables locales
 * ---------------------------------------------------------- */
:root {
    --db72-primary:     #635bff;
    --db72-primary-dim: rgba(99, 91, 255, 0.08);
    --db72-success:     #0e9f6e;
    --db72-danger:      #e02424;
    --db72-warning:     #d97706;
    --db72-gray-50:     #f7f8fa;
    --db72-gray-100:    #e3e8ee;
    --db72-gray-200:    #c8d0dc;
    --db72-gray-500:    #697386;
    --db72-gray-700:    #425466;
    --db72-gray-900:    #0a2540;
    --db72-radius:      10px;
    --db72-shadow:      0 1px 4px rgba(10,37,64,.06), 0 2px 12px rgba(10,37,64,.04);
    --db72-font-num:    'JetBrains Mono', 'Fira Mono', 'Courier New', monospace;
    --db72-font-ui:     'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ----------------------------------------------------------
 * 72.2 FIELDSET — reemplaza borde legacy por card Stripe
 * ---------------------------------------------------------- */
#GRAFICA_VENTAS       > FIELDSET,
#GRAFICA_UTILIDADES   > FIELDSET,
#GRAFICA_VENTAS_X_PRODUCTO > FIELDSET,
#CAJAS_REGISTRADORAS  > FIELDSET,
[id^="GRAFICA_"]      > FIELDSET,
[id^="RESUMEN_"]      > FIELDSET,
[id^="SALDOS_"]       > FIELDSET,
.dashboards-panel     > FIELDSET,
.db72-panel {
    background: #fff;
    border: 1px solid var(--db72-gray-100);
    border-radius: var(--db72-radius);
    box-shadow: var(--db72-shadow);
    padding: 0;
    margin-bottom: 16px;
    overflow: hidden;
    font-family: var(--db72-font-ui);
}

/* LEGEND → header de card con borde inferior */
#GRAFICA_VENTAS       > FIELDSET > LEGEND,
#GRAFICA_UTILIDADES   > FIELDSET > LEGEND,
#GRAFICA_VENTAS_X_PRODUCTO > FIELDSET > LEGEND,
#CAJAS_REGISTRADORAS  > FIELDSET > LEGEND,
[id^="GRAFICA_"]      > FIELDSET > LEGEND,
[id^="RESUMEN_"]      > FIELDSET > LEGEND,
[id^="SALDOS_"]       > FIELDSET > LEGEND,
.dashboards-panel     > FIELDSET > LEGEND,
.db72-panel-title {
    float: none;
    display: block;
    width: 100%;
    padding: 14px 20px 13px 20px;
    margin: 0;
    background: #fff;
    border-bottom: 1px solid var(--db72-gray-100);
    font-family: var(--db72-font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--db72-gray-900);
    letter-spacing: .01em;
    box-sizing: border-box;
}

/* Celda raíz directa dentro de FIELDSET > TABLE > TR > TD */
#GRAFICA_VENTAS       > FIELDSET > TABLE > TBODY > TR > TD,
#GRAFICA_UTILIDADES   > FIELDSET > TABLE > TBODY > TR > TD,
#GRAFICA_VENTAS_X_PRODUCTO > FIELDSET > TABLE > TBODY > TR > TD,
#CAJAS_REGISTRADORAS  > FIELDSET > TABLE > TBODY > TR > TD,
[id^="GRAFICA_"]      > FIELDSET > TABLE > TBODY > TR > TD,
[id^="RESUMEN_"]      > FIELDSET > TABLE > TBODY > TR > TD,
[id^="SALDOS_"]       > FIELDSET > TABLE > TBODY > TR > TD {
    padding: 16px 20px;
}

/* ----------------------------------------------------------
 * 72.3 DATATABLA — tabla de datos legacy
 * ---------------------------------------------------------- */
TABLE.DATATABLA {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--db72-font-ui);
    font-size: 13px;
    color: var(--db72-gray-900);
    margin-top: 8px;
}

TD.TITULOS_DATATABLA,
TH.TITULOS_DATATABLA {
    background: var(--db72-gray-50);
    color: var(--db72-gray-500);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 8px 12px;
    border-bottom: 1px solid var(--db72-gray-100);
    white-space: nowrap;
}

TD.FONDO_RENGLON1,
TD.FONDO_RENGLON2 {
    padding: 9px 12px;
    border-bottom: 1px solid var(--db72-gray-100);
    font-size: 13px;
    color: var(--db72-gray-900);
}

TD.FONDO_RENGLON1 { background: #fff; }
TD.FONDO_RENGLON2 { background: var(--db72-gray-50); }

TABLE.DATATABLA TR:hover TD.FONDO_RENGLON1,
TABLE.DATATABLA TR:hover TD.FONDO_RENGLON2 {
    background: var(--db72-primary-dim);
    transition: background 0.12s;
}

/* ----------------------------------------------------------
 * 72.4 Filtros de formulario (FORM_TABLE_LIGHT / DARK,
 *      FONT.NEGRITA, DIV.FLOAT [Actualizar])
 * ---------------------------------------------------------- */
TABLE TD.FORM_TABLE_LIGHT,
TABLE TD.FORM_TABLE_DARK {
    font-family: var(--db72-font-ui);
    font-size: 12px;
    color: var(--db72-gray-700);
    padding: 4px 10px;
}
TABLE TD.FORM_TABLE_DARK {
    font-weight: 600;
    color: var(--db72-gray-500);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

FONT.NEGRITA {
    font-family: var(--db72-font-ui);
    font-size: 12px;
    font-weight: 600;
    color: var(--db72-gray-500);
    letter-spacing: .03em;
}

DIV.FLOAT { text-align: right; margin-top: 4px; }
DIV.FLOAT a {
    font-size: 12px;
    font-weight: 500;
    color: var(--db72-primary);
    text-decoration: none;
    border: 1px solid var(--db72-primary);
    border-radius: 6px;
    padding: 4px 12px;
    display: inline-block;
    transition: background .12s, color .12s;
}
DIV.FLOAT a:hover { background: var(--db72-primary); color: #fff; }

/* ----------------------------------------------------------
 * 72.5 KPI cards — patrón "rag-*" (display_resumen_admin_general)
 * ---------------------------------------------------------- */
.rag-card {
    background: #fff;
    border: 1px solid var(--db72-gray-100);
    border-radius: var(--db72-radius);
    box-shadow: var(--db72-shadow);
    padding: 16px 20px;
    font-family: var(--db72-font-ui);
}

.rag-h {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.rag-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--db72-gray-900);
    letter-spacing: .01em;
}

.rag-cta {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: var(--db72-primary);
    padding: 5px 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: opacity .12s;
    white-space: nowrap;
}
.rag-cta:hover { opacity: .85; }

.rag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.rag-k {
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--db72-gray-50);
    border-left: 3px solid var(--db72-primary);
    text-align: left;
}
.rag-k.k-red    { border-left-color: var(--db72-danger);  background: #fef2f2; }
.rag-k.k-green  { border-left-color: var(--db72-success); background: #f0fdf4; }
.rag-k.k-yellow { border-left-color: var(--db72-warning); background: #fffbeb; }

.rag-k .rag-v,
.rag-v {
    font-family: var(--db72-font-num);
    font-size: 20px;
    font-weight: 700;
    color: var(--db72-gray-900);
    line-height: 1.15;
    letter-spacing: -.02em;
}

.rag-k .rag-l,
.rag-l {
    font-family: var(--db72-font-ui);
    font-size: 10px;
    font-weight: 500;
    color: var(--db72-gray-500);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 4px;
}

/* ----------------------------------------------------------
 * 72.6 card-stat / card-num / card-label
 * ---------------------------------------------------------- */
.card-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    background: var(--db72-gray-50);
    border: 1px solid var(--db72-gray-100);
    border-radius: 8px;
    border-left: 3px solid var(--db72-primary);
    min-width: 100px;
}
.card-stat.ok    { border-left-color: var(--db72-success); background: #f0fdf4; }
.card-stat.error { border-left-color: var(--db72-danger);  background: #fef2f2; }
.card-stat.warn  { border-left-color: var(--db72-warning); background: #fffbeb; }

.card-num {
    font-family: var(--db72-font-num);
    font-size: 22px;
    font-weight: 700;
    color: var(--db72-gray-900);
    line-height: 1.1;
    letter-spacing: -.02em;
}

.card-label {
    font-family: var(--db72-font-ui);
    font-size: 10px;
    font-weight: 500;
    color: var(--db72-gray-500);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 5px;
}

.cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

/* ----------------------------------------------------------
 * 72.7 Wrapper gráficas FusionCharts (solo contenedor visual)
 * ---------------------------------------------------------- */
[id^="GRAFICA_"] > FIELDSET .fusioncharts-container,
[id^="GRAFICA_"] > FIELDSET object,
[id^="GRAFICA_"] > FIELDSET embed {
    border-radius: 6px;
    overflow: hidden;
    display: block;
}

/* ----------------------------------------------------------
 * 72.8 Botones de acción legacy
 * ---------------------------------------------------------- */
TD.BUTTON_OK A, INPUT.BUTTON_OK, A.BUTTON_OK {
    display: inline-block;
    background: var(--db72-primary);
    color: #fff;
    font-family: var(--db72-font-ui);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 6px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: opacity .12s;
}
TD.BUTTON_OK A:hover, INPUT.BUTTON_OK:hover, A.BUTTON_OK:hover { opacity: .85; }

TD.BUTTON_BACK A, A.BUTTON_BACK {
    display: inline-block;
    background: transparent;
    color: var(--db72-primary);
    font-family: var(--db72-font-ui);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--db72-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background .12s, color .12s;
}
TD.BUTTON_BACK A:hover, A.BUTTON_BACK:hover { background: var(--db72-primary); color: #fff; }

TD.BUTTON_SMALL A, A.BUTTON_SMALL {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 5px;
    color: var(--db72-primary);
    border: 1px solid var(--db72-gray-200);
    background: #fff;
    text-decoration: none;
    font-family: var(--db72-font-ui);
    font-weight: 500;
    transition: background .12s;
}
TD.BUTTON_SMALL A:hover, A.BUTTON_SMALL:hover { background: var(--db72-gray-50); }

/* ----------------------------------------------------------
 * 72.9 Títulos de sección / pathbar / fuente legacy
 * ---------------------------------------------------------- */
TD.SECTION_TITLE, .SECTION_TITLE, .section-title {
    font-family: var(--db72-font-ui);
    font-size: 14px;
    font-weight: 600;
    color: var(--db72-gray-900);
    padding: 12px 20px;
    letter-spacing: .01em;
    border-bottom: 1px solid var(--db72-gray-100);
}

TD.PATHBAR, .PATHBAR {
    font-family: var(--db72-font-ui);
    font-size: 11px;
    color: var(--db72-gray-500);
    padding: 6px 20px;
    background: var(--db72-gray-50);
    border-bottom: 1px solid var(--db72-gray-100);
}

TD.FUENTE, .FUENTE {
    font-family: var(--db72-font-ui);
    font-size: 13px;
    color: var(--db72-gray-700);
    font-weight: 500;
}

/* ----------------------------------------------------------
 * 72.10 Estado ERROR
 * ---------------------------------------------------------- */
TD.ERROR, .ERROR {
    font-family: var(--db72-font-ui);
    font-size: 12px;
    color: var(--db72-danger);
    font-weight: 500;
}

/* ----------------------------------------------------------
 * 72.11 Pills bar
 * ---------------------------------------------------------- */
.pills-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }

/* ----------------------------------------------------------
 * 72.12 Monitor APIs (display_monitor_apis)
 * ---------------------------------------------------------- */
.monitor-container { font-family: var(--db72-font-ui); font-size: 13px; }

.log-scroll {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--db72-gray-100);
    border-radius: 8px;
    background: #fff;
}

.log-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--db72-font-ui); }
.log-table th {
    position: sticky; top: 0;
    background: var(--db72-gray-50);
    color: var(--db72-gray-500);
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--db72-gray-100);
    z-index: 1;
}
.log-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--db72-gray-100);
    color: var(--db72-gray-900);
    vertical-align: middle;
}
.log-table tr:hover td { background: var(--db72-gray-50); }

.api-tag {
    display: inline-block;
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
    background: var(--db72-primary-dim); color: var(--db72-primary);
}

.badge {
    display: inline-block;
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 999px;
    letter-spacing: .03em; white-space: nowrap;
}
.badge.ok     { background: #ecfdf5; color: var(--db72-success); }
.badge.error  { background: #fef2f2; color: var(--db72-danger); }
.badge.warn   { background: #fffbeb; color: var(--db72-warning); }
.badge.info   { background: var(--db72-primary-dim); color: var(--db72-primary); }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--db72-gray-200);
    border-top-color: var(--db72-primary);
    border-radius: 50%;
    animation: db72-spin .7s linear infinite;
    vertical-align: middle;
}
@keyframes db72-spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------
 * 72.13 Inputs especializados (codigo-input, excel-input,
 *        series-container/textarea, modal-btn, btn-csv,
 *        boton-venta, boton-subir)
 * ---------------------------------------------------------- */
.codigo-input {
    font-family: var(--db72-font-num);
    font-size: 14px; padding: 6px 10px;
    border: 1px solid var(--db72-gray-200); border-radius: 6px;
    color: var(--db72-gray-900); background: #fff;
    transition: border-color .15s; box-sizing: border-box;
}
.codigo-input:focus {
    outline: none;
    border-color: var(--db72-primary);
    box-shadow: 0 0 0 3px var(--db72-primary-dim);
}

.excel-input {
    font-family: var(--db72-font-ui);
    font-size: 12px; padding: 5px 8px;
    border: 1px solid var(--db72-gray-200); border-radius: 6px;
    background: #fff; color: var(--db72-gray-900);
}

.series-container {
    background: var(--db72-gray-50);
    border: 1px solid var(--db72-gray-100);
    border-radius: 8px; padding: 12px; margin-top: 8px;
}

.series-textarea {
    width: 100%;
    font-family: var(--db72-font-num); font-size: 12px;
    padding: 8px; border: 1px solid var(--db72-gray-200); border-radius: 6px;
    background: #fff; color: var(--db72-gray-900);
    resize: vertical; box-sizing: border-box;
}

.modal-btn, .btn-csv, .boton-venta, .boton-subir {
    display: inline-block;
    font-family: var(--db72-font-ui); font-size: 12px; font-weight: 500;
    padding: 6px 16px; border-radius: 6px;
    text-decoration: none; cursor: pointer; border: none;
    transition: opacity .12s, background .12s;
}
.boton-venta, .boton-subir { background: var(--db72-primary); color: #fff; }
.boton-venta:hover, .boton-subir:hover { opacity: .85; }
.btn-csv { background: var(--db72-success); color: #fff; }
.btn-csv:hover { opacity: .85; }
.modal-btn { background: #fff; color: var(--db72-primary); border: 1px solid var(--db72-primary); }
.modal-btn:hover { background: var(--db72-primary); color: #fff; }

/* ----------------------------------------------------------
 * 72.14 Responsive
 * ---------------------------------------------------------- */
@media (max-width: 720px) {
    .rag-grid { grid-template-columns: repeat(2, 1fr); }
    .cards-row { flex-direction: column; }
    TD.TITULOS_DATATABLA, TH.TITULOS_DATATABLA { font-size: 10px; padding: 6px 8px; }
    TD.FONDO_RENGLON1, TD.FONDO_RENGLON2 { padding: 7px 8px; font-size: 12px; }
}

/* ============================================================
 * Fin SECCIÓN 72 — Dashboards personalizados (V4).
 * ============================================================ */


/* ============================================================
 * SECCIÓN 73 — Saldos (CXC/CXP/inventario/comisiones/bancos) V4
 * ============================================================
 *
 * Cubre los patrones específicos del módulo SALDOS que no están
 * resueltos por las secciones genéricas (26 DATATABLA, 4 LIST_TABLE,
 * etc.). Sin refactors de PHP — todo vía selectores sobre HTML legacy.
 *
 * Sub-módulos: CXC, CXP, comisiones, inventario, cuentas bancarias,
 *              cajas, panel raíz (stx_panel_render_v4 ya cubierto).
 *
 * Patrones nuevos:
 *   A. Columnas numéricas — tabular-nums JetBrains Mono, right-aligned
 *   B. Filas de saldo positivo / negativo (color por signo)
 *   C. Totales acumulados (semibold, fondo sutil, borde top)
 *   D. Tabla resumen de saldo bancario (saldo inicial → saldo disponible)
 *   E. Filtro de período (FIELDSET "Periodo") — refinamiento saldos
 *   F. Tabla de aplicaciones — override inline alternating rows
 *   G. Totales de inventario (existencias_totales snippet)
 *   H. Fila "gran total" en pasivo por cliente / proveedor
 *   I. Responsive — colapsar tablas en pantallas angostas
 * ============================================================ */

/* ------------------------------------------------------------------
 * A. COLUMNAS NUMÉRICAS en tablas de saldos
 *    Clase opt-in: .sal-num
 *    También cubre TD[ALIGN="right"] dentro de FORM_TABLE_LIGHT.
 * ------------------------------------------------------------------ */
body.main-v2 td.sal-num,
body.main-v2 th.sal-num {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    font-size: 13px !important;
    text-align: right !important;
    white-space: nowrap !important;
    letter-spacing: 0.01em !important;
}

/* FORM_TABLE_LIGHT alineados a la derecha en contexto saldos */
body.main-v2 fieldset td.FORM_TABLE_LIGHT[align="right"],
body.main-v2 fieldset td.FORM_TABLE_LIGHT[ALIGN="right"] {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    font-size: 13px !important;
    text-align: right !important;
    white-space: nowrap !important;
    letter-spacing: 0.01em !important;
}

/* ------------------------------------------------------------------
 * B. FILAS CON SALDO POSITIVO / NEGATIVO
 *    Clases opt-in: .sal-row-positive / .sal-row-negative / .sal-row-zero
 *    Celdas individuales: .sal-amount-pos / .sal-amount-neg
 * ------------------------------------------------------------------ */
body.main-v2 tr.sal-row-positive td {
    background-color: var(--stx-success-light, #ecfdf3) !important;
    color: var(--stx-success-dark, #027a48) !important;
}
body.main-v2 tr.sal-row-negative td {
    background-color: var(--stx-danger-light, #fef3f2) !important;
    color: var(--stx-danger-dark, #b42318) !important;
}
body.main-v2 tr.sal-row-zero td {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-tertiary, #697386) !important;
}
body.main-v2 tr.sal-row-positive:hover td { background-color: #d1fae5 !important; }
body.main-v2 tr.sal-row-negative:hover td { background-color: #fee2e2 !important; }

body.main-v2 td.sal-amount-pos,
body.main-v2 th.sal-amount-pos {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
    color: var(--stx-success-dark, #027a48) !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}
body.main-v2 td.sal-amount-neg,
body.main-v2 th.sal-amount-neg {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
    color: var(--stx-danger-dark, #b42318) !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

/* ------------------------------------------------------------------
 * C. FILAS / BLOQUES DE TOTALES ACUMULADOS
 *    .sal-row-total — fila de total en LIST_TABLE o tabla inline
 *    .sal-total-block — wrapper de fieldset "Totales" (inv, CXC)
 * ------------------------------------------------------------------ */
body.main-v2 tr.sal-row-total td {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-top: 2px solid var(--border-default, #e3e8ee) !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    color: var(--text-primary, #0a2540) !important;
}
body.main-v2 tr.sal-row-total td.sal-num,
body.main-v2 tr.sal-row-total td.FORM_TABLE_LIGHT {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
}

body.main-v2 fieldset.sal-total-block,
body.main-v2 .sal-total-block fieldset {
    background: var(--bg-subtle, #f6f9fc) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
}
body.main-v2 fieldset.sal-total-block legend,
body.main-v2 .sal-total-block fieldset legend {
    font-weight: 700 !important;
    color: var(--text-primary, #0a2540) !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

/* ------------------------------------------------------------------
 * D. TABLA RESUMEN DE SALDO BANCARIO (display_bancos.php)
 *    Wrapper: .sal-balance-summary
 *    Filas clave (Saldo Conciliado, Saldo Disponible): .sal-balance-key
 *    Abonos: .sal-abono   Cargos/Retiros: .sal-cargo / .sal-retiro
 * ------------------------------------------------------------------ */
body.main-v2 .sal-balance-summary {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    background: #fff !important;
}
body.main-v2 .sal-balance-summary tr.sal-balance-key td {
    background-color: var(--stx-primary-50, #efeefe) !important;
    font-weight: 600 !important;
    color: var(--text-primary, #0a2540) !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
}
body.main-v2 .sal-balance-summary tr.sal-balance-key td.FORM_TABLE_LIGHT {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--stx-primary-600, #635bff) !important;
}
body.main-v2 .sal-balance-summary td[colspan] hr,
body.main-v2 .sal-balance-summary td[COLSPAN] hr {
    border: none !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
    margin: 2px 0 !important;
}
body.main-v2 .sal-balance-summary tr.sal-abono td.FORM_TABLE_LIGHT {
    color: var(--stx-success-dark, #027a48) !important;
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
}
body.main-v2 .sal-balance-summary tr.sal-cargo td.FORM_TABLE_LIGHT,
body.main-v2 .sal-balance-summary tr.sal-retiro td.FORM_TABLE_LIGHT {
    color: var(--stx-danger-dark, #b42318) !important;
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
}

/* ------------------------------------------------------------------
 * E. FILTRO DE PERÍODO — clase opt-in .sal-filter-bar
 *    Refinamiento para selector cliente + rango fechas en saldos.
 * ------------------------------------------------------------------ */
body.main-v2 .sal-filter-bar {
    background: var(--bg-muted, #f3f6fa) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 10px !important;
    padding: 14px 18px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 12px 24px !important;
    margin-bottom: 16px !important;
}
body.main-v2 .sal-filter-bar label,
body.main-v2 .sal-filter-bar td.FORM_TABLE_DARK {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-secondary, #425466) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    white-space: nowrap !important;
    border: none !important;
    background: transparent !important;
}
body.main-v2 .sal-filter-bar .BUTTON_ {
    margin-left: auto !important;
}

/* ------------------------------------------------------------------
 * F. TABLA DE APLICACIONES (CXC/CXP estado_de_cuenta)
 *    Override de inline style background-color en LIST_TABLE.
 *    Columnas 4-7 (importe, abono, aplicado, saldo) → tabular-nums.
 * ------------------------------------------------------------------ */
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT[style*="background-color"],
body.main-v2 .LIST_TABLE tr[class="FORM_TABLE_LIGHT"][style] {
    background-color: unset !important;
}
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT:nth-child(even) {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT:nth-child(odd) {
    background-color: var(--bg-base, #ffffff) !important;
}
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT:hover {
    background-color: var(--stx-primary-50, #efeefe) !important;
}
body.main-v2 .LIST_TABLE tr.LIST_TABLE_HEAD td,
body.main-v2 .LIST_TABLE tr.LIST_TABLE_HEAD th {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    border-bottom: 2px solid var(--border-default, #e3e8ee) !important;
    padding: 8px 10px !important;
    white-space: nowrap !important;
}
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT td:nth-child(4),
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT td:nth-child(5),
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT td:nth-child(6),
body.main-v2 .LIST_TABLE tr.FORM_TABLE_LIGHT td:nth-child(7) {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
    font-size: 13px !important;
    white-space: nowrap !important;
}

/* ------------------------------------------------------------------
 * G. TOTALES DE INVENTARIO (existencias_totales.php snippet)
 *    Targeteado via #EXISTENCIAS_TOTALES y clase opt-in .sal-inv-totals
 * ------------------------------------------------------------------ */
body.main-v2 #EXISTENCIAS_TOTALES fieldset,
body.main-v2 .sal-inv-totals fieldset {
    background: var(--bg-subtle, #f6f9fc) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    margin-top: 8px !important;
}
body.main-v2 #EXISTENCIAS_TOTALES fieldset legend,
body.main-v2 .sal-inv-totals fieldset legend {
    font-weight: 700 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: var(--text-secondary, #425466) !important;
}
body.main-v2 #EXISTENCIAS_TOTALES td.FORM_TABLE_LIGHT[align="right"],
body.main-v2 #EXISTENCIAS_TOTALES td.FORM_TABLE_LIGHT[ALIGN="right"],
body.main-v2 .sal-inv-totals td.FORM_TABLE_LIGHT[align="right"] {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    color: var(--text-primary, #0a2540) !important;
}
body.main-v2 #EXISTENCIAS_TOTALES td.FORM_TABLE_LIGHT:not([align]):not([ALIGN]),
body.main-v2 .sal-inv-totals td.FORM_TABLE_LIGHT:not([align]):not([ALIGN]) {
    font-weight: 600 !important;
    font-size: 14px !important;
    color: var(--text-primary, #0a2540) !important;
    font-variant-numeric: tabular-nums !important;
}

/* ------------------------------------------------------------------
 * H. GRAN TOTAL — pasivo por cliente / proveedor
 *    Fieldset "Totales por moneda" + clase .sal-gran-total en TR
 * ------------------------------------------------------------------ */
body.main-v2 .sal-gran-total-wrap fieldset {
    background: var(--bg-subtle, #f6f9fc) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    margin-top: 12px !important;
}
body.main-v2 .sal-gran-total td:first-child {
    font-weight: 600 !important;
    font-size: 13px !important;
    color: var(--text-secondary, #425466) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
}
body.main-v2 .sal-gran-total td:last-child {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', monospace !important;
    font-variant-numeric: tabular-nums !important;
    text-align: right !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    color: var(--stx-primary-600, #635bff) !important;
}

/* ------------------------------------------------------------------
 * I. RESPONSIVE — colapsar tablas de saldo en pantallas angostas
 * ------------------------------------------------------------------ */
@media (max-width: 768px) {
    body.main-v2 .sal-balance-summary table,
    body.main-v2 .sal-balance-summary tr,
    body.main-v2 .sal-balance-summary td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    body.main-v2 .sal-balance-summary td.FORM_TABLE_DARK {
        padding-bottom: 2px !important;
        font-size: 11px !important;
        color: var(--text-tertiary, #697386) !important;
    }
    body.main-v2 .sal-balance-summary td.FORM_TABLE_LIGHT {
        font-size: 15px !important;
        padding-top: 2px !important;
        padding-bottom: 10px !important;
    }
    body.main-v2 .sal-filter-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
}

/* ============================================================
 * Fin SECCIÓN 73.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 74 — Dashboard inicio scroll horizontal restaurado
 *
 * El nuevo wrapper .stx-dash2-wrap de SECCIÓN 68 no permitía scroll
 * horizontal del contenido (el TABLE BGCOLOR legacy sí). En módulos
 * con tableros anchos eso recorta info.
 * ============================================================ */

body.main-v2 .stx-dash2-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
    max-width: 100% !important;
}
body.main-v2 .stx-dash2-grid {
    min-width: 0 !important;
}
body.main-v2 .stx-dash2-col,
body.main-v2 .stx-dash2-section-wrap {
    min-width: 0 !important;
    overflow-x: auto !important;
}
/* Las secciones que el dashboard renderiza adentro pueden ser tablas
   muy anchas — permitir scroll interno sin que rompa el layout */
body.main-v2 .stx-dash2-section-wrap > table,
body.main-v2 .stx-dash2-section-wrap > fieldset > table {
    max-width: 100% !important;
}
/* ============================================================
 * Fin SECCIÓN 74.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 74 — PDV V4 polish profesional (consolida y corrige)
 *
 * Esta sección consolida y reemplaza la mecánica conflictiva que se
 * había acumulado en las secciones 53/63/64/65/66 sobre el PDV:
 *
 *   - LAYER_TOOLS dejaba de estar dentro de la card por usar
 *     `position: fixed` con `padding-right: 130px` en body. Eso recortaba
 *     el contenido y dejaba al sidebar flotando fuera del popup.
 *   - El icono Pagar (wallet) heredaba 52px + padding 10 + content-box
 *     en sección 63.B, lo que rompía el wrapper .pdv-side-icon de 90px.
 *   - Existencias / Otros mapeaban ambos al icono Lucide `boxes` que
 *     se renderiza como un cubo 3D parcialmente outline → aspecto "hueco".
 *   - LAYER_TABS a 32px era marginal para 12px + 6/14 padding del tab.
 *   - FORM_TABLE_DARK/LIGHT inducía contraste pobre (franja gris + blanco).
 *   - El grid del PDV traía padding inline 2px que aplastaba las filas.
 *   - El botón "agregar detalle" salía como GIF gigante 152x65 estilo card.
 *
 * Esta sección 74 hace UN solo override coherente:
 *
 *   74.A  Body sin padding-right + card fluida 880 max
 *   74.B  LAYER_TABS 36px + tabs con buen padding
 *   74.C  LAYER_TOOLS dentro de la card (sticky top:8, no fixed)
 *   74.D  Pagar / Pasar Caja → pastilla 44x44 success
 *   74.E  Cancelar → pastilla 44x44 danger / Guardar → primary
 *   74.F  pdv-side-icon wrapper limpio (sin border ni shadow propio)
 *   74.G  Action-bar icons con pastilla SIEMPRE sólida (anti-outline)
 *   74.H  FORM_TABLE_DARK/LIGHT transparentes en PDV
 *   74.I  Grid del detalle con padding cómodo
 *   74.J  TOTALES con card shadow sutil
 *   74.K  Botón "+" de agregar detalle normalizado
 *   74.L  Responsive smoothing
 *
 * NO toca JS ni IDs. Sólo CSS con namespace `body.pdv-popup` para no
 * afectar otras pantallas.
 * ============================================================ */

/* 74.A — Body sin compensación; card fluida hasta 880px */
body.pdv-popup {
    padding-right: 0 !important;
    padding-left: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
}
body.pdv-popup .pdv-card {
    width: 100% !important;
    max-width: 880px !important;
    margin: 8px auto !important;
}
body.pdv-popup .pdv-card > table {
    width: 100% !important;
    max-width: 880px !important;
}

/* 74.B — LAYER_TABS: altura y padding cómodos */
body.pdv-popup .LAYER_TABS {
    height: 36px !important;
    display: flex !important;
    align-items: flex-end !important;
    padding: 0 4px !important;
}
body.pdv-popup .OFF_MIDDLE_PDV,
body.pdv-popup .ON_MIDDLE_PDV {
    padding: 7px 16px !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
    height: auto !important;
    margin-right: 2px !important;
}

/* 74.C — LAYER_TOOLS dentro del flujo de la card (mata fixed de 66.A) */
body.pdv-popup td.LAYER_TOOLS,
body.pdv-popup .LAYER_TOOLS {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 8px !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100px !important;
    max-width: 100px !important;
    min-width: 100px !important;
    max-height: calc(100vh - 80px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 5 !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    display: block !important;
}
body.pdv-popup td > div[id^="LAYER_FORM_TICKET"] > table > tbody > tr > td.LAYER_TOOLS,
body.pdv-popup td > div[id^="LAYER_FORM_FACTURA"] > table > tbody > tr > td.LAYER_TOOLS,
body.pdv-popup td > div[id^="LAYER_FORM_DEVOLUCION"] > table > tbody > tr > td.LAYER_TOOLS {
    flex: 0 0 100px !important;
}

/* 74.D — Pagar / Pasar Caja: pastilla 44x44 success (mata 52px + padding 10 de 63.B) */
body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"],
body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"],
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    padding: 10px !important;
    box-sizing: border-box !important;
    border-radius: 10px !important;
    background: var(--stx-success-light, #ecfdf3) !important;
    color: var(--stx-success-dark, #027a48) !important;
    box-shadow: 0 1px 2px rgba(22,179,100,0.12) !important;
    cursor: pointer !important;
    transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"]:hover,
body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"]:hover,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"]:hover,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"]:hover {
    background: var(--stx-success, #16b364) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(22,179,100,0.22) !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"]:active,
body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"]:active,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"]:active,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"]:active {
    transform: scale(0.96) !important;
}

/* 74.E — Cancelar: tinte danger / Guardar: tinte primary */
body.pdv-popup .LAYER_TOOLS img[src*="bt_cancelar_captura"],
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_cancelar_captura"] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    padding: 10px !important;
    box-sizing: border-box !important;
    border-radius: 10px !important;
    background: var(--stx-danger-light, #fef3f2) !important;
    color: var(--stx-danger, #f04438) !important;
    box-shadow: 0 1px 2px rgba(240,68,56,0.12) !important;
    cursor: pointer !important;
    transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_cancelar_captura"]:hover,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_cancelar_captura"]:hover {
    background: var(--stx-danger, #f04438) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(240,68,56,0.22) !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_cancelar_captura"]:active,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_cancelar_captura"]:active {
    transform: scale(0.96) !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_guardar_documento"],
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_guardar_documento"] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    padding: 10px !important;
    box-sizing: border-box !important;
    border-radius: 10px !important;
    background: var(--stx-primary-100, #dddcff) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.12) !important;
    cursor: pointer !important;
    transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_guardar_documento"]:hover,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_guardar_documento"]:hover {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(99,91,255,0.22) !important;
}
body.pdv-popup .LAYER_TOOLS img[src*="bt_guardar_documento"]:active,
body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_guardar_documento"]:active {
    transform: scale(0.96) !important;
}

/* 74.F — pdv-side-icon wrapper: compacto, sin border ni shadow (lo aporta el tile) */
body.pdv-popup .LAYER_TOOLS .pdv-side-icon {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 4px 0 !important;
    width: 88px !important;
    max-width: 88px !important;
    margin: 6px auto !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    text-align: center !important;
    cursor: pointer !important;
}
body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover {
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
}
body.pdv-popup .LAYER_TOOLS .pdv-side-label {
    font-family: 'Inter', sans-serif !important;
    font-size: 11.5px !important;
    font-weight: 500 !important;
    color: var(--text-primary, #0a2540) !important;
    line-height: 1.2 !important;
    text-align: center !important;
    letter-spacing: -0.005em !important;
}
body.pdv-popup .LAYER_TOOLS > table,
body.pdv-popup .LAYER_TOOLS > table > tbody {
    width: 100% !important;
    border-collapse: collapse !important;
}
body.pdv-popup .LAYER_TOOLS > table > tbody > tr > td,
body.pdv-popup .LAYER_TOOLS > table > tr > td {
    text-align: center !important;
    padding: 0 !important;
    vertical-align: middle !important;
}

/* 74.G — Action bar icons: pastilla SIEMPRE con background sólido para evitar
   el efecto "hexágono hueco" del icono Lucide boxes/warehouse cuando sólo
   se ve el outline. Esto fuerza fondo + color del tile aunque el SVG sea pobre. */
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    background-color: var(--tile-bg, rgba(99,91,255,0.12)) !important;
    color: var(--tile-fg, #635bff) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile .stx-svg-icon {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    stroke-width: 2 !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
    flex: 1 1 0 !important;
    min-width: 70px !important;
    max-width: none !important;
    padding: 8px 4px !important;
    gap: 6px !important;
    height: 78px !important;
    min-height: 78px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .pdv-action-label {
    font-size: 11.5px !important;
    font-weight: 500 !important;
    color: var(--text-primary, #0a2540) !important;
    line-height: 1.2 !important;
    letter-spacing: -0.005em !important;
}
/* Fallback IMG GIF (si el replacer no corrió): visible pero degradado */
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon > img {
    max-width: 28px !important;
    max-height: 28px !important;
    display: block !important;
    margin: 0 auto !important;
    opacity: 0.45 !important;
    border-radius: 4px !important;
}

/* 74.H — Encabezado: FORM_TABLE_DARK/LIGHT transparentes para look V4 limpio */
body.pdv-popup .FORM_TABLE_DARK,
body.pdv-popup td.FORM_TABLE_DARK,
body.pdv-popup .FORM_TABLE_DARK[class] {
    background-color: transparent !important;
    background-image: none !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--text-secondary, #425466) !important;
    padding: 6px 10px 6px 0 !important;
    border: none !important;
    letter-spacing: -0.005em !important;
}
body.pdv-popup .FORM_TABLE_LIGHT,
body.pdv-popup td.FORM_TABLE_LIGHT,
body.pdv-popup .FORM_TABLE_LIGHT[class] {
    background-color: transparent !important;
    background-image: none !important;
    padding: 4px 0 !important;
    border: none !important;
}
body.pdv-popup .TEXTBOX,
body.pdv-popup input.TEXTBOX,
body.pdv-popup select.TEXTBOX,
body.pdv-popup textarea.TEXTBOX {
    font-family: 'Inter', sans-serif !important;
    font-size: 12.5px !important;
    color: var(--text-primary, #0a2540) !important;
    background-color: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    line-height: 1.35 !important;
    min-height: 30px !important;
    box-sizing: border-box !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
}
body.pdv-popup .TEXTBOX:focus,
body.pdv-popup input.TEXTBOX:focus,
body.pdv-popup select.TEXTBOX:focus,
body.pdv-popup textarea.TEXTBOX:focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}

/* 74.I — Grid del detalle: padding cómodo (mata inline 2px de PHP) */
body.pdv-popup .GRID_HEADER_PDV th,
body.pdv-popup .GRID_HEADER_PDV td {
    padding: 8px 10px !important;
}
body.pdv-popup .ODD_ROW_PDV > td,
body.pdv-popup .EVEN_ROW_PDV > td,
body.pdv-popup tr.ODD_ROW_PDV td,
body.pdv-popup tr.EVEN_ROW_PDV td {
    padding: 8px 10px !important;
    vertical-align: middle !important;
}
body.pdv-popup .ODD_ROW_PDV td[style*="padding-left:2px"],
body.pdv-popup .EVEN_ROW_PDV td[style*="padding-left:2px"],
body.pdv-popup .GRID_HEADER_PDV th[style*="padding-left:2px"],
body.pdv-popup .GRID_HEADER_PDV td[style*="padding-left:2px"] {
    padding-left: 10px !important;
    padding-right: 10px !important;
}

/* 74.J — Totales / Gran total: card shadow sutil para destacar */
body.pdv-popup td.TOTALES,
body.pdv-popup .TOTALES {
    color: var(--stx-primary-700, #5147e2) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    line-height: 1.1 !important;
    padding: 8px 4px !important;
}
body.pdv-popup td.SUBTOTALES,
body.pdv-popup .SUBTOTALES {
    color: var(--text-secondary, #425466) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: -0.005em !important;
    padding: 4px 4px !important;
}

/* 74.K — Botón "+" / agregar detalle: tamaño normal en input row */
body.pdv-popup input[type="button"][value="+"],
body.pdv-popup input[type="submit"][value="+"],
body.pdv-popup #BOTON_AGRAGAR_DETALLES_TICKET,
body.pdv-popup #BOTON_AGRAGAR_DETALLES_FACTURA,
body.pdv-popup img[src*="bt_agregar_detalles"] {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    padding: 0 !important;
    background-image: none !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border: 1px solid var(--stx-primary-700, #5147e2) !important;
    border-radius: 8px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
    transition: background-color 120ms ease, transform 100ms ease, box-shadow 120ms ease !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
body.pdv-popup input[type="button"][value="+"]:hover,
body.pdv-popup input[type="submit"][value="+"]:hover,
body.pdv-popup #BOTON_AGRAGAR_DETALLES_TICKET:hover,
body.pdv-popup #BOTON_AGRAGAR_DETALLES_FACTURA:hover,
body.pdv-popup img[src*="bt_agregar_detalles"]:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(48,49,61,0.08)) !important;
}
body.pdv-popup input[type="button"][value="+"]:active,
body.pdv-popup input[type="submit"][value="+"]:active,
body.pdv-popup #BOTON_AGRAGAR_DETALLES_TICKET:active,
body.pdv-popup #BOTON_AGRAGAR_DETALLES_FACTURA:active,
body.pdv-popup img[src*="bt_agregar_detalles"]:active {
    transform: scale(0.96) !important;
}

/* 74.L — Lupa de búsqueda + input alineados a misma altura */
body.pdv-popup img[src*="bt_buscar_productos_on"],
body.pdv-popup img[src*="bt_buscar_productos_off"],
body.pdv-popup img[src*="bt_buscar.gif"],
body.pdv-popup img[src*="bt_buscar_off.gif"] {
    width: 18px !important;
    height: 18px !important;
    vertical-align: middle !important;
    cursor: pointer !important;
}
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_buscar_productos"],
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_buscar.gif"],
body.pdv-popup svg.stx-svg-icon[data-gif*="bt_buscar_off"] {
    width: 20px !important;
    height: 20px !important;
    vertical-align: middle !important;
    color: var(--stx-primary-600, #635bff) !important;
    margin-right: 4px !important;
}

/* 74.M — Spacer cells (img/iconos/comun/spacer.gif): que NUNCA generen alturas raras */
body.pdv-popup img[src*="iconos/comun/spacer.gif"] {
    display: inline-block !important;
    vertical-align: middle !important;
}

/* 74.N — Responsive: en pantallas ≤ 900px, action-bar wrap a 2 filas con buen gap */
@media (max-width: 900px) {
    body.pdv-popup .pdv-action-bar {
        flex-wrap: wrap !important;
        gap: 6px !important;
        min-height: 64px !important;
        height: auto !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 calc(25% - 6px) !important;
        min-width: 60px !important;
        height: 68px !important;
        min-height: 68px !important;
    }
}
@media (max-width: 768px) {
    body.pdv-popup td.LAYER_TOOLS,
    body.pdv-popup .LAYER_TOOLS {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        padding: 6px 4px !important;
        border-top: 1px solid var(--border-default, #e3e8ee) !important;
        background: var(--bg-base, #ffffff) !important;
    }
    body.pdv-popup .LAYER_TOOLS .pdv-side-icon {
        margin: 2px 4px !important;
    }
    body.pdv-popup .pdv-card {
        margin: 0 auto !important;
        border-radius: 8px !important;
    }
}

/* ============================================================
 * Fin SECCIÓN 74 — PDV V4 polish profesional.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 75 — Cuadro de búsqueda / FILTER_* + botón "+" topbar
 *
 * Las clases .FILTER_HEADER / .FILTER_TITLE / .FILTER_CONTENT /
 * .FILTER_LABEL / .FILTER_BUTTON emitidas por class_datagrid.php
 * para el cuadro "Búsqueda" arriba de los grids seguían con
 * estilo legacy. Aplica V4 sobre la CLASE — afecta a TODOS los
 * grids del sistema (catálogos, documentos, reportes, etc).
 *
 * El botón "+" del topbar para agregar pestaña se veía "despintado"
 * — opacidad baja. Reforzar contraste y hover.
 * ============================================================ */

/* 75.A — Wrapper del filtro (envuelve header + content + button) */
body.main-v2 .FILTER_HEADER {
    display: block !important;
    background: #ffffff !important;
    border: 1px solid var(--stx-neutral-200, #e3e8ee) !important;
    border-radius: 8px 8px 0 0 !important;
    padding: 12px 16px !important;
    cursor: pointer !important;
    transition: background 0.15s ease !important;
}
body.main-v2 .FILTER_HEADER:hover {
    background: var(--stx-neutral-50, #f6f9fc) !important;
}
body.main-v2 .FILTER_TITLE {
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--stx-text-primary, #0a2540) !important;
    margin: 0 !important;
    padding: 0 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    background: transparent !important;
    border: 0 !important;
}

/* 75.B — Contenido del filtro */
body.main-v2 .FILTER_CONTENT {
    background: #ffffff !important;
    border: 1px solid var(--stx-neutral-200, #e3e8ee) !important;
    border-top: 0 !important;
    border-radius: 0 !important;
    padding: 16px !important;
    overflow-x: auto !important;
}
body.main-v2 .FILTER_CONTENT table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
    background: transparent !important;
}
body.main-v2 .FILTER_CONTENT table tr {
    background: transparent !important;
}
body.main-v2 .FILTER_CONTENT table td {
    padding: 4px 12px 4px 0 !important;
    vertical-align: middle !important;
    background: transparent !important;
    border: 0 !important;
}
body.main-v2 .FILTER_CONTENT td:first-child {
    width: 220px !important;
    white-space: nowrap !important;
}

/* 75.C — Label + checkbox del filtro */
body.main-v2 .FILTER_LABEL {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    color: var(--stx-text-secondary, #425466) !important;
    cursor: pointer !important;
    margin-left: 4px !important;
}
body.main-v2 .FILTER_CONTENT input[type="checkbox"] {
    accent-color: var(--stx-primary-600, #635bff) !important;
    cursor: pointer !important;
    width: 14px !important;
    height: 14px !important;
}

/* 75.D — Inputs del filtro: misma estética V4 que .TEXTBOX */
body.main-v2 .FILTER_CONTENT input[type="text"],
body.main-v2 .FILTER_CONTENT input:not([type]),
body.main-v2 .FILTER_CONTENT select {
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 12.5px !important;
    color: var(--stx-text-primary, #0a2540) !important;
    background: #ffffff !important;
    border: 1px solid var(--stx-neutral-200, #e3e8ee) !important;
    border-radius: 6px !important;
    padding: 7px 10px !important;
    transition: all 0.15s ease !important;
    min-width: 200px !important;
    box-sizing: border-box !important;
}
body.main-v2 .FILTER_CONTENT input[type="text"]:focus,
body.main-v2 .FILTER_CONTENT input:not([type]):focus,
body.main-v2 .FILTER_CONTENT select:focus {
    outline: none !important;
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.12) !important;
}

/* 75.E — Botón Buscar y contenedor del button */
body.main-v2 .FILTER_BUTTON {
    background: #ffffff !important;
    border: 1px solid var(--stx-neutral-200, #e3e8ee) !important;
    border-top: 0 !important;
    border-radius: 0 0 8px 8px !important;
    padding: 12px 16px !important;
    text-align: right !important;
}

/* 75.F — Asegurar que el wrapper externo no tenga bordes legacy */
body.main-v2 .FILTER_HEADER + .FILTER_CONTENT + .FILTER_BUTTON,
body.main-v2 div:has(> .FILTER_HEADER) {
    background: transparent !important;
}

/* 75.G — Botón "+" del topbar (agregar pestaña): hacer visible */
body.topbar-v2 a[onclick*="open"][href*="javascript"],
body.topbar-v2 img[src*="adicionar.gif"],
body.topbar-v2 img[src*="nueva.gif"],
body.topbar-v2 td a img,
body.topbar-v2 td:last-child img,
body.topbar-v2 .stx-tab-plus,
body.topbar-v2 .stx-add-tab,
body.topbar-v2 [class*="tab-add"],
body.topbar-v2 [class*="tab_add"],
body.topbar-v2 [class*="add-tab"] {
    opacity: 1 !important;
    filter: none !important;
}
body.topbar-v2 .stx-tab-plus,
body.topbar-v2 .stx-add-tab,
body.topbar-v2 [class*="tab-add"],
body.topbar-v2 [class*="add-tab"] {
    background: var(--stx-primary-600, #635bff) !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(99, 91, 255, 0.25) !important;
    transition: all 0.15s ease !important;
}
body.topbar-v2 .stx-tab-plus:hover,
body.topbar-v2 .stx-add-tab:hover,
body.topbar-v2 [class*="tab-add"]:hover,
body.topbar-v2 [class*="add-tab"]:hover {
    background: var(--stx-primary-700, #4f46e5) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(99, 91, 255, 0.35) !important;
}

/* Fallback: cualquier <a> en el topbar que apunte a abrir nueva pestaña */
body.topbar-v2 td:last-child a,
body.topbar-v2 td.tab-add-cell a {
    color: var(--stx-primary-600, #635bff) !important;
    font-weight: 600 !important;
    opacity: 1 !important;
}

/* ============================================================
 * Fin SECCIÓN 75.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 75 — checkbox_select_array (Display::checkbox_select_array)
 * ------------------------------------------------------------
 * Reemplaza la antigua "barra azul cielo" con GIFs tool_mac_left/
 * tool_mac_middle/tool_mac_drop_down + popup TABLE-based por un
 * trigger limpio V4 (chevron Lucide) y un popup con buscador
 * integrado. La estructura DOM la emite class_display.php; aqui
 * solo styling. Aplica a Almacen, Sucursal y cualquier filtro
 * CHECKBOX_SELECT_ARRAY de reportes / forms.
 * ============================================================ */

/* 75.A — Trigger (botón cerrado, antes era TABLE+IMG tool_mac_*) */
body.main-v2 .stx-cbs-trigger,
.stx-cbs-trigger {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    height: 36px !important;
    padding: 0 12px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    background: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    box-shadow: 0 1px 2px rgba(48,49,61,0.04) !important;
    transition: border-color .15s ease, box-shadow .15s ease !important;
    user-select: none !important;
    box-sizing: border-box !important;
}
body.main-v2 .stx-cbs-trigger:hover,
.stx-cbs-trigger:hover {
    border-color: var(--stx-primary-400, #a5a0ff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.08) !important;
}
body.main-v2 .stx-cbs-trigger .stx-cbs-trigger-label,
.stx-cbs-trigger .stx-cbs-trigger-label {
    flex: 1 1 auto !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
body.main-v2 .stx-cbs-trigger .stx-cbs-trigger-chev,
.stx-cbs-trigger .stx-cbs-trigger-chev {
    display: inline-flex !important;
    align-items: center !important;
    color: var(--text-secondary, #425466) !important;
    flex: 0 0 auto !important;
}
.stx-cbs-trigger-anchor {
    display: inline-block !important;
    width: 0 !important;
    height: 0 !important;
}

/* 75.B — Popup contenedor */
body.main-v2 .stx-cbs-popup,
.stx-cbs-popup {
    box-sizing: border-box !important;
    background: #ffffff !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: 0 10px 30px rgba(48,49,61,0.12), 0 4px 8px rgba(48,49,61,0.06) !important;
    font-family: var(--font-sans, 'Inter', 'Segoe UI', sans-serif) !important;
    color: var(--text-primary, #0a2540) !important;
    z-index: 10000 !important;
    overflow: hidden !important;
}

/* 75.C — Caja de búsqueda */
body.main-v2 .stx-cbs-search-wrap,
.stx-cbs-search-wrap {
    position: relative !important;
    padding: 8px 10px !important;
    border-bottom: 1px solid var(--border-subtle, #f0f4f8) !important;
    background: var(--bg-base, #ffffff) !important;
}
body.main-v2 .stx-cbs-search-icon,
.stx-cbs-search-icon {
    position: absolute !important;
    left: 18px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--text-secondary, #425466) !important;
    pointer-events: none !important;
}
body.main-v2 .stx-cbs-search,
.stx-cbs-search {
    width: 100% !important;
    height: 30px !important;
    box-sizing: border-box !important;
    padding: 0 10px 0 28px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: var(--radius-sm, 6px) !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    font-family: inherit !important;
    font-size: 13px !important;
    color: var(--text-primary, #0a2540) !important;
    outline: none !important;
}
body.main-v2 .stx-cbs-search:focus,
.stx-cbs-search:focus {
    border-color: var(--stx-primary-500, #7b73ff) !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.12) !important;
}

/* 75.D — Header "Seleccionar todos" */
body.main-v2 .stx-cbs-header,
.stx-cbs-header {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-bottom: 1px solid var(--border-subtle, #f0f4f8) !important;
    cursor: pointer !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-secondary, #425466) !important;
    text-transform: uppercase !important;
    letter-spacing: .03em !important;
    user-select: none !important;
}
body.main-v2 .stx-cbs-header:hover,
.stx-cbs-header:hover {
    background: var(--bg-muted, #f3f6fa) !important;
}

/* 75.E — Lista de opciones */
body.main-v2 .stx-cbs-options,
.stx-cbs-options {
    max-height: 280px !important;
    overflow-y: auto !important;
    background: #ffffff !important;
    padding: 4px 0 !important;
}
body.main-v2 .stx-cbs-option,
.stx-cbs-option {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 7px 12px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    color: var(--text-primary, #0a2540) !important;
    background: #ffffff !important;
    user-select: none !important;
}
body.main-v2 .stx-cbs-option:hover,
.stx-cbs-option:hover {
    background: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
}
body.main-v2 .stx-cbs-option-label,
.stx-cbs-option-label {
    flex: 1 1 auto !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
/* 75.G — Hide opciones filtradas por el buscador. Necesita !important
   porque .stx-cbs-option { display: flex !important; } gana de otro modo
   sobre el inline style display:none que pondria el JS. */
body.main-v2 .stx-cbs-option.stx-cbs-hidden,
.stx-cbs-option.stx-cbs-hidden {
    display: none !important;
}
body.main-v2 .stx-cbs-check,
.stx-cbs-check {
    accent-color: var(--stx-primary-600, #635bff) !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    cursor: pointer !important;
    flex: 0 0 auto !important;
}

/* 75.F — Estado "sin resultados" */
body.main-v2 .stx-cbs-no-results,
.stx-cbs-no-results {
    padding: 16px 12px !important;
    text-align: center !important;
    font-size: 13px !important;
    color: var(--text-secondary, #425466) !important;
}

/* ============================================================
 * Fin SECCIÓN 75 — checkbox_select_array V4
 * ============================================================ */

/* ============================================================
 * SECCIÓN 76 — PDV V4 fixes 2da iteración
 *
 * Reportados por usuario tras SECCIÓN 74:
 *   1. Responsive: en ciertos tamaños no se ven todos los elementos
 *      → 74.N solo cubría ≤900 y ≤768; faltan rangos 768-900, 900-1100
 *   2. Iconos action-bar se amontonan en algunos anchos
 *      → 74.G usaba flex 1 1 0 min-width 70 → mal en popups < 500px
 *   3. Botón guardar IMEI/teléfono sin etiqueta visible
 *      → causa: el INPUT no tenía VALUE (dependía de bt_*.gif eliminado).
 *      → fix PHP en layer_campos_extra.php × 4 + layer_formas_pago.php
 *   4. Vista vieja del select forma de pago en pago del ticket
 *      → causa: Display::select_array(_keys) no agregaba CLASS al SELECT
 *      → fix PHP en class_display.php:121 y :140 (CLASS="TEXTBOX")
 *
 * Esta sección 76 sólo cubre lo CSS-only (responsive + iconos + refuerzo
 * button text + refuerzo SELECT FDP). Los puntos 3 y 4 se resuelven
 * principalmente en PHP; aquí va el cinturón de seguridad CSS.
 *
 *   76.A  Action-bar uniforme 7-col + labels 2 líneas sin truncamiento
 *   76.B  Responsive bulletproof (1200/1000/800/600 + sidebar 768-1100)
 *   76.C  Refuerzo INPUT BUTTON con VALUE: padding + line-height centrado
 *   76.D  Refuerzo SELECT FDP en LAYER_PAGO (defense-in-depth)
 * ============================================================ */

/* 76.A — Action-bar: 7 columnas iguales (sin amontonamiento), labels 2 líneas */
body.pdv-popup .pdv-action-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    height: auto !important;
    min-height: 78px !important;
    align-items: stretch !important;
    justify-content: space-between !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon,
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon.stx-icon-tile-host {
    flex: 1 1 calc(14.2857% - 6px) !important;   /* 100% / 7 - gap */
    min-width: 70px !important;
    max-width: none !important;
    padding: 8px 4px !important;
    gap: 6px !important;
    height: auto !important;
    min-height: 78px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}
body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .pdv-action-label {
    font-family: 'Inter', sans-serif !important;
    font-size: 11.5px !important;
    font-weight: 500 !important;
    color: var(--text-primary, #0a2540) !important;
    line-height: 1.2 !important;
    letter-spacing: -0.005em !important;
    text-align: center !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    word-break: break-word !important;
    max-width: 100% !important;
    min-height: 28px !important;
}

/* 76.B — Responsive bulletproof: cubre 600/800/1000/1200 */
@media (max-width: 1200px) {
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 calc(14.2857% - 6px) !important;
        min-width: 65px !important;
        height: auto !important;
        min-height: 74px !important;
    }
}
@media (max-width: 1000px) {
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 calc(25% - 6px) !important;       /* 4 por fila → 4+3 */
        min-width: 60px !important;
        height: auto !important;
        min-height: 70px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile {
        width: 32px !important;
        height: 32px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile .stx-svg-icon {
        width: 18px !important;
        height: 18px !important;
    }
}
@media (max-width: 800px) {
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 calc(33.333% - 6px) !important;   /* 3 por fila → 3+3+1 */
        min-width: 56px !important;
        height: auto !important;
        min-height: 66px !important;
        padding: 6px 3px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .pdv-action-label {
        font-size: 10.5px !important;
        min-height: 24px !important;
    }
}
@media (max-width: 600px) {
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon {
        flex: 1 1 calc(33.333% - 4px) !important;
        min-width: 50px !important;
        min-height: 62px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile {
        width: 28px !important;
        height: 28px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .stx-icon-tile .stx-svg-icon {
        width: 16px !important;
        height: 16px !important;
    }
    body.pdv-popup .pdv-action-bar .ICON.pdv-action-icon .pdv-action-label {
        font-size: 10px !important;
        line-height: 1.1 !important;
        min-height: 22px !important;
    }
}

/* Sidebar LAYER_TOOLS: pulir transición 768-1100 (rango no cubierto antes) */
@media (max-width: 1100px) and (min-width: 769px) {
    body.pdv-popup td.LAYER_TOOLS,
    body.pdv-popup .LAYER_TOOLS {
        width: 92px !important;
        max-width: 92px !important;
        min-width: 92px !important;
    }
    body.pdv-popup .LAYER_TOOLS .pdv-side-icon {
        width: 84px !important;
        max-width: 84px !important;
    }
    body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"],
    body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"],
    body.pdv-popup .LAYER_TOOLS img[src*="bt_cancelar_captura"],
    body.pdv-popup .LAYER_TOOLS img[src*="bt_guardar_documento"],
    body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
    body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"],
    body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_cancelar_captura"],
    body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_guardar_documento"] {
        width: 40px !important;
        height: 40px !important;
        padding: 8px !important;
    }
}

/* 76.C — INPUT BUTTON con VALUE: centrado vertical, padding consistente */
body.pdv-popup input[type="button"].BUTTON_CONTINUAR_CAMPOS_EXTRAS,
body.pdv-popup input[type="button"].BUTTON_CANCELAR_CAMPOS_EXTRAS,
body.pdv-popup input[type="button"].BUTTON_ADD_FDP,
body.pdv-popup input[type="button"].BUTTON_GUARDAR,
body.pdv-popup input[type="button"].BUTTON_GUARDAR_IMPRIMIR {
    width: auto !important;
    min-width: 160px !important;
    height: auto !important;
    min-height: 38px !important;
    padding: 8px 20px !important;
    line-height: 1.2 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em !important;
    color: #ffffff !important;
    text-align: center !important;
    text-shadow: none !important;
    text-transform: none !important;
    box-sizing: border-box !important;
    display: inline-block !important;
    vertical-align: middle !important;
    border: 1px solid var(--stx-primary-700, #5147e2) !important;
    border-radius: 8px !important;
    background-image: none !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    cursor: pointer !important;
}
/* Guardar (sin imprimir) en success verde */
body.pdv-popup input[type="button"].BUTTON_GUARDAR {
    background-color: var(--stx-success, #16b364) !important;
    border-color: var(--stx-success-dark, #027a48) !important;
}
body.pdv-popup input[type="button"].BUTTON_GUARDAR:hover {
    background-color: var(--stx-success-dark, #027a48) !important;
}
/* Cancelar campos extras en danger outline */
body.pdv-popup input[type="button"].BUTTON_CANCELAR_CAMPOS_EXTRAS {
    background-color: var(--bg-base, #ffffff) !important;
    color: var(--stx-danger, #f04438) !important;
    border-color: var(--stx-danger, #f04438) !important;
}
body.pdv-popup input[type="button"].BUTTON_CANCELAR_CAMPOS_EXTRAS:hover {
    background-color: var(--stx-danger-light, #fef3f2) !important;
}

/* 76.D — SELECT del FDP (forma de pago) en LAYER_PAGO: refuerzo
   por si la migración PHP de class_display.php no llegó al deploy. */
body.pdv-popup div[id^="LAYER_PAGO_TICKET_"] select,
body.pdv-popup div[id^="LAYER_PAGO_FACTURA_"] select,
body.pdv-popup div[id^="LAYER_FORMAS_DE_PAGO_"] select,
body.pdv-popup select[name*="FDP["][name*="][FDP]"] {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23697386' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 12px 12px !important;
    background-color: var(--bg-base, #ffffff) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12.5px !important;
    color: var(--text-primary, #0a2540) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    padding: 6px 28px 6px 10px !important;
    line-height: 1.35 !important;
    min-height: 30px !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    transition: border-color 120ms ease, box-shadow 120ms ease !important;
}
body.pdv-popup div[id^="LAYER_PAGO_TICKET_"] select:hover,
body.pdv-popup div[id^="LAYER_PAGO_FACTURA_"] select:hover,
body.pdv-popup div[id^="LAYER_FORMAS_DE_PAGO_"] select:hover,
body.pdv-popup select[name*="FDP["][name*="][FDP]"]:hover {
    border-color: var(--border-strong, #c1c9d2) !important;
}
body.pdv-popup div[id^="LAYER_PAGO_TICKET_"] select:focus,
body.pdv-popup div[id^="LAYER_PAGO_FACTURA_"] select:focus,
body.pdv-popup div[id^="LAYER_FORMAS_DE_PAGO_"] select:focus,
body.pdv-popup select[name*="FDP["][name*="][FDP]"]:focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}
/* Cards de totales en LAYER_PAGO (TOTAL A PAGAR / RECIBIDO / POR PAGAR / CAMBIO) */
body.pdv-popup div[id^="LAYER_PAGO_TICKET_"] table[bgcolor="#F6F7F9"],
body.pdv-popup div[id^="LAYER_PAGO_FACTURA_"] table[bgcolor="#F6F7F9"] {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
}

/* ============================================================
 * Fin SECCIÓN 76 — PDV V4 fixes 2da iteración.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 77 — Polish reportes V4 (display.php)
 * ------------------------------------------------------------
 * 77.A: Datepicker INPUT + icono calendario en línea (no abajo).
 *       .stx-rep-control es flex-direction:column por default
 *       (para apilar input + helper text). Cuando hay un
 *       <a class="mxw_cld"> adjunto al INPUT, los queremos
 *       lado-a-lado.
 * 77.B: Refuerzo opacidad/z-index del popup checkbox_select* —
 *       garantizar fondo blanco sólido sobre los labels del form
 *       y que el ancho de las opciones no rompa columnas.
 * ============================================================ */

/* 77.A — Datepicker inline (requiere :has, soportado en navegadores
   modernos; fallback: comportamiento actual con icono debajo) */
@supports selector(:has(*)) {
    body.main-v2 .stx-rep-control:has(> a.mxw_cld) {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
    }
    body.main-v2 .stx-rep-control:has(> a.mxw_cld) > input[type="text"] {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
    }
    body.main-v2 .stx-rep-control:has(> a.mxw_cld) > a.mxw_cld {
        flex: 0 0 auto !important;
        display: inline-flex !important;
        align-items: center !important;
        margin: 0 !important;
        vertical-align: middle !important;
    }
}

/* 77.B — Popup checkbox_select(_array): opacidad + ancho robustos.
   El popup vive position:absolute appended al FORM_GENERAL; si
   el background se ve transparente o las opciones rompen 2 líneas
   sobre los labels detrás, esta capa lo blinda. */
body.main-v2 .stx-cbs-popup,
.stx-cbs-popup {
    background-color: #ffffff !important;
    box-shadow: 0 10px 30px rgba(48,49,61,0.18), 0 4px 12px rgba(48,49,61,0.08) !important;
    z-index: 10050 !important;
}
body.main-v2 .stx-cbs-popup .stx-cbs-header,
.stx-cbs-popup .stx-cbs-header {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}
body.main-v2 .stx-cbs-popup .stx-cbs-options,
.stx-cbs-popup .stx-cbs-options {
    background-color: #ffffff !important;
    width: 100% !important;
    box-sizing: border-box !important;
}
body.main-v2 .stx-cbs-popup .stx-cbs-option,
.stx-cbs-popup .stx-cbs-option {
    background-color: #ffffff !important;
    box-sizing: border-box !important;
    width: 100% !important;
}
body.main-v2 .stx-cbs-popup .stx-cbs-option-label,
.stx-cbs-popup .stx-cbs-option-label {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0 !important;
}
body.main-v2 .stx-cbs-popup .stx-cbs-search-wrap,
.stx-cbs-popup .stx-cbs-search-wrap {
    background-color: var(--bg-base, #ffffff) !important;
}

/* ============================================================
 * Fin SECCIÓN 77 — Polish reportes V4
 * ============================================================ */

/* ============================================================
 * SECCIÓN 78 — Typeaheads V4 (DYN_CONTENT_*, DYNAMIC_LIST_*)
 * ------------------------------------------------------------
 * Polish del widget de autocompletado (Display::dynamic_content
 * y Display::js_dynamic_list) — usado por filtros "Cliente",
 * "Producto", "Categoria" en reportes y por dynamic_content en
 * documentos. Cubre 3 capas:
 *
 *  78.A — Popup de resultados (.DYNAMIC_LIST + filas):
 *         tarjeta V4 con sombra Stripe, rows con padding y
 *         hover púrpura. Aplica globalmente (consistente con
 *         el resto del ERP, sin cambio funcional).
 *
 *  78.B — "Chip" de valor seleccionado (LAYER_NAME dentro de
 *         dynamic_content): aparece cuando el usuario eligió
 *         una opción. Antes era una DIV cruda con `cerrar.gif`;
 *         ahora se ve como botón redondeado con X SVG. Se
 *         scope a `.stx-rep-control > div[id^="LAYER_"]` para
 *         no tocar layers de otras pantallas.
 *
 *  78.C — Refuerzo del input search dentro del REF_DYNAMIC_
 *         wrapper para que llene el ancho del control.
 *
 *  Importante: no se setea `display` con !important sobre el
 *  chip — lo controla el JS legacy via style inline (display
 *  none/'' al seleccionar/limpiar). CSS solo viste cuando es
 *  visible.
 * ============================================================ */

/* 78.A — Popup de resultados */
body.main-v2 .DYNAMIC_LIST {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(48,49,61,0.12), 0 4px 8px rgba(48,49,61,0.06) !important;
    background-color: #ffffff !important;
    overflow: hidden !important;
}
body.main-v2 .DYNAMIC_LIST_HEADER {
    background-image: none !important;
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-secondary, #425466) !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--border-subtle, #f0f4f8) !important;
}
body.main-v2 .DYNAMIC_LIST_OUT_A,
body.main-v2 .DYNAMIC_LIST_OUT_B {
    background-color: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
    cursor: pointer !important;
    border-bottom: 1px solid var(--border-subtle, #f0f4f8) !important;
}
body.main-v2 .DYNAMIC_LIST_OUT_A td,
body.main-v2 .DYNAMIC_LIST_OUT_B td,
body.main-v2 .DYNAMIC_LIST_OVER td {
    padding: 7px 12px !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    font-size: 13.5px !important;
}
body.main-v2 .DYNAMIC_LIST_OVER {
    background-color: var(--stx-primary-50, #efeefe) !important;
    color: var(--stx-primary-700, #5147e2) !important;
    cursor: pointer !important;
}

/* 78.B — Chip "valor seleccionado" del dynamic_content (scope: reportes) */
body.main-v2 .stx-rep-control > div[id^="LAYER_"] {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 10px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    background-color: var(--bg-subtle, #f6f9fc) !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: var(--font-sans, 'Inter', sans-serif) !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
}
body.main-v2 .stx-rep-control > div[id^="LAYER_"] > div[id^="CAPTION_"] {
    flex: 1 1 auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    float: none !important;
}
body.main-v2 .stx-rep-control > div[id^="LAYER_"] > a[id^="ICONO_"] {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 22px !important;
    height: 22px !important;
    color: var(--text-secondary, #425466) !important;
    text-decoration: none !important;
    cursor: pointer !important;
    border-radius: 4px !important;
}
body.main-v2 .stx-rep-control > div[id^="LAYER_"] > a[id^="ICONO_"] img {
    display: none !important;
}
body.main-v2 .stx-rep-control > div[id^="LAYER_"] > a[id^="ICONO_"]::before {
    content: "" !important;
    width: 14px !important;
    height: 14px !important;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23425466' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>") no-repeat center !important;
    background-size: 14px 14px !important;
}
body.main-v2 .stx-rep-control > div[id^="LAYER_"] > a[id^="ICONO_"]:hover {
    background-color: rgba(99,91,255,0.10) !important;
}

/* 78.C — Wrapper REF_DYNAMIC_ + input search */
body.main-v2 .stx-rep-control > div[id^="REF_DYNAMIC_"] {
    width: 100% !important;
}
body.main-v2 .stx-rep-control > div[id^="REF_DYNAMIC_"] > input[type="text"] {
    width: 100% !important;
    box-sizing: border-box !important;
}

/* ============================================================
 * Fin SECCIÓN 78 — Typeaheads V4
 * ============================================================ */

/* ============================================================
 * SECCIÓN 79 — PDV Sidebar: botones Pagar / Pasar a Caja /
 *              Cancelar / Guardar — look V4 Stripe DEFINITIVO
 *
 * Las SECCIONES 38/59/62/63/66/74 acumularon overrides que se
 * contradicen entre si (tile 36/44/52px, paleta primary/success,
 * padding 8/10, content-box/border-box, position static/sticky/
 * fixed). Resultado visual: el icono wallet del boton "Pagar" se
 * veia desproporcionado/sobrepuesto.
 *
 * Esta seccion 79 es el override TERMINAL que gana por orden de
 * cascada + specificity (`html body.pdv-popup ...`) sin tocar las
 * secciones anteriores (se conservan por historia).
 *
 *   - Wrapper `.pdv-side-icon` (la tarjeta blanca completa)
 *     limpio, columna, sin border ni shadow propio (el shadow
 *     lo aporta el tile).
 *   - Tile (svg/img bt_pagar_documento / bt_pasar_caja / cancelar /
 *     guardar) 48x48 redondeado, paleta semantica (success/danger/
 *     primary), icon SVG/IMG 22x22 centrado.
 *   - Label "Pagar"/"Pasar a caja"/"Cancelar"/"Guardar" Inter 12px
 *     peso 500, color text-primary.
 *   - Hover: lift -2px + shadow mas prominente + color saturado.
 *   - Active: scale(0.96).
 * ============================================================ */

/* 79.A — Wrapper de la tarjeta (DIV.pdv-side-icon) */
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 80px !important;
    max-width: 80px !important;
    margin: 8px auto !important;
    padding: 6px 4px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    cursor: pointer !important;
    text-align: center !important;
    transition: transform 120ms ease !important;
}
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:active {
    transform: scale(0.96) !important;
}

/* 79.B — Tile base (icono dentro del wrapper): 48x48 redondeado */
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon img,
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon svg.stx-svg-icon,
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon .stx-icon-tile {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 2px rgba(10,37,64,0.06), 0 1px 3px rgba(10,37,64,0.10) !important;
    cursor: pointer !important;
    transition: background 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease !important;
    flex-shrink: 0 !important;
    object-fit: contain !important;
}
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon .stx-icon-tile svg.stx-svg-icon {
    width: 24px !important;
    height: 24px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 24px !important;
    max-height: 24px !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    stroke-width: 2.25 !important;
    background: transparent !important;
}

/* 79.C — PAGAR (wallet, bt_pagar_documento) y PASAR A CAJA
   (shoppingCart, bt_pasar_caja): tinte success Stripe */
html body.pdv-popup .LAYER_TOOLS img[src*="bt_pagar_documento"],
html body.pdv-popup .LAYER_TOOLS img[src*="bt_pasar_caja"],
html body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
html body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"],
html body.pdv-popup .LAYER_TOOLS .stx-icon-tile[data-gif*="bt_pagar_documento"],
html body.pdv-popup .LAYER_TOOLS .stx-icon-tile[data-gif*="bt_pasar_caja"] {
    background: var(--stx-success, #16b364) !important;
    background-image: linear-gradient(180deg, #1bc66c 0%, #16b364 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(2,122,72,0.30) !important;
    box-shadow: 0 1px 2px rgba(22,179,100,0.18), 0 2px 6px rgba(22,179,100,0.12) !important;
}
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover img[src*="bt_pagar_documento"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover img[src*="bt_pasar_caja"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover svg.stx-svg-icon[data-gif*="bt_pasar_caja"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover .stx-icon-tile[data-gif*="bt_pagar_documento"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover .stx-icon-tile[data-gif*="bt_pasar_caja"] {
    background-image: linear-gradient(180deg, #16b364 0%, #0fa05a 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(22,179,100,0.30), 0 2px 4px rgba(22,179,100,0.18) !important;
}

/* 79.D — CANCELAR (xCircle, bt_cancelar_captura): tinte danger Stripe */
html body.pdv-popup .LAYER_TOOLS img[src*="bt_cancelar_captura"],
html body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_cancelar_captura"],
html body.pdv-popup .LAYER_TOOLS .stx-icon-tile[data-gif*="bt_cancelar_captura"] {
    background: var(--bg-base, #ffffff) !important;
    background-image: none !important;
    color: var(--stx-danger, #f04438) !important;
    border: 1px solid rgba(240,68,56,0.30) !important;
    box-shadow: 0 1px 2px rgba(240,68,56,0.10), 0 1px 3px rgba(10,37,64,0.06) !important;
}
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover img[src*="bt_cancelar_captura"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover svg.stx-svg-icon[data-gif*="bt_cancelar_captura"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover .stx-icon-tile[data-gif*="bt_cancelar_captura"] {
    background: var(--stx-danger, #f04438) !important;
    background-image: linear-gradient(180deg, #f04438 0%, #d92d20 100%) !important;
    color: #ffffff !important;
    border-color: rgba(180,35,24,0.40) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(240,68,56,0.28), 0 2px 4px rgba(240,68,56,0.16) !important;
}

/* 79.E — GUARDAR (check, bt_guardar_documento): tinte primary Stripe */
html body.pdv-popup .LAYER_TOOLS img[src*="bt_guardar_documento"],
html body.pdv-popup .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_guardar_documento"],
html body.pdv-popup .LAYER_TOOLS .stx-icon-tile[data-gif*="bt_guardar_documento"] {
    background: var(--bg-base, #ffffff) !important;
    background-image: none !important;
    color: var(--stx-primary-600, #635bff) !important;
    border: 1px solid rgba(99,91,255,0.30) !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.10), 0 1px 3px rgba(10,37,64,0.06) !important;
}
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover img[src*="bt_guardar_documento"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover svg.stx-svg-icon[data-gif*="bt_guardar_documento"],
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon:hover .stx-icon-tile[data-gif*="bt_guardar_documento"] {
    background-image: linear-gradient(180deg, #635bff 0%, #5147e2 100%) !important;
    color: #ffffff !important;
    border-color: rgba(81,71,226,0.40) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(99,91,255,0.28), 0 2px 4px rgba(99,91,255,0.16) !important;
}

/* 79.F — Label debajo del tile */
html body.pdv-popup .LAYER_TOOLS .pdv-side-icon .pdv-side-label,
html body.pdv-popup .LAYER_TOOLS .pdv-side-label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.25 !important;
    letter-spacing: -0.005em !important;
    color: var(--text-primary, #0a2540) !important;
    text-align: center !important;
    margin-top: 0 !important;
    padding: 0 !important;
}

/* 79.G — Tabla interna del LAYER_TOOLS: centrado, sin padding */
html body.pdv-popup .LAYER_TOOLS > table,
html body.pdv-popup .LAYER_TOOLS > table > tbody {
    width: 100% !important;
    border-collapse: collapse !important;
}
html body.pdv-popup .LAYER_TOOLS > table > tbody > tr > td,
html body.pdv-popup .LAYER_TOOLS > table > tr > td {
    text-align: center !important;
    padding: 4px 0 !important;
    vertical-align: middle !important;
    border: none !important;
    background: transparent !important;
}

/* ============================================================
 * Fin SECCIÓN 79 — PDV Sidebar V4 definitivo.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 80 — Modales legacy (Dialog.alert/error/notice): texto VISIBLE
 *
 * Bug: los modales del sistema (Prototype Window + Dialog.alert/error)
 * mostraban solo el header rojo con la X de cerrar; el cuerpo del
 * mensaje quedaba en BLANCO (texto invisible).
 *
 * Causa raíz (identificada por audit):
 *   - SECCION 60.B (linea ~6996) define `.alert_content { display:
 *     table-cell }` sin namespace, gana en contextos donde no aplica
 *     `body.main-v2`.
 *   - SECCION 66.B intenta forzar visibilidad pero no override
 *     `display: table-cell` -> el contenedor central de la tabla legacy
 *     colapsa porque los bordes (.alert_w/.alert_e) heredan width:0.
 *
 * Fix: override con max-specificity (`html body ...`) que:
 *   - Convierte el body del modal a `display: block` con padding/min-height
 *   - Garantiza color de texto contrastante (no blanco sobre blanco)
 *   - Estandariza colores semanticos del header (rojo error / verde
 *     notice / morado dialog/alert / amarillo warning)
 *   - Botones de accion con look V4 Stripe (purple primary, outline cancel)
 *   - X de cerrar bien posicionada y visible
 *   - Sombra y border-radius Stripe en el wrapper
 *
 * Cubre todos los tipos: alert / error / notice / warning / dialog /
 * bitacora — mismos selectores para cada uno con sufijo _content,
 * _message, _window, _title, _close, _buttons, _n/_nw/_ne (header),
 * _w/_e/_s/_sw/_se (bordes laterales).
 *
 * NO toca window.js (sin riesgo de romper los 200+ call sites). Si en
 * el futuro se quiere migrar a un componente V4 vanilla JS, ese es
 * trabajo de proximo sprint (la base CSS de aqui ya conduce al estilo
 * correcto).
 * ============================================================ */

/* 80.A — Contenedor central: SIEMPRE block, nunca table-cell */
html body .alert_content,
html body .error_content,
html body .notice_content,
html body .warning_content,
html body .dialog_content,
html body .bitacora_content {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 60px !important;
    padding: 20px 24px !important;
    background: #ffffff !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    overflow: auto !important;
    word-wrap: break-word;
    box-sizing: border-box;
}

/* 80.B — Mensaje interior: visible y legible */
html body .alert_message,
html body .error_message,
html body .notice_message,
html body .warning_message,
html body .dialog_message,
html body .bitacora_message {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: var(--text-primary, #0a2540) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    text-align: left !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: 24px !important;
    background: transparent !important;
    margin: 0 0 16px 0 !important;
}
/* Tipografía dentro del mensaje */
html body .alert_message *,
html body .error_message *,
html body .notice_message *,
html body .warning_message *,
html body .dialog_message *,
html body .bitacora_message *,
html body .alert_content *,
html body .error_content *,
html body .notice_content *,
html body .warning_content *,
html body .dialog_content * {
    color: var(--text-primary, #0a2540) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 80.C — Wrapper del modal: visible, no colapsado */
html body .alert_window,
html body .error_window,
html body .notice_window,
html body .warning_window,
html body .dialog_window,
html body .bitacora_window {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 380px !important;
    width: auto !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: 0 20px 40px rgba(10,37,64,0.18), 0 8px 16px rgba(10,37,64,0.08) !important;
    border-radius: 12px !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    overflow: hidden !important;
}

/* 80.D — Header del modal — color semantico segun tipo */
/* Alert / Dialog → morado primary */
html body .alert_n, html body .alert_nw, html body .alert_ne,
html body .dialog_n, html body .dialog_nw, html body .dialog_ne {
    background-color: var(--stx-primary-600, #635bff) !important;
    background-image: linear-gradient(180deg, #635bff 0%, #5147e2 100%) !important;
    color: #ffffff !important;
    height: 44px !important;
    min-height: 44px !important;
}
/* Error → rojo danger */
html body .error_n, html body .error_nw, html body .error_ne {
    background-color: var(--stx-danger, #f04438) !important;
    background-image: linear-gradient(180deg, #f04438 0%, #d92d20 100%) !important;
    color: #ffffff !important;
    height: 44px !important;
    min-height: 44px !important;
}
/* Notice → verde success */
html body .notice_n, html body .notice_nw, html body .notice_ne {
    background-color: var(--stx-success, #16b364) !important;
    background-image: linear-gradient(180deg, #16b364 0%, #0fa05a 100%) !important;
    color: #ffffff !important;
    height: 44px !important;
    min-height: 44px !important;
}
/* Warning → amarillo */
html body .warning_n, html body .warning_nw, html body .warning_ne {
    background-color: var(--stx-warning, #f79009) !important;
    background-image: linear-gradient(180deg, #f79009 0%, #dc6803 100%) !important;
    color: #ffffff !important;
    height: 44px !important;
    min-height: 44px !important;
}
/* Bitacora → gris oscuro */
html body .bitacora_n, html body .bitacora_nw, html body .bitacora_ne {
    background-color: var(--text-primary, #0a2540) !important;
    background-image: linear-gradient(180deg, #1a3556 0%, #0a2540 100%) !important;
    color: #ffffff !important;
    height: 44px !important;
    min-height: 44px !important;
}

/* 80.E — Titulo del header */
html body .alert_title, html body .error_title,
html body .notice_title, html body .warning_title,
html body .dialog_title, html body .bitacora_title {
    color: #ffffff !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 44px !important;
    text-align: left !important;
    padding: 0 16px !important;
    margin: 0 !important;
    text-shadow: none !important;
}
/* Contenido del titulo (FONT/A/B legacy) tambien blanco */
html body .alert_title *, html body .error_title *,
html body .notice_title *, html body .warning_title *,
html body .dialog_title *, html body .bitacora_title * {
    color: #ffffff !important;
}

/* 80.F — Boton X de cerrar */
html body .alert_close, html body .error_close,
html body .notice_close, html body .warning_close,
html body .dialog_close, html body .bitacora_close {
    width: 28px !important;
    height: 28px !important;
    background-image: none !important;
    background-color: rgba(255,255,255,0.10) !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    z-index: 10 !important;
    border: none !important;
    display: block !important;
    transition: background-color 120ms ease !important;
    position: relative !important;
}
html body .alert_close::after, html body .error_close::after,
html body .notice_close::after, html body .warning_close::after,
html body .dialog_close::after, html body .bitacora_close::after {
    content: "\00d7" !important;
    color: #ffffff !important;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    line-height: 28px !important;
    display: block !important;
    text-align: center !important;
    pointer-events: none !important;
}
html body .alert_close:hover, html body .error_close:hover,
html body .notice_close:hover, html body .warning_close:hover,
html body .dialog_close:hover, html body .bitacora_close:hover {
    background-color: rgba(255,255,255,0.22) !important;
}

/* 80.G — Botones de accion (OK / Cancelar / etc) */
html body .alert_buttons, html body .error_buttons,
html body .notice_buttons, html body .warning_buttons,
html body .dialog_buttons, html body .bitacora_buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 10px !important;
    padding: 14px 24px 18px 24px !important;
    margin: 0 !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}
html body .alert_buttons input[type="button"],
html body .alert_buttons input[type="submit"],
html body .alert_buttons button,
html body .error_buttons input[type="button"],
html body .error_buttons input[type="submit"],
html body .error_buttons button,
html body .notice_buttons input[type="button"],
html body .notice_buttons input[type="submit"],
html body .notice_buttons button,
html body .warning_buttons input[type="button"],
html body .warning_buttons input[type="submit"],
html body .warning_buttons button,
html body .dialog_buttons input[type="button"],
html body .dialog_buttons input[type="submit"],
html body .dialog_buttons button,
html body .bitacora_buttons input[type="button"],
html body .bitacora_buttons input[type="submit"],
html body .bitacora_buttons button {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 8px 18px !important;
    border-radius: 8px !important;
    border: 1px solid var(--stx-primary-700, #5147e2) !important;
    cursor: pointer !important;
    min-width: 88px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    background-color: var(--stx-primary-600, #635bff) !important;
    background-image: none !important;
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(99,91,255,0.18) !important;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 100ms ease !important;
    text-shadow: none !important;
}
html body .alert_buttons input[type="button"]:hover,
html body .alert_buttons button:hover,
html body .error_buttons input[type="button"]:hover,
html body .error_buttons button:hover,
html body .notice_buttons input[type="button"]:hover,
html body .notice_buttons button:hover,
html body .warning_buttons input[type="button"]:hover,
html body .warning_buttons button:hover,
html body .dialog_buttons input[type="button"]:hover,
html body .dialog_buttons button:hover,
html body .bitacora_buttons input[type="button"]:hover,
html body .bitacora_buttons button:hover {
    background-color: var(--stx-primary-700, #5147e2) !important;
    box-shadow: 0 2px 6px rgba(99,91,255,0.26) !important;
}
html body .alert_buttons input[type="button"]:active,
html body .alert_buttons button:active {
    transform: scale(0.97) !important;
}
/* Botones secundarios / cancel: outline */
html body .alert_buttons .cancel_button,
html body .alert_buttons input.cancel_button,
html body .alert_buttons input[value="Cancelar" i],
html body .alert_buttons input[value="Cancel" i],
html body .dialog_buttons .cancel_button,
html body .dialog_buttons input.cancel_button,
html body .dialog_buttons input[value="Cancelar" i],
html body .dialog_buttons input[value="Cancel" i] {
    background-color: var(--bg-base, #ffffff) !important;
    color: var(--text-primary, #0a2540) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    box-shadow: 0 1px 2px rgba(10,37,64,0.04) !important;
}
html body .alert_buttons .cancel_button:hover,
html body .alert_buttons input[value="Cancelar" i]:hover,
html body .dialog_buttons .cancel_button:hover,
html body .dialog_buttons input[value="Cancelar" i]:hover {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-color: var(--border-strong, #c1c9d2) !important;
}

/* 80.H — Bordes laterales legacy (.alert_w/_e/_s/_sw/_se): neutralizar */
html body .alert_w, html body .alert_e, html body .alert_sw, html body .alert_se, html body .alert_s,
html body .error_w, html body .error_e, html body .error_sw, html body .error_se, html body .error_s,
html body .notice_w, html body .notice_e, html body .notice_sw, html body .notice_se, html body .notice_s,
html body .warning_w, html body .warning_e, html body .warning_sw, html body .warning_se, html body .warning_s,
html body .dialog_w, html body .dialog_e, html body .dialog_sw, html body .dialog_se, html body .dialog_s,
html body .bitacora_w, html body .bitacora_e, html body .bitacora_sw, html body .bitacora_se, html body .bitacora_s {
    background-image: none !important;
    background-color: transparent !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    border: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
}

/* 80.I — Tabla layout del modal: no colapsar */
html body .alert_window > table,
html body .error_window > table,
html body .notice_window > table,
html body .warning_window > table,
html body .dialog_window > table,
html body .bitacora_window > table,
html body table.alert,
html body table.error,
html body table.notice,
html body table.warning,
html body table.dialog,
html body table.bitacora {
    width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    background: #ffffff !important;
}

/* 80.J — Overlay backdrop semi-transparente */
html body .overlay_alert, html body .overlay_error,
html body .overlay_notice, html body .overlay_warning,
html body .overlay_dialog, html body .overlay_bitacora {
    background-color: rgba(10,37,64,0.40) !important;
    opacity: 1 !important;
    -moz-opacity: 1 !important;
}

/* ============================================================
 * Fin SECCIÓN 80 — Modales legacy V4 (texto visible).
 * ============================================================ */

/* ============================================================
 * SECCIÓN 81 — Modales V4 nativos (.stx-modal-*)
 *
 * Estilos del nuevo helper `stx_modal_v4.js` que reemplaza la
 * implementación interna de Dialog.alert/error/notice/warning/info/
 * confirm por modales V4 Stripe usando <dialog> HTML5 + vanilla JS.
 *
 * Mantiene la API publica de Dialog.* intacta — los 200+ call sites
 * del ERP no se tocan. El bridge JS reemplaza Dialog.alert(...) por
 * un modal nuevo con estos estilos.
 *
 * Estructura HTML del modal:
 *   <dialog class="stx-modal stx-modal-{type}">
 *     <div class="stx-modal-card">
 *       <header class="stx-modal-header">
 *         <span class="stx-modal-icon">SVG</span>
 *         <h2 class="stx-modal-title">Titulo</h2>
 *         <button class="stx-modal-close">X</button>
 *       </header>
 *       <div class="stx-modal-body">Mensaje HTML</div>
 *       <footer class="stx-modal-footer">
 *         <button class="stx-modal-btn stx-modal-btn-secondary">Cancelar</button>
 *         <button class="stx-modal-btn stx-modal-btn-primary">Aceptar</button>
 *       </footer>
 *     </div>
 *   </dialog>
 *
 * Tipos:
 *   stx-modal-alert    primary purple
 *   stx-modal-confirm  primary purple (con cancelar)
 *   stx-modal-error    danger red
 *   stx-modal-notice   success green
 *   stx-modal-warning  warning amber
 *   stx-modal-bitacora gris oscuro
 *
 * Cuando el browser no soporta <dialog>, el JS usa <div> con clase
 * extra `stx-modal-fallback` -> regla CSS 81.K simula el overlay
 * con position: fixed + backdrop manual.
 * ============================================================ */

/* 81.A — Container raiz (siempre presente, sin estilos para no afectar) */
#stx-modal-root {
    position: relative;
    z-index: 100000;
}

/* 81.B — <dialog> outer + backdrop nativo */
dialog.stx-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    max-width: 100vw; max-height: 100vh;
    margin: 0; padding: 0;
    border: none;
    background: transparent;
    color: var(--text-primary, #0a2540);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001;
    overflow: hidden;
    animation: stx-modal-fade-in 160ms ease-out;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
dialog.stx-modal::backdrop {
    background-color: rgba(10, 37, 64, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: stx-modal-backdrop-fade-in 160ms ease-out;
}
dialog.stx-modal.stx-modal-closing {
    animation: stx-modal-fade-out 140ms ease-in forwards;
}
dialog.stx-modal.stx-modal-closing::backdrop {
    animation: stx-modal-backdrop-fade-out 140ms ease-in forwards;
}

/* 81.C — Card (la caja blanca) */
.stx-modal .stx-modal-card {
    background: var(--bg-base, #ffffff);
    border-radius: 14px;
    box-shadow:
        0 20px 50px rgba(10, 37, 64, 0.20),
        0 10px 20px rgba(10, 37, 64, 0.10);
    max-width: 520px;
    min-width: 360px;
    width: 92vw;
    max-height: 86vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-default, #e3e8ee);
    transform-origin: center;
}

/* 81.D — Header */
.stx-modal .stx-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px 14px 18px;
    border-bottom: 1px solid var(--border-default, #e3e8ee);
    background: var(--bg-base, #ffffff);
}
.stx-modal .stx-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
}
.stx-modal .stx-modal-icon svg {
    width: 22px; height: 22px;
    display: block;
}
.stx-modal .stx-modal-title {
    flex: 1 1 auto;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary, #0a2540);
    letter-spacing: -0.005em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stx-modal .stx-modal-close {
    flex-shrink: 0;
    width: 32px; height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-tertiary, #697386);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease;
}
.stx-modal .stx-modal-close:hover {
    background: var(--bg-subtle, #f6f9fc);
    color: var(--text-primary, #0a2540);
}

/* 81.E — Body */
.stx-modal .stx-modal-body {
    padding: 18px 22px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-primary, #0a2540);
    overflow-y: auto;
    flex: 1 1 auto;
    word-wrap: break-word;
    min-height: 24px;
}
.stx-modal .stx-modal-body * {
    color: inherit !important;
    font-family: inherit !important;
}
.stx-modal .stx-modal-body a {
    color: var(--stx-primary-600, #635bff) !important;
    text-decoration: underline;
}
.stx-modal .stx-modal-body ul,
.stx-modal .stx-modal-body ol {
    margin: 8px 0;
    padding-left: 20px;
}
.stx-modal .stx-modal-body code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
    font-size: 12.5px;
    background: var(--bg-subtle, #f6f9fc);
    padding: 1px 6px;
    border-radius: 4px;
}

/* 81.F — Footer (botones) */
.stx-modal .stx-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 14px 22px 18px 22px;
    background: var(--bg-subtle, #f6f9fc);
    border-top: 1px solid var(--border-default, #e3e8ee);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.stx-modal .stx-modal-btn {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.005em;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    min-width: 96px;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.25;
    text-decoration: none;
    box-sizing: border-box;
}
.stx-modal .stx-modal-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.30);
}
.stx-modal .stx-modal-btn:active {
    transform: scale(0.97);
}
.stx-modal .stx-modal-btn-primary {
    background: var(--stx-primary-600, #635bff);
    color: #ffffff;
    border-color: var(--stx-primary-700, #5147e2);
    box-shadow: 0 1px 2px rgba(99, 91, 255, 0.20);
}
.stx-modal .stx-modal-btn-primary:hover {
    background: var(--stx-primary-700, #5147e2);
    box-shadow: 0 2px 6px rgba(99, 91, 255, 0.28);
}
.stx-modal .stx-modal-btn-secondary {
    background: var(--bg-base, #ffffff);
    color: var(--text-primary, #0a2540);
    border-color: var(--border-default, #e3e8ee);
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.04);
}
.stx-modal .stx-modal-btn-secondary:hover {
    background: var(--bg-subtle, #f6f9fc);
    border-color: var(--border-strong, #c1c9d2);
}

/* 81.G — Tinte semantico del icono (header) por tipo */
.stx-modal.stx-modal-alert .stx-modal-icon,
.stx-modal.stx-modal-confirm .stx-modal-icon {
    background: rgba(99, 91, 255, 0.12);
    color: var(--stx-primary-700, #5147e2);
}
.stx-modal.stx-modal-error .stx-modal-icon {
    background: rgba(240, 68, 56, 0.12);
    color: var(--stx-danger, #f04438);
}
.stx-modal.stx-modal-notice .stx-modal-icon {
    background: rgba(22, 179, 100, 0.12);
    color: var(--stx-success, #16b364);
}
.stx-modal.stx-modal-warning .stx-modal-icon {
    background: rgba(247, 144, 9, 0.14);
    color: #b54708;
}
.stx-modal.stx-modal-bitacora .stx-modal-icon {
    background: rgba(10, 37, 64, 0.10);
    color: var(--text-primary, #0a2540);
}

/* 81.H — Boton primario tematico: error/notice/warning usan color semantico */
.stx-modal.stx-modal-error .stx-modal-btn-primary {
    background: var(--stx-danger, #f04438);
    border-color: #b42318;
    box-shadow: 0 1px 2px rgba(240, 68, 56, 0.22);
}
.stx-modal.stx-modal-error .stx-modal-btn-primary:hover {
    background: #d92d20;
    box-shadow: 0 2px 6px rgba(240, 68, 56, 0.30);
}
.stx-modal.stx-modal-error .stx-modal-btn:focus {
    box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.28);
}
.stx-modal.stx-modal-notice .stx-modal-btn-primary {
    background: var(--stx-success, #16b364);
    border-color: var(--stx-success-dark, #027a48);
    box-shadow: 0 1px 2px rgba(22, 179, 100, 0.22);
}
.stx-modal.stx-modal-notice .stx-modal-btn-primary:hover {
    background: var(--stx-success-dark, #027a48);
    box-shadow: 0 2px 6px rgba(22, 179, 100, 0.30);
}
.stx-modal.stx-modal-notice .stx-modal-btn:focus {
    box-shadow: 0 0 0 3px rgba(22, 179, 100, 0.28);
}
.stx-modal.stx-modal-warning .stx-modal-btn-primary {
    background: #b54708;
    border-color: #93370d;
    box-shadow: 0 1px 2px rgba(247, 144, 9, 0.22);
}
.stx-modal.stx-modal-warning .stx-modal-btn-primary:hover {
    background: #93370d;
    box-shadow: 0 2px 6px rgba(247, 144, 9, 0.30);
}

/* 81.I — Animaciones */
@keyframes stx-modal-fade-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes stx-modal-fade-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-4px) scale(0.97); }
}
@keyframes stx-modal-backdrop-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes stx-modal-backdrop-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    dialog.stx-modal,
    dialog.stx-modal::backdrop {
        animation: none !important;
    }
}

/* 81.J — Responsive */
@media (max-width: 600px) {
    .stx-modal .stx-modal-card {
        min-width: 0;
        width: 94vw;
        max-width: 94vw;
        border-radius: 12px;
    }
    .stx-modal .stx-modal-header {
        padding: 14px 14px 12px 14px;
    }
    .stx-modal .stx-modal-body {
        padding: 14px 16px;
    }
    .stx-modal .stx-modal-footer {
        padding: 12px 14px 16px 14px;
    }
    .stx-modal .stx-modal-btn {
        min-width: 0;
        flex: 1 1 auto;
    }
}

/* 81.K — Fallback para browsers sin <dialog> (usa <div>) */
div.stx-modal.stx-modal-fallback {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: rgba(10, 37, 64, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001;
    animation: stx-modal-fade-in 160ms ease-out;
}

/* ============================================================
 * Fin SECCIÓN 81 — Modales V4 nativos.
 * ============================================================ */


/* ============================================================
 * SECCIÓN 82 — PDV en pestaña: layout fluido (post popup→tab)
 * ------------------------------------------------------------
 * El PDV se abre ahora como pestaña interna del ERP (no popup
 * 870x660) — ver panel_cajas.php línea 75 (add_tab/tab_url).
 *
 * El body sigue llevando la clase `pdv-popup` (la mantenemos para
 * no romper las ~300 líneas de CSS V4 dependientes en SECCIONES
 * 53/63/64/65/66/74/76/79). Detectamos "modo pestaña" porque el
 * body también incluye `topbar-v2` (el host del ERP en topbar
 * V2). Los popups reales no tienen topbar.
 *
 * Esta sección:
 *   82.A — Anula los workarounds agresivos de SECCIÓN 66.A
 *          (position: fixed; right: 12px; padding-right body)
 *          que eran para popup angosto.
 *   82.B — `.pdv-card` fluida en viewport ≥1100px (max-width
 *          1280 / 1440 px).
 *   82.C — Override de WIDTH="706" / "98" / "825" en HTML legacy
 *          para layout flexible.
 *   82.D — Sidebar `.LAYER_TOOLS` sticky DENTRO del flujo del
 *          card (no fixed que se salga del card).
 *   82.E — Action bar inferior con tiles más generosas en
 *          pantallas grandes.
 *   82.F — Botones Pagar / Pasar a Caja respetan el flow, sin
 *          posicionamiento absoluto.
 *   82.G — Padding extra para LAYER_PAGO (totales).
 *
 * Sentinel: aplicamos sólo cuando body.topbar-v2 (pestaña) y
 * body.pdv-popup (módulo PDV). En popup real (sin topbar-v2)
 * conservamos comportamiento original.
 * ============================================================ */

/* 82.A — Anula workarounds popup-only de SECCIONES 66.A / 64 */
body.pdv-popup.topbar-v2 {
    /* La SECCIÓN 66.A daba `padding-right: 130px` al body para hacer
       hueco al sidebar fixed. En pestaña no aplica. */
    padding-right: 0 !important;
}

body.pdv-popup.topbar-v2 td.LAYER_TOOLS,
body.pdv-popup.topbar-v2 .LAYER_TOOLS {
    /* SECCIÓN 66.A: position: fixed; right: 12px; top: ...
       Lo neutralizamos para que el sidebar viva en el flow. */
    position: static !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
}

/* 82.B — pdv-card fluida en viewport amplio (pestaña) */
@media (min-width: 1100px) {
    body.pdv-popup.topbar-v2 .pdv-card {
        max-width: 1280px !important;
        width: auto !important;
        margin: 16px auto !important;
        padding: 20px 24px !important;
        box-sizing: border-box;
    }
    /* El shell <TABLE class="pdv-shell"> tiene height 100% que en
       pestaña empuja al footer. Le quitamos la altura forzada. */
    body.pdv-popup.topbar-v2 table.pdv-shell {
        height: auto !important;
    }
    body.pdv-popup.topbar-v2 table.pdv-shell > tbody > tr > td {
        text-align: center;
        padding: 0;
    }
}

@media (min-width: 1500px) {
    body.pdv-popup.topbar-v2 .pdv-card {
        max-width: 1440px !important;
        padding: 24px 28px !important;
    }
}

/* 82.C — Override WIDTH legacy en pestaña: pdv-card y tablas
   internas se vuelven fluidas. */
@media (min-width: 1100px) {
    body.pdv-popup.topbar-v2 .pdv-card > table[width="825"] {
        width: 100% !important;
    }
    /* Tabla principal del documento (layer_unticket / layer_unafactura
       / layer_devolucion) que define el grid spacer-7 / contenido-706
       / spacer-7 / LAYER_TOOLS-98 */
    body.pdv-popup.topbar-v2 .pdv-card table[width="100%"]
        > tbody > tr > td[width="706"],
    body.pdv-popup.topbar-v2 .pdv-card table[width="100%"]
        > tr > td[width="706"] {
        width: auto !important;
        min-width: 0 !important;
    }
    body.pdv-popup.topbar-v2 .pdv-card table[width="100%"]
        > tbody > tr > td[width="98"],
    body.pdv-popup.topbar-v2 .pdv-card table[width="100%"]
        > tr > td[width="98"] {
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
    }
    /* Los spacers de 7px no aportan en layout fluido — los
       achicamos a 4 para ganar espacio horizontal. */
    body.pdv-popup.topbar-v2 .pdv-card table[width="100%"]
        > tbody > tr > td[width="7"],
    body.pdv-popup.topbar-v2 .pdv-card table[width="100%"]
        > tr > td[width="7"] {
        width: 8px !important;
        min-width: 8px !important;
    }
}

/* 82.D — LAYER_TOOLS sidebar sticky DENTRO del card, no fixed */
@media (min-width: 1100px) {
    body.pdv-popup.topbar-v2 td.LAYER_TOOLS,
    body.pdv-popup.topbar-v2 .LAYER_TOOLS {
        position: -webkit-sticky !important;
        position: sticky !important;
        top: 80px !important;          /* respeta topbar V4 */
        right: auto !important;
        left: auto !important;
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
        flex: 0 0 120px !important;
        align-self: flex-start;
        background: transparent !important;
        box-shadow: none !important;
        padding: 8px 6px !important;
        z-index: 5;
        /* override SECCIÓN 64.G @media ≤1100px que la hacía sticky
           bottom — acá ya estamos ≥1100 y queremos sticky top */
    }

    body.pdv-popup.topbar-v2 .LAYER_TOOLS > table {
        width: 100% !important;
    }
    body.pdv-popup.topbar-v2 .LAYER_TOOLS .pdv-side-icon {
        margin: 6px auto !important;
    }
}

/* 82.E — Action bar inferior (Ticket/Factura/Devolución/Caja/
   Existencias/Precios/Otros) más generoso en viewport amplio. */
@media (min-width: 1100px) {
    body.pdv-popup.topbar-v2 .pdv-action-bar {
        gap: 14px !important;
        padding: 14px 18px !important;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    body.pdv-popup.topbar-v2 .pdv-action-bar .pdv-action-icon {
        min-width: 90px !important;
        height: 90px !important;
        padding: 10px 8px !important;
    }
    body.pdv-popup.topbar-v2 .pdv-action-bar .pdv-action-icon
        > img,
    body.pdv-popup.topbar-v2 .pdv-action-bar .pdv-action-icon
        > svg {
        width: 36px !important;
        height: 36px !important;
    }
    body.pdv-popup.topbar-v2 .pdv-action-bar .pdv-action-label {
        font-size: 13px !important;
        margin-top: 6px !important;
    }
    /* La celda padre que define width: 618px en STYLE inline */
    body.pdv-popup.topbar-v2 td.pdv-action-bar-cell[style*="width: 618px"] {
        width: auto !important;
        height: auto !important;
    }
}

/* 82.F — Botones Pagar / Pasar Caja respetan el flow (no fixed) */
body.pdv-popup.topbar-v2 .LAYER_TOOLS .pdv-side-icon,
body.pdv-popup.topbar-v2 .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pagar_documento"],
body.pdv-popup.topbar-v2 .LAYER_TOOLS svg.stx-svg-icon[data-gif*="bt_pasar_caja"],
body.pdv-popup.topbar-v2 .LAYER_TOOLS img[src*="bt_pagar_documento"],
body.pdv-popup.topbar-v2 .LAYER_TOOLS img[src*="bt_pasar_caja"] {
    position: static !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
}

/* 82.G — LAYER_PAGO (totales) más respirable en pestaña.
   La mecánica de aparecer/desaparecer (display:none/'') se conserva
   tal cual — solo agregamos padding/min-width cuando esté visible. */
@media (min-width: 1100px) {
    body.pdv-popup.topbar-v2 div[id^="LAYER_PAGO"]:not([style*="display: none"]):not([style*="display:none"]) {
        padding: 18px 20px !important;
        min-width: 320px;
    }
}

/* 82.H — En viewport pequeño (<900px) o popup real (sin topbar-v2),
   no aplicamos NADA de 82 — el CSS legacy SECCIONES 53/63/64/65/66/
   74/76/79 mantiene comportamiento popup angosto. */

/* TODO 82: si LAYER_PAGO se quisiera permanente como panel lateral
   derecho (en lugar de aparecer/desaparecer), habría que tocar
   pdv.js (js_mostrar_layer / js_ocultar_layer) además del CSS.
   Por ahora se mantiene mecánica original. */

/* ============================================================
 * Fin SECCIÓN 82 — PDV en pestaña: layout fluido.
 * ============================================================ */


/* ============================================================
 * SECCIÓN 83 — RESERVADA (anteriormente "PDV App Shell")
 * ------------------------------------------------------------
 * La SECCIÓN 83 original aplicaba `position: fixed` con `100vh`
 * sobre TRs legacy (<TR id="LAYER_TICKET_TABS"> + <TR
 * id="LAYER_BUTTONS">). El navegador no respeta bien `position:
 * fixed` sobre table-row, y la franja morada del header (::after
 * sobre el body) se solapaba con un TR LAYER_TABS de altura
 * libre — el banner morado salía "gigante deformado" (200-300px)
 * en lugar de los 60px planeados, el sidebar derecho quedaba
 * invisible o con altura cero, y los totales se cortaban.
 *
 * Esta sección quedó VACÍA y reemplazada por SECCIÓN 85 más
 * abajo, que reescribe el layout sin depender de `position:
 * fixed` sobre TRs.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 85 — PDV App Shell Full-screen v2 (en pestaña)
 * ------------------------------------------------------------
 * Reescritura de la SECCIÓN 83 original (que aplicaba
 * `position: fixed` sobre <TR>s legacy y resultaba en banner
 * morado deformado + sidebar derecho invisible). Esta versión:
 *
 *   - NO toca el HTML legacy.
 *   - Pone elementos posicionables (DIV / TD con display:block)
 *     en `position: fixed`, NO los <TR> nativos.
 *   - Pinta el header morado del shell con el TR LAYER_TICKET_TABS
 *     forzado a `display: block` (que SÍ acepta position:fixed),
 *     en lugar de un pseudo-elemento que duplique área.
 *   - Compacta el header a 40px (en 83 eran 60px con franja extra).
 *   - Sidebar derecho 300px ancla LAYER_TOOLS + totales.
 *   - Acción bar inferior 90px fixed bottom.
 *   - Sin sidebar izquierdo (el "60px ::before" de 83 no aportaba).
 *
 * Sentinel: `body.pdv-popup.pdv-tab`. La clase `pdv-tab` la
 * agrega el IIFE de pdv.php al detectar iframe. En popup real
 * (sin pdv-tab) las SECCIONES 53/64/66/74/76/82 mantienen
 * comportamiento popup angosto.
 *
 * Subsecciones:
 *   85.A — Tokens + body full-viewport.
 *   85.B — Shell wrappers (pdv-shell / pdv-card) full-bleed.
 *   85.C — Header fixed top (LAYER_TABS compacto, ~40px).
 *   85.D — Contenido central scrollable.
 *   85.E — Sidebar derecha fija (LAYER_TOOLS).
 *   85.F — Action bar fixed bottom (LAYER_BUTTONS).
 *   85.G — Ocultar logo PDV / divider row (no caben).
 *   85.H — Override widths legacy del card / table interior.
 *   85.I — Responsive: < 1100px desactiva shell (vuelve a 82).
 * ============================================================ */

/* 85.A — Tokens del shell + reset del body al viewport del iframe.
   En modo pestaña el iframe del PDV ocupa todo el viewport del
   <iframe name="MAIN">, por lo que `100vh` aquí dentro = altura
   del frame MAIN (≈ viewport - 50px del topbar V3). */
body.pdv-popup.pdv-tab {
    --pdv-header-h: 40px;
    --pdv-actbar-h: 90px;
    --pdv-sidebar-r: 300px;
    --pdv-shell-bg: var(--bg-base, #ffffff);
    --pdv-shell-border: var(--border-default, #e3e8ee);

    /* Anula padding/scroll del body legacy + SECCIONES 66.A / 83.A */
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    background: var(--pdv-shell-bg) !important;
}
body.pdv-popup.pdv-tab #FORM_GENERAL {
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important;
    overflow: hidden !important;
}

/* 85.B — Shell wrappers full-bleed.
   El <TABLE class="pdv-shell"> y el <DIV class="pdv-card"> NO
   necesitan ancho/altura fija — los hijos clave (header, tools,
   actions) van fixed. Limpiamos cualquier estilo de "tarjeta
   centrada" heredado de SECCIÓN 82. */
body.pdv-popup.pdv-tab table.pdv-shell,
body.pdv-popup.pdv-tab table.pdv-shell > tbody > tr,
body.pdv-popup.pdv-tab table.pdv-shell > tbody > tr > td {
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
}
body.pdv-popup.pdv-tab .pdv-card {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--pdv-shell-bg) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}
/* Tablas interiores legacy (width=825 / width=100%) full-fluid */
body.pdv-popup.pdv-tab .pdv-card > table[width="825"],
body.pdv-popup.pdv-tab .pdv-card > table {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
}

/* 85.C — HEADER fixed top (banner morado compacto con tabs).
   El <TR id="LAYER_TICKET_TABS"> es un table-row legacy. Para
   poder posicionarlo fixed lo forzamos a `display: block`.
   En el placeholder (LAYER_BLANK) hay otro `<DIV class="LAYER_TABS">`
   suelto en otro TR — también lo controlamos para que NO crezca. */
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: var(--pdv-sidebar-r) !important;
    width: auto !important;
    height: var(--pdv-header-h) !important;
    min-height: var(--pdv-header-h) !important;
    max-height: var(--pdv-header-h) !important;
    margin: 0 !important;
    padding: 0 !important;
    background: linear-gradient(180deg,
        var(--stx-primary-600, #635bff),
        var(--stx-primary-700, #5147e2)) !important;
    z-index: 100;
    overflow: hidden !important;
    box-shadow: 0 1px 0 rgba(255,255,255,0.08),
                0 2px 8px rgba(99,91,255,0.18);
}
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS > td {
    display: block !important;
    width: 100% !important;
    height: var(--pdv-header-h) !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
}
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS .LAYER_TABS {
    background: transparent !important;
    height: var(--pdv-header-h) !important;
    min-height: var(--pdv-header-h) !important;
    max-height: var(--pdv-header-h) !important;
    border-radius: 0 !important;
    padding: 0 12px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS .LAYER_TABS > table {
    width: 100% !important;
    height: var(--pdv-header-h) !important;
    margin: 0 !important;
}
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS .OFF_MIDDLE_PDV,
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS .ON_MIDDLE_PDV {
    height: calc(var(--pdv-header-h) - 6px) !important;
    line-height: calc(var(--pdv-header-h) - 6px) !important;
    padding: 0 18px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
}
/* Tope: si el header tiene STYLE inline HEIGHT="28" en la <TABLE>
   interna (layer_ticket.php línea 43), lo neutralizamos. */
body.pdv-popup.pdv-tab #LAYER_TICKET_TABS table[height="28"] {
    height: var(--pdv-header-h) !important;
}
/* El LAYER_TABS placeholder (sin tickets, LAYER_BLANK) NO debe
   pintar otra franja morada — el banner real ya está en #LAYER_TICKET_TABS.
   Lo ocultamos para que no se acumule alto. */
body.pdv-popup.pdv-tab #LAYER_BLANK .LAYER_TABS {
    display: none !important;
}

/* 85.D — Contenido central scrollable.
   El cuerpo del documento se ubica entre el header y la action bar,
   con el sidebar derecho ocupando los últimos 300px. Como los
   anchors (header / actbar / sidebar) son fixed, el contenido fluye
   normal pero le damos margins iguales a los espacios reservados.

   El "card" pasa a ser un wrapper de pantalla completa con margenes
   reservados. Su tabla interior (que tiene TR de errores top + TR
   de show_section LAYER_MAIN + TR divider + TR LAYER_BUTTONS) ya
   apilará en flow normal — y los TRs que son fixed (LAYER_BUTTONS)
   no estorban porque salen del flow. */
body.pdv-popup.pdv-tab .pdv-card > table {
    margin-top: var(--pdv-header-h) !important;
    margin-bottom: var(--pdv-actbar-h) !important;
    margin-right: var(--pdv-sidebar-r) !important;
    margin-left: 0 !important;
    width: calc(100vw - var(--pdv-sidebar-r)) !important;
    background: var(--pdv-shell-bg) !important;
    min-height: calc(100vh - var(--pdv-header-h) - var(--pdv-actbar-h));
}
/* El TR de errores (top_errors) y el TR del LAYER_MAIN deben ocupar
   ancho completo del card sin sidebar. */
body.pdv-popup.pdv-tab .pdv-card > table > tbody > tr > td,
body.pdv-popup.pdv-tab .pdv-card > table > tr > td {
    background: var(--pdv-shell-bg) !important;
}
/* LAYER_DOCUMENTO_MAIN (en cada unticket / unafactura): contiene
   el grid de productos. Le damos max-height calculada para que
   SOLO ese div scrollee — no toda la página. */
body.pdv-popup.pdv-tab .LAYER_DOCUMENTO_MAIN {
    height: auto !important;
    max-height: calc(100vh - var(--pdv-header-h) - var(--pdv-actbar-h) - 40px) !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    background: var(--pdv-shell-bg) !important;
    border: 0 !important;
    border-radius: 0 !important;
}
/* Los TDs internos del unticket (width=706 contenido / width=98 TOOLS)
   fluyen normal — pero el TD de TOOLS lo sacamos del flow porque lo
   anclamos al sidebar derecho fijo (85.E). */
body.pdv-popup.pdv-tab .pdv-card table[width="100%"] > tbody > tr > td[width="706"],
body.pdv-popup.pdv-tab .pdv-card table[width="100%"] > tr > td[width="706"] {
    width: auto !important;
    min-width: 0 !important;
    padding: 0 8px !important;
}
body.pdv-popup.pdv-tab .pdv-card table[width="100%"] > tbody > tr > td[width="7"],
body.pdv-popup.pdv-tab .pdv-card table[width="100%"] > tr > td[width="7"] {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
}
/* LAYER_BLANK (empty state cuando no hay tickets): le damos un fondo
   limpio sin border-bottom legacy. */
body.pdv-popup.pdv-tab #LAYER_BLANK > table {
    width: 100% !important;
    height: calc(100vh - var(--pdv-header-h) - var(--pdv-actbar-h)) !important;
    background: var(--pdv-shell-bg) !important;
}
body.pdv-popup.pdv-tab #LAYER_BLANK > table div[style*="background-color"] {
    background-color: transparent !important;
    border: 0 !important;
    height: 100% !important;
}

/* 85.E — SIDEBAR DERECHA fija (LAYER_TOOLS = Pagar/Cancelar/Guardar).
   El <TD class="LAYER_TOOLS"> es una table-cell legacy. Forzamos
   `display: block` para poder posicionarlo fixed. */
body.pdv-popup.pdv-tab td.LAYER_TOOLS,
body.pdv-popup.pdv-tab .LAYER_TOOLS {
    display: block !important;
    position: fixed !important;
    top: var(--pdv-header-h) !important;
    right: 0 !important;
    bottom: var(--pdv-actbar-h) !important;
    left: auto !important;
    width: var(--pdv-sidebar-r) !important;
    min-width: var(--pdv-sidebar-r) !important;
    max-width: var(--pdv-sidebar-r) !important;
    height: auto !important;
    max-height: none !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-left: 1px solid var(--pdv-shell-border) !important;
    border-radius: 0 !important;
    box-shadow: -1px 0 2px rgba(48,49,61,0.04);
    padding: 20px 16px !important;
    z-index: 90;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    flex: none !important;
    transform: none !important;
    /* Notas: el `top` se setea arriba al inicio del bloque, override
       de SECCIÓN 82.D que la hacía sticky con top:80px. */
}
/* El TR padre del TD.LAYER_TOOLS: como el TD pasa a fixed, queda
   un "hueco" en el row. No nos importa — el row sigue el flow del
   card central pero ya sin ese TD ancho. */
body.pdv-popup.pdv-tab .pdv-card table[width="100%"] > tbody > tr > td[width="98"],
body.pdv-popup.pdv-tab .pdv-card table[width="100%"] > tr > td[width="98"] {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
}
/* Tabla interna del sidebar: ocupa todo el ancho del sidebar */
body.pdv-popup.pdv-tab .LAYER_TOOLS > table {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: separate !important;
}
body.pdv-popup.pdv-tab .LAYER_TOOLS .pdv-side-icon {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 64px !important;
    margin: 8px 0 !important;
    padding: 12px 10px !important;
    border-radius: 10px !important;
    border: 1px solid var(--pdv-shell-border) !important;
    background: var(--bg-base, #ffffff) !important;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
body.pdv-popup.pdv-tab .LAYER_TOOLS .pdv-side-icon:hover {
    border-color: var(--stx-primary-600, #635bff) !important;
    background: var(--bg-subtle, #f6f9fc) !important;
}
body.pdv-popup.pdv-tab .LAYER_TOOLS .pdv-side-icon:active {
    transform: scale(0.98);
}
body.pdv-popup.pdv-tab .LAYER_TOOLS .pdv-side-icon > img,
body.pdv-popup.pdv-tab .LAYER_TOOLS .pdv-side-icon > svg {
    width: 28px !important;
    height: 28px !important;
    margin-bottom: 6px !important;
}
body.pdv-popup.pdv-tab .LAYER_TOOLS .pdv-side-label {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-primary, #0a2540) !important;
    text-align: center;
}

/* 85.F — ACTION BAR fixed bottom (Ticket/Factura/Devol/Caja/...).
   El <TR id="LAYER_BUTTONS"> es un table-row. Forzamos `display:block`
   para que acepte position:fixed. */
body.pdv-popup.pdv-tab #LAYER_BUTTONS {
    display: block !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--pdv-actbar-h) !important;
    min-height: var(--pdv-actbar-h) !important;
    max-height: var(--pdv-actbar-h) !important;
    margin: 0 !important;
    padding: 0 16px !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-top: 1px solid var(--pdv-shell-border) !important;
    box-shadow: 0 -2px 6px rgba(48,49,61,0.05);
    z-index: 100;
    box-sizing: border-box !important;
}
/* Los TDs hijos también necesitan display:block para flow flex */
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td {
    display: inline-flex !important;
    align-items: center !important;
    vertical-align: middle;
    height: var(--pdv-actbar-h) !important;
    width: auto !important;
    padding: 0 !important;
    border: 0 !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-action-bar-cell {
    width: calc(100% - 200px) !important;
    height: var(--pdv-actbar-h) !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-action-bar-gap {
    width: 8px !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    width: 100% !important;
    height: calc(var(--pdv-actbar-h) - 12px) !important;
    padding: 6px 0 !important;
    margin: 0 !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar .pdv-action-icon {
    flex: 1 1 0 !important;
    min-width: 88px !important;
    max-width: 130px !important;
    height: calc(var(--pdv-actbar-h) - 16px) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 6px !important;
    border-radius: 10px !important;
    border: 1px solid var(--pdv-shell-border) !important;
    background: var(--bg-base, #ffffff) !important;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar .pdv-action-icon:hover {
    border-color: var(--stx-primary-600, #635bff) !important;
    background: var(--bg-subtle, #f6f9fc) !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar .pdv-action-icon:active {
    transform: scale(0.98);
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar .pdv-action-icon > img,
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar .pdv-action-icon > svg {
    width: 30px !important;
    height: 30px !important;
    margin-bottom: 4px !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS .pdv-action-bar .pdv-action-label {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-primary, #0a2540) !important;
    text-align: center;
    margin-top: 2px !important;
}
/* STYLE inline en TDs legacy (width: 618px / 200px) — neutralizar */
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td[style*="width: 618px"],
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td[style*="width: 200px"] {
    width: auto !important;
    max-width: none !important;
}

/* 85.G — Logo del PDV (TD.pdv-logo-cell con IMG): a la derecha del
   action bar pero compacto. Si no cabe, ocultar. */
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-logo-cell {
    width: 180px !important;
    height: 64px !important;
    padding: 0 0 0 8px !important;
    align-self: center !important;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-logo-cell > div {
    width: 180px !important;
    height: 56px !important;
    overflow: hidden;
}
body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-logo-cell img {
    max-width: 100% !important;
    max-height: 56px !important;
    object-fit: contain;
}
/* Si viewport angosto (< 1300px) ocultamos el logo para que las 7
   tiles tengan espacio. */
@media (max-width: 1299px) {
    body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-logo-cell,
    body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-action-bar-gap {
        display: none !important;
    }
    body.pdv-popup.pdv-tab #LAYER_BUTTONS > td.pdv-action-bar-cell {
        width: 100% !important;
    }
}
/* Divider row (.pdv-divider-row): DESHABILITADA (iter 8 del loop POS).
   Misma lección que SECCIÓN 89: el `display:none` colapsa también el
   header púrpura del PDV porque la TR padre contiene LAYER_TICKET_TABS.
   El overflow latente que esto buscaba evitar es invisible al usuario
   (body:overflow:hidden lo oculta). NO REACTIVAR sin analizar el HTML
   anidado del TABLE legacy. */
/*
body.pdv-popup.pdv-tab .pdv-divider-row,
body.pdv-popup.pdv-tab .pdv-divider-row td {
    display: none !important;
}
*/

/* 85.H — Override widths legacy de la tabla interior del card y
   la tabla del cuerpo del unticket (width=825 / width=618 / etc).
   Ya no hay anchos fijos: todo fluye. */
body.pdv-popup.pdv-tab .pdv-card td[width],
body.pdv-popup.pdv-tab .pdv-card table[width="825"] {
    /* `auto` fuerza al navegador a recalcular según contenido */
    width: auto !important;
    max-width: none !important;
}

/* Barra de búsqueda (lupa + input + Descto + checkbox %) vive en
   layer_agregar_detalles.php dentro de LAYER_TICKET_X_AGREGAR. El
   contenedor padre es un DIV con altura 100px legacy. En modo
   shell la queremos un poco más respirable, pero NO la fijamos
   (vive dentro del flow del LAYER_DOCUMENTO_MAIN). */
body.pdv-popup.pdv-tab [id^="LAYER_TICKET_"][id$="_AGREGAR"],
body.pdv-popup.pdv-tab [id^="LAYER_FACTURA_"][id$="_AGREGAR"] {
    height: auto !important;
    min-height: 60px !important;
    background: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--pdv-shell-border) !important;
    border-radius: 8px !important;
    padding: 6px 10px !important;
    box-sizing: border-box !important;
}
body.pdv-popup.pdv-tab [id^="LAYER_TICKET_"][id$="_TOTALES"],
body.pdv-popup.pdv-tab [id^="LAYER_FACTURA_"][id$="_TOTALES"] {
    height: auto !important;
    min-height: 60px !important;
    background: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--pdv-shell-border) !important;
    border-radius: 8px !important;
    padding: 6px 10px !important;
    box-sizing: border-box !important;
}

/* 85.I — Responsive: < 1100px (laptops chicas / tablets) desactiva
   el shell y deja que SECCIÓN 82 maneje el layout fluido. */
@media (max-width: 1099px) {
    body.pdv-popup.pdv-tab {
        --pdv-header-h: 40px;
        --pdv-actbar-h: 80px;
        --pdv-sidebar-r: 0px;
        height: auto !important;
        max-height: none !important;
        overflow: auto !important;
        padding: 0 !important;
    }
    body.pdv-popup.pdv-tab #LAYER_TICKET_TABS,
    body.pdv-popup.pdv-tab #LAYER_BUTTONS,
    body.pdv-popup.pdv-tab td.LAYER_TOOLS,
    body.pdv-popup.pdv-tab .LAYER_TOOLS {
        display: table-row !important;
        position: static !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        height: auto !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        box-shadow: none !important;
    }
    body.pdv-popup.pdv-tab td.LAYER_TOOLS,
    body.pdv-popup.pdv-tab .LAYER_TOOLS {
        display: table-cell !important;
    }
    body.pdv-popup.pdv-tab .pdv-card > table {
        margin: 0 !important;
        width: 100% !important;
    }
    body.pdv-popup.pdv-tab .LAYER_DOCUMENTO_MAIN {
        max-height: none !important;
        height: auto !important;
    }
}

/* ============================================================
 * Fin SECCIÓN 85 — PDV App Shell v2.
 * ============================================================ */

/* ============================================================
 * SECCION 84 — Skeleton screen V4 (overlay "Cargando..." iframe).
 * ------------------------------------------------------------
 *  Reemplaza visualmente el overlay legacy que main.php crea
 *  mientras un iframe esta cargando. El JS de main.php sigue
 *  agregando los mismos divs (CARGANDO_IFRAME_X / CARGANDO_IMAGEN_
 *  IFRAME_X) y eliminandolos en set_tab_title — aqui SOLO
 *  cambiamos su apariencia para que sea un skeleton calmado en
 *  vez del fondo blanco al 60% con texto "Cargando" + GIF.
 *
 *  Estrategia:
 *    - La capa CARGANDO (overlay base) pasa a fondo neutro
 *      slate (no blanco opaco) para no flashear al usuario.
 *    - La capa CARGANDO_IMAGEN (donde antes vivia el texto + GIF)
 *      pasa a ocupar 100% / 100% y dibujamos dentro un esqueleto
 *      vacio que simula la estructura tipica del PDV/modulo:
 *      header morado + 4 barras (toolbar) + grid 12 filas.
 *    - El texto "Cargando" original queda oculto por especificidad;
 *      el <img> circle_loader.gif tambien (visibility hidden mas
 *      tarde para no romper layout).
 *    - El shimmer es un gradiente animado horizontalmente sobre
 *      cada barra del skeleton (clase .stx-skeleton-bar).
 *    - Cero JS necesario — todo CSS sobre los divs que main.php
 *      ya inyecta. Cuando desbloquear() los quita del DOM, el
 *      skeleton desaparece automaticamente.
 * ============================================================ */

/* 84.A — Animacion shimmer (sweep gradiente) */
@keyframes stx-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Helper visual reutilizable para "barras" del esqueleto */
.stx-skeleton-bar {
    background: linear-gradient(90deg,
        #eef1f6 0%,
        #f8fafc 50%,
        #eef1f6 100%);
    background-size: 200% 100%;
    animation: stx-shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}

/* 84.B — Capa base (CARGANDO): fondo subtle, no opaco-blanco */
.CARGANDO {
    background-color: #f6f9fc !important; /* var(--bg-subtle) Stripe */
    /* legacy MSIE filter alpha — anular */
    filter: none !important;
    -moz-opacity: 1 !important;
    opacity: 1 !important;
    /* asegurar cobertura completa del iframe */
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* 84.C — Capa "imagen" (donde vivia texto+GIF) -> contenedor skeleton.
 *
 *  El legacy le pone top:40px y left:(screen.width/2)-200 al elemento.
 *  Anulamos esos inline styles con !important y la convertimos en un
 *  contenedor full-bleed. El <FONT>Cargando</FONT> y el <img> hijos
 *  quedan ocultos por reglas mas abajo.
 */
.CARGANDO_IMAGEN {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box;
    padding: 0;
    background: transparent;
    overflow: hidden;
    z-index: 102;
    /* ocultar el contenido legacy (FONT "Cargando" + IMG GIF) sin
     * borrarlos: el JS de desbloquear() hace removeChild por ID, no
     * tolera que les borremos display. */
    font-size: 0;
    line-height: 0;
    color: transparent;
}
.CARGANDO_IMAGEN > * {
    visibility: hidden !important;
}

/* 84.D — Header morado falso (banda superior simulando topbar PDV) */
.CARGANDO_IMAGEN::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background: linear-gradient(90deg, #635bff 0%, #7c75ff 100%);
    box-shadow: 0 1px 3px rgba(60, 66, 87, 0.08);
    z-index: 1;
}

/* 84.E — Cuerpo del skeleton (toolbar + grid) — un solo ::after con
 *  multiples background-image apilados que forman:
 *    - 3 chips de toolbar (parte alta debajo del header morado)
 *    - 12 filas de "grid" (parte central/inferior)
 *  Cada "barra" se dibuja como background-image #f0f2f5 -> el
 *  shimmer real (animado) se aplica en 84.F via background-blend o,
 *  mas simple, via repeated rectangular backgrounds animados.
 *
 *  Para evitar complejidad de superposicion, hacemos el shimmer
 *  global con un overlay extra (84.F) en vez de animar 15 elementos.
 */
.CARGANDO_IMAGEN::after {
    content: "";
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    background-color: #f6f9fc;
    /* Filas del "grid" + 3 chips toolbar via gradients horizontales.
     * Cada linear-gradient pinta una franja gris #e7ecf3 sobre fondo
     * transparente; el background-position decide donde aparece. */
    background-image:
        /* 3 chips toolbar (parte alta del cuerpo) */
        linear-gradient(90deg, #e7ecf3 0, #e7ecf3 160px, transparent 160px),
        linear-gradient(90deg, transparent 180px, #e7ecf3 180px, #e7ecf3 340px, transparent 340px),
        linear-gradient(90deg, transparent 360px, #e7ecf3 360px, #e7ecf3 460px, transparent 460px),
        /* 12 filas full-width del grid */
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px),
        linear-gradient(180deg, #e7ecf3 0, #e7ecf3 14px, transparent 14px);
    background-repeat: no-repeat;
    background-size:
        /* chips: 1px alto interno, posicionados verticalmente */
        160px 30px,
        160px 30px,
        100px 30px,
        /* filas grid */
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px,
        calc(100% - 48px) 14px;
    background-position:
        24px 24px,
        24px 24px,
        24px 24px,
        24px 90px,
        24px 124px,
        24px 158px,
        24px 192px,
        24px 226px,
        24px 260px,
        24px 294px,
        24px 328px,
        24px 362px,
        24px 396px,
        24px 430px,
        24px 464px;
}

/* 84.F — Shimmer overlay (capa extra encima del skeleton estatico).
 *
 *  Para que el sweep se vea sobre TODO el skeleton (no solo barras)
 *  agregamos un pseudo-elemento en .CARGANDO (la capa base) que
 *  emite el gradiente animado por encima.
 *
 *  Nota: .CARGANDO no es position:relative por defecto pero el
 *  legacy lo pone position:absolute con z-index:100 — un hijo
 *  posicionado absoluto cubre toda su area sin problema.
 */
.CARGANDO::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 105; /* encima del CARGANDO_IMAGEN (z 101/102) */
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0) 100%);
    background-size: 200% 100%;
    animation: stx-shimmer 1.8s ease-in-out infinite;
}

/* 84.G — Anular en caso de que el iframe sea el PDV-popup full-bleed
 *   (el contenido legacy del CARGANDO_IMAGEN no debe parpadear mas).
 *   No requerido por ahora — el skeleton aplica a todos los iframes. */

/* ============================================================
 * Fin SECCION 84 — Skeleton screen V4.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 86 — PDV App Shell DEFINITIVO (override final SECCIÓN 85)
 *
 * Bug diagnosticado vía Chrome DevTools en producción:
 *   1. LAYER_TOOLS computed width 0px (regla previa pisa por specificity)
 *      con position:fixed; left:1310 -> 2px casi fuera del viewport
 *   2. .pdv-card y=-161 h=1408; .pdv-shell y=-221 h=1564 (display:table
 *      legacy con altura natural enorme). body overflow:hidden corta
 *      hacia arriba -> el centro queda vacío
 *   3. LAYER_DOCUMENTO_MAIN hereda mala posición del .pdv-card
 *
 * Fix: override con max specificity (html body.pdv-popup.pdv-tab ...)
 *      forzando pdv-shell/pdv-card a position:absolute y LAYER_TOOLS
 *      a 300px con left:auto.
 * ============================================================ */

html body.pdv-popup.pdv-tab .pdv-shell {
    position: absolute !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: auto !important; height: auto !important;
    max-height: 100vh !important;
    display: block !important;
    overflow: hidden !important;
    margin: 0 !important; padding: 0 !important;
}
html body.pdv-popup.pdv-tab .pdv-shell > tbody,
html body.pdv-popup.pdv-tab .pdv-shell > tbody > tr,
html body.pdv-popup.pdv-tab .pdv-shell > tr {
    display: block !important;
    width: 100% !important; height: 100% !important;
}
html body.pdv-popup.pdv-tab .pdv-shell > tbody > tr > td,
html body.pdv-popup.pdv-tab .pdv-shell > tr > td {
    display: block !important;
    width: 100% !important; height: 100% !important;
    vertical-align: top !important; padding: 0 !important;
}
html body.pdv-popup.pdv-tab .pdv-card {
    position: absolute !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: auto !important; height: auto !important;
    max-width: none !important; max-height: 100vh !important;
    margin: 0 !important; padding: 0 !important;
    overflow: hidden !important;
    background: var(--bg-base, #fff) !important;
    border: none !important; box-shadow: none !important; border-radius: 0 !important;
}
html body.pdv-popup.pdv-tab .pdv-card > table,
html body.pdv-popup.pdv-tab .pdv-card > table > tbody {
    display: block !important;
    width: 100% !important; height: 100% !important;
}
html body.pdv-popup.pdv-tab .pdv-card > table > tbody > tr,
html body.pdv-popup.pdv-tab .pdv-card > table > tr {
    display: block !important;
    width: 100% !important; height: 100% !important;
}
html body.pdv-popup.pdv-tab .pdv-card > table > tbody > tr > td,
html body.pdv-popup.pdv-tab .pdv-card > table > tr > td {
    display: block !important;
    width: 100% !important; height: 100% !important;
    padding: 0 !important;
    vertical-align: top !important;
}

/* 86.B — LAYER_TOOLS 300px right:0 left:auto */
html body.pdv-popup.pdv-tab td.LAYER_TOOLS,
html body.pdv-popup.pdv-tab .LAYER_TOOLS {
    position: fixed !important;
    top: 40px !important;
    right: 0 !important;
    bottom: 90px !important;
    left: auto !important;
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
    height: auto !important;
    max-height: none !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-left: 1px solid var(--border-default, #e3e8ee) !important;
    padding: 16px !important;
    z-index: 40 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    box-sizing: border-box !important;
}
html body.pdv-popup.pdv-tab .LAYER_TOOLS > table,
html body.pdv-popup.pdv-tab .LAYER_TOOLS > table > tbody {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
}
html body.pdv-popup.pdv-tab .LAYER_TOOLS > table > tbody > tr,
html body.pdv-popup.pdv-tab .LAYER_TOOLS > table > tr {
    display: block !important;
}
html body.pdv-popup.pdv-tab .LAYER_TOOLS > table > tbody > tr > td,
html body.pdv-popup.pdv-tab .LAYER_TOOLS > table > tr > td {
    display: block !important;
    padding: 0 !important;
    text-align: center !important;
}

/* 86.C — LAYER_DOCUMENTO_MAIN central scrollable */
html body.pdv-popup.pdv-tab .LAYER_DOCUMENTO_MAIN {
    position: fixed !important;
    top: 40px !important;
    left: 0 !important;
    right: 300px !important;
    bottom: 90px !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--bg-base, #fff) !important;
    padding: 16px 20px !important;
    box-sizing: border-box !important;
    z-index: 5 !important;
}

/* 86.D — Header 40px morado */
html body.pdv-popup.pdv-tab .LAYER_TABS,
html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS,
html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS .LAYER_TABS {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    z-index: 50 !important;
    background: var(--stx-primary-700, #5147e2) !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    display: block !important;
    margin: 0 !important; padding: 0 !important;
}

/* 86.E — Footer 90px full-width */
html body.pdv-popup.pdv-tab #LAYER_BUTTONS,
html body.pdv-popup.pdv-tab tr#LAYER_BUTTONS {
    position: fixed !important;
    bottom: 0 !important; left: 0 !important; right: 0 !important;
    height: 90px !important;
    z-index: 50 !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
    padding: 8px 16px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: flex !important;
    align-items: stretch !important;
    gap: 12px !important;
}

/* 86.F — Body PDV: overflow hidden, viewport fijo */
html body.pdv-popup.pdv-tab {
    overflow: hidden !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important; padding: 0 !important;
    background: var(--bg-base, #fff) !important;
}

html body.pdv-popup.pdv-tab #LAYER_BLANK {
    display: none !important;
}

@media (max-width: 1100px) {
    html body.pdv-popup.pdv-tab .pdv-shell,
    html body.pdv-popup.pdv-tab .pdv-card,
    html body.pdv-popup.pdv-tab .LAYER_DOCUMENTO_MAIN,
    html body.pdv-popup.pdv-tab .LAYER_TABS,
    html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS,
    html body.pdv-popup.pdv-tab #LAYER_BUTTONS,
    html body.pdv-popup.pdv-tab td.LAYER_TOOLS,
    html body.pdv-popup.pdv-tab .LAYER_TOOLS {
        position: static !important;
        width: auto !important; max-width: none !important; min-width: 0 !important;
        height: auto !important; max-height: none !important;
        top: auto !important; right: auto !important; bottom: auto !important; left: auto !important;
        display: block !important;
    }
    html body.pdv-popup.pdv-tab {
        overflow: auto !important;
        height: auto !important;
    }
}

/* ============================================================
 * Fin SECCIÓN 86 — PDV App Shell DEFINITIVO.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 87 — PDV App Shell RESPONSIVE FLUIDO
 *
 * Bug confirmado via Chrome DevTools: SECCIÓN 85 mete
 *   `width: var(--pdv-sidebar-r) !important` en LAYER_TOOLS pero
 *   la variable CSS no cascade correctamente y el computed termina
 *   width:2px (left:1310 right:0). Mi SECCIÓN 86 con `width:300px
 *   !important` pierde la cascada.
 *
 * Fix: specificity bombs (duplicar clases) + valores FLUIDOS para
 *   adaptarse a cualquier resolución (laptops 13" hasta 4K). Usamos
 *   clamp() para min/preferred/max y vh/vw para escalar.
 *
 * Resoluciones objetivo:
 *   - 1024×768 (tablet): sidebar 260px, header 36px, footer 80px
 *   - 1366×768 (laptop estandar): sidebar ~290px, header 40px, footer 90px
 *   - 1920×1080 (FullHD): sidebar ~320px, header 44px, footer 96px
 *   - 2560×1440 (QHD): sidebar 360px, header 48px, footer 108px
 *   - 3840×2160 (4K): sidebar 360px (cap), header 50px (cap), footer 110px
 *
 * Test con inline style en DevTools confirmó: tools sale 300x294
 *   correctamente cuando se aplica directo. Aquí en CSS aseguramos
 *   la cascada con specificity bomb.
 * ============================================================ */

/* 87.A — Tokens FLUIDOS via clamp(min, preferred, max) */
html body.pdv-popup.pdv-tab {
    --pdv-sidebar-r: clamp(260px, 20vw, 360px);   /* 260 a 360 segun viewport */
    --pdv-header-h: clamp(36px, 4.5vh, 50px);     /* 36 a 50 */
    --pdv-actbar-h: clamp(80px, 9vh, 110px);      /* 80 a 110 */
}

/* 87.B — LAYER_TOOLS (sidebar derecho) con specificity bomb y valores fluidos.
 * Duplicar clases: (0,6,3) > (0,3,3) de SECCION 86 -> gana cascada.
 * Width usa la var definida arriba que es responsive. */
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab td.LAYER_TOOLS.LAYER_TOOLS,
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .LAYER_TOOLS.LAYER_TOOLS {
    position: fixed !important;
    top: var(--pdv-header-h) !important;
    right: 0 !important;
    bottom: var(--pdv-actbar-h) !important;
    left: auto !important;
    width: var(--pdv-sidebar-r) !important;
    min-width: 260px !important;       /* hard floor para que clamp resuelva */
    max-width: 360px !important;       /* hard ceiling */
    height: auto !important;
    max-height: none !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-left: 1px solid var(--border-default, #e3e8ee) !important;
    padding: clamp(12px, 1.5vh, 20px) clamp(12px, 1.2vw, 18px) !important;
    z-index: 90 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    gap: clamp(8px, 1vh, 14px) !important;
    box-sizing: border-box !important;
    box-shadow: -1px 0 2px rgba(48, 49, 61, 0.04) !important;
    transform: none !important;
}

/* 87.C — LAYER_DOCUMENTO_MAIN (centro) responsive: cubre lo que queda */
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .LAYER_DOCUMENTO_MAIN.LAYER_DOCUMENTO_MAIN {
    position: fixed !important;
    top: var(--pdv-header-h) !important;
    left: 0 !important;
    right: var(--pdv-sidebar-r) !important;
    bottom: var(--pdv-actbar-h) !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: clamp(12px, 1.5vh, 24px) clamp(16px, 1.5vw, 28px) !important;
    box-sizing: border-box !important;
    z-index: 5 !important;
}

/* 87.D — Header LAYER_TABS responsive */
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .LAYER_TABS.LAYER_TABS,
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab #LAYER_TICKET_TABS.LAYER_TABS,
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab #LAYER_TICKET_TABS#LAYER_TICKET_TABS {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    height: var(--pdv-header-h) !important;
    min-height: var(--pdv-header-h) !important;
    max-height: var(--pdv-header-h) !important;
    z-index: 50 !important;
    background: var(--stx-primary-700, #5147e2) !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    display: block !important;
    margin: 0 !important; padding: 0 !important;
}

/* 87.E — Footer LAYER_BUTTONS responsive */
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab #LAYER_BUTTONS#LAYER_BUTTONS {
    position: fixed !important;
    bottom: 0 !important; left: 0 !important; right: 0 !important;
    height: var(--pdv-actbar-h) !important;
    z-index: 50 !important;
    background: var(--bg-subtle, #f6f9fc) !important;
    border-top: 1px solid var(--border-default, #e3e8ee) !important;
    padding: clamp(6px, 0.8vh, 12px) clamp(12px, 1.2vw, 20px) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: flex !important;
    align-items: stretch !important;
    gap: clamp(8px, 1vw, 16px) !important;
}

/* 87.F — Action bar interno tiles: flex 1 cada uno para distribuir uniforme */
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .pdv-action-bar.pdv-action-bar {
    display: flex !important;
    flex: 1 1 auto !important;
    gap: clamp(6px, 0.8vw, 12px) !important;
    height: 100% !important;
    align-items: stretch !important;
}
html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .pdv-action-icon.pdv-action-icon {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
}

/* 87.G — Pequeño breakpoint para laptops (1024-1366px): sidebar más estrecho */
@media (min-width: 1024px) and (max-width: 1366px) {
    html body.pdv-popup.pdv-tab {
        --pdv-sidebar-r: 280px;
    }
}

/* 87.H — Monitores grandes (>=1920px): sidebar más generoso */
@media (min-width: 1920px) {
    html body.pdv-popup.pdv-tab {
        --pdv-sidebar-r: clamp(320px, 18vw, 380px);
        --pdv-header-h: 46px;
        --pdv-actbar-h: 100px;
    }
}

/* 87.I — Mobile / pantalla angosta: desactiva el shell por completo */
@media (max-width: 900px) {
    html body.pdv-popup.pdv-tab {
        --pdv-sidebar-r: 0px;
        --pdv-header-h: 40px;
        --pdv-actbar-h: 80px;
    }
    html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab td.LAYER_TOOLS.LAYER_TOOLS,
    html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .LAYER_TOOLS.LAYER_TOOLS {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }
    html body.pdv-popup.pdv-popup.pdv-tab.pdv-tab .LAYER_DOCUMENTO_MAIN.LAYER_DOCUMENTO_MAIN {
        right: 0 !important;
    }
}

/* ============================================================
 * Fin SECCIÓN 87 — Responsive fluido.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 88 — PDV ticket tabs: X close button + visual V4
 *
 * Los tabs internos del PDV (TICKET #1, TICKET #2...) ahora tienen
 *   boton X visible (SVG Lucide). Las plantillas en pdv.js generan:
 *
 *     <TABLE class="pdv-tab-tbl pdv-tab-tbl-on/off">
 *       <TR>
 *         <TD class="ON_MIDDLE_PDV/OFF_MIDDLE_PDV"> @@@TIPO@@@ #N </TD>
 *         <TD class="pdv-tab-x-cell">
 *           <SPAN class="pdv-tab-close"> <svg X> </SPAN>
 *         </TD>
 *       </TR>
 *     </TABLE>
 *
 * Estilo: matchea el header purpura del PDV (SECCION 86) y el tab
 *   activo blanco. El boton X aparece siempre en hover/activo. Hover
 *   sobre la X muestra fondo rojo claro.
 * ============================================================ */

/* 88.A — Contenedor de cada tab (tabla legacy)
 * NOTA: NO seteo background aqui; se delega a -off/-on para que ganen
 * la cascada. Antes habia un `background: transparent !important` que
 * pisaba a -on (specificity (0,3,2) vs (0,3,1) del estado). */
html body.pdv-popup.pdv-tab .pdv-tab-tbl,
html body.pdv-popup.pdv-tab table.pdv-tab-tbl {
    margin: 0 4px 0 0 !important;
    padding: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    height: 28px !important;
    border-radius: 6px 6px 0 0 !important;
    overflow: hidden !important;
    transition: background-color 0.15s ease !important;
}
/* Estados con selector table.pdv-tab-tbl.* para subir specificity a (0,3,2)
 * y empatar/ganar a la regla base. */
html body.pdv-popup.pdv-tab table.pdv-tab-tbl.pdv-tab-tbl-off,
html body.pdv-popup.pdv-tab .pdv-tab-tbl.pdv-tab-tbl-off {
    background: rgba(255,255,255,0.08) !important;
}
html body.pdv-popup.pdv-tab table.pdv-tab-tbl.pdv-tab-tbl-off:hover,
html body.pdv-popup.pdv-tab .pdv-tab-tbl.pdv-tab-tbl-off:hover {
    background: rgba(255,255,255,0.18) !important;
}
html body.pdv-popup.pdv-tab table.pdv-tab-tbl.pdv-tab-tbl-on,
html body.pdv-popup.pdv-tab .pdv-tab-tbl.pdv-tab-tbl-on {
    background: #ffffff !important;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.08) !important;
}

/* 88.B — Celda del label (TIPO + #N) */
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.OFF_MIDDLE_PDV,
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.ON_MIDDLE_PDV {
    padding: 0 4px 0 14px !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    vertical-align: middle !important;
    height: 28px !important;
    line-height: 28px !important;
    background: transparent !important;
    border: 0 !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.OFF_MIDDLE_PDV,
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.OFF_MIDDLE_PDV a {
    color: rgba(255,255,255,0.78) !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.ON_MIDDLE_PDV,
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.ON_MIDDLE_PDV a {
    color: var(--stx-primary-700, #5147e2) !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-tbl .pdv-tab-num {
    opacity: 0.55 !important;
    font-weight: 500 !important;
    margin-left: 2px !important;
}

/* 88.C — Celda y boton X */
html body.pdv-popup.pdv-tab .pdv-tab-tbl td.pdv-tab-x-cell {
    padding: 0 6px 0 4px !important;
    vertical-align: middle !important;
    height: 28px !important;
    background: transparent !important;
    border: 0 !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-close {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 18px !important;
    height: 18px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: background-color 0.12s ease, color 0.12s ease !important;
    opacity: 0.7 !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-tbl-off .pdv-tab-close {
    color: rgba(255,255,255,0.85) !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-tbl-off:hover .pdv-tab-close {
    opacity: 1 !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-tbl-on .pdv-tab-close {
    color: var(--text-muted, #697386) !important;
    opacity: 0.85 !important;
}
html body.pdv-popup.pdv-tab .pdv-tab-close:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #dc2626 !important;
    opacity: 1 !important;
}

/* 88.D — Boton + de agregar tab */
html body.pdv-popup.pdv-tab .LAYER_TABS table tr td:last-child img[src*="bt_add_tab"] {
    display: none !important;
}
html body.pdv-popup.pdv-tab .LAYER_TABS table tr td:last-child a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 6px !important;
    background: rgba(255,255,255,0.12) !important;
    color: #ffffff !important;
    text-decoration: none !important;
    cursor: pointer !important;
    transition: background-color 0.12s ease !important;
    line-height: 1 !important;
    margin-left: 6px !important;
}
html body.pdv-popup.pdv-tab .LAYER_TABS table tr td:last-child a::before {
    content: "+" !important;
    color: #ffffff !important;
    font-size: 20px !important;
    font-weight: 300 !important;
    line-height: 1 !important;
}
html body.pdv-popup.pdv-tab .LAYER_TABS table tr td:last-child a:hover {
    background: rgba(255,255,255,0.22) !important;
}

/* 88.E — Contenedor general del LAYER_TABS */
html body.pdv-popup.pdv-tab .LAYER_TABS > table {
    width: 100% !important;
    height: 100% !important;
}
html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS_CONTENEDOR {
    display: flex !important;
    align-items: flex-end !important;
    gap: 2px !important;
    height: 100% !important;
    padding: 6px 0 0 16px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
}
html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS_CONTENEDOR > div {
    flex-shrink: 0 !important;
}
html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS_CONTENEDOR [style*="float: left"],
html body.pdv-popup.pdv-tab #LAYER_TICKET_TABS_CONTENEDOR [style*="float:left"] {
    float: none !important;
}

/* ============================================================
 * Fin SECCIÓN 88 — PDV ticket tabs.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 89 — DESHABILITADA por bug crítico (iter 5)
 *
 * Las reglas anteriores colapsaban filas del TABLE legacy del PDV
 *   con la intención de eliminar 22px de overflow latente (oculto por
 *   body:overflow:hidden). Pero la suposición de que `pdv-divider-row`
 *   era una fila separadora aislada resultó FALSA — la TR que contiene
 *   `pdv-action-bar-cell` y `pdv-divider-row` también contiene
 *   LAYER_TICKET_TABS o un ancestro de él. Al hacer display:none
 *   se rompió la visualización completa del header púrpura del PDV
 *   (tabs ticket invisibles, LAYER_TICKET_TABS_CONTENEDOR colapsado).
 *
 * Lección: el overflow de 22px era INVISIBLE al usuario y NO era
 *   bloqueante. No vale la pena romper el layout por un fix preventivo.
 *   Si en algun futuro se requiere limpiar el overflow, hay que
 *   analizar la estructura HTML completa del <TABLE> del PDV antes
 *   de aplicar display:none a TR/TD.
 *
 * Por ahora, comentado completamente. El overflow latente vuelve a
 *   existir pero el layout funciona correctamente.
 * ============================================================ */
/* Reglas deshabilitadas (mantener documentadas para no repetir el error):
 *   tr.pdv-divider-row { display: none }       <- afecta tabs ticket
 *   tr:has(td.pdv-action-bar-cell) { display: none }  <- idem
 *   .pdv-card, .pdv-shell { height: 100vh; overflow: hidden }  <- safe
 */

/* ============================================================
 * SECCIÓN 90 — Layers ALT (Factura/Devolución/Caja/Existencias/Precios/Otros)
 *
 * El SECCIÓN 86 (shell PDV) solo posicionó LAYER_TICKET con position:fixed
 * + dimensiones del centro. Los otros layers (FACTURA, DEVOLUCION, etc.)
 * cuando se hacen display:block via js_mostrar_layer() siguen sin dimensiones
 * porque heredan del flujo legacy aplastado. Resultado: 0x0 visible.
 *
 * Fix: aplicar mismas dimensiones del centro a TODOS los layers ALT cuando
 * se desplegan. Position fixed para evitar afectar el flujo legacy.
 * ============================================================ */
html body.pdv-popup.pdv-tab #LAYER_FACTURA,
html body.pdv-popup.pdv-tab #LAYER_DEVOLUCION,
html body.pdv-popup.pdv-tab #LAYER_CAJA,
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS,
html body.pdv-popup.pdv-tab #LAYER_PRECIOS,
html body.pdv-popup.pdv-tab #LAYER_OTROS {
    position: fixed !important;
    top: var(--pdv-header-h, 40px) !important;
    left: 0 !important;
    right: var(--pdv-sidebar-r, 300px) !important;
    bottom: var(--pdv-actbar-h, 90px) !important;
    width: auto !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px clamp(16px, 1.5vw, 28px) !important;
    background: #ffffff !important;
    z-index: 10 !important;
    box-sizing: border-box !important;
}
/* Cuando display:none por js_mostrar_layer(otro) - mantener oculto */
html body.pdv-popup.pdv-tab #LAYER_FACTURA[style*="display: none"],
html body.pdv-popup.pdv-tab #LAYER_DEVOLUCION[style*="display: none"],
html body.pdv-popup.pdv-tab #LAYER_CAJA[style*="display: none"],
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS[style*="display: none"],
html body.pdv-popup.pdv-tab #LAYER_PRECIOS[style*="display: none"],
html body.pdv-popup.pdv-tab #LAYER_OTROS[style*="display: none"] {
    display: none !important;
}
/* TABLE/TBODY anidados de estos layers: forzar flujo normal */
html body.pdv-popup.pdv-tab #LAYER_FACTURA > table,
html body.pdv-popup.pdv-tab #LAYER_DEVOLUCION > table,
html body.pdv-popup.pdv-tab #LAYER_CAJA > table,
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS > table,
html body.pdv-popup.pdv-tab #LAYER_PRECIOS > table,
html body.pdv-popup.pdv-tab #LAYER_OTROS > table {
    width: 100% !important;
    table-layout: auto !important;
}

/* ============================================================
 * Fin SECCIÓN 90.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 91 — Fixes consolidados de 9 sub-agentes (PDV interno)
 *
 * Sub-agentes auditaron: FACTURA, DEVOLUCION, CAJA, EXISTENCIAS,
 * PRECIOS, OTROS, PAGO, ENCABEZADO_TICKET, GRID_DETALLE.
 * Esta sección aplica los fixes CSS sin tocar PHP/JS.
 * ============================================================ */

/* 91.A — Headers de columnas del grid detalle (Cantidad/Producto/Precio/Desc/Total)
 * Bug: .GRID_TITLE heredaba display:inline-flex que las colapsaba en PDV.
 * El selector correcto es .GRID_TITLE (no .GRID_TITLE_PDV). */
html body.pdv-popup.pdv-tab .GRID_HEADER_PDV,
html body.pdv-popup.pdv-tab thead.GRID_HEADER_PDV {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-bottom: 1px solid var(--border-default, #e3e8ee) !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 5 !important;
}
html body.pdv-popup.pdv-tab .GRID_TITLE,
html body.pdv-popup.pdv-tab thead.GRID_HEADER_PDV .GRID_TITLE {
    display: block !important;
    min-height: 16px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: var(--gray-700, #425466) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    padding: 4px 6px !important;
}

/* 91.B — Encabezado del ticket: forzar min-height en filas (CAMPO_ENCABEZADO_*)
 * para que no colapsen cuando padding V4 las achicó */
html body.pdv-popup div[id^="LAYER_TICKET_"][id$="_ENCABEZADO"] table > tbody > tr,
html body.pdv-popup div[id^="LAYER_FACTURA_"][id$="_ENCABEZADO"] table > tbody > tr,
html body.pdv-popup div[id^="LAYER_DEVOLUCION_"][id$="_ENCABEZADO"] table > tbody > tr {
    min-height: 32px !important;
    display: table-row !important;
    height: auto !important;
}

/* 91.C — Sub-divs de LAYER_FACTURA con dimensiones desde inline-style
 * Permitir height:auto + max-height responsive */
html body.pdv-popup.pdv-tab div[id^="LAYER_FACTURA_"][id$="_ENCABEZADO"],
html body.pdv-popup.pdv-tab div[id^="LAYER_FACTURA_"][id$="_DETALLE"],
html body.pdv-popup.pdv-tab div[id^="LAYER_FACTURA_"][id$="_AGREGAR"],
html body.pdv-popup.pdv-tab div[id^="LAYER_FACTURA_"][id$="_TOTALES"],
html body.pdv-popup.pdv-tab div[id^="LAYER_DEVOLUCION_"][id$="_ENCABEZADO"],
html body.pdv-popup.pdv-tab div[id^="LAYER_DEVOLUCION_"][id$="_DETALLE"],
html body.pdv-popup.pdv-tab div[id^="LAYER_DEVOLUCION_"][id$="_AGREGAR"],
html body.pdv-popup.pdv-tab div[id^="LAYER_DEVOLUCION_"][id$="_TOTALES"] {
    overflow-y: auto !important;
}

/* 91.D — LAYER_PAGO contenedor: refactor V4 (efectivo/tarjeta/cambio) */
html body.pdv-popup div[id^="LAYER_PAGO_"] > table:first-of-type {
    background-color: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(48,49,61,0.04)) !important;
    overflow: hidden !important;
}
html body.pdv-popup div[id^="LAYER_CONTENEDOR_FDPS_"] {
    background-color: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-subtle, #f3f6fa) !important;
    border-radius: 4px !important;
}
html body.pdv-popup input[id^="FDP["].TEXTBOX,
html body.pdv-popup input[name*="MONTO"].TEXTBOX,
html body.pdv-popup input[name*="REFERENCIA"].TEXTBOX {
    background-color: var(--bg-base, #ffffff) !important;
    border: 1px solid var(--border-default, #e3e8ee) !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    color: var(--text-primary, #0a2540) !important;
}
html body.pdv-popup input.TEXTBOX:focus {
    border-color: var(--stx-primary-600, #635bff) !important;
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15) !important;
    outline: none !important;
}

/* 91.E — LAYER_EXISTENCIAS datagrid azul legacy → V4 */
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS .GRID_TABLE {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    background: var(--bg-base, #ffffff) !important;
}
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS .GRID_HEADER,
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS .GRID_FREEZED_HEADER {
    background-color: var(--bg-subtle, #f6f9fc) !important;
    border-color: var(--border-default, #e3e8ee) !important;
}
html body.pdv-popup.pdv-tab #LAYER_EXISTENCIAS .ODD_ROW {
    background-color: var(--bg-base, #ffffff) !important;
}

/* 91.F — LAYER_CAJA: anular inline styles legacy (height/border/bg) */
html body.pdv-popup.pdv-tab #LAYER_CAJA {
    height: auto !important;
    border: none !important;
}
html body.pdv-popup.pdv-tab #LAYER_CAJA fieldset {
    border: 1px solid var(--border-default, #e3e8ee) !important;
    background: var(--bg-base, #fff) !important;
    border-radius: 8px !important;
}

/* 91.G — LAYER_OTROS: legend uppercase V4 + tile spacing */
html body.pdv-popup.pdv-tab #LAYER_OTROS {
    overflow: visible !important;
}
html body.pdv-popup.pdv-tab #LAYER_OTROS fieldset > legend {
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: var(--stx-primary-600, #635bff) !important;
    font-weight: 600 !important;
}
html body.pdv-popup.pdv-tab #LAYER_OTROS .ICON img {
    filter: brightness(0.95) contrast(1.05) !important;
    transition: transform 120ms ease, filter 120ms ease !important;
}
html body.pdv-popup.pdv-tab #LAYER_OTROS .ICON:hover img {
    transform: scale(1.05) !important;
    filter: brightness(1) contrast(1.1) !important;
}

/* 91.H — LAYER_PRECIOS: datagrid V4 + overflow visible */
html body.pdv-popup.pdv-tab #LAYER_PRECIOS {
    overflow: visible !important;
}
html body.pdv-popup.pdv-tab #LAYER_PRECIOS .GRID_TABLE {
    margin: 0 !important;
    border-radius: var(--radius-md, 8px) !important;
}

/* 91.I — Encabezado bg legacy #6B7F9A → V4 */
html body.pdv-popup div[id^="LAYER_TICKET_"][id$="_ENCABEZADO"],
html body.pdv-popup div[id^="LAYER_FACTURA_"][id$="_ENCABEZADO"],
html body.pdv-popup div[id^="LAYER_DEVOLUCION_"][id$="_ENCABEZADO"] {
    background-color: var(--bg-subtle, #f6f9fc) !important;
}

/* ============================================================
 * Fin SECCIÓN 91.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 93 — Dashboard V4 Radical (Stripe/Linear)
 *
 * Transformacion completa de los modulos del dashboard del usuario
 * (.stx-dash2-section-wrap) y de los Quick Links del footer.
 *
 * Cero cambio en JS/PHP. Solo CSS scopeado a .stx-dash2-section-wrap
 * y .quick-links para no afectar Documentos/Catalogos/PDV/etc.
 *
 * Fecha: 2026-06-07
 * ============================================================ */

/* Background sutil con gradiente */
body.main-v2 {
    background: linear-gradient(180deg, #fafbff 0%, #f6f9fc 100%) !important;
}

/* ----- 93.A — Cards de seccion: shadow doble + hover lift ----- */
body.main-v2 .stx-dash2-section-wrap {
    background: #ffffff !important;
    border: 1px solid #e6ebf1 !important;
    border-radius: 14px !important;
    box-shadow:
        0 1px 2px rgba(10,37,64,0.04),
        0 4px 16px rgba(10,37,64,0.04) !important;
    overflow: hidden !important;
    padding: 0 !important;
    transition: box-shadow 200ms ease, transform 200ms ease !important;
}
body.main-v2 .stx-dash2-section-wrap:hover {
    box-shadow:
        0 1px 2px rgba(10,37,64,0.04),
        0 8px 32px rgba(10,37,64,0.08) !important;
}

/* Fieldset interno sin borde legacy */
body.main-v2 .stx-dash2-section-wrap fieldset {
    border: none !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 24px 28px !important;
}

/* ----- 93.B — Header (LEGEND) con accent purple ----- */
body.main-v2 .stx-dash2-section-wrap legend {
    display: block !important;
    width: 100% !important;
    padding: 0 0 14px 0 !important;
    margin: 0 0 18px 0 !important;
    font: 700 13px/1 'Inter', sans-serif !important;
    letter-spacing: 0.6px !important;
    text-transform: uppercase !important;
    color: #425466 !important;
    border-bottom: 1px solid #ebeef3 !important;
    position: relative !important;
}
body.main-v2 .stx-dash2-section-wrap legend::after {
    content: '';
    position: absolute;
    left: 0; bottom: -1px;
    width: 32px; height: 2px;
    background: #635bff;
    border-radius: 2px;
}

/* ----- 93.C — Tablas internas del fieldset ----- */
body.main-v2 .stx-dash2-section-wrap fieldset > table,
body.main-v2 .stx-dash2-section-wrap > table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: transparent !important;
    border: none !important;
}
body.main-v2 .stx-dash2-section-wrap fieldset td,
body.main-v2 .stx-dash2-section-wrap > table td {
    background: transparent !important;
    border: none !important;
    padding: 8px 0 !important;
    vertical-align: middle !important;
    font: 400 14px/1.5 'Inter', sans-serif !important;
    color: #0a2540 !important;
}
body.main-v2 .stx-dash2-section-wrap .FORM_TABLE_DARK,
body.main-v2 .stx-dash2-section-wrap td.FORM_TABLE_DARK {
    font: 500 13px/1.5 'Inter', sans-serif !important;
    color: #425466 !important;
    padding-right: 16px !important;
    text-transform: none !important;
}

/* ----- 93.D — Enlaces rapidos como cards lavanda ----- */
body.main-v2 .stx-dash2-section-wrap ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: grid !important;
    gap: 6px !important;
}
body.main-v2 .stx-dash2-section-wrap ul li {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}
body.main-v2 .stx-dash2-section-wrap ul li a {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 11px 14px !important;
    background: #f6f9fc !important;
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    color: #0a2540 !important;
    font: 500 14px/1.4 'Inter', sans-serif !important;
    transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}
body.main-v2 .stx-dash2-section-wrap ul li a::before {
    content: '';
    flex-shrink: 0;
    width: 32px; height: 32px;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23635bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h14M12 5l7 7-7 7'/></svg>") center/16px no-repeat,
        linear-gradient(135deg, #ebe9fe 0%, #ddd9fe 100%);
    border-radius: 8px;
}
body.main-v2 .stx-dash2-section-wrap ul li a:hover {
    background: #ffffff !important;
    border-color: #635bff !important;
    box-shadow: 0 6px 20px rgba(99,91,255,0.15) !important;
    transform: translateX(4px) !important;
    color: #635bff !important;
}

/* ----- 93.E — Botones gradient purple + press ----- */
body.main-v2 .stx-dash2-section-wrap input[type="button"],
body.main-v2 .stx-dash2-section-wrap input[type="submit"],
body.main-v2 .stx-dash2-section-wrap button:not(.stx-icon-btn) {
    padding: 9px 20px !important;
    background: linear-gradient(180deg, #635bff 0%, #5147e6 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font: 500 14px/1.4 'Inter', sans-serif !important;
    cursor: pointer !important;
    box-shadow:
        0 1px 1px rgba(0,0,0,0.06),
        0 1px 2px rgba(10,37,64,0.10),
        inset 0 1px 0 rgba(255,255,255,0.15) !important;
    transition: all 150ms ease !important;
    letter-spacing: 0.2px !important;
}
body.main-v2 .stx-dash2-section-wrap input[type="button"]:hover,
body.main-v2 .stx-dash2-section-wrap input[type="submit"]:hover,
body.main-v2 .stx-dash2-section-wrap button:not(.stx-icon-btn):hover {
    background: linear-gradient(180deg, #5147e6 0%, #4338ca 100%) !important;
    box-shadow:
        0 4px 14px rgba(99,91,255,0.30),
        inset 0 1px 0 rgba(255,255,255,0.15) !important;
    transform: translateY(-1px) !important;
}
body.main-v2 .stx-dash2-section-wrap input[type="button"]:active,
body.main-v2 .stx-dash2-section-wrap input[type="submit"]:active,
body.main-v2 .stx-dash2-section-wrap button:not(.stx-icon-btn):active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 2px rgba(10,37,64,0.10) !important;
}

/* ----- 93.F — Inputs V4 ----- */
body.main-v2 .stx-dash2-section-wrap input[type="text"],
body.main-v2 .stx-dash2-section-wrap input[type="number"],
body.main-v2 .stx-dash2-section-wrap input[type="date"],
body.main-v2 .stx-dash2-section-wrap input[type="email"],
body.main-v2 .stx-dash2-section-wrap input:not([type]),
body.main-v2 .stx-dash2-section-wrap textarea {
    border: 1px solid #e3e8ee !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    padding: 9px 12px !important;
    font: 400 14px/1.4 'Inter', sans-serif !important;
    color: #0a2540 !important;
    transition: all 150ms ease !important;
    box-shadow: 0 1px 2px rgba(10,37,64,0.04) !important;
}
body.main-v2 .stx-dash2-section-wrap input:focus,
body.main-v2 .stx-dash2-section-wrap textarea:focus {
    outline: none !important;
    border-color: #635bff !important;
    box-shadow:
        0 0 0 3px rgba(99,91,255,0.16),
        0 1px 2px rgba(10,37,64,0.04) !important;
}

/* ----- 93.G — Selects V4 con caret SVG ----- */
body.main-v2 .stx-dash2-section-wrap select {
    appearance: none !important;
    -webkit-appearance: none !important;
    border: 1px solid #e3e8ee !important;
    background: #ffffff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23425466' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") right 10px center/14px no-repeat !important;
    border-radius: 8px !important;
    padding: 9px 32px 9px 12px !important;
    font: 400 14px/1.4 'Inter', sans-serif !important;
    color: #0a2540 !important;
    cursor: pointer !important;
    transition: all 150ms ease !important;
    box-shadow: 0 1px 2px rgba(10,37,64,0.04) !important;
}
body.main-v2 .stx-dash2-section-wrap select:focus {
    outline: none !important;
    border-color: #635bff !important;
    box-shadow:
        0 0 0 3px rgba(99,91,255,0.16),
        0 1px 2px rgba(10,37,64,0.04) !important;
}

/* ----- 93.H — Tablas de datos Stripe-style ----- */
body.main-v2 .stx-dash2-section-wrap fieldset table tbody tr {
    transition: background 120ms ease;
}
body.main-v2 .stx-dash2-section-wrap fieldset table tbody tr:hover {
    background: #f7fafc !important;
}
body.main-v2 .stx-dash2-section-wrap fieldset table thead td,
body.main-v2 .stx-dash2-section-wrap fieldset table thead th {
    font: 600 11px/1.5 'Inter', sans-serif !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    color: #697386 !important;
    background: #fafbfc !important;
    padding: 12px 14px !important;
    border-bottom: 1px solid #e3e8ee !important;
}

/* ============================================================
 * 93.I — Quick Links del footer (dashboard_quick_links.php)
 * ============================================================ */
body.main-v2 .quick-links {
    padding: 32px 28px 24px 28px !important;
    background: #ffffff !important;
    border: 1px solid #e6ebf1 !important;
    border-radius: 14px !important;
    box-shadow:
        0 1px 2px rgba(10,37,64,0.04),
        0 4px 16px rgba(10,37,64,0.04) !important;
}
body.main-v2 .quick-links__title {
    font: 700 22px/1.2 'Inter', sans-serif !important;
    color: #0a2540 !important;
    margin: 0 0 4px 0 !important;
    letter-spacing: -0.4px !important;
}
body.main-v2 .quick-links__subtitle {
    font: 400 14px/1.5 'Inter', sans-serif !important;
    color: #697386 !important;
    margin: 0 !important;
}
body.main-v2 .quick-links__header {
    margin-bottom: 28px !important;
    padding-bottom: 18px !important;
    border-bottom: 1px solid #ebeef3 !important;
    position: relative !important;
}
body.main-v2 .quick-links__header::after {
    content: '';
    position: absolute;
    left: 0; bottom: -1px;
    width: 40px; height: 2px;
    background: linear-gradient(90deg, #635bff 0%, #8b5cf6 100%);
    border-radius: 2px;
}
body.main-v2 .quick-links__category {
    margin-top: 24px !important;
}
body.main-v2 .quick-links__category:first-of-type {
    margin-top: 0 !important;
}
body.main-v2 .quick-links__category-title {
    font: 600 11px/1.5 'Inter', sans-serif !important;
    letter-spacing: 0.7px !important;
    text-transform: uppercase !important;
    color: #635bff !important;
    margin: 0 0 14px 0 !important;
    padding: 4px 10px !important;
    background: linear-gradient(135deg, #ebe9fe 0%, #ddd9fe 100%) !important;
    display: inline-block !important;
    border-radius: 6px !important;
}
body.main-v2 .quick-links__grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 12px !important;
}
body.main-v2 .quick-link-card {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 14px 16px !important;
    background: #ffffff !important;
    border: 1px solid #e6ebf1 !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    color: #0a2540 !important;
    transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1) !important;
    position: relative !important;
    overflow: hidden !important;
}
body.main-v2 .quick-link-card::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    width: 3px; height: 0;
    background: linear-gradient(180deg, #635bff 0%, #8b5cf6 100%);
    border-radius: 0 3px 3px 0;
    transform: translateY(-50%);
    transition: height 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
body.main-v2 .quick-link-card:hover {
    border-color: #635bff !important;
    background: linear-gradient(135deg, #fafbff 0%, #f4f3ff 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow:
        0 1px 2px rgba(99,91,255,0.10),
        0 8px 24px rgba(99,91,255,0.15) !important;
}
body.main-v2 .quick-link-card:hover::before {
    height: 60%;
}
body.main-v2 .quick-link-card__icon-wrap {
    flex-shrink: 0 !important;
    width: 36px !important; height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f6f9fc !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    transition: background 180ms ease !important;
}
body.main-v2 .quick-link-card:hover .quick-link-card__icon-wrap {
    background: #ffffff !important;
}
body.main-v2 .quick-link-card__icon {
    width: 20px !important; height: 20px !important;
    object-fit: contain !important;
}
body.main-v2 .quick-link-card__content {
    flex: 1 !important;
    min-width: 0 !important;
}
body.main-v2 .quick-link-card__title {
    font: 600 13px/1.3 'Inter', sans-serif !important;
    color: #0a2540 !important;
    margin: 0 0 2px 0 !important;
    text-decoration: none !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
body.main-v2 .quick-link-card__subtitle,
body.main-v2 .quick-link-card__desc {
    font: 400 12px/1.4 'Inter', sans-serif !important;
    color: #697386 !important;
    margin: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
body.main-v2 .quick-link-card:hover .quick-link-card__title {
    color: #635bff !important;
}
body.main-v2 .quick-link-card,
body.main-v2 .quick-link-card * {
    text-decoration: none !important;
}

/* ============================================================
 * Fin SECCIÓN 93.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 94 — Dashboard V4: DATATABLA + links de modulos custom
 *
 * Los modulos personalizados (Pedidos a venta, Saldos cajas, etc.)
 * usan clases legacy DATATABLA y TITULOS_DATATABLA en lugar del
 * markup table generico. Adicionalmente meten links con href="js_void()"
 * que se deben estilizar como pills.
 *
 * Cero cambio en JS/PHP. Solo CSS scopeado a .stx-dash2-section-wrap.
 *
 * Fecha: 2026-06-07
 * ============================================================ */

body.main-v2 .stx-dash2-section-wrap .DATATABLA {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    border: 1px solid #e6ebf1 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 2px rgba(10,37,64,0.04) !important;
    margin: 8px 0 !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA td {
    border: none !important;
    border-bottom: 1px solid #f1f4f7 !important;
    padding: 11px 14px !important;
    font: 400 13px/1.45 'Inter', sans-serif !important;
    color: #0a2540 !important;
    background: transparent !important;
    vertical-align: middle !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr:last-child td {
    border-bottom: none !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr {
    transition: background 120ms ease !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr:hover {
    background: #f7fafc !important;
}

/* Headers TITULOS_DATATABLA */
body.main-v2 .stx-dash2-section-wrap .TITULOS_DATATABLA,
body.main-v2 .stx-dash2-section-wrap td.TITULOS_DATATABLA {
    font: 600 11px/1.5 'Inter', sans-serif !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    color: #697386 !important;
    background: #fafbfc !important;
    border-bottom: 1px solid #e3e8ee !important;
    padding: 12px 14px !important;
}

/* Links dentro de la DATATABLA */
body.main-v2 .stx-dash2-section-wrap .DATATABLA a {
    color: #635bff !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    transition: color 120ms ease !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA a:hover {
    color: #4338ca !important;
    text-decoration: underline !important;
}

/* Links [Actualizar] / [Refresh] / etc. con href javascript:js_void() — pill */
body.main-v2 .stx-dash2-section-wrap a[href*="js_void"] {
    display: inline-flex !important;
    align-items: center !important;
    padding: 6px 14px !important;
    font: 500 13px/1.4 'Inter', sans-serif !important;
    color: #635bff !important;
    background: #ebe9fe !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    transition: all 150ms ease !important;
}
body.main-v2 .stx-dash2-section-wrap a[href*="js_void"]:hover {
    background: #635bff !important;
    color: #fff !important;
}

/* ============================================================
 * Fin SECCIÓN 94.
 * ============================================================ */

/* ============================================================
 * SECCIÓN 95 — Dashboard: botones action en ultima columna DATATABLA
 *
 * Los links de la ultima columna (Surtir, Aplicar, Procesar, etc.) son
 * acciones primarias del row. Convertirlos en botones pill purple con
 * icono check para que destaquen visualmente vs los links de texto
 * (folios, etc).
 *
 * Usa el mismo gradient purple V4 de los botones .stx-dash2-section-wrap
 * input[type=button] (SECCION 93.E) para mantener consistencia visual
 * con todo el dashboard.
 *
 * Fecha: 2026-06-07
 * ============================================================ */
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr td:last-child a {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 14px !important;
    font: 600 12px/1.3 'Inter', sans-serif !important;
    color: #ffffff !important;
    background: linear-gradient(180deg, #635bff 0%, #5147e6 100%) !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    box-shadow:
        0 1px 1px rgba(0,0,0,0.06),
        0 1px 2px rgba(10,37,64,0.10),
        inset 0 1px 0 rgba(255,255,255,0.15) !important;
    transition: all 150ms ease !important;
    letter-spacing: 0.2px !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr td:last-child a::before {
    content: '';
    width: 12px; height: 12px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center/contain no-repeat;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr td:last-child a:hover {
    background: linear-gradient(180deg, #5147e6 0%, #4338ca 100%) !important;
    color: #fff !important;
    text-decoration: none !important;
    box-shadow:
        0 4px 12px rgba(99,91,255,0.30),
        inset 0 1px 0 rgba(255,255,255,0.15) !important;
    transform: translateY(-1px) !important;
}
body.main-v2 .stx-dash2-section-wrap .DATATABLA tbody tr td:last-child a:active {
    transform: translateY(0) !important;
}

/* ============================================================
 * Fin SECCIÓN 95.
 * ============================================================ */
