/* =========================================================
   WIRTZ HUB · EVENTOS · VENTAS
   Vista lista anual · Producto + 12 meses + total
   Limpio · compacto · responsive · dark safe · sin glow
   ========================================================= */

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

.sales-page {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  min-height: calc(100vh - var(--topbar-height) - 44px);
  animation: salesPageIn 0.18s ease both;
}

/* =========================================================
   BLOQUES BASE
   ========================================================= */

.sales-head,
.sales-metrics,
.sales-panel {
  border: 1px solid rgba(17, 24, 39, 0.11);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-solid) 98%, transparent);
  box-shadow: none;
  overflow: hidden;
  transition:
    background var(--transition),
    border-color var(--transition);
}

html[data-theme="dark"] .sales-head,
html[data-theme="dark"] .sales-metrics,
html[data-theme="dark"] .sales-panel {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(13, 13, 13, 0.96);
  box-shadow: none;
}

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

.sales-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
}

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

.sales-brand__icon {
  display: grid;
  width: 32px;
  height: 32px;
  min-width: 32px;
  place-items: center;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.055);
  color: #2563eb;
  box-shadow: none;
}

.sales-brand__icon .icon {
  width: 15px;
  height: 15px;
  stroke-width: 2.1;
}

.sales-brand h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 13.5px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.045em;
}

.sales-brand p {
  margin: 3px 0 0;
  max-width: 780px;
  color: var(--muted);
  font-size: 8.6px;
  font-weight: 740;
  line-height: 1.35;
}

.sales-actions,
.sales-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

html[data-theme="dark"] .sales-brand__icon {
  border-color: rgba(96, 165, 250, 0.2);
  background: rgba(96, 165, 250, 0.08);
  color: #60a5fa;
}

html[data-theme="dark"] .sales-brand h2 {
  color: rgba(255, 255, 255, 0.92);
}

html[data-theme="dark"] .sales-brand p {
  color: rgba(255, 255, 255, 0.5);
}

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

.sales-btn,
.sales-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text-strong);
  font-size: 8.3px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    opacity var(--transition);
}

.sales-btn:hover,
.sales-action:hover {
  border-color: rgba(17, 24, 39, 0.26);
  background: #f8fafc;
}

.sales-btn:active,
.sales-action:active {
  opacity: 0.82;
}

.sales-btn:focus-visible,
.sales-action:focus-visible {
  outline: 2px solid rgba(17, 24, 39, 0.16);
  outline-offset: 2px;
}

.sales-btn .icon,
.sales-action .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2.15;
}

.sales-btn--dark {
  border-color: rgba(17, 24, 39, 0.92);
  background: #111827;
  color: #ffffff;
}

.sales-btn--dark:hover {
  border-color: #111827;
  background: #1f2937;
}

html[data-theme="dark"] .sales-btn,
html[data-theme="dark"] .sales-action {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.045);
  color: #ffffff;
}

html[data-theme="dark"] .sales-btn:hover,
html[data-theme="dark"] .sales-action:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.075);
}

html[data-theme="dark"] .sales-btn--dark {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

html[data-theme="dark"] .sales-btn--dark:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.15);
}

/* =========================================================
   MÉTRICAS
   ========================================================= */

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

.sales-metric {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 54px;
  padding: 9px 10px;
  border-right: 1px solid rgba(17, 24, 39, 0.09);
  background: transparent;
  transition:
    background var(--transition),
    border-color var(--transition);
}

.sales-metric:last-child {
  border-right: 0;
}

.sales-metric:hover {
  background: rgba(15, 23, 42, 0.025);
}

.sales-metric span {
  min-width: 0;
  color: var(--muted);
  font-size: 7.3px;
  font-weight: 950;
  letter-spacing: 0.085em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-metric strong {
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.055em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-metric small {
  color: var(--muted-2);
  font-size: 7.3px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-metric:nth-child(1) strong {
  color: #2563eb;
}

.sales-metric:nth-child(2) strong {
  color: #15803d;
}

.sales-metric:nth-child(3) strong {
  color: #6d28d9;
}

.sales-metric:nth-child(4) strong {
  color: #b45309;
}

.sales-metric:nth-child(5) strong {
  color: #b91c1c;
}

.sales-metric:nth-child(6) strong {
  color: #0f766e;
}

html[data-theme="dark"] .sales-metric {
  border-right-color: rgba(255, 255, 255, 0.085);
}

html[data-theme="dark"] .sales-metric:hover {
  background: rgba(255, 255, 255, 0.045);
}

html[data-theme="dark"] .sales-metric span {
  color: rgba(255, 255, 255, 0.48);
}

html[data-theme="dark"] .sales-metric strong {
  color: rgba(255, 255, 255, 0.92);
}

html[data-theme="dark"] .sales-metric small {
  color: rgba(255, 255, 255, 0.38);
}

/* =========================================================
   PANEL
   ========================================================= */

.sales-panel {
  display: grid;
  min-width: 0;
}

.sales-toolbar {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.09);
}

.sales-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sales-title span {
  color: var(--muted);
  font-size: 7.2px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.sales-title strong {
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

html[data-theme="dark"] .sales-toolbar {
  border-bottom-color: rgba(255, 255, 255, 0.085);
}

html[data-theme="dark"] .sales-title span {
  color: rgba(255, 255, 255, 0.48);
}

html[data-theme="dark"] .sales-title strong {
  color: rgba(255, 255, 255, 0.92);
}

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

.sales-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(390px, 100%);
  min-width: 240px;
  height: 29px;
  padding: 0 8px;
  border: 1px solid rgba(17, 24, 39, 0.13);
  border-radius: 9px;
  background: #ffffff;
  color: var(--muted);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.sales-search:focus-within {
  border-color: rgba(17, 24, 39, 0.32);
  background: #ffffff;
}

.sales-search .icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  stroke-width: 2.15;
  color: #2563eb;
}

.sales-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  outline: none;
  font-size: 8.8px;
  font-weight: 760;
}

.sales-search input::placeholder {
  color: var(--muted-2);
}

.sales-filters select {
  height: 29px;
  min-width: 104px;
  padding: 0 8px;
  border: 1px solid rgba(17, 24, 39, 0.13);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text-strong);
  outline: none;
  font-size: 8.3px;
  font-weight: 850;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.sales-filters select:hover,
.sales-filters select:focus {
  border-color: rgba(17, 24, 39, 0.28);
  background: #ffffff;
}

html[data-theme="dark"] .sales-search {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.48);
}

html[data-theme="dark"] .sales-search:focus-within {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.065);
}

html[data-theme="dark"] .sales-search .icon {
  color: #60a5fa;
}

html[data-theme="dark"] .sales-search input {
  color: rgba(255, 255, 255, 0.9);
}

html[data-theme="dark"] .sales-search input::placeholder {
  color: rgba(255, 255, 255, 0.34);
}

html[data-theme="dark"] .sales-filters select {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.88);
}

html[data-theme="dark"] .sales-filters select:hover,
html[data-theme="dark"] .sales-filters select:focus {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.065);
}

/* =========================================================
   LISTA ANUAL
   ========================================================= */

.sales-board {
  display: block;
  min-width: 0;
  padding: 8px;
  overflow-x: auto;
  overflow-y: hidden;
}

.sales-list {
  display: grid;
  min-width: 980px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 13px;
  background: #ffffff;
  overflow: hidden;
}

.sales-list-header,
.sales-list-row {
  display: grid;
  grid-template-columns:
    minmax(260px, 1.7fr)
    repeat(12, minmax(48px, 0.32fr))
    minmax(62px, 0.42fr);
  min-width: 0;
}

.sales-list-header {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 34px;
  background: #f8fafc;
  border-bottom: 1px solid rgba(17, 24, 39, 0.1);
}

.sales-list-body {
  display: grid;
  min-width: 0;
}

.sales-list-row {
  min-height: 42px;
  background: #ffffff;
  border-bottom: 1px solid rgba(17, 24, 39, 0.075);
  transition: background var(--transition);
}

.sales-list-row:last-child {
  border-bottom: 0;
}

.sales-list-row:hover {
  background: #f9fafb;
}

.sales-list-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: inherit;
  padding: 6px 7px;
  border-right: 1px solid rgba(17, 24, 39, 0.065);
  color: var(--text-strong);
  font-size: 8px;
  font-weight: 850;
  line-height: 1;
}

.sales-list-cell:last-child {
  border-right: 0;
}

.sales-list-cell--product {
  justify-content: flex-start;
  text-align: left;
}

.sales-list-cell--month,
.sales-list-cell--number,
.sales-list-cell--total {
  justify-content: center;
  text-align: center;
}

.sales-list-cell--month,
.sales-list-cell--total {
  color: var(--muted);
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.sales-list-cell--number {
  color: var(--text-strong);
  font-size: 8.2px;
  font-weight: 900;
}

.sales-list-cell--total {
  color: #111827;
  background: rgba(15, 23, 42, 0.025);
}

.sales-list-row .sales-list-cell--total {
  color: #111827;
  font-size: 8.4px;
  font-weight: 950;
  letter-spacing: -0.01em;
  background: rgba(15, 23, 42, 0.025);
}

.sales-list-product {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sales-list-product strong {
  display: block;
  min-width: 0;
  color: var(--text-strong);
  font-size: 8.9px;
  font-weight: 950;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sales-list-product span {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 7px;
  font-weight: 740;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   LISTA ANUAL · DARK
   ========================================================= */

html[data-theme="dark"] .sales-list {
  border-color: rgba(255, 255, 255, 0.095);
  background: rgba(255, 255, 255, 0.025);
}

html[data-theme="dark"] .sales-list-header {
  background: rgba(255, 255, 255, 0.055);
  border-bottom-color: rgba(255, 255, 255, 0.095);
}

html[data-theme="dark"] .sales-list-row {
  background: rgba(255, 255, 255, 0.025);
  border-bottom-color: rgba(255, 255, 255, 0.075);
}

html[data-theme="dark"] .sales-list-row:hover {
  background: rgba(255, 255, 255, 0.045);
}

html[data-theme="dark"] .sales-list-cell {
  border-right-color: rgba(255, 255, 255, 0.065);
  color: rgba(255, 255, 255, 0.88);
}

html[data-theme="dark"] .sales-list-cell--month,
html[data-theme="dark"] .sales-list-cell--total {
  color: rgba(255, 255, 255, 0.48);
}

html[data-theme="dark"] .sales-list-cell--number {
  color: rgba(255, 255, 255, 0.9);
}

html[data-theme="dark"] .sales-list-row .sales-list-cell--total,
html[data-theme="dark"] .sales-list-cell--total {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .sales-list-product strong {
  color: rgba(255, 255, 255, 0.92);
}

html[data-theme="dark"] .sales-list-product span {
  color: rgba(255, 255, 255, 0.45);
}

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

.sales-empty {
  display: grid;
  place-items: center;
  min-height: 90px;
  padding: 14px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  text-align: center;
}

/* =========================================================
   TOAST
   ========================================================= */

.sales-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99999;
  max-width: min(360px, calc(100vw - 36px));
  padding: 9px 11px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel-solid) 98%, transparent);
  color: var(--text-strong);
  box-shadow: none;
  font-size: 8.7px;
  font-weight: 900;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity var(--transition),
    transform var(--transition);
}

.sales-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

html[data-theme="dark"] .sales-toast {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(12, 12, 12, 0.96);
  color: rgba(255, 255, 255, 0.9);
}

/* =========================================================
   LIMPIEZA DE BLOQUES VIEJOS
   ========================================================= */

.sales-insight,
.sales-ranking,
.sales-product-row,
.sales-product-info,
.sales-product-title,
.sales-product-kpis,
.sales-product-kpi,
.sales-months-panel,
.sales-months-head,
.sales-months-grid,
.sales-month-chip,
.sales-provider,
.sales-sku,
.sales-trend,
.sales-stock-pill,
.sales-image-flag {
  box-shadow: none;
}

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

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

  .sales-metric:nth-child(3n) {
    border-right: 0;
  }

  .sales-metric:nth-child(n + 4) {
    border-top: 1px solid rgba(17, 24, 39, 0.09);
  }

  html[data-theme="dark"] .sales-metric:nth-child(n + 4) {
    border-top-color: rgba(255, 255, 255, 0.085);
  }
}

@media (max-width: 980px) {
  .sales-page {
    gap: 7px;
    min-height: auto;
  }

  .sales-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .sales-actions {
    justify-content: flex-start;
  }

  .sales-toolbar {
    grid-template-columns: 1fr;
  }

  .sales-filters {
    justify-content: flex-start;
  }
}

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

  .sales-metric {
    border-right: 1px solid rgba(17, 24, 39, 0.09);
  }

  .sales-metric:nth-child(2n) {
    border-right: 0;
  }

  .sales-metric:nth-child(n + 3) {
    border-top: 1px solid rgba(17, 24, 39, 0.09);
  }

  html[data-theme="dark"] .sales-metric {
    border-right-color: rgba(255, 255, 255, 0.085);
  }

  html[data-theme="dark"] .sales-metric:nth-child(n + 3) {
    border-top-color: rgba(255, 255, 255, 0.085);
  }
}

@media (max-width: 620px) {
  .sales-head,
  .sales-panel,
  .sales-metrics {
    border-radius: 15px;
  }

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

  .sales-actions,
  .sales-filters {
    width: 100%;
  }

  .sales-btn,
  .sales-action,
  .sales-filters select,
  .sales-search {
    width: 100%;
  }

  .sales-search {
    min-width: 0;
  }

  .sales-board {
    padding: 7px;
  }

  .sales-list {
    min-width: 900px;
  }

  .sales-list-header,
  .sales-list-row {
    grid-template-columns:
      minmax(220px, 1.7fr)
      repeat(12, minmax(44px, 0.32fr))
      minmax(58px, 0.42fr);
  }
}

@media (max-width: 420px) {
  .sales-metrics {
    grid-template-columns: 1fr;
  }

  .sales-metric {
    border-right: 0;
    border-top: 1px solid rgba(17, 24, 39, 0.09);
  }

  .sales-metric:first-child {
    border-top: 0;
  }

  html[data-theme="dark"] .sales-metric {
    border-top-color: rgba(255, 255, 255, 0.085);
  }
}

/* =========================================================
   ANIMACIÓN
   ========================================================= */

@keyframes salesPageIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .sales-page,
  .sales-page *,
  .sales-page *::before,
  .sales-page *::after {
    animation: none !important;
    transition: none !important;
  }
}