:root {
  --bg: #0f1115;
  --surface: #171a21;
  --border: #282d38;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(229, 231, 235, 0.05), transparent 28rem),
    var(--bg);
  color: var(--text);
  padding: 24px;
  max-width: 1120px;
  margin-inline: auto;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.75rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.repair-shortcut {
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.repair-shortcut:hover {
  text-decoration: underline;
}

.subtitle,
.status {
  color: var(--muted);
  margin: 4px 0 0;
}

.subtitle {
  max-width: 640px;
  line-height: 1.5;
}

#search-input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 240px;
}

.cart-button,
.primary-button {
  background: #e5e7eb;
  color: #101219;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.cart-button:hover,
.primary-button:not(:disabled):hover {
  background: #fff;
  transform: translateY(-1px);
}

.cart-count {
  display: inline-grid;
  min-width: 1.5em;
  height: 1.5em;
  margin-left: 4px;
  place-items: center;
  border-radius: 999px;
  background: #171a21;
  color: var(--text);
  font-size: 0.8em;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.brand-filters {
  margin-top: -8px;
}

.filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 0 0 20px;
}

.filter-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.85rem;
}

.filter-controls input,
.filter-controls select {
  min-height: 40px;
  min-width: 120px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.chip {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.repair-section {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.repair-heading h2 {
  margin: 0;
}

.repair-heading p,
.repair-card p {
  color: var(--muted);
}

.repair-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.repair-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.repair-card h3 {
  margin: 0;
  font-size: 1rem;
}

.repair-card p {
  flex: 1;
  line-height: 1.45;
}

.repair-button {
  margin-top: auto;
  padding: 9px 12px;
  color: var(--text);
  background: #232733;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.repair-button:hover {
  background: #303544;
}

.card {
  min-width: 0;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: card-enter 420ms both;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  border-color: #3d4452;
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.card-media {
  aspect-ratio: 16 / 10;
  background: #101219;
  border-bottom: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}

.card:hover .card-media img {
  transform: scale(1.045);
}

.card-media-fallback {
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 700;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent),
    #101219;
}

.card-body {
  min-height: 210px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

.release-date {
  color: var(--muted);
  font-size: 0.8rem;
}

.card h2 {
  margin: 4px 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.card-summary {
  min-height: 2.8em;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.card-footer {
  margin-top: auto;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.price {
  font-size: 1.15rem;
  font-weight: 700;
}

.stock {
  font-size: 0.85rem;
  color: #86efac;
  text-align: right;
}

.stock.out-of-stock {
  color: #fca5a5;
}

.grid[aria-busy="true"] {
  opacity: 0.6;
}

.card:focus-visible,
button:focus-visible {
  outline: 2px solid #c4b5fd;
  outline-offset: 3px;
}

.card-add-button {
  width: 100%;
  margin-top: 8px;
}

.modal {
  position: fixed;
  width: min(860px, calc(100% - 32px));
  max-width: none;
  max-height: min(88vh, 900px);
  padding: 28px;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.modal::backdrop {
  background: rgba(3, 5, 10, 0.76);
  backdrop-filter: blur(4px);
}

.modal-close {
  position: sticky;
  z-index: 1;
  top: 0;
  float: right;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin: -12px -12px 8px 8px;
  color: var(--text);
  background: #232733;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1fr);
  gap: 28px;
  clear: both;
}

.detail-media {
  min-height: 280px;
  overflow: hidden;
  align-self: start;
  background: #101219;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.detail-media img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.detail-info h2 {
  margin: 4px 0 12px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.15;
}

.detail-eyebrow,
.detail-summary,
.checkout-note,
.empty-cart {
  color: var(--muted);
}

.detail-eyebrow {
  margin: 4px 0;
  font-size: 0.9rem;
}

.detail-summary {
  line-height: 1.6;
}

.detail-price {
  margin: 18px 0 4px;
  font-size: 1.5rem;
  font-weight: 750;
}

.detail-stock {
  margin: 4px 0 20px;
  color: #86efac;
}

.detail-stock.out-of-stock {
  color: #fca5a5;
}

.detail-info h3 {
  margin: 24px 0 8px;
}

.spec-list {
  margin: 0 0 22px;
  border-top: 1px solid var(--border);
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row dt {
  color: var(--muted);
}

.detail-row dd {
  margin: 0;
  text-align: right;
}

.cart-modal {
  width: min(640px, calc(100% - 32px));
}

.cart-modal h2 {
  margin-top: 4px;
}

.cart-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.cart-line > div:first-child {
  display: grid;
  gap: 5px;
}

.cart-line-price {
  color: var(--muted);
  font-size: 0.9rem;
}

.cart-line-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-line-actions button {
  min-width: 32px;
  min-height: 32px;
  color: var(--text);
  background: #232733;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}

.cart-line-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.cart-line-actions .remove-line {
  padding: 4px 8px;
  color: #fca5a5;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  font-size: 1.2rem;
}

.checkout-note {
  line-height: 1.45;
}

.whatsapp-button {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  color: #062b15;
  background: #25d366;
  border: 1px solid #25d366;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.whatsapp-button:hover {
  background: #4be582;
}

.whatsapp-button:focus-visible {
  outline: 2px solid #c4b5fd;
  outline-offset: 3px;
}

.empty-cart[hidden] {
  display: none;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 560px) {
  body {
    padding: 16px;
  }

  .topbar,
  .controls {
    width: 100%;
  }

  #search-input {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .detail-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .detail-media {
    min-height: 180px;
  }

  .modal {
    padding: 20px;
  }

  .cart-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}