/* ============================================================
   GoCRM — Componentes de UI
   ============================================================ */

/* ---------------- Botones ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: #334155;
}
.btn-ghost:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-whatsapp {
  background: #25d366;
  color: #073b1f;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.28);
}
.btn-whatsapp:hover:not(:disabled) { background: #1ebe57; color: #fff; }

.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: #e0e7ff; }

.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: #f1f5f9; color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-icon.success:hover { background: var(--success-bg); color: var(--success); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  color: #334155;
  cursor: pointer;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: #f8fafc; }

/* ---------------- Formularios ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: #334155; }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}

.input::placeholder, .textarea::placeholder { color: var(--muted-2); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.textarea { resize: vertical; min-height: 74px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------------- Tarjetas ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.card-title { font-size: 14.5px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card-body { padding: 16px 18px; }
.card-body.p0 { padding: 0; }

/* ---------------- Toolbar ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar .search {
  position: relative;
  flex: 1 1 250px;
  max-width: 330px;
}

.toolbar .search input { padding-left: 36px; }

.toolbar .search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  pointer-events: none;
}

.toolbar .select { width: auto; min-width: 145px; }
.toolbar .spacer { flex: 1; }

/* ---------------- KPIs ---------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 17px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 3px; }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}
.kpi-icon svg { width: 21px; height: 21px; }
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.amber { background: var(--warn-bg); color: var(--warn); }
.kpi-icon.red { background: var(--danger-bg); color: var(--danger); }

/* ---------------- Grillas de paneles ---------------- */

.grid-2 {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
  }
  .kpi {
    padding: 12px 14px;
    gap: 8px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }
  .kpi-icon svg {
    width: 17px;
    height: 17px;
  }
  .kpi-foot {
    display: none;
  }
}

/* ---------------- Tablas ---------------- */

.table-wrap { width: 100%; overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }

.table tr.row-low {
  background: #ffffff;
  border-left: 3px solid #f59e0b;
}
.table tr.row-low:hover { background: #fffdf7; }
.table tr.row-out {
  background: #ffffff;
  border-left: 3px solid #ef4444;
}
.table tr.row-out:hover { background: #fff8f8; }
.table tr.row-out .cell-sub { color: #64748b; }

.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---------------- Badges ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.4;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok, .badge-recibido, .badge-activo { background: var(--success-bg); color: var(--success); }
.badge-low, .badge-enviado { background: var(--warn-bg); color: var(--warn); }
.badge-out, .badge-cancelado { background: var(--danger-bg); color: var(--danger); }
.badge-borrador, .badge-inactivo, .badge-neutral { background: #f1f5f9; color: #475569; }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---------------- Chips / utilidades ---------------- */

.chip {
  display: inline-block;
  background: #f1f5f9;
  color: #475569;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-8 { gap: 8px; }

/* ---------------- Barras (dashboard) ---------------- */

.bar-row {
  display: grid;
  grid-template-columns: 86px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.bar-row:last-child { margin-bottom: 0; }

.bar {
  height: 8px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.35s ease;
}

.bar-row .bar-count { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.bar-row[data-estado="enviado"] .bar > i { background: #f59e0b; }
.bar-row[data-estado="recibido"] .bar > i { background: #22c55e; }
.bar-row[data-estado="cancelado"] .bar > i { background: #ef4444; }

/* ---------------- Stepper de stock ---------------- */

.stepper { display: inline-flex; align-items: center; gap: 5px; }

.stepper button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #475569;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.stepper button:hover { background: #f1f5f9; color: var(--text); }
.stepper b {
  min-width: 30px;
  text-align: center;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade-in 0.15s ease;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.35);
  animation: pop-in 0.16s ease;
}

.modal.modal-xl { max-width: 960px; width: 96vw; }
.modal.modal-lg { max-width: 780px; }
.modal.modal-sm { max-width: 430px; }

.modal-head {
  padding: 17px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.modal-body { padding: 20px; overflow-y: auto; }

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  background: #f8fafc;
  border-radius: 0 0 16px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex: none;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------------- Toasts ---------------- */

.toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 11px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  max-width: 380px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.3);
  border-left: 3px solid #64748b;
  animation: toast-in 0.2s ease;
  pointer-events: auto;
}

.toast svg { width: 17px; height: 17px; flex: none; }
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast.info { border-left-color: #3b82f6; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- Empty state / loading ---------------- */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #94a3b8;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
}
.empty-icon svg { width: 22px; height: 22px; }
.empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 3px; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 90px 20px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Detalle (modales) ---------------- */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.detail-item label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2px;
}

.detail-item span { font-size: 13.5px; font-weight: 600; word-break: break-word; }

.info-banner {
  background: var(--primary-soft);
  color: #3730a3;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.info-banner svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ---------------- Constructor de items (pedidos) ---------------- */

.item-builder {
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 14px;
}

.builder-row {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) 140px 82px 105px auto;
  gap: 9px;
  align-items: end;
}

.builder-row .field > span { font-size: 11px; }

.builder-hint {
  min-height: 17px;
  margin-top: 6px;
  padding: 0 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.price-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  background: #fffbeb;
}

.price-alert[hidden] { display: none; }

.price-alert-main { flex: 1; min-width: 0; }

.price-alert-title {
  font-size: 13px;
  font-weight: 700;
  color: #92400e;
}

.price-alert-text {
  margin-top: 3px;
  font-size: 12px;
  color: #78350f;
}

.price-alert-list {
  margin: 8px 0 0;
  padding-left: 18px;
  max-height: 150px;
  overflow: auto;
  font-size: 12px;
  color: #78350f;
}

.price-alert-list li { margin: 3px 0; }

.price-alert-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .price-alert { flex-direction: column; }
  .price-alert-actions { width: 100%; }
}

/* Buscador de productos (combobox) */
.product-picker { position: relative; }

.picker-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.16);
  padding: 4px;
}

.picker-results[hidden] { display: none; }

.picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.picker-option:hover,
.picker-option.active { background: #eef2ff; }

.picker-option .po-main { min-width: 0; }
.picker-option .po-name { font-size: 13px; font-weight: 600; }
.picker-option .po-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.picker-option .po-price { font-size: 12px; color: var(--muted); white-space: nowrap; }

.picker-empty { padding: 9px 10px; font-size: 12.5px; color: var(--muted); }

.items-list { margin-top: 14px; }

.items-list table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: 9px; overflow: hidden; }
.items-list th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 10px;
  background: #f1f5f9;
}
.items-list td { padding: 8px 10px; border-top: 1px solid var(--border-soft); }
.items-list td.num { text-align: right; font-variant-numeric: tabular-nums; }
.items-list .remove { color: var(--danger); background: none; border: 0; cursor: pointer; display: inline-grid; place-items: center; }
.items-list .remove svg { width: 15px; height: 15px; }

.total-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 12px;
  padding: 12px 4px 0;
  font-size: 13px;
  color: var(--muted);
}
.total-row strong { font-size: 19px; color: var(--text); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .builder-row { grid-template-columns: 1fr 1fr; }
  .builder-row .field:first-child { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-foot { flex-wrap: wrap; }
}

/* ---------------- Dashboard: alertas ---------------- */

.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.alert-row:last-child { border-bottom: 0; }

.alert-row .alert-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  flex: none;
}
.alert-row.is-out .alert-dot { background: #ef4444; }
.alert-row .alert-main { flex: 1; min-width: 0; }
.alert-row .alert-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-row .alert-meta { font-size: 11.5px; color: var(--muted); }
.alert-row .alert-stock { font-size: 12px; font-weight: 700; white-space: nowrap; }
.alert-row .alert-stock.low { color: var(--warn); }
.alert-row .alert-stock.out { color: var(--danger); }

/* ---------------- Escáner de Códigos de Barras ---------------- */

.scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 380px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.scanner-target {
  position: relative;
  width: 75%;
  height: 60%;
  max-width: 280px;
  max-height: 180px;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  border-radius: 10px;
}

.scanner-target .corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid #6366f1;
}

.scanner-target .corner.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.scanner-target .corner.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.scanner-target .corner.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.scanner-target .corner.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: scanAnim 2s ease-in-out infinite alternate;
}

@keyframes scanAnim {
  0% { top: 5%; }
  100% { top: 95%; }
}

.scanner-actions-bar {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
}

.scanner-actions-bar .btn.active {
  background: #fef08a;
  color: #854d0e;
}

.scanner-status {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

/* ---------------- Barra Móvil Inferior (Bottom Bar) ---------------- */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  grid-template-columns: repeat(5, 1fr);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 0;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-item.scan-action {
  color: #ffffff;
}

.mobile-nav-item.scan-action .scan-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.35);
  margin-top: -14px;
}

