:root {
  --bg: #f4f7fa; --surface: #ffffff; --text: #14212b; --muted: #5b6b78; --line: #dbe3ea;
  --brand: #0b6bcb; --brand-ink: #ffffff; --brand-soft: #e6f1fc;
  --ok: #17794a; --ok-bg: #e3f5ec; --warn: #9a5b00; --warn-bg: #fff1d6; --bad: #b3261e; --bad-bg: #fde7e5;
  --shadow: 0 1px 2px rgba(16, 36, 52, .06), 0 4px 14px rgba(16, 36, 52, .06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1419; --surface: #172029; --text: #e8eef3; --muted: #93a3b1; --line: #263440;
    --brand: #4da3ff; --brand-ink: #06121e; --brand-soft: #14283b;
    --ok: #55d59a; --ok-bg: #123325; --warn: #ffc15c; --warn-bg: #36280d; --bad: #ff8d84; --bad-bg: #3b1613;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1419; --surface: #172029; --text: #e8eef3; --muted: #93a3b1; --line: #263440;
  --brand: #4da3ff; --brand-ink: #06121e; --brand-soft: #14283b;
  --ok: #55d59a; --ok-bg: #123325; --warn: #ffc15c; --warn-bg: #36280d; --bad: #ff8d84; --bad-bg: #3b1613;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding-top: 20px; padding-bottom: 48px; outline: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.2; margin: .4em 0 .3em; }
h2, h3, h4 { line-height: 1.25; }
h3 { margin: 0 0 .4em; font-size: 1.05rem; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 99; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar { display: flex; align-items: center; gap: 16px; padding: 10px 0; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 6px; }
.logo:hover { text-decoration: none; }
.search { position: relative; flex: 1 1 280px; min-width: 200px; }
.search input, .finder input, .finder select, .field input, .field textarea, .filters input[type=search], .toolbar select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit;
}
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--text); font-weight: 600; }
.nav a:hover, .nav a.active { background: var(--brand-soft); text-decoration: none; }
.count { background: var(--brand); color: var(--brand-ink); border-radius: 99px; padding: 0 7px; font-size: .75rem; margin-left: 2px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); overflow: hidden; z-index: 30; }
.suggest a { display: flex; gap: 10px; padding: 10px 14px; color: var(--text); align-items: center; }
.suggest a:hover { background: var(--brand-soft); text-decoration: none; }
.suggest small { display: block; color: var(--muted); }
.suggest .all { justify-content: center; color: var(--brand); font-weight: 600; border-top: 1px solid var(--line); }
.s-empty { padding: 12px 14px; color: var(--muted); }

