:root {
  --bg: #f3f4f6; --panel: #ffffff; --panel-2: #f8fafc; --text: #111827; --muted: #6b7280;
  --line: #e5e7eb; --accent: #2563eb; --accent-2: #1d4ed8; --accent-soft: #dbeafe;
  --good: #15803d; --bad: #b91c1c; --warn: #b45309; --head: #1f2937; --head-text: #f9fafb;
  --row-hover: #f1f5f9; --chip: #eef2ff; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --panel: #131a26; --panel-2: #0f1520; --text: #e5e7eb; --muted: #9ca3af;
    --line: #243042; --accent: #60a5fa; --accent-2: #93c5fd; --accent-soft: #1e3a5f;
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24; --head: #0f1520; --head-text: #f9fafb;
    --row-hover: #1a2333; --chip: #1e293b; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17; --panel: #131a26; --panel-2: #0f1520; --text: #e5e7eb; --muted: #9ca3af;
  --line: #243042; --accent: #60a5fa; --accent-2: #93c5fd; --accent-soft: #1e3a5f;
  --good: #4ade80; --bad: #f87171; --warn: #fbbf24; --head: #0f1520; --head-text: #f9fafb;
  --row-hover: #1a2333; --chip: #1e293b; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0; }

.btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--head-text); border-color: rgba(255,255,255,.25); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* header */
.top { background: var(--head); color: var(--head-text); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1600px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 16px; align-items: center; }
.logo { font-weight: 800; font-size: 20px; color: var(--head-text); letter-spacing: -.5px; white-space: nowrap; }
.logo span { color: #60a5fa; }
.logo:hover { text-decoration: none; }
.search { flex: 1; }
.search input { width: 100%; padding: 8px 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: var(--head-text); font: inherit; }
.search input::placeholder { color: #9ca3af; }
.top nav { display: flex; gap: 8px; }
#compareCount { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }

/* layout */
main { max-width: 1600px; margin: 0 auto; padding: 16px; }
.layout { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow: auto; }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.close-filters, .open-filters { display: none; }

.fsec { border-bottom: 1px solid var(--line); }
.fsec > summary { list-style: none; cursor: pointer; padding: 10px 14px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; user-select: none; }
.fsec > summary::-webkit-details-marker { display: none; }
.fsec > summary::after { content: "▸"; color: var(--muted); transition: transform .15s; }
.fsec[open] > summary::after { transform: rotate(90deg); }
.fsec .active-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; display: inline-block; margin-left: 6px; }
.fbody { padding: 0 14px 12px; }
.fbody input[type=search] { width: 100%; margin-bottom: 6px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); color: var(--text); font: inherit; }
.opt { display: flex; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
.opt input { margin: 0; accent-color: var(--accent); }
.opt .lbl { flex: 1; 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; }
.more { margin-top: 4px; }

.range { display: grid; gap: 8px; }
.range .inputs { display: flex; gap: 6px; align-items: center; }
.range .inputs input { width: 100%; padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); color: var(--text); font: inherit; }
.dual { position: relative; height: 22px; }
.dual input[type=range] { position: absolute; left: 0; right: 0; top: 0; width: 100%; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; height: 22px; }
.dual input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); cursor: pointer; position: relative; z-index: 2; }
.dual input[type=range]::-moz-range-thumb { pointer-events: auto; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); cursor: pointer; }
.dual .track { position: absolute; left: 0; right: 0; top: 9px; height: 4px; background: var(--line); border-radius: 2px; }
.dual .fill { position: absolute; top: 9px; height: 4px; background: var(--accent); border-radius: 2px; }
.range .unk { font-size: 12px; }

/* results */
.results { min-width: 0; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.controls select { padding: 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.cols { position: relative; }
.cols summary { list-style: none; }
.cols summary::-webkit-details-marker { display: none; }
#colPicker { position: absolute; right: 0; top: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; z-index: 10; min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--chip); border: 1px solid var(--line); border-radius: 14px; padding: 2px 6px 2px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }

.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; background: var(--panel-2); position: sticky; top: 0; }
.grid th.sorted { color: var(--accent); }
.grid th .arr { font-size: 10px; margin-left: 2px; }
.grid td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid td.name { min-width: 260px; }
.grid .pname { font-weight: 600; color: var(--text); display: block; }
.grid .pname:hover { color: var(--accent); }
.grid .sub { font-size: 12px; color: var(--muted); }
.grid td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid td.price { text-align: right; white-space: nowrap; }
.grid td.price b { font-size: 15px; }
.grid td.nowrap { white-space: nowrap; }
.grid td.wrap { max-width: 190px; }
.grid .mob { display: none; }
.thumb { width: 56px; height: 42px; object-fit: contain; background: #fff; border-radius: 4px; display: block; }
.thumb.ph { background: var(--panel-2); }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); margin-right: 4px; white-space: nowrap; }
.tag.dgpu { color: var(--good); border-color: currentColor; }
.tag.oled { color: #a855f7; border-color: currentColor; }
.tag.cfg { color: var(--warn); border-color: currentColor; }
.stores { font-size: 12px; color: var(--muted); }
.cmp-box { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: center; gap: 6px; padding: 14px; flex-wrap: wrap; }
.pager button[aria-current] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* product page */
.crumbs { margin-bottom: 10px; font-size: 13px; }
.pp { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 16px; }
.pp .img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; border-radius: 6px; }
.pp h1 { font-size: 22px; margin-bottom: 6px; }
.big-price { font-size: 28px; font-weight: 800; }
.offers { width: 100%; border-collapse: collapse; margin-top: 8px; }
.offers th, .offers td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.offers th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.offers td.p { font-weight: 700; white-space: nowrap; }
.stock-in { color: var(--good); } .stock-out { color: var(--bad); }
.was { text-decoration: line-through; color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.specs { width: 100%; border-collapse: collapse; }
.specs th { text-align: left; width: 34%; color: var(--muted); font-weight: 500; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.specs td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.specs tr.grp th { color: var(--text); font-weight: 700; padding-top: 16px; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.section-title { margin: 18px 0 8px; }
.hist svg { width: 100%; height: 160px; display: block; }
.hist .axis { fill: var(--muted); font-size: 11px; }
.inferred { color: var(--muted); font-size: 11px; margin-left: 6px; }

/* compare */
.cmp { overflow-x: auto; }
.cmp table { border-collapse: collapse; min-width: 100%; }
.cmp th, .cmp td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; min-width: 200px; }
.cmp th:first-child { min-width: 140px; color: var(--muted); font-weight: 500; position: sticky; left: 0; background: var(--panel); }
.cmp tr.diff td { background: var(--accent-soft); }
.cmp img { width: 140px; height: 100px; object-fit: contain; background: #fff; border-radius: 4px; }

.foot { max-width: 1600px; margin: 0 auto; padding: 20px 16px 40px; font-size: 12px; display: grid; gap: 6px; color: var(--muted); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: fixed; inset: 0; z-index: 50; max-height: none; border-radius: 0; display: none; }
  .filters.open { display: block; }
  .close-filters, .open-filters { display: inline-flex; }
  .pp { grid-template-columns: 1fr; }
  .grid .hide-sm { display: none; }
}
@media (max-width: 700px) {
  .grid thead { display: none; }
  .grid td:not(.name):not(.price):not(.cmp) { display: none; }
  .grid td.name { min-width: 0; }
  .grid .mob { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
  .thumb { width: 44px; height: 34px; }
  .top-inner { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; }
  .top nav { margin-left: auto; }
}
.builds { font-size: 12px; margin-top: 2px; }
