:root {
  --bg: #09070f;
  --surface: rgba(16, 13, 25, 0.88);
  --surface-solid: #12101b;
  --surface-soft: rgba(29, 23, 43, 0.8);
  --line: rgba(232, 225, 255, 0.15);
  --line-strong: rgba(232, 225, 255, 0.32);
  --text: #fbfaff;
  --muted: #9e98ad;
  --muted-bright: #d0cada;
  --accent: #8b5cf6;
  --accent-light: #c4b5fd;
  --accent-soft: rgba(139, 92, 246, 0.17);
  --success: #c4b5fd;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

button { font: inherit; }

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse 70% 58% at 62% 45%, rgba(74, 48, 130, 0.28), transparent 68%),
    radial-gradient(ellipse 55% 50% at 86% 105%, rgba(43, 25, 73, 0.28), transparent 70%),
    #09070f;
}

.stage::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(196, 181, 253, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(196, 181, 253, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 75%);
  content: "";
  pointer-events: none;
}

#view {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  top: 24px;
  right: 30px;
  left: 30px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: block;
  width: 154px;
  height: 48px;
  object-fit: cover;
  object-position: center;
  filter: drop-shadow(0 8px 20px rgba(139, 92, 246, 0.2));
}

.brand-text h1 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.brand-text h1 { color: var(--accent-light); }

.brand-text p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mobile-budget-button {
  display: none;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px rgba(196, 181, 253, 0.9);
}

.vehicle-switcher {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 13px;
  transform: translateX(-50%);
}

.switcher-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chips {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 19, 26, 0.74);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(16px);
}

.chip {
  padding: 8px 13px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.chip:hover { color: var(--text); }

.chip.active {
  color: #120c20;
  background: var(--accent-light);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.28);
}

