/* =========================================================
   WIRTZ HUB · PEDIDOS MAYORISTAS · HISTORIAL
   CSS limpio · Historial + Diferencias integradas
   ========================================================= */

/* =========================================================
   PAGE
   ========================================================= */

.pm-page.pm-hist-page {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;

  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - var(--topbar-height, 72px) - 44px);

  color: #111827;
  overflow-x: hidden;
}

html[data-theme="dark"] .pm-page.pm-hist-page {
  color: #f9fafb;
}

/* =========================================================
   HEADER
   ========================================================= */

.pm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  width: 100%;
  padding: 14px 16px;

  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
}

html[data-theme="dark"] .pm-head {
  background: #111827;
  border-color: #273244;
}

.pm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pm-brand__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 42px;
  height: 42px;
  flex: 0 0 42px;

  color: #111827;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

html[data-theme="dark"] .pm-brand__icon {
  color: #f9fafb;
  background: #1f2937;
  border-color: #374151;
}

.pm-brand h2 {
  margin: 0;
  color: inherit;
  font-size: 21px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.pm-brand p {
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

html[data-theme="dark"] .pm-brand p {
  color: #9ca3af;
}

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

/* =========================================================
   BUTTONS
   ========================================================= */

.pm-btn,
.pm-icon-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.pm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 36px;
  padding: 0 13px;

  color: #111827;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;

  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;

  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.pm-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.pm-btn--dark {
  color: #ffffff;
  background: #111827;
  border-color: #111827;
}

.pm-btn--dark:hover {
  background: #030712;
  border-color: #030712;
}

html[data-theme="dark"] .pm-btn {
  color: #f9fafb;
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-btn:hover {
  background: #273244;
  border-color: #4b5563;
}

html[data-theme="dark"] .pm-btn--dark {
  color: #111827;
  background: #f9fafb;
  border-color: #f9fafb;
}

html[data-theme="dark"] .pm-btn--dark:hover {
  background: #e5e7eb;
  border-color: #e5e7eb;
}

.pm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 34px;
  height: 34px;
  min-width: 34px;

  color: #111827;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 11px;

  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.pm-icon-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.pm-icon-btn.is-danger {
  color: #991b1b;
  background: #fff7f7;
  border-color: #fecaca;
}

html[data-theme="dark"] .pm-icon-btn {
  color: #f9fafb;
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-icon-btn:hover {
  background: #273244;
  border-color: #4b5563;
}

html[data-theme="dark"] .pm-icon-btn.is-danger {
  color: #fecaca;
  background: #331313;
  border-color: #7f1d1d;
}

.icon {
  width: 17px;
  height: 17px;
  display: block;
  stroke-width: 2.2;
  flex: 0 0 auto;
}

/* =========================================================
   METRICS
   ========================================================= */

.pm-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.pm-card-metric {
  min-width: 0;
  padding: 14px 14px 13px;

  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
}

html[data-theme="dark"] .pm-card-metric {
  background: #111827;
  border-color: #273244;
}

.pm-card-metric span {
  display: block;
  margin-bottom: 7px;

  color: #6b7280;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.pm-card-metric strong {
  display: block;

  color: #111827;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
}

.pm-card-metric small {
  display: block;
  margin-top: 7px;

  color: #6b7280;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
}

html[data-theme="dark"] .pm-card-metric span,
html[data-theme="dark"] .pm-card-metric small {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-card-metric strong {
  color: #f9fafb;
}

/* =========================================================
   PANELS
   ========================================================= */

.pm-panel {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  overflow: hidden;
}

html[data-theme="dark"] .pm-panel {
  background: #111827;
  border-color: #273244;
}

.pm-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  min-height: 58px;
  padding: 13px 15px;

  border-bottom: 1px solid #e5e7eb;
}

html[data-theme="dark"] .pm-panel__head {
  border-color: #273244;
}

.pm-panel__head--toolbar {
  align-items: flex-start;
}

.pm-panel__head span {
  display: block;
  margin-bottom: 4px;

  color: #6b7280;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pm-panel__head strong {
  display: block;

  color: #111827;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.15;
}

.pm-panel__head small {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
}

html[data-theme="dark"] .pm-panel__head span,
html[data-theme="dark"] .pm-panel__head small {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-panel__head strong {
  color: #f9fafb;
}

/* =========================================================
   FILTERS / TOOLBAR
   ========================================================= */

.pm-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: min(100%, 720px);
}

.pm-search {
  display: flex;
  align-items: center;
  gap: 8px;

  min-width: 280px;
  height: 38px;
  padding: 0 11px;

  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 12px;
}

.pm-search input {
  width: 100%;
  min-width: 0;
  height: 100%;

  color: #111827;
  background: transparent;
  border: 0;
  outline: 0;

  font-size: 13px;
  font-weight: 650;
}

.pm-search input::placeholder {
  color: #9ca3af;
}

.pm-toolbar select,
.pm-toolbar input[type="date"] {
  height: 38px;
  min-width: 132px;
  padding: 0 10px;

  color: #111827;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  outline: 0;

  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
}

html[data-theme="dark"] .pm-search {
  color: #9ca3af;
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-search input,
html[data-theme="dark"] .pm-toolbar select,
html[data-theme="dark"] .pm-toolbar input[type="date"] {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-toolbar select,
html[data-theme="dark"] .pm-toolbar input[type="date"] {
  background: #1f2937;
  border-color: #374151;
}

/* =========================================================
   TABS
   ========================================================= */

.pm-hist-tabs-panel {
  padding: 8px;
}

.pm-hist-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pm-hist-tab {
  appearance: none;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 38px;
  padding: 0 14px;

  color: #374151;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 13px;

  font-family: inherit;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;

  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}

.pm-hist-tab:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.pm-hist-tab.is-active {
  color: #ffffff;
  background: #111827;
  border-color: #111827;
}

html[data-theme="dark"] .pm-hist-tab {
  color: #d1d5db;
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-hist-tab:hover {
  background: #273244;
}

html[data-theme="dark"] .pm-hist-tab.is-active {
  color: #111827;
  background: #f9fafb;
  border-color: #f9fafb;
}

.pm-hist-section {
  display: none;
}

.pm-hist-section.is-active {
  display: block;
}

/* =========================================================
   TABLES
   ========================================================= */

.pm-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pm-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.pm-table th,
.pm-table td {
  padding: 11px 10px;
  color: #111827;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
  text-align: left;
}

.pm-table th {
  color: #6b7280;
  background: #f9fafb;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pm-table td {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.pm-table td strong {
  display: block;
  color: #111827;
  font-size: 12.5px;
  font-weight: 850;
  line-height: 1.2;
}

.pm-table td small {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

.pm-table tbody tr:hover {
  background: #f9fafb;
}

.pm-table tbody tr:last-child td {
  border-bottom: 0;
}

html[data-theme="dark"] .pm-table th {
  color: #9ca3af;
  background: #1f2937;
  border-color: #273244;
}

html[data-theme="dark"] .pm-table td {
  color: #f9fafb;
  border-color: #273244;
}

html[data-theme="dark"] .pm-table td strong {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-table td small {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-table tbody tr:hover {
  background: #162032;
}

/* Columnas historial */
.pm-hist-table th:nth-child(1),
.pm-hist-table td:nth-child(1) {
  width: 140px;
}

.pm-hist-table th:nth-child(2),
.pm-hist-table td:nth-child(2) {
  width: 190px;
}

.pm-hist-table th:nth-child(3),
.pm-hist-table td:nth-child(3) {
  width: 120px;
}

.pm-hist-table th:nth-child(4),
.pm-hist-table td:nth-child(4) {
  width: 150px;
}

.pm-hist-table th:nth-child(5),
.pm-hist-table td:nth-child(5),
.pm-hist-table th:nth-child(6),
.pm-hist-table td:nth-child(6),
.pm-hist-table th:nth-child(7),
.pm-hist-table td:nth-child(7),
.pm-hist-table th:nth-child(8),
.pm-hist-table td:nth-child(8),
.pm-hist-table th:nth-child(9),
.pm-hist-table td:nth-child(9),
.pm-hist-table th:nth-child(10),
.pm-hist-table td:nth-child(10) {
  width: 92px;
  text-align: center;
}

.pm-hist-table th:nth-child(11),
.pm-hist-table td:nth-child(11) {
  width: 92px;
  text-align: center;
}

/* Columnas diferencias */
.pm-hist-diff-table {
  min-width: 1120px;
}

.pm-hist-diff-table th:nth-child(1),
.pm-hist-diff-table td:nth-child(1) {
  width: 140px;
}

.pm-hist-diff-table th:nth-child(2),
.pm-hist-diff-table td:nth-child(2) {
  width: 175px;
}

.pm-hist-diff-table th:nth-child(3),
.pm-hist-diff-table td:nth-child(3) {
  width: 250px;
}

.pm-hist-diff-table th:nth-child(4),
.pm-hist-diff-table td:nth-child(4) {
  width: 130px;
}

.pm-hist-diff-table th:nth-child(5),
.pm-hist-diff-table td:nth-child(5),
.pm-hist-diff-table th:nth-child(6),
.pm-hist-diff-table td:nth-child(6),
.pm-hist-diff-table th:nth-child(7),
.pm-hist-diff-table td:nth-child(7),
.pm-hist-diff-table th:nth-child(8),
.pm-hist-diff-table td:nth-child(8),
.pm-hist-diff-table th:nth-child(9),
.pm-hist-diff-table td:nth-child(9) {
  width: 88px;
  text-align: center;
}

.pm-hist-diff-table th:nth-child(10),
.pm-hist-diff-table td:nth-child(10) {
  width: 88px;
  text-align: center;
}

.pm-table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pm-hist-main {
  display: block;
  overflow: hidden;
  color: #111827;
  font-size: 12.5px;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .pm-hist-main {
  color: #f9fafb;
}

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

.pm-hist-diff-product strong,
.pm-hist-diff-product small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-hist-diff-stock {
  color: #111827;
  font-weight: 900;
}

.pm-hist-diff-stock.is-low,
.pm-hist-diff-faltante {
  color: #b91c1c !important;
}

html[data-theme="dark"] .pm-hist-diff-stock {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-hist-diff-stock.is-low,
html[data-theme="dark"] .pm-hist-diff-faltante {
  color: #fca5a5 !important;
}

.pm-table tr.has-diff {
  background: #fff7ed;
}

.pm-table tr.is-ok {
  background: #f0fdf4;
}

html[data-theme="dark"] .pm-table tr.has-diff {
  background: #2a1b0f;
}

html[data-theme="dark"] .pm-table tr.is-ok {
  background: #102316;
}

/* =========================================================
   BADGES
   ========================================================= */

.pm-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 24px;
  max-width: 100%;
  padding: 0 9px;

  color: #374151;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;

  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pm-badge.is-ok {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.pm-badge.is-warning {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.pm-badge.is-danger {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

.pm-badge.is-info {
  color: #1f3a8a;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.pm-badge.is-muted {
  color: #4b5563;
  background: #f3f4f6;
  border-color: #e5e7eb;
}

html[data-theme="dark"] .pm-badge {
  color: #d1d5db;
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-badge.is-ok {
  color: #bbf7d0;
  background: #12301d;
  border-color: #166534;
}

html[data-theme="dark"] .pm-badge.is-warning {
  color: #fde68a;
  background: #332509;
  border-color: #92400e;
}

html[data-theme="dark"] .pm-badge.is-danger {
  color: #fecaca;
  background: #331313;
  border-color: #991b1b;
}

html[data-theme="dark"] .pm-badge.is-info {
  color: #bfdbfe;
  background: #13233f;
  border-color: #1d4ed8;
}

html[data-theme="dark"] .pm-badge.is-muted {
  color: #9ca3af;
  background: #1f2937;
  border-color: #374151;
}

/* =========================================================
   EVENT TIMELINE
   ========================================================= */

.pm-hist-events-panel {
  min-height: 420px;
}

.pm-hist-timeline {
  display: grid;
  gap: 10px;
  max-height: 620px;
  padding: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.pm-hist-event {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;

  padding: 11px;

  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 15px;
}

html[data-theme="dark"] .pm-hist-event {
  background: #111827;
  border-color: #273244;
}

.pm-hist-event__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;

  color: #111827;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.pm-hist-event.is-ok .pm-hist-event__icon {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.pm-hist-event.is-warning .pm-hist-event__icon {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.pm-hist-event.is-danger .pm-hist-event__icon {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

.pm-hist-event.is-info .pm-hist-event__icon {
  color: #1f3a8a;
  background: #dbeafe;
  border-color: #bfdbfe;
}

html[data-theme="dark"] .pm-hist-event__icon {
  color: #f9fafb;
  background: #1f2937;
  border-color: #374151;
}

.pm-hist-event__body {
  min-width: 0;
}

.pm-hist-event__body header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pm-hist-event__body header span {
  display: block;
  margin-bottom: 3px;

  color: #6b7280;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pm-hist-event__body header strong {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
}

.pm-hist-event__body header small {
  display: block;
  margin-top: 3px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

.pm-hist-event__body time {
  color: #6b7280;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.pm-hist-event__body p {
  margin: 8px 0 0;
  color: #374151;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.pm-hist-event__body footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.pm-hist-event__body footer span {
  display: inline-flex;
  align-items: center;
  gap: 5px;

  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 5px 8px;

  font-size: 10.5px;
  font-weight: 750;
}

.pm-hist-event__body footer .pm-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.pm-hist-event__body footer .icon {
  width: 14px;
  height: 14px;
}

html[data-theme="dark"] .pm-hist-event__body header span,
html[data-theme="dark"] .pm-hist-event__body header small,
html[data-theme="dark"] .pm-hist-event__body time,
html[data-theme="dark"] .pm-hist-event__body footer span {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-hist-event__body header strong {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-hist-event__body p {
  color: #d1d5db;
}

html[data-theme="dark"] .pm-hist-event__body footer span {
  background: #1f2937;
  border-color: #374151;
}

/* =========================================================
   EMPTY STATES
   ========================================================= */

.pm-hist-empty,
.pm-hist-diff-empty {
  display: grid;
  place-items: center;
  gap: 7px;

  min-height: 180px;
  padding: 22px;

  color: #6b7280;
  text-align: center;
}

.pm-hist-empty .icon {
  width: 28px;
  height: 28px;
}

.pm-hist-empty strong,
.pm-hist-diff-empty strong {
  color: #111827;
  font-size: 14px;
  font-weight: 850;
}

.pm-hist-empty span,
.pm-hist-diff-empty span {
  color: #6b7280;
  font-size: 12px;
  font-weight: 650;
}

.pm-hist-empty.is-error strong {
  color: #991b1b;
}

html[data-theme="dark"] .pm-hist-empty,
html[data-theme="dark"] .pm-hist-diff-empty,
html[data-theme="dark"] .pm-hist-empty span,
html[data-theme="dark"] .pm-hist-diff-empty span {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-hist-empty strong,
html[data-theme="dark"] .pm-hist-diff-empty strong {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-hist-empty.is-error strong {
  color: #fecaca;
}

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

.pm-hist-diff-mobile {
  display: none;
  padding: 12px;
}

.pm-hist-diff-card {
  display: grid;
  gap: 11px;

  padding: 13px;
  margin-bottom: 10px;

  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
}

.pm-hist-diff-card:last-child {
  margin-bottom: 0;
}

html[data-theme="dark"] .pm-hist-diff-card {
  background: #111827;
  border-color: #273244;
}

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

.pm-hist-diff-card header span,
.pm-hist-diff-card header small {
  display: block;
  color: #6b7280;
  font-size: 11px;
  font-weight: 750;
}

.pm-hist-diff-card header strong {
  display: block;
  margin: 3px 0;
  color: #111827;
  font-size: 14px;
  font-weight: 850;
}

.pm-hist-diff-card__product {
  display: grid;
  gap: 4px;
}

.pm-hist-diff-card__product strong {
  color: #111827;
  font-size: 13px;
  font-weight: 850;
}

.pm-hist-diff-card__product span {
  color: #6b7280;
  font-size: 12px;
  font-weight: 650;
}

.pm-hist-diff-card__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pm-hist-diff-card__grid div {
  padding: 9px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.pm-hist-diff-card__grid span {
  display: block;
  margin-bottom: 4px;
  color: #6b7280;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.pm-hist-diff-card__grid strong {
  color: #111827;
  font-size: 14px;
  font-weight: 900;
}

html[data-theme="dark"] .pm-hist-diff-card header span,
html[data-theme="dark"] .pm-hist-diff-card header small,
html[data-theme="dark"] .pm-hist-diff-card__product span,
html[data-theme="dark"] .pm-hist-diff-card__grid span {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-hist-diff-card header strong,
html[data-theme="dark"] .pm-hist-diff-card__product strong,
html[data-theme="dark"] .pm-hist-diff-card__grid strong {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-hist-diff-card__grid div {
  background: #1f2937;
  border-color: #374151;
}

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

.pm-modal {
  position: fixed;
  inset: 0;
  z-index: 90;

  display: none;
  align-items: center;
  justify-content: center;

  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.pm-modal.is-open {
  display: flex;
}

.pm-modal__card {
  display: flex;
  flex-direction: column;

  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);

  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 22px;
  overflow: hidden;
}

html[data-theme="dark"] .pm-modal__card {
  background: #111827;
  border-color: #374151;
}

.pm-hist-detail-modal {
  width: min(1280px, calc(100vw - 28px));
}

.pm-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  padding: 15px 16px;
  border-bottom: 1px solid #e5e7eb;
}

html[data-theme="dark"] .pm-modal__head {
  border-color: #273244;
}

.pm-modal__head span {
  display: block;
  margin-bottom: 4px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.pm-modal__head strong {
  display: block;
  color: #111827;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
}

.pm-modal__head small {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 650;
}

html[data-theme="dark"] .pm-modal__head span,
html[data-theme="dark"] .pm-modal__head small {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-modal__head strong {
  color: #f9fafb;
}

.pm-modal__body {
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* =========================================================
   DETAIL MODAL CONTENT
   ========================================================= */

.pm-hist-detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
}

.pm-hist-detail-grid article {
  min-width: 0;
  padding: 11px;

  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

.pm-hist-detail-grid span {
  display: block;
  margin-bottom: 5px;
  color: #6b7280;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pm-hist-detail-grid strong {
  display: block;
  overflow: hidden;
  color: #111827;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .pm-hist-detail-grid article {
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-hist-detail-grid span {
  color: #9ca3af;
}

html[data-theme="dark"] .pm-hist-detail-grid strong {
  color: #f9fafb;
}

.pm-hist-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pm-hist-mini-table-wrap,
.pm-hist-detail-table-wrap {
  max-height: 360px;
  overflow: auto;
  scrollbar-width: thin;
}

.pm-hist-mini-table {
  min-width: 520px;
}

.pm-hist-detail-table {
  min-width: 980px;
}

.pm-hist-mini-table th:nth-child(1),
.pm-hist-mini-table td:nth-child(1) {
  width: 130px;
}

.pm-hist-mini-table th:nth-child(2),
.pm-hist-mini-table td:nth-child(2) {
  width: auto;
}

.pm-hist-mini-table th:nth-child(3),
.pm-hist-mini-table td:nth-child(3) {
  width: 90px;
  text-align: center;
}

.pm-hist-detail-table th:nth-child(1),
.pm-hist-detail-table td:nth-child(1) {
  width: 130px;
}

.pm-hist-detail-table th:nth-child(2),
.pm-hist-detail-table td:nth-child(2) {
  width: 280px;
}

.pm-hist-detail-table th:nth-child(3),
.pm-hist-detail-table td:nth-child(3),
.pm-hist-detail-table th:nth-child(4),
.pm-hist-detail-table td:nth-child(4),
.pm-hist-detail-table th:nth-child(5),
.pm-hist-detail-table td:nth-child(5),
.pm-hist-detail-table th:nth-child(6),
.pm-hist-detail-table td:nth-child(6) {
  width: 92px;
  text-align: center;
}

.pm-hist-detail-table th:nth-child(7),
.pm-hist-detail-table td:nth-child(7) {
  width: 115px;
  text-align: center;
}

.pm-hist-detail-table th:nth-child(8),
.pm-hist-detail-table td:nth-child(8) {
  width: 190px;
}

.pm-hist-detail-events {
  display: grid;
  gap: 9px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
}

.pm-hist-detail-events article {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;

  padding: 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

.pm-hist-detail-events strong {
  display: block;
  color: #111827;
  font-size: 13px;
  font-weight: 850;
}

.pm-hist-detail-events span,
.pm-hist-detail-events small {
  display: block;
  margin-top: 3px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 650;
}

html[data-theme="dark"] .pm-hist-detail-events article {
  background: #1f2937;
  border-color: #374151;
}

html[data-theme="dark"] .pm-hist-detail-events strong {
  color: #f9fafb;
}

html[data-theme="dark"] .pm-hist-detail-events span,
html[data-theme="dark"] .pm-hist-detail-events small {
  color: #9ca3af;
}

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

@media (max-width: 1180px) {
  .pm-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pm-hist-detail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pm-hist-compare-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .pm-head,
  .pm-panel__head,
  .pm-panel__head--toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pm-actions,
  .pm-toolbar {
    justify-content: flex-start;
    width: 100%;
  }

  .pm-search {
    width: 100%;
    min-width: 0;
  }

  .pm-toolbar select,
  .pm-toolbar input[type="date"] {
    flex: 1 1 160px;
    min-width: 0;
  }

  .pm-table {
    min-width: 980px;
  }
}

@media (max-width: 760px) {
  .pm-page.pm-hist-page {
    gap: 10px;
  }

  .pm-head,
  .pm-panel,
  .pm-card-metric {
    border-radius: 16px;
  }

  .pm-brand {
    align-items: flex-start;
  }

  .pm-brand__icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .pm-brand h2 {
    font-size: 19px;
  }

  .pm-brand p {
    font-size: 12px;
  }

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

  .pm-card-metric strong {
    font-size: 22px;
  }

  .pm-hist-diff-table-wrap {
    display: none;
  }

  .pm-hist-diff-mobile {
    display: grid;
  }

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

  .pm-hist-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pm-modal {
    padding: 10px;
  }

  .pm-modal__card,
  .pm-hist-detail-modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 18px;
  }

  .pm-modal__head {
    align-items: stretch;
    flex-direction: column;
  }

  .pm-modal__body {
    padding: 10px;
  }
}

@media (max-width: 520px) {
  .pm-metrics,
  .pm-hist-detail-grid {
    grid-template-columns: 1fr;
  }

  .pm-actions,
  .pm-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pm-btn {
    width: 100%;
  }

  .pm-toolbar select,
  .pm-toolbar input[type="date"] {
    width: 100%;
  }

  .pm-hist-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pm-hist-tab {
    width: 100%;
  }

  .pm-hist-event {
    grid-template-columns: 1fr;
  }

  .pm-hist-event__body header {
    flex-direction: column;
  }

  .pm-hist-event__body time {
    white-space: normal;
  }
}/* =========================================================
   HISTORIAL · SIN AZUL OSCURO
   Paleta neutra: negro / blanco / grises
   ========================================================= */

/* Botones principales activos */
.pm-btn--dark,
.pm-hist-tab.is-active {
  color: #ffffff !important;
  background: #111111 !important;
  border-color: #111111 !important;
}

.pm-btn--dark:hover,
.pm-hist-tab.is-active:hover {
  color: #ffffff !important;
  background: #000000 !important;
  border-color: #000000 !important;
}

/* Modo oscuro: botón activo sigue neutro, no azul */
html[data-theme="dark"] .pm-btn--dark,
html[data-theme="dark"] .pm-hist-tab.is-active {
  color: #111111 !important;
  background: #ffffff !important;
  border-color: #ffffff !important;
}

html[data-theme="dark"] .pm-btn--dark:hover,
html[data-theme="dark"] .pm-hist-tab.is-active:hover {
  color: #111111 !important;
  background: #e5e7eb !important;
  border-color: #e5e7eb !important;
}

/* Badges info: antes azul, ahora gris */
.pm-badge.is-info {
  color: #374151 !important;
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
}

html[data-theme="dark"] .pm-badge.is-info {
  color: #f3f4f6 !important;
  background: #1f2937 !important;
  border-color: #4b5563 !important;
}

/* Eventos info: antes azul, ahora gris */
.pm-hist-event.is-info .pm-hist-event__icon {
  color: #374151 !important;
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
}

html[data-theme="dark"] .pm-hist-event.is-info .pm-hist-event__icon {
  color: #f3f4f6 !important;
  background: #1f2937 !important;
  border-color: #4b5563 !important;
}

/* Iconos / fondos que podían verse azulados */
.pm-brand__icon,
.pm-hist-event__icon {
  color: #111111 !important;
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
}

html[data-theme="dark"] .pm-brand__icon,
html[data-theme="dark"] .pm-hist-event__icon {
  color: #ffffff !important;
  background: #1f2937 !important;
  border-color: #4b5563 !important;
}

/* Hover de filas sin tinte azul */
.pm-table tbody tr:hover {
  background: #f9fafb !important;
}

html[data-theme="dark"] .pm-table tbody tr:hover {
  background: #1f2937 !important;
}

/* Inputs / selects sin azul */
.pm-search,
.pm-toolbar select,
.pm-toolbar input[type="date"] {
  accent-color: #111111;
}

html[data-theme="dark"] .pm-search,
html[data-theme="dark"] .pm-toolbar select,
html[data-theme="dark"] .pm-toolbar input[type="date"] {
  accent-color: #ffffff;
}/* =========================================================
   HISTORIAL · LIMPIEZA TOTAL AZUL
   Negro / gris neutro real
   Pegar al final del CSS
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page,
html[data-theme="dark"] .pm-page.pm-hist-page * {
  scrollbar-color: #525252 #0a0a0a;
}

/* =========================================================
   FONDOS PRINCIPALES
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-head,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-panel,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-card-metric,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-modal__card,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-event,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-diff-card {
  background: #0f0f0f !important;
  border-color: #2a2a2a !important;
  color: #f5f5f5 !important;
}

/* Fondo de cabeceras internas */
html[data-theme="dark"] .pm-page.pm-hist-page .pm-panel__head,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-modal__head {
  background: #0f0f0f !important;
  border-color: #2a2a2a !important;
}

/* Bloque tabs que se veía azul */
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tabs-panel {
  background: #0f0f0f !important;
  border-color: #2a2a2a !important;
}

/* =========================================================
   TABLAS · SACAR AZUL DE FILAS Y CABECERA
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-table th {
  background: #181818 !important;
  color: #a3a3a3 !important;
  border-color: #2a2a2a !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-table td {
  background: #101010 !important;
  color: #f5f5f5 !important;
  border-color: #2a2a2a !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-table tbody tr:hover td {
  background: #1a1a1a !important;
}

/* Filas OK / diferencia sin azul */
html[data-theme="dark"] .pm-page.pm-hist-page .pm-table tr.has-diff td {
  background: #1c1410 !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-table tr.is-ok td {
  background: #101810 !important;
}

/* =========================================================
   INPUTS / FILTROS
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-search,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-toolbar select,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-toolbar input[type="date"] {
  background: #181818 !important;
  border-color: #333333 !important;
  color: #f5f5f5 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-search input {
  color: #f5f5f5 !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-search input::placeholder {
  color: #a3a3a3 !important;
}

/* =========================================================
   BOTONES
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-btn,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-icon-btn,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab {
  background: #181818 !important;
  border-color: #333333 !important;
  color: #f5f5f5 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-btn:hover,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-icon-btn:hover,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab:hover {
  background: #222222 !important;
  border-color: #4a4a4a !important;
  color: #ffffff !important;
}

/* Activos blancos como en tu screenshot */
html[data-theme="dark"] .pm-page.pm-hist-page .pm-btn--dark,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab.is-active {
  background: #ffffff !important;
  border-color: #ffffff !important;
  color: #111111 !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-btn--dark:hover,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab.is-active:hover {
  background: #e5e5e5 !important;
  border-color: #e5e5e5 !important;
  color: #111111 !important;
}

/* =========================================================
   ICONOS / CONTENEDORES DE ICONOS
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-brand__icon,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-event__icon {
  background: #181818 !important;
  border-color: #333333 !important;
  color: #f5f5f5 !important;
}

/* =========================================================
   BADGES · SIN AZUL
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-badge,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-badge.is-info,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-badge.is-muted {
  background: #222222 !important;
  border-color: #3a3a3a !important;
  color: #d4d4d4 !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-badge.is-ok {
  background: #102015 !important;
  border-color: #245c36 !important;
  color: #86efac !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-badge.is-warning {
  background: #241a0b !important;
  border-color: #7c4a03 !important;
  color: #facc15 !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page .pm-badge.is-danger {
  background: #2a1111 !important;
  border-color: #7f1d1d !important;
  color: #fca5a5 !important;
}

/* Evento info antes azul */
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-event.is-info .pm-hist-event__icon {
  background: #222222 !important;
  border-color: #3a3a3a !important;
  color: #e5e5e5 !important;
}

/* =========================================================
   TARJETAS / DETALLE MODAL
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-detail-grid article,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-diff-card__grid div,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-detail-events article {
  background: #181818 !important;
  border-color: #333333 !important;
}

/* =========================================================
   TEXTOS
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page strong,
html[data-theme="dark"] .pm-page.pm-hist-page h2,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-main,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-table td strong {
  color: #f5f5f5 !important;
}

html[data-theme="dark"] .pm-page.pm-hist-page span,
html[data-theme="dark"] .pm-page.pm-hist-page small,
html[data-theme="dark"] .pm-page.pm-hist-page p,
html[data-theme="dark"] .pm-page.pm-hist-page time {
  color: #a3a3a3 !important;
}

/* Respetar faltantes en rojo */
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-diff-faltante,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-diff-stock.is-low {
  color: #f87171 !important;
}

/* =========================================================
   MODAL OVERLAY
   ========================================================= */

html[data-theme="dark"] .pm-page.pm-hist-page .pm-modal {
  background: rgba(0, 0, 0, 0.72) !important;
}/* =========================================================
   PEDIDOS MAYORISTAS · HISTORIAL
   TAMAÑO IGUAL A LAS DEMÁS PÁGINAS
   ========================================================= */

.pm-page.pm-hist-page {
  gap: 9px !important;
}

/* Header */
.pm-page.pm-hist-page .pm-head {
  min-height: 60px !important;
  padding: 10px !important;
  gap: 10px !important;
  border-radius: 16px !important;
}

.pm-page.pm-hist-page .pm-brand {
  gap: 9px !important;
}

.pm-page.pm-hist-page .pm-brand__icon {
  width: 32px !important;
  height: 32px !important;
  flex: 0 0 32px !important;
  border-radius: 11px !important;
}

.pm-page.pm-hist-page .pm-brand__icon .icon,
.pm-page.pm-hist-page .pm-brand__icon svg {
  width: 15.5px !important;
  height: 15.5px !important;
}

.pm-page.pm-hist-page .pm-brand h2 {
  font-size: 15px !important;
  line-height: 1 !important;
}

.pm-page.pm-hist-page .pm-brand p {
  margin-top: 3px !important;
  font-size: 9.8px !important;
  line-height: 1.36 !important;
}

/* Iconos generales */
.pm-page.pm-hist-page .icon,
.pm-page.pm-hist-page svg,
.pm-modal .icon,
.pm-modal svg {
  width: 12px !important;
  height: 12px !important;
  min-width: 12px !important;
}

/* Botones */
.pm-page.pm-hist-page .pm-btn,
.pm-page.pm-hist-page .pm-hist-tab,
.pm-modal .pm-btn {
  min-height: 30px !important;
  height: 30px !important;
  padding: 0 10px !important;
  gap: 5px !important;
  border-radius: 10px !important;
  font-size: 9.4px !important;
}

.pm-page.pm-hist-page .pm-icon-btn,
.pm-modal .pm-icon-btn {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  border-radius: 10px !important;
}

/* Métricas */
.pm-page.pm-hist-page .pm-metrics {
  gap: 9px !important;
}

.pm-page.pm-hist-page .pm-card-metric {
  min-height: 48px !important;
  padding: 9px 10px !important;
  border-radius: 16px !important;
}

.pm-page.pm-hist-page .pm-card-metric span {
  margin-bottom: 4px !important;
  font-size: 7.8px !important;
  line-height: 1 !important;
}

.pm-page.pm-hist-page .pm-card-metric strong {
  font-size: 16px !important;
  line-height: 1 !important;
}

.pm-page.pm-hist-page .pm-card-metric small {
  margin-top: 4px !important;
  font-size: 7.8px !important;
  line-height: 1.1 !important;
}

/* Paneles */
.pm-page.pm-hist-page .pm-panel {
  border-radius: 16px !important;
}

.pm-page.pm-hist-page .pm-panel__head,
.pm-modal .pm-panel__head {
  min-height: 46px !important;
  padding: 10px 11px !important;
  gap: 10px !important;
}

.pm-page.pm-hist-page .pm-panel__head span,
.pm-modal .pm-panel__head span {
  margin-bottom: 3px !important;
  font-size: 7.8px !important;
}

.pm-page.pm-hist-page .pm-panel__head strong,
.pm-modal .pm-panel__head strong {
  font-size: 12px !important;
}

.pm-page.pm-hist-page .pm-panel__head small {
  margin-top: 3px !important;
  font-size: 8.8px !important;
}

/* Toolbar / filtros */
.pm-page.pm-hist-page .pm-toolbar {
  gap: 7px !important;
  min-width: min(100%, 650px) !important;
}

.pm-page.pm-hist-page .pm-search {
  min-width: 240px !important;
  height: 30px !important;
  padding: 0 9px !important;
  gap: 6px !important;
  border-radius: 10px !important;
}

.pm-page.pm-hist-page .pm-search input {
  font-size: 9.6px !important;
}

.pm-page.pm-hist-page .pm-toolbar select,
.pm-page.pm-hist-page .pm-toolbar input[type="date"] {
  height: 30px !important;
  min-width: 118px !important;
  padding: 0 9px !important;
  border-radius: 10px !important;
  font-size: 9.4px !important;
}

/* Tabs */
.pm-page.pm-hist-page .pm-hist-tabs-panel {
  padding: 8px !important;
}

.pm-page.pm-hist-page .pm-hist-tabs {
  gap: 7px !important;
}

.pm-page.pm-hist-page .pm-hist-tab {
  min-height: 30px !important;
  height: 30px !important;
  padding: 0 10px !important;
  font-size: 9.4px !important;
}

/* Tablas */
.pm-page.pm-hist-page .pm-table {
  min-width: 920px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-table {
  min-width: 1040px !important;
}

.pm-page.pm-hist-page .pm-table th {
  padding: 8px !important;
  font-size: 7.8px !important;
  line-height: 1.1 !important;
}

.pm-page.pm-hist-page .pm-table td {
  padding: 8px !important;
  font-size: 9.6px !important;
  line-height: 1.2 !important;
}

.pm-page.pm-hist-page .pm-table td strong,
.pm-page.pm-hist-page .pm-hist-main {
  font-size: 10px !important;
  line-height: 1.15 !important;
}

.pm-page.pm-hist-page .pm-table td small {
  margin-top: 3px !important;
  font-size: 8px !important;
}

.pm-page.pm-hist-page .pm-table-actions {
  gap: 5px !important;
}

/* Badges */
.pm-page.pm-hist-page .pm-badge,
.pm-modal .pm-badge {
  min-height: 20px !important;
  padding: 0 8px !important;
  font-size: 8px !important;
}

/* Línea de tiempo */
.pm-page.pm-hist-page .pm-hist-events-panel {
  min-height: 360px !important;
}

.pm-page.pm-hist-page .pm-hist-timeline {
  gap: 8px !important;
  max-height: 560px !important;
  padding: 10px !important;
}

.pm-page.pm-hist-page .pm-hist-event {
  grid-template-columns: 32px minmax(0, 1fr) !important;
  gap: 9px !important;
  padding: 10px !important;
  border-radius: 14px !important;
}

.pm-page.pm-hist-page .pm-hist-event__icon {
  width: 32px !important;
  height: 32px !important;
  border-radius: 11px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body header {
  gap: 8px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body header span {
  margin-bottom: 3px !important;
  font-size: 7.8px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body header strong {
  font-size: 10.8px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body header small {
  margin-top: 3px !important;
  font-size: 8.4px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body time {
  font-size: 8.4px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body p {
  margin-top: 7px !important;
  font-size: 9px !important;
  line-height: 1.35 !important;
}

.pm-page.pm-hist-page .pm-hist-event__body footer {
  gap: 6px !important;
  margin-top: 8px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body footer span {
  padding: 4px 7px !important;
  font-size: 8.4px !important;
}

.pm-page.pm-hist-page .pm-hist-event__body footer .pm-btn {
  min-height: 28px !important;
  height: 28px !important;
  padding: 0 9px !important;
  font-size: 8.8px !important;
}

/* Empty states */
.pm-page.pm-hist-page .pm-hist-empty,
.pm-page.pm-hist-page .pm-hist-diff-empty {
  min-height: 180px !important;
  padding: 20px !important;
  gap: 7px !important;
}

.pm-page.pm-hist-page .pm-hist-empty .icon {
  width: 30px !important;
  height: 30px !important;
}

.pm-page.pm-hist-page .pm-hist-empty strong,
.pm-page.pm-hist-page .pm-hist-diff-empty strong {
  font-size: 13px !important;
}

.pm-page.pm-hist-page .pm-hist-empty span,
.pm-page.pm-hist-page .pm-hist-diff-empty span {
  font-size: 9.4px !important;
}

/* Mobile diferencias */
.pm-page.pm-hist-page .pm-hist-diff-mobile {
  padding: 10px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card {
  gap: 9px !important;
  padding: 10px !important;
  margin-bottom: 9px !important;
  border-radius: 14px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card header {
  gap: 8px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card header span,
.pm-page.pm-hist-page .pm-hist-diff-card header small {
  font-size: 8.4px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card header strong {
  margin: 3px 0 !important;
  font-size: 10.8px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__product {
  gap: 3px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__product strong {
  font-size: 10.4px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__product span {
  font-size: 8.8px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__grid {
  gap: 7px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__grid div {
  padding: 8px !important;
  border-radius: 11px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__grid span {
  margin-bottom: 3px !important;
  font-size: 7.6px !important;
}

.pm-page.pm-hist-page .pm-hist-diff-card__grid strong {
  font-size: 11px !important;
}

/* Modal */
.pm-page.pm-hist-page .pm-modal,
.pm-modal {
  padding: 14px !important;
}

.pm-page.pm-hist-page .pm-modal__card,
.pm-modal__card {
  width: min(980px, calc(100vw - 32px)) !important;
  max-height: calc(100vh - 32px) !important;
  border-radius: 16px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-modal,
.pm-hist-detail-modal {
  width: min(1040px, calc(100vw - 32px)) !important;
}

.pm-page.pm-hist-page .pm-modal__head,
.pm-modal__head {
  min-height: 54px !important;
  padding: 10px 12px !important;
  gap: 10px !important;
}

.pm-page.pm-hist-page .pm-modal__head span,
.pm-modal__head span {
  margin-bottom: 3px !important;
  font-size: 8px !important;
}

.pm-page.pm-hist-page .pm-modal__head strong,
.pm-modal__head strong {
  font-size: 14px !important;
}

.pm-page.pm-hist-page .pm-modal__head small,
.pm-modal__head small {
  margin-top: 3px !important;
  font-size: 8.8px !important;
}

.pm-page.pm-hist-page .pm-modal__body,
.pm-modal__body {
  gap: 10px !important;
  padding: 10px !important;
}

/* Detalle modal */
.pm-page.pm-hist-page .pm-hist-detail-grid {
  gap: 8px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-grid article {
  min-height: 48px !important;
  padding: 9px 10px !important;
  border-radius: 13px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-grid span {
  margin-bottom: 4px !important;
  font-size: 7.8px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-grid strong {
  font-size: 10.4px !important;
}

.pm-page.pm-hist-page .pm-hist-compare-grid {
  gap: 10px !important;
}

.pm-page.pm-hist-page .pm-hist-mini-table-wrap,
.pm-page.pm-hist-page .pm-hist-detail-table-wrap {
  max-height: 320px !important;
}

.pm-page.pm-hist-page .pm-hist-mini-table {
  min-width: 500px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-table {
  min-width: 920px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-events {
  gap: 8px !important;
  max-height: 280px !important;
  padding: 10px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-events article {
  grid-template-columns: 32px minmax(0, 1fr) !important;
  gap: 8px !important;
  padding: 9px !important;
  border-radius: 13px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-events strong {
  font-size: 10.4px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-events span,
.pm-page.pm-hist-page .pm-hist-detail-events small {
  margin-top: 3px !important;
  font-size: 8.4px !important;
}

/* Responsive */
@media (max-width: 760px) {
  .pm-page.pm-hist-page {
    gap: 9px !important;
  }

  .pm-page.pm-hist-page .pm-head,
  .pm-page.pm-hist-page .pm-panel,
  .pm-page.pm-hist-page .pm-card-metric {
    border-radius: 14px !important;
  }

  .pm-page.pm-hist-page .pm-brand__icon {
    width: 32px !important;
    height: 32px !important;
    flex-basis: 32px !important;
  }

  .pm-page.pm-hist-page .pm-brand h2 {
    font-size: 15px !important;
  }

  .pm-page.pm-hist-page .pm-brand p {
    font-size: 9.4px !important;
  }

  .pm-page.pm-hist-page .pm-card-metric strong {
    font-size: 16px !important;
  }

  .pm-page.pm-hist-page .pm-modal {
    padding: 8px !important;
  }

  .pm-page.pm-hist-page .pm-modal__card,
  .pm-page.pm-hist-page .pm-hist-detail-modal,
  .pm-modal__card,
  .pm-hist-detail-modal {
    width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 16px) !important;
    border-radius: 16px !important;
  }

  .pm-page.pm-hist-page .pm-modal__body {
    padding: 9px !important;
  }
}

@media (max-width: 520px) {
  .pm-page.pm-hist-page .pm-actions,
  .pm-page.pm-hist-page .pm-toolbar {
    align-items: stretch !important;
  }

  .pm-page.pm-hist-page .pm-btn {
    width: 100% !important;
  }

  .pm-page.pm-hist-page .pm-hist-tabs {
    grid-template-columns: 1fr !important;
  }

  .pm-page.pm-hist-page .pm-hist-tab {
    width: 100% !important;
  }

  .pm-page.pm-hist-page .pm-hist-event {
    grid-template-columns: 1fr !important;
  }

  .pm-page.pm-hist-page .pm-hist-event__body header {
    flex-direction: column !important;
  }
}/* =========================================================
   HISTORIAL · BOTONES E ICONOS VENTANA
   - Exportar CSV / Pedidos con letra negra
   - Iconos eventos centrados
   ========================================================= */

/* Botones activos en modo oscuro: fondo blanco + texto negro */
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-pm-hist],
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-detail-csv],
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab.is-active {
  background: #ffffff !important;
  border-color: #ffffff !important;
  color: #111111 !important;
}

/* Texto e iconos internos negros */
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-pm-hist] *,
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-detail-csv] *,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab.is-active *,
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-pm-hist] svg,
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-detail-csv] svg,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab.is-active svg {
  color: #111111 !important;
  stroke: #111111 !important;
}

/* Hover modo oscuro */
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-pm-hist]:hover,
html[data-theme="dark"] .pm-page.pm-hist-page [data-export-detail-csv]:hover,
html[data-theme="dark"] .pm-page.pm-hist-page .pm-hist-tab.is-active:hover {
  background: #e5e5e5 !important;
  border-color: #e5e5e5 !important;
  color: #111111 !important;
}

/* Modo claro: activo negro + letra blanca */
html[data-theme="light"] .pm-page.pm-hist-page [data-export-pm-hist],
html[data-theme="light"] .pm-page.pm-hist-page [data-export-detail-csv],
html[data-theme="light"] .pm-page.pm-hist-page .pm-hist-tab.is-active {
  background: #111111 !important;
  border-color: #111111 !important;
  color: #ffffff !important;
}

html[data-theme="light"] .pm-page.pm-hist-page [data-export-pm-hist] *,
html[data-theme="light"] .pm-page.pm-hist-page [data-export-detail-csv] *,
html[data-theme="light"] .pm-page.pm-hist-page .pm-hist-tab.is-active *,
html[data-theme="light"] .pm-page.pm-hist-page [data-export-pm-hist] svg,
html[data-theme="light"] .pm-page.pm-hist-page [data-export-detail-csv] svg,
html[data-theme="light"] .pm-page.pm-hist-page .pm-hist-tab.is-active svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

/* =========================================================
   EVENTOS · ICONOS CENTRADOS
   ========================================================= */

.pm-page.pm-hist-page .pm-hist-event__icon,
.pm-page.pm-hist-page .pm-hist-detail-events .pm-hist-event__icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;

  padding: 0 !important;
  line-height: 1 !important;
}

.pm-page.pm-hist-page .pm-hist-event__icon .icon,
.pm-page.pm-hist-page .pm-hist-event__icon svg,
.pm-page.pm-hist-page .pm-hist-detail-events .pm-hist-event__icon .icon,
.pm-page.pm-hist-page .pm-hist-detail-events .pm-hist-event__icon svg {
  display: block !important;

  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;

  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
}/* =========================================================
   HISTORIAL · MODAL NO CORTADO POR TOPBAR / FOOTER
   ========================================================= */

/* Overlay por encima de topbar/footer */
.pm-page.pm-hist-page .pm-modal,
.pm-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;

  display: none !important;
  align-items: center !important;
  justify-content: center !important;

  padding: 64px 16px 28px !important;
  background: rgba(0, 0, 0, 0.72) !important;

  overflow: hidden !important;
}

.pm-page.pm-hist-page .pm-modal.is-open,
.pm-modal.is-open {
  display: flex !important;
}

/* Card más baja y centrada */
.pm-page.pm-hist-page .pm-modal__card,
.pm-modal__card,
.pm-page.pm-hist-page .pm-hist-detail-modal,
.pm-hist-detail-modal {
  width: min(1040px, calc(100vw - 32px)) !important;
  height: min(760px, calc(100vh - 108px)) !important;
  max-height: calc(100vh - 108px) !important;

  display: flex !important;
  flex-direction: column !important;

  border-radius: 16px !important;
  overflow: hidden !important;
}

/* Header fijo dentro de la ventana */
.pm-page.pm-hist-page .pm-modal__head,
.pm-modal__head {
  flex: 0 0 auto !important;
  min-height: 54px !important;
  padding: 10px 12px !important;
}

/* Body scrolleable */
.pm-page.pm-hist-page .pm-modal__body,
.pm-modal__body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;

  overflow-y: auto !important;
  overflow-x: hidden !important;

  padding: 10px !important;
  scrollbar-width: thin !important;
}

/* Tablas internas con altura menor para que no empujen el modal */
.pm-page.pm-hist-page .pm-hist-mini-table-wrap,
.pm-page.pm-hist-page .pm-hist-detail-table-wrap {
  max-height: 220px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-events {
  max-height: 260px !important;
  overflow-y: auto !important;
}

/* Eventos más compactos dentro del modal */
.pm-page.pm-hist-page .pm-hist-detail-events article {
  min-height: 48px !important;
  padding: 8px 9px !important;
}

.pm-page.pm-hist-page .pm-hist-detail-events .pm-hist-event__icon {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
}

/* Mobile */
@media (max-width: 760px) {
  .pm-page.pm-hist-page .pm-modal,
  .pm-modal {
    padding: 56px 8px 14px !important;
  }

  .pm-page.pm-hist-page .pm-modal__card,
  .pm-modal__card,
  .pm-page.pm-hist-page .pm-hist-detail-modal,
  .pm-hist-detail-modal {
    width: calc(100vw - 16px) !important;
    height: calc(100vh - 70px) !important;
    max-height: calc(100vh - 70px) !important;
  }

  .pm-page.pm-hist-page .pm-modal__body,
  .pm-modal__body {
    padding: 9px !important;
  }
}