.hpe-substitutes-section {
  border-top: 1px solid #e5e7eb;
  padding: 2.5rem 0;
}

.hpe-substitutes-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hpe-substitutes-header > div:first-child {
  min-width: 0;
}

.hpe-substitutes-section h2 {
  margin: 0 0 1rem;
  color: #111827;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.75rem;
  line-height: 1.15;
}

.hpe-substitutes-intro {
  margin: .75rem 0 0;
  color: #4b5563;
  font-size: .875rem;
  line-height: 1.6;
}

.hpe-substitutes-controls {
  display: flex;
  flex-shrink: 0;
  gap: .5rem;
}

.hpe-substitutes-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid #d1d5db;
  border-radius: .25rem;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.hpe-substitutes-controls button:hover:not(:disabled) {
  border-color: #dc143c;
  color: #a30d2b;
}

.hpe-substitutes-controls button:disabled {
  opacity: .4;
  cursor: default;
}

.hpe-substitutes-controls svg {
  width: 1.25rem;
  height: 1.25rem;
}

.hpe-substitutes-viewport {
  margin: 1.25rem -.25rem -.25rem;
  padding: .25rem .25rem .75rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: .25rem;
  scrollbar-width: thin;
  scrollbar-color: #9ca3af #f3f4f6;
}

.hpe-substitutes-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3rem) / 4);
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hpe-substitutes-list > li {
  display: flex;
  min-width: 0;
  scroll-snap-align: start;
}

.hpe-substitute-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  background: #fff;
  overflow-wrap: anywhere;
}

.hpe-substitute-card:hover {
  border-color: #dc143c;
}

.hpe-substitute-card-image {
  aspect-ratio: 1;
  background: #f9fafb;
  margin-bottom: .75rem;
  overflow: hidden;
}

.hpe-substitute-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hpe-substitute-part-number {
  color: #4b5563;
  font-family: monospace;
}

.hpe-substitute-card h3 {
  margin: .5rem 0;
  color: #111827;
  font-size: .875rem;
  font-weight: 600;
}

.hpe-substitute-brand {
  color: #4b5563;
  font-size: .8125rem;
  line-height: 1.5;
}

.hpe-substitute-price {
  margin-top: auto;
  padding-top: .75rem;
  color: #a30d2b;
  font-size: .875rem;
  font-weight: 600;
}

.hpe-substitutes-status {
  margin: 1rem 0;
  color: #4b5563;
  font-size: .875rem;
  line-height: 1.6;
}

.hpe-substitutes-status button {
  color: #a30d2b;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hpe-substitutes-status button:disabled {
  opacity: .6;
}

.hpe-substitutes-section :is(a, button, [tabindex]):focus-visible {
  outline: 2px solid #dc143c;
  outline-offset: 2px;
}

.hpe-substitutes-instructions {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .hpe-substitutes-list {
    grid-auto-columns: calc((100% - 1rem) / 2);
  }
}

@media (max-width: 540px) {
  .hpe-substitutes-header {
    flex-wrap: wrap;
  }

  .hpe-substitutes-list {
    grid-auto-columns: 82%;
  }

  .hpe-substitute-card {
    padding: .75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hpe-substitutes-viewport {
    scroll-behavior: auto;
  }
}