/* stepper + breadcrumbs */
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; overflow-x: auto; }
.stepper li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; white-space: nowrap; flex: 1; }
.stepper li::after { content: ""; height: 2px; background: var(--line); flex: 1; min-width: 12px; }
.stepper li:last-child::after { display: none; }
.stepper b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--muted); font-size: .75rem; }
.stepper .active { color: var(--text); font-weight: 700; } .stepper .active b { background: var(--brand); color: var(--brand-ink); }
.stepper .done b { background: var(--ok); color: #fff; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 8px; }
.crumbs i { margin: 0 6px; font-style: normal; }

/* hero */
.hero { background: linear-gradient(135deg, var(--brand-soft), var(--surface)); border: 1px solid var(--line); border-radius: 20px; padding: clamp(20px, 4vw, 40px); box-shadow: var(--shadow); }
.hero p { color: var(--muted); max-width: 60ch; margin: 0 0 18px; }
.finder { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.finder input { flex: 1 1 260px; width: auto; } .finder select { flex: 0 1 200px; width: auto; }
.form-error { color: var(--bad); min-height: 1.5em; margin-top: 6px; }
.stats { display: flex; gap: 24px; margin-top: 14px; color: var(--muted); } .stats b { color: var(--text); font-size: 1.4rem; margin-right: 4px; }
.section { margin: 32px 0 12px; font-size: 1.2rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.small { padding: 6px 12px; font-size: .875rem; } .btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; } .link.danger { color: var(--bad); }

/* cards + grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid.brands { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid.models { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.parts { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.brand, .model { padding: 18px; color: var(--text); display: block; transition: transform .12s, border-color .12s; }
.brand:hover, .model:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; margin-bottom: 10px; }
.brand p, .model p { margin: 0; color: var(--muted); }
.model-top { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; margin-bottom: 6px; }
.tag { background: var(--brand-soft); color: var(--brand); padding: 2px 10px; border-radius: 99px; font-weight: 700; font-size: .8rem; }
.go { color: var(--brand); font-weight: 600; display: inline-block; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; color: var(--text); }
.chip:hover { border-color: var(--brand); text-decoration: none; } .chip small { color: var(--muted); margin-left: 4px; }

/* parts */
.part { display: flex; flex-direction: column; overflow: hidden; }
.part-link { color: var(--text); display: block; flex: 1; } .part-link:hover { text-decoration: none; }
.tile { --h: 210; background: linear-gradient(135deg, hsl(var(--h) 70% 92%), hsl(var(--h) 60% 80%)); display: grid; place-items: center; height: 110px; font-size: 2.6rem; }
:root[data-theme="dark"] .tile { background: linear-gradient(135deg, hsl(var(--h) 35% 22%), hsl(var(--h) 35% 30%)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile { background: linear-gradient(135deg, hsl(var(--h) 35% 22%), hsl(var(--h) 35% 30%)); } }
.tile.big { height: 100%; min-height: 260px; border-radius: var(--radius); font-size: 6rem; }
.part-body { padding: 12px 14px 4px; }
.part h3 { font-size: 1rem; margin: 2px 0 4px; }
.cat { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.pn { color: var(--muted); font-size: .875rem; font-family: ui-monospace, Consolas, monospace; } .pn.big { font-size: 1rem; }
.part-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px 14px; }
.price { font-weight: 800; font-size: 1.15rem; } .price.quote { font-size: .95rem; color: var(--warn); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.low { background: var(--warn-bg); color: var(--warn); } .badge.out { background: var(--bad-bg); color: var(--bad); }

/* model page */
.model-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; margin-bottom: 16px; gap: 12px; }
.model-head h1 { margin: 6px 0 2px; } .model-head p { margin: 2px 0; }
.stat { text-align: center; } .stat b { display: block; font-size: 2rem; line-height: 1; } .stat span { color: var(--muted); }
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.layout.cart { grid-template-columns: 1fr 340px; }
.filters { padding: 16px; position: sticky; top: 76px; }
.filters h4 { margin: 16px 0 6px; font-size: .85rem; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; } .check small { color: var(--muted); margin-left: auto; }
.filters .btn { margin-top: 14px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.toolbar select { width: auto; margin-left: 6px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin: 14px 0; } .note a { color: inherit; text-decoration: underline; }

/* part detail */
.detail { display: grid; grid-template-columns: 340px 1fr; gap: 28px; margin-top: 12px; }
.detail-main h1 { margin-top: 4px; }
.buy { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.buy .price { font-size: 1.7rem; margin-right: 8px; }
.qty-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.qty { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty button { width: 36px; border: 0; background: var(--bg); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.qty input { width: 52px; border: 0; text-align: center; background: var(--surface); color: var(--text); font: inherit; -moz-appearance: textfield; }
.specs { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 16px 0; }
.specs dt { color: var(--muted); } .specs dd { margin: 0; }

/* cart / checkout */
.lines { overflow: hidden; }
.line { display: grid; grid-template-columns: 64px 1fr auto 90px; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.line:last-child { border-bottom: 0; }
.line .tile { height: 64px; width: 64px; font-size: 1.6rem; border-radius: 10px; }
.line-price { text-align: right; font-weight: 700; }
.order-line { grid-template-columns: 1fr auto; } .order-line:hover { background: var(--brand-soft); text-decoration: none; }
.summary { padding: 18px; position: sticky; top: 76px; } .summary.wide { position: static; margin-top: 16px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.form { padding: 20px; } .form h3 { margin-top: 18px; } .form h3:first-child { margin-top: 0; }
.field { margin-bottom: 12px; } .field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { color: var(--bad); display: block; min-height: 1.2em; }
.radios { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.radio { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; cursor: pointer; }
.radio small { grid-column: 2; color: var(--muted); } .radio:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.success { padding: 28px; text-align: center; } .check-big { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 2rem; margin: 0 auto 10px; }
.ref { font-family: ui-monospace, Consolas, monospace; background: var(--brand-soft); padding: 2px 8px; border-radius: 6px; }
.timeline { display: flex; justify-content: center; gap: 8px; list-style: none; padding: 0; margin: 20px 0 0; flex-wrap: wrap; }
.timeline li { padding: 6px 14px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); } .timeline .done { background: var(--ok-bg); color: var(--ok); border-color: transparent; font-weight: 700; }
.actions { display: flex; gap: 10px; margin-top: 12px; }

.foot { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: .875rem; background: var(--surface); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 30px); background: #14212b; color: #fff; padding: 12px 18px; border-radius: 12px; display: flex; gap: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; } .toast a { color: #8fc6ff; font-weight: 700; }

@media (max-width: 820px) {
  .layout, .layout.cart, .detail { grid-template-columns: 1fr; }
  .filters, .summary { position: static; }
  .tile.big { min-height: 160px; font-size: 4rem; }
  .line { grid-template-columns: 56px 1fr; } .line .qty, .line-price { grid-column: 2; justify-self: start; }
  .two, .radios { grid-template-columns: 1fr; }
  .nav { margin-left: 0; width: 100%; justify-content: space-between; }
  .specs { grid-template-columns: 1fr; gap: 2px; } .specs dd { margin-bottom: 8px; }
}
@media print { .top, .foot, .actions, .stepper, #toast { display: none; } }
