:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #121826;
  --muted: #5b6474;
  --line: #e2e6ec;
  --brand: #0f2340;
  --accent: #f26a1b;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --ok: #157f3b;
  --ok-soft: #e6f6ec;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #1f5fbf;
  --info-soft: #e8f0fc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b24;
    --surface-2: #1c2430;
    --text: #e8ecf2;
    --muted: #9aa4b2;
    --line: #2a3340;
    --brand: #e8ecf2;
    --accent: #ff7a2e;
    --accent-soft: #3a2416;
    --ok: #4ac27a;
    --ok-soft: #13301f;
    --warn: #f0b44c;
    --warn-soft: #33270f;
    --bad: #ff7b6e;
    --bad-soft: #3a1714;
    --info: #79a8ff;
    --info-soft: #142640;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); text-decoration: none; font-weight: 700; white-space: nowrap; letter-spacing: -.01em; }
.brand b { color: var(--accent); }
.brand-mark { width: 32px; height: 32px; }
.brand-mark rect { fill: var(--accent); stroke: none; }
.brand-mark path { stroke: #fff; stroke-width: 2; }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; border: 0; background: transparent; padding: 10px 0; outline: none; min-width: 0; }
.topnav { margin-left: auto; display: flex; gap: 6px; }
.navbtn { background: transparent; border: 1px solid transparent; padding: 8px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.navbtn:hover { background: var(--surface-2); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }

.sample-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); padding: 10px 24px; font-size: 14px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; max-width: 1480px; margin: 0 auto; padding: 20px 24px 120px; }

