/* =========================================================
   WIRTZ HUB · PEDIDOS MAYORISTAS · DIFERENCIAS
   Comparación simple: pedido / producto / stock / cantidades
   Orden por columnas
   ========================================================= */

.pm-diff-page .pm-panel__head--toolbar {
  align-items: center;
}

.pm-diff-page .pm-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: nowrap;
  min-width: 0;
}

.pm-diff-page .pm-toolbar .pm-search {
  width: 260px;
  min-width: 190px;
  flex: 0 1 260px;
}

.pm-diff-page .pm-toolbar input[type="date"] {
  height: 28px;
  min-width: 112px;
  padding: 0 8px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  border-radius: 8px;
  background: transparent;
  color: var(--text-strong);
  outline: none;
  font-size: 8.3px;
  font-weight: 850;
}

html[data-theme="dark"] .pm-diff-page .pm-toolbar input[type="date"] {
  border-color: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.02);
}

/* =========================================================
   ORDEN COLUMNAS
   ========================================================= */

.pm-diff-sortable {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
}

.pm-diff-sortable:hover {
  color: var(--text-strong);
}

.pm-diff-sortable__icon {
  display: inline-grid;
  place-items: center;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 950;
  line-height: 1;
  opacity: 0.55;
}

.pm-diff-sortable.is-active .pm-diff-sortable__icon {
  color: var(--text-strong);
  opacity: 1;
}

/* =========================================================
   TABLA · COLUMNAS
   ========================================================= */

.pm-diff-table-wrap {
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.pm-diff-table {
  width: 100%;
  table-layout: fixed;
}

.pm-diff-table th,
.pm-diff-table td {
  vertical-align: middle;
}

.pm-diff-table th:nth-child(1),
.pm-diff-table td:nth-child(1) {
  width: 11%;
}

.pm-diff-table th:nth-child(2),
.pm-diff-table td:nth-child(2) {
  width: 15%;
}

.pm-diff-table th:nth-child(3),
.pm-diff-table td:nth-child(3) {
  width: 31%;
}

.pm-diff-table th:nth-child(4),
.pm-diff-table td:nth-child(4),
.pm-diff-table th:nth-child(5),
.pm-diff-table td:nth-child(5),
.pm-diff-table th:nth-child(6),
.pm-diff-table td:nth-child(6),
.pm-diff-table th:nth-child(7),
.pm-diff-table td:nth-child(7) {
  width: 8%;
}

.pm-diff-table th:nth-child(8),
.pm-diff-table td:nth-child(8) {
  width: 11%;
  min-width: 104px;
  text-align: center;
  overflow: visible;
}

/* =========================================================
   ACCIONES · CENTRADAS Y MÁS GRANDES
   ========================================================= */

.pm-diff-table td:nth-child(8) {
  padding: 0 7px;
}

.pm-diff-table td:nth-child(8) .pm-table-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  width: 100%;
  height: 100%;
  min-height: 34px;
  flex-wrap: nowrap !important;
  overflow: visible !important;
}

.pm-diff-table td:nth-child(8) .pm-icon-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 25px !important;
  height: 25px !important;
  min-width: 25px !important;
  max-width: 25px !important;
  min-height: 25px !important;
  max-height: 25px !important;
  flex: 0 0 25px !important;
  padding: 0 !important;
  border-radius: 8px !important;
  border-color: rgba(15, 23, 42, 0.24) !important;
  background: #ffffff !important;
  color: #0f172a !important;
  opacity: 1 !important;
}

.pm-diff-table td:nth-child(8) .pm-icon-btn:hover {
  border-color: #0f172a !important;
  background: #f8fafc !important;
  color: #0f172a !important;
}

.pm-diff-table td:nth-child(8) .pm-icon-btn .icon {
  display: block !important;
  width: 15px !important;
  height: 15px !important;
  margin: 0 !important;
  padding: 0 !important;
  stroke-width: 2.35 !important;
  color: inherit !important;
  stroke: currentColor !important;
  opacity: 1 !important;
}

html[data-theme="dark"] .pm-diff-table td:nth-child(8) .pm-icon-btn {
  border-color: rgba(255, 255, 255, 0.18) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(255, 255, 255, 0.92) !important;
}

