:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --radius: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: var(--text-main);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-icon {
  padding: 6px;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* Main Container */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.toolbar-stats {
  font-size: 14px;
  color: var(--text-muted);
}

/* Card & Table */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Table elements */
.sku-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  display: inline-block;
}

.product-thumb {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 2px;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.product-thumb:hover {
  transform: scale(1.06);
  border-color: #94a3b8;
  box-shadow: 0 4px 8px -1px rgba(0, 0, 0, 0.12);
  z-index: 3;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.product-thumb-placeholder {
  color: #94a3b8;
  font-size: 22px;
}

.product-name-cell {
  font-weight: 500;
  color: var(--text-main);
  max-width: 480px;
}

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

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-dialog.modal-sm {
  max-width: 520px;
}

.modal-dialog.modal-md {
  max-width: 640px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #ffffff;
  z-index: 2;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

/* Scrollbar estilizado y suave para modales */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f8fafc;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: #ffffff;
  flex-shrink: 0;
  z-index: 2;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

/* Print Modal Layout (Matching Screenshot) */
.print-modal-layout {
  display: flex;
  gap: 24px;
  min-height: 380px;
}

.print-sidebar {
  width: 340px;
  border-right: 1px solid var(--border);
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.print-list-container {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

.form-label span.req {
  color: #ef4444;
}

.form-select, .form-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.radio-group {
  display: flex;
  gap: 16px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-with-unit {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.input-with-unit input {
  width: 100%;
  border: none;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}

.input-with-unit .unit {
  padding: 8px 10px;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border);
}

/* Live Preview Box */
.preview-box-container {
  margin-top: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  overflow: visible;
}

.preview-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  align-self: flex-start;
}

/* ========================================================
   COMPONENTE UNIVERSAL DE ETIQUETA (PREVIEW Y PRINT UNIFICADOS)
   ======================================================== */
.label-page {
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.0mm 1.4mm 0 1.4mm;
  text-align: center;
  overflow: hidden;
  font-family: 'SourceHanSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #000;
  flex-shrink: 0;
  margin: 0 auto;
}

.label-page .barcode-wrap {
  width: 93%;
  height: 11.4mm;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.label-page svg.barcode {
  width: 100%;
  height: 100%;
  display: block;
}

.label-page .label-sku {
  font-weight: 800;
  font-size: 10.5pt;
  color: #000;
  margin-top: 0.6mm;
  line-height: 1.05;
  letter-spacing: 0.2px;
  text-align: center;
}

.label-page .label-name {
  font-family: 'SourceHanSans', -apple-system, sans-serif;
  text-align: center;
  width: 95%;
  max-width: 95%;
  margin-top: 1.0mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.label-page .label-title-text {
  font-family: 'SourceHanSans', -apple-system, sans-serif;
  font-weight: 400;
  font-size: 6.5pt;
  color: #000;
  line-height: 1.22;
  text-align: center;
  width: 100%;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
}

.label-page .label-variant-text {
  font-family: 'SourceHanSans', -apple-system, sans-serif;
  font-weight: 600;
  font-size: 6.5pt;
  color: #000;
  margin-top: 0.4mm;
  line-height: 1.22;
  text-align: center;
  width: 100%;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
}

/* En modo preview en el modal, con borde sólido, sombra limpia y escalado auto-fit sin cortes */
.label-page.preview-mode {
  border: 1px solid #94a3b8;
  box-shadow: 0 8px 18px -4px rgba(0, 0, 0, 0.1), 0 3px 6px -2px rgba(0, 0, 0, 0.05);
  transform-origin: center center;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Selected Items Table in Modal */
.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.modal-table th {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
}

.modal-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.item-sku-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-sku-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
  box-sizing: border-box;
  border: 1px solid var(--border);
}

.item-sku-info .sku-code {
  font-weight: 700;
  color: var(--text-main);
  font-size: 13px;
}

.item-sku-info .product-name {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qty-input {
  width: 65px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
}

/* File Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone-icon {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 8px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.2s ease forwards;
}

.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========================================================
   PRINT STYLES FOR THERMAL LABEL PRINTERS
   ======================================================== */
#print-root {
  display: none;
}

@media print {
  /* Ocultar la app completa en impresión */
  body * {
    visibility: hidden;
  }
  
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Solo mostrar el contenedor de etiquetas */
  #print-root, #print-root * {
    visibility: visible;
  }

  #print-root {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .print-page-label {
    box-sizing: border-box;
    page-break-after: always;
    break-after: page;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    padding: 1mm 1.5mm;
    text-align: center;
    overflow: hidden;
    background: #fff;
  }

  .print-page-label svg.barcode {
    width: 95% !important;
    max-height: 48% !important;
    display: block;
    margin: 0 auto;
  }

  .print-page-label .label-sku {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-weight: 900;
    color: #000;
    letter-spacing: 0.5px;
    margin-top: 1mm;
    line-height: 1.1;
  }

  .print-page-label .label-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-weight: 400;
    color: #000;
    line-height: 1.15;
    margin-top: 0.8mm;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ========================================================
   CAJA DRAG AND DROP PARA FOTOGRAFÍA DE PRODUCTO
   ======================================================== */
.photo-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-dropzone:hover, .photo-dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.photo-drop-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.photo-drop-icon {
  font-size: 28px;
  margin-bottom: 2px;
}

.photo-drop-title {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

.photo-drop-title .browse-link {
  color: var(--primary);
  text-decoration: underline;
}

.photo-drop-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.photo-drop-filled {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.photo-drop-filled img {
  max-height: 135px;
  max-width: 100%;
  border-radius: 6px;
  object-fit: contain;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
  background: #fff;
}

.photo-drop-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ========================================================
   ESTILOS PARA VARIANTES, MERCADO LIBRE Y COLUMNAS DINÁMICAS
   ======================================================== */

.variant-pill {
  display: inline-block;
  padding: 2px 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
}

.meli-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #0284c7;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  background: #e0f2fe;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #bae6fd;
  transition: all 0.15s ease;
}

.meli-link:hover {
  background: #0284c7;
  color: #ffffff;
  text-decoration: none;
}

.meli-text-mobile {
  display: none;
}

.meli-text-desktop {
  display: inline;
}

.column-toggle-item:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

/* ========================================================
   PESTAÑAS DE VISTA: ACTIVOS VS ARCHIVADOS
   ======================================================== */

.view-tabs-container {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-tab:hover {
  background: #f8fafc;
  color: #334155;
}

.view-tab.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.view-tab.active span {
  filter: brightness(1.2);
}

/* ========================================================
   ESTILOS DE REORDENAMIENTO DE COLUMNAS
   ======================================================== */

.column-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.15s ease;
  user-select: none;
}

.column-toggle-item.dragging {
  opacity: 0.4;
  border: 1px dashed #2563eb;
  background: #eff6ff;
}

.column-toggle-item.drag-over {
  border-top: 2px solid #2563eb !important;
  background: #f1f5f9;
}

.col-drag-handle {
  cursor: grab;
  color: #94a3b8;
  font-size: 14px;
  margin-right: 6px;
  padding: 2px 4px;
}

.col-drag-handle:active {
  cursor: grabbing;
}

.col-order-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 11px;
  border-radius: 4px;
  color: #475569;
  transition: all 0.1s;
}

.col-order-btn:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.col-order-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* ========================================================
   ESTILOS DE MENÚ DESPLEGABLE (3 PUNTITOS) E ICONOS SVG
   ======================================================== */

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn .icon, .view-tab .icon {
  margin-right: 2px;
}

.row-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.dropdown-container {
  position: relative;
  display: inline-flex;
}

.btn-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-dots:hover, .btn-dots.active {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 5px;
  min-width: 175px;
  z-index: 1000;
  display: none;
  animation: dropdownFade 0.15s ease-out;
}

.dropdown-menu.show {
  display: block;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.dropdown-item:hover {
  background: #f8fafc;
  color: #0f172a;
}

.dropdown-item.danger {
  color: #ef4444;
}

.dropdown-item.danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 4px 0;
}

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

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ========================================================
   ESTILOS DE AGRUPACIÓN Y ANIDACIÓN DE PRODUCTOS
   ======================================================== */

.group-parent-row {
  background-color: #ffffff;
  border-top: 2px solid #e2e8f0;
  transition: background-color 0.15s ease;
}

.group-parent-row:hover {
  background-color: #f8fafc;
}

.group-parent-row td {
  padding-top: 14px;
  padding-bottom: 14px;
}

.group-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}

.group-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.group-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.15s ease;
  user-select: none;
}

.group-toggle-btn:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.group-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  transition: transform 0.2s ease;
}

/* Filas Hijas / Variantes anidadas */
.group-child-row {
  background-color: #f8fafc;
  transition: background-color 0.12s ease;
  border-bottom: 1px dashed #e2e8f0;
}

.group-child-row:hover {
  background-color: #f1f5f9;
}

.group-child-row.collapsed {
  display: none !important;
}

.group-child-row td {
  padding: 10px 16px;
}

.group-child-tree-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-child-tree-line {
  color: #94a3b8;
  font-family: monospace;
  font-size: 16px;
  user-select: none;
  margin-right: 2px;
}

.variant-color-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: #334155;
}

.variant-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #3b82f6;
  display: inline-block;
}

/* ========================================================
   SISTEMA DE ETIQUETAS (TAGS) Y FILTRADO POR TAGS
   ======================================================== */
.tag-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  transition: all 0.2s ease;
}

