/* ===== Variables ===== */
:root {
  --brand: #1565d8;
  --bg-page: #f4f6f9;
  --card: #fff;
  --muted: #6c757d;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .1);
  --shadow-sm: 0 8px 24px rgba(16, 24, 40, .08);

  /* Topbar */
  --topbar-bg: #0A0230;
  /* 🔵 AZUL OSCURO DEFINITIVO */
  --topbar-fg: #e9f2f7;
  --topbar-fg-hover: #ffffff;

  /* ✨ Premium Gradients */
  --grad-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --grad-success: linear-gradient(135deg, #00b09b 0%, #96c93d 100%);
  --grad-warning: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
  --grad-danger: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
  --grad-info: linear-gradient(135deg, #1fa2ff 0%, #12d8fa 50%, #a6ffcb 100%);
  --grad-dark: linear-gradient(135deg, #232526 0%, #414345 100%);
  --grad-card: linear-gradient(135deg, #ffffff 0%, #f9f9f9 100%);

  /* ✨ Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

/* ===== Base ===== */
.bg-page {
  background: #eef2f6;
}

/* Ajustado para mejor contraste */
.bg-brand {
  background: var(--brand);
}

/* por si aún lo usas en alguna card */

/* ===== TOPBAR (solo superior) ===== */
/* === TOPBAR DEFINITIVA === */
.topbar {
  background: #0A0230 !important;
  --bs-navbar-color: var(--topbar-fg);
  --bs-navbar-hover-color: var(--topbar-fg-hover);
  --bs-navbar-brand-color: #fff;
  --bs-navbar-toggler-border-color: rgba(255, 255, 255, .25);
  box-shadow: 0 2px 10px rgba(5, 34, 53, .15);
}

.topbar .navbar-brand {
  color: #fff;
}

.topbar .navbar-brand img {
  display: block;
}

.topbar .navbar-toggler {
  border-color: var(--bs-navbar-toggler-border-color);
}

.topbar .navbar-toggler-icon {
  filter: invert(1) contrast(200%);
}

.topbar .nav-link {
  color: var(--bs-navbar-color);
}

.topbar .nav-link.active {
  color: #fff;
  font-weight: 600;
}

.topbar .dropdown-menu {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, .05);
  box-shadow: 0 12px 34px rgba(2, 22, 34, .18);
  overflow: hidden;
}

.topbar .dropdown-header {
  font-size: .75rem;
  letter-spacing: .06em;
  color: #6b7b86;
  font-weight: 700;
}

/* Mega menú para "Sistemas" */
.dropdown-mega {
  min-width: 900px;
  /* ancho cómodo en desktop */
  max-width: 100%;
}

@media (max-width: 991.98px) {
  .dropdown-mega {
    min-width: 100%;
  }

  /* ocupa el ancho en móvil */
}

.dropdown-mega .dropdown-item {
  padding-left: 0;
  /* estilo tipo lista */
}

/* Eliminar hueco entre el toggle y el mega-menú */
.navbar .dropdown-menu.dropdown-mega {
  margin-top: 0 !important;
}

/* (Si antes usabas abrir por CSS en hover, quítalo.
   Ahora el comportamiento hover lo maneja el JS de base.html.) */

/* ===== (Eliminado Sidebar) ===== */
.sidebar {
  display: none !important;
}

/* ===== Burbujas (si las usas en otras vistas) ===== */
.bubble-vertical {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.bubble-vertical li {
  display: block;
}

.bubble-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid #e0e0e0;
  /* Borde más suave */
  border-radius: 12px;
  background: #f5f5f5;
  /* Color gris claro BABABA mejorado */
  color: #2c3e50;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.bubble-item i {
  font-size: 1.05rem;
  opacity: .9;
  flex-shrink: 0;
}

.bubble-item:hover {
  transform: translateY(-1px);
  border-color: #d0d0d0;
  background: #f0f0f0;
  /* Fondo más oscuro al hover */
}

.bubble-item.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 8px 24px rgba(21, 101, 216, .18);
}

/* ===== KPI Cards ===== */
.card.kpi {
  border: 1px solid #eef0f4;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card.kpi .kpi-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #edf2ff;
  color: var(--brand);
  border-radius: 12px;
  margin-bottom: .5rem;
  font-size: 1.1rem;
}

.card.kpi .kpi-title {
  color: #475467;
  font-size: .9rem;
}

.card.kpi .kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
}

/* ============================================================
   MEJORAS UI/UX LISTAS, CATÁLOGO Y DETALLE DE PEDIDOS
   ============================================================ */

/* Cards redondeadas consistentes */
.card.rounded-4 {
  border-radius: var(--radius-lg) !important;
}

.card.shadow {
  box-shadow: var(--shadow-sm) !important;
}

/* ✅ Header neutro para cards (evita barra azul dentro de cards) */
.card .card-header.head-neutral {
  background: #fff !important;
  color: #1f2937 !important;
  /* slate-800 aprox */
  border-bottom: 1px solid #edf0f4;
}

/* Tablas compactas con hover suave */
.table-sm> :not(caption)>*>* {
  padding: .45rem .6rem;
}

.table tbody tr:hover {
  background: #fafcff;
}

/* Cabeceras de tabla "sticky" (en contenedor con scroll) */
.table-responsive thead th,
.card .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  box-shadow: inset 0 -1px 0 #e9ecef;
}

/* Sin bordes duros en tablas dentro de cards */
.card .table {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

/* Badges un poco más legibles en tablas */
.table .badge {
  font-weight: 600;
  letter-spacing: .02em;
}

/* Botones de acción en filas: mantener iconos clicables y alineados */
.table .btn i {
  pointer-events: none;
}

/* Estados para botón (+) del catálogo cuando no hay stock */
.table .btn[disabled],
.table .btn:disabled {
  opacity: .55 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* Buscador del catálogo: enfoque visible pero sutil */
.card .form-control:focus {
  box-shadow: 0 0 0 .2rem rgba(21, 101, 216, .08);
  border-color: #cfe0ff;
}

/* Panel de totales: cifras alineadas y monoespaciadas */
#totales {
  font-variant-numeric: tabular-nums;
}

#totales .list-group-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Cabeceras compactas en cards de pedido */
.card .card-header h5,
.card .card-header h6 {
  line-height: 1.25;
  margin: 0;
}

.card .card-header .badge {
  transform: translateY(-1px);
}

/* Inputs pequeños para edición inline en líneas */
#items-table input[type="number"] {
  height: 34px;
  font-variant-numeric: tabular-nums;
}

/* Indicador HTMX más visible pero no invasivo */
.htmx-indicator {
  display: none;
  vertical-align: middle;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request .btn,
.htmx-request button {
  pointer-events: none;
  opacity: .7;
}

/* Resaltar fila "editable" (cuando mostramos el renglón de edición) */
tr[id^="edit-row-"] {
  border-top: 1px dashed #e7e9ee;
}

tr[id^="edit-row-"] .form-label {
  font-size: .8rem;
  color: var(--muted);
}

/* Pequeño realce para acciones secundarias */
.btn-outline-secondary.btn-sm {
  --bs-btn-padding-y: .25rem;
  --bs-btn-padding-x: .45rem;
  --bs-btn-font-size: .85rem;
}

/* En listados largos, celdas de ID/etiquetas con tipografía más tenue */
.text-muted.small {
  color: #7b8a97 !important;
}

/* ============================================================
   Utilidades para plegado (flecha), cards compactas y filtros
   ============================================================ */
.collapse-toggle .bi {
  transition: transform .15s ease-in-out;
}

.collapse-toggle[aria-expanded="true"] .bi {
  transform: rotate(180deg);
}

.card-compact>.card-header {
  padding: .35rem .75rem;
}

.card-compact>.card-body {
  padding: .5rem .75rem;
}

/* Botón icon-only genérico */
.btn-icon {
  --btn-size: 28px;
  width: var(--btn-size);
  height: var(--btn-size);
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}

/* Toolbar del catálogo (buscador + filtros) */
.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.catalog-toolbar .form-control,
.catalog-toolbar .form-select,
.catalog-toolbar .form-select-sm {
  height: 34px;
  padding: .25rem .5rem;
}

.catalog-toolbar .form-check {
  margin-bottom: 0;
}

/* ============================================================
   Más aire en cards de la columna derecha
   ============================================================ */
.card-compact>.card-header {
  padding: .5rem 1rem;
}

.card-compact>.card-body {
  padding: .85rem 1rem;
}

#totales,
#adjuntos-panel {
  padding: .95rem 1rem;
}

.card-compact>.card-header {
  border-bottom: 1px solid #edf0f4;
}

/* ============================================================
   Pedidos: tabla de alto/ancho fijo (table-orders)
   ============================================================ */
.table-orders {
  table-layout: fixed;
  width: 100%;
}

.table-orders thead th,
.table-orders tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* Altura visual consistente por fila */
.table-orders tbody tr>* {
  padding-top: .55rem;
  padding-bottom: .55rem;
}

/* Evitar que badges "rompan" la altura */
.table-orders .badge {
  white-space: nowrap;
}

/* Anchos de columnas para table-orders */
.table-orders .col-code {
  width: 11rem;
}

/* PED-20250904-001 */
.table-orders .col-client {
  width: 6rem;
}

/* id o etiqueta corta */
.table-orders .col-date {
  width: 8.5rem;
}

/* YYYY-MM-DD */
.table-orders .col-status {
  width: 9rem;
}

/* badge */
.table-orders .col-priority {
  width: 8rem;
}

/* badge */
.table-orders .col-total {
  width: 7rem;
}

/* número */
.table-orders .col-actions {
  width: 8.5rem;
}

/* botones */
@media (max-width: 1200px) {
  .table-orders .col-code {
    width: 10rem;
  }

  .table-orders .col-actions {
    width: 7.5rem;
  }
}

/* ============================================================
   Panel azul estilo "Transacciones" + tabla compacta
   ============================================================ */
.panel-box {
  border: 1px solid #dfe6ee;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 18px rgba(16, 24, 40, .06);
}

.panel-box .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem;
  background: linear-gradient(0deg, #0d5b86, #0f4a67);
  color: #fff;
}

.panel-header .title {
  font-weight: 700;
  letter-spacing: .2px;
}

.panel-header .btn {
  --bs-btn-color: #fff;
  --bs-btn-border-color: rgba(255, 255, 255, .35);
  --bs-btn-hover-bg: rgba(255, 255, 255, .12);
  --bs-btn-hover-border-color: rgba(255, 255, 255, .55);
}

/* Toolbar superior (filtros compactos) */
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .75rem;
  background: #f7fbff;
  border-bottom: 1px solid #e6edf5;
}

.panel-toolbar .left,
.panel-toolbar .right {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.panel-toolbar .form-control,
.panel-toolbar .form-select {
  height: 32px;
  padding: .25rem .5rem;
  font-size: .875rem;
}

.panel-toolbar .btn {
  height: 32px;
  padding: .25rem .6rem;
}

/* Tabla compacta y centrada (table-transacciones) */
.table-transacciones {
  table-layout: fixed;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-transacciones thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  color: #334155;
  font-weight: 600;
  padding: .45rem .6rem;
  border-bottom: 1px solid #e5ebf3;
}

.table-transacciones tbody td {
  padding: .45rem .6rem;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.table-transacciones tbody tr:hover {
  background: #f8fbff;
}

/* Indicador de ordenamiento visual (decorativo) */
.th-sort {
  position: relative;
  padding-right: 1rem !important;
}

.th-sort::after {
  content: "▾";
  position: absolute;
  right: .35rem;
  top: 50%;
  transform: translateY(-40%);
  font-size: .7rem;
  opacity: .25;
}

.th-sort.asc::after {
  content: "▴";
}

/* Badges pequeñas */
.table-transacciones .badge {
  white-space: nowrap;
  font-weight: 700;
  font-size: .75rem;
}

/* Anchos por columna (no interfieren con table-orders) */
.table-transacciones .col-code {
  width: 220px;
}

.table-transacciones .col-client {
  width: 120px;
}

.table-transacciones .col-date {
  width: 120px;
}

.table-transacciones .col-status {
  width: 120px;
}

.table-transacciones .col-priority {
  width: 120px;
}

.table-transacciones .col-total {
  width: 120px;
}

.table-transacciones .col-actions {
  width: 150px;
}

/* "Código" queda a la izquierda; resto centrado lo controlas en HTML */
.table-transacciones td.text-truncate {
  max-width: 100%;
}

/* Acciones centradas con espacio entre botones */
.table-transacciones .actions-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  /* separa "Abrir" del basurero */
}

/* Paleta de marca */
:root {
  --brand-700: #0d4e66;
  --brand-600: #126e82;
  --brand-500: #2b7a9c;
}

/* Navbar azul (por si no lo tienes ya) */
.topbar {
  background: linear-gradient(90deg, var(--brand-700), var(--brand-600));
}

/* Franja azul de encabezado interna reutilizable */
.page-head {
  background: linear-gradient(90deg, var(--brand-600), var(--brand-500));
  color: #fff;
  border-radius: .5rem;
  padding: .75rem 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}

.page-head .form-control,
.page-head .form-select {
  height: 2.25rem;
}

.page-head .btn {
  height: 2.25rem;
  line-height: 2.25rem;
  padding-top: 0;
  padding-bottom: 0;
}

/* Switch compacto para tablas */
.form-switch.form-switch-sm .form-check-input {
  width: 2rem;
  height: 1rem;
  transform: translateY(1px);
}

.switch-cell .form-switch {
  margin: 0;
}

/* === Parche mínimo recomendado === */

/* 1) Headers de cards siempre neutros (evita franjas azules internas) */
.card>.card-header {
  background: #fff !important;
  color: #1f2937 !important;
  border-bottom: 1px solid #edf0f4;
}

/* 2) Dropdown sin "salto" y cierre más natural en hover */
@media (min-width: 992px) {
  .navbar .dropdown-menu {
    margin-top: 0 !important;
  }
}

/* ============================================================
   🎯 PICKING — Estilos oficiales WMS
   ============================================================ */

/* Contenedor del panel principal */
.picking-panel {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

/* Encabezado del picking (ícono + información) */
.picking-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.picking-header i {
  font-size: 1.4rem;
  color: var(--brand);
}

/* Línea de picking */
.picking-item {
  border: 1px solid #e5e9ef;
  border-radius: 12px;
  padding: .75rem .85rem;
  background: #fff;
  margin-bottom: .65rem;
  box-shadow: var(--shadow-xs);
  transition: all .18s ease;
  display: flex;
  flex-direction: column;
}

.picking-item:hover {
  transform: translateY(-1px);
  border-color: #d8dde6;
}

/* Estado completado */
.picking-item.completed {
  background: #eaffea;
  border-color: #b5e3b5;
}

.picking-item.completed .qty {
  color: #1a7f1a;
  font-weight: 700;
}

/* Estado faltante */
.picking-item.partial {
  background: #fff8e6;
  border-color: #f2d08c;
}

.picking-item.partial .qty {
  color: #d28100;
  font-weight: 700;
}

/* Estado error (ubicación incorrecta) */
.picking-item.error {
  background: #ffecec;
  border-color: #f1b1b1;
}

.picking-item.error .qty {
  color: #cc0000;
  font-weight: 700;
}

/* Encabezado interno de cada ítem */
.picking-item .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .4rem;
}

.picking-item .code {
  font-weight: 700;
  color: #0f2b45;
  font-size: .95rem;
}

.picking-item .status-badge {
  font-size: .7rem;
  padding: .15rem .45rem;
  border-radius: 8px;
  letter-spacing: .02em;
}

.status-pendiente {
  background: #e2e8f0;
  color: #475569;
}

.status-parcial {
  background: #fff1c2;
  color: #b36b00;
}

.status-completo {
  background: #d1fadf;
  color: #007f3b;
}

/* Sección inferior del ítem */
.picking-item .bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  margin-top: .4rem;
}