html[data-theme="dark"] .pm-diff-table td:nth-child(8) .pm-icon-btn:hover {
  border-color: rgba(255, 255, 255, 0.35) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  color: #ffffff !important;
}

/* =========================================================
   CONTENIDO TABLA
   ========================================================= */

.pm-diff-main {
  color: var(--text-strong);
  font-weight: 900;
}

.pm-diff-product {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pm-diff-product strong {
  color: var(--text-strong);
  font-size: 8.6px;
  font-weight: 950;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-diff-product small {
  color: var(--muted);
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-diff-stock {
  color: var(--text-strong);
  font-weight: 950;
}

.pm-diff-stock.is-low {
  color: #dc2626;
}

html[data-theme="dark"] .pm-diff-stock.is-low {
  color: #f87171;
}

.pm-diff-faltante {
  color: #dc2626 !important;
  font-weight: 950 !important;
}

html[data-theme="dark"] .pm-diff-faltante {
  color: #f87171 !important;
}

/* =========================================================
   MOBILE CARDS
   ========================================================= */

.pm-diff-mobile {
  display: none;
}

.pm-diff-empty {
  display: grid;
  gap: 4px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
}

.pm-diff-empty strong {
  color: var(--text-strong);
  font-size: 10px;
  font-weight: 950;
}

.pm-diff-empty span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 760;
}

.pm-diff-empty.is-error strong {
  color: #dc2626;
}

.pm-diff-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.11);
  border-radius: 14px;
  background: transparent;
}

.pm-diff-card header,
.pm-diff-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pm-diff-card header div {
  min-width: 0;
}

.pm-diff-card header span:first-child {
  display: block;
  color: var(--muted);
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.pm-diff-card header strong {
  display: block;
  margin-top: 3px;
  color: var(--text-strong);
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
}

.pm-diff-card header small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 780;
  line-height: 1.2;
}

.pm-diff-card__product {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.04);
}

.pm-diff-card__product strong {
  color: var(--text-strong);
  font-size: 9.5px;
  font-weight: 950;
}

.pm-diff-card__product span {
  color: var(--muted);
  font-size: 7.5px;
  font-weight: 800;
}

.pm-diff-card__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid rgba(0, 0, 0, 0.095);
  border-radius: 11px;
  overflow: hidden;
}

.pm-diff-card__grid div {
  display: grid;
  gap: 3px;
  padding: 7px;
  border-right: 1px solid rgba(0, 0, 0, 0.095);
}

.pm-diff-card__grid div:last-child {
  border-right: 0;
}

