:root {
    --brand: #2563eb; --brand-soft: #6ea0ff;
    --bg: #fff; --fg: #1a1d21; --muted: #667085; --border: #e1e4e8;
    --panel: #f6f7f9; --head: #1f2937; --head-fg: #fff; --accent: #2563eb;
    --accent-bg: #e8efff; --good: #15803d; --row-hover: #f3f6fc;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418; --fg: #e6e8eb; --muted: #98a2b3; --border: #2b313a;
        --panel: #181c22; --head: #0b0d10; --accent: #6ea0ff;
        --accent-bg: #1c2a45; --good: #4ade80; --row-hover: #1a1f27;
    }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font: 15px/1.45 system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

#header { background: var(--head); color: var(--head-fg); padding: 12px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; font-size: 22px; font-weight: 700; letter-spacing: -.02em; color: var(--head-fg); text-decoration: none !important; }
.brand-ram { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8em; background: var(--brand); color: #fff; padding: 2px 7px 3px; border-radius: 5px;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.brand-sep { color: var(--brand-soft); font-weight: 300; margin: 0 3px 0 4px; }
.brand-sorted { font-weight: 600; }
.tagline { font-size: 15px; color: #d5dae1; font-style: italic; }
#last-updated { color: #8b94a3; font-size: 13px; }
.lang { margin-left: auto; font-size: 13px; color: #b6bcc6 !important; border: 1px solid #4b5563; border-radius: 4px; padding: 2px 8px; }
#subtitle { padding: 10px 16px 0; color: var(--muted); font-size: 14px; }
.market { font-size: 13px; color: #b6bcc6; }
.market select { margin-left: 4px; padding: 2px 4px; border-radius: 4px; border: 1px solid #4b5563; background: #111827; color: #fff; font: inherit; }

#stats { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.stat { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; min-width: 160px; }
button.stat:hover { border-color: var(--accent); }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 20px; font-weight: 600; }
.stat.best .value { color: var(--good); }
.stat small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

#layout { display: flex; align-items: flex-start; }
#sidebar { width: 230px; min-width: 230px; padding: 12px; border-right: 1px solid var(--border); position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
.facet { border: 0; border-bottom: 1px solid var(--border); padding: 8px 0 10px; }
.facet legend { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-bottom: 4px; display: flex; gap: 8px; width: 100%; }
.facet label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
.facet label.zero { color: var(--muted); opacity: .55; }
.facet .count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.link { color: var(--accent); font-size: 13px; text-transform: none; letter-spacing: 0; }
.link:hover { text-decoration: underline; }
.more { margin-top: 4px; }

#main { flex: 1; min-width: 0; padding: 12px 16px; }
#toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
#search { flex: 1; max-width: 360px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--fg); font: inherit; }
#product-count { color: var(--muted); font-size: 13px; }
#toggle-filters { display: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; }
#chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; min-height: 4px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); font-size: 13px; font-weight: 500; }
.chip:hover { filter: brightness(.95); }

#table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; font-size: 13px; }
th:last-child { cursor: default; }
th.sort-asc::after { content: " ▲"; font-size: 9px; }
th.sort-desc::after { content: " ▼"; font-size: 9px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ppg { font-weight: 600; }
tbody tr:hover { background: var(--row-hover); }
tr.oos td { color: var(--muted); }
tr.oos .store::after { content: " " attr(data-oos); font-size: 11px; }

.drill { padding: 1px 4px; margin: -1px -4px; border-radius: 4px; }
.drill:hover { background: var(--accent-bg); color: var(--accent); }
.drill.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--good); color: #fff; margin-right: 6px; vertical-align: 1px; }
.buy a { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 600; margin-right: 6px; }
.buy a:hover { text-decoration: none; filter: brightness(1.08); }
.store { border: 1px solid var(--border); }
.amazon { background: #232f3e; color: #fff !important; box-shadow: inset 0 -2px 0 #ff9900; }
@media (prefers-color-scheme: dark) { .amazon { background: #ff9900; color: #000 !important; box-shadow: none; } }
#empty { padding: 24px; color: var(--muted); text-align: center; }
#footer { padding: 12px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.prose { max-width: 760px; padding: 24px 16px 40px; }
.prose h1 { font-size: 24px; margin-bottom: 12px; }
.prose h2 { font-size: 16px; margin: 22px 0 6px; }
.prose p { margin-bottom: 10px; line-height: 1.55; }

@media (max-width: 800px) {
    #layout { flex-direction: column; }
    #sidebar { display: none; width: 100%; min-width: 0; position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
    #sidebar.open { display: block; }
    #toggle-filters { display: inline-block; }
    #main { padding: 8px; }
    .tagline { display: none; }
    #last-updated { width: 100%; order: 3; }
}
@media (max-width: 600px) {
    /* Price, Kit, Form, CL, Brand: still filterable from the sidebar */
    th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4), th:nth-child(6), td:nth-child(6),
    th:nth-child(8), td:nth-child(8), th:nth-child(9), td:nth-child(9) { display: none; }
    #search { min-width: 0; }
    #product-count { width: 100%; }
    tr.oos .store::after { content: ""; }
    th, td { padding: 6px 5px; }
    body { font-size: 14px; }
    #search { width: 0; }
    .buy a { display: block; width: max-content; margin: 2px 0; padding: 2px 6px; }
}