@media (max-width: 900px) {
  .mobile-bottom-nav {
    display: grid;
  }
  .view {
    padding-bottom: 85px !important;
  }
}

/* ============================================================
   Estilos de Ticket Térmico (58mm / 80mm) y Veri*factu
   ============================================================ */

.ticket-modal-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ticket-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.ticket-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border);
}
.btn-group .btn:last-child {
  border-right: none;
}
.btn-group .btn.active {
  background: var(--primary);
  color: #ffffff;
}

.ticket-preview-container {
  display: flex;
  justify-content: center;
  background: #cbd5e1;
  padding: 24px 16px;
  border-radius: 12px;
  max-height: 520px;
  overflow-y: auto;
}

.ticket-paper {
  background: #ffffff;
  color: #0f172a;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 16px 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  box-sizing: border-box;
}

.ticket-paper.width-58 {
  width: 250px;
}

.ticket-paper.width-80 {
  width: 340px;
}

.ticket-header {
  text-align: center;
  margin-bottom: 8px;
}

.ticket-brand {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.ticket-muted {
  font-size: 10.5px;
  color: #475569;
}

.ticket-divider {
  border-top: 1px dashed #64748b;
  margin: 8px 0;
}

.ticket-meta {
  font-size: 11px;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ticket-desc {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-val {
  font-weight: 600;
  flex: none;
}

.ticket-subrow {
  font-size: 10.5px;
  color: #475569;
  margin-bottom: 4px;
}

.ticket-total-strong {
  font-size: 15px;
  font-weight: bold;
  border-top: 1px solid #0f172a;
  padding-top: 4px;
  margin-top: 4px;
}

.ticket-verifactu {
  text-align: center;
  margin: 10px 0;
}

.ticket-verifactu-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: bold;
  padding: 2px 6px;
  border: 1px solid #0f172a;
  border-radius: 3px;
  margin-bottom: 4px;
}

.ticket-hash {
  font-size: 8.5px;
  color: #64748b;
  word-break: break-all;
  font-family: monospace;
}

.ticket-qr-box {
  margin-top: 6px;
}

.ticket-qr {
  width: 100px;
  height: 100px;
  display: block;
  margin: 0 auto;
}

.ticket-qr-caption {
  font-size: 8.5px;
  color: #64748b;
}

.ticket-footer {
  text-align: center;
  font-size: 10px;
  color: #475569;
  margin-top: 8px;
}

/* ============================================================
   Reglas de Impresión (@media print) para Tickets Térmicos
   ============================================================ */
@media print {
  @page {
    margin: 0;
    size: auto;
  }

  body * {
    visibility: hidden;
  }

  #printable-ticket,
  #printable-ticket * {
    visibility: visible;
  }

  #printable-ticket {
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 6mm 4mm !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  .ticket-preview-container {
    background: transparent !important;
    padding: 0 !important;
  }
}

/* ============================================================
   Hoja de Pedido Rápido (Order Sheet) — Móvil y Escritorio
   ============================================================ */
.modal-order-sheet {
  max-width: 920px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}

@media (max-width: 767px) {
  .modal-overlay:has(.modal-order-sheet) {
    padding: 0;
  }
  .modal.modal-order-sheet {
    max-width: 100% !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal.modal-order-sheet .modal-body {
    padding: 12px 12px 6px 12px;
  }
}

.order-sheet-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.order-form-header {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.order-header-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.order-header-row .flex-2 { flex: 2; min-width: 200px; }
.order-header-row .flex-1 { flex: 1; min-width: 140px; }

.order-obs-details {
  margin-top: 8px;
  cursor: pointer;
}
.order-obs-details summary {
  user-select: none;
  font-weight: 500;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.order-obs-details summary:hover {
  text-decoration: underline;
}

/* Barra de herramientas / buscador y tabs */
.order-sheet-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-bottom: 4px;
}

.order-sheet-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.order-sheet-search-wrap .search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.order-sheet-search {
  padding-left: 36px !important;
  padding-right: 44px !important;
  height: 40px;
  font-size: 14px;
  border-radius: 10px;
}

.btn-scan-inline {
  position: absolute;
  right: 5px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
  border: none;
  cursor: pointer;
}
.btn-scan-inline:hover {
  background: #e0e7ff;
}

/* Tabs: Todos / En pedido */
.order-sheet-tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
  user-select: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #475569;
}
.tab-btn.active .tab-badge {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Contenedor scrolleable del catálogo */
.order-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 8px 2px;
}

@media (max-width: 767px) {
  .order-sheet-list {
    max-height: none;
    flex: 1;
  }
}

/* Tarjeta individual de producto */
.order-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.order-card.is-selected {
  border-color: #6366f1;
  background: #f8faff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.1);
}

.order-card.flash-glow {
  animation: card-pulse 1s ease;
}

@keyframes card-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7); }
  30% { transform: scale(1.015); box-shadow: 0 0 0 8px rgba(79, 70, 229, 0.2); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.order-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.order-card-meta {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  flex-wrap: wrap;
}

.stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}
.stock-chip.stock-ok {
  background: #ecfdf5;
  color: #047857;
}
.stock-chip.stock-low {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Cuerpo de la tarjeta */
.order-card-body {
  display: grid;
  grid-template-columns: minmax(130px, 1.4fr) minmax(110px, 1fr) minmax(140px, 1.2fr) minmax(90px, 0.9fr);
  gap: 12px;
  align-items: end;
}

.order-field-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.order-field-col .field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.order-price-input {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  height: 38px;
}

/* Stepper táctil */
.stepper {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
  width: 100%;
  max-width: 160px;
  user-select: none;
}

.stepper-btn {
  width: 40px;
  height: 36px;
  min-width: 40px;
  border: none;
  background: var(--surface);
  border-radius: 7px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  touch-action: manipulation;
  transition: background-color 0.1s ease, transform 0.08s ease;
}
.stepper-btn:active {
  background: #e2e8f0;
  transform: scale(0.94);
}
.stepper-btn.btn-inc {
  color: var(--primary);
}

.stepper-input {
  flex: 1;
  width: 40px;
  min-width: 0;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding: 2px;
  -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.order-subtotal-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  height: 36px;
  display: flex;
  align-items: center;
}
.order-card.is-selected .order-subtotal-val {
  color: var(--primary);
}

.order-subtotal-units {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.presentation-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  padding: 8px 10px;
  border-radius: 7px;
  height: 38px;
  box-sizing: border-box;
}

/* Versión móvil de la tarjeta */
@media (max-width: 640px) {
  .order-card-body {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .order-field-col.col-qty {
    grid-column: 1 / 2;
  }
  .order-field-col.col-subtotal {
    grid-column: 2 / 3;
    align-items: flex-end;
    text-align: right;
  }
  .stepper {
    max-width: 100%;
  }
  .stepper-btn {
    height: 40px;
  }
}

/* Footer con resumen sticky */
.order-sheet-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
}

.order-summary-box {
  display: flex;
  flex-direction: column;
}

.order-summary-count {
  font-size: 12px;
  color: var(--muted);
}

.order-summary-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.order-summary-total strong {
  font-size: 18px;
  color: var(--primary);
}

.order-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  .order-sheet-footer-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .order-summary-box {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
  .order-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 8px;
  }
  .order-footer-actions .btn {
    height: 44px;
    font-size: 14px;
  }
}

