:root {
  --bg: #f5f4f0;
  --tint: #ebe9e3;
  --ink: #161618;
  --muted: #6a6964;
  --line: #d9d7d0;
  --accent: #9dc807;
  --accent-ink: #4c6300;
  --danger: #b3261e;
  --on-fill: #cfccc3;
  --card: #ffffff;
  --hover: #33333a;
  --tint-hover: #dedcd4;
  --plan-hover: #d3e68a;
  --thumb-line: #b9b6ad;
  --shadow: 0 1px 2px rgba(22, 22, 24, .06), 0 8px 24px rgba(22, 22, 24, .05);
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

/* Темна тема: за системним налаштуванням або за перемикачем у шапці */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #141416; --tint: #1f1f22; --ink: #ededea; --muted: #9a9a94; --line: #2e2e32; --accent-ink: #c9ec5a; --danger: #ff7a70; --on-fill: #3a3a40; --card: #1c1c1f; --hover: #d6d6d2; --tint-hover: #2a2a2e; --plan-hover: #4a5a1e; --thumb-line: #4a4a50; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); }
}
:root[data-theme="dark"] { --bg: #141416; --tint: #1f1f22; --ink: #ededea; --muted: #9a9a94; --line: #2e2e32; --accent-ink: #c9ec5a; --danger: #ff7a70; --on-fill: #3a3a40; --card: #1c1c1f; --hover: #d6d6d2; --tint-hover: #2a2a2e; --plan-hover: #4a5a1e; --thumb-line: #4a4a50; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); }

* { box-sizing: border-box; }
html { color-scheme: light dark; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--sans); }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--muted); }

/* Шапка */
.top { border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 18px; letter-spacing: -.01em; }
.logo img { width: 40px; height: 40px; flex: none; }
.logo span { font-weight: 400; font-size: 13px; letter-spacing: 0; color: var(--muted); margin-left: 2px; }
.nav { display: flex; align-items: center; gap: 24px; }
.phone { text-decoration: none; font-family: var(--mono); font-size: 14px; }
.theme { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme:hover { border-color: var(--ink); }
.theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme .moon { display: none; }
:root[data-theme="dark"] .theme .sun { display: none; }
:root[data-theme="dark"] .theme .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { display: none; }
  :root:not([data-theme="light"]) .theme .moon { display: block; }
}
.req-link { text-decoration: none; font-weight: 500; }
.req-link b { display: inline-block; min-width: 24px; padding: 0 6px; margin-left: 4px; text-align: center; font: 500 13px/24px var(--mono); background: var(--tint); }
.req-link b.has { background: var(--accent); color: var(--ink); }

/* Головна */
.hero { padding: 40px 0 0; }
.hero h1 { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.1; font-weight: 500; letter-spacing: -.02em; }

/* Панель пошуку й фільтрів */
.panel { margin-top: 24px; padding: 12px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.bar { display: grid; grid-template-columns: 2fr 5fr auto; gap: 8px; }
.filters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.bar input, .bar select, .bar .go { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font: inherit; color: var(--ink); background: var(--bg); outline: 0; }
.bar input:focus, .bar select:focus { border-color: var(--ink); }
.bar input::placeholder { color: var(--muted); }
.bar select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px; color: var(--muted);
  background: var(--bg) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8"><path d="M1 1l5 5 5-5" fill="none" stroke="%23161618" stroke-width="1.5"/></svg>') no-repeat right 14px center; }
.bar select.set { color: var(--ink); border-color: var(--ink); }
.bar .go { width: auto; background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; padding: 0 22px; cursor: pointer; }
.bar .go:hover { background: var(--hover); }
.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mchip { padding: 6px 14px; border: 0; border-radius: 999px; background: var(--tint); font-size: 14px; cursor: pointer; }
.mchip:hover { background: var(--tint-hover); }
.mchip.act { background: var(--accent); }

.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 36px 0 16px; }
.sec-head h2 { font-size: 22px; font-weight: 500; letter-spacing: -.01em; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; }
.link:hover { color: var(--ink); }