.picking-item .location {
  font-weight: 600;
  color: #2b4a7f;
}

/* Ubicación sugerida con estilo especial */
.location-suggested {
  background: #eef6ff;
  color: #0a4b83;
  padding: .2rem .45rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
}

/* Badge cantidad */
.qty {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Botón de escanear */
.btn-scan {
  background: var(--brand);
  border: none;
  color: #fff;
  padding: .45rem .9rem;
  border-radius: 8px;
  font-weight: 600;
  transition: background .15s ease;
}

.btn-scan:hover {
  background: #0f5cb8;
}

/* Zona de captura */
.scan-box {
  border: 2px dashed #adc4d5;
  padding: 1rem;
  text-align: center;
  border-radius: 12px;
  background: #f7fbff;
  color: #56718f;
  margin-bottom: 1rem;
}

.scan-box i {
  font-size: 1.8rem;
  margin-bottom: .25rem;
}

/* Botones de acción inferior */
.picking-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

.btn-complete-task {
  background: #007d4c;
  color: #fff;
  border: none;
  padding: .5rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
}

.btn-complete-task:hover {
  background: #00663e;
}

/* ============================================================
   📊 MEJORA DE CONTRASTE EN TABLAS (WMS) - MEJORADO
   ============================================================ */

.card .table {
  border: 1px solid #d1d9e6;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table thead th {
  background: #1e3a5f !important;
  /* 🔵 AZUL OSCURO NOTORIO para encabezados */
  color: #ffffff !important;
  font-weight: 600;
  border-bottom: 3px solid #0d2847;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem !important;
}

.table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.table tbody tr:hover {
  background: #e8f0ff !important;
  box-shadow: inset 0 0 0 1px #d0e0ff;
}

/* Bordes suaves entre columnas */
.table th:not(:last-child),
.table td:not(:last-child) {
  border-right: 1px solid #f0f4f8;
}

/* Mejor separación entre filas */
.table tbody tr {
  border-bottom: 1px solid #f0f4f8;
}

.table tbody tr:last-child {
  border-bottom: none;
}

/* Asegurar consistencia en todas las tablas */
.table> :not(caption)>*>* {
  padding: 0.65rem 1rem;
  vertical-align: middle;
}

/* ============================================================
   📦 CONTRASTE GENERAL DE CONTENIDO
   ============================================================ */

.bg-page {
  background: #e6ecf5;
  /* Color más oscuro para mejor contraste */
}

.card {
  background: #ffffff;
  border: 1px solid #e1e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   🎨 MEJORAS ESPECÍFICAS PARA BURBUJAS Y ELEMENTOS
   ============================================================ */

/* Fondo de contenedores de burbujas */
.bubble-vertical-container {
  background: #f0f4f9;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid #dce4ee;
  margin-bottom: 1.5rem;
}

/* Ajustes para burbujas tipo tarjeta */
.bubble-item {
  background: #f5f7fa;
  /* Gris claro tipo #BABABA mejorado */
  border: 1px solid #d5dce6;
  transition: all 0.2s ease;
}

.bubble-item:hover {
  background: #eef2f8;
  border-color: #b8c4d6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bubble-item.active {
  background: linear-gradient(135deg, #1565d8, #0a4b9c);
  border-color: #0a4b9c;
  color: #ffffff;
}

/* Separadores visuales mejorados */
hr,
.border-bottom {
  border-color: #e2e8f0 !important;
}

/* ============================================================
   🎯 MEJORAS DE LEGIBILIDAD GENERAL
   ============================================================ */

/* Mejor contraste para texto */
.text-muted {
  color: #6b7280 !important;
}

/* Mejor contraste para encabezados de cards */
.card-header {
  background: #f8fafc !important;
  border-bottom: 2px solid #e2e8f0 !important;
  color: #1e293b !important;
  font-weight: 600;
}

/* Sombra sutil para mejor profundidad */
.shadow-sm {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.shadow {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
}

/* ============================================================
   ✅ FIX WMS PRO: Dropdowns NO recortados + Toast (burbuja)
   - Soluciona: menú "Opciones" cortado dentro de cards/tablas
   - Agrega: estilos para toast inferior derecha (flash messages)
   ============================================================ */

/* 1) Dropdowns siempre por encima */
.dropdown-menu {
  z-index: 2000 !important;
}

/* 2) Evitar recorte de dropdowns dentro de cards/tablas */
.card,
.card-body,
.card-header {
  overflow: visible !important;
}

/* OJO: Este era el recorte real que te está matando el dropdown */
.card .table {
  overflow: visible !important;
  /* antes estaba hidden */
}

/* Si usas table-responsive, mantener scroll X pero permitir overflow Y */
.table-responsive {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

/* 3) Toast container (flash) abajo-derecha */
.toast-container {
  z-index: 2500 !important;
}

/* look & feel más pro */
.toast {
  border-radius: 14px !important;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .18) !important;
}

.toast .toast-body {
  font-size: .92rem;
}

.toast .btn-close {
  filter: invert(1);
  opacity: .9;
}

/* ============================================================
   ✨ PREMIUM UI HELPERS
   ============================================================ */

.card.premium-card {
  border: none;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  /* Soft shadow */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
  position: relative;
}

.card.premium-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
}

.card.premium-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--grad-primary);
}

.card.premium-card.card-success::before {
  background: var(--grad-success);
}

.card.premium-card.card-warning::before {
  background: var(--grad-warning);
}

.card.premium-card.card-danger::before {
  background: var(--grad-danger);
}

.card.premium-card.card-info::before {
  background: var(--grad-info);
}

.card-icon-bg {
  width: 60px;
  height: 60px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #fff;
  margin-bottom: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.bg-grad-primary {
  background: var(--grad-primary) !important;
}

.bg-grad-success {
  background: var(--grad-success) !important;
}

.bg-grad-warning {
  background: var(--grad-warning) !important;
}

.bg-grad-danger {
  background: var(--grad-danger) !important;
}

.bg-grad-info {
  background: var(--grad-info) !important;
}

.bg-grad-dark {
  background: var(--grad-dark) !important;
}


.text-grad-primary {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}


/* =========================================
   🌙 DARK MODE OVERRIDES (Polished Slate)
   ========================================= */
[data-bs-theme="dark"] {
  /* --- PALETTE: Slate/Zinc Theme --- */
  --bg-page: #0f172a;
  /* Deep Slate Background */
  --card: #1e293b;
  /* Surface Color */
  --muted: #94a3b8;
  /* Muted Text */
  --border-color: #334155;
  /* Subtle Border */
  --input-bg: #020617;
  /* Input Background (Darker) */
  --text-main: #f8fafc;
  /* Main Text */
  --brand-glow: rgba(56, 189, 248, 0.5);
  /* Cyan/Blue Glow */

  /* --- GLOBAL LAYOUT --- */
  body,
  html {
    background-color: var(--bg-page) !important;
    color: var(--text-main);
  }

  /* Fix Catalog/Sidebar Layouts */
  .catalog-layout,
  .catalog-main-content,
  .main-content,
  .app-container {
    background-color: var(--bg-page) !important;
  }

  .catalog-sidebar-container {
    background-color: var(--card) !important;
    border-right-color: var(--border-color) !important;
  }

  /* Topbar adjustment */
  .topbar {
    background: #020617 !important;
    /* Almost black */
    border-bottom: 1px solid var(--border-color);
  }

  /* --- COMPONENTS --- */

  /* Cards & Containers */
  .card,
  .stats-card,
  .info-card,
  .picking-panel,
  .bubble-vertical-container {
    background-color: var(--card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-main);
  }

  .card-header,
  .modal-header,
  .modal-footer,
  .card-footer {
    background-color: rgba(0, 0, 0, 0.2) !important;
    /* Slightly darker than card */
    border-color: var(--border-color) !important;
    color: var(--text-main) !important;
  }

  /* Titles & Headings */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  .h1,
  .h2,
  .h3,
  .h4,
  .h5,
  .h6,
  .card-title,
  .modal-title {
    color: #f1f5f9 !important;
  }

  .text-muted,
  .small.text-muted {
    color: var(--muted) !important;
  }

  /* --- FORMS & INPUTS --- */
  .form-control,
  .form-select,
  .input-group-text,
  .search-input {
    background-color: var(--input-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-main) !important;
  }

  .form-control::placeholder {
    color: #475569;
  }

  .form-control:focus,
  .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.25rem rgba(14, 165, 233, 0.25);
    background-color: var(--input-bg) !important;
    color: #fff !important;
  }

  .form-check-input {
    background-color: var(--input-bg);
    border-color: var(--border-color);
  }

  /* --- TABLES --- */
  .table {
    --bs-table-color: var(--text-main);
    --bs-table-bg: var(--card);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  }

  .table-responsive thead th,
  .table thead th {
    background-color: #0f172a !important;
    /* Header darker */
    color: #e2e8f0 !important;
    border-bottom-color: var(--border-color);
  }

  .table td,
  .table th {
    border-color: var(--border-color);
  }

  /* --- BUTTONS --- */
  .btn-light,
  .btn-white {
    background-color: #334155;
    border-color: #475569;
    color: #f8fafc;
  }

  .btn-light:hover {
    background-color: #475569;
    color: #fff;
  }

  .btn-outline-secondary {
    border-color: #64748b;
    color: #94a3b8;
  }

  .btn-outline-secondary:hover {
    background-color: #334155;
    color: #fff;
  }

  /* Dashboard Shortcut Buttons */
  .btn-nice-shortcut {
    background: var(--card) !important;
    border: 1px solid var(--border-color) !important;
  }

  .btn-nice-shortcut:hover {
    background: #334155 !important;
  }

  /* --- MODALS & DROPDOWNS --- */
  .modal-content {
    background-color: var(--card);
    border: 1px solid var(--border-color);
  }

  .dropdown-menu {
    background-color: var(--card);
    border-color: var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  }

  .dropdown-item {
    color: var(--text-main);
  }

  .dropdown-item:hover,
  .dropdown-item:focus {
    background-color: #334155;
    color: #fff;
  }

  .dropdown-header {
    color: #94a3b8;
  }

  .dropdown-divider {
    border-top-color: var(--border-color);
  }

  /* Close Button Invert */
  .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
  }

  /* --- SPECIFIC MODULE FIXES --- */

  /* Compras/Pedidos Visuals */
  .badge.bg-light {
    background-color: #334155 !important;
    color: #fff !important;
    border-color: #475569 !important;
  }

  /* Bubbles */
  .bubble-item {
    background-color: var(--card);
    border-color: var(--border-color);
    color: var(--text-main);
  }

  .bubble-item:hover {
    background-color: #334155;
  }

  /* Picking */
  .scan-box {
    background-color: rgba(15, 23, 42, 0.5);
    border-color: #334155;
    color: #cbd5e1;
  }

  /* Empty States */
  .empty-state i {
    opacity: 0.5;
    color: #64748b;
  }
}/* ============================================================
   PDA & HANDHELD MOBILE ADAPTATION
   ============================================================ */