/* ============================================================
   Imágenes de Productos (Inventario, Pedidos y TPV)
   ============================================================ */
.product-image-upload {
  width: 100%;
}

.img-placeholder {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.img-placeholder:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.img-placeholder-icon {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-placeholder:hover .img-placeholder-icon {
  color: var(--primary);
}

.img-placeholder-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.img-placeholder-hint {
  font-size: 11px;
  color: var(--muted);
}

.img-preview-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.img-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 9px;
  border: 1px solid var(--border-soft);
  cursor: pointer;
}

.img-remove-btn {
  color: var(--danger) !important;
}

/* Celdas con miniaturas en tablas de inventario */
.prod-table-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prod-thumb {
  width: 44px;
  height: 44px;
  min-width: 44px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.prod-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.prod-thumb-empty {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: #f1f5f9;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

.prod-table-info {
  min-width: 0;
}

/* Identidad del producto en tarjeta de Order Sheet */
.order-card-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.order-prod-thumb {
  width: 48px;
  height: 48px;
  min-width: 48px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 2px;
}

.order-prod-thumb-empty {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: #f1f5f9;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

/* ============================================================
   Catálogo de Inventario — Vistas Responsivas (Escritorio y Móvil)
   ============================================================ */

.inv-desktop-view {
  display: block;
}

.inv-mobile-view {
  display: none;
}

.toolbar-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 300px;
}

.toolbar-search-row .search {
  flex: 1;
}

.toolbar-filters-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inv-catalog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inv-catalog-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inv-sort-select {
  height: 30px;
  font-size: 12px;
  padding: 0 24px 0 8px;
  border-radius: 8px;
  background: var(--surface);
  color: #475569;
  border: 1px solid var(--border);
  font-weight: 600;
  cursor: pointer;
}

.inv-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.inv-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  border: none;
  display: grid;
  place-items: center;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.inv-search-clear:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.kpi-touchable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.kpi-touchable:active {
  transform: scale(0.97);
}

.kpi-touchable.kpi-active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25) !important;
  background: #fbfbfe !important;
}

.inv-empty-state {
  text-align: center;
  padding: 36px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.inv-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #f1f5f9;
  color: var(--muted-2);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.inv-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.inv-empty-desc {
  font-size: 12px;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.4;
}

.inv-ean-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  color: #64748b;
  font-family: monospace;
  font-size: 10px;
}

.inv-margin-pill {
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
  background: #dcfce7;
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.stock-alert-text {
  color: var(--warn);
  font-weight: 600;
}

.inv-drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-soft);
}

.inv-drawer-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-drawer-reset {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.inv-drawer-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inv-drawer-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------------- Pedidos Base ---------------- */
.ped-desktop-view {
  display: block;
}

.ped-mobile-view {
  display: none;
}

.ped-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.ped-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  border: none;
  display: grid;
  place-items: center;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.ped-search-clear:hover {
  background: #cbd5e1;
  color: #0f172a;
}

/* Base styles for mobile filter bars, chips, and floating action buttons */
.inv-mobile-filters-bar,
.ped-mobile-filters-bar {
  display: none;
}

.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.chip-filter:active {
  transform: scale(0.96);
}

.chip-filter.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.chip-filter.active .chip-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.chip-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--border-soft);
  color: var(--muted);
}

.chip-filter-toggle {
  background: #f8fafc;
  color: var(--text);
  border-style: dashed;
}

.chip-filter-toggle.active {
  background: #e0e7ff;
  color: var(--primary);
  border-color: var(--primary);
  border-style: solid;
}

.inv-fab-btn,
.ped-fab-btn {
  display: none;
  position: fixed !important;
  right: 16px !important;
  bottom: 74px !important;
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4) !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 45 !important;
  cursor: pointer !important;
  transition: transform 0.15s ease !important;
  line-height: 0 !important;
  box-sizing: border-box !important;
  outline: none !important;
  -webkit-appearance: none !important;
}

.inv-fab-btn svg,
.ped-fab-btn svg {
  display: block !important;
  width: 24px !important;
  height: 24px !important;
  stroke-width: 2.5 !important;
  margin: 0 auto !important;
  flex-shrink: 0 !important;
  pointer-events: none !important;
}

.inv-fab-btn:active,
.ped-fab-btn:active {
  transform: scale(0.92) !important;
}

/* Tablet Optimization (768px - 1024px): 100% responsive, zero grey buttons, table & toolbar fitted cleanly */
@media (min-width: 768px) and (max-width: 1024px) {
  .inv-mobile-filters-bar,
  .ped-mobile-filters-bar,
  .inv-fab-btn,
  .ped-fab-btn,
  .only-mobile {
    display: none !important;
  }

  .table thead th {
    padding: 8px 10px;
    font-size: 11px;
    white-space: nowrap;
  }

  .table tbody td {
    padding: 8px 10px;
    font-size: 12.5px;
  }

  .prod-thumb {
    width: 36px;
    height: 36px;
  }

  .toolbar {
    gap: 8px;
  }

  .toolbar .select {
    min-width: 120px;
    font-size: 12px;
  }

  .toolbar-search-row {
    flex: 1 1 240px;
  }
}