.model-caption {
  position: absolute;
  bottom: 116px;
  left: 50%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.model-caption strong {
  color: var(--text);
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 560;
  letter-spacing: -0.03em;
}

.model-caption span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.eyebrow {
  color: var(--accent-light);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.view-tip {
  position: absolute;
  right: 31px;
  bottom: 31px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.mouse-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent-light);
  font-size: 17px;
}

/* Parts picker */
.parts-browser,
.panel {
  position: fixed;
  z-index: 10;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(20px);
}

.parts-browser {
  top: 50%;
  left: 30px;
  width: 238px;
  padding: 19px;
  transform: translateY(-50%);
}

.browser-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.browser-head h2 {
  margin: 7px 0 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 560;
  letter-spacing: -0.035em;
}

.part-count {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid rgba(139, 92, 246, 0.42);
  border-radius: 50%;
  color: var(--accent-light);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 800;
}

.browser-note {
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.parts-list { display: flex; flex-direction: column; gap: 4px; }

.part-option {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 43px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted-bright);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.part-option:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.part-option.selected {
  border-color: rgba(139, 92, 246, 0.62);
  color: var(--text);
  background: var(--accent-soft);
}

.part-number {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  font-size: 10px;
  font-weight: 750;
}

.part-option.selected .part-number {
  color: #140d22;
  background: var(--accent-light);
}

.part-label { font-size: 12px; font-weight: 650; }

.part-price {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.part-option.selected .part-price { color: var(--accent-light); }

/* Detail panel */
.panel {
  top: 50%;
  right: 30px;
  width: 292px;
  min-height: 118px;
  padding: 19px;
  transform: translateY(-50%);
}

.panel-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.panel-empty p { margin: 0; }

.empty-orb {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  color: var(--accent-light);
  font-size: 19px;
  font-weight: 300;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 17px;
}

.panel-head h2 {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 560;
  letter-spacing: -0.045em;
}

.close {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  font-weight: 300;
  line-height: 20px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.close:hover { border-color: var(--line-strong); color: var(--text); }

.base-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 15px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.base-price b {
  color: var(--text);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.cond { display: flex; flex-direction: column; gap: 6px; }

.cond-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 47px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.cond-item:hover { border-color: var(--line-strong); }
.cond-item.on { border-color: rgba(139, 92, 246, 0.62); background: var(--accent-soft); }

.cond-item .lbl b { display: block; color: var(--muted-bright); font-size: 12px; font-weight: 650; }
.cond-item .lbl span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.cond-item .val { color: var(--accent-light); font-size: 11px; font-weight: 750; }

.line { height: 1px; margin: 16px 0 11px; background: var(--line); }

.tot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.tot span { color: var(--muted); font-size: 12px; }
.tot strong { color: var(--accent-light); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }

.add {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 14px;
  padding: 13px 14px;
  border: 0;
  border-radius: 11px;
  color: #140d22;
  background: var(--accent-light);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: transform 0.15s ease, filter 0.2s ease, opacity 0.2s ease;
}

.add span { font-size: 17px; font-weight: 500; }
.add:hover { filter: brightness(1.08); }
.add:active { transform: scale(0.98); }
.add:disabled { opacity: 0.4; cursor: default; filter: none; }
.add.flash { color: #140d22; background: var(--success); }

/* Budget tray */
.budget {
  position: fixed;
  bottom: 27px;
  left: 50%;
  z-index: 11;
  width: min(420px, calc(100% - 40px));
  transform: translateX(-50%);
}

.budget-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  color: var(--text);
  background: rgba(17, 24, 32, 0.9);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  backdrop-filter: blur(18px);
  transition: border-color 0.2s ease;
}

.budget-bar:hover { border-color: rgba(139, 92, 246, 0.68); }
.budget-icon { color: var(--accent-light); font-size: 20px; line-height: 1; transform: rotate(-20deg); }
.budget-bar .b-title { color: var(--muted-bright); font-size: 12px; font-weight: 700; }
.budget-bar .b-count { padding: 3px 8px; border-radius: 999px; color: var(--accent-light); background: var(--accent-soft); font-size: 10px; font-weight: 800; }
.budget-bar .b-total { margin-left: auto; color: var(--accent-light); font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }
.budget-bar .b-chev { color: var(--muted); font-size: 16px; }

.budget-list {
  max-height: 36vh;
  margin-bottom: 9px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 24, 32, 0.96);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
}

.budget-empty { padding: 12px 8px; color: var(--muted); font-size: 11px; text-align: center; }

.budget-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 5px;
  border-bottom: 1px solid var(--line);
}

.budget-item .bi-name { color: var(--muted-bright); font-size: 12px; font-weight: 700; }
.budget-item .bi-cond { grid-column: 1 / 2; color: var(--muted); font-size: 10px; }
.budget-item .bi-price { grid-row: 1 / 3; grid-column: 2; color: var(--accent-light); font-size: 12px; font-weight: 700; }
.bi-del { grid-row: 1 / 3; grid-column: 3; padding: 0 2px; border: 0; color: var(--muted); background: none; cursor: pointer; font-size: 19px; line-height: 1; }
.bi-del:hover { color: var(--accent-light); }

.budget-grand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 5px 2px;
}
.budget-grand span { color: var(--muted); font-size: 11px; }
.budget-grand strong { color: var(--accent-light); font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; }

.send-quote {
  display: block;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(139, 92, 246, 0.56);
  border-radius: 10px;
  color: #f8f5ff;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: filter 0.2s ease, transform 0.15s ease;
}

.send-quote:hover { filter: brightness(1.12); }
.send-quote:active { transform: scale(0.98); }

@media (max-width: 980px) {
  .parts-browser { left: 18px; }
  .panel { right: 18px; }
  .topbar { right: 18px; left: 18px; }
  .view-tip { right: 18px; }
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .stage { position: relative; min-height: 100svh; height: 100svh; }
  #view {
    top: 156px;
    right: 12px;
    bottom: auto;
    left: 12px;
    width: calc(100% - 24px);
    height: min(350px, calc(100svh - 470px));
    min-height: 220px;
    border: 1px solid rgba(196, 181, 253, 0.12);
    border-radius: 16px;
  }
  .topbar { top: 14px; right: 14px; left: 14px; }
  .topbar-status { display: none; }
  .brand { min-width: 0; flex: 1; }
  .brand-text { min-width: 0; }
  .brand-logo { width: 118px; height: 38px; }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 13px; }
  .mobile-budget-button {
    display: flex;
    position: absolute;
    top: 52px;
    right: 0;
    left: 0;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 7px 9px;
    border: 1px solid rgba(139, 92, 246, 0.55);
    border-radius: 9px;
    color: var(--muted-bright);
    background: rgba(18, 16, 27, 0.92);
    cursor: pointer;
    font-size: 9px;
    font-weight: 750;
    flex-shrink: 0;
    pointer-events: auto;
    white-space: nowrap;
  }
  .mobile-budget-button b { color: var(--accent-light); font-size: 10px; }
  .vehicle-switcher { top: 102px; left: 14px; right: 14px; display: block; transform: none; }
  .switcher-label { display: block; margin: 0 0 6px 3px; }
  .chips { justify-content: space-between; width: 100%; }
  .chip { flex: 1; padding: 8px 5px; font-size: 11px; }
  .model-caption { bottom: 255px; }
  .view-tip { display: none; }
  .parts-browser {
    top: auto;
    right: 12px;
    bottom: 148px;
    left: 12px;
    width: auto;
    padding: 13px;
    transform: none;
  }
  .browser-head { align-items: center; padding-bottom: 9px; }
  .browser-head h2 { margin-top: 3px; font-size: 16px; }
  .browser-note { display: none; }
  .parts-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 9px;
  }
  .parts-browser:not(.expanded) .parts-list { display: none; }
  .parts-browser:not(.expanded) .browser-head { padding-bottom: 0; border-bottom: 0; }
  .part-option { grid-template-columns: 1fr; justify-items: center; gap: 3px; min-height: 49px; padding: 4px 2px; text-align: center; }
  .part-number { width: 22px; height: 22px; font-size: 9px; }
  .part-label { font-size: 9px; }
  .part-price { display: none; }
  .panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    min-height: auto;
    max-height: 54svh;
    padding: 15px;
    overflow: auto;
    transform: none;
  }
  .panel.is-empty { display: none; }
  .budget {
    top: 96px;
    right: 12px;
    bottom: auto;
    left: 12px;
    width: auto;
    transform: none;
    pointer-events: none;
  }
  .budget-bar { display: none; }
  .budget-list {
    top: 0;
    right: auto;
    bottom: auto;
    left: 0;
    width: 100%;
    margin: 0;
    pointer-events: auto;
  }
  body:not(.panel-active) .budget { top: 96px; bottom: auto; }
  body:not(.panel-active) .parts-browser { bottom: 20px; }
  .panel-empty { justify-content: center; }
  .panel-body { padding-bottom: 1px; }
  .panel-head { margin-bottom: 12px; }
  .panel-head h2 { font-size: 20px; }
  .cond { display: grid; grid-template-columns: 1fr 1fr; }
  .cond-item { min-height: 43px; }
  .cond-item .lbl span { display: none; }
}

@media (max-width: 720px) and (max-height: 700px) {
  #view { top: 145px; height: 250px; }
  .model-caption { bottom: 150px; }
}

@media (max-width: 720px) and (orientation: portrait) {
  #view {
    height: min(525px, max(350px, calc(100svh - 320px)));
  }
  .model-caption { bottom: 155px; }
}
