/* FlexIA · Syndron UI v4
   Capa visual final. No modifica contratos API, cálculos ni lógica de negocio. */
:root{
  --fx-primary:#008cff;
  --fx-primary-rgb:0,140,255;
  --fx-success:#15ca20;
  --fx-danger:#fd3550;
  --fx-warning:#ffc107;
  --fx-info:#0dcaf0;
  --fx-purple:#8833ff;
  --fx-body:#f7f8fa;
  --fx-surface:#fff;
  --fx-surface-2:#f8f9fa;
  --fx-surface-3:#f1f3f5;
  --fx-text:#212529;
  --fx-muted:#7b8288;
  --fx-border:#dee2e6;
  --fx-border-soft:rgba(0,0,0,.075);
  --fx-shadow-sm:0 .125rem .25rem rgba(0,0,0,.075);
  --fx-shadow:0 .3rem .8rem rgba(0,0,0,.08);
  --fx-shadow-lg:0 1rem 3rem rgba(0,0,0,.17);
  --fx-sidebar-width:250px;
  --fx-sidebar-collapsed:70px;
  --fx-topbar-height:60px;
  --fx-footer-height:42px;
  --fx-radius:8px;
  --fx-radius-lg:10px;
  --fx-ease:cubic-bezier(.2,.7,.2,1);
}
html[data-bs-theme="dark"]{
  --fx-body:#15181b;
  --fx-surface:#1d2125;
  --fx-surface-2:#24292e;
  --fx-surface-3:#2a3036;
  --fx-text:#e3e7ea;
  --fx-muted:#a1a9b0;
  --fx-border:#343a40;
  --fx-border-soft:rgba(255,255,255,.08);
  --fx-shadow-sm:0 .125rem .35rem rgba(0,0,0,.22);
  --fx-shadow:0 .35rem 1rem rgba(0,0,0,.26);
  --fx-shadow-lg:0 1.15rem 3.2rem rgba(0,0,0,.42);
}
html,body{min-width:320px;background:var(--fx-body)!important;color:var(--fx-text);}
body,button,input,select,textarea,.tooltip,.popover,.dropdown-menu{font-family:Roboto,"Segoe UI",system-ui,-apple-system,sans-serif!important;}
body{font-size:13px;line-height:1.45;letter-spacing:0;overflow-x:hidden;transition:background-color .18s ease,color .18s ease;}
::selection{background:rgba(var(--fx-primary-rgb),.18)}
a{transition:color .15s ease,background-color .15s ease,opacity .15s ease}

/* Shell: exacto al comportamiento vertical de Syndron */
.wrapper{width:100%;min-height:100vh;position:relative;background:var(--fx-body)!important;}
.topbar{position:fixed!important;top:0;left:var(--fx-sidebar-width)!important;right:0;height:var(--fx-topbar-height)!important;z-index:1040;background:var(--fx-surface)!important;border-bottom:1px solid var(--fx-border-soft)!important;box-shadow:0 1px 4px rgba(0,0,0,.035)!important;transition:left .2s ease,background-color .18s ease!important;}
.topbar .navbar{width:100%;height:var(--fx-topbar-height)!important;padding:0 14px!important;background:transparent!important;}
.mobile-toggle-menu,.fx-theme-toggle{width:42px!important;height:42px!important;min-width:42px!important;padding:0!important;border:0!important;border-radius:50%!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;background:transparent!important;color:var(--fx-text)!important;box-shadow:none!important;transition:.18s ease!important;}
.mobile-toggle-menu:hover,.mobile-toggle-menu:focus,.fx-theme-toggle:hover,.fx-theme-toggle:focus{background:rgba(var(--fx-primary-rgb),.09)!important;color:var(--fx-primary)!important;outline:0!important;}
.mobile-toggle-menu i,.fx-theme-toggle i{font-size:22px!important;line-height:1!important;}
.fx-theme-toggle i{display:block!important;position:static!important;transform:none!important;opacity:1!important;}
.topbar .top-menu{margin-left:auto!important;margin-right:0!important;}
.topbar .navbar-nav{gap:1px!important;}
.topbar .nav-link{color:var(--fx-text)!important;}
.topbar .user-block{display:flex!important;align-items:center!important;gap:9px!important;min-height:46px;padding:5px 8px!important;border-radius:8px!important;text-decoration:none!important;}
.topbar .user-block:hover{background:rgba(var(--fx-primary-rgb),.06)!important;}
.topbar .user-img{width:36px!important;height:36px!important;border-radius:50%!important;object-fit:cover!important;background:var(--fx-surface-2)!important;border:1px solid var(--fx-border-soft)!important;}
.topbar .user-block .meta{display:flex;flex-direction:column;line-height:1.15;min-width:0;}
.topbar .user-block .name{font-size:13px!important;font-weight:500!important;color:var(--fx-text)!important;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.topbar .user-block .sub{font-size:11px!important;color:var(--fx-muted)!important;margin-top:3px;}
.fx-user-chevron{font-size:17px;color:var(--fx-muted)!important;}
.fx-user-menu{min-width:210px!important;}
body:not(.pos-page) .page-wrapper{margin-top:var(--fx-topbar-height)!important;margin-left:var(--fx-sidebar-width)!important;padding-top:0!important;min-height:calc(100vh - var(--fx-topbar-height) - var(--fx-footer-height));background:var(--fx-body)!important;transition:margin-left .2s ease!important;}
body:not(.pos-page) .page-content{max-width:100%!important;padding:8px 18px 52px!important;animation:fx-content-in .16s ease both;}
.page-footer{left:var(--fx-sidebar-width)!important;height:var(--fx-footer-height)!important;min-height:var(--fx-footer-height)!important;padding:0 16px!important;display:flex!important;align-items:center!important;justify-content:center!important;background:var(--fx-surface)!important;color:var(--fx-muted)!important;border-top:1px solid var(--fx-border-soft)!important;box-shadow:none!important;transition:left .2s ease!important;}
.page-footer p{margin:0!important;font-size:11px!important;line-height:1!important;}
@keyframes fx-content-in{from{opacity:.72;transform:translateY(3px)}to{opacity:1;transform:none}}
@media (min-width:1025px){
  .wrapper.toggled .topbar{left:var(--fx-sidebar-collapsed)!important;}
  body:not(.pos-page) .wrapper.toggled .page-wrapper{margin-left:var(--fx-sidebar-collapsed)!important;}
  .wrapper.toggled .page-footer{left:var(--fx-sidebar-collapsed)!important;}
}
@media (max-width:1024px){
  .topbar{left:0!important;}
  body:not(.pos-page) .page-wrapper{margin-left:0!important;}
  .page-footer{left:0!important;}
  body:not(.pos-page) .wrapper.toggled .page-wrapper{margin-left:0!important;}
  .wrapper.toggled .page-footer{left:0!important;}
  .topbar .navbar{padding:0 9px!important;}
  body:not(.pos-page) .page-content{padding:7px 10px 48px!important;}
}

/* Títulos: una sola jerarquía, el topbar ya no los repite */
.page-content>div:first-child.d-flex.justify-content-between,
.page-content>div:first-child.d-flex.align-items-center,
.page-content>.toolbar:first-child,
.page-content>.hero:first-child,
.page-content>.fx-hero:first-child,
.page-content>section:first-child>div:first-child.d-flex{
  margin-top:0!important;
}
.page-content h1,.page-content h2,.page-content h3,.page-content h4,.page-content h5,.page-content h6{color:var(--fx-text);}
.page-content>div:first-child h1,.page-content>div:first-child h2,.page-content>div:first-child h3,
.page-content>div:first-child h4,.page-content>div:first-child h5,
.page-content>.toolbar h1,.page-content>.toolbar h2,.page-content>.toolbar h3,.page-content>.toolbar h4,.page-content>.toolbar h5,
.page-content>section:first-child h1,.page-content>section:first-child h2,.page-content>section:first-child h3{
  margin-top:0!important;margin-bottom:0!important;font-size:18px!important;font-weight:500!important;letter-spacing:-.01em!important;line-height:1.25!important;
}
.fx-page-subtitle,.page-content .subtitle,.page-content .lead{color:var(--fx-muted)!important;}
.text-secondary,.text-muted,.muted,.hint{color:var(--fx-muted)!important;}

/* Cards / paneles */
body:not(.pos-page) .page-content .card,
body:not(.pos-page) .page-content .panel,
body:not(.pos-page) .page-content .box,
body:not(.pos-page) .page-content .table-wrap,
body:not(.pos-page) .page-content .shell,
body:not(.pos-page) .page-content .fx-panel{
  background:var(--fx-surface)!important;color:var(--fx-text)!important;border:1px solid var(--fx-border-soft)!important;border-radius:var(--fx-radius)!important;box-shadow:var(--fx-shadow-sm)!important;
}
body:not(.pos-page) .page-content .card{overflow:visible;}
body:not(.pos-page) .page-content .card-header{min-height:46px;padding:.7rem .9rem!important;background:var(--fx-surface)!important;border-bottom:1px solid var(--fx-border-soft)!important;color:var(--fx-text)!important;}
body:not(.pos-page) .page-content .card-body{padding:.9rem!important;}
body:not(.pos-page) .page-content .card-footer{padding:.7rem .9rem!important;background:var(--fx-surface-2)!important;border-top:1px solid var(--fx-border-soft)!important;}
body:not(.pos-page) .page-content .card-title,body:not(.pos-page) .page-content .card-header h6{font-size:13.5px!important;font-weight:500!important;color:var(--fx-text)!important;}

/* Formularios */
body:not(.pos-page) .page-content .form-label,.modal .form-label{margin-bottom:4px!important;font-size:11px!important;font-weight:500!important;letter-spacing:.01em!important;text-transform:none!important;color:var(--fx-muted)!important;}
body:not(.pos-page) .page-content .form-control,
body:not(.pos-page) .page-content .form-select,
body:not(.pos-page) .page-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body:not(.pos-page) .page-content textarea,
body:not(.pos-page) .page-content select,
.modal .form-control,.modal .form-select,.modal textarea,.modal input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),.modal select{
  min-height:36px!important;border-radius:5px!important;border:1px solid var(--fx-border)!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;font-size:12.5px!important;box-shadow:none!important;}
body:not(.pos-page) .page-content textarea,.modal textarea{min-height:74px!important;}
body:not(.pos-page) .page-content .form-control:focus,body:not(.pos-page) .page-content .form-select:focus,
body:not(.pos-page) .page-content input:focus,body:not(.pos-page) .page-content textarea:focus,body:not(.pos-page) .page-content select:focus,
.modal .form-control:focus,.modal .form-select:focus,.modal input:focus,.modal textarea:focus,.modal select:focus{
  border-color:rgba(var(--fx-primary-rgb),.7)!important;box-shadow:0 0 0 .16rem rgba(var(--fx-primary-rgb),.12)!important;outline:0!important;}
body:not(.pos-page) .page-content .input-group-text,.modal .input-group-text{min-height:36px!important;border-color:var(--fx-border)!important;background:var(--fx-surface-2)!important;color:var(--fx-muted)!important;border-radius:5px!important;}
body:not(.pos-page) .page-content .input-group>.input-group-text:first-child,.modal .input-group>.input-group-text:first-child{border-radius:5px 0 0 5px!important;}
body:not(.pos-page) .page-content .input-group>.form-control:last-child,body:not(.pos-page) .page-content .input-group>.form-select:last-child,.modal .input-group>.form-control:last-child,.modal .input-group>.form-select:last-child{border-radius:0 5px 5px 0!important;}
.form-check-input:checked{background-color:var(--fx-primary)!important;border-color:var(--fx-primary)!important;}
.form-text{font-size:11px!important;color:var(--fx-muted)!important;}