.pm-diff-card__grid span {
  color: var(--muted);
  font-size: 6.8px;
  font-weight: 950;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.pm-diff-card__grid strong {
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
}

.pm-diff-card__grid div:nth-child(1) strong {
  color: #111827;
}

.pm-diff-card__grid div:nth-child(2) strong {
  color: #7c3aed;
}

.pm-diff-card__grid div:nth-child(3) strong {
  color: #16a34a;
}

.pm-diff-card__grid div:nth-child(4) strong {
  color: #dc2626;
}

html[data-theme="dark"] .pm-diff-card__grid div:nth-child(1) strong {
  color: rgba(255, 255, 255, 0.9);
}

/* =========================================================
   MODAL RESUMEN
   ========================================================= */

.pm-diff-modal-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.pm-diff-modal-summary article {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.pm-diff-modal-summary article:last-child {
  border-right: 0;
}

.pm-diff-modal-summary span {
  color: var(--muted);
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pm-diff-modal-summary strong {
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 950;
}

.pm-diff-products-list {
  display: grid;
  gap: 7px;
  padding: 8px;
}

.pm-diff-product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 70px 70px 70px;
  gap: 7px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 11px;
  background: transparent;
}

.pm-diff-product-row.has-diff {
  border-color: color-mix(in srgb, #dc2626 35%, rgba(0, 0, 0, 0.12));
  background: color-mix(in srgb, #dc2626 4%, transparent);
}

.pm-diff-product-row.is-ok {
  border-color: color-mix(in srgb, #16a34a 24%, rgba(0, 0, 0, 0.12));
  background: color-mix(in srgb, #16a34a 3%, transparent);
}

.pm-diff-product-row__name {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pm-diff-product-row__name strong {
  color: var(--text-strong);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.12;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-diff-product-row__name span {
  color: var(--muted);
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-diff-product-row__value {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.pm-diff-product-row__value span {
  color: var(--muted);
  font-size: 6.7px;
  font-weight: 950;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
}

.pm-diff-product-row__value strong {
  color: var(--text-strong);
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
}

.pm-diff-product-row__value.is-stock-low strong,
.pm-diff-product-row__value.is-faltante strong {
  color: #dc2626;
}

.pm-diff-product-row__value.is-armado strong {
  color: #16a34a;
}

.pm-diff-product-row__value.is-cargado strong {
  color: #7c3aed;
}

.pm-diff-detail-empty {
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 850;
  text-align: center;
}

/* =========================================================
   DARK SAFE
   ========================================================= */

html[data-theme="dark"] .pm-diff-card,
html[data-theme="dark"] .pm-diff-card__grid,
html[data-theme="dark"] .pm-diff-modal-summary,
html[data-theme="dark"] .pm-diff-product-row {
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .pm-diff-card__product {
  background: rgba(255, 255, 255, 0.055);
}

html[data-theme="dark"] .pm-diff-card__grid div,
html[data-theme="dark"] .pm-diff-modal-summary article {
  border-right-color: rgba(255, 255, 255, 0.09);
}

html[data-theme="dark"] .pm-diff-product-row.has-diff {
  border-color: color-mix(in srgb, #f87171 40%, rgba(255, 255, 255, 0.12));
  background: color-mix(in srgb, #f87171 6%, transparent);
}

html[data-theme="dark"] .pm-diff-product-row.is-ok {
  border-color: color-mix(in srgb, #4ade80 30%, rgba(255, 255, 255, 0.12));
  background: color-mix(in srgb, #4ade80 5%, transparent);
}

html[data-theme="dark"] .pm-diff-product-row__value.is-stock-low strong,
html[data-theme="dark"] .pm-diff-product-row__value.is-faltante strong {
  color: #f87171;
}

html[data-theme="dark"] .pm-diff-product-row__value.is-armado strong {
  color: #4ade80;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1180px) {
  .pm-diff-page .pm-panel__head--toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pm-diff-page .pm-toolbar {
    justify-content: flex-start;
    width: 100%;
  }

  .pm-diff-page .pm-toolbar .pm-search {
    flex: 1 1 auto;
    width: auto;
  }
}

@media (max-width: 940px) {
  .pm-diff-table-wrap {
    display: none;
  }

  .pm-diff-mobile {
    display: grid;
    gap: 8px;
    padding: 8px;
  }

  .pm-diff-modal-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pm-diff-modal-summary article:nth-child(2n) {
    border-right: 0;
  }

  .pm-diff-modal-summary article:nth-child(n + 3) {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }

  .pm-diff-product-row {
    grid-template-columns: minmax(0, 1fr) repeat(4, 58px);
  }
}

@media (max-width: 760px) {
  .pm-diff-page .pm-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .pm-diff-page .pm-toolbar .pm-search {
    grid-column: 1 / -1;
    width: 100%;
  }

  .pm-diff-page .pm-toolbar input[type="date"] {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .pm-diff-card header,
  .pm-diff-card footer {
    align-items: stretch;
    flex-direction: column;
  }

  .pm-diff-card footer .pm-table-actions {
    width: 100%;
  }

  .pm-diff-card footer .pm-btn {
    width: 100%;
  }

  .pm-diff-card__grid,
  .pm-diff-modal-summary {
    grid-template-columns: 1fr;
  }

  .pm-diff-card__grid div,
  .pm-diff-modal-summary article {
    border-right: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }

  .pm-diff-card__grid div:first-child,
  .pm-diff-modal-summary article:first-child {
    border-top: 0;
  }

  .pm-diff-product-row {
    grid-template-columns: 1fr 1fr;
  }

  .pm-diff-product-row__name {
    grid-column: 1 / -1;
  }
}