@media (max-width: 767px) {
  .inv-desktop-view,
  .ped-desktop-view,
  #inv-desktop-filters,
  #ped-desktop-filters,
  .toolbar #btn-new,
  .hide-mobile {
    display: none !important;
  }

  /* KPIs ultra-compactos para móvil: reducen altura de 200px a ~62px */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin-bottom: 8px !important;
  }

  .kpi {
    padding: 7px 10px !important;
    border-radius: 10px !important;
    gap: 6px !important;
    align-items: center !important;
    min-height: 48px !important;
  }

  .kpi-info-col {
    min-width: 0;
  }

  .kpi-label {
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    margin-bottom: 2px !important;
  }

  .kpi-value {
    font-size: 15px !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
  }

  .kpi-foot {
    display: none !important;
  }

  .kpi-icon {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    border-radius: 7px !important;
  }

  .kpi-icon svg {
    width: 15px !important;
    height: 15px !important;
  }

  /* Toolbar móvil compacta */
  .toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
    margin-bottom: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    flex: 0 0 auto !important;
  }

  .toolbar .spacer {
    display: none !important;
  }

  .toolbar .search {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    position: relative !important;
    box-sizing: border-box !important;
  }

  .toolbar-search-row {
    display: flex !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 6px !important;
    box-sizing: border-box !important;
  }

  .toolbar-search-row .search {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    position: relative !important;
    box-sizing: border-box !important;
  }

  .toolbar .search input,
  .toolbar-search-row .search input {
    height: 40px !important;
    font-size: 13.5px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding-right: 36px !important;
  }

  .toolbar-search-row #btn-scan-inv {
    flex: 0 0 auto !important;
    height: 40px !important;
    padding: 0 12px !important;
    min-width: 44px !important;
    box-sizing: border-box !important;
  }

  /* Filtros rápidos táctiles (Chips de stock) */
  .inv-mobile-filters-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin-bottom: 8px !important;
  }

  .inv-filter-chips {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 2px 0 6px !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    scrollbar-width: none !important;
    touch-action: pan-y !important;
  }

  .inv-filter-chips::-webkit-scrollbar {
    display: none;
  }

  .chip-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
  }

  .chip-filter:active {
    transform: scale(0.96);
  }

  .chip-filter.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
  }

  .chip-filter.active .chip-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
  }

  .chip-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--border-soft);
    color: var(--muted);
  }

  .chip-filter-toggle {
    background: #f8fafc;
    color: var(--text);
    border-style: dashed;
  }

  .chip-filter-toggle.active {
    background: #e0e7ff;
    color: var(--primary);
    border-color: var(--primary);
    border-style: solid;
  }

  .inv-mobile-drawer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-top: 4px;
    box-shadow: var(--shadow-sm);
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .inv-mobile-drawer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .select-sm {
    height: 34px !important;
    font-size: 12px !important;
    padding: 0 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Cabecera del catálogo compacta */
  .inv-catalog-card {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .inv-catalog-head {
    padding: 6px 2px 8px !important;
    border-bottom: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .inv-catalog-title-group {
    display: flex !important;
    align-items: baseline !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .inv-catalog-title-group .card-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  .inv-catalog-title-group .card-sub {
    font-size: 11.5px !important;
    color: var(--muted) !important;
    white-space: nowrap !important;
  }

  .inv-catalog-controls {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .inv-sort-select {
    flex: 1 1 auto !important;
    height: 32px !important;
    font-size: 11.5px !important;
    padding: 0 18px 0 6px !important;
    border-radius: 8px !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }

  .inv-catalog-actions {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    box-sizing: border-box !important;
  }

  .inv-catalog-actions .btn {
    padding: 0 8px !important;
    font-size: 11px !important;
    height: 32px !important;
    border-radius: 8px !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    box-sizing: border-box !important;
  }

  .inv-catalog-actions #btn-new-head {
    font-weight: 700 !important;
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
  }

  @media (max-width: 480px) {
    .inv-catalog-actions #btn-new-head {
      display: none !important;
    }
    .inv-catalog-actions .action-btn-text {
      display: inline !important;
      font-size: 11px !important;
      font-weight: 700 !important;
    }
    .inv-catalog-actions .btn {
      padding: 0 8px !important;
      height: 32px !important;
      font-size: 11px !important;
      gap: 3px !important;
    }
  }

  /* Contenedor de lista móvil */
  .inv-mobile-view {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 0 0 75px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Tarjeta de producto móvil de alta densidad (~112px de altura) */
  .inv-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid #94a3b8;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, background-color 0.15s ease;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .inv-card.row-ok {
    border-left-color: #22c55e;
  }

  .inv-card.row-low {
    border-left-color: #f59e0b;
    background: #fffdf5;
    border-color: #fde68a;
  }

  .inv-card.row-out {
    border-left-color: #ef4444;
    background: #fff8f8;
    border-color: #fecaca;
  }

  /* Fila superior: Miniatura + Info principal */
  .inv-card-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }

  .inv-card-thumb-wrap {
    flex: none;
    width: 44px;
    height: 44px;
  }

  .inv-card-thumb {
    width: 44px;
    height: 44px;
    min-width: 44px;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 2px;
  }

  .inv-card-thumb-empty {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: #f1f5f9;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--muted-2);
  }

  .inv-card-info {
    flex: 1;
    min-width: 0;
  }

  .inv-card-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
  }

  .inv-card-name {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
  }

  .inv-card-badge {
    flex: none;
  }

  .inv-card-badge .badge {
    font-size: 10px;
    padding: 2px 7px;
  }

  .inv-card-meta-line {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
  }

  .chip-sm {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 10.5px;
    font-weight: 600;
  }

  .inv-sku-pill {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    font-family: monospace;
    font-size: 10px;
    font-weight: 600;
  }

  .inv-card-supplier-line {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #475569;
    margin-top: 2px;
  }

  /* Fila inferior: Stepper + Precios + Acciones */
  .inv-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-soft);
  }

  .inv-card-stepper-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .stepper-compact {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
  }

  .step-btn {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text);
    padding: 0;
    transition: background 0.1s;
  }

  .step-btn:hover {
    background: #e2e8f0;
  }

  .step-btn:active {
    background: #cbd5e1;
  }

  .step-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }

  .step-qty {
    min-width: 28px;
    text-align: center;
    font-size: 13.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .inv-card-stock-sub {
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 2px;
  }

  .inv-card-price-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 75px;
  }

  .inv-card-pvp {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
  }

  .pvp-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
  }

  .inv-card-cost {
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 1px;
  }

  .inv-card-actions-compact {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .btn-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
  }

  .btn-action-icon:active {
    transform: scale(0.92);
  }

  .btn-action-icon.primary {
    background: #eef2ff;
    color: var(--primary);
    border-color: #c7d2fe;
  }

  .btn-action-icon.danger {
    color: var(--danger);
  }

  /* Botón flotante para nuevo producto (FAB) */
  .inv-fab-btn {
    position: fixed !important;
    right: 16px !important;
    bottom: 74px !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 45 !important;
    cursor: pointer !important;
    transition: transform 0.15s ease !important;
    line-height: 0 !important;
    box-sizing: border-box !important;
    outline: none !important;
    -webkit-appearance: none !important;
  }

  .inv-fab-btn svg {
    display: block !important;
    width: 24px !important;
    height: 24px !important;
    stroke-width: 2.5 !important;
    margin: 0 auto !important;
    flex-shrink: 0 !important;
    pointer-events: none !important;
  }

  .inv-fab-btn:active {
    transform: scale(0.92) !important;
  }

  /* ============================================================
     PEDIDOS EN MÓVIL
     ============================================================ */

  .ped-mobile-filters-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin-bottom: 8px !important;
  }

  .ped-filter-chips {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 2px 0 6px !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    scrollbar-width: none !important;
    touch-action: pan-y !important;
  }

  .ped-filter-chips::-webkit-scrollbar {
    display: none;
  }

  .ped-mobile-provider-row {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin-top: 8px !important;
    display: block !important;
  }

  .ped-mobile-provider-row select,
  .ped-mobile-provider-row .select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    height: 38px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 9px !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    padding: 0 10px !important;
    color: var(--text) !important;
  }

  .ped-mobile-view {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 0 0 75px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ped-catalog-card {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ped-catalog-head {
    padding: 6px 2px 8px !important;
    border-bottom: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ped-catalog-title-group .card-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  .ped-catalog-title-group .card-sub {
    font-size: 11px !important;
    color: var(--muted) !important;
  }

  .ped-catalog-head #btn-new-head {
    font-weight: 700 !important;
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
    height: 28px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
  }

  /* Tarjeta de pedido móvil */
  .ped-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid #94a3b8;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, background-color 0.15s ease;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ped-card-borrador {
    border-left-color: #6366f1;
    background: #fbfbfe;
  }

  .ped-card-enviado {
    border-left-color: #f59e0b;
    background: #fffdf9;
    border-color: #fde68a;
  }

  .ped-card-recibido {
    border-left-color: #16a34a;
    background: #fcfdfd;
  }

  .ped-card-cancelado {
    border-left-color: #ef4444;
    background: #fffbfb;
    border-color: #fecaca;
    opacity: 0.85;
  }

  .ped-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .ped-card-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .ped-card-num {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    font-family: monospace;
    letter-spacing: 0.02em;
  }

  .ped-card-date {
    font-size: 11.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 3px;
  }

  .ped-card-badge {
    flex: none;
  }

  .ped-card-badge .badge {
    font-size: 10px;
    padding: 2px 7px;
  }

  .ped-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .ped-card-supplier {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--text);
    font-weight: 600;
  }

  .ped-card-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .ped-card-items-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 500;
  }

  .ped-card-total-group {
    display: flex;
    align-items: baseline;
    gap: 5px;
  }

  .ped-card-total-label {
    font-size: 10.5px;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
  }

  .ped-card-total-val {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
  }

  .ped-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px dashed var(--border-soft);
  }

  .ped-card-actions .btn {
    padding: 4px 9px !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    height: 30px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .ped-fab-btn {
    position: fixed !important;
    right: 16px !important;
    bottom: 74px !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 45 !important;
    cursor: pointer !important;
    transition: transform 0.15s ease !important;
    line-height: 0 !important;
    box-sizing: border-box !important;
    outline: none !important;
    -webkit-appearance: none !important;
  }

  .ped-fab-btn svg {
    display: block !important;
    width: 24px !important;
    height: 24px !important;
    stroke-width: 2.5 !important;
    margin: 0 auto !important;
    flex-shrink: 0 !important;
    pointer-events: none !important;
  }

  .ped-fab-btn:active {
    transform: scale(0.92) !important;
  }

  /* ============================================================
     TABLAS EN MÓVIL: Transformación a tarjetas (0 Scroll Horizontal)
     ============================================================ */
  .table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    box-sizing: border-box !important;
  }

  .table-wrap > table.table {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    border-collapse: separate !important;
    box-sizing: border-box !important;
  }

  .table-wrap > table.table > thead {
    display: none !important;
  }

  .table-wrap > table.table > tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 0 16px 0 !important;
  }

  .table-wrap > table.table > tbody > tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 10px 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  }

  .table-wrap > table.table > tbody > tr > td {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 2px 0 !important;
    border-bottom: none !important;
    font-size: 13px !important;
  }

  .table-wrap > table.table > tbody > tr > td:first-child {
    border-bottom: 1px dashed var(--border-soft) !important;
    padding-bottom: 6px !important;
    margin-bottom: 2px !important;
  }

  .table-wrap > table.table > tbody > tr > td:last-child {
    border-top: 1px dashed var(--border-soft) !important;
    padding-top: 6px !important;
    margin-top: 2px !important;
    justify-content: flex-end !important;
  }

  .table-wrap > table.table > tbody > tr > td .actions {
    width: 100% !important;
    justify-content: flex-end !important;
    gap: 6px !important;
  }

  .table-wrap > table.table > tbody > tr > td .actions .btn-icon {
    width: 34px !important;
    height: 34px !important;
  }
}