.note { margin-top: 24px; padding: 12px 16px; border-left: 2px solid var(--accent); background: var(--tint); }

.cars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px 24px; padding-bottom: 64px; }
.car { text-decoration: none; display: block; }
.car-img { aspect-ratio: 16 / 10; background: var(--tint); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--ink); font-size: 12px; font-weight: 500; vertical-align: 2px; }
.car-img img { width: 100%; height: 100%; object-fit: cover; }
.car h3 { margin-top: 12px; font-size: 18px; font-weight: 500; }
.car:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.car:hover .badge { text-decoration: none; }
.car .meta { color: var(--muted); font-size: 14px; }
.paint { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); flex: none; }
.spec .sw, .row .sw { width: 11px; height: 11px; }
.car .vin { margin-top: 8px; font-size: 13px; }
.car .sum { margin-top: 4px; font-size: 14px; }

.side { width: 78%; fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.side .ground { stroke: var(--line); }

/* Сторінка машини */
.crumbs { padding: 24px 0 0; font-size: 14px; color: var(--muted); }
.crumbs a { color: inherit; }
.car-top { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; padding: 24px 0 48px; }
.gallery .main { aspect-ratio: 16 / 10; background: var(--tint); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gallery .main img { width: 100%; height: 100%; object-fit: cover; }
.gallery .hint { margin-top: 8px; font-size: 13px; color: var(--muted); }
.thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.thumbs button { border: 1px solid var(--line); padding: 0; background: none; cursor: pointer; flex: none; }
.thumbs img { width: 88px; height: 56px; object-fit: cover; }

.car-info h1 { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.12; font-weight: 500; letter-spacing: -.02em; }
.vin-big { display: block; margin-top: 12px; font: 500 clamp(15px, 1.8vw, 18px)/1.3 var(--mono); letter-spacing: .06em; word-break: break-all; }
.spec { margin: 24px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 0 24px; }
.spec dt, .spec dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--line); }
.spec dt { color: var(--muted); }
.oem-note { margin-top: 4px; font-size: 13px; color: var(--muted); }

.map-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--ink); padding-top: 16px; }
.map-head h2 { font-size: 22px; font-weight: 500; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--muted); }
.legend i.a { background: var(--on-fill); border-color: var(--ink); }
.legend i.b { background: var(--accent); border-color: var(--accent-ink); }

