/* ============================================================
   Part Codes — garagiste UI
   Palette: graphite #11151c · neutral #f5f6f8 · amber #f0a020
   Signature: part references & prices set in monospace, like the
   numbers stamped on the part itself. Calm cards, one warm accent.
   ============================================================ */

:root {
  --ink:        #11151c;   /* near-black header / primary text  */
  --ink-soft:   #3a424e;
  --muted:      #6b7480;
  --line:       #e2e5ea;
  --line-soft:  #eef0f3;
  --bg:         #f5f6f8;
  --surface:    #ffffff;
  --surface-2:  #fafbfc;

  --amber:      #f0a020;   /* single accent: actions + highlight */
  --amber-deep: #c87f0a;
  --amber-wash: #fff6e6;

  --neuf:       #1f9d57;   /* NEUF / new      */
  --neuf-wash:  #e9f7ef;
  --occ:        #d98613;   /* OCCASION / exchange */
  --occ-wash:   #fdf1de;

  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(17,21,28,.05), 0 6px 22px rgba(17,21,28,.06);
  --shadow-lo:  0 1px 2px rgba(17,21,28,.06);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1100px, 100% - 40px); margin-inline: auto; }

a { color: inherit; }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  background: var(--ink);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand__mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--amber); color: var(--ink);
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  letter-spacing: .5px;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -.2px; }
.brand__tag  { font-size: 12px; color: #9aa4b1; }

.iconbtn {
  appearance: none; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04); color: #cfd6df;
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer;
  font-size: 17px; line-height: 1; transition: background .15s, color .15s, border-color .15s;
}
.iconbtn:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.28); }

/* ── API key gate ────────────────────────────────────────── */
.keygate { padding: 56px 0; }
.keygate__card {
  max-width: 460px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px;
}
.keygate__title { margin: 0 0 6px; font-size: 20px; letter-spacing: -.2px; }
.keygate__hint  { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.keygate__form  { display: flex; gap: 10px; }
.keygate__form .field { flex: 1; }
.keygate__error { margin: 12px 0 0; color: #c0392b; font-size: 13.5px; }

/* ── App / hero ──────────────────────────────────────────── */
.app { padding: 40px 0 64px; }
.hero { margin-bottom: 8px; }
.hero__title {
  margin: 0 0 22px;
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -.6px; font-weight: 700;
}

/* search bar */
.search { display: flex; gap: 12px; align-items: stretch; }
.search__field {
  position: relative; flex: 1; display: flex; align-items: center;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lo);
  transition: border-color .15s, box-shadow .15s;
}
.search__field:focus-within {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-wash);
}
.search__icon { padding-left: 16px; color: var(--muted); font-size: 20px; }
.search__input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 17px; padding: 16px 12px; color: var(--ink);
  font-family: var(--mono); letter-spacing: .3px;
}
.search__input::placeholder { font-family: var(--sans); letter-spacing: 0; color: #9aa3ae; }
.search__kind {
  margin-right: 12px; padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .6px;
  background: var(--ink); color: #fff; white-space: nowrap;
  opacity: 0; transform: translateY(2px); transition: opacity .15s, transform .15s;
}
.search__kind.show { opacity: 1; transform: none; }
.search__btn { flex: 0 0 auto; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  appearance: none; cursor: pointer; border: 1.5px solid transparent;
  border-radius: var(--radius-sm); padding: 0 22px; height: 54px;
  font: 600 15px/1 var(--sans); letter-spacing: .2px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--amber); color: var(--ink); box-shadow: 0 2px 0 var(--amber-deep); }
.btn--primary:hover { background: #ffb02e; }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 16px;
  margin: 26px 0 18px; color: var(--muted);
  font-size: 12.5px; text-transform: uppercase; letter-spacing: 1.5px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ── Funnel ──────────────────────────────────────────────── */
.funnel {
  display: grid; gap: 12px;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  align-items: end;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-lo);
}
.funnel__group { display: flex; flex-direction: column; gap: 6px; }
.funnel__label {
  font-size: 11px; font-weight: 700; letter-spacing: .8px;
  color: var(--muted); text-transform: uppercase;
}
.funnel__label em { font-style: normal; font-weight: 600; color: var(--amber-deep); }
.funnel__go { height: 46px; }

.select {
  appearance: none; -webkit-appearance: none;
  font: 500 14.5px var(--sans); color: var(--ink);
  background: var(--surface)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b7480' stroke-width='1.6' stroke-linecap='round'/></svg>")
    no-repeat right 12px center;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 34px 11px 12px; cursor: pointer; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.select:focus { outline: 0; border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-wash); }
.select:disabled { color: var(--muted); cursor: not-allowed; background-color: var(--surface-2); }

