* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.topbar {
  background: #ffffff;
  color: #1f2937;
  padding: 10px 16px 12px;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 8px;
  max-width: 960px;
  margin: 0 auto;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  max-height: 56px;
  width: auto;
  max-width: min(72vw, 320px);
  height: auto;
  object-fit: contain;
}

.tagline {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
  color: #4b5563;
  letter-spacing: 0.01em;
}

@media (max-width: 520px) {
  .brand-logo {
    max-height: 44px;
  }
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.tabs {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  /* Reset global <button> styles — tabs must not inherit Search button blue/white */
  appearance: none;
  -webkit-appearance: none;
  color: #111827;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    color 0.15s ease;
}

.tab.tab--text {
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Icon tabs: no fill/box so PNG transparency shows the page background (#f3f4f6) */
.tab.tab--icon {
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  height: auto;
  background: transparent;
  border: none;
}

.tab.tab--icon .tab-image {
  display: block;
  max-height: 38px;
  width: auto;
  max-width: min(44vw, 175px);
  object-fit: contain;
  opacity: 1;
  pointer-events: none;
}

/* Slot 1 All — orange when selected */
.tabs > .tab:nth-child(1).tab--text.active {
  background: #ea580c;
  color: #fff;
  border-color: #c2410c;
}

.tabs > .tab:nth-child(1).tab--text:hover:not(.active) {
  border-color: #fb923c;
  background: #fff7ed;
  color: #c2410c;
}

.tabs > .tab:nth-child(1).tab--text.active:hover {
  background: #f97316;
  border-color: #ea580c;
  color: #fff;
}

/* Slots 2–5: blue / orange / blue / orange — hover + selected use same hues */
.tabs > .tab:nth-child(2).tab--icon:hover:not(.active),
.tabs > .tab:nth-child(2).tab--icon.active {
  background: rgba(37, 99, 235, 0.1);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.75);
}

.tabs > .tab:nth-child(2).tab--icon.active:hover {
  background: rgba(37, 99, 235, 0.16);
  box-shadow: 0 0 0 2px #2563eb;
}

.tabs > .tab:nth-child(3).tab--icon:hover:not(.active),
.tabs > .tab:nth-child(3).tab--icon.active {
  background: rgba(234, 88, 12, 0.1);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.75);
}

.tabs > .tab:nth-child(3).tab--icon.active:hover {
  background: rgba(234, 88, 12, 0.16);
  box-shadow: 0 0 0 2px #ea580c;
}

.tabs > .tab:nth-child(4).tab--icon:hover:not(.active),
.tabs > .tab:nth-child(4).tab--icon.active {
  background: rgba(37, 99, 235, 0.1);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.75);
}

.tabs > .tab:nth-child(4).tab--icon.active:hover {
  background: rgba(37, 99, 235, 0.16);
  box-shadow: 0 0 0 2px #2563eb;
}

.tabs > .tab:nth-child(5).tab--icon:hover:not(.active),
.tabs > .tab:nth-child(5).tab--icon.active {
  background: rgba(234, 88, 12, 0.1);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.75);
}

.tabs > .tab:nth-child(5).tab--icon.active:hover {
  background: rgba(234, 88, 12, 0.16);
  box-shadow: 0 0 0 2px #ea580c;
}

@media (max-width: 640px) {
  .tabs {
    gap: 10px;
  }

  .tab.tab--icon {
    min-height: 44px;
    padding: 6px 8px;
  }

  .tab.tab--icon .tab-image {
    max-height: 32px;
    max-width: min(36vw, 140px);
  }
}

.search-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
}

#searchForm {
  display: grid;
  grid-template-columns: 1fr 150px 130px minmax(200px, 1fr) 120px;
  gap: 8px;
  align-items: center;
}

#searchForm .exclude-row {
  grid-column: 1 / -1;
}

#searchForm .strict-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

#searchForm .strict-row input {
  width: auto;
  height: auto;
  margin: 0;
  cursor: pointer;
}

#searchForm .strict-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: #6b7280;
}

.search-hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: #4b5563;
}

.link-button {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font: inherit;
}

.link-button:hover {
  color: #1d4ed8;
}

input,
select {
  height: 38px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 0 10px;
}

/* Only the search form submit — not .tabs buttons (fixes tab images / “empty” blue pills) */
#searchForm button[type="submit"] {
  height: 38px;
  border-radius: 8px;
  border: none;
  padding: 0 10px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  margin: 14px 2px;
  font-size: 14px;
  color: #374151;
}

.results {
  display: grid;
  gap: 10px;
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

/* Alternate result cards with a strict blue/orange rhythm. */
.results > .card:nth-child(odd) {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.results > .card:nth-child(even) {
  background: #fff7ed;
  border-color: #fed7aa;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.card-top h3 {
  margin: 0;
  font-size: 17px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 12px;
  padding: 3px 8px;
  text-transform: capitalize;
}

.pill--live {
  background: #fef3c7;
  color: #92400e;
  text-transform: none;
}

.retailer,
.parts,
.meta,
.price {
  margin: 8px 0;
}

.empty {
  text-align: center;
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 22px;
}

.search-shell.is-hidden,
.detail-shell.is-hidden {
  display: none;
}

.detail-shell {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
}

.back-to-search {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #1f2937;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 14px;
}

.back-to-search:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.detail-content h1 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.detail-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-meta {
  margin: 10px 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
}

.detail-meta dl {
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.detail-meta dt {
  margin: 0;
  color: #6b7280;
}

.detail-meta dd {
  margin: 0;
}

.detail-extras {
  margin-top: 8px;
}

.detail-extras dl {
  margin: 0;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
}

.detail-actions .deal-link {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.detail-actions .deal-link:hover {
  background: #1d4ed8;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.card-actions .item-detail-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}

.card-actions .item-detail-link:hover {
  text-decoration: underline;
}

@media (max-width: 760px) {
  #searchForm {
    grid-template-columns: 1fr;
  }
}
