/* TABLERO DE VENTAS */
.sales-dashboard-view .panel {
  background: #f4f6fb !important;
}
.sales-dashboard-view .panel-header {
  background: #ffffff !important;
  border-bottom: 1px solid #dfe5ef !important;
}
.sales-dashboard-view #tableWrap.table-wrap {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 14px 18px 22px !important;
  background: #f4f6fb !important;
}
.sales-dashboard {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  color: #0f172a;
}
.sales-dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #dfe5ef;
}
.sales-dashboard-toolbar > div:first-child {
  display: grid;
  gap: 3px;
}
.sales-dashboard-kicker,
.sales-card-head span,
.sales-summary-card > span {
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}
.sales-dashboard-toolbar strong {
  font-size: 16px;
}
.sales-dashboard-selects {
  display: flex;
  gap: 8px;
}
.sales-dashboard-selects label {
  display: grid;
  gap: 3px;
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}
.sales-dashboard-selects select {
  min-width: 130px;
  height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 0;
  background: #fff;
  color: #0f172a;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 800;
}
.sales-chart-open-btn {
  align-self: end;
  height: 34px;
  min-width: 112px;
  border: 0;
  border-radius: 0;
  background: #1d4ed8;
  color: #fff;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .05em;
  cursor: pointer;
}
.sales-chart-open-btn:hover {
  background: #163fb7;
}
.sales-dashboard-chart-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(15, 23, 42, .6);
}
.sales-dashboard-chart-modal.open {
  display: flex;
}
.sales-dashboard-chart-card {
  width: min(1260px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 16px 18px 18px;
  background: #fff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .3);
}
.sales-dashboard-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}
.sales-dashboard-chart-head > div:first-child {
  display: grid;
  gap: 4px;
}
.sales-dashboard-chart-head span {
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}
.sales-dashboard-chart-head strong {
  font-size: 18px;
}
.sales-dashboard-chart-head > div:last-child {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sales-dashboard-chart-head b {
  color: #1d4ed8;
  font-size: 16px;
  white-space: nowrap;
}
.sales-dashboard-chart-head button {
  height: 32px;
  border: 0;
  border-radius: 0;
  background: #0f172a;
  color: #fff;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}
.sales-dashboard-chart-card .sales-history-chart {
  height: 320px;
  grid-template-columns: repeat(12, minmax(54px, 1fr));
}
.sales-dashboard-chart-card .sales-history-item {
  height: 286px;
}
.sales-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.sales-summary-card,
.sales-dashboard-card {
  background: #ffffff;
  border: 1px solid #dfe5ef;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
}
.sales-summary-card {
  min-height: 112px;
  padding: 16px 17px;
  display: grid;
  align-content: center;
  gap: 6px;
}
.sales-summary-card.primary {
  background: linear-gradient(135deg, #0f2f72 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #ffffff;
}
.sales-summary-card.primary > span,
.sales-summary-card.primary small {
  color: rgba(255,255,255,.72);
}
.sales-summary-card strong {
  font-size: clamp(23px, 2.2vw, 34px);
  line-height: 1;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.sales-summary-card small {
  color: #64748b;
  font-size: 11px;
}
.sales-summary-card.documents strong {
  font-size: 32px;
}
.sales-variation.positive { color: #15803d; }
.sales-variation.negative { color: #b91c1c; }
.sales-variation.neutral { color: #64748b; }
.sales-dashboard-card {
  padding: 15px 16px 14px;
}
.sales-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.sales-card-head > div {
  display: grid;
  gap: 4px;
}
.sales-card-head strong {
  font-size: 15px;
}
.sales-card-head > b {
  color: #1d4ed8;
  font-size: 16px;
  white-space: nowrap;
}
.sales-history-card {
  margin-bottom: 12px;
}
.sales-history-chart {
  height: 205px;
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  gap: 8px;
  align-items: end;
  padding: 8px 3px 0;
  border-top: 1px solid #edf1f6;
}
.sales-history-item {
  height: 174px;
  display: grid;
  grid-template-rows: 22px 1fr 20px;
  gap: 4px;
  min-width: 0;
}
.sales-history-value {
  overflow: hidden;
  color: #475569;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-history-track {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: linear-gradient(to top, rgba(226,232,240,.48) 1px, transparent 1px);
  background-size: 100% 25%;
  border-bottom: 1px solid #cbd5e1;
}
.sales-history-bar {
  width: min(32px, 72%);
  min-height: 3px;
  background: #94a3b8;
  transition: height .2s ease;
}
.sales-history-item.selected .sales-history-bar {
  background: #1d4ed8;
}
.sales-history-item.negative .sales-history-bar {
  background: #dc2626;
}
.sales-history-label {
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}
.sales-history-item.selected .sales-history-label {
  color: #1d4ed8;
}
.sales-dashboard-bottom {
  display: grid;
  grid-template-columns: minmax(380px, .9fr) minmax(540px, 1.45fr);
  gap: 12px;
  align-items: start;
}
.sales-ranking-list {
  display: grid;
  gap: 0;
}
.sales-ranking-row {
  min-height: 30px;
  display: grid;
  grid-template-columns: 28px minmax(150px, 1fr) 58px 115px;
  gap: 7px;
  align-items: center;
  border-top: 1px solid #edf1f6;
}
.sales-ranking-position {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}
.sales-ranking-main {
  min-width: 0;
}
.sales-ranking-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-ranking-track {
  height: 3px;
  margin-top: 2px;
  overflow: hidden;
  background: #e9eef6;
}
.sales-ranking-track span {
  display: block;
  height: 100%;
  background: #3b82f6;
}
.sales-ranking-share {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  text-align: right;
}
.sales-ranking-total {
  font-size: 12px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}
.sales-products-table-wrap {
  overflow: auto;
  max-height: 355px;
  border-top: 1px solid #edf1f6;
}
.sales-products-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}
.sales-products-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 3 !important;
  padding: 8px 7px !important;
  background: #f8fafc !important;
  color: #475569 !important;
  border-bottom: 1px solid #dfe5ef;
  font-size: 9px !important;
  text-align: left !important;
}
.sales-products-table td {
  height: 32px !important;
  padding: 6px 7px !important;
  border-bottom: 1px solid #edf1f6;
  color: #0f172a;
  font-size: 11px !important;
  white-space: nowrap;
}
.sales-product-rank {
  width: 28px;
  color: #94a3b8 !important;
  font-weight: 900;
  text-align: center;
}
.sales-product-sku {
  width: 88px;
  font-weight: 900;
}
.sales-product-name {
  max-width: 310px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sales-product-qty,
.sales-product-total {
  text-align: right;
}
.sales-product-total {
  font-weight: 900;
}
.sales-list-empty,
.sales-dashboard-empty {
  padding: 28px 12px !important;
  color: #64748b !important;
  font-size: 12px !important;
  text-align: center !important;
}
@media (max-width: 1100px) {
  .sales-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-dashboard-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sales-dashboard-view #tableWrap.table-wrap { padding: 10px !important; }
  .sales-dashboard-toolbar { align-items: stretch; flex-direction: column; }
  .sales-dashboard-selects { width: 100%; }
  .sales-dashboard-selects label { flex: 1; }
  .sales-dashboard-selects select { width: 100%; min-width: 0; }
  .sales-chart-open-btn { min-width: 96px; padding: 0 10px; }
  .sales-dashboard-chart-modal { padding: 8px; }
  .sales-dashboard-chart-card { width: 100%; padding: 12px; }
  .sales-dashboard-chart-head { flex-direction: column; }
  .sales-dashboard-chart-card .sales-history-chart { overflow-x: auto; grid-template-columns: repeat(12, 58px); }
  .sales-summary-grid { grid-template-columns: 1fr; }
  .sales-history-chart { overflow-x: auto; grid-template-columns: repeat(12, 58px); }
  .sales-ranking-row { grid-template-columns: 24px minmax(120px, 1fr) 48px 100px; }
}




/* Detalle de vendedor dentro de la misma ventana */
.sales-dashboard-view.sales-seller-detail-active #tableWrap.table-wrap {
  padding: 0 !important;
  overflow: hidden !important;
}
.sales-seller-inline {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #f3f6fb;
}
.sales-seller-inline iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #f3f6fb;
}

/* Vendedores clicables: abre histórico y detalle */
.sales-seller-button {
  width: 100%;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-top: 1px solid #edf1f6;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.sales-seller-button:hover {
  background: #f5f8ff;
  transform: translateX(2px);
}
.sales-seller-button:hover .sales-ranking-name {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sales-seller-button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  background: #eff6ff;
}

/* Corrección del encabezado en Ventas por grupo de artículos */
.sales-dashboard-view #tableWrap .sales-products-table-wrap {
  position: relative !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
}
.sales-dashboard-view #tableWrap .sales-products-table thead,
.sales-dashboard-view #tableWrap .sales-products-table thead tr {
  position: static !important;
  top: auto !important;
  transform: none !important;
}
.sales-dashboard-view #tableWrap .sales-products-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background: #0b1220 !important;
  color: #ffffff !important;
  box-shadow: 0 1px 0 #ffffff, 0 2px 0 #0b1220 !important;
}

/* Ajuste de vista de ventas: periodos, comparativo por vendedor y grupos compactos */
.sales-current-period-card {
  border: 1px solid #1d4ed8;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.sales-current-period-card:hover { filter: brightness(1.04); }
.sales-ranking-columns {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 112px 112px 68px;
  gap: 8px;
  padding: 0 8px 5px 32px;
  color: #64748b;
  font-size: 9px;
  font-weight: 900;
  text-align: right;
}
.sales-ranking-columns span:first-child { text-align: left; }
.sales-ranking-row {
  grid-template-columns: 24px minmax(140px, 1fr) 112px 112px 68px !important;
  min-height: 30px !important;
  padding: 3px 8px !important;
  gap: 8px !important;
}
.sales-ranking-name { font-size: 11px !important; }
.sales-ranking-track { margin-top: 2px !important; height: 3px !important; }
.sales-ranking-current,
.sales-ranking-previous,
.sales-ranking-comparison {
  text-align: right;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 900;
}
.sales-ranking-comparison.positive { color: #15803d; }
.sales-ranking-comparison.negative { color: #b91c1c; }
.sales-ranking-comparison.neutral { color: #64748b; }
.sales-products-table-wrap {
  overflow-x: hidden !important;
}
.sales-products-table {
  table-layout: fixed !important;
  min-width: 0 !important;
}
.sales-products-table th:nth-child(1),
.sales-products-table td:nth-child(1) { width: 42px; }
.sales-products-table th:nth-child(3),
.sales-products-table td:nth-child(3) { width: 150px; text-align: right !important; }
.sales-products-table td {
  height: 26px !important;
  padding: 3px 7px !important;
}
.sales-product-name { max-width: none !important; }
@media (max-width: 1100px) {
  .sales-ranking-columns { grid-template-columns: minmax(130px, 1fr) 100px 100px 62px; }
  .sales-ranking-row { grid-template-columns: 22px minmax(130px, 1fr) 100px 100px 62px !important; }
}

/* Distribución solicitada: vendedores 60% y grupos de artículos 40% */
.sales-dashboard-bottom {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) !important;
}
.sales-dashboard-bottom > .sales-dashboard-card {
  min-width: 0;
}
@media (max-width: 1100px) {
  .sales-dashboard-bottom {
    grid-template-columns: 1fr !important;
  }
}
