/* ════════════════════════════════════════════════════════════════
   CLOOS Control — capa de marca sobre la plantilla Able Pro.
   Estructura y componentes tomados de milsa_control (admin_dashboard),
   con la paleta de cloos-group.com: naranja #EC6906 y gris pizarra #2E393F.
   ════════════════════════════════════════════════════════════════ */
:root {
  --ms: #ec6906; --ms-dark: #c95905;
  --ms-bg: rgba(236,105,6,.09); --ms-light: #fff4ec;
  --cl-slate: #2e393f; --cl-slate-2: #354248; --cl-gray: #84888c;
  --bs-primary: #ec6906; --bs-primary-rgb: 236,105,6;
  --bs-link-color: #ec6906; --bs-link-hover-color: #c95905;
  --ms-logo: #2e393f;
  --ms-sb-w: 280px; --ms-sb-w-min: 68px; --ms-hd-h: 60px;
}
body { background: #f3f4f6 !important; }
a { color: var(--ms); }
a:hover { color: var(--ms-dark); }

/* ── Header ───────────────────────────────────────────── */
.milsa-topbar {
  position: fixed; top: 0; right: 0; left: var(--ms-sb-w);
  height: var(--ms-hd-h); z-index: 1025;
  background: #fff; border-bottom: 1px solid #e8eaed;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 24px; transition: left .2s ease;
}
.milsa-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.milsa-topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.milsa-title { font-size: 1.15rem; font-weight: 700; color: var(--ms-logo); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#js-page-content .page-header-title h2,
#js-page-content .page-header-title h3,
#js-page-content .card-header h4,
#js-page-content .card-header h5 { color: var(--ms-logo); }

.cloos-almacen-sel {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid #e5e7eb; background: #fafbfc; color: var(--cl-slate) !important;
  font-size: .8rem; font-weight: 600; text-decoration: none !important; white-space: nowrap; max-width: 280px;
}
.cloos-almacen-sel .lbl { overflow: hidden; text-overflow: ellipsis; }
.cloos-almacen-sel .ti-building-warehouse { color: var(--ms); font-size: 1rem; }
.cloos-almacen-sel::after { display: none !important; }
.cloos-almacen-sel:hover { border-color: var(--ms); }

.milsa-pend {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 500; text-decoration: none !important; border: 1px solid transparent; white-space: nowrap;
}
.milsa-pend::after { display: none !important; }
.milsa-pend .ti { font-size: .95rem; }
.milsa-pend-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; background: #fff; }
.milsa-pend-aprobar   { background: #fff1e6; color: #c95905 !important; border-color: #fcd5b5; }
.milsa-pend-finalizar { background: #e8eef0; color: var(--cl-slate) !important; border-color: #cfd8dc; }
.milsa-pend.is-zero   { background: #f3f4f6; color: #9ca3af !important; border-color: #e5e7eb; }
.milsa-pend-menu { width: 320px; padding: 0; overflow: hidden; }
.milsa-pend-menu .hd { padding: 10px 14px; font-size: .78rem; font-weight: 600; color: #374151; border-bottom: 1px solid #f1f3f6; }
.milsa-pend-menu .bd { max-height: 300px; overflow-y: auto; }
.milsa-pend-menu .it { display: block; padding: 8px 14px; border-bottom: 1px solid #f7f8fa; text-decoration: none; color: #374151; font-size: .8rem; }
.milsa-pend-menu .it:hover { background: #f9fafb; }
.milsa-pend-menu .it .no { font-weight: 600; color: var(--ms); }
.milsa-pend-menu .it .sub { font-size: .72rem; color: #9ca3af; }
.milsa-pend-menu .empty { padding: 14px; font-size: .8rem; color: #9ca3af; text-align: center; }
.milsa-pend-menu .ft { display: block; padding: 8px 14px; font-size: .76rem; text-align: center; color: #6b7280; text-decoration: none; background: #f9fafb; }
@media (max-width: 991.98px) { .milsa-pend .lbl, .cloos-almacen-sel .lbl { display: none; } }

.milsa-hd-user { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; color: #4b5563 !important; text-decoration: none !important; font-size: .875rem; }
.milsa-hd-user:hover { background: #f3f4f6; }
.milsa-hd-user::after { display: none !important; }
.milsa-hd-user .milsa-hd-name { font-weight: 500; }
.milsa-hd-user .ti-chevron-down { font-size: .9rem; color: #9ca3af; }
.milsa-hd-user .milsa-avatar { width: 32px !important; height: 32px !important; font-size: .75rem !important; }
.milsa-topbar .dropdown-menu { display: none; }
.milsa-topbar .dropdown-menu.show { display: block; }
.milsa-topbar .dropdown-item.active, .milsa-topbar .dropdown-item:active { background: var(--ms-bg); color: var(--ms); }

#main-wrapper .pc-container { padding-top: var(--ms-hd-h) !important; }
body.milsa-sidebar-collapsed .milsa-topbar { left: var(--ms-sb-w-min); }

.nav-header, .pc-header, .pc-footer { display: none !important; }

/* ── Sidebar ─────────────────────────────────────────── */
.pc-sidebar { top: 0 !important; height: 100vh !important; background: #fff !important; border-right: 1px solid #e8eaed !important; box-shadow: none !important; }
#js-page-content, .page-content { margin-top: 0 !important; padding-top: 0 !important; }
.navbar-wrapper { height: 100% !important; }
.milsa-sw { display: flex !important; flex-direction: column !important; height: 100% !important; }

.milsa-logo {
  display: flex !important; align-items: center !important; gap: 10px;
  padding: 0 14px 0 20px; height: var(--ms-hd-h); flex-shrink: 0;
  background: var(--cl-slate); border-bottom: 3px solid var(--ms);
}
.cloos-logo-img { height: 26px; width: auto; display: block; }
.cloos-logo-mini { display: none; width: 32px; height: 32px; border-radius: 6px; }
.cloos-logo-sub {
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
  color: var(--cl-gray); padding: 10px 20px 6px; flex-shrink: 0;
}
.milsa-toggle-btn {
  background: none; border: none; cursor: pointer; padding: 5px; border-radius: 6px; color: #aab3b8;
  margin-left: auto; flex-shrink: 0; display: flex; align-items: center; justify-content: center; line-height: 1;
}
.milsa-toggle-btn:hover { color: #fff !important; background: rgba(255,255,255,.1) !important; }
.milsa-toggle-btn .ti { font-size: 1.15rem; }
.milsa-icon-expand { display: none !important; }

.milsa-user { position: absolute !important; bottom: 0 !important; left: 0 !important; right: 0 !important; background: #fff !important; border-top: 1px solid #f0f0f0 !important; padding: 10px 12px !important; z-index: 1060 !important; }
.milsa-user-btn { display: flex !important; align-items: center !important; gap: 10px; padding: 6px 8px; border-radius: 8px; text-decoration: none !important; color: inherit !important; width: 100%; }
.milsa-user-btn:hover { background: #f8f8f8 !important; }
.milsa-user-btn::after { display: none !important; }
.milsa-avatar { width: 36px !important; height: 36px !important; border-radius: 50% !important; background: var(--ms) !important; color: #fff !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; font-weight: 700 !important; font-size: .8rem !important; flex-shrink: 0 !important; }
.milsa-user-text { flex: 1; min-width: 0; }
.milsa-user-name { font-size: .83rem !important; font-weight: 600 !important; color: var(--cl-slate) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.milsa-user-role { font-size: .7rem !important; color: #9ea3b5 !important; }
.milsa-caret { font-size: .85rem; color: #b8bcc8; flex-shrink: 0; }
.milsa-user ul.dropdown-menu { display: none !important; position: absolute; }
.milsa-user ul.dropdown-menu.show { display: block !important; }

.milsa-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 0 0 80px; }
.milsa-nav::-webkit-scrollbar { width: 3px; }
.milsa-nav::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

.pc-navbar { padding: 0; margin: 0; }
.pc-navbar .pc-caption { display: none !important; }
.pc-navbar .pc-item { list-style: none; margin: 0; }
.pc-navbar .pc-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 20px; color: #5a5f72 !important;
  font-size: .875rem; font-weight: 500; text-decoration: none !important; border-left: 3px solid transparent;
  transition: color .15s, background .15s, border-color .15s; line-height: 1.4;
}
.pc-navbar .pc-link .ti { font-size: 1.1rem; color: #a0a5b8; flex-shrink: 0; }
.pc-navbar .pc-link:hover { color: var(--ms) !important; background: var(--ms-bg) !important; }
.pc-navbar .pc-link:hover .ti { color: var(--ms) !important; }
.pc-navbar .pc-item.active > .pc-link, .pc-navbar .pc-item.pc-trigger > .pc-link {
  color: var(--ms) !important; background: var(--ms-bg) !important; border-left-color: var(--ms) !important; font-weight: 600;
}
.pc-navbar .pc-item.active > .pc-link .ti, .pc-navbar .pc-item.pc-trigger > .pc-link .ti { color: var(--ms) !important; }
.pc-submenu { padding: 0; margin: 0; list-style: none; background: #fafafa; }
.pc-submenu .pc-link { padding-left: 50px; font-size: .845rem; color: #6c757d !important; }
.pc-arrow { margin-left: auto; font-size: .78rem; color: #b8bcc8; flex-shrink: 0; }

/* Colapsado */
body.milsa-sidebar-collapsed .pc-sidebar, body.milsa-sidebar-collapsed .pc-sidebar .navbar-wrapper { width: 68px !important; }
body.milsa-sidebar-collapsed .pc-container { margin-left: 68px !important; }
body.milsa-sidebar-collapsed .milsa-logo { justify-content: center !important; padding: 0 !important; flex-direction: column; gap: 2px; }
body.milsa-sidebar-collapsed .cloos-logo-img, body.milsa-sidebar-collapsed .cloos-logo-sub { display: none !important; }
body.milsa-sidebar-collapsed .cloos-logo-mini { display: none; }
body.milsa-sidebar-collapsed .milsa-toggle-btn { margin-left: 0 !important; }
body.milsa-sidebar-collapsed .milsa-icon-collapse { display: none !important; }
body.milsa-sidebar-collapsed .milsa-icon-expand { display: inline !important; }
body.milsa-sidebar-collapsed .pc-mtext, body.milsa-sidebar-collapsed .pc-arrow { display: none !important; }
body.milsa-sidebar-collapsed .pc-navbar .pc-link { justify-content: center !important; padding: 11px 0 !important; }
body.milsa-sidebar-collapsed .pc-submenu { display: none !important; }
body.milsa-sidebar-collapsed .milsa-user-text, body.milsa-sidebar-collapsed .milsa-caret { display: none !important; }
body.milsa-sidebar-collapsed .milsa-user-btn { justify-content: center !important; padding: 5px !important; }

.milsa-flyout-submenu { display: none; position: fixed; min-width: 210px; background: #fff; list-style: none; margin: 0; padding: 6px 0; border: 1px solid #e8eaed; border-radius: 10px; box-shadow: 4px 6px 18px rgba(0,0,0,.15); z-index: 2000; }
.milsa-flyout-submenu.show { display: block; }
.milsa-flyout-submenu .pc-item { list-style: none; }
.milsa-flyout-submenu .pc-link { display: flex !important; align-items: center; gap: 10px; padding: 9px 18px !important; white-space: nowrap; color: #5a5f72 !important; font-size: .845rem; text-decoration: none !important; }
.milsa-flyout-submenu .pc-link:hover { color: var(--ms) !important; background: var(--ms-bg) !important; }

/* Móvil */
.milsa-mobile-toggle { display: none; background: none; border: none; border-radius: 6px; width: 36px; height: 36px; padding: 0; align-items: center; justify-content: center; cursor: pointer; color: #5a5f72; }
.milsa-mobile-toggle .ti { font-size: 1.3rem; }
.milsa-mobile-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1079; }
body.milsa-mobile-open .milsa-mobile-backdrop { display: block; }
@media (max-width: 767.98px) {
  .milsa-mobile-toggle { display: flex !important; }
  .pc-sidebar { position: fixed !important; left: 0 !important; width: 280px !important; z-index: 1085 !important; transform: translateX(-280px) !important; transition: transform .25s ease !important; visibility: hidden; }
  body.milsa-mobile-open .pc-sidebar { transform: translateX(0) !important; visibility: visible !important; }
  .pc-container, #js-page-content, .page-content { margin-left: 0 !important; }
  .milsa-topbar, body.milsa-sidebar-collapsed .milsa-topbar { left: 0; padding: 0 12px; }
  .milsa-hd-user .milsa-hd-name { display: none; }
  .table-responsive, .dataTables_wrapper { overflow-x: auto !important; }
}

/* ── Bootstrap → Naranja CLOOS ───────────────────────── */
.btn-primary, .btn-primary:focus { background-color: var(--ms) !important; border-color: var(--ms) !important; color: #fff !important; }
.btn-primary:hover, .btn-primary:active { background-color: var(--ms-dark) !important; border-color: var(--ms-dark) !important; }
.btn-outline-primary { color: var(--ms) !important; border-color: var(--ms) !important; }
.btn-outline-primary:hover { background-color: var(--ms) !important; color: #fff !important; }
.btn-dark, .btn-secondary-cl { background: var(--cl-slate) !important; border-color: var(--cl-slate) !important; color: #fff !important; }
.btn-dark:hover { background: #1f272b !important; }
.text-primary, a.text-primary { color: var(--ms) !important; }
.bg-primary, .badge.bg-primary { background-color: var(--ms) !important; }
.bg-light-primary { background: var(--ms-light) !important; color: var(--ms) !important; }
.border-primary { border-color: var(--ms) !important; }
.form-check-input:checked { background-color: var(--ms) !important; border-color: var(--ms) !important; }
.form-control:focus, .form-select:focus { border-color: #f5a564; box-shadow: 0 0 0 .2rem rgba(236,105,6,.15); }
.nav-tabs .nav-link.active { color: var(--ms) !important; border-bottom-color: var(--ms) !important; }
.page-link { color: var(--ms); }
.page-item.active .page-link { background: var(--ms); border-color: var(--ms); }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { background: var(--ms) !important; border-color: var(--ms) !important; color: #fff !important; }

/* ── Pestañas del módulo Almacén (milsa) ─────────────── */
.milsa-almacen-tab { display: flex; align-items: center; gap: 14px; height: 100%; background: #fff; border: 1px solid #e8eaed; border-radius: 10px; padding: 16px 18px; text-decoration: none !important; color: inherit; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.milsa-almacen-tab:hover { border-color: var(--ms); box-shadow: 0 2px 10px rgba(236,105,6,.12); }
.milsa-almacen-tab.active { border-color: var(--ms); background: var(--ms-bg); }
.milsa-almacen-tab-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #f0f2f5; color: #6b7280; font-size: 1.25rem; flex-shrink: 0; }
.milsa-almacen-tab.active .milsa-almacen-tab-icon { background: var(--ms); color: #fff; }
.milsa-almacen-tab-label { font-weight: 600; color: var(--cl-slate); font-size: .92rem; line-height: 1.25; }

/* ── Tablas compactas (milsa) ───────────────────────── */
table.dataTable td { white-space: normal !important; }
.milsa-tabla-compacta { font-size: .78rem; }
.milsa-tabla-compacta th { font-size: .74rem; white-space: nowrap; padding: 5px 7px !important; background: #f8f9fa; }
.milsa-tabla-compacta td { padding: 4px 7px !important; vertical-align: middle; }
.mono { font-family: "Courier New", monospace; }

/* ── KPI cards ──────────────────────────────────────── */
.cl-kpi { border: 1px solid #eceef1; border-radius: 12px; background: #fff; padding: 16px 18px; display: flex; gap: 14px; align-items: center; height: 100%; }
.cl-kpi-ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; background: var(--ms-light); color: var(--ms); }
.cl-kpi-ico.slate { background: #e8eef0; color: var(--cl-slate); }
.cl-kpi-ico.green { background: #e6f6ec; color: #2ba24c; }
.cl-kpi-ico.blue { background: #e8f0ff; color: #3b6fe0; }
.cl-kpi-val { font-size: 1.35rem; font-weight: 700; color: var(--cl-slate); line-height: 1.1; }
.cl-kpi-lbl { font-size: .75rem; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }

/* ── Documentos: borrador (milsa nueva_borrador) ─────── */
.d-contents { display: contents; }
.milsa-btn-regresar { --bs-btn-bg: #d3d4d5; --bs-btn-border-color: #c6c7c8; }
.milsa-entrada-meta { margin-top: 4px; font-size: 13px; color: #6b7280; }
.milsa-factura-input { background-color: #fffdf0; }
.milsa-panel-items { border-top: 3px solid #d9dee5; }
.milsa-item-list { display: flex; flex-direction: column; }
.milsa-item-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid rgba(0,0,0,.07); background: #fff; flex-wrap: wrap; font-size: 13.5px; }
.milsa-item-list .milsa-item-row:first-child { border-top: none; }
.milsa-item-row--pending { background: #fff7f0; }
.milsa-item-desc { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.milsa-item-tag-group { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.milsa-item-tag { color: #6b7280; font-size: 12px; }
.milsa-item-unit { color: #9ca3af; font-size: 11px; }
.milsa-item-qty { font-family: "Courier New", monospace; font-size: 13px; color: #374151; font-weight: 700; flex-shrink: 0; }
.milsa-item-partida { flex-shrink: 0; width: 22px; text-align: center; font-size: 12px; font-weight: 700; color: #9ca3af; }
.milsa-item-del button { border: none; background: transparent; color: #dc2626; opacity: .7; cursor: pointer; padding: 4px; display: flex; }
.milsa-item-del button:hover { opacity: 1; }
.milsa-item-empty { padding: 16px; text-align: center; color: #6b7280; font-size: 13px; background: #fff; }
.milsa-search-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.milsa-search-box, .milsa-scan-box { display: flex; align-items: center; gap: 8px; background: #f3f4f6; border: 1px solid #d9dee5; border-radius: 8px; padding: 8px 12px; margin: 0; }
.milsa-search-box { flex: 1 1 280px; }
.milsa-scan-box { flex: 0 1 220px; }
.milsa-search-box i, .milsa-scan-box i { color: #6b7280; font-size: 15px; }
.milsa-search-box input, .milsa-scan-box input { border: none; background: transparent; outline: none; width: 100%; font-size: 14px; color: #1f2430; }
.milsa-resultados { max-height: 440px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
.milsa-resultados table { margin-bottom: 0; table-layout: fixed; width: 100%; }
.milsa-resultados thead th { position: sticky; top: 0; background: #f3f4f6; z-index: 1; font-size: .74rem; }
.milsa-resultados td { vertical-align: middle; }
.milsa-col-producto { max-width: 0; }
.milsa-prod-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.milsa-prod-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.milsa-prod-meta { font-size: 11.5px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.milsa-qty-badge { display: inline-block; font-size: 12px; background: #eef0f3; border-radius: 6px; padding: 2px 8px; color: #4b5563; }
.milsa-qty-badge.cero { background: #fde8e8; color: #b91c1c; }
.milsa-empty-search { padding: 26px 16px; color: #6b7280; text-align: center; font-size: 13px; }
.cl-qty-input { width: 80px; text-align: center; }

/* Loader de pantalla completa */
#cl-loading { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(46,57,63,.55); backdrop-filter: blur(4px); align-items: center; justify-content: center; }
#cl-loading.active { display: flex; }
#cl-loading .box { background: #fff; border-radius: 1rem; padding: 2rem 2.6rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
#cl-loading .spin { width: 48px; height: 48px; border: 5px solid rgba(236,105,6,.2); border-top-color: var(--ms); border-radius: 50%; animation: clspin .75s linear infinite; }
@keyframes clspin { to { transform: rotate(360deg); } }

/* Toma de inventario */
.cl-progress { height: 8px; border-radius: 99px; background: #eef0f3; overflow: hidden; }
.cl-progress > div { height: 100%; background: var(--ms); border-radius: 99px; }
.cl-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cl-ciclo-hist { background: #f8fafc !important; color: #64748b; border-left: 2px solid #e2e8f0 !important; }
.cl-ciclo-act { background: #fff4ec !important; border-left: 2px solid #fcd5b5 !important; }
.qty-input { width: 110px; text-align: right; }
[x-cloak] { display: none !important; }