.tag-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  user-select: none;
}

.tag-pills-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tag-pill:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.tag-pill.active {
  background: #3b82f6;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}

.tag-pill .tag-pill-count {
  font-size: 11px;
  opacity: 0.8;
  font-weight: 600;
}

.tag-pill.active .tag-pill-count {
  opacity: 0.95;
}

.btn-clear-tag {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.btn-clear-tag:hover {
  background: #fee2e2;
}

/* Badges de Tags en las filas de productos */
.product-tags-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #0369a1;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tag-badge:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.tag-badge.active-filter {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
}

.tag-badge-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px dashed #cbd5e1;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0;
}

tr:hover .tag-badge-add {
  opacity: 0.7;
}

.tag-badge-add:hover {
  opacity: 1 !important;
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}

.product-tags-wrapper:has(.tag-badge) .tag-badge-add {
  opacity: 0.5;
}

/* Input de Tags con Chips */
.tags-input-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  min-height: 38px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tags-input-container:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-chip-remove {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 13px;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  transition: color 0.15s;
}

.tag-chip-remove:hover {
  color: #ef4444;
}

.tag-chip.tag-chip-danger-remove {
  background: #fef2f2;
  border: 1px dashed #f87171;
  color: #991b1b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-chip.tag-chip-danger-remove:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

.tag-chip-undo {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.tag-chip-undo:hover {
  color: #991b1b;
}

.tags-inline-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 3px 0 !important;
  font-size: 13px !important;
  flex: 1;
  min-width: 140px;
  background: transparent;
}

.quick-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.quick-tag-chip:hover {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

/* ========================================================
   GALERÍA DE FOTOS MULTI-IMAGEN (PRODUCT MODAL)
   ======================================================== */
.gallery-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  min-height: 110px;
  transition: border-color 0.2s, background-color 0.2s;
}

.gallery-dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 10px;
}