/* Botones: consistentes con Syndron */
.btn{min-height:34px;border-radius:5px!important;font-size:12px!important;font-weight:500!important;display:inline-flex;align-items:center;justify-content:center;gap:4px;box-shadow:none!important;transition:transform .12s ease,background-color .15s ease,border-color .15s ease,color .15s ease!important;}
.btn:hover:not(:disabled){transform:translateY(-1px);}
.btn-sm{min-height:30px!important;font-size:11.5px!important;}
.btn-lg{min-height:42px!important;font-size:13px!important;}
.btn-primary{background:var(--fx-primary)!important;border-color:var(--fx-primary)!important;color:#fff!important;}
.btn-primary:hover{background:#087fdc!important;border-color:#087fdc!important;}
.btn-light,.btn-secondary,.btn-outline-secondary{background:var(--fx-surface-2)!important;border-color:var(--fx-border)!important;color:var(--fx-text)!important;}
.btn-light:hover,.btn-secondary:hover,.btn-outline-secondary:hover{background:var(--fx-surface-3)!important;color:var(--fx-text)!important;}
.btn-outline-primary{background:transparent!important;border-color:rgba(var(--fx-primary-rgb),.55)!important;color:var(--fx-primary)!important;}
.btn-outline-primary:hover{background:var(--fx-primary)!important;color:#fff!important;}
.btn-danger,.btn-outline-danger:hover{background:var(--fx-danger)!important;border-color:var(--fx-danger)!important;color:#fff!important;}

/* Tablas: misma identidad en notas, remisiones, compras, reportes y administración */
body:not(.pos-page) .page-content .table-responsive{border-radius:6px;}
body:not(.pos-page) .page-content table{margin-bottom:0!important;color:var(--fx-text)!important;border-color:var(--fx-border-soft)!important;font-size:12px!important;}
body:not(.pos-page) .page-content table thead th{
  padding:9px 10px!important;background:var(--fx-surface-2)!important;color:var(--fx-muted)!important;border-color:var(--fx-border-soft)!important;font-size:10.5px!important;font-weight:600!important;letter-spacing:.035em!important;text-transform:uppercase!important;white-space:nowrap;vertical-align:middle!important;}
body:not(.pos-page) .page-content table tbody td{padding:9px 10px!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;border-color:var(--fx-border-soft)!important;vertical-align:middle!important;}
body:not(.pos-page) .page-content table tbody tr:nth-child(even)>td{background:color-mix(in srgb,var(--fx-surface) 96%,var(--fx-primary) 4%)!important;}
body:not(.pos-page) .page-content table tbody tr:hover>td{background:rgba(var(--fx-primary-rgb),.055)!important;}
body:not(.pos-page) .page-content table .btn{white-space:nowrap;}
body:not(.pos-page) .page-content .table> :not(caption)>*>*{box-shadow:none!important;}

/* Tabs / badges / alerts */
.nav-tabs{border-bottom-color:var(--fx-border-soft)!important;gap:2px;}
.nav-tabs .nav-link{border:0!important;border-bottom:2px solid transparent!important;border-radius:0!important;color:var(--fx-muted)!important;font-size:12px!important;font-weight:500!important;padding:.65rem .8rem!important;}
.nav-tabs .nav-link:hover{color:var(--fx-primary)!important;background:rgba(var(--fx-primary-rgb),.04)!important;}
.nav-tabs .nav-link.active{color:var(--fx-primary)!important;background:transparent!important;border-bottom-color:var(--fx-primary)!important;}
.badge{font-size:10.5px!important;font-weight:500!important;border-radius:4px!important;padding:.38em .55em!important;}
.alert{border-radius:6px!important;font-size:12px!important;}

/* Dropdowns */
.dropdown-menu{padding:.4rem!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;border:1px solid var(--fx-border-soft)!important;border-radius:7px!important;box-shadow:var(--fx-shadow-lg)!important;}
.dropdown-item{padding:.52rem .7rem!important;border-radius:5px!important;color:var(--fx-text)!important;font-size:12.5px!important;}
.dropdown-item:hover,.dropdown-item:focus{background:rgba(var(--fx-primary-rgb),.08)!important;color:var(--fx-primary)!important;}
.dropdown-divider{border-color:var(--fx-border-soft)!important;}

/* Modal rules: normal centered by default. Listados completos; panel lateral solo editor de producto. */
.modal{--bs-modal-border-radius:8px;}
.modal-backdrop{z-index:1080!important;}
.modal-backdrop.show{opacity:.42!important;}
.modal.show{z-index:1090!important;}
.modal-dialog{margin-top:1rem;margin-bottom:1rem;}
.modal.show .modal-dialog{animation:fx-modal-in .18s var(--fx-ease) both;}
@keyframes fx-modal-in{from{opacity:0;transform:translateY(6px) scale(.992)}to{opacity:1;transform:none}}
.modal-content{background:var(--fx-surface)!important;color:var(--fx-text)!important;border:1px solid var(--fx-border-soft)!important;border-radius:8px!important;box-shadow:0 1.25rem 4rem rgba(0,0,0,.24)!important;overflow:hidden!important;}
.modal-header{min-height:54px!important;padding:.8rem 1rem!important;display:flex!important;align-items:center!important;gap:12px!important;background:var(--fx-surface)!important;border-bottom:1px solid var(--fx-border-soft)!important;}
.modal-title{margin:0!important;font-size:14px!important;font-weight:500!important;color:var(--fx-text)!important;}
.modal-header>.btn-close,.modal-header>div+.btn-close,.modal-header h5+.btn-close,.modal-header h6+.btn-close{margin-left:auto!important;margin-right:0!important;flex:0 0 auto!important;opacity:.62!important;}
html[data-bs-theme="dark"] .btn-close{filter:invert(1) grayscale(100%) brightness(180%);}
.modal-body{padding:1rem!important;background:var(--fx-surface)!important;}
.modal-footer{padding:.7rem 1rem!important;background:var(--fx-surface-2)!important;border-top:1px solid var(--fx-border-soft)!important;gap:6px!important;}
.fx-modal-kicker{margin-bottom:2px;color:var(--fx-muted);font-size:10px;font-weight:500;text-transform:uppercase;letter-spacing:.07em;}
.fx-choice-card{min-height:58px;padding:10px 12px;display:flex;align-items:center;gap:8px;border:1px solid var(--fx-border);border-radius:6px;background:var(--fx-surface-2);cursor:pointer;}
.fx-choice-card:hover{border-color:rgba(var(--fx-primary-rgb),.42);background:rgba(var(--fx-primary-rgb),.05);}
.fx-choice-card i{font-size:18px;color:var(--fx-primary);}
/* Search/list dialogs must use the screen, not a side sheet. */
.modal.fx-modal-list .modal-dialog{width:min(1460px,96vw)!important;max-width:min(1460px,96vw)!important;height:min(88vh,900px)!important;}
.modal.fx-modal-list .modal-content{height:100%!important;}
.modal.fx-modal-list .modal-body{overflow:auto!important;min-height:0!important;}
.modal.fx-modal-list .table-responsive{max-height:calc(88vh - 170px)!important;overflow:auto!important;}
/* Editor lateral: reservado únicamente a formularios largos de producto. */
@media (min-width:992px){
  .modal.fx-modal-product-editor .modal-dialog{width:min(760px,94vw)!important;max-width:min(760px,94vw)!important;height:100vh!important;min-height:100vh!important;margin:0 0 0 auto!important;display:flex!important;align-items:stretch!important;transform:none!important;}
  .modal.fx-modal-product-editor .modal-content{height:100vh!important;max-height:100vh!important;border-radius:8px 0 0 8px!important;border-top:0!important;border-right:0!important;border-bottom:0!important;}
  .modal.fx-modal-product-editor .modal-body{overflow:auto!important;flex:1 1 auto!important;}
}
/* Confirmaciones siempre arriba del modal que las originó. */
.modal[id*="confirm" i],.modal[id*="confirmar" i]{z-index:1130!important;}
body .modal-overlay[id*="confirm" i],body #modalConfirm{z-index:42000!important;background:rgba(0,0,0,.46)!important;}
body #modalConfirm>.card,body .modal-overlay[id*="confirm" i]>.card{background:var(--fx-surface)!important;color:var(--fx-text)!important;border:1px solid var(--fx-border-soft)!important;box-shadow:var(--fx-shadow-lg)!important;}
.swal2-container{z-index:60000!important;}
.toast-container{z-index:61000!important;}

/* KPIs y reportes */
.kpi-strip{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(170px,1fr))!important;gap:10px!important;}
.kpi-strip>*{min-width:0!important;background:var(--fx-surface)!important;border:1px solid var(--fx-border-soft)!important;border-radius:7px!important;box-shadow:var(--fx-shadow-sm)!important;padding:12px 14px!important;}
.kpi-strip .label,.kpi-strip small{color:var(--fx-muted)!important;font-size:10.5px!important;}
.kpi-strip .value,.kpi-strip strong{color:var(--fx-text)!important;font-size:18px!important;font-weight:500!important;}
.hero,.fx-hero{background:var(--fx-surface)!important;border:1px solid var(--fx-border-soft)!important;border-radius:8px!important;box-shadow:var(--fx-shadow-sm)!important;}
.action-bar{background:transparent!important;border:0!important;box-shadow:none!important;padding-left:0!important;padding-right:0!important;}

/* Administración: listado + ficha visualmente alineados */
body[class*="fx-page-admin-"] .page-content>.toolbar{min-height:44px;margin-bottom:10px!important;display:flex!important;align-items:center!important;gap:10px!important;}
body[class*="fx-page-admin-"] .page-content>.row.g-3{align-items:stretch!important;}
body[class*="fx-page-admin-"] .page-content>.row.g-3>[class*="col-"]>.card{height:100%;}
body[class*="fx-page-admin-"] .toolbar .btn{margin-left:auto;}

/* Compras/NC/remisiones/recuento/traslados: cabecera compacta + tabla protagonista */
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .page-content>div:first-child.d-flex{min-height:42px;margin-bottom:10px!important;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-compact{margin-bottom:10px!important;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-compact .card-body{padding:.75rem .85rem!important;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-detail{margin-bottom:10px!important;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-detail .table-responsive{max-height:52vh;overflow:auto;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-detail table thead{position:sticky;top:0;z-index:2;}

/* Clientes/proveedores: mantener su flujo, solo reforzar consistencia */
body.fx-page-clientes #clientes-page,body.fx-page-proveedores #proveedores-page{padding-top:0!important;}
body.fx-page-clientes #clientes-page>.d-flex:first-child,body.fx-page-proveedores #proveedores-page>.d-flex:first-child{margin-bottom:10px!important;}

/* Factura/POS: NO tocar distribución ni visibilidad. Solo identidad visual. */
body.pos-page{font-family:Roboto,"Segoe UI",sans-serif!important;background:var(--fx-body)!important;color:var(--fx-text)!important;}
body.pos-page .card,body.pos-page .panel,body.pos-page .box{border-color:var(--fx-border-soft)!important;box-shadow:var(--fx-shadow-sm)!important;}
body.pos-page .btn{border-radius:5px!important;font-family:Roboto,"Segoe UI",sans-serif!important;}
body.pos-page .form-control,body.pos-page .form-select,body.pos-page input,body.pos-page textarea,body.pos-page select{border-radius:5px!important;font-family:Roboto,"Segoe UI",sans-serif!important;}
body.pos-page .modal-content{background:var(--fx-surface)!important;color:var(--fx-text)!important;}
html[data-bs-theme="dark"] body.pos-page .modal-content,html[data-bs-theme="dark"] body.pos-page .card,html[data-bs-theme="dark"] body.pos-page .panel{background:var(--fx-surface)!important;color:var(--fx-text)!important;}
/* Factura v3: importante: no se cambia grid, display, overflow ni alturas de sus zonas operativas. */
body.fx-page-facturav3 .page-wrapper,body.fx-page-facturav2 .page-wrapper,body.fx-page-factura .page-wrapper{background:var(--fx-body)!important;}

/* Legacy pedido/remisión/venta: piel común sin modificar grid */
body.fx-legacy-page{background:var(--fx-body)!important;color:var(--fx-text)!important;}
body.fx-legacy-page .top-bar{background:var(--fx-surface)!important;color:var(--fx-text)!important;border-bottom:1px solid var(--fx-border-soft)!important;box-shadow:0 1px 4px rgba(0,0,0,.04)!important;}
body.fx-legacy-page .card,body.fx-legacy-page .panel{background:var(--fx-surface)!important;color:var(--fx-text)!important;border-color:var(--fx-border-soft)!important;box-shadow:var(--fx-shadow-sm)!important;border-radius:8px!important;}
body.fx-legacy-page table{color:var(--fx-text)!important;}
body.fx-legacy-page table thead th{background:var(--fx-surface-2)!important;color:var(--fx-muted)!important;}
body.fx-legacy-page .modal-overlay{background:rgba(0,0,0,.44)!important;}
body.fx-legacy-page .modal-overlay>.card{background:var(--fx-surface)!important;color:var(--fx-text)!important;}

/* Dashboard */
.fx-dashboard-hero{position:relative;overflow:hidden;padding:16px 18px;margin-bottom:12px;background:linear-gradient(135deg,#087be7 0%,#008cff 55%,#0dcaf0 100%)!important;color:#fff!important;border:0!important;border-radius:9px!important;box-shadow:0 .45rem 1.2rem rgba(0,140,255,.20)!important;}
.fx-dashboard-hero:after{content:"";position:absolute;width:220px;height:220px;border:38px solid rgba(255,255,255,.08);border-radius:50%;right:-78px;top:-106px;pointer-events:none;}
.fx-dashboard-hero h1,.fx-dashboard-hero h2,.fx-dashboard-hero p,.fx-dashboard-hero .text-secondary{color:#fff!important;}
.fx-dashboard-hero h1{font-size:20px!important;font-weight:500!important;}
.fx-dashboard-hero .fx-hero-meta{display:flex;flex-wrap:wrap;gap:7px;margin-top:9px;}
.fx-dashboard-hero .fx-hero-chip{display:inline-flex;align-items:center;gap:5px;padding:5px 8px;border:1px solid rgba(255,255,255,.2);border-radius:5px;background:rgba(255,255,255,.10);font-size:11px;color:#fff;}
.fx-kpi-card{position:relative;overflow:hidden;height:100%;}
.fx-kpi-card .card-body{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:13px 14px!important;}
.fx-kpi-label{font-size:10.5px;color:var(--fx-muted);margin-bottom:5px;}
.fx-kpi-value{font-size:20px;font-weight:500;letter-spacing:-.025em;color:var(--fx-text);line-height:1.15;}
.fx-kpi-note{margin-top:4px;font-size:10.5px;color:var(--fx-muted);}
.fx-kpi-icon{width:42px;height:42px;min-width:42px;display:grid;place-items:center;border-radius:8px;background:rgba(var(--fx-primary-rgb),.10);color:var(--fx-primary);}
.fx-kpi-icon i{font-size:23px;}
.fx-kpi-icon.success{background:rgba(21,202,32,.10);color:var(--fx-success)}
.fx-kpi-icon.danger{background:rgba(253,53,80,.10);color:var(--fx-danger)}
.fx-kpi-icon.warning{background:rgba(255,193,7,.13);color:#d39e00}
.fx-dashboard-card .card-header{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.fx-dashboard-card .card-header .fx-card-heading{min-width:0;}
.fx-dashboard-card .card-header h6{margin:0 0 2px!important;}
.fx-dashboard-card .card-header small{color:var(--fx-muted);}
.fx-chart{min-height:280px;}
.fx-chart-sm{min-height:235px;}
.fx-ranking{display:grid;gap:8px;}
.fx-ranking-item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;padding:8px 0;border-bottom:1px solid var(--fx-border-soft);}
.fx-ranking-item:last-child{border-bottom:0;}
.fx-ranking-name{font-size:12px;color:var(--fx-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.fx-ranking-meta{font-size:10.5px;color:var(--fx-muted);}
.fx-ranking-value{font-size:12px;font-weight:500;text-align:right;color:var(--fx-text);}
.fx-stock-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;padding:8px 0;border-bottom:1px solid var(--fx-border-soft);}
.fx-stock-row:last-child{border-bottom:0;}
.fx-stock-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;}
.fx-stock-code{font-size:10px;color:var(--fx-muted);}
.fx-stock-qty{font-size:11px;font-weight:500;color:var(--fx-danger);}
.fx-quick-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;}
.fx-quick-action{min-height:62px;padding:10px;display:flex;align-items:center;gap:9px;text-decoration:none;color:var(--fx-text)!important;border:1px solid var(--fx-border-soft);border-radius:7px;background:var(--fx-surface-2);}
.fx-quick-action:hover{background:rgba(var(--fx-primary-rgb),.06);border-color:rgba(var(--fx-primary-rgb),.25);color:var(--fx-primary)!important;transform:translateY(-1px);}
.fx-quick-action i{font-size:21px;color:var(--fx-primary);}
.fx-quick-action strong{display:block;font-size:11.5px;font-weight:500;}
.fx-quick-action small{display:block;margin-top:2px;font-size:9.8px;color:var(--fx-muted);}
.fx-empty{padding:26px 16px;text-align:center;color:var(--fx-muted);font-size:11.5px;}

/* Login helper modal must be opaque in both themes */
body.fx-page-login .modal-backdrop,body.fx-page-login #modalForgot{backdrop-filter:none!important;}
body.fx-page-login #modalForgot .modal,body.fx-page-login #modalForgot .modal-content{background:var(--fx-surface)!important;color:var(--fx-text)!important;opacity:1!important;}

/* Dark-mode specifics */
html[data-bs-theme="dark"] .table-light,html[data-bs-theme="dark"] .bg-light{background:var(--fx-surface-2)!important;color:var(--fx-text)!important;}
html[data-bs-theme="dark"] .form-control::placeholder,html[data-bs-theme="dark"] input::placeholder,html[data-bs-theme="dark"] textarea::placeholder{color:#7d868e!important;}
html[data-bs-theme="dark"] .apexcharts-tooltip,html[data-bs-theme="dark"] .apexcharts-xaxistooltip,html[data-bs-theme="dark"] .apexcharts-menu{background:var(--fx-surface)!important;color:var(--fx-text)!important;border-color:var(--fx-border)!important;}
html[data-bs-theme="dark"] .apexcharts-text,html[data-bs-theme="dark"] .apexcharts-legend-text{fill:var(--fx-muted)!important;color:var(--fx-muted)!important;}

/* Responsive refinements */
@media (max-width:1199.98px){.fx-quick-actions{grid-template-columns:repeat(2,minmax(0,1fr));}.fx-chart{min-height:260px;}}
@media (max-width:767.98px){
  body{font-size:12.5px;}
  body:not(.pos-page) .page-content{padding:9px 8px 46px!important;}
  body:not(.pos-page) .page-content>div:first-child.d-flex,body:not(.pos-page) .page-content>.toolbar{gap:7px!important;flex-wrap:wrap!important;}
  body:not(.pos-page) .page-content>div:first-child h1,body:not(.pos-page) .page-content>div:first-child h2,body:not(.pos-page) .page-content>div:first-child h3,body:not(.pos-page) .page-content>div:first-child h4,body:not(.pos-page) .page-content>div:first-child h5,body:not(.pos-page) .page-content>.toolbar h1,body:not(.pos-page) .page-content>.toolbar h2,body:not(.pos-page) .page-content>.toolbar h3,body:not(.pos-page) .page-content>.toolbar h4,body:not(.pos-page) .page-content>.toolbar h5{font-size:16px!important;}
  body:not(.pos-page) .page-content .card-body{padding:.75rem!important;}
  .modal-dialog{margin:.45rem!important;}
  .modal-content{border-radius:7px!important;}
  .modal-header{padding:.72rem .8rem!important;}
  .modal-body{padding:.8rem!important;}
  .modal-footer{padding:.65rem .8rem!important;}
  .modal.fx-modal-list .modal-dialog{width:auto!important;max-width:none!important;height:calc(100vh - .9rem)!important;}
  .modal.fx-modal-list .modal-content{height:100%!important;}
  .fx-dashboard-hero{padding:13px 14px;}
  .fx-dashboard-hero h1{font-size:18px!important;}
  .fx-kpi-value{font-size:18px;}
  .fx-quick-actions{grid-template-columns:1fr 1fr;}
  .fx-chart{min-height:240px;}
}
@media (max-width:479.98px){
  .topbar .user-block{padding:4px!important;}
  .topbar .user-img{width:34px!important;height:34px!important;}
  .mobile-toggle-menu,.fx-theme-toggle{width:38px!important;height:38px!important;min-width:38px!important;}
  .fx-quick-actions{grid-template-columns:1fr;}
  .btn{min-height:32px;}
}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important;}}

/* ═══════════════════════════════════════════════════════════════
   REFINAMIENTO V4 · CONSISTENCIA PAGE-BY-PAGE
   Esta capa solo corrige presentación; no cambia IDs ni flujos.
   ═══════════════════════════════════════════════════════════════ */

/* Menos aire entre topbar y contenido. */
body:not(.pos-page) .page-content{padding-top:6px!important;}
.fx-first-block{margin-top:0!important;}
.fx-first-block>:first-child{margin-top:0!important;}
body:not(.pos-page) .page-content>.mb-4:first-child,
body:not(.pos-page) .page-content>.mb-3:first-child,
body:not(.pos-page) .page-content>.toolbar:first-child{margin-top:0!important;margin-bottom:10px!important;}

/* Sidebar vertical: comportamiento igual al template, sin X en escritorio. */
.sidebar-wrapper .sidebar-header{position:fixed!important;top:0!important;bottom:auto!important;left:0!important;z-index:5!important;}
.sidebar-wrapper .metismenu{margin-top:60px!important;}
.sidebar-wrapper .sidebar-header .mobile-toggle-icon{display:none!important;}
@media (min-width:1025px){
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header{width:250px!important;padding:0 15px!important;justify-content:flex-start!important;}
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header img.logo-text{display:block!important;}
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header img.logo-icon{display:none!important;}
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper .metismenu .menu-title,
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper .metismenu li.menu-label{display:block!important;}
}
@media (max-width:1024px){
  .sidebar-wrapper .sidebar-header .mobile-toggle-icon{display:flex!important;margin-left:auto!important;}
}

/* Legacy pages (pedido/remisión/venta/admin antiguo): misma piel de sidebar. */
body.fx-legacy-page .ov-shell{background:var(--fx-body)!important;font-family:Roboto,"Segoe UI",sans-serif!important;}
body.fx-legacy-page .ov-sidebar{width:250px!important;background:var(--fx-surface)!important;border-right:1px solid var(--fx-border-soft)!important;box-shadow:var(--fx-shadow)!important;}
body.fx-legacy-page .ov-sidebar.ov-collapsed{width:70px!important;}
body.fx-legacy-page .ov-sidebar-header{min-height:60px!important;height:60px!important;padding:0 12px!important;background:var(--fx-surface)!important;border-bottom:1px solid var(--fx-border-soft)!important;}
body.fx-legacy-page .ov-logo-full{height:34px!important;max-width:166px!important;}
body.fx-legacy-page .ov-logo-mark{width:30px!important;height:30px!important;}
body.fx-legacy-page .ov-sidebar-nav{padding:8px 8px 22px!important;}
body.fx-legacy-page .ov-nav-item{margin:1px 0!important;}
body.fx-legacy-page .ov-nav-link{min-height:40px!important;padding:7px 10px!important;border:0!important;border-radius:6px!important;color:var(--fx-text)!important;font-size:13px!important;}
body.fx-legacy-page .ov-nav-ico{width:27px!important;height:27px!important;border-radius:5px!important;background:transparent!important;color:var(--fx-primary)!important;font-size:19px!important;}
body.fx-legacy-page .ov-nav-link:hover,body.fx-legacy-page .ov-nav-link.ov-active{background:rgba(var(--fx-primary-rgb),.09)!important;color:var(--fx-primary)!important;transform:none!important;}
body.fx-legacy-page .ov-sidebar-toggler,body.fx-legacy-page .ov-sidebar-close,body.fx-legacy-page .ov-hamb,body.fx-legacy-page .ov-sidebar-menu-button{border:0!important;border-radius:50%!important;background:transparent!important;color:var(--fx-text)!important;}
body.fx-legacy-page .ov-sidebar-toggler:hover,body.fx-legacy-page .ov-sidebar-close:hover,body.fx-legacy-page .ov-hamb:hover,body.fx-legacy-page .ov-sidebar-menu-button:hover{background:rgba(var(--fx-primary-rgb),.09)!important;color:var(--fx-primary)!important;transform:none!important;}
body.fx-legacy-page .ov-dropdown-menu{border-left:0!important;margin-left:28px!important;}
body.fx-legacy-page .ov-dropdown-link{border-radius:5px!important;color:var(--fx-muted)!important;font-size:12px!important;}
body.fx-legacy-page .ov-dropdown-link::before{display:none!important;}
@media(max-width:1024px){body.fx-legacy-page .ov-sidebar{width:min(86vw,286px)!important;}}

/* Formularios: columnas visualmente alineadas sin tocar sus inputs/IDs. */
body:not(.pos-page) .fx-form-row>[class*="col-"]{display:flex;flex-direction:column;min-width:0;}
body:not(.pos-page) .fx-form-row>[class*="col-"]>.form-label{min-height:27px!important;display:flex!important;align-items:flex-end!important;line-height:1.2!important;}
body:not(.pos-page) .fx-form-row>[class*="col-"]>.form-text{margin-top:5px!important;}
body:not(.pos-page) .page-content .row.g-2,body:not(.pos-page) .page-content .row.g-3{--bs-gutter-y:.7rem;}

/* Tablas: aspecto DataTable de Syndron, más legible y uniforme. */
body:not(.pos-page) .page-content .table-responsive,
.modal .table-responsive{border-radius:6px;scrollbar-width:thin;}
body:not(.pos-page) .page-content table.table,
.modal table.table{margin-bottom:0!important;vertical-align:middle!important;}
body:not(.pos-page) .page-content .table>:not(caption)>*>*,
.modal .table>:not(caption)>*>*{padding:.62rem .72rem!important;}
body:not(.pos-page) .page-content table.table tbody tr,
.modal table.table tbody tr{transition:background-color .13s ease!important;}
body:not(.pos-page) .page-content table.table tbody tr:hover,
.modal table.table tbody tr:hover{background:rgba(var(--fx-primary-rgb),.045)!important;}
body:not(.pos-page) .page-content table.table thead th,
.modal table.table thead th{height:40px!important;font-size:10.5px!important;font-weight:500!important;letter-spacing:.025em!important;text-transform:none!important;white-space:nowrap!important;}
body:not(.pos-page) .page-content table.table tbody td,
.modal table.table tbody td{font-size:12px!important;}

/* Modales: centrados por defecto; listado ancho; editor de producto lateral. */
.modal-dialog:not(.modal-fullscreen){align-items:center;}
.modal-header{position:relative!important;}
.modal-header>.btn-close{margin-left:auto!important;margin-right:0!important;order:99!important;}
.modal-header>div:first-child{min-width:0!important;}
.modal-header>div:first-child .modal-title{white-space:normal!important;}
.modal.fx-modal-list .modal-dialog{display:flex!important;align-items:center!important;margin-left:auto!important;margin-right:auto!important;}
.modal.fx-modal-list .modal-content{max-height:88vh!important;}
.modal.fx-modal-list .modal-body{overflow:auto!important;}
/* Confirmaciones y avisos deben quedar por encima aun en pantallas legacy. */
.modal[id*="confirm" i],.modal[id*="confirmar" i]{z-index:1130!important;}
body #modalConfirm,body .modal-overlay[id*="confirm" i]{z-index:42000!important;}
.swal2-container{z-index:60000!important;}
.toast-container{z-index:61000!important;}

/* Cabeceras de páginas: mismo ritmo y acciones alineadas. */
body:not(.pos-page) .page-content .toolbar,
body:not(.pos-page) .page-content>.d-flex:first-child,
body:not(.pos-page) .page-content>section>.d-flex:first-child{min-height:38px;align-items:center!important;}
body:not(.pos-page) .page-content .toolbar .btn,
body:not(.pos-page) .page-content>.d-flex:first-child .btn{white-space:nowrap;}

/* Dashboard de operación */
.fx-dashboard-welcome{display:flex;align-items:center;justify-content:space-between;gap:18px;min-height:102px;margin-bottom:12px;padding:16px 18px;border:1px solid rgba(var(--fx-primary-rgb),.16);border-radius:8px;background:linear-gradient(105deg,rgba(var(--fx-primary-rgb),.10),rgba(13,202,240,.055) 56%,var(--fx-surface) 100%);box-shadow:var(--fx-shadow-sm);overflow:hidden;position:relative;}
.fx-dashboard-welcome::after{content:"";position:absolute;right:-62px;top:-92px;width:220px;height:220px;border-radius:50%;border:38px solid rgba(var(--fx-primary-rgb),.055);pointer-events:none;}
.fx-dashboard-welcome-copy{min-width:0;position:relative;z-index:1;}
.fx-dashboard-eyebrow{font-size:10px;font-weight:500;letter-spacing:.09em;text-transform:uppercase;color:var(--fx-primary);margin-bottom:4px;}
.fx-dashboard-welcome h1{margin:0!important;font-size:21px!important;font-weight:500!important;letter-spacing:-.025em!important;}
.fx-dashboard-welcome p{margin:4px 0 0;color:var(--fx-muted);font-size:11.5px;}
.fx-dashboard-welcome-actions{display:flex;align-items:center;justify-content:flex-end;gap:7px;flex-wrap:wrap;position:relative;z-index:1;}
.fx-context-pill{height:32px;display:inline-flex;align-items:center;gap:6px;padding:0 9px;border:1px solid var(--fx-border-soft);border-radius:5px;background:var(--fx-surface);color:var(--fx-muted);font-size:10.5px;box-shadow:0 1px 2px rgba(0,0,0,.025);}
.fx-context-pill i{font-size:15px;color:var(--fx-primary);}
.fx-dashboard-pos-btn{height:32px!important;min-height:32px!important;display:inline-flex!important;align-items:center!important;gap:5px!important;border:1px solid rgba(var(--fx-primary-rgb),.22)!important;color:var(--fx-primary)!important;}
.fx-dashboard-pos-btn:hover{background:var(--fx-primary)!important;color:#fff!important;}
.fx-kpi-card{border-top:2px solid transparent!important;}
.fx-kpi-primary{border-top-color:var(--fx-primary)!important;}
.fx-kpi-card .card-body{min-height:94px!important;}
.fx-kpi-label{font-size:10.5px!important;text-transform:uppercase;letter-spacing:.035em;}
.fx-kpi-value{font-size:19px!important;font-weight:500!important;}
.fx-dashboard-card{overflow:hidden!important;}
.fx-dashboard-card .card-header{min-height:54px!important;padding:.7rem .85rem!important;}
.fx-dashboard-card .card-header h6{font-size:13px!important;font-weight:500!important;}
.fx-dashboard-card .card-header small{font-size:10px!important;}
.fx-card-link{font-size:10.5px;text-decoration:none;color:var(--fx-primary);white-space:nowrap;}
.fx-card-link:hover{text-decoration:underline;}
.fx-dashboard-card .card-body{min-width:0;}
.fx-chart{width:100%;min-height:290px;}
.fx-chart-lines{min-height:300px;}
.fx-chart-finance{min-height:250px;}
.fx-finance-balance{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;border-radius:5px;background:var(--fx-surface-2);font-size:10.5px;color:var(--fx-muted);}
.fx-finance-balance strong{font-size:12px;}
.fx-dashboard-list{padding:0 13px;max-height:390px;overflow:auto;}
.fx-stock-item{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid var(--fx-border-soft);}
.fx-stock-item:last-child{border-bottom:0;}
.fx-stock-main{flex:1 1 auto;min-width:0;}
.fx-stock-name{font-size:11.5px;font-weight:500;color:var(--fx-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.fx-stock-code{margin-top:2px;font-size:9.5px;color:var(--fx-muted);}
.fx-stock-progress{height:3px!important;margin-top:7px;background:var(--fx-surface-3)!important;}
.fx-stock-values{flex:0 0 auto;text-align:right;}
.fx-stock-values strong{display:block;font-size:12px;color:var(--fx-danger);}
.fx-stock-values span{display:block;margin-top:2px;font-size:9.5px;color:var(--fx-muted);}
.fx-dashboard-table-wrap{max-height:390px;overflow:auto;}
.fx-dashboard-table thead{position:sticky;top:0;z-index:2;}
.fx-dashboard-table .fx-table-customer{max-width:260px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.fx-quick-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
.fx-quick-action{min-height:68px!important;}

/* Login: mismo sistema visual, modal de ayuda siempre opaco y dark mode real. */
body.fx-page-login{transition:background-color .18s ease,color .18s ease!important;}
.fx-login-theme-toggle{position:fixed!important;top:18px!important;right:18px!important;z-index:90!important;width:42px!important;height:42px!important;border:1px solid rgba(11,45,104,.10)!important;background:rgba(255,255,255,.94)!important;box-shadow:0 8px 24px rgba(20,49,79,.10)!important;}
body.fx-page-login .login-panel{background:var(--fx-surface)!important;border-color:var(--fx-border-soft)!important;box-shadow:var(--fx-shadow-lg)!important;}
body.fx-page-login #modalForgot{background:rgba(5,13,23,.58)!important;opacity:1!important;backdrop-filter:blur(3px)!important;-webkit-backdrop-filter:blur(3px)!important;}
body.fx-page-login #modalForgot .modal{position:relative!important;inset:auto!important;display:block!important;width:min(430px,100%)!important;max-width:430px!important;height:auto!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;border:1px solid var(--fx-border)!important;border-radius:10px!important;opacity:1!important;box-shadow:var(--fx-shadow-lg)!important;}
body.fx-page-login #modalForgot .modal-header{background:var(--fx-surface)!important;border-bottom-color:var(--fx-border-soft)!important;}
body.fx-page-login #modalForgot .modal-header h2{color:var(--fx-text)!important;}
body.fx-page-login #modalForgot .modal-body{background:var(--fx-surface)!important;color:var(--fx-muted)!important;}
body.fx-page-login #modalForgot .modal-body strong{color:var(--fx-text)!important;}
body.fx-page-login #modalForgot .modal-actions{background:var(--fx-surface)!important;}
body.fx-page-login #modalForgot .modal-close{margin-left:auto!important;background:var(--fx-surface-2)!important;color:var(--fx-muted)!important;}
html[data-bs-theme="dark"] body.fx-page-login{background:radial-gradient(circle at 10% 10%,rgba(0,140,255,.10),transparent 31rem),radial-gradient(circle at 92% 90%,rgba(13,202,240,.06),transparent 35rem),#15181b!important;}
html[data-bs-theme="dark"] body.fx-page-login .brand-title,html[data-bs-theme="dark"] body.fx-page-login .capability-group h2,html[data-bs-theme="dark"] body.fx-page-login .login-heading h1,html[data-bs-theme="dark"] body.fx-page-login .login-brand-text strong{color:var(--fx-text)!important;}
html[data-bs-theme="dark"] body.fx-page-login .brand-copy,html[data-bs-theme="dark"] body.fx-page-login .capability-group p,html[data-bs-theme="dark"] body.fx-page-login .login-heading p,html[data-bs-theme="dark"] body.fx-page-login .login-help,html[data-bs-theme="dark"] body.fx-page-login .brand-footer{color:var(--fx-muted)!important;}
html[data-bs-theme="dark"] body.fx-page-login .capabilities{border-top-color:var(--fx-border-soft)!important;}
html[data-bs-theme="dark"] body.fx-page-login .input-shell{background:var(--fx-surface-2)!important;border-color:var(--fx-border)!important;}
html[data-bs-theme="dark"] body.fx-page-login .input-shell input{color:var(--fx-text)!important;background:transparent!important;}
html[data-bs-theme="dark"] body.fx-page-login .field label,html[data-bs-theme="dark"] body.fx-page-login .remember,html[data-bs-theme="dark"] body.fx-page-login .login-footer{color:var(--fx-muted)!important;}
html[data-bs-theme="dark"] body.fx-page-login .support-menu{background:var(--fx-surface)!important;border-color:var(--fx-border)!important;}
html[data-bs-theme="dark"] body.fx-page-login .support-option:hover{background:var(--fx-surface-2)!important;}
html[data-bs-theme="dark"] body.fx-page-login .support-option-text strong{color:var(--fx-text)!important;}
html[data-bs-theme="dark"] body.fx-page-login .fx-login-theme-toggle{background:rgba(29,33,37,.96)!important;border-color:var(--fx-border)!important;color:var(--fx-text)!important;}

/* POS: solo piel. Se preservan su grid, alturas, overflow y contenido operativo. */
body.fx-page-facturav3 .pos-app,body.fx-page-facturav2 .pos-app,body.fx-page-factura .pos-app{color:var(--fx-text)!important;}
body.fx-page-facturav3 .modal-header>.btn-close,body.fx-page-facturav2 .modal-header>.btn-close,body.fx-page-factura .modal-header>.btn-close{margin-left:auto!important;}

@media(max-width:991.98px){
  .fx-dashboard-welcome{align-items:flex-start;flex-direction:column;}
  .fx-dashboard-welcome-actions{justify-content:flex-start;}
  .fx-chart{min-height:265px;}
}
@media(max-width:767.98px){
  body:not(.pos-page) .page-content{padding-top:7px!important;}
  body:not(.pos-page) .fx-form-row>[class*="col-"]>.form-label{min-height:auto!important;}
  .fx-dashboard-welcome{padding:13px 14px;min-height:auto;}
  .fx-dashboard-welcome h1{font-size:18px!important;}
  .fx-context-pill{height:30px;}
  .fx-dashboard-pos-btn{width:100%;justify-content:center;}
  .fx-chart{min-height:245px;}
  .fx-dashboard-table .fx-table-customer{max-width:160px;}
  .fx-login-theme-toggle{top:10px!important;right:10px!important;}
}

/* Login cover inspirado directamente en Syndron, conservando la identidad FlexIA. */
@media (min-width:861px){
  body.fx-page-login .page-shell{width:100%!important;max-width:none!important;min-height:100dvh!important;grid-template-columns:minmax(0,1.35fr) minmax(410px,.65fr)!important;gap:0!important;padding:0!important;}
  body.fx-page-login .brand-panel{position:relative!important;min-height:100dvh!important;display:flex!important;flex-direction:column!important;justify-content:center!important;padding:54px clamp(46px,6vw,92px)!important;background:linear-gradient(135deg,rgba(var(--fx-primary-rgb),.055),transparent 65%),var(--fx-surface-2)!important;border-right:1px solid var(--fx-border-soft)!important;overflow:hidden!important;}
  body.fx-page-login .brand-panel::after{content:"";position:absolute;right:-70px;bottom:-45px;width:min(48vw,640px);height:min(44vw,520px);background:url('/assets/images/login-images/login-cover.svg') center/contain no-repeat;opacity:.20;pointer-events:none;}
  body.fx-page-login .brand-panel>*{position:relative;z-index:1;}
  body.fx-page-login .brand-logo{width:min(250px,58%)!important;margin-bottom:42px!important;}
  body.fx-page-login .brand-title{max-width:650px!important;font-size:clamp(2.55rem,4vw,4.7rem)!important;line-height:1!important;}
  body.fx-page-login .brand-copy{max-width:610px!important;}
  body.fx-page-login .capabilities{max-width:680px!important;}
  body.fx-page-login .login-panel{width:min(470px,calc(100% - 44px))!important;align-self:center!important;justify-self:center!important;padding:42px 38px!important;border-radius:8px!important;background:var(--fx-surface)!important;}
}
@media (max-width:860px){
  body.fx-page-login .page-shell{padding-top:58px!important;}
  body.fx-page-login .login-panel{border-radius:8px!important;}
}

/* Legacy: completar tema y controles sin alterar su estructura operativa. */
body.fx-legacy-page .top-bar{min-height:56px!important;height:56px!important;padding:0 16px!important;}
body.fx-legacy-page .top-bar h1{font-family:Roboto,"Segoe UI",sans-serif!important;font-size:15px!important;font-weight:500!important;color:var(--fx-text)!important;}
body.fx-legacy-page .top-bar>div{align-items:center!important;}
body.fx-legacy-page .top-bar button:not(.fx-theme-toggle){min-height:32px!important;border-radius:5px!important;padding:0 11px!important;font-family:Roboto,"Segoe UI",sans-serif!important;font-size:11.5px!important;}
body.fx-legacy-page .grid input,body.fx-legacy-page .grid select,body.fx-legacy-page .grid textarea,
body.fx-legacy-page main input,body.fx-legacy-page main select,body.fx-legacy-page main textarea{background:var(--fx-surface)!important;color:var(--fx-text)!important;border-color:var(--fx-border)!important;border-radius:5px!important;}
body.fx-legacy-page .grid label,body.fx-legacy-page main label{color:var(--fx-muted)!important;font-family:Roboto,"Segoe UI",sans-serif!important;font-weight:500!important;}
body.fx-legacy-page .grid .card,body.fx-legacy-page main .card{background:var(--fx-surface)!important;border-color:var(--fx-border-soft)!important;box-shadow:var(--fx-shadow-sm)!important;}
body.fx-legacy-page .dropdown-productos,body.fx-legacy-page .suggestions,body.fx-legacy-page [class*="dropdown-"]{background-color:var(--fx-surface)!important;color:var(--fx-text)!important;border-color:var(--fx-border)!important;}

/* Ajustes finales v3.1: dashboard fluido y sidebar sin handlers duplicados. */
.fx-kpi-grid{
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(205px,1fr));
  gap:12px;
}
.fx-kpi-grid>[class*="col-"]{
  width:auto!important;
  max-width:none!important;
  padding:0!important;
  margin:0!important;
}
.fx-kpi-grid>[hidden]{display:none!important;}
.fx-kpi-grid .fx-kpi-card{height:100%;margin:0!important;}
@media(max-width:575.98px){
  .fx-kpi-grid{grid-template-columns:1fr 1fr;gap:8px;}
}
@media(max-width:389.98px){
  .fx-kpi-grid{grid-template-columns:1fr;}
}

/* ═══════════════════════════════════════════════════════════════
   V3.1 · DOCUMENTOS Y MAESTROS
   Refinamiento visual por familia de pantalla. No altera layout
   funcional, IDs, valores, eventos ni reglas de negocio.
   ═══════════════════════════════════════════════════════════════ */

/* Compras / NC / remisiones / órdenes: misma gramática visual. */
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .grid-head,
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .search-duo{
  gap:10px!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-compact,
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-detail{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:7px!important;
  background:var(--fx-surface)!important;
  box-shadow:0 2px 8px rgba(0,0,0,.035)!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-detail{
  border-top:2px solid rgba(var(--fx-primary-rgb),.82)!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-detail .search-duo{
  margin-bottom:10px!important;
  padding:9px 10px!important;
  border:1px solid var(--fx-border-soft)!important;
  border-radius:6px!important;
  background:var(--fx-surface-2)!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .table-wrap{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:6px!important;
  background:var(--fx-surface)!important;
  box-shadow:none!important;
  overflow:hidden;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .table-wrap .table-responsive{
  border-radius:0!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .table-wrap table thead th{
  background:var(--fx-surface-2)!important;
  color:var(--fx-muted)!important;
  border-bottom:1px solid var(--fx-border)!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .table-wrap table tbody td{
  border-bottom:1px solid var(--fx-border-soft)!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .action-bar{
  background:color-mix(in srgb,var(--fx-surface) 96%,transparent)!important;
  border-top:1px solid var(--fx-border)!important;
  box-shadow:0 -4px 16px rgba(0,0,0,.055)!important;
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) [class$="-total-box"],
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) [class*="-total-box "]{
  border-color:var(--fx-border-soft)!important;
  background:var(--fx-surface-2)!important;
  border-radius:6px!important;
  box-shadow:none!important;
}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) [class$="-total-box"].total,
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) [class*="-total-box "].total{
  border-color:rgba(var(--fx-primary-rgb),.22)!important;
  background:rgba(var(--fx-primary-rgb),.065)!important;
}

/* Clientes, proveedores, usuarios y maestros: toolbar + ficha + tabla coherentes. */
body:is(.fx-page-clientes,.fx-page-proveedores,.fx-page-usuarios,.fx-page-admin-productos,
.fx-page-admin-almacenes,.fx-page-admin-categorias,.fx-page-admin-conceptos,.fx-page-admin-impuestos,
.fx-page-admin-price-lists,.fx-page-admin-uom-groups,.fx-page-admin-uoms,.fx-page-admin-ubicaciones) .toolbar{
  padding:0 0 8px!important;
  border-bottom:1px solid var(--fx-border-soft)!important;
}
body:is(.fx-page-clientes,.fx-page-proveedores,.fx-page-usuarios,.fx-page-admin-productos) .table-wrap{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:6px!important;
  background:var(--fx-surface)!important;
  overflow:hidden;
}
body:is(.fx-page-clientes,.fx-page-proveedores,.fx-page-usuarios,.fx-page-admin-productos) .table-wrap .table-responsive{
  border-radius:0!important;
}

/* Caja, bancos y cartera: filtros se leen como una sola banda de trabajo. */
body:is(.fx-page-caja-general,.fx-page-banco-general,.fx-page-cxc,.fx-page-cxp,.fx-page-cajas-bancos) .filters,
body:is(.fx-page-caja-general,.fx-page-banco-general,.fx-page-cxc,.fx-page-cxp,.fx-page-cajas-bancos) .filters-row,
body:is(.fx-page-caja-general,.fx-page-banco-general,.fx-page-cxc,.fx-page-cxp,.fx-page-cajas-bancos) .filter-row{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:6px!important;
  background:var(--fx-surface-2)!important;
  padding:9px 10px!important;
}
body:is(.fx-page-cxc,.fx-page-cxp,.fx-page-caja-general,.fx-page-banco-general) .table-wrap{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:6px!important;
  overflow:hidden;
  background:var(--fx-surface)!important;
}

/* Reportes: filtros compactos y tabla/gráfico visualmente separados. */
body[class*="fx-page-reportes-reporte-"] .card,
body[class*="fx-page-reportes-compras-"] .card,
body.fx-page-reportes .card{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:7px!important;
  box-shadow:var(--fx-shadow-sm)!important;
}
body[class*="fx-page-reportes-reporte-"] .table-responsive,
body[class*="fx-page-reportes-compras-"] .table-responsive{
  border:1px solid var(--fx-border-soft)!important;
  background:var(--fx-surface)!important;
}

/* En dark, las capas auxiliares conservan contraste sin cambiar su estructura. */
html[data-bs-theme="dark"] body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .action-bar{
  background:rgba(29,33,37,.96)!important;
}


/* ═══════════════════════════════════════════════════════════════
   FLEXIA / SYNDRON V4 · HARDENING VISUAL Y RESPONSIVE
   Solo presentación. No cambia IDs, contratos API ni reglas de negocio.
   ═══════════════════════════════════════════════════════════════ */

/* Navegación entre documentos: Chrome/Edge conservan la sensación de una sola app. */
@view-transition{navigation:none;}
::view-transition-old(root){animation:fx-vt-old .12s ease both;}
::view-transition-new(root){animation:fx-vt-new .15s ease both;}
@keyframes fx-vt-old{to{opacity:.90}}
@keyframes fx-vt-new{from{opacity:.88}to{opacity:1}}
body.fx-page-leaving:not(.pos-page) .page-content{opacity:.82;transform:translateY(1px);transition:opacity .08s ease,transform .08s ease!important;}

/* Sidebar: estado de escritorio predecible; al colapsar queda en iconos y el hover lo expande encima. */
.sidebar-wrapper{overflow-x:hidden!important;}
.sidebar-wrapper .simplebar-content-wrapper{overflow-x:hidden!important;}
.sidebar-wrapper .sidebar-header{box-sizing:border-box!important;}
@media (min-width:1025px){
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper{width:70px!important;min-width:70px!important;left:0!important;}
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header{width:70px!important;min-width:70px!important;}
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper{width:250px!important;min-width:250px!important;left:0!important;}
  .wrapper.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header{width:250px!important;min-width:250px!important;}
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper #menu>li>a{justify-content:center!important;}
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper #menu>li>a>.parent-icon{margin:0!important;}
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper #menu>li>a>.menu-title,
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper #menu>li>ul,
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .menu-label,
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .has-arrow::after{display:none!important;}
}
@media (max-width:1024px){
  .sidebar-wrapper{width:min(86vw,286px)!important;min-width:min(86vw,286px)!important;}
  .sidebar-wrapper .sidebar-header .mobile-toggle-icon{display:flex!important;}
}

/* Logo: en oscuro se vuelve blanco sin sustituir el archivo/logo cargado por el usuario. */
html[data-bs-theme="dark"] .sidebar-wrapper .logo-text,
html[data-bs-theme="dark"] .sidebar-wrapper .logo-icon,
html[data-bs-theme="dark"] body.fx-legacy-page .ov-logo-full,
html[data-bs-theme="dark"] body.fx-legacy-page .ov-logo-mark,
html[data-bs-theme="dark"] .fx-login-brand-logo{filter:brightness(0) invert(1) contrast(1.05)!important;}

/* Topbar: una sola línea, controles alineados y sin títulos/breadcrumbs duplicados. */
.topbar .navbar{display:flex!important;align-items:center!important;min-width:0!important;}
.topbar .top-menu{display:flex!important;align-items:center!important;min-width:0!important;}
.topbar .navbar-nav{display:flex!important;align-items:center!important;}
.fx-theme-toggle{position:relative!important;overflow:hidden!important;}
.fx-theme-toggle>i{position:absolute!important;left:50%!important;top:50%!important;display:block!important;line-height:1!important;transform:translate(-50%,-50%)!important;}
.topbar .dropdown-menu{margin-top:6px!important;}

/* Footer uniforme. */
.page-footer{height:42px!important;min-height:42px!important;max-height:42px!important;}
.page-footer p{white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;}

/* Primer bloque casi pegado al topbar, pero con respiración suficiente. */
body:not(.pos-page) .page-content{padding-top:6px!important;}
body:not(.pos-page) .page-content>.toolbar:first-child,
body:not(.pos-page) .page-content>.d-flex:first-child,
body:not(.pos-page) .page-content>section:first-child,
body:not(.pos-page) .page-content>.fx-page-head:first-child{margin-top:0!important;}

/* POS: no tocar su geometría. Factura/facturaV2/facturaV3 conservan sus reglas propias de
   alturas, offsets, columnas, action-bar y responsive. Esta capa solo aporta tema/componentes. */
body.pos-page .page-wrapper{background:var(--fx-body)!important;}

/* Formularios: etiquetas, controles y acciones alineados página por página sin cambiar el grid. */
body:not(.pos-page) .page-content .form-label{font-size:12px!important;font-weight:500!important;color:var(--fx-text)!important;margin-bottom:5px!important;}
body:not(.pos-page) .page-content .form-text{font-size:10.5px!important;color:var(--fx-muted)!important;}
body:not(.pos-page) .fx-form-row>[class*="col-"]{justify-content:flex-start!important;}
body:not(.pos-page) .fx-form-row>[class*="col-"]>.form-label{min-height:22px!important;align-items:flex-end!important;}
body:not(.pos-page) .page-content .form-control,
body:not(.pos-page) .page-content .form-select,
.modal .form-control,.modal .form-select{min-height:36px!important;}
body:not(.pos-page) .page-content textarea.form-control,.modal textarea.form-control{min-height:74px!important;}
.input-group>.btn{min-height:36px!important;}

/* Tablas: misma altura, cabecera y acciones en todos los módulos. */
body:not(.pos-page) .page-content .table,
.modal .table{margin-bottom:0!important;}
body:not(.pos-page) .page-content .table>thead>tr>th,
.modal .table>thead>tr>th{height:38px!important;vertical-align:middle!important;padding:.48rem .58rem!important;background:var(--fx-surface-2)!important;color:var(--fx-muted)!important;border-bottom:1px solid var(--fx-border)!important;font-size:10.5px!important;font-weight:500!important;letter-spacing:.025em!important;text-transform:uppercase!important;white-space:nowrap!important;}
body:not(.pos-page) .page-content .table>tbody>tr>td,
.modal .table>tbody>tr>td{height:42px;vertical-align:middle!important;padding:.46rem .58rem!important;border-color:var(--fx-border-soft)!important;font-size:12px!important;}
body:not(.pos-page) .page-content .table-hover>tbody>tr:hover>* ,
.modal .table-hover>tbody>tr:hover>*{background:rgba(var(--fx-primary-rgb),.035)!important;}
.table-responsive{scrollbar-gutter:stable;}

/* Sistema de modales V4.
   - confirmaciones: pequeñas y centradas
   - listado/selección de documentos: amplias, casi pantalla completa
   - detalles: amplios y centrados
   - editor lateral: solo producto, cuando el clasificador lo indique
*/
.modal{--bs-modal-margin:.75rem;}
.modal-backdrop{z-index:1080!important;background:#0b1220!important;}
.modal-backdrop.show{opacity:.48!important;}
.modal.show{z-index:1090!important;}
.modal-dialog{display:flex!important;align-items:center!important;min-height:calc(100% - 1.5rem)!important;}
.modal-content{width:100%!important;max-height:calc(100dvh - 1.5rem)!important;border-radius:9px!important;border:1px solid var(--fx-border-soft)!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;box-shadow:0 1.5rem 4.5rem rgba(0,0,0,.28)!important;overflow:hidden!important;}
.modal-header{min-height:54px!important;padding:.78rem 1rem!important;display:flex!important;align-items:center!important;gap:12px!important;flex-wrap:nowrap!important;background:var(--fx-surface)!important;border-bottom:1px solid var(--fx-border-soft)!important;}
.modal-header>div:first-child{min-width:0!important;flex:1 1 auto!important;}
.modal-header .modal-title,.modal-header h1,.modal-header h2,.modal-header h3,.modal-header h4,.modal-header h5,.modal-header h6{min-width:0!important;flex:1 1 auto!important;width:auto!important;margin:0!important;text-align:left!important;font-size:14px!important;font-weight:500!important;line-height:1.3!important;color:var(--fx-text)!important;}
.modal-header .btn-close{position:static!important;flex:0 0 auto!important;margin:0 0 0 auto!important;padding:.5rem!important;opacity:.62!important;box-shadow:none!important;}
.modal-header .btn-close:hover{opacity:1!important;}
.modal-body{padding:1rem!important;overflow:auto!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;}
.modal-footer{min-height:52px!important;padding:.65rem 1rem!important;display:flex!important;align-items:center!important;background:var(--fx-surface-2)!important;border-top:1px solid var(--fx-border-soft)!important;gap:7px!important;}
.modal-footer .btn{min-height:34px!important;padding:.42rem .82rem!important;font-size:12px!important;border-radius:5px!important;}
.modal.fx-modal-confirm .modal-dialog{max-width:470px!important;}
.modal.fx-modal-confirm .modal-content{max-height:min(78dvh,560px)!important;}
.modal.fx-modal-document-list .modal-dialog{width:min(1500px,calc(100vw - 24px))!important;max-width:min(1500px,calc(100vw - 24px))!important;height:min(91dvh,940px)!important;margin:.75rem auto!important;align-items:stretch!important;}
.modal.fx-modal-document-list .modal-content{height:100%!important;max-height:100%!important;}
.modal.fx-modal-document-list .modal-body{min-height:0!important;overflow:auto!important;}
.modal.fx-modal-document-list .table-responsive{max-height:calc(91dvh - 200px)!important;overflow:auto!important;}
.modal.fx-modal-detail .modal-dialog{width:min(1380px,calc(100vw - 28px))!important;max-width:min(1380px,calc(100vw - 28px))!important;}
.modal.fx-modal-manager .modal-dialog{width:min(1220px,calc(100vw - 28px))!important;max-width:min(1220px,calc(100vw - 28px))!important;}
.modal.fx-modal-editor:not(.fx-modal-product-editor) .modal-dialog{width:min(860px,calc(100vw - 28px))!important;max-width:min(860px,calc(100vw - 28px))!important;}
@media (min-width:992px){
  .modal.fx-modal-product-editor .modal-dialog{width:min(760px,94vw)!important;max-width:min(760px,94vw)!important;height:100dvh!important;min-height:100dvh!important;margin:0 0 0 auto!important;align-items:stretch!important;}
  .modal.fx-modal-product-editor .modal-content{height:100dvh!important;max-height:100dvh!important;border-radius:9px 0 0 9px!important;border-top:0!important;border-right:0!important;border-bottom:0!important;}
}
@media (max-width:991.98px){
  .modal.fx-modal-document-list .modal-dialog,.modal.fx-modal-detail .modal-dialog,.modal.fx-modal-manager .modal-dialog,.modal.fx-modal-editor .modal-dialog{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;height:calc(100dvh - 12px)!important;min-height:calc(100dvh - 12px)!important;margin:6px!important;align-items:stretch!important;}
  .modal.fx-modal-document-list .modal-content,.modal.fx-modal-detail .modal-content,.modal.fx-modal-manager .modal-content,.modal.fx-modal-editor .modal-content{height:100%!important;max-height:100%!important;border-radius:8px!important;}
}

/* Confirmaciones y alertas siempre por encima de cualquier editor/listado. */
.modal.fx-modal-confirm{z-index:70010!important;}
.modal.fx-modal-confirm + .modal-backdrop,.modal-backdrop.fx-confirm-backdrop{z-index:70000!important;}
.swal2-container{z-index:80000!important;}
.toast-container{z-index:81000!important;}
body .modal-overlay[id*="confirm" i],body #modalConfirm{z-index:70020!important;}
body .modal-overlay[id*="confirm" i].show,body #modalConfirm.show{display:flex!important;}

/* Botones: misma geometría sin cambiar la semántica/color que usa cada módulo. */
.btn{border-radius:5px!important;font-weight:500!important;box-shadow:none!important;}
.btn-sm{min-height:31px!important;padding:.34rem .62rem!important;font-size:11.5px!important;}
.btn:not(.btn-sm):not(.btn-lg){min-height:36px!important;padding:.43rem .78rem!important;font-size:12.5px!important;}
.btn-primary{box-shadow:0 2px 5px rgba(var(--fx-primary-rgb),.18)!important;}
.btn:active{transform:translateY(0)!important;}

/* Cabeceras de módulos y filtros: patrón único tipo Syndron. */
body:not(.pos-page) .page-content>.toolbar,
body:not(.pos-page) .page-content>.d-flex.justify-content-between.align-items-center:first-child,
body:not(.pos-page) .page-content>.d-flex.align-items-center.justify-content-between:first-child,
body:not(.pos-page) .page-content>.fx-page-head:first-child{min-height:42px!important;margin-bottom:8px!important;gap:8px!important;}
body:not(.pos-page) .page-content>.toolbar h1,
body:not(.pos-page) .page-content>.toolbar h2,
body:not(.pos-page) .page-content>.toolbar h3,
body:not(.pos-page) .page-content>.toolbar h4,
body:not(.pos-page) .page-content>.toolbar h5,
body:not(.pos-page) .page-content>.d-flex:first-child h1,
body:not(.pos-page) .page-content>.d-flex:first-child h2,
body:not(.pos-page) .page-content>.d-flex:first-child h3,
body:not(.pos-page) .page-content>.d-flex:first-child h4,
body:not(.pos-page) .page-content>.d-flex:first-child h5{font-size:17px!important;font-weight:500!important;}

/* Administración/clientes/proveedores: formularios compactos y perfectamente alineados. */
body[class*="fx-page-admin-"] .card-body .row>[class*="col-"],
body.fx-page-clientes #clientes-page .row>[class*="col-"],
body.fx-page-proveedores #proveedores-page .row>[class*="col-"]{min-width:0;}
body[class*="fx-page-admin-"] .table-responsive,
body.fx-page-clientes .table-responsive,
body.fx-page-proveedores .table-responsive{border:1px solid var(--fx-border-soft)!important;border-radius:7px!important;background:var(--fx-surface)!important;}

/* Compras, NC, remisiones, recuentos y traslados: misma jerarquía visual. */
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .page-content>div:first-child.d-flex{min-height:42px!important;margin-bottom:8px!important;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card{border-radius:8px!important;}
body:is(.fc-page,.nc-page,.oc-page,.rem-page,.rc-page,.tr-page) .card-header{min-height:44px!important;}

/* Dashboard */
.fx-dashboard-welcome{border-radius:9px!important;box-shadow:var(--fx-shadow-sm)!important;}
.fx-dashboard-card{overflow:hidden!important;}
.fx-dashboard-card .card-header{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:10px!important;}
.fx-dashboard-card .card-body{min-width:0!important;}
.fx-chart{width:100%!important;min-width:0!important;}
.fx-kpi-card{overflow:hidden!important;position:relative!important;}
.fx-kpi-card::after{content:"";position:absolute;right:-36px;bottom:-48px;width:110px;height:110px;border-radius:50%;background:rgba(var(--fx-primary-rgb),.045);pointer-events:none;}
html[data-bs-theme="dark"] .fx-kpi-card::after{background:rgba(255,255,255,.025);}

/* Tema oscuro: controles y tablas que todavía venían con clases claras del template. */
html[data-bs-theme="dark"] .table-light,html[data-bs-theme="dark"] .table-light>*{--bs-table-bg:var(--fx-surface-2)!important;--bs-table-color:var(--fx-text)!important;}
html[data-bs-theme="dark"] .bg-light{background-color:var(--fx-surface-2)!important;color:var(--fx-text)!important;}
html[data-bs-theme="dark"] .text-bg-light{background-color:var(--fx-surface-2)!important;color:var(--fx-text)!important;}
html[data-bs-theme="dark"] .form-control,html[data-bs-theme="dark"] .form-select{background-color:var(--fx-surface-2)!important;color:var(--fx-text)!important;border-color:var(--fx-border)!important;}
html[data-bs-theme="dark"] .form-control::placeholder{color:var(--fx-muted)!important;opacity:.7;}

@media (max-width:767.98px){
  body:not(.pos-page) .page-content{padding-left:8px!important;padding-right:8px!important;}
  .page-footer{padding-left:8px!important;padding-right:8px!important;}
  body:not(.pos-page) .page-content>.toolbar,body:not(.pos-page) .page-content>.d-flex:first-child{align-items:flex-start!important;}
  body:not(.pos-page) .page-content>.toolbar>.d-flex,body:not(.pos-page) .page-content>.d-flex:first-child>.d-flex{flex-wrap:wrap!important;}
}

/* Modales legacy que consultan/listan documentos: mismo lenguaje visual que Bootstrap. */
body:not(.pos-page) .modal-overlay{
  background:rgba(10,18,30,.50)!important;
  backdrop-filter:blur(1px);
}
body:not(.pos-page) .modal-overlay.show{display:grid!important;place-items:center!important;padding:12px!important;}
body:not(.pos-page) .modal-overlay>.card,
body:not(.pos-page) .modal-overlay>.modal-p{
  border:1px solid var(--fx-border-soft)!important;
  border-radius:9px!important;
  background:var(--fx-surface)!important;
  color:var(--fx-text)!important;
  box-shadow:0 1.5rem 4.5rem rgba(0,0,0,.28)!important;
}
body.fx-legacy-page #modalBuscarPedidos>.card,
body.fx-page-compra #modalBuscar>.modal-p,
body.fx-legacy-page #modalRelDocs>.card{
  width:min(1480px,calc(100vw - 28px))!important;
  max-width:min(1480px,calc(100vw - 28px))!important;
  min-width:0!important;
  max-height:calc(100dvh - 28px)!important;
  padding:16px!important;
}
body.fx-legacy-page #modalBuscarPedidos .table-wrap,
body.fx-page-compra #modalBuscar .table-wrap,
body.fx-legacy-page #modalRelDocs .card-body{min-height:260px;max-height:calc(100dvh - 235px)!important;overflow:auto!important;}
body.fx-legacy-page #modalBuscarPedidos h4,
body.fx-page-compra #modalBuscar h6,
body.fx-legacy-page #modalRelDocs h3{color:var(--fx-text)!important;font-size:14px!important;font-weight:500!important;}
body.fx-legacy-page #modalBuscarPedidos .close,
body.fx-legacy-page #modalRelDocs .close{margin-left:auto!important;color:var(--fx-muted)!important;font-size:20px!important;font-weight:400!important;line-height:1!important;}
body.fx-legacy-page #modalBuscarPedidos .close:hover,
body.fx-legacy-page #modalRelDocs .close:hover{color:var(--fx-text)!important;}
body.fx-legacy-page #modalBuscarPedidos input,
body.fx-legacy-page #modalBuscarPedidos select,
body.fx-page-compra #modalBuscar input,
body.fx-page-compra #modalBuscar select{min-height:36px!important;border:1px solid var(--fx-border)!important;border-radius:5px!important;background:var(--fx-surface)!important;color:var(--fx-text)!important;}
body.fx-legacy-page #modalBuscarPedidos table,
body.fx-page-compra #modalBuscar table,
body.fx-legacy-page #modalRelDocs table{width:100%!important;color:var(--fx-text)!important;background:var(--fx-surface)!important;}
body.fx-legacy-page #modalBuscarPedidos th,
body.fx-page-compra #modalBuscar th,
body.fx-legacy-page #modalRelDocs th{height:38px!important;padding:.48rem .58rem!important;background:var(--fx-surface-2)!important;color:var(--fx-muted)!important;border-bottom:1px solid var(--fx-border)!important;font-size:10.5px!important;font-weight:500!important;text-transform:uppercase!important;white-space:nowrap!important;}
body.fx-legacy-page #modalBuscarPedidos td,
body.fx-page-compra #modalBuscar td,
body.fx-legacy-page #modalRelDocs td{height:42px!important;padding:.46rem .58rem!important;border-bottom:1px solid var(--fx-border-soft)!important;color:var(--fx-text)!important;font-size:12px!important;}
@media(max-width:900px){
  body.fx-legacy-page #modalBuscarPedidos form{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  body.fx-legacy-page #modalBuscarPedidos>.card,
  body.fx-page-compra #modalBuscar>.modal-p,
  body.fx-legacy-page #modalRelDocs>.card{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;max-height:calc(100dvh - 12px)!important;padding:12px!important;}
}
@media(max-width:520px){body.fx-legacy-page #modalBuscarPedidos form{grid-template-columns:1fr!important;}}

/* Si el módulo ya declaró fullscreen, respetarlo: es la variante correcta para estados de cuenta completos. */
.modal .modal-dialog.modal-fullscreen{
  width:100vw!important;max-width:none!important;height:100dvh!important;min-height:100dvh!important;margin:0!important;align-items:stretch!important;
}
.modal .modal-dialog.modal-fullscreen .modal-content{
  width:100%!important;height:100dvh!important;max-height:100dvh!important;border-radius:0!important;border:0!important;
}

/* ================================================================
   V4.1 - Normalización final de diálogos por intención
   Mantiene el DOM/IDs originales; solo unifica presentación.
   ================================================================ */
.modal.fx-modal-action .modal-dialog{
  width:min(640px,calc(100vw - 28px))!important;
  max-width:min(640px,calc(100vw - 28px))!important;
}
.modal.fx-modal-action .modal-content{max-height:min(88dvh,760px)!important;}
.modal.fx-modal-action .modal-body{overflow:auto!important;}

/* Todos los encabezados de modal: título a la izquierda, cierre al extremo derecho. */
.modal .modal-header>.btn-close{order:99!important;margin-left:auto!important;flex:0 0 auto!important;}
.modal .modal-header>:not(.btn-close){min-width:0;}

/* Overlays antiguos fuera del POS: mismos tamaños según su función. */
body:not(.pos-page) .modal-overlay.fx-overlay-document-list{
  z-index:9100!important;
  background:rgba(10,18,30,.50)!important;
  backdrop-filter:blur(1px);
  align-items:center!important;
  justify-content:center!important;
  padding:12px!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list>.card,
body:not(.pos-page) .modal-overlay.fx-overlay-document-list>.modal-p{
  width:min(1500px,calc(100vw - 24px))!important;
  max-width:min(1500px,calc(100vw - 24px))!important;
  min-width:0!important;
  height:min(91dvh,940px)!important;
  max-height:min(91dvh,940px)!important;
  padding:16px!important;
  display:flex!important;
  flex-direction:column!important;
  overflow:hidden!important;
  border-radius:9px!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list .table-wrap,
body:not(.pos-page) .modal-overlay.fx-overlay-document-list .table-responsive{
  flex:1 1 auto!important;
  min-height:0!important;
  max-height:none!important;
  overflow:auto!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-detail>.card,
body:not(.pos-page) .modal-overlay.fx-overlay-detail>.modal-p{
  width:min(920px,calc(100vw - 28px))!important;
  max-width:min(920px,calc(100vw - 28px))!important;
  min-width:0!important;
  max-height:88dvh!important;
  overflow:auto!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-editor>.card,
body:not(.pos-page) .modal-overlay.fx-overlay-editor>.modal-p{
  width:min(760px,calc(100vw - 28px))!important;
  max-width:min(760px,calc(100vw - 28px))!important;
  min-width:0!important;
  max-height:90dvh!important;
  overflow:auto!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-confirm{z-index:70020!important;}

/* Controles internos de overlays legacy: aspecto Syndron sin cambiar handlers. */
body:not(.pos-page) .modal-overlay.fx-overlay-document-list input,
body:not(.pos-page) .modal-overlay.fx-overlay-document-list select,
body:not(.pos-page) .modal-overlay.fx-overlay-document-list textarea,
body:not(.pos-page) .modal-overlay.fx-overlay-editor input,
body:not(.pos-page) .modal-overlay.fx-overlay-editor select,
body:not(.pos-page) .modal-overlay.fx-overlay-editor textarea{
  min-height:36px!important;
  border:1px solid var(--fx-border)!important;
  border-radius:5px!important;
  background:var(--fx-surface)!important;
  color:var(--fx-text)!important;
  box-shadow:none!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list button,
body:not(.pos-page) .modal-overlay.fx-overlay-editor button{
  min-height:34px;
  border-radius:5px!important;
  font-family:Roboto,"Segoe UI",sans-serif!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list button.primary,
body:not(.pos-page) .modal-overlay.fx-overlay-document-list .primary,
body:not(.pos-page) .modal-overlay.fx-overlay-editor button.primary,
body:not(.pos-page) .modal-overlay.fx-overlay-editor .primary{
  border:1px solid var(--fx-primary)!important;
  background:var(--fx-primary)!important;
  color:#fff!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list table,
body:not(.pos-page) .modal-overlay.fx-overlay-detail table{
  width:100%!important;
  color:var(--fx-text)!important;
  background:var(--fx-surface)!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list th,
body:not(.pos-page) .modal-overlay.fx-overlay-detail th{
  height:38px!important;
  padding:.48rem .58rem!important;
  background:var(--fx-surface-2)!important;
  color:var(--fx-muted)!important;
  border-bottom:1px solid var(--fx-border)!important;
  font-size:10.5px!important;
  font-weight:500!important;
  text-transform:uppercase!important;
  white-space:nowrap!important;
}
body:not(.pos-page) .modal-overlay.fx-overlay-document-list td,
body:not(.pos-page) .modal-overlay.fx-overlay-detail td{
  height:42px!important;
  padding:.46rem .58rem!important;
  border-bottom:1px solid var(--fx-border-soft)!important;
  color:var(--fx-text)!important;
  font-size:12px!important;
}

/* Historial legacy de venta (no usa modal-dialog de Bootstrap). */
body.fx-page-venta #modalHistorial>.modal-content{
  position:relative!important;
  width:min(920px,calc(100vw - 28px))!important;
  max-width:min(920px,calc(100vw - 28px))!important;
  max-height:88dvh!important;
  margin:auto!important;
  padding:16px!important;
  border:1px solid var(--fx-border-soft)!important;
  border-radius:9px!important;
  background:var(--fx-surface)!important;
  color:var(--fx-text)!important;
  box-shadow:0 1.5rem 4.5rem rgba(0,0,0,.28)!important;
  overflow:auto!important;
}
body.fx-page-venta #modalHistorial>.modal-content>.close{
  position:absolute!important;
  top:12px!important;
  right:14px!important;
  left:auto!important;
  color:var(--fx-muted)!important;
  font-size:22px!important;
  line-height:1!important;
}

@media(max-width:991.98px){
  .modal.fx-modal-action .modal-dialog{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;margin:6px!important;}
  body:not(.pos-page) .modal-overlay.fx-overlay-document-list>.card,
  body:not(.pos-page) .modal-overlay.fx-overlay-document-list>.modal-p,
  body:not(.pos-page) .modal-overlay.fx-overlay-detail>.card,
  body:not(.pos-page) .modal-overlay.fx-overlay-detail>.modal-p,
  body:not(.pos-page) .modal-overlay.fx-overlay-editor>.card,
  body:not(.pos-page) .modal-overlay.fx-overlay-editor>.modal-p{
    width:calc(100vw - 12px)!important;
    max-width:calc(100vw - 12px)!important;
    max-height:calc(100dvh - 12px)!important;
  }
  body:not(.pos-page) .modal-overlay.fx-overlay-document-list>.card,
  body:not(.pos-page) .modal-overlay.fx-overlay-document-list>.modal-p{height:calc(100dvh - 12px)!important;}
}

/* Cross-document View Transitions (Chrome/Edge modernos): el armazón permanece
   visualmente estable y solo cambia el contenido central. En navegadores sin soporte
   estas reglas se ignoran y continúa funcionando la navegación normal. */
@view-transition{navigation:none;}
.sidebar-wrapper{view-transition-name:flexia-sidebar;}
.topbar{view-transition-name:flexia-topbar;}
body:not(.pos-page) .page-content{view-transition-name:flexia-content;}
.page-footer{view-transition-name:flexia-footer;}
::view-transition-old(flexia-sidebar),::view-transition-new(flexia-sidebar),
::view-transition-old(flexia-topbar),::view-transition-new(flexia-topbar),
::view-transition-old(flexia-footer),::view-transition-new(flexia-footer){animation-duration:.01s;}
::view-transition-old(flexia-content){animation:fx-vt-old .10s ease both;}
::view-transition-new(flexia-content){animation:fx-vt-new .12s ease both;}
@keyframes fx-vt-old{to{opacity:.94;}}
@keyframes fx-vt-new{from{opacity:.94;}to{opacity:1;}}

/* ======================================================================
   FlexIA · Syndron UI v5
   Armonización final: topbar, modales de documentos, dashboard y navegación.
   Esta sección prevalece sobre V4 sin cambiar IDs, eventos ni lógica de negocio.
   ====================================================================== */

/* Topbar: el link de usuario no hereda el ancho fijo de 42px de .nav-link. */
.topbar .navbar{display:flex!important;align-items:center!important;flex-wrap:nowrap!important;min-width:0!important;}
.topbar .top-menu{display:flex!important;align-items:center!important;justify-content:flex-end!important;min-width:0!important;max-width:calc(100% - 54px)!important;margin-left:auto!important;}
.topbar .navbar-nav{display:flex!important;flex-direction:row!important;align-items:center!important;flex-wrap:nowrap!important;gap:4px!important;min-width:0!important;}
.topbar .navbar-nav>.nav-item{flex:0 0 auto!important;min-width:0!important;}
.topbar .fx-theme-toggle{width:42px!important;height:42px!important;min-width:42px!important;max-width:42px!important;flex:0 0 42px!important;}
.topbar .user-block{width:auto!important;height:46px!important;min-width:0!important;max-width:min(280px,42vw)!important;display:flex!important;align-items:center!important;gap:8px!important;padding:4px 8px!important;overflow:hidden!important;}
.topbar .user-block .user-img{width:36px!important;height:36px!important;min-width:36px!important;flex:0 0 36px!important;}
.topbar .user-block .meta{min-width:0!important;max-width:190px!important;flex:1 1 auto!important;}
.topbar .user-block .name{display:block!important;max-width:100%!important;overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;}
.topbar .fx-user-chevron{flex:0 0 auto!important;margin-left:0!important;}
@media(max-width:575.98px){
  .topbar .top-menu{max-width:calc(100% - 48px)!important;}
  .topbar .user-block{width:42px!important;height:42px!important;min-width:42px!important;max-width:42px!important;padding:3px!important;justify-content:center!important;}
  .topbar .user-block .user-img{width:34px!important;height:34px!important;min-width:34px!important;}
  .topbar .user-block .meta,.topbar .fx-user-chevron{display:none!important;}
}

/* Logo cargado por el cliente: mismo archivo, blanco en modo oscuro. */
html[data-bs-theme="dark"] .sidebar-wrapper .sidebar-header img.logo-text,
html[data-bs-theme="dark"] .sidebar-wrapper .sidebar-header img.logo-icon{filter:brightness(0) invert(1) contrast(1.18)!important;opacity:1!important;}

/* Modales SIEMPRE encima de topbar/sidebar. */
.modal-backdrop{z-index:9090!important;}
.modal.show{z-index:9100!important;}
.modal-overlay.show,.modal-overlay[style*="display: block"],.modal-overlay[style*="display:block"]{z-index:9100!important;}
.modal.fx-modal-confirm{z-index:70010!important;}
.modal-backdrop.fx-confirm-backdrop{z-index:70000!important;}
body .modal-overlay.fx-overlay-confirm,body #modalConfirm{z-index:70020!important;}
.swal2-container{z-index:80000!important;}
.toast-container{z-index:81000!important;}

/* Un solo patrón para buscar/listar documentos: grande, limpio y con acciones visibles. */
.modal.fx-modal-document-list .modal-dialog{
  width:min(1480px,calc(100vw - 28px))!important;
  max-width:min(1480px,calc(100vw - 28px))!important;
  height:min(91dvh,930px)!important;
  min-height:0!important;
  margin:clamp(6px,1.2vh,12px) auto!important;
  display:flex!important;
  align-items:stretch!important;
}
.modal.fx-modal-document-list .modal-content{
  height:100%!important;max-height:100%!important;min-height:0!important;
  display:flex!important;flex-direction:column!important;
  border-radius:8px!important;overflow:hidden!important;
}
.modal.fx-modal-document-list .modal-header,
.modal.fx-modal-document-list .modal-footer{flex:0 0 auto!important;}
.modal.fx-modal-document-list .modal-header{min-height:56px!important;padding:.72rem 1rem!important;}
.modal.fx-modal-document-list .modal-body{flex:1 1 auto!important;min-height:0!important;overflow:auto!important;padding:.9rem 1rem!important;}
.modal.fx-modal-document-list .modal-footer{min-height:54px!important;padding:.62rem 1rem!important;display:flex!important;align-items:center!important;flex-wrap:wrap!important;gap:7px!important;}
.modal.fx-modal-document-list .modal-footer>.d-flex,
.modal.fx-modal-document-list .modal-footer>.w-100{min-width:0!important;flex-wrap:wrap!important;gap:7px!important;align-items:center!important;}
.modal.fx-modal-document-list .table-responsive{flex:1 1 auto!important;min-height:0!important;max-height:none!important;overflow:auto!important;border:1px solid var(--fx-border-soft)!important;border-radius:6px!important;}
.modal.fx-modal-document-list .btn{border-radius:4px!important;box-shadow:none!important;}
.modal.fx-modal-document-list .btn-close{margin-left:auto!important;order:99!important;}

/* Los overlays históricos de factura/compra/pedido usan exactamente el mismo lenguaje. */
body .modal-overlay.fx-overlay-document-list{
  z-index:9100!important;background:rgba(10,18,30,.52)!important;backdrop-filter:blur(1px)!important;
  align-items:center!important;justify-content:center!important;padding:12px!important;
}
body .modal-overlay.fx-overlay-document-list>.card,
body .modal-overlay.fx-overlay-document-list>.modal-p{
  width:min(1480px,calc(100vw - 28px))!important;max-width:min(1480px,calc(100vw - 28px))!important;
  height:min(91dvh,930px)!important;max-height:min(91dvh,930px)!important;min-height:0!important;
  display:flex!important;flex-direction:column!important;overflow:hidden!important;
  padding:14px!important;border:1px solid var(--fx-border-soft)!important;border-radius:8px!important;
  background:var(--fx-surface)!important;color:var(--fx-text)!important;box-shadow:0 1.5rem 4.5rem rgba(0,0,0,.28)!important;
}
body .modal-overlay.fx-overlay-document-list .table-wrap,
body .modal-overlay.fx-overlay-document-list .table-responsive{flex:1 1 auto!important;min-height:0!important;max-height:none!important;overflow:auto!important;}
body .modal-overlay.fx-overlay-document-list button{border-radius:4px!important;}

/* Crédito: pies de modal estables, sin botones montados ni necesidad de desplazar el diálogo completo. */
body.fx-page-credito .modal-content,
body.fx-page-compra-nc .modal-content,
body.fx-page-compra-remision .modal-content,
body.fx-page-compra-orden .modal-content{display:flex!important;flex-direction:column!important;min-height:0!important;}
body.fx-page-credito .modal-header,body.fx-page-credito .modal-footer{flex:0 0 auto!important;}
body.fx-page-credito .modal-body{flex:1 1 auto!important;min-height:0!important;overflow:auto!important;}
body.fx-page-credito .modal-footer .d-flex.w-100,
body.fx-page-credito .modal-footer .d-flex.gap-2{display:flex!important;align-items:center!important;flex-wrap:wrap!important;gap:7px!important;min-width:0!important;}
body.fx-page-credito .modal-footer .btn{flex:0 0 auto!important;white-space:nowrap!important;}

/* Dashboard: rejillas sin tarjetas huérfanas y mayor variedad visual. */
body.fx-page-dashboard .page-content{padding-top:8px!important;}
.fx-kpi-grid{display:grid!important;gap:12px!important;}
.fx-kpi-grid-admin{grid-template-columns:repeat(4,minmax(0,1fr))!important;}
.fx-kpi-grid-operator{grid-template-columns:repeat(6,minmax(0,1fr))!important;}
.fx-kpi-grid>.card{min-width:0!important;margin:0!important;}
.fx-kpi-card .card-body{height:100%;min-height:112px;display:flex!important;align-items:center!important;justify-content:space-between!important;gap:12px!important;}
.fx-kpi-value small{font-size:11px;font-weight:400;color:var(--fx-muted);}
.fx-kpi-icon.info{color:#0dcaf0!important;background:rgba(13,202,240,.11)!important;}
.fx-kpi-icon.purple{color:#8833ff!important;background:rgba(136,51,255,.10)!important;}
.fx-dashboard-card{overflow:hidden!important;}
.fx-dashboard-card .card-header{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:12px!important;}
.fx-dashboard-card .card-body{min-height:0!important;}
.fx-chart{min-height:300px;position:relative;}
.fx-chart-lg{min-height:330px;}
.fx-chart-tall{min-height:350px;}
.fx-chart-radial{width:100%;min-height:300px;}
.fx-chart-empty{min-height:280px;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;color:var(--fx-muted);font-size:12px;text-align:center;}
.fx-chart-empty i{font-size:34px;opacity:.55;}
.fx-dashboard-table-wrap{max-height:390px;overflow:auto!important;}
@media(max-width:1399.98px){.fx-kpi-grid-operator{grid-template-columns:repeat(3,minmax(0,1fr))!important;}}
@media(max-width:1199.98px){.fx-kpi-grid-admin{grid-template-columns:repeat(2,minmax(0,1fr))!important;}}
@media(max-width:767.98px){.fx-kpi-grid-admin,.fx-kpi-grid-operator{grid-template-columns:repeat(2,minmax(0,1fr))!important;}.fx-kpi-card .card-body{min-height:104px;}}
@media(max-width:479.98px){.fx-kpi-grid-admin,.fx-kpi-grid-operator{grid-template-columns:1fr!important;}.fx-kpi-card .card-body{min-height:90px;}}

/* Navegación fluida: sin desplazamiento artificial del contenido al salir. */
body.fx-page-leaving .page-content{opacity:.985!important;transform:none!important;transition:opacity .06s linear!important;}
@view-transition{navigation:none;}
::view-transition-old(flexia-content){animation:fx-v5-vt-old .07s ease both!important;}
::view-transition-new(flexia-content){animation:fx-v5-vt-new .10s ease both!important;}
@keyframes fx-v5-vt-old{to{opacity:.97;}}
@keyframes fx-v5-vt-new{from{opacity:.97;}to{opacity:1;}}

@media(max-width:991.98px){
  .modal.fx-modal-document-list .modal-dialog{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;height:calc(100dvh - 12px)!important;margin:6px!important;}
  body .modal-overlay.fx-overlay-document-list>.card,body .modal-overlay.fx-overlay-document-list>.modal-p{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;height:calc(100dvh - 12px)!important;max-height:calc(100dvh - 12px)!important;}
}

/* Controles internos de listados: mismo acabado independientemente del módulo de origen. */
.modal.fx-modal-document-list .filters-row{display:flex!important;align-items:flex-end!important;flex-wrap:wrap!important;gap:9px!important;margin-bottom:8px!important;}
.modal.fx-modal-document-list .filters-row>div{min-width:0;}
.modal.fx-modal-document-list .btn-ghost,
.modal.fx-modal-document-list .btn-soft{background:var(--fx-surface)!important;border:1px solid var(--fx-border)!important;color:var(--fx-text)!important;}
.modal.fx-modal-document-list .btn-ghost:hover,
.modal.fx-modal-document-list .btn-soft:hover{background:rgba(var(--fx-primary-rgb),.07)!important;border-color:rgba(var(--fx-primary-rgb),.42)!important;color:var(--fx-primary)!important;}
body .modal-overlay.fx-overlay-document-list .close{margin-left:auto!important;color:var(--fx-muted)!important;font-weight:400!important;}

/* V5 final: cualquier overlay legacy debe abrir por encima del armazón fijo,
   independientemente de si el módulo lo muestra con .show, display:block o display:flex. */
body .modal-overlay{z-index:9100!important;}
body .modal-overlay.fx-overlay-confirm,body #modalConfirm{z-index:70020!important;}

/* ========================================================================
   FlexIA V6 · capa final de armonización
   ======================================================================== */

/* Modal stack: el armazón nunca tapa diálogos y las confirmaciones mandan. */
header.fx-topbar-host,.topbar{z-index:1040!important;}
.sidebar-wrapper{z-index:1030!important;}
body>.modal-backdrop,.modal-backdrop{z-index:19990!important;}
.modal.show{z-index:20000!important;}
body .modal-overlay.show,
body .modal-overlay[style*="display: block"],
body .modal-overlay[style*="display:block"],
body .modal-overlay[style*="display: flex"],
body .modal-overlay[style*="display:flex"]{z-index:20000!important;}

.modal.fx-modal-confirm,
.modal[id*="confirm" i],
.modal[id*="confirmar" i]{z-index:120060!important;}
.modal-backdrop.fx-confirm-backdrop{z-index:120050!important;}
body .modal-overlay.fx-overlay-confirm,
body #modalConfirm,
body .modal-overlay[id*="confirm" i],
body .modal-overlay[id*="confirmar" i]{z-index:120080!important;}
body>.swal2-container,.swal2-container{z-index:130000!important;}
.toast-container{z-index:131000!important;}

/* Toda confirmación tipo Bootstrap queda realmente centrada. */
.modal.fx-modal-confirm .modal-dialog,
.modal[id*="confirm" i] .modal-dialog,
.modal[id*="confirmar" i] .modal-dialog{
  width:min(470px,calc(100vw - 24px))!important;
  max-width:min(470px,calc(100vw - 24px))!important;
  min-height:calc(100% - 1rem)!important;
  margin:.5rem auto!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
}
.modal.fx-modal-confirm .modal-content,
.modal[id*="confirm" i] .modal-content,
.modal[id*="confirmar" i] .modal-content{width:100%!important;margin:auto!important;}

/* Confirmaciones legacy: no heredan posiciones laterales de editores/listados. */
body .modal-overlay.fx-overlay-confirm.show,
body #modalConfirm.show,
body #modalConfirm[style*="display: block"],
body #modalConfirm[style*="display:block"],
body #modalConfirm[style*="display: flex"],
body #modalConfirm[style*="display:flex"],
body .modal-overlay[id*="confirm" i][style*="display: block"],
body .modal-overlay[id*="confirm" i][style*="display:block"],
body .modal-overlay[id*="confirm" i][style*="display: flex"],
body .modal-overlay[id*="confirm" i][style*="display:flex"]{
  position:fixed!important;inset:0!important;width:100vw!important;height:100dvh!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
  padding:16px!important;margin:0!important;transform:none!important;
}
body .modal-overlay.fx-overlay-confirm>.card,
body .modal-overlay.fx-overlay-confirm>.modal-p,
body #modalConfirm>.card,
body #modalConfirm>.modal-p{
  position:relative!important;inset:auto!important;transform:none!important;
  margin:auto!important;max-width:min(470px,calc(100vw - 24px))!important;
}
/* SweetAlert normal/confirmado siempre en el centro; los toasts conservan su esquina. */
.swal2-container.swal2-center{position:fixed!important;inset:0!important;width:100vw!important;height:100dvh!important;display:grid!important;place-items:center!important;padding:16px!important;}
.swal2-container.swal2-center>.swal2-popup{margin:auto!important;position:relative!important;inset:auto!important;transform:none!important;}

/* Dashboard V6: lenguaje Syndron, mayor densidad y variedad de visualizaciones. */
body.fx-page-dashboard .page-content{padding-top:8px!important;padding-bottom:18px!important;}
body.fx-page-dashboard .card.radius-10{border-radius:10px!important;}
.fx-dashboard-welcome{min-height:90px!important;margin-bottom:14px!important;padding:15px 18px!important;border-radius:10px!important;}
.fx-dashboard-welcome h1{font-size:20px!important;font-weight:500!important;}
.fx-dashboard-welcome p{font-size:11.5px!important;}
.fx-dashboard-pos-btn{height:34px!important;min-height:34px!important;color:#fff!important;border-color:transparent!important;}

.fx-metric-card{overflow:hidden!important;position:relative!important;min-height:146px!important;}
.fx-metric-card>.card-body{padding:15px 16px 9px!important;display:flex!important;flex-direction:column!important;min-width:0!important;}
.fx-metric-label{margin:0 0 3px!important;color:var(--fx-muted)!important;font-size:11.5px!important;font-weight:400!important;}
.fx-metric-value{margin:0!important;color:var(--fx-text)!important;font-size:22px!important;font-weight:500!important;letter-spacing:-.025em!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;}
.fx-metric-foot{margin:4px 0 0!important;color:var(--fx-muted)!important;font-size:10.5px!important;}
.fx-metric-spark{height:58px!important;min-height:58px!important;margin:5px -4px -5px!important;}
.fx-metric-card .widgets-icons{width:42px!important;height:42px!important;min-width:42px!important;font-size:21px!important;border-radius:9px!important;display:grid!important;place-items:center!important;}
.fx-bg-purple-soft{background:rgba(136,51,255,.10)!important;}.fx-text-purple{color:#8833ff!important;}
.fx-metric-track{height:5px;margin-top:auto;margin-bottom:8px;border-radius:999px;background:var(--fx-surface-2);overflow:hidden;}
.fx-metric-track>span{display:block;height:100%;min-width:2px;border-radius:inherit;transition:width .45s ease;}
.fx-metric-red .fx-metric-track>span{background:#fd3550;}.fx-metric-amber .fx-metric-track>span{background:#ff9700;}

.fx-mini-stat{min-height:98px!important;}
.fx-mini-stat .card-body{height:100%;padding:13px 14px!important;display:flex!important;align-items:center!important;gap:11px!important;min-width:0!important;}
.fx-mini-stat-icon{width:40px;height:40px;min-width:40px;border-radius:9px;display:grid;place-items:center;font-size:20px;}
.fx-mini-stat .card-body>div:last-child{min-width:0;display:flex;flex-direction:column;}
.fx-mini-stat span{color:var(--fx-muted);font-size:10.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.fx-mini-stat strong{color:var(--fx-text);font-size:15px;font-weight:500;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.fx-mini-stat small{color:var(--fx-muted);font-size:9.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

.fx-dashboard-card{border-radius:10px!important;box-shadow:var(--fx-shadow-sm)!important;}
.fx-dashboard-card .card-header{min-height:56px!important;padding:10px 14px!important;background:transparent!important;border-bottom:1px solid var(--fx-border-soft)!important;}
.fx-dashboard-card .card-header h6{font-size:13px!important;font-weight:500!important;margin:0 0 2px!important;}
.fx-dashboard-card .card-header small{font-size:10px!important;color:var(--fx-muted)!important;}
.fx-dashboard-card .card-body{padding:12px 14px!important;}
.fx-dashboard-card .fx-card-link{font-size:10.5px!important;text-decoration:none!important;white-space:nowrap!important;}
.fx-chart{min-height:300px!important;}.fx-chart-lg{min-height:330px!important;}.fx-chart-tall{min-height:350px!important;}.fx-chart-radial{min-height:300px!important;}
.fx-dashboard-list{max-height:354px!important;}
.fx-dashboard-table-wrap{max-height:390px!important;}
.fx-dashboard-table thead th{font-size:10px!important;font-weight:500!important;letter-spacing:.025em!important;text-transform:uppercase!important;}
.fx-dashboard-table tbody td{font-size:11px!important;}
.fx-quick-actions{display:grid!important;grid-template-columns:1fr!important;gap:7px!important;}
.fx-quick-action{min-height:52px!important;padding:8px 10px!important;border-radius:7px!important;}
.fx-quick-action>i{width:34px!important;height:34px!important;min-width:34px!important;border-radius:7px!important;font-size:18px!important;}
.fx-quick-action strong{font-size:11.5px!important;}.fx-quick-action small{font-size:9.5px!important;}

html[data-bs-theme="dark"] .fx-metric-track{background:rgba(255,255,255,.08)!important;}
html[data-bs-theme="dark"] .bg-light-primary,
html[data-bs-theme="dark"] .bg-light-info,
html[data-bs-theme="dark"] .bg-light-success,
html[data-bs-theme="dark"] .bg-light-warning,
html[data-bs-theme="dark"] .bg-light-danger{background:rgba(255,255,255,.07)!important;}

@media(max-width:767.98px){
  .fx-dashboard-welcome{align-items:flex-start!important;padding:13px 14px!important;}
  .fx-dashboard-welcome-actions{width:100%;justify-content:flex-start!important;}
  .fx-dashboard-pos-btn{width:auto!important;}
  .fx-metric-card{min-height:136px!important;}
  .fx-metric-value{font-size:19px!important;}
  .fx-mini-stat{min-height:88px!important;}
}
@media(max-width:479.98px){
  .fx-dashboard-welcome-actions .fx-context-pill{max-width:100%;}
  .fx-metric-card{min-height:130px!important;}
}

/* ========================================================================
   FlexIA V6.4 · loader global + dashboard ejecutivo
   ======================================================================== */

/* Cualquier loader de pantalla completa debe bloquear por encima de documentos,
   modales y sidebars. Las alertas/confirmaciones de resultado aún pueden aparecer
   por encima para que el usuario nunca quede atrapado. */
body.fx-global-loading{overflow:hidden!important;}
#loadingOverlay,
#reportLoadingOverlay,
#pgLoadingOverlay,
#ieLoadingOverlay,
#fxLoading,
.report-loading-overlay,
.pg-loading-overlay,
.fx-loading,
[id*="loadingOverlay" i],
[class*="loading-overlay" i]{
  z-index:140000!important;
}
body>.swal2-container,.swal2-container{z-index:150000!important;}
.toast-container{z-index:160000!important;}
#loadingOverlay.show,
#reportLoadingOverlay.show,
#ieLoadingOverlay.show,
#fxLoading.show,
.report-loading-overlay.show,
.fx-loading.show{
  pointer-events:auto!important;
}

/* Dashboard: composición inspirada en los ejemplos Infographic / eCommerce /
   Analytics de Syndron, pero conectada a datos reales de FlexIA. */
body.fx-page-dashboard .page-content{padding-top:7px!important;padding-bottom:20px!important;}
.fx-dashboard-welcome-pro{margin-bottom:10px!important;}
.fx-dashboard-filterbar{border:1px solid var(--fx-border-soft)!important;box-shadow:var(--fx-shadow-sm)!important;background:var(--fx-surface)!important;}
.fx-dashboard-filterbar .card-body{padding:10px 12px!important;display:flex!important;align-items:center!important;justify-content:space-between!important;gap:12px!important;flex-wrap:wrap!important;}
.fx-dashboard-period-copy{display:flex;align-items:center;gap:10px;min-width:210px;}
.fx-dashboard-period-icon{width:36px;height:36px;border-radius:9px;display:grid;place-items:center;background:rgba(13,110,253,.09);color:#0d6efd;font-size:18px;}
.fx-dashboard-period-copy>div{display:flex;flex-direction:column;line-height:1.25;}
.fx-dashboard-period-copy strong{font-size:12px;font-weight:500;color:var(--fx-text);}
.fx-dashboard-period-copy small{font-size:10px;color:var(--fx-muted);margin-top:2px;}
.fx-dashboard-period-controls{margin-left:auto;display:flex;align-items:flex-end;justify-content:flex-end;gap:7px;flex-wrap:wrap;}
.fx-dashboard-period-controls>.form-select{width:108px;min-width:108px;height:34px;border-radius:6px!important;font-size:10.5px!important;}
.fx-date-field{display:flex;flex-direction:column;gap:2px;}
.fx-date-field>span{font-size:8.5px;text-transform:uppercase;letter-spacing:.05em;color:var(--fx-muted);padding-left:2px;}
.fx-date-field .form-control{width:132px;height:34px;border-radius:6px!important;font-size:10.5px!important;}
.fx-dashboard-period-controls .btn{height:34px;min-height:34px;border-radius:6px!important;font-size:10.5px!important;display:inline-flex!important;align-items:center!important;gap:5px!important;}
.fx-dashboard-period-controls .fx-icon-btn{width:34px;padding:0!important;justify-content:center!important;font-size:18px!important;}
.fx-dashboard-period-controls .fx-icon-btn.is-loading i{animation:fxDashSpin .65s linear infinite;}
@keyframes fxDashSpin{to{transform:rotate(360deg)}}
body.fx-dashboard-loading #adminDashboard,body.fx-dashboard-loading #operatorDashboard{opacity:.72;transition:opacity .15s ease;}

.fx-dashboard-showcase>.d-flex>.card{min-height:278px;}
.fx-hero-stat{position:relative;overflow:hidden;border:0!important;box-shadow:var(--fx-shadow-sm)!important;color:var(--fx-text);}
.fx-hero-stat::before{content:"";position:absolute;inset:0;pointer-events:none;background:radial-gradient(circle at 92% 6%,rgba(13,110,253,.11),transparent 36%);}
.fx-hero-stat-sales::after,.fx-hero-stat-operator::after{content:"";position:absolute;width:180px;height:180px;border-radius:50%;right:-100px;top:-95px;background:rgba(2,194,122,.08);pointer-events:none;}
.fx-hero-stat>.card-body{position:relative;z-index:1;padding:16px 17px 4px!important;display:flex;flex-direction:column;min-width:0;}
.fx-card-kicker{font-size:10.5px;color:var(--fx-muted);margin-bottom:4px;}
.fx-hero-value{font-size:25px;font-weight:500;letter-spacing:-.035em;margin:0;color:var(--fx-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.fx-hero-meta{display:flex;gap:12px;flex-wrap:wrap;margin-top:5px;font-size:9.5px;color:var(--fx-muted);}
.fx-hero-meta b{font-weight:500;color:var(--fx-text);}
.fx-hero-stat .widgets-icons,.fx-cash-pulse-card .widgets-icons{width:42px;height:42px;min-width:42px;border-radius:50%!important;display:grid;place-items:center;font-size:20px;}
.fx-chart-hero{height:185px;min-height:185px;margin:2px -8px -2px;}
.fx-chart-showcase{height:220px;min-height:220px;}
.fx-chart-radial-mini{height:185px;min-height:185px;margin-top:-3px;}
.fx-compact-radial-card .card-body{padding:14px 12px 10px!important;display:flex;flex-direction:column;min-width:0;}
.fx-compact-radial-card h6{font-size:11.5px;font-weight:500;}
.fx-compact-radial-card .text-center{display:flex;flex-direction:column;line-height:1.25;}
.fx-compact-radial-card .text-center strong{font-size:16px;font-weight:500;color:var(--fx-text);}
.fx-compact-radial-card .text-center small{font-size:9px;color:var(--fx-muted);}
.fx-cash-pulse-card .card-body{padding:15px 13px 0!important;}
.fx-cash-pulse-card h3{font-size:24px;font-weight:500;color:var(--fx-text);}
.fx-cash-pulse-card p{font-size:9.5px!important;}
.fx-chart-cash-pulse{height:105px;min-height:105px;margin-top:auto;}
.widgets-icons-sm{width:31px;height:31px;min-width:31px;border-radius:7px;display:grid;place-items:center;font-size:16px;}
.fx-compact-kpi-card .card-body{padding:14px 12px!important;display:flex;flex-direction:column;align-items:flex-start;justify-content:center;min-height:100%;}
.fx-compact-kpi-card .widgets-icons{width:38px;height:38px;min-width:38px;border-radius:8px!important;display:grid;place-items:center;font-size:19px;margin-bottom:12px;}
.fx-compact-kpi-card span{font-size:10px;color:var(--fx-muted);}
.fx-compact-kpi-card strong{font-size:24px;font-weight:500;color:var(--fx-text);line-height:1.2;margin:2px 0;}
.fx-compact-kpi-card small{font-size:9px;color:var(--fx-muted);}

body.fx-page-dashboard .fx-dashboard-card{border:1px solid var(--fx-border-soft)!important;background:var(--fx-surface)!important;}
body.fx-page-dashboard .fx-dashboard-card .card-header{min-height:52px!important;padding:9px 13px!important;}
body.fx-page-dashboard .fx-dashboard-card .card-body{padding:10px 13px!important;}
body.fx-page-dashboard .fx-dashboard-card .card-header h6{font-size:12.5px!important;}
body.fx-page-dashboard .fx-dashboard-card .card-header small{font-size:9.5px!important;}
body.fx-page-dashboard .fx-chart{min-height:310px!important;}
body.fx-page-dashboard .fx-chart-tall{min-height:365px!important;}
body.fx-page-dashboard .fx-dashboard-list{max-height:365px!important;}
.fx-quick-actions-horizontal{grid-template-columns:repeat(4,minmax(0,1fr))!important;}

html[data-bs-theme="dark"] .fx-dashboard-filterbar{background:var(--fx-surface)!important;}
html[data-bs-theme="dark"] .fx-dashboard-period-icon{background:rgba(80,155,255,.12);color:#72aef8;}
html[data-bs-theme="dark"] .fx-hero-stat::before{background:radial-gradient(circle at 92% 6%,rgba(80,155,255,.10),transparent 36%);}
html[data-bs-theme="dark"] .fx-hero-stat-sales::after,html[data-bs-theme="dark"] .fx-hero-stat-operator::after{background:rgba(2,194,122,.06);}

@media(max-width:1199.98px){
  .fx-dashboard-showcase>.d-flex>.card{min-height:250px;}
  .fx-dashboard-period-controls{width:100%;justify-content:flex-start;margin-left:46px;}
  .fx-quick-actions-horizontal{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
}
@media(max-width:767.98px){
  .fx-dashboard-filterbar .card-body{align-items:flex-start!important;}
  .fx-dashboard-period-copy{min-width:0;width:100%;}
  .fx-dashboard-period-controls{margin-left:0;width:100%;display:grid;grid-template-columns:1fr 1fr;align-items:end;}
  .fx-dashboard-period-controls>.form-select{width:100%;min-width:0;grid-column:1/-1;}
  .fx-date-field .form-control{width:100%;}
  .fx-dashboard-period-controls #dashApply{grid-column:1/2;justify-content:center!important;}
  .fx-dashboard-period-controls #dashRefresh{grid-column:2/3;width:100%;}
  .fx-dashboard-showcase>.d-flex>.card{min-height:230px;}
  .fx-chart-hero{height:165px;min-height:165px;}
  .fx-chart-showcase{height:205px;min-height:205px;}
  .fx-quick-actions-horizontal{grid-template-columns:1fr!important;}
}
