:root {
  --bg: #0b0b0c;
  --bg2: #111113;
  --card: #161618;
  --card2: #1e1e21;
  --line: #2a2a2f;
  --text: #f5f5f6;
  --muted: #9b9ba3;
  --dim: #6c6c74;
  --accent: #ff6b00;
  --accent2: #ff8b33;
  --accent-soft: rgba(255, 107, 0, 0.14);
  --ok: #34d17a;
  --warn: #ffb020;
  --bad: #ff5252;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); text-decoration: none; }
.hidden { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: rgba(11, 11, 12, 0.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 900; letter-spacing: 0.5px; font-size: 20px; }
.logo b { color: var(--accent); }
.top .sub { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
.back { display: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); align-items: center; justify-content: center; }
.top.detail .back { display: inline-flex; }

main { padding: 14px 16px calc(92px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; }

/* Bottom navigation */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(17, 17, 19, 0.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tabs button { background: none; border: 0; padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--dim); font-size: 11px; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--accent); }

/* Common blocks */
h1 { font-size: 22px; margin: 4px 0 12px; line-height: 1.2; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 9px 6px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--accent); color: #111; }
.input, select.input, textarea.input {
  width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none;
}
.input:focus { border-color: var(--accent); }
label.f { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--accent); color: #111; font-weight: 700; cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 7px 13px; font-size: 13px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent2); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 7px; background: rgba(0, 0, 0, 0.62); color: #fff; }
.badge.or { background: var(--accent); color: #111; }
.badge.ok { background: rgba(52, 209, 122, 0.16); color: var(--ok); }
.badge.warn { background: rgba(255, 176, 32, 0.16); color: var(--warn); }
.badge.bad { background: rgba(255, 82, 82, 0.16); color: var(--bad); }
.badge.gray { background: var(--card2); color: var(--muted); }

/* Hero on the home page */
.hero { background: radial-gradient(120% 140% at 100% 0%, rgba(255, 107, 0, 0.28), transparent 55%), var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.hero h1 { margin: 0 0 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.stat b { display: block; font-size: 20px; color: var(--accent2); }
.stat span { font-size: 12px; color: var(--muted); }

/* Car cards */
.list { display: grid; gap: 12px; }
@media (min-width: 560px) { .list { grid-template-columns: 1fr 1fr; } }
.car { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative; }
.car .ph { position: relative; aspect-ratio: 16 / 10; background: var(--card2); overflow: hidden; }
.car .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.car .ph .tl { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
.car .ph .bl { position: absolute; bottom: 8px; left: 8px; }
.heart { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; color: #fff; }
.heart.on { color: var(--accent); }
.heart svg { width: 20px; height: 20px; }
.car .body { padding: 11px 12px 13px; }
.car .t { font-weight: 700; font-size: 15px; line-height: 1.25; }
.car .m { color: var(--muted); font-size: 13px; margin-top: 3px; }
.car .p { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; gap: 8px; }
.car .p b { color: var(--accent2); font-size: 18px; white-space: nowrap; }
.car .p span { color: var(--muted); font-size: 12px; text-align: right; }
.noimg { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--dim); gap: 6px; background: linear-gradient(135deg, #1b1b1e, #121214); }
.noimg svg { width: 64px; height: 64px; opacity: 0.5; }
.hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: 74%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; }
@media (min-width: 560px) { .hscroll { grid-auto-columns: 46%; } }

/* Toolbar of the catalogue */
.toolbar { display: flex; gap: 8px; margin: 12px 0; }
.toolbar .btn { padding: 10px 12px; }
.toolbar select { flex: 1; }
.count { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

/* Detail page */
.gallery { position: relative; margin: 0 -16px; }
.gallery .track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 4 / 3; background: var(--card2); }
.gallery .track::-webkit-scrollbar { display: none; }
.gallery .track img { flex: none; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; }
.gallery .n { position: absolute; right: 12px; bottom: 12px; }
.gallery .heart { top: 12px; right: 12px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 0; scrollbar-width: none; }
.thumbs img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; opacity: 0.55; flex: none; border: 2px solid transparent; }
.thumbs img.on { opacity: 1; border-color: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.price-big { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.price-big b { font-size: 26px; color: var(--accent2); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.facts div { background: var(--card); padding: 10px 12px; }
.facts span { display: block; font-size: 11px; color: var(--muted); }
.facts b { font-weight: 600; font-size: 14px; word-break: break-word; }
.breakdown { width: 100%; border-collapse: collapse; }
.breakdown td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.breakdown td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
.breakdown tr.total td { border-bottom: 0; font-weight: 800; color: var(--accent2); font-size: 17px; padding-top: 10px; }
.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.hist { display: grid; gap: 8px; }
.hist .h { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.hist .h b { color: var(--accent2); }
.posttext { white-space: pre-wrap; font-size: 14px; color: #d8d8dc; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: calc(62px + var(--safe-bottom)); z-index: 25; padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 35%); }
.sticky-cta .btn { width: 100%; max-width: 688px; margin: 0 auto; display: flex; box-shadow: 0 8px 24px rgba(255, 107, 0, 0.25); }
.with-cta { padding-bottom: 150px; }

/* Bottom sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg2); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; max-height: 88vh; overflow-y: auto; padding: 8px 16px calc(16px + var(--safe-bottom)); }
.sheet .grab { width: 40px; height: 4px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { margin-top: 4px; }
.sheet .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; position: sticky; bottom: 0; background: var(--bg2); padding-top: 8px; }
.sharebox { min-height: 220px; resize: vertical; font-size: 14px; line-height: 1.45; }
.sharephotos { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.sharephotos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* States */
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty svg { width: 54px; height: 54px; color: var(--dim); }
.skel { background: linear-gradient(90deg, var(--card) 0%, var(--card2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spin { width: 18px; height: 18px; border: 2px solid rgba(0, 0, 0, 0.25); border-top-color: #111; border-radius: 50%; animation: rot 0.8s linear infinite; }
.btn.ghost .spin { border-color: rgba(255, 255, 255, 0.2); border-top-color: var(--accent); }
@keyframes rot { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60; background: #26262a; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; text-align: center; }
.lock { text-align: center; padding: 60px 20px; }
.lock .logo { font-size: 34px; margin-bottom: 14px; }
.devbar { background: var(--accent-soft); color: var(--accent2); font-size: 12px; text-align: center; padding: 5px; }