/* ============================================================
   TERMINAL PUNTO DE VENTA (TPV) — MODO PANTALLA ÚNICA 17"
   Diseño de alta densidad sin scroll estilo TPV Profesional
   ============================================================ */

.tpv-pos-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  gap: 4px;
}

/* Barra superior ultra-compacta del TPV */
.tpv-compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 8px;
  height: 38px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.tpv-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tpv-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpv-toggle-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  transition: all 0.1s ease;
}

.tpv-toggle-btn:hover {
  background: #e2e8f0;
}

.tpv-toggle-btn.active {
  background: #0070f3;
  color: #ffffff;
  border-color: #0056b3;
}

/* Raíz de 2 Columnas: Izquierda (Cobro/Ticket) + Derecha (Productos/Catálogo) */
.tpv-pos-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

/* ---------------- COLUMNA IZQUIERDA ---------------- */
.tpv-col-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Fila Superior: Tabla de Artículos + Numpad */
.tpv-upper-split {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 6px;
  flex: 1 1 50%;
  min-height: 0;
  overflow: hidden;
}

/* Tabla de Artículos */
.tpv-ticket-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.tpv-table-scrollable {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.tpv-pos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.tpv-pos-table thead th {
  background: #f8fafc;
  color: #1e293b;
  font-weight: 700;
  font-size: 11.5px;
  padding: 6px 4px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid #cbd5e1;
  text-align: left;
  user-select: none;
}

.tpv-pos-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  user-select: none;
  transition: background 0.08s;
  height: 28px;
}

.tpv-pos-table tbody tr:hover {
  background: #f8fafc;
}

.tpv-pos-table tbody tr.is-selected {
  background: #eff6ff !important;
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.tpv-pos-table td {
  padding: 4px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpv-pos-table .col-icon-btn {
  width: 24px;
  height: 24px;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.1s, transform 0.05s;
}

.tpv-pos-table .col-icon-btn:hover {
  background: #fecaca;
  color: #b91c1c;
}

.tpv-pos-table .col-icon-btn:active {
  transform: scale(0.92);
}

.tpv-qty-ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 4px;
  border: 1px solid #e2e8f0;
}

.tpv-qty-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  user-select: none;
  transition: background 0.1s, transform 0.05s;
}