.gallery-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.gallery-card.is-main {
  border: 2px solid #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-main-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #2563eb;
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  z-index: 2;
}

.gallery-card-index {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(15, 23, 42, 0.75);
  color: #f8fafc;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  z-index: 2;
}

.gallery-card-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0.85;
  transition: opacity 0.15s;
  z-index: 2;
}

.gallery-card:hover .gallery-card-actions {
  opacity: 1;
}

.btn-gallery-action {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  color: #334155;
  transition: all 0.15s;
}

.btn-gallery-action:hover {
  background: #ffffff;
  transform: scale(1.1);
  color: #0f172a;
}

.btn-gallery-action.set-main:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

.btn-gallery-action.danger:hover {
  background: #fef2f2;
  color: #ef4444;
  border-color: #fecaca;
}

/* ========================================================
   MINIATURAS CON CONTADOR EN TABLA / GRUPOS
   ======================================================== */
.product-thumb-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.12s;
}

.product-thumb-container:hover {
  transform: scale(1.05);
}

.product-thumb-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.2;
  letter-spacing: 0.3px;
  pointer-events: none;
}

/* ========================================================
   MODAL: VISOR DE FOTOS (LIGHTBOX / CAROUSEL)
   ======================================================== */
.photo-viewer-backdrop {
  background: rgba(10, 15, 29, 0.88) !important;
  backdrop-filter: blur(8px);
}