/* ---------- filters ---------- */
.filters { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.filters-head h2 { margin: 0; font-size: 16px; flex: 1; }
.filters-foot { display: none; }
.close-filters { display: none; }
.fsec { border-bottom: 1px solid var(--line); }
.fsec:last-child { border-bottom: 0; }
.fsec > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-weight: 600; cursor: pointer; user-select: none; }
.fsec > summary::-webkit-details-marker { display: none; }
.fsec > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.fsec[open] > summary::after { transform: rotate(-135deg); }
.fsec .sel { font-size: 12px; font-weight: 700; color: var(--accent); }
.fbody { padding: 0 16px 14px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.opt input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.opt .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.opt.zero { opacity: .45; }
.opt .hide { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; font-size: 11px; padding: 1px 6px; color: var(--muted); }
.opt .hide[aria-pressed="true"] { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.opt.excluded .lbl { text-decoration: line-through; color: var(--muted); }
.fsearch { width: 100%; padding: 7px 10px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.more { margin-top: 4px; }
.group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 0 2px; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.range input, .range select { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.qbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 4px; font-size: 13px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.switch input { width: 36px; height: 20px; accent-color: var(--accent); }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.linkbtn { border: 0; background: transparent; color: var(--accent); font-weight: 600; padding: 4px; }
.iconbtn { border: 0; background: transparent; font-size: 26px; line-height: 1; padding: 2px 8px; border-radius: 8px; color: var(--muted); }
.iconbtn:hover { background: var(--surface-2); }

/* ---------- results ---------- */
.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: thin; }
.preset { flex: none; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
.preset[aria-pressed="true"] { background: var(--brand); color: var(--surface); border-color: var(--brand); }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.count { margin: 0; font-weight: 700; font-size: 17px; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.open-filters { display: none; }
.sort { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.sort select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.viewtoggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.viewtoggle button { border: 0; background: var(--surface); padding: 6px 8px; display: grid; place-items: center; }
.viewtoggle button[aria-pressed="true"] { background: var(--surface-2); color: var(--accent); }
.viewtoggle svg { width: 18px; height: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--text); border: 1px solid transparent; border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.chip.neg { background: var(--bad-soft); }
.chip button { border: 0; background: transparent; width: 20px; height: 20px; border-radius: 50%; line-height: 1; font-size: 16px; color: var(--muted); }
.chip button:hover { background: rgba(0, 0, 0, .08); color: var(--text); }
.alert { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 12px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(16, 24, 40, .08), 0 10px 28px rgba(16, 24, 40, .1); }
.card .media { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); }
.card .media img, .card .media svg.car { width: 100%; height: 100%; object-fit: cover; display: block; }
.badges { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: rgba(15, 35, 64, .85); color: #fff; }
.badge.sample { background: var(--warn); color: #fff; }
.watch { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); display: grid; place-items: center; color: #5b6474; box-shadow: var(--shadow); }
.watch svg { width: 20px; height: 20px; }
.watch[aria-pressed="true"] { color: var(--accent); }
.watch[aria-pressed="true"] svg { fill: var(--accent); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 16px; line-height: 1.3; }
.card h3 button { all: unset; cursor: pointer; }
.card h3 button:hover { color: var(--accent); }
.card h3 button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.price { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line); }
.price .k { font-size: 12px; color: var(--muted); }
.price .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.price .bn { text-align: right; }
.price .bn .v { font-size: 15px; color: var(--ok); }
.sale { font-size: 13px; font-weight: 600; }
.sale.soon { color: var(--bad); }
.cmp { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cmp input { accent-color: var(--accent); }

.grid.list { grid-template-columns: 1fr; }
.grid.list .card { flex-direction: row; }
.grid.list .card .media { width: 280px; flex: none; aspect-ratio: auto; }

.skeleton { height: 340px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 400% 100%; animation: sk 1.2s infinite; border: 1px solid var(--line); }
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }
.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { margin: 0 0 6px; }
.empty .quick { justify-content: center; margin-top: 14px; }

.pager { display: flex; justify-content: center; gap: 6px; margin: 24px 0; flex-wrap: wrap; }
.pager button { min-width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; font-weight: 600; }
.pager button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pager button:disabled { opacity: .4; cursor: default; }

/* ---------- compare tray ---------- */
.compare-tray { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 25; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: 0 10px 40px rgba(16, 24, 40, .25); max-width: calc(100vw - 32px); }
.compare-items { display: flex; gap: 8px; overflow-x: auto; }
.citem { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 4px 4px 4px 10px; font-size: 13px; white-space: nowrap; }
.citem button { border: 0; background: transparent; font-size: 16px; color: var(--muted); }

/* ---------- drawer & modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 50; overflow: auto; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); }
.drawer-close { position: absolute; right: 10px; top: 10px; z-index: 2; background: var(--surface); }
.dmedia { aspect-ratio: 16 / 9; background: var(--surface-2); }
.dmedia svg.car, .dmedia img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dbody { padding: 18px 22px 32px; display: flex; flex-direction: column; gap: 16px; }
.dbody h2 { margin: 0; font-size: 22px; line-height: 1.25; }
.salebox { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: var(--surface-2); border-radius: var(--radius); padding: 14px; }
.salebox .k { font-size: 12px; color: var(--muted); }
.salebox .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.salebox .full { grid-column: 1 / -1; }
.salebox .btn { width: 100%; padding: 12px; }
.note { font-size: 13px; color: var(--muted); margin: 0; }
.specs { width: 100%; border-collapse: collapse; font-size: 14px; }
.specs th { text-align: left; font-weight: 500; color: var(--muted); padding: 7px 0; width: 42%; border-bottom: 1px solid var(--line); }
.specs td { padding: 7px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.copy { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; font-size: 12px; padding: 1px 8px; margin-left: 8px; }
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(10, 15, 25, .5); }
.modal-card { background: var(--surface); border-radius: 16px; width: min(980px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 16px 18px 22px; }
.ctable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ctable th, .ctable td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ctable thead th { font-size: 15px; }
.ctable tbody th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.ctable td.best { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.savedlist, .watchlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.savedlist li, .watchlist li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.savedlist .grow, .watchlist .grow { flex: 1; min-width: 0; }
.savedlist .sub, .watchlist .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saveform { display: flex; gap: 8px; margin-bottom: 14px; }
.saveform input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }

.footer { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; max-width: 1480px; margin: 0 auto; padding: 24px; font-size: 13px; border-top: 1px solid var(--line); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 120px; }
  .filters { position: fixed; inset: 0; z-index: 55; max-height: none; border-radius: 0; display: none; }
  .filters.open { display: block; }
  .filters-foot { display: block; position: sticky; bottom: 0; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); }
  .filters-foot .btn { width: 100%; padding: 12px; }
  .close-filters { display: block; }
  .open-filters { display: inline-flex; align-items: center; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .sample-banner { padding: 10px 16px; }
}
@media (max-width: 640px) {
  .brand span { display: none; }
  .toolbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  #saveSearch { display: none; }
  .grid.list .card { flex-direction: column; }
  .grid.list .card .media { width: 100%; aspect-ratio: 16 / 10; }
  .navbtn { padding: 8px; }
}