.tpv-qty-btn:active {
  background: #e2e8f0;
  transform: scale(0.92);
}

.tpv-qty-btn.plus {
  color: #0284c7;
}

.tpv-qty-btn.minus {
  color: #dc2626;
}

.tpv-qty-num {
  font-weight: 800;
  font-size: 12.5px;
  color: #0f172a;
  min-width: 18px;
  text-align: center;
}

.tpv-pos-table .col-chk {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #0070f3;
}

/* Numpad Box al lado de la tabla */
.tpv-numpad-pane {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  min-height: 0;
}

.tpv-numpad-screen {
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: 4px 8px;
  height: 32px;
  font-family: ui-monospace, monospace;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  text-align: right;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.tpv-numpad-grid-3x5 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 4px;
  flex: 1;
  min-height: 0;
}

.tpv-np-btn {
  background: #0070f3;
  color: #ffffff;
  border: 1px solid #0056b3;
  border-radius: 4px;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: filter 0.08s, transform 0.05s;
}

.tpv-np-btn:active {
  filter: brightness(0.85);
  transform: translateY(1px);
}

.tpv-np-btn.btn-intro {
  grid-column: span 2;
  font-size: 14px;
  font-weight: 900;
}

/* Contenedor de Pestaña TPV */
#tpv-tab-content,
.tpv-tab-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Barra de Resumen / Totales */
.tpv-totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  flex-shrink: 0;
  height: 38px;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tpv-totals-row .tpv-tot-item strong {
  color: #0f172a;
}

.tpv-totals-row .tot-big {
  font-size: 18px;
  font-weight: 900;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  transition: transform 0.1s, color 0.1s;
}

.tpv-totals-row .tot-big:hover {
  color: #d97706;
}

.tpv-totals-row .tot-big:active {
  transform: scale(0.97);
}

/* Cuadrícula 4x4 de Acciones Táctiles (Desktop) */
.tpv-actions-4x4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 5px;
  flex: 1 1 45%;
  min-height: 0;
}