.photo-viewer-dialog {
  background: #0f172a !important;
  border: 1px solid #1e293b;
  border-radius: 12px;
  width: 90% !important;
  max-width: 820px !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.photo-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

.photo-viewer-title-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 580px;
}

.photo-viewer-title {
  font-size: 15px;
  font-weight: 600;
  color: #f8fafc;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-viewer-subtitle {
  font-size: 12px;
  color: #94a3b8;
}

.photo-viewer-header .modal-close {
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  background: transparent;
  border: none;
  line-height: 1;
  transition: color 0.15s;
}

.photo-viewer-header .modal-close:hover {
  color: #f8fafc;
}

.photo-viewer-stage {
  position: relative;
  height: 440px;
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.photo-main-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.photo-viewer-main-img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s ease;
}

.photo-viewer-badge {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.82);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.photo-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
}

.photo-nav-btn:hover {
  background: #2563eb;
  color: #ffffff;
  transform: translateY(-50%) scale(1.1);
  border-color: #3b82f6;
}

.photo-nav-prev {
  left: 14px;
}

.photo-nav-next {
  right: 14px;
}

.photo-viewer-strip {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #090d16;
  border-top: 1px solid #1e293b;
  overflow-x: auto;
  align-items: center;
}

.photo-viewer-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: all 0.15s ease;
  background: #020617;
}

.photo-viewer-thumb:hover {
  opacity: 0.85;
}

.photo-viewer-thumb.active {
  opacity: 1;
  border-color: #3b82f6;
  transform: scale(1.05);
}

.photo-viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ========================================================
   BADGES DE STOCK (MERCADO LIBRE)
   ======================================================== */
.stock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 7px;
  min-width: 26px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}

