:root {
  --paper: #f4efe5;
  --panel: #fffaf0;
  --ink: #171512;
  --muted: #6d655c;
  --line: #d8cec0;
  --red: #d7192a;
  --red-dark: #94111d;
  --green: #1f7a53;
  --blue: #225f8f;
  --gold: #b7832f;
  --shadow: 0 18px 50px rgba(39, 31, 24, 0.14);
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(215, 25, 42, 0.08), transparent 28rem),
    linear-gradient(180deg, #f9f5ec 0%, #eee6da 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell-header,
main {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto;
}

.shell-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(23, 21, 18, 0.18);
  background:
    linear-gradient(135deg, transparent 0 42%, #fff 43% 57%, transparent 58%),
    radial-gradient(circle, var(--red) 0 44%, #111 45%);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.45);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-button,
.danger-button,
.part-button,
.category-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.82);
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
}

.icon-button svg,
.search svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.danger-button {
  padding: 0 13px;
  font-weight: 800;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 340px);
  gap: 24px;
  align-items: end;
  padding: 42px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red-dark);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.6rem, 7vw, 6.2rem);
  line-height: 0.92;
}

h2 {
  font-size: 1.35rem;
}

.intro-copy {
  width: min(100%, 640px);
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.55;
}

.garage-card,
.metric,
.vehicle-picker,
.filters,
.parts-panel,
.build-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: var(--shadow);
}

.garage-card {
  min-height: 150px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 24px;
}

.card-label,
.metric span,
.part-meta,
.selected-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.garage-card strong {
  font-size: 2rem;
}

.garage-card span:last-child {
  color: var(--muted);
  line-height: 1.45;
}

.vehicle-picker {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 1.05fr);
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
  box-shadow: none;
}

.vehicle-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.field select {
  width: 100%;
  max-width: none;
}

.vehicle-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.vehicle-facts span {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 1px solid #eadfce;
  border-radius: 7px;
  padding: 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 780;
  background: #fff;
}

.vehicle-facts b {
  color: var(--ink);
  font-size: 0.92rem;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 9px;
  padding: 20px;
  box-shadow: none;
}

.metric strong {
  font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
  padding: 16px 0 42px;
}

.filters,
.parts-panel,
.build-panel {
  padding: 16px;
}

.filters,
.build-panel {
  position: sticky;
  top: 14px;
}

.search {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.filters h2 {
  margin: 20px 0 10px;
  font-size: 1rem;
}

.category-list {
  display: grid;
  gap: 7px;
}

.category-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 760;
}

.category-button.active {
  border-color: rgba(215, 25, 42, 0.5);
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-top.compact {
  margin-bottom: 12px;
}

select {
  min-height: 40px;
  max-width: 210px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.part-card {
  min-height: 192px;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.part-card.selected {
  border-color: rgba(31, 122, 83, 0.58);
  background: linear-gradient(180deg, #fff 0%, #f0fbf5 100%);
}

.part-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.part-name {
  font-size: 1.05rem;
  font-weight: 880;
}

.tag {
  align-self: start;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  background: var(--blue);
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.fitment-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 0.73rem;
  font-weight: 880;
}

.fitment-badge.compatible {
  background: var(--green);
}

.fitment-badge.modified {
  background: var(--gold);
}

.fitment-badge.advised {
  background: var(--red-dark);
}

.fitment-badge.unknown {
  background: var(--blue);
}

.part-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.fitment-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.part-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.part-stats span {
  min-height: 42px;
  display: grid;
  align-content: center;
  border: 1px solid #eadfce;
  border-radius: 7px;
  padding: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  background: #fffaf0;
}

.part-button {
  width: 100%;
  color: #fff;
  font-weight: 860;
  background: var(--ink);
}

.part-button.remove {
  background: var(--green);
}

.selected-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.selected-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.selected-item strong {
  font-size: 0.96rem;
}

.selected-item .fitment-badge {
  margin-top: 6px;
}

.remove-small {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff6f5;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  max-width: calc(100% - 36px);
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .build-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 820px) {
  .intro,
  .dashboard,
  .vehicle-picker,
  .workspace,
  .parts-grid {
    grid-template-columns: 1fr;
  }

  .vehicle-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    position: static;
  }

  .category-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .shell-header,
  main {
    width: min(100% - 22px, 1420px);
  }

  .shell-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0 8px;
  }

  .header-actions {
    width: 100%;
  }

  .danger-button {
    flex: 1;
  }

  .category-list,
  .part-stats,
  .vehicle-form,
  .vehicle-facts {
    grid-template-columns: 1fr;
  }

  .panel-top {
    align-items: flex-start;
    flex-direction: column;
  }

  select {
    width: 100%;
    max-width: none;
  }
}