.tpv-act-tile {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  padding: 5px 3px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  position: relative;
  transition: all 0.12s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.tpv-act-tile:hover {
  filter: brightness(1.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.tpv-act-tile:active {
  filter: brightness(0.92);
  transform: translateY(1px) scale(0.98);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tpv-act-tile svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.tpv-act-tile span {
  display: block;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.tpv-act-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Colores modernos y refinados */
.tpv-act-tile.tile-blue {
  background: linear-gradient(145deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1e40af;
  color: #ffffff;
}

.tpv-act-tile.tile-blue:hover {
  background: linear-gradient(145deg, #3b82f6 0%, #1d4ed8 100%);
}

.tpv-act-tile.tile-gold {
  background: linear-gradient(145deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border-color: #b45309;
  font-size: 12.5px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}

.tpv-act-tile.tile-gold svg {
  width: 24px;
  height: 24px;
}

.tpv-act-tile.tile-gold:hover {
  background: linear-gradient(145deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 3px 12px rgba(217, 119, 6, 0.5);
}

.tpv-act-tile.tile-dark {
  background: linear-gradient(145deg, #334155 0%, #1e293b 100%);
  border-color: #0f172a;
  color: #f8fafc;
}

.tpv-act-tile.tile-dark:hover {
  background: linear-gradient(145deg, #475569 0%, #1e293b 100%);
}

.tpv-act-tile.tile-danger:hover {
  background: linear-gradient(145deg, #ef4444 0%, #b91c1c 100%) !important;
  border-color: #991b1b !important;
}

.tpv-empty-ticket-cell {
  text-align: center;
  padding: 24px 12px;
  color: #94a3b8;
}

/* ---------------- COLUMNA DERECHA ---------------- */
.tpv-col-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.tpv-products-grid,
.tpv-products-tier {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
}

.tpv-pos-product-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px 3px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.05s, border-color 0.1s;
  overflow: hidden;
  text-align: center;
  box-sizing: border-box;
}

.tpv-pos-product-card:hover {
  border-color: #0070f3;
}

.tpv-pos-product-card:active {
  transform: scale(0.97);
}

.tpv-card-img-container {
  flex: 1;
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.tpv-card-img-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tpv-card-caption {
  width: 100%;
  font-size: 11.5px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.15;
  text-align: center;
  padding: 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tpv-card-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}

.tpv-card-meta-tag {
  display: inline-block;
  background: #f1f5f9;
  color: #0369a1;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #bae6fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.2;
}

.tpv-card-price-tag {
  font-size: 12px;
  font-weight: 800;
  color: #0284c7;
}

/* Barras de Navegación del Catálogo */
.tpv-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  height: 32px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.tpv-nav-arrow {
  background: #0070f3;
  color: #ffffff;
  border: 1px solid #0056b3;
  border-radius: 3px;
  width: 28px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  user-select: none;
}

.tpv-nav-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tpv-nav-inicio-btn {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  user-select: none;
}

.tpv-nav-inicio-btn.active {
  background: #0070f3;
  color: #ffffff;
  border-color: #0056b3;
}

.tpv-page-dots-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tpv-page-radio-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.tpv-page-radio-item input[type="radio"] {
  cursor: pointer;
  margin: 0;
}

.tpv-search-mini {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  max-width: 240px;
}

.tpv-search-mini input {
  width: 100%;
  height: 24px;
  padding: 2px 20px 2px 6px;
  font-size: 11.5px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  outline: none;
}

.tpv-search-mini .clear-btn {
  position: absolute;
  right: 4px;
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  color: #64748b;
}

/* Adaptación Responsive para Móvil y Tableta: Scroll vertical libre, CERO scroll horizontal */
@media (max-width: 900px) {
  #tpv-tab-content,
  .tpv-tab-content {
    flex: none !important;
    height: auto !important;
    min-height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .tpv-pos-wrapper {
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .tpv-compact-header {
    height: auto !important;
    min-height: 42px !important;
    flex-wrap: wrap !important;
    padding: 6px 8px !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .tpv-header-left, .tpv-header-right {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  #tpv-toggle-fullscreen {
    display: none !important;
  }

  #tpv-toggle-sidebar {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    background: #eef2ff !important;
    color: #4338ca !important;
    border: 1px solid #c7d2fe !important;
    font-weight: 700 !important;
    padding: 6px 12px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    user-select: none !important;
  }

  #tpv-toggle-sidebar * {
    pointer-events: none !important;
  }

  .tpv-pos-screen {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .tpv-col-left, .tpv-col-right {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    gap: 8px !important;
    width: 100% !important;
    flex: none !important;
  }

  .tpv-upper-split {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    gap: 6px !important;
    width: 100% !important;
    flex: none !important;
  }

  .tpv-ticket-box {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 120px !important;
    max-height: 220px !important;
    width: 100% !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
    overflow: hidden !important;
  }

  .tpv-empty-ticket-cell {
    padding: 16px 8px !important;
  }

  .tpv-table-scrollable {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 110px !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .tpv-pos-table {
    table-layout: auto !important;
    width: 100% !important;
    font-size: 12px !important;
  }

  .tpv-pos-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
    padding: 7px 4px !important;
    background: #f1f5f9 !important;
    font-size: 11px !important;
    border-bottom: 2px solid #cbd5e1 !important;
  }

  .tpv-pos-table tbody td {
    padding: 5px 3px !important;
    font-size: 12px !important;
    vertical-align: middle !important;
  }

  .tpv-pos-table th:nth-child(4), .tpv-pos-table td:nth-child(4),
  .tpv-pos-table .col-dto {
    display: none !important; /* Ocultar columna Dto en pantallas estrechas */
  }

  .tpv-pos-table th:nth-child(7), .tpv-pos-table td:nth-child(7),
  .tpv-pos-table .col-chk-th,
  .tpv-pos-table .col-chk-td {
    display: none !important; /* Ocultar columna Checkbox en móvil */
  }

  .tpv-pos-table th:nth-child(1), .tpv-pos-table td:nth-child(1) {
    width: 28px !important;
    padding: 2px !important;
    text-align: center !important;
  }

  .tpv-pos-table th:nth-child(2), .tpv-pos-table td:nth-child(2) {
    max-width: 140px;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.25 !important;
  }

  .tpv-pos-table th:nth-child(3), .tpv-pos-table td:nth-child(3) {
    width: 50px !important;
    text-align: right !important;
    font-size: 11.5px !important;
  }

  .tpv-pos-table th:nth-child(5), .tpv-pos-table td:nth-child(5) {
    width: 78px !important;
    text-align: center !important;
  }

  .tpv-pos-table th:nth-child(6), .tpv-pos-table td:nth-child(6) {
    width: 58px !important;
    text-align: right !important;
    font-weight: 700 !important;
    font-size: 12px !important;
  }

  /* Ocultar el numpad físico gigante en móvil para dar 100% de espacio al ticket */
  .tpv-numpad-pane {
    display: none !important;
  }

  .tpv-numpad-screen {
    height: 38px !important;
    font-size: 19px !important;
    width: 100% !important;
  }

  .tpv-numpad-grid-3x5 {
    height: 185px !important;
    width: 100% !important;
    gap: 4px !important;
  }

  .tpv-np-btn {
    min-height: 32px !important;
    font-size: 17px !important;
    border-radius: 6px !important;
  }

  .tpv-totals-row {
    height: 42px !important;
    padding: 6px 12px !important;
    width: 100% !important;
    font-size: 12.5px !important;
    border-radius: 8px !important;
    flex: none !important;
  }

  .tpv-totals-row .tot-big {
    font-size: 17.5px !important;
    font-weight: 900 !important;
    background: #f8fafc;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
  }

  /* BOTONERA TPV DEL MEDIO EN MÓVIL: 100% VISIBLE Y ERGONÓMICA */
  .tpv-actions-4x4 {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-template-rows: repeat(4, auto) !important;
    grid-auto-rows: minmax(52px, auto) !important;
    gap: 6px !important;
    flex: none !important;
    height: auto !important;
    min-height: auto !important;
    width: 100% !important;
    overflow: visible !important;
    margin: 2px 0 6px 0 !important;
  }

  .tpv-act-tile {
    min-height: 52px !important;
    height: auto !important;
    padding: 6px 3px !important;
    font-size: 10.5px !important;
    border-radius: 8px !important;
    gap: 3px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  }

  .tpv-act-tile svg {
    width: 20px !important;
    height: 20px !important;
  }

  .tpv-act-tile.tile-gold {
    font-size: 12px !important;
    border: 1.5px solid #b45309 !important;
  }

  .tpv-act-tile.tile-gold svg {
    width: 22px !important;
    height: 22px !important;
  }

  .tpv-nav-bar {
    height: auto !important;
    min-height: 38px !important;
    flex-wrap: wrap !important;
    padding: 4px 6px !important;
    gap: 6px !important;
    justify-content: space-between !important;
    width: 100% !important;
    flex: none !important;
  }

  .tpv-page-dots-group {
    flex-wrap: wrap !important;
    gap: 5px !important;
    max-width: 100% !important;
  }

  .tpv-page-radio-item {
    font-size: 11px !important;
  }

  .tpv-search-mini {
    max-width: 100% !important;
    width: 100% !important;
    margin-top: 2px;
  }
}

/* Modo Móvil / Pistola Lectora Continua */
.tpv-mobile-nav {
  display: none;
}

.tpv-mobile-scanner-panel {
  display: none;
  flex-direction: column;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}

.tpv-mobile-scanner-panel.active {
  display: flex !important;
}

.tpv-mobile-scanner-video {
  width: 100%;
  height: 220px;
  min-height: 220px;
  object-fit: cover;
  background: #000;
  display: block;
}

.tpv-scanner-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 90px;
  border: 2px solid #22c55e;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
  pointer-events: none;
}

.tpv-scanner-laser-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: laser-scan 1.5s infinite alternate ease-in-out;
}

@keyframes laser-scan {
  0% { transform: translateY(-40px); }
  100% { transform: translateY(40px); }
}

.tpv-mobile-scanner-ctrls {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}

.tpv-torch-btn {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tpv-torch-btn.active {
  background: #eab308;
  color: #000;
  border-color: #ca8a04;
}

/* Modal de Cobro Rápido */
.tpv-pay-modal-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tpv-pay-method-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tpv-pay-method-btn {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.tpv-pay-method-btn.selected {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1e40af;
  box-shadow: 0 0 0 1px #2563eb;
}

.tpv-fast-cash-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.tpv-fast-cash-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 4px;
  font-weight: 800;
  font-size: 13.5px;
  color: #0f172a;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s ease;
}

.tpv-fast-cash-btn:hover {
  background: #e2e8f0;
}

.tpv-fast-cash-btn:active {
  transform: translateY(1px);
}

.tpv-change-box {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.tpv-change-box.has-change {
  background: #ecfdf5;
  border-color: #10b981;
}

.tpv-change-box.missing-cash {
  background: #fef2f2;
  border-color: #ef4444;
}

.tpv-change-val {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 4px;
}

/* ============================================================
   Optimizaciones de Cuadrícula de Productos para Móvil y Tableta
   ============================================================ */

@media (max-width: 600px) {
  .tpv-products-grid,
  .tpv-products-tier {
    grid-template-columns: repeat(3, 1fr) !important;
    grid-template-rows: auto !important;
    gap: 6px !important;
    height: auto !important;
    min-height: auto !important;
    width: 100% !important;
  }

  .tpv-pos-product-card {
    min-height: 88px !important;
    height: 102px !important;
    padding: 5px 3px !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .tpv-card-img-container {
    height: 44px !important;
    max-height: 44px !important;
  }

  .tpv-card-caption {
    font-size: 11px !important;
    line-height: 1.15 !important;
    text-align: center;
    width: 100% !important;
  }

  .tpv-card-name {
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    line-height: 1.15 !important;
    max-height: 26px !important;
  }

  .tpv-card-price-tag {
    font-size: 12.5px !important;
    font-weight: 800 !important;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .tpv-products-grid,
  .tpv-products-tier {
    grid-template-columns: repeat(4, 1fr) !important;
    grid-template-rows: auto !important;
    gap: 6px !important;
    height: auto !important;
    min-height: auto !important;
    width: 100% !important;
  }

  .tpv-pos-product-card {
    min-height: 94px !important;
    height: 108px !important;
    padding: 6px 4px !important;
    border-radius: 8px !important;
    width: 100% !important;
  }

  .tpv-card-img-container {
    height: 48px !important;
    max-height: 48px !important;
  }

  .tpv-card-caption {
    font-size: 11.5px !important;
  }

  .tpv-card-name {
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    line-height: 1.2 !important;
  }
}

/* ============================================================
   PROHIBICIÓN ESTRICTA DE SCROLL HORIZONTAL EN MÓVIL Y TABLETA
   ============================================================ */
@media (max-width: 1024px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
    box-sizing: border-box !important;
  }

  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  .app, .main, .view, .view.view-tpv, .card, .form-grid {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  /* Barra de pestañas en Sistema / Ajustes */
  .sistema-tabs-wrapper, .btn-group {
    max-width: 100% !important;
    flex-wrap: wrap !important;
  }

  .btn-group .btn {
    flex: 1 1 auto !important;
  }
}

/* ============================================================
   Diseño Minimalista y Control de Stock para Inventario y Pedidos
   ============================================================ */

/* Botón interactivo de ajuste de stock formal */
.stock-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.stock-badge-btn:hover {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4338ca;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.2);
}
.stock-badge-btn.stock-zero {
  background: #fff5f5;
  border-color: #fecaca;
  color: #dc2626;
}
.stock-badge-btn.stock-zero:hover {
  background: #fee2e2;
  border-color: #ef4444;
}
.stock-badge-btn.stock-low {
  background: #fffdf5;
  border-color: #fde68a;
  color: #b45309;
}
.stock-badge-btn.stock-low:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

/* Segmented Control para Tipos de Movimiento de Stock */
.stock-move-segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  margin-bottom: 16px;
}
.stock-move-tab {
  padding: 8px 12px;
  border-radius: 7px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.stock-move-tab:hover {
  color: #1e293b;
}
.stock-move-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.stock-move-tab.active.tab-entrada {
  color: #15803d;
}
.stock-move-tab.active.tab-recuento {
  color: #4338ca;
}
.stock-move-tab.active.tab-merma {
  color: #b91c1c;
}

/* Celdas de Margen Comercial */
.margin-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.margin-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.margin-pill.positive {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.margin-pill.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.margin-pill.danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.profit-text {
  font-size: 11px;
  color: #64748b;
}

/* Barra de Paginación Minimalista */
.inv-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #ffffff;
  border-top: 1px solid var(--border-soft);
  gap: 12px;
  flex-wrap: wrap;
}
.inv-pagination-info {
  font-size: 12.5px;
  color: #64748b;
}
.inv-pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inv-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}
.inv-pagination-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}
.inv-pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Lightbox de Imagen */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
.lightbox-modal {
  background: #ffffff;
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}
.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
}
.lightbox-body {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}
.lightbox-img {
  max-width: 480px;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
}

/* Plantilla de Etiquetas de Lineales / Góndolas */
.labels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}
.shelf-label-card {
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  page-break-inside: avoid;
}
.shelf-label-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  margin-bottom: 4px;
}
.shelf-label-sub {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
}
.shelf-label-price-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid #e2e8f0;
  padding-top: 6px;
  margin-top: 4px;
}
.shelf-label-pvp {
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.5px;
}
.shelf-label-tax {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
}
.shelf-label-barcode {
  font-family: monospace;
  font-size: 10.5px;
  color: #334155;
  letter-spacing: 1px;
  margin-top: 4px;
  text-align: center;
}

@media print {
  body * {
    visibility: hidden;
  }
  #print-shelf-container, #print-shelf-container * {
    visibility: visible;
  }
  #print-shelf-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .shelf-label-card {
    border: 1px solid #000 !important;
  }
}

/* ============================================================
   Módulo de Compras: Estilos y Componentes UI
   ============================================================ */

.compras-kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-warning {
  border-color: #fef3c7;
  background: #fffbeb;
}

.compras-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compras-filter-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.compras-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-compact, .input-compact {
  padding: 6px 10px;
  font-size: 13px;
  height: 35px;
}

.date-range-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.range-sep {
  color: var(--muted);
  font-weight: 600;
}

.badge-toggle-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.badge-toggle-btn:hover {
  opacity: 0.85;
  transform: scale(1.04);
}

.compras-fab-btn {
  position: fixed;
  bottom: 74px;
  right: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 45;
  transition: transform 0.15s, box-shadow 0.15s;
}
.compras-fab-btn:active {
  transform: scale(0.95);
}

.compras-form-container {
  display: flex;
  flex-direction: column;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.compras-toggles-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
}

.compras-toggle-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex: none;
  margin-top: 2px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(18px);
}

.toggle-text {
  display: flex;
  flex-direction: column;
}
.toggle-text strong {
  font-size: 13px;
  color: #1e293b;
}

.add-line-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  align-items: end;
}

.compras-summary-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 18px;
  background: #f1f5f9;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.summary-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.summary-col .lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.summary-col .val {
  font-size: 14px;
  color: #1e293b;
}

.summary-col.grand-total {
  padding-left: 14px;
  border-left: 2px solid #cbd5e1;
}

.summary-col.grand-total .val {
  font-size: 19px;
  font-weight: 800;
  color: var(--primary);
}

.detail-header-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.detail-header-col {
  display: flex;
  flex-direction: column;
}

.fiscal-breakdown-card {
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  justify-content: flex-end;
}

.fiscal-breakdown-table {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fiscal-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #334155;
}

.fiscal-row.font-bold {
  font-weight: 700;
}

.fiscal-divider {
  border: 0;
  border-top: 1px solid #cbd5e1;
  margin: 4px 0;
}

.fiscal-row.grand-total-row {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  padding-top: 4px;
  border-top: 2px solid var(--primary);
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------- Autocompletado y Búsqueda Rápida ---------------- */

.search-autocomplete-wrap {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-height: 220px;
  overflow-y: auto;
  z-index: 150;
  display: flex;
  flex-direction: column;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  transition: background 0.12s;
  color: var(--text);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.active {
  background: #f1f5f9;
}

.autocomplete-create-btn {
  background: #eef2ff;
  color: var(--primary);
  font-weight: 600;
  border-top: 1px dashed #c7d2fe;
}
.autocomplete-create-btn:hover {
  background: #e0e7ff;
}

.selected-entity-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #166534;
  width: 100%;
}

.selected-entity-chip .chip-close {
  background: none;
  border: none;
  color: #15803d;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: 4px;
}
.selected-entity-chip .chip-close:hover {
  background: #dcfce7;
  color: #b91c1c;
}


.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}

.chip-green {
  background: #dcfce7;
  color: #15803d;
}

.chip-blue {
  background: #e0f2fe;
  color: #0369a1;
}

.chip-purple {
  background: #ede9fe;
  color: #6d28d9;
}