@media (max-width: 991.98px) {
    /* Typographic scaling down SUPER AGGRESSIVE for PDA */
    html { font-size: 12px !important; }
    body { font-size: 12px !important; }
    
    h1, .h1 { font-size: 1.3rem !important; }
    h2, .h2 { font-size: 1.15rem !important; }
    h3, .h3 { font-size: 1.05rem !important; }
    h4, .h4 { font-size: 0.95rem !important; }
    h5, .h5 { font-size: 0.85rem !important; }
    h6, .h6 { font-size: 0.75rem !important; }
    
    /* Target only specific text containers, not ALL divs/spans to avoid breaking flex/icons */
    p, label, th, td, li { font-size: 0.85rem !important; }
    input, select, .btn { font-size: 0.85rem !important; }
    
    strong, b, .fw-bold { font-size: 0.9rem !important; }
    small, .small, .text-xs, .text-muted { font-size: 0.75rem !important; }
    
    .fs-1 { font-size: 1.3rem !important; }
    .fs-2 { font-size: 1.15rem !important; }
    .fs-3 { font-size: 1.05rem !important; }
    .fs-4 { font-size: 0.95rem !important; }
    .fs-5 { font-size: 0.85rem !important; }
    .fs-6 { font-size: 0.75rem !important; }
    
    .display-1, .display-2, .display-3 { font-size: 1.5rem !important; }
    
    /* Minimize visual footprint of general UI layers */
    .py-4, .py-5 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
    .px-4, .px-5 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .p-4, .p-5 { padding: 0.75rem !important; }
    .mb-4, .mb-5, .my-4, .my-5 { margin-bottom: 0.75rem !important; }
    .mt-4, .mt-5, .my-4, .my-5 { margin-top: 0.75rem !important; }
    
    .card-body { padding: 0.75rem !important; }
    
    /* General buttons scale down */
    .btn { padding: 0.35rem 0.65rem !important; }
    .btn-lg { padding: 0.5rem 0.75rem !important; font-size: 0.9rem !important; }
    .btn-sm { padding: 0.25rem 0.5rem !important; font-size: 0.75rem !important; }
    
    /* Inputs scale down */
    .input-group-lg > .form-control, .input-group-lg > .form-select, .input-group-lg > .input-group-text, .input-group-lg > .btn { padding: 0.5rem !important; font-size: 0.9rem !important; }
    .form-control, .form-select { height: auto !important; padding: 0.35rem 0.5rem !important; }
    
    /* Hero Scanner specifically */
    .ops-hero-icon { font-size: 2.5rem !important; margin-bottom: 0.5rem !important; }
    .ops-hero-title { font-size: 1.1rem !important; margin-bottom: 0.5rem !important; }
    .ops-hero-subtitle { display: none !important; }
    
    /* Sticky action bar */
    .sticky-action-bar-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: white;
        border-top: 1px solid #e0e0e0;
        padding: 0.75rem 1rem;
        z-index: 1040;
        display: flex;
        gap: 0.5rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }
    .has-sticky-action-bar { padding-bottom: 80px !important; }
    
    /* Refactor de Tabla Desktop a Mobile Cards */
    .table-responsive.mobile-cards table { display: block; border: none; }
    .table-responsive.mobile-cards thead { display: none; }
    .table-responsive.mobile-cards tbody, .table-responsive.mobile-cards tr, .table-responsive.mobile-cards td { display: block; }
    .table-responsive.mobile-cards tr { background: #fff; margin-bottom: 0.75rem; border: 1px solid #dee2e6; border-radius: 8px; padding: 0.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
    .table-responsive.mobile-cards td { border: none !important; padding: 0.25rem 0.5rem !important; display: flex; justify-content: space-between; align-items: center; }
    .table-responsive.mobile-cards td::before { content: attr(data-label); font-weight: bold; color: #6c757d; font-size: 0.75rem; margin-right: 1rem; }
    .table-responsive.mobile-cards td.text-end { text-align: right !important; justify-content: flex-end; width: 100%; margin-top: 0.5rem; border-top: 1px solid #f1f5f9 !important; padding-top: 0.5rem !important; }
    .table-responsive.mobile-cards td.text-end::before { display: none; }
}

/* ==========================================
   ✅ SMART TABLES TO CARDS (MOBILE)
   Convierte tablas complejas en tarjetas legibles
   ========================================== */
@media (max-width: 767.98px) {
  .table-responsive-stack tr {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1rem;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  }
  .table-responsive-stack thead {
    display: none; /* Ocultamos la cabecera original */
  }
  .table-responsive-stack td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    padding: 0.5rem 0;
    font-size: 0.95rem;
  }
  .table-responsive-stack td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #666;
    margin-right: 1rem;
    text-transform: uppercase;
    font-size: 0.75rem;
  }
  .table-responsive-stack td:last-child {
    border-top: 1px solid #f0f0f0;
    margin-top: 0.5rem;
    padding-top: 1rem;
    justify-content: center;
  }
}
