/* FlexIA · cierre visual v4
   Ultima capa de cascada: alinea V3 y blinda el modo oscuro en toda la interfaz.
   No contiene logica de negocio. */

/* ===== V3 · cliente + cupo + saldo, una sola linea ===== */
@media (min-width: 992px) {
  body.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .ventas-toolbar {
    grid-template-columns: auto minmax(430px, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search {
    width: 100% !important;
    min-width: 0 !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: var(--pos-surface, #fff) !important;
    border: 1px solid var(--pos-line-strong, #d1dce7) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search .cliente-header {
    display: none !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search .search-wrap {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 34px !important;
    margin: 0 !important;
    position: relative !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search .form-control {
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 2.2rem !important;
    padding-right: 4rem !important;
    color: var(--pos-text, #17314f) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 7px 0 0 7px !important;
    box-shadow: none !important;
    line-height: 34px !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search:focus-within {
    border-color: #62bce7 !important;
    box-shadow: 0 0 0 3px var(--pos-focus, rgba(53,184,243,.13)) !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search > .fx-client-balances {
    position: static !important;
    flex: 0 0 auto !important;
    width: auto !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    margin: 0 !important;
    padding: 0 9px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    color: var(--pos-muted, #71839a) !important;
    font-size: 9.6px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    overflow: visible !important;
    border-left: 1px solid var(--pos-line, #e1e7ee) !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search > .fx-client-balances span {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    margin: 0 !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search > .fx-client-balances b {
    margin: 0 !important;
    color: var(--pos-navy, #0b2d68) !important;
    font-family: var(--font-mono, "IBM Plex Mono", monospace) !important;
    font-size: 9.7px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
  }

  body.fx-pos-family.fx-page-facturav3 .fx-topbar-client-search #aFavorVal {
    color: #16835e !important;
  }
}

/* ===== Selector de documento: seleccionado siempre legible ===== */
body.fx-pos-family .segmented button.active,
body.fx-pos-family #docTypeToggle button.active,
body.fx-pos-family #ventasToolbarInlineHost .segmented button.active,
body.fx-pos-family #ventasToolbarMobileHost .segmented button.active {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  background: var(--pos-navy, #0b2d68) !important;
  border-color: var(--pos-navy, #0b2d68) !important;
  opacity: 1 !important;
}

/* ===== Modo oscuro global ===== */
html[data-bs-theme="dark"] {
  --fx-final-bg: #091321;
  --fx-final-surface: #101b2e;
  --fx-final-surface-2: #142239;
  --fx-final-surface-3: #182842;
  --fx-final-text: #e8eef6;
  --fx-final-muted: #9caec3;
  --fx-final-border: rgba(255,255,255,.11);
  --fx-final-border-strong: rgba(255,255,255,.17);
  --fx-final-hover: rgba(255,255,255,.055);
  --fx-final-accent: #6bc8ef;
  color-scheme: dark;
}

html[data-bs-theme="dark"] body,
html[data-bs-theme="dark"] .wrapper,
html[data-bs-theme="dark"] .page-wrapper,
html[data-bs-theme="dark"] .page-content {
  color: var(--fx-final-text) !important;
  background-color: var(--fx-final-bg) !important;
}

html[data-bs-theme="dark"] body {
  background-image:
    radial-gradient(760px 330px at 5% -2%, rgba(40,183,243,.08), transparent 64%),
    linear-gradient(180deg, #0b1626 0%, var(--fx-final-bg) 260px, var(--fx-final-bg) 100%) !important;
}

/* Superficies comunes */
html[data-bs-theme="dark"] :is(
  .card,
  .panel,
  .card-body,
  .card-header,
  .card-footer,
  .table-wrap,
  .list-group-item,
  .accordion-item,
  .accordion-body,
  .accordion-header,
  .offcanvas,
  .popover,
  .toast,
  .dropdown-menu,
  .dropdown-productos,
  .suggestions,
  .summary-card,
  .summary-head,
  .summary-body,
  .summary-footer,
  .summary-empty,
  .fx-cart-total-stack
) {
  color: var(--fx-final-text) !important;
  background-color: var(--fx-final-surface) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] :is(.bg-white, .bg-light, .text-bg-light) {
  color: var(--fx-final-text) !important;
  background-color: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] :is(.text-dark, .text-body, .text-primary) {
  color: var(--fx-final-text) !important;
}

html[data-bs-theme="dark"] :is(.text-secondary, .text-muted, .muted, small, .small.text-secondary) {
  color: var(--fx-final-muted) !important;
}

/* Tablas: nunca fondo claro con texto claro */
html[data-bs-theme="dark"] .table {
  --bs-table-bg: var(--fx-final-surface);
  --bs-table-color: var(--fx-final-text);
  --bs-table-border-color: var(--fx-final-border);
  --bs-table-striped-bg: rgba(255,255,255,.025);
  --bs-table-striped-color: var(--fx-final-text);
  --bs-table-hover-bg: var(--fx-final-hover);
  --bs-table-hover-color: var(--fx-final-text);
  width: 100%;
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] .table > :not(caption) > * > * {
  color: var(--fx-final-text) !important;
  background-color: transparent !important;
  border-color: var(--fx-final-border) !important;
  box-shadow: none !important;
}

html[data-bs-theme="dark"] .table thead,
html[data-bs-theme="dark"] .table thead tr,
html[data-bs-theme="dark"] .table thead th,
html[data-bs-theme="dark"] .table-light,
html[data-bs-theme="dark"] .table-light > * {
  color: var(--fx-final-muted) !important;
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] .table tbody tr:hover > * {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-hover) !important;
}

/* Formularios y buscadores */
html[data-bs-theme="dark"] :is(
  .form-control,
  .form-select,
  .input-group-text,
  .form-control-sm,
  .form-select-sm,
  .search-box input,
  .search-wrap input
) {
  color: var(--fx-final-text) !important;
  background-color: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border-strong) !important;
  caret-color: var(--fx-final-text) !important;
}

html[data-bs-theme="dark"] :is(.form-control, .search-box input, .search-wrap input)::placeholder {
  color: #8295aa !important;
  opacity: 1 !important;
}

html[data-bs-theme="dark"] :is(.form-control:disabled, .form-select:disabled, .form-control[readonly]) {
  color: #8fa1b5 !important;
  background-color: #0d1828 !important;
  opacity: 1 !important;
}

html[data-bs-theme="dark"] .btn-light,
html[data-bs-theme="dark"] .btn-outline-secondary {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border-strong) !important;
}

html[data-bs-theme="dark"] .btn-light:hover,
html[data-bs-theme="dark"] .btn-outline-secondary:hover {
  color: #fff !important;
  background: var(--fx-final-surface-3) !important;
  border-color: rgba(107,200,239,.35) !important;
}

/* Modales Bootstrap, modales propios y SweetAlert */
html[data-bs-theme="dark"] :is(
  .modal-content,
  .modal-p,
  .swal2-popup,
  .swal2-html-container,
  .swal2-title
) {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] :is(.modal-header, .modal-body) {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] .modal-footer {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] :is(.modal-title, .modal-p h1, .modal-p h2, .modal-p h3, .modal-p h4, .modal-p h5, .modal-p h6, .swal2-title) {
  color: var(--fx-final-text) !important;
}

html[data-bs-theme="dark"] :is(.modal-body label, .modal-p label, .swal2-html-container, .modal-body p, .modal-p p) {
  color: var(--fx-final-muted) !important;
}

html[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(1.8) !important;
  opacity: .85 !important;
}

html[data-bs-theme="dark"] .modal-overlay {
  background: rgba(1, 7, 16, .72) !important;
}

/* Dropdowns y resultados de buscadores */
html[data-bs-theme="dark"] :is(.dropdown-menu, .dropdown-productos, .suggestions) :is(.dropdown-item, .item-prod, .suggestion-item, li, a) {
  color: var(--fx-final-text) !important;
  background-color: transparent !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] :is(.dropdown-menu, .dropdown-productos, .suggestions) :is(.dropdown-item, .item-prod, .suggestion-item, li, a):hover,
html[data-bs-theme="dark"] :is(.dropdown-menu, .dropdown-productos, .suggestions) :is(.selected, .active) {
  color: #fff !important;
  background: rgba(40,183,243,.12) !important;
}

/* ===== V2/V3: catálogo, productos y carrito completamente oscuros ===== */
html[data-bs-theme="dark"] body.fx-pos-family {
  --pos-bg: var(--fx-final-bg) !important;
  --pos-surface: var(--fx-final-surface) !important;
  --pos-surface-soft: var(--fx-final-surface-2) !important;
  --pos-text: var(--fx-final-text) !important;
  --pos-muted: var(--fx-final-muted) !important;
  --pos-line: var(--fx-final-border) !important;
  --pos-line-strong: var(--fx-final-border-strong) !important;
  color: var(--fx-final-text) !important;
  background: var(--fx-final-bg) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family :is(
  .pos-shell,
  .pos-left,
  .pos-right,
  .card-detail,
  .card-detail > .card-body,
  .catalogo-wrap,
  .catalog-toolbar,
  #prodGrid,
  .prod-card,
  .prod-card .body,
  .summary-card,
  .summary-head,
  .summary-body,
  .summary-footer,
  .fx-cart-total-stack,
  .footer-totals,
  .mini-cart,
  .mini-item
) {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family .prod-card .img-wrap,
html[data-bs-theme="dark"] body.fx-pos-family .prod-card .img-placeholder,
html[data-bs-theme="dark"] body.fx-pos-family .prod-card .img-wrap.no-photo {
  background: var(--fx-final-surface-3) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family :is(.prod-card .name, .prod-card .priceVal, .summary-title, .mi-name, .mi-total, #grandTot, .footer-totals strong) {
  color: var(--fx-final-text) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family :is(.prod-card .meta, .summary-sub, .mi-meta, .summary-empty) {
  color: var(--fx-final-muted) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family :is(.prod-card .uomPick, .catalog-toolbar .form-select, .catalog-toolbar .form-control) {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border-strong) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family .cat-chip:not(.active) {
  color: var(--fx-final-muted) !important;
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family .cat-chip.active,
html[data-bs-theme="dark"] body.fx-pos-family .segmented button.active {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  background: #0f6cb2 !important;
  border-color: #0f6cb2 !important;
}

html[data-bs-theme="dark"] body.fx-page-facturav3 .topbar,
html[data-bs-theme="dark"] body.fx-page-facturav3 .topbar .navbar {
  color: var(--fx-final-text) !important;
  background: #0d192a !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] body.fx-page-facturav3 .fx-topbar-client-search {
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border-strong) !important;
}

html[data-bs-theme="dark"] body.fx-page-facturav3 .fx-topbar-client-search .form-control {
  color: var(--fx-final-text) !important;
  background: transparent !important;
}

html[data-bs-theme="dark"] body.fx-page-facturav3 .fx-topbar-client-search > .fx-client-balances {
  color: var(--fx-final-muted) !important;
  border-left-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] body.fx-page-facturav3 .fx-topbar-client-search > .fx-client-balances b {
  color: #dceaff !important;
}

html[data-bs-theme="dark"] body.fx-page-facturav3 .fx-topbar-client-search #aFavorVal {
  color: #5dd6aa !important;
}

/* Configuración POS y modales POS: elimina cualquier fondo blanco residual. */
html[data-bs-theme="dark"] body.fx-pos-family :is(
  #posSettingsModal .modal-content,
  #posSettingsModal .modal-header,
  #posSettingsModal .modal-body,
  #modalTopSettings > .modal-p,
  #modalPrice > .modal-p,
  #modalStock > .modal-p,
  #modalUbic > .modal-p,
  #modalBuscarFacturas > .modal-p,
  #modalCarrito > .modal-p,
  #modalPagos > .modal-p,
  #modalPrintFormat > .modal-p,
  #modalClientePos > .modal-p
) {
  color: var(--fx-final-text) !important;
  background: var(--fx-final-surface) !important;
  border-color: var(--fx-final-border) !important;
}

html[data-bs-theme="dark"] body.fx-pos-family :is(#posSettingsModal .modal-footer, #modalPagos .modal-footer) {
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border) !important;
}

/* En móvil el bloque de saldos puede bajar por espacio, sin romper el buscador. */
@media (max-width: 991.98px) {
  body.fx-pos-family.fx-page-facturav3 #ventasToolbarMobileHost .fx-topbar-client-search {
    height: auto !important;
    max-height: none !important;
  }
}

/* ===== V3 · override final con especificidad superior al CSS inline historico ===== */
@media (min-width: 992px) {
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 36px !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .ventas-toolbar {
    width: 100% !important;
    min-width: 0 !important;
    height: 36px !important;
    display: grid !important;
    grid-template-columns: auto minmax(430px, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    display: flex !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    align-items: center !important;
    gap: 0 !important;
    row-gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap {
    flex: 1 1 auto !important;
    grid-column: auto !important;
    grid-row: auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 34px !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search > .fx-client-balances {
    position: static !important;
    flex: 0 0 auto !important;
    grid-column: auto !important;
    grid-row: auto !important;
    width: auto !important;
    min-width: auto !important;
    max-width: none !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    margin: 0 !important;
    padding: 0 9px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
    overflow: visible !important;
    font-size: 9.6px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    text-align: left !important;
    border-left: 1px solid var(--pos-line, #e1e7ee) !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search > .fx-client-balances span {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    overflow: visible !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search > .fx-client-balances b {
    font-size: 9.7px !important;
    line-height: 1 !important;
  }
}

/* ===== V3 · saldos dentro del mismo buscador, despues del nombre y antes de + / x ===== */
@media (min-width: 992px) {
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente {
    width: 100% !important;
    min-width: 0 !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 5px 0 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    overflow: visible !important;
    background: var(--pos-surface, #fff) !important;
    border: 1px solid var(--pos-line-strong, #d1dce7) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente:focus-within {
    border-color: #62bce7 !important;
    box-shadow: 0 0 0 3px var(--pos-focus, rgba(53,184,243,.13)) !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente .form-control {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 135px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 6px 0 2.2rem !important;
    line-height: 34px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances {
    position: static !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 26px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
    overflow: visible !important;
    color: var(--pos-muted, #71839a) !important;
    font-size: 9.6px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    border-left: 1px solid var(--pos-line, #e1e7ee) !important;
    border-right: 1px solid var(--pos-line, #e1e7ee) !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances span {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    margin: 0 !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances b {
    color: var(--pos-navy, #0b2d68) !important;
    font-family: var(--font-mono, "IBM Plex Mono", monospace) !important;
    font-size: 9.7px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > #btnNuevoCliPos,
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > #btnCerrarCli {
    position: static !important;
    flex: 0 0 23px !important;
    width: 23px !important;
    min-width: 23px !important;
    height: 23px !important;
    min-height: 23px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-grid !important;
    place-items: center !important;
  }

  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > #dropdownClientes {
    top: calc(100% + 7px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
}

html[data-bs-theme="dark"] body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente {
  background: var(--fx-final-surface-2) !important;
  border-color: var(--fx-final-border-strong) !important;
}
html[data-bs-theme="dark"] body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances {
  color: var(--fx-final-muted) !important;
  border-color: var(--fx-final-border) !important;
}
html[data-bs-theme="dark"] body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances b {
  color: #dceaff !important;
}
html[data-bs-theme="dark"] body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarInlineHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances #aFavorVal {
  color: #5dd6aa !important;
}

@media (max-width: 991.98px) {
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarMobileHost .fx-topbar-client-search .search-wrap-cliente {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) auto auto !important;
    grid-template-rows: 36px auto !important;
    height: auto !important;
    min-height: 36px !important;
    overflow: visible !important;
  }
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarMobileHost .fx-topbar-client-search .search-wrap-cliente .form-control {
    grid-column: 1 / 2 !important;
    grid-row: 1 !important;
  }
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarMobileHost .fx-topbar-client-search .search-wrap-cliente > #btnNuevoCliPos {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarMobileHost .fx-topbar-client-search .search-wrap-cliente > #btnCerrarCli {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }
  body.pos-page.fx-pos-family.fx-page-facturav3 #ventasToolbarMobileHost .fx-topbar-client-search .search-wrap-cliente > .fx-client-balances {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-height: 18px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 3px 2px 0 !important;
    border: 0 !important;
  }
}

/* ======================================================================
   Flexia final polish 4.0.2 - Dark Mode regression hardening (2026-09-06)
   Scope: color/contrast/font inheritance only. No search/icon geometry.
   ====================================================================== */

/* Preserve icon-font glyphs even inside POS families that force UI fonts. */
body .bx,
body.fx-pos-family .bx,
body.fx-pos-family .topbar .bx,
body[data-pos-view="touch"] .bx,
body[data-pos-view="touch"] .topbar .bx {
  font-family: boxicons !important;
  font-weight: 400 !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-transform: none !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* V2/V3 user chip: dark hover should be a subtle elevation, never white. */
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav2 .topbar .user-block:hover,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav2 .topbar .user-block:focus,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav3 .topbar .user-block:hover,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav3 .topbar .user-block:focus {
  background: rgba(107, 200, 239, 0.08) !important;
  border-color: var(--fx-final-border, #2b3a4f) !important;
  color: var(--fx-final-text, #e8eef6) !important;
  box-shadow: none !important;
}
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav2 .topbar .user-block:hover .name,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav2 .topbar .user-block:focus .name,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav3 .topbar .user-block:hover .name,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav3 .topbar .user-block:focus .name,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav2 .topbar .user-block:hover .fx-user-chevron,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav2 .topbar .user-block:focus .fx-user-chevron,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav3 .topbar .user-block:hover .fx-user-chevron,
html[data-bs-theme="dark"] body.fx-pos-family.fx-page-facturav3 .topbar .user-block:focus .fx-user-chevron {
  color: var(--fx-final-text, #e8eef6) !important;
}

/* Factura V1 detail controls: U.M., cantidad y precio. */
html[data-bs-theme="dark"] body.fx-page-factura #detalleBody :is(.uomSel, .qty, .unit, .form-control, .form-select) {
  background-color: #142239 !important;
  color: #e8eef6 !important;
  -webkit-text-fill-color: #e8eef6 !important;
  border-color: #34455d !important;
  caret-color: #e8eef6 !important;
  color-scheme: dark;
}
html[data-bs-theme="dark"] body.fx-page-factura #detalleBody :is(.uomSel, .qty, .unit, .form-control, .form-select):focus {
  background-color: #182842 !important;
  color: #f7fbff !important;
  -webkit-text-fill-color: #f7fbff !important;
  border-color: #6bc8ef !important;
  box-shadow: 0 0 0 0.16rem rgba(107, 200, 239, 0.16) !important;
}
html[data-bs-theme="dark"] body.fx-page-factura #detalleBody select option {
  background: #142239 !important;
  color: #e8eef6 !important;
}

/* Operational document forms (NC, purchases, remissions, counts, etc.). */
html[data-bs-theme="dark"] body.fx-operativa :is(.form-control, .form-select, textarea.form-control, input.form-control, select.form-select) {
  background-color: #142239 !important;
  color: #e8eef6 !important;
  -webkit-text-fill-color: #e8eef6 !important;
  border-color: #34455d !important;
  caret-color: #e8eef6 !important;
  color-scheme: dark;
}
html[data-bs-theme="dark"] body.fx-operativa :is(.form-control, .form-select, textarea.form-control, input.form-control, select.form-select)::placeholder {
  color: #93a4ba !important;
  -webkit-text-fill-color: #93a4ba !important;
  opacity: 1 !important;
}
html[data-bs-theme="dark"] body.fx-operativa :is(.form-control, .form-select, textarea.form-control, input.form-control, select.form-select):focus {
  background-color: #182842 !important;
  color: #f7fbff !important;
  -webkit-text-fill-color: #f7fbff !important;
  border-color: #6bc8ef !important;
  box-shadow: 0 0 0 0.16rem rgba(107, 200, 239, 0.16) !important;
}
html[data-bs-theme="dark"] body.fx-operativa :is(.form-control, .form-select, textarea.form-control, input.form-control, select.form-select):disabled,
html[data-bs-theme="dark"] body.fx-operativa :is(.form-control, .form-select, textarea.form-control, input.form-control, select.form-select)[readonly] {
  background-color: #101b2d !important;
  color: #8ea0b8 !important;
  -webkit-text-fill-color: #8ea0b8 !important;
  border-color: #27384e !important;
  opacity: 1 !important;
}
html[data-bs-theme="dark"] body.fx-operativa select option {
  background: #142239 !important;
  color: #e8eef6 !important;
}

/* Legacy pages also contain raw inputs/selects without Bootstrap classes. */
html[data-bs-theme="dark"] body.fx-legacy-page input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]),
html[data-bs-theme="dark"] body.fx-legacy-page select,
html[data-bs-theme="dark"] body.fx-legacy-page textarea {
  background-color: #142239 !important;
  color: #e8eef6 !important;
  -webkit-text-fill-color: #e8eef6 !important;
  border-color: #34455d !important;
  caret-color: #e8eef6 !important;
  color-scheme: dark;
}
html[data-bs-theme="dark"] body.fx-legacy-page input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"])::placeholder,
html[data-bs-theme="dark"] body.fx-legacy-page textarea::placeholder {
  color: #93a4ba !important;
  -webkit-text-fill-color: #93a4ba !important;
  opacity: 1 !important;
}
html[data-bs-theme="dark"] body.fx-legacy-page input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]):focus,
html[data-bs-theme="dark"] body.fx-legacy-page select:focus,
html[data-bs-theme="dark"] body.fx-legacy-page textarea:focus {
  background-color: #182842 !important;
  color: #f7fbff !important;
  -webkit-text-fill-color: #f7fbff !important;
  border-color: #6bc8ef !important;
  box-shadow: 0 0 0 0.16rem rgba(107, 200, 239, 0.16) !important;
}
html[data-bs-theme="dark"] body.fx-legacy-page select option {
  background: #142239 !important;
  color: #e8eef6 !important;
}

/* Native calendar indicator should remain visible on dark inputs. */
html[data-bs-theme="dark"] body.fx-operativa input:is([type="date"], [type="datetime-local"], [type="time"])::-webkit-calendar-picker-indicator,
html[data-bs-theme="dark"] body.fx-legacy-page input:is([type="date"], [type="datetime-local"], [type="time"])::-webkit-calendar-picker-indicator {
  filter: invert(0.86) brightness(1.08);
  opacity: 0.88;
}

/* Document headings: semantic brand blue must not become unreadable navy. */
html[data-bs-theme="dark"] body.fx-operativa .page-content :is(h1, h2, h3, h4, h5, h6).text-primary,
html[data-bs-theme="dark"] body.fx-operativa .page-content > :is(h1, h2, h3, h4, h5, h6),
html[data-bs-theme="dark"] body.fx-page-credito h5.text-primary {
  color: #e8eef6 !important;
  -webkit-text-fill-color: #e8eef6 !important;
}

/* Operational tables: subtle zebra, hover and selected states without white flashes. */
html[data-bs-theme="dark"] body.fx-operativa .table > :not(caption) > * > * {
  color: #e2eaf4 !important;
  border-color: #2d3d52 !important;
}
html[data-bs-theme="dark"] body.fx-operativa .table thead > tr > * {
  background-color: #101b2d !important;
  color: #f1f6fb !important;
}
html[data-bs-theme="dark"] body.fx-operativa .table tbody > tr:not(.table-success):not(.table-warning):not(.table-danger):not(.table-info):nth-child(odd) > * {
  background-color: #111e32 !important;
}
html[data-bs-theme="dark"] body.fx-operativa .table tbody > tr:not(.table-success):not(.table-warning):not(.table-danger):not(.table-info):nth-child(even) > * {
  background-color: #142239 !important;
}
html[data-bs-theme="dark"] body.fx-operativa .table-hover tbody > tr:not(.table-success):not(.table-warning):not(.table-danger):not(.table-info):hover > * {
  background-color: #1a2b46 !important;
  color: #f7fbff !important;
}
html[data-bs-theme="dark"] body.fx-operativa .table tbody > tr:is(.selected, .active, [aria-selected="true"]) > * {
  background-color: #203b57 !important;
  color: #ffffff !important;
}

/* Bootstrap/dropdown/modal surfaces on operational pages. */
html[data-bs-theme="dark"] body.fx-operativa :is(.dropdown-menu, .popover, .modal-content, .offcanvas, .list-group, .list-group-item) {
  background-color: #111e32 !important;
  color: #e8eef6 !important;
  border-color: #2d3d52 !important;
}
html[data-bs-theme="dark"] body.fx-operativa .dropdown-item {
  color: #dce6f1 !important;
}
html[data-bs-theme="dark"] body.fx-operativa .dropdown-item:hover,
html[data-bs-theme="dark"] body.fx-operativa .dropdown-item:focus {
  background-color: #1a2b46 !important;
  color: #ffffff !important;
}

/* Checkbox/radio accents need enough contrast while preserving native geometry. */
html[data-bs-theme="dark"] body.fx-operativa :is(.form-check-input, input[type="checkbox"], input[type="radio"]) {
  border-color: #536981 !important;
}
html[data-bs-theme="dark"] body.fx-operativa .form-check-input:not(:checked) {
  background-color: #142239 !important;
}

/* 4.0.2 final page-by-page QA fixes: color only, no geometry. */
html[data-bs-theme="dark"] body.fx-page-admin-index h1,
html[data-bs-theme="dark"] body.fx-page-admin-index .wrap h1 {
  color: var(--fx-final-text, #e8eef6) !important;
  -webkit-text-fill-color: var(--fx-final-text, #e8eef6) !important;
}
html[data-bs-theme="dark"] body.fx-page-admin-index small {
  color: var(--fx-final-muted, #9fb0c3) !important;
}
html[data-bs-theme="dark"] body.fx-page-admin-index a.card {
  background: var(--fx-final-surface, #101b2e) !important;
  color: var(--fx-final-text, #e8eef6) !important;
  border-color: var(--fx-final-border, #2d3d52) !important;
}

html[data-bs-theme="dark"] body.fx-page-banco-general .table-wrap {
  background: var(--fx-final-surface, #101b2e) !important;
  background-color: var(--fx-final-surface, #101b2e) !important;
  color: var(--fx-final-text, #e8eef6) !important;
  border-color: var(--fx-final-border, #2d3d52) !important;
}

html[data-bs-theme="dark"] body.fx-page-pedido .modal-overlay h4,
html[data-bs-theme="dark"] body.fx-page-venta .modal-overlay h4,
html[data-bs-theme="dark"] body.fx-page-venta #modalPagos h4,
html[data-bs-theme="dark"] body.fx-page-pedido .modal-overlay .close,
html[data-bs-theme="dark"] body.fx-page-venta .modal-overlay .close,
html[data-bs-theme="dark"] body.fx-page-remision .modal-overlay .close,
html[data-bs-theme="dark"] body.fx-page-factura .modal-overlay .close,
html[data-bs-theme="dark"] body.fx-page-facturav2 .modal-overlay .close,
html[data-bs-theme="dark"] body.fx-page-facturav3 .modal-overlay .close {
  color: var(--fx-final-text, #e8eef6) !important;
  -webkit-text-fill-color: var(--fx-final-text, #e8eef6) !important;
}

html[data-bs-theme="dark"] body.fx-page-admin-almacenes h6,
html[data-bs-theme="dark"] body.fx-page-admin-uom-groups h6,
html[data-bs-theme="dark"] body[data-acl-page-id="admin-almacenes"] h6,
html[data-bs-theme="dark"] body[data-acl-page-id="admin-uom-groups"] h6 {
  color: var(--fx-final-text, #e8eef6) !important;
  -webkit-text-fill-color: var(--fx-final-text, #e8eef6) !important;
}