.stock-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stock-badge.stock-in {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.stock-badge.stock-in .stock-badge-dot {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.stock-badge.stock-low {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.stock-badge.stock-low .stock-badge-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.stock-badge.stock-out {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.stock-badge.stock-out .stock-badge-dot {
  background: #ef4444;
}

.stock-badge.stock-unknown {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.stock-badge.stock-unknown .stock-badge-dot {
  background: #94a3b8;
}

/* Badge Stock Local (Bodega) con botón de edición rápida */
.stock-badge.stock-local {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.stock-badge.stock-local:hover {
  background: #dcfce7;
  border-color: #86efac;
  transform: translateY(-1px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stock-badge.stock-local .stock-badge-dot {
  background: #22c55e;
}
.stock-badge.stock-local.stock-zero {
  background: #f8fafc;
  color: #64748b;
  border: 1px dashed #cbd5e1;
}
.stock-badge.stock-local.stock-zero .stock-badge-dot {
  background: #94a3b8;
}

/* Botones de Sincronización Separada (Stock, Fotos, Mapeo) */
.sync-action-group {
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.btn-sync-stock:hover {
  background: #dcfce7 !important;
  border-color: #86efac !important;
}
.btn-sync-photos:hover {
  background: #dbeafe !important;
  border-color: #93c5fd !important;
}
.btn-sync-mapping:hover {
  background: #ede9fe !important;
  border-color: #c4b5fd !important;
}
.btn-sync-stock:active, .btn-sync-photos:active, .btn-sync-mapping:active {
  transform: translateY(1px);
}

/* ========================================================
   EDITOR INLINE DE STOCK DE BODEGA
   ======================================================== */
.inline-stock-editor {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #ffffff;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  padding: 1px 3px;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
  animation: fadeInStockEditor 0.15s ease-out;
  vertical-align: middle;
}

@keyframes fadeInStockEditor {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.inline-stock-input {
  width: 44px;
  height: 22px;
  border: none;
  outline: none;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #1e293b;
  background: transparent;
  padding: 0 2px;
  -moz-appearance: textfield;
}

.inline-stock-input::-webkit-outer-spin-button,
.inline-stock-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.inline-stock-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.inline-stock-btn {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  padding: 0;
  line-height: 1;
  transition: all 0.1s ease;
}

.inline-stock-btn-save {
  background: #10b981;
  color: #ffffff;
}

.inline-stock-btn-save:hover {
  background: #059669;
}

.inline-stock-btn-cancel {
  background: #f1f5f9;
  color: #64748b;
}

.inline-stock-btn-cancel:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.stock-badge-highlight {
  animation: badgeHighlight 1.2s ease-out;
}

@keyframes badgeHighlight {
  0% { transform: scale(1.2); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.4); background: #bbf7d0; }
  100% { transform: scale(1); box-shadow: none; }
}

/* ========================================================
   VARIANTE DESTACADA / FOTO PRINCIPAL DE GRUPO (SUTIL Y LIMPIO)
   ======================================================== */
.star-featured-btn {
  background: none;
  border: none;
  outline: none;
  padding: 0 4px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: #cbd5e1;
  transition: color 0.15s ease, transform 0.15s ease;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.star-featured-btn:hover {
  color: #f59e0b;
  transform: scale(1.2);
}

.star-featured-btn.active {
  color: #f59e0b;
}

.star-featured-btn.active:hover {
  color: #d97706;
}

.parent-thumb-flash {
  animation: parentThumbFlash 1.2s ease-out;
}

@keyframes parentThumbFlash {
  0% { transform: scale(1.08); box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.5); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); }
}

/* ========================================================
   DESKTOP DEFAULT RULES (Hidden on Desktop)
   ======================================================== */
.product-mobile-meta,
.product-mobile-stock-bar,
.mobile-selection-bar,
.header-mobile-menu-container,
#btn-mobile-menu,
.label-mobile {
  display: none;
}

.label-desktop {
  display: inline;
}

/* ========================================================
   RESPONSIVE MOBILE UX & DESIGN (Max Width: 768px)
   ======================================================== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
  }

  /* Safe Area Padding for iOS Devices */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .label-desktop {
    display: none !important;
  }

  .label-mobile {
    display: inline !important;
  }

  /* Compact Sticky Header */
  .header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }

  .header-container {
    padding: 8px 10px !important;
    gap: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  .brand {
    gap: 6px !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  .brand-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 13px !important;
    border-radius: 6px !important;
    flex-shrink: 0;
  }

  .brand-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-subtitle {
    display: none !important;
  }

  .header-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 5px !important;
    flex-shrink: 0 !important;
  }

  /* Hide bulky desktop buttons from mobile top bar */
  #btn-open-columns,
  #btn-open-import,
  #btn-open-designer,
  #btn-bulk-group,
  #btn-bulk-ungroup,
  #btn-bulk-tags,
  #btn-bulk-archive,
  #btn-bulk-unarchive,
  #btn-bulk-print {
    display: none !important;
  }

  /* Compact + Nuevo button */
  #btn-open-create {
    padding: 5px 9px !important;
    font-size: 12px !important;
    height: 32px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    gap: 4px !important;
  }

  /* Compact Sync dropdown */
  #btn-sync-dropdown {
    padding: 5px 8px !important;
    font-size: 12px !important;
    height: 32px !important;
    border-radius: 8px !important;
    gap: 3px !important;
  }

  /* Mobile More (3-dots) Menu Trigger */
  .header-mobile-menu-container {
    display: inline-block !important;
  }

  #btn-mobile-menu {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
    background: #ffffff !important;
    color: var(--text-main) !important;
  }

  #sync-menu,
  #mobile-menu-dropdown {
    left: auto !important;
    right: 0 !important;
    min-width: 240px !important;
    max-width: calc(100vw - 20px) !important;
  }

  /* Main Container */
  .main-content {
    padding: 12px 10px 100px 10px !important;
  }

  /* Segmented Control Tabs */
  .view-tabs-container {
    display: flex !important;
    width: 100% !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
  }

  .view-tab {
    flex: 1 !important;
    justify-content: center !important;
    padding: 10px 12px !important;
    height: 42px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
  }

  /* Toolbar and Search */
  .toolbar {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
    margin-bottom: 12px !important;
  }

  .search-box {
    width: 100% !important;
    max-width: 100% !important;
  }

  .search-input {
    height: 44px !important;
    font-size: 16px !important; /* Crucial for iOS: prevents automatic zoom on focus */
    border-radius: 10px !important;
    padding-left: 38px !important;
  }

  .search-icon {
    left: 12px !important;
  }

  .toolbar > div:nth-child(2) {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
  }

  #btn-auto-group,
  #btn-toggle-all-groups {
    height: 36px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
  }

  .toolbar-stats {
    font-size: 12px !important;
    margin-left: auto !important;
  }

  /* Tag Filter Bar - Single row horizontal scroll */
  .tag-filter-bar {
    display: flex !important;
    align-items: center !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    background: #f8fafc !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    scrollbar-width: none !important;
  }

  .tag-filter-bar::-webkit-scrollbar {
    display: none !important;
  }

  .tag-filter-label {
    flex-shrink: 0 !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #64748b !important;
  }

  .tag-pills-list {
    display: flex !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    flex-wrap: nowrap !important;
  }

  .tag-pill {
    flex-shrink: 0 !important;
    padding: 4px 10px !important;
    font-size: 12px !important;
  }

  /* Card and Responsive Table Reset */
  .card {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .table-responsive {
    overflow-x: visible !important;
  }

  .data-table {
    display: block !important;
    width: 100% !important;
    border: none !important;
  }

  .data-table thead {
    display: none !important; /* Headers not needed in card presentation */
  }

  .data-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  /* ========================================================
     MOBILE PRODUCT CARD - NO WASTED SPACE, PERFECT REDISTRIBUTION
     ======================================================== */
  .data-table tr.product-row,
  .data-table tr.group-parent-row {
    display: grid !important;
    grid-template-columns: 22px 54px 1fr 32px !important;
    grid-template-areas:
      "select thumb name actions" !important;
    gap: 6px 8px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
    padding: 10px 9px !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
    transition: all 0.15s ease !important;
    position: relative !important;
    align-items: start !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Selected Card State */
  .data-table tr.product-row[style*="#eff6ff"],
  .data-table tr.group-parent-row[style*="#eff6ff"] {
    border-color: #3b82f6 !important;
    background: #f0f7ff !important;
    box-shadow: 0 0 0 1px #3b82f6 !important;
  }

  /* Group Parent Card */
  .data-table tr.group-parent-row {
    background: #f8fafc !important;
    border: 1.5px solid #cbd5e1 !important;
  }

  /* ========================================================
     NESTED GROUP CHILD ROW (ULTRA-COMPACT VARIANT - MOBILE)
     ======================================================== */
  .data-table tr.group-child-row {
    display: grid !important;
    grid-template-columns: 20px 42px 1fr 30px !important;
    grid-template-areas:
      "select thumb name actions" !important;
    gap: 6px 8px !important;
    margin-left: 10px !important;
    width: calc(100% - 10px) !important;
    border: 1px solid #e2e8f0 !important;
    border-left: 3.5px solid #3b82f6 !important;
    border-radius: 10px !important;
    padding: 6px 8px !important;
    background: #f8fafc !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
    position: relative !important;
    align-items: center !important;
    box-sizing: border-box !important;
    min-height: 48px !important;
  }

  .data-table tr.group-child-row.collapsed {
    display: none !important;
  }

  .data-table tr.group-child-row[style*="#eff6ff"],
  .data-table tr.group-child-row[style*="background-color: rgb(239, 246, 255)"] {
    background: #eff6ff !important;
    border-color: #93c5fd !important;
    border-left-color: #2563eb !important;
  }

  .data-table tr.group-child-row td.cell-thumb .product-thumb {
    width: 42px !important;
    height: 42px !important;
    border-radius: 8px !important;
  }

  .data-table tr.group-child-row td.cell-thumb .product-thumb-badge {
    font-size: 9px !important;
    padding: 1px 3px !important;
    bottom: 1px !important;
    right: 1px !important;
    border-radius: 4px !important;
  }

  .data-table tr.group-child-row td.cell-select {
    padding-top: 0 !important;
    align-items: center !important;
  }

  .data-table tr.group-child-row td.cell-select input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
  }

  .data-table tr.group-child-row td.cell-thumb {
    align-items: center !important;
  }

  .data-table tr.group-child-row td.cell-name {
    gap: 2px !important;
    justify-content: center !important;
  }

  /* Hide redundant tags and verbose desktop labels on child rows in mobile */
  .data-table tr.group-child-row .child-variant-tags,
  .data-table tr.group-child-row .product-tags-wrapper,
  .data-table tr.group-child-row .child-variant-label-desktop {
    display: none !important;
  }

  .data-table tr.group-child-row td.cell-actions {
    width: 30px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .data-table tr.group-child-row .btn-dots {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    border-radius: 6px !important;
  }

  /* Compact Variant Header & Typography */
  .child-variant-header {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    line-height: 1.2 !important;
  }

  .child-variant-title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 140px !important;
  }

  .child-sku-badge {
    font-size: 10px !important;
    padding: 1px 5px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
  }

  .star-featured-btn {
    font-size: 13px !important;
    padding: 0 2px !important;
    line-height: 1 !important;
  }

  /* Cells inside card */
  .data-table td {
    border: none !important;
    padding: 0 !important;
  }

  /* 1. Checkbox */
  .data-table td.cell-select {
    grid-area: select !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding-top: 4px !important;
  }

  .data-table td.cell-select input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    cursor: pointer !important;
    accent-color: #2563eb !important;
  }

  /* 2. Thumbnail */
  .data-table td.cell-thumb {
    grid-area: thumb !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
  }

  .data-table td.cell-thumb .product-thumb {
    width: 54px !important;
    height: 54px !important;
    border-radius: 9px !important;
    border: 1px solid #e2e8f0 !important;
    object-fit: cover !important;
    background: #f8fafc !important;
  }

  /* 3. Product & Group Information (Takes all available space!) */
  .data-table td.cell-name {
    grid-area: name !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    min-width: 0 !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  .product-title-text,
  .group-title {
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    color: #0f172a !important;
    word-break: break-word !important;
    padding-right: 2px !important;
  }

  .group-child-tree-cell {
    display: flex !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .group-child-tree-line {
    display: none !important;
  }

  .desktop-only-subtitle {
    display: none !important;
  }

  /* Mobile Meta Pills (SKU + Variant) */
  .product-mobile-meta {
    display: flex !important;
    gap: 6px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    margin-top: 2px !important;
  }

  .product-mobile-meta .sku-badge {
    font-size: 11px !important;
    padding: 2px 6px !important;
    font-weight: 700 !important;
  }

  .product-mobile-meta .variant-pill {
    font-size: 11px !important;
    padding: 2px 7px !important;
  }

  .product-mobile-meta .group-badge {
    font-size: 11px !important;
    padding: 2px 6px !important;
  }

  /* Tags inside card */
  .product-tags-wrapper {
    margin-top: 2px !important;
    gap: 4px !important;
  }

  .tag-badge {
    font-size: 11px !important;
    padding: 2px 7px !important;
  }

  .tag-badge-add {
    width: 18px !important;
    height: 18px !important;
    font-size: 12px !important;
  }

  /* Mobile Stock Bar (Prominent, thumb-friendly metrics) */
  .product-mobile-stock-bar {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px 4px !important;
    background: #f8fafc !important;
    border: 1px solid #edf2f7 !important;
    border-radius: 7px !important;
    padding: 2.5px 5px !important;
    margin-top: 4px !important;
    flex-wrap: nowrap !important;
    box-sizing: border-box !important;
    width: fit-content !important;
    max-width: 100% !important;
  }

  .mobile-stock-item {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
    font-size: 10.5px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .mobile-stock-label {
    font-size: 8.5px !important;
    font-weight: 700 !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.1px !important;
  }

  .mobile-stock-item .stock-badge {
    padding: 1px 5px !important;
    font-size: 10.5px !important;
    min-height: 18px !important;
  }

  /* Compact Stock Bar in Child Variant (clean, borderless, single-line) */
  .data-table tr.group-child-row .product-mobile-stock-bar,
  .data-table tr.group-child-row .child-stock-bar {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin-top: 2px !important;
    gap: 5px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    max-width: 100% !important;
  }

  .data-table tr.group-child-row .mobile-stock-item {
    font-size: 10.5px !important;
    gap: 2px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .data-table tr.group-child-row .mobile-stock-label {
    font-size: 9px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
  }

  .data-table tr.group-child-row .stock-badge {
    padding: 1px 5px !important;
    font-size: 10.5px !important;
    min-height: 17px !important;
    border-radius: 4px !important;
  }

  .data-table tr.group-child-row .stock-badge-edit-btn {
    font-size: 9px !important;
    margin-left: 1px !important;
    opacity: 0.7 !important;
  }

  .data-table tr.group-child-row .meli-link {
    padding: 1px 5px !important;
    font-size: 10.5px !important;
    flex-shrink: 0 !important;
  }

  /* Compact Mercado Libre Badges on Mobile (ML ↗ instead of full ID) */
  .meli-text-mobile {
    display: inline !important;
  }
  .meli-text-desktop {
    display: none !important;
  }

  .meli-link {
    padding: 2px 6px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    gap: 3px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    line-height: 1.2 !important;
  }

  .meli-link svg {
    width: 10px !important;
    height: 10px !important;
  }

  .group-toggle-btn {
    margin-top: 5px !important;
    font-size: 11.5px !important;
    padding: 4px 9px !important;
    background: #eff6ff !important;
    color: #2563eb !important;
    border: 1px solid #bfdbfe !important;
    border-radius: 6px !important;
    width: fit-content !important;
  }

  /* 4. Actions Cell (Only 3-dots button on mobile - Print button is inside the 3-dots menu!) */
  .data-table td.cell-actions {
    grid-area: actions !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: flex-end !important;
    width: 34px !important;
  }

  .row-actions-group {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    width: 100% !important;
  }

  /* Standalone print button is hidden on mobile to reclaim horizontal space */
  .row-actions-group .btn-sm {
    display: none !important;
  }

  .btn-dots {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    color: #475569 !important;
  }

  .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    min-width: 190px !important;
    max-width: calc(100vw - 24px) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12) !important;
    border-radius: 10px !important;
  }

  .dropdown-item {
    padding: 9px 12px !important;
    font-size: 13px !important;
  }

  /* Hide redundant desktop table cells on mobile */
  .data-table td.cell-sku,
  .data-table td.cell-variant,
  .data-table td.cell-local-stock,
  .data-table td.cell-stock,
  .data-table td.cell-meli-id,
  .data-table td.cell-meli-prod,
  .data-table td.cell-extra {
    display: none !important;
  }

  /* ========================================================
     FLOATING MOBILE SELECTION BAR
     ======================================================== */
  .mobile-selection-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-top: 1px solid #e2e8f0 !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08) !important;
    padding: 10px 14px !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    align-items: center !important;
    justify-content: space-between !important;
    z-index: 100 !important;
    transform: translateY(120%) !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .mobile-selection-bar.visible {
    transform: translateY(0) !important;
  }

  .mobile-selection-content {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
  }

  .mobile-selection-badge {
    background: #2563eb !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .mobile-selection-buttons {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  #btn-mobile-print {
    font-weight: 600 !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
  }

  #btn-mobile-tags,
  #btn-mobile-archive,
  #btn-mobile-clear {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    font-size: 14px !important;
  }

  /* ========================================================
     MODALS AS BOTTOM SHEETS ON MOBILE
     ======================================================== */
  .modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh !important;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.16) !important;
  }

  .modal-header {
    padding: 14px 16px !important;
  }

  .modal-body {
    padding: 16px !important;
    max-height: calc(92vh - 120px) !important;
  }

  .modal-footer {
    padding: 12px 16px !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .print-modal-layout {
    flex-direction: column !important;
    gap: 16px !important;
  }

  .print-sidebar {
    width: 100% !important;
  }

  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Avoid iOS Auto-zoom on Inputs */
  .form-input,
  .form-select,
  .search-input,
  .inline-stock-input {
    font-size: 16px !important;
    height: 42px !important;
  }
}