.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 16px; }
.plans figure { margin: 0; }
.plans figcaption { font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.plan { display: block; width: 100%; height: auto; }
.plan .z { fill: none; stroke: var(--line); stroke-width: 1; }
.plan .z.on { fill: var(--on-fill); stroke: var(--ink); }
.plan .z[data-at] { cursor: pointer; }
.plan .z[data-at]:hover { fill: var(--plan-hover); }
.plan .z.lit, .plan .z.lit:hover { fill: var(--accent); stroke: var(--accent-ink); }
.plan .z:focus-visible { outline: none; stroke: var(--accent-ink); stroke-width: 2.5; }
.plan .cell { stroke: var(--ink); stroke-width: .75; opacity: .25; pointer-events: none; }
.plan.thumb { width: 104px; flex: none; }
.plan.thumb .z { stroke: var(--thumb-line); stroke-width: 2; }
.plan.thumb .cell { display: none; }
.plan.thumb .z.lit { stroke: var(--accent-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 8px; }
#map .chips { margin-bottom: 0; }
.chip { border: 1px solid var(--line); background: none; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip span { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-left: 4px; }
.chip:hover { border-color: var(--ink); }
.chip.act { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.act span { color: inherit; }
.chip:disabled { opacity: .4; cursor: default; border-color: var(--line); }

.car-search { margin-top: 24px; }
.car-search input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font: inherit; background: var(--card); outline: 0; }
.car-search input:focus { border-color: var(--ink); }
.found { margin-top: 20px; font-size: 14px; color: var(--muted); }
.found .link { margin-left: 8px; }
.grp { border-top: 1px solid var(--line); }
.grp-head { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 16px 0; border: 0; background: none; font: inherit; font-size: 18px; font-weight: 500; cursor: pointer; text-align: left; }
.grp-head .n { font-size: 14px; font-weight: 400; color: var(--muted); }
.grp-head::before { content: ''; width: 8px; height: 8px; margin-right: 12px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.grp.open .grp-head::before { transform: rotate(45deg); }
.grp-head span:first-of-type { flex: 1; }
.grp .sub-head { margin: 16px 0 0; font-size: 14px; font-weight: 500; color: var(--muted); }
.grp .rows { margin-bottom: 16px; }
.group { margin-top: 32px; font-size: 14px; font-weight: 500; color: var(--muted); }

/* Рядки деталей */
.rows { border-top: 1px solid var(--ink); margin-top: 8px; }
.row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 150px 110px 112px; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row .name { font-weight: 500; text-decoration: none; display: block; }
.row a.name:hover { text-decoration: underline; text-underline-offset: 3px; }
.row .sub { font-size: 13px; color: var(--muted); }
.qty { margin-left: 8px; font: 500 12px var(--mono); color: var(--muted); }
.total small { font-size: 13px; font-weight: 400; }
.row .oem { font-size: 13px; color: var(--muted); }
.row .price { font-weight: 500; text-align: right; white-space: nowrap; }
.row.off .name, .row.off .price { color: var(--muted); }
.row.off .plan { opacity: .5; }

.btn { display: inline-block; padding: 10px 16px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); font-weight: 500; text-decoration: none; text-align: center; cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn.ghost { background: none; color: var(--ink); }
.btn.ghost:hover { background: var(--tint); }
.btn.sm { padding: 5px 10px; font-size: 14px; font-weight: 400; width: 100%; }
.btn.added { background: var(--accent); color: var(--ink); border-color: var(--accent-ink); }
.tag { font-size: 13px; color: var(--muted); text-align: center; }

.empty { padding: 48px 0; color: var(--muted); }

/* Сторінка деталі */
.part { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; padding: 24px 0 48px; }
.part-pic { background: var(--tint); padding: 32px; }
.part-pic img { width: 100%; }
.part-pic .plan .z.on { fill: none; stroke: var(--thumb-line); }
.part-cap { margin-top: 8px; font-size: 13px; color: var(--muted); }
.part-loc { margin-top: 16px; max-width: 240px; }
.pthumb { width: 104px; height: 68px; object-fit: cover; }
.part h1 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.15; font-weight: 500; letter-spacing: -.02em; }
.part .big-price { margin-top: 16px; font-size: 28px; font-weight: 500; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.warn { margin-top: 16px; font-size: 14px; padding-left: 12px; border-left: 2px solid var(--accent); }

/* Запит */
.req { padding: 32px 0 64px; }
.req h1 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 500; letter-spacing: -.02em; margin-bottom: 24px; }
.total { display: flex; justify-content: space-between; padding: 16px 0; font-size: 20px; font-weight: 500; }


.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); background: var(--ink); color: var(--bg); padding: 10px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .cars { grid-template-columns: repeat(2, 1fr); }
  .bar { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(5, 1fr); }
  .bar .go { width: 100%; padding: 12px; }
  .car-top, .part { grid-template-columns: 1fr; gap: 24px; }
  .row { grid-template-columns: 104px minmax(0, 1fr) 100px 104px; }
  .row .oem { display: none; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .logo span { display: none; }
  .phone { display: none; }
  .hero { padding: 28px 0 0; }
  .panel { padding: 10px; border-radius: 12px; }
  .bar { grid-template-columns: 1fr; }
  .bar .go { width: 100%; padding: 12px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .chips { overflow-x: auto; flex-wrap: nowrap; margin: 10px -10px 0; padding: 0 10px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .mchip { flex: none; }
  .cars { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; gap: 16px; }
  .row { grid-template-columns: 80px minmax(0, 1fr) auto; gap: 4px 12px; }
  .row .plan.thumb, .row .pthumb { width: 80px; grid-row: span 2; }
  .row .pthumb { height: 60px; }
  .row .act { grid-column: 2 / -1; }
  .row .act .btn { width: auto; }
  .row .tag { text-align: left; }
  .acts .btn { flex: 1 1 100%; }
}