/* ── Status / loading ────────────────────────────────────── */
.status {
  margin: 26px 0; padding: 16px 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); font-size: 14.5px;
  display: flex; align-items: center; gap: 12px;
}
.status--error { border-color: #f3c9c2; background: #fdf3f1; color: #8e2c1c; }
.status--empty { color: var(--muted); justify-content: center; }

.spinner {
  width: 18px; height: 18px; flex: 0 0 auto;
  border: 2.5px solid var(--line); border-top-color: var(--amber);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ─────────────────────────────────────────────── */
.results { margin-top: 30px; display: grid; gap: 22px; }
.results:empty { margin: 0; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise .28s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.panel__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.panel__title {
  margin: 0; font-size: 12.5px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase; color: var(--ink);
}
.panel__sub { font-size: 13px; color: var(--muted); }

/* result header: the searched ref */
.refhead {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 20px;
}
.refhead__code {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  letter-spacing: .5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 8px;
}
.refhead__counts { display: flex; gap: 18px; color: var(--muted); font-size: 13.5px; }
.refhead__counts b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── Prices list ─────────────────────────────────────────── */
.price-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center; gap: 16px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
  transition: background .12s;
}
.price-row:hover { background: var(--surface-2); }
.price-row--best {
  background: var(--amber-wash);
  box-shadow: inset 3px 0 0 var(--amber);
}
.price-row--best:hover { background: #fff1d6; }

.price-id { min-width: 0; }
.price-best-flag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: var(--amber-deep); margin-bottom: 4px;
}
.price-brand { font-weight: 600; font-size: 15px; }
.price-ref {
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  margin-left: 8px; word-break: break-all;
}
.price-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.price-source {
  font-size: 12px; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 999px;
}

.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge--neuf { color: var(--neuf); background: var(--neuf-wash); }
.badge--occ  { color: var(--occ);  background: var(--occ-wash); }

.price-amount {
  font-family: var(--mono); font-weight: 700;
  font-size: 22px; letter-spacing: -.5px; text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.price-amount small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }

.buy {
  text-decoration: none; white-space: nowrap;
  background: var(--ink); color: #fff;
  font: 600 13.5px var(--sans); padding: 9px 16px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, transform .08s;
}
.buy:hover { background: #000; }
.buy:active { transform: translateY(1px); }
.buy--off {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); cursor: default;
}

/* ── Equivalents ─────────────────────────────────────────── */
.equiv-grid {
  display: grid; gap: 10px; padding: 16px 20px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.equiv {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .08s;
}
.equiv:hover { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
.equiv:active { transform: translateY(1px); }
.equiv__brand { font-weight: 600; font-size: 13.5px; }
.equiv__value { font-family: var(--mono); font-size: 14.5px; margin-top: 3px; word-break: break-all; }
.equiv__foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.equiv__type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stamp {
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  color: var(--neuf); background: var(--neuf-wash);
  padding: 2px 8px; border-radius: 999px; display: inline-flex; gap: 4px;
}
.stamp--oe { color: var(--ink); background: var(--amber-wash); border: 1px solid #f3dca6; }

/* ── Compatibility ───────────────────────────────────────── */
.compat-body { padding: 16px 20px; }
.compat-makes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2);
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.chip b { font-family: var(--mono); font-size: 12px; color: var(--amber-deep); font-variant-numeric: tabular-nums; }

.veh-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.veh-table th {
  text-align: left; font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 0 12px 8px; border-bottom: 1px solid var(--line);
}
.veh-table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.veh-table tr:last-child td { border-bottom: 0; }
.veh-table td:first-child { font-weight: 600; }
.veh-table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ── VIN card ────────────────────────────────────────────── */
.vin-card .panel__head { background: var(--ink); }
.vin-card .panel__head .panel__title { color: #fff; }
.vin-card .panel__head .panel__sub { color: #9aa4b1; }
.vin-grid {
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.vin-cell { background: var(--surface); padding: 14px 18px; }
.vin-cell dt { font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; font-weight: 700; }
.vin-cell dd { margin: 0; font-size: 15px; font-weight: 600; }
.vin-cell dd.mono { font-family: var(--mono); }
.vin-cta { padding: 16px 20px; border-top: 1px solid var(--line-soft); }

/* parts-from-vehicle list reuses equiv-grid styling */

/* ── Footer ──────────────────────────────────────────────── */
.foot { padding: 28px 0 40px; color: var(--muted); font-size: 12.5px; text-align: center; }
.foot__key { font-family: var(--mono); }

/* ── Focus visibility (a11y) ─────────────────────────────── */
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
.field {
  font: 500 15px var(--sans); padding: 14px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); outline: 0;
}
.field:focus { border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-wash); }

/* ── Responsive (tablet / phone) ─────────────────────────── */
@media (max-width: 820px) {
  .funnel { grid-template-columns: 1fr 1fr; }
  .funnel__group--wide { grid-column: 1 / -1; }
  .funnel__go { grid-column: 1 / -1; width: 100%; }
}
@media (max-width: 600px) {
  .wrap { width: calc(100% - 28px); }
  .search { flex-direction: column; }
  .search__btn { width: 100%; }
  .funnel { grid-template-columns: 1fr; }
  .price-row { grid-template-columns: 1fr auto; row-gap: 12px; }
  .price-amount { grid-column: 2; }
  .buy { grid-column: 1 / -1; justify-content: center; }
  .refhead__code { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
