/* HitRadar — one stylesheet, tokens first. */
:root {
  --bg: #f6f4ee; --surface: #ffffff; --surface-2: #efece4; --ink: #15201d; --muted: #5d6763;
  --line: #e0dcd1; --accent: #0e7c5a; --accent-ink: #ffffff; --warm: #b45309;
  --hot: #0e7c5a; --good: #2f8f6b; --ok: #9a6b12; --low: #8a8f8c;
  --up: #0e7c5a; --down: #b42318; --radius: 14px; --shadow: 0 1px 2px rgba(20, 30, 25, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1513; --surface: #151f1c; --surface-2: #1c2825; --ink: #e8efe9; --muted: #9aa8a2;
    --line: #26332f; --accent: #3ddc97; --accent-ink: #062016; --warm: #ffb547;
    --hot: #3ddc97; --good: #6fcfa6; --ok: #e9b44c; --low: #7d8a85; --up: #3ddc97; --down: #ff7b6b;
    --shadow: none; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 'Anuphan', system-ui, sans-serif; }
a { color: inherit; }
img { max-width: 100%; display: block; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
h1, h2 { line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

.site-header { background: #10221f; color: #e8efe9; }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #3ddc97;
  background: radial-gradient(circle, transparent 38%, rgba(61, 220, 151, .35) 40%, transparent 44%); position: relative; }
.brand-mark::after { content: ''; position: absolute; left: 50%; top: 50%; width: 11px; height: 2px; background: #ffb547;
  transform-origin: left center; transform: rotate(-40deg); border-radius: 2px; }
.nav { display: flex; gap: 18px; font-size: .95rem; }
.nav a { text-decoration: none; opacity: .85; }
.nav a:hover { opacity: 1; text-decoration: underline; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; font-size: .88rem; }
.site-footer p { margin: 0 0 6px; }

.hero h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; max-width: 60ch; }
.stats { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: .92rem; }
.stats strong { color: var(--ink); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; scrollbar-width: thin; }
.chip { flex: none; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; font-size: .9rem; white-space: nowrap; }
.chip-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 10px; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); min-width: 0; }
.field input, .field select { font: inherit; font-size: .95rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; min-height: 42px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-ghost { display: inline-flex; align-items: center; min-height: 42px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }
.result-meta { margin: 16px 0 8px; font-size: .9rem; }

.rank-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.rank-head, .rank-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 76px 110px 96px 86px 110px; gap: 10px; align-items: center; padding: 10px 14px; }
.rank-head { font-size: .78rem; color: var(--muted); background: var(--surface-2); }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-row { border-top: 1px solid var(--line); }
.rank-row:hover { background: var(--surface-2); }
.rank-pos { font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.rank-main { display: flex; gap: 12px; align-items: center; text-decoration: none; min-width: 0; }
.rank-main img, .img-ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.rank-text { display: flex; flex-direction: column; min-width: 0; }
.rank-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; line-height: 1.4; }
.rank-main:hover .rank-name { text-decoration: underline; }
.rank-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; font-size: .95rem; }
.cell small { color: var(--muted); }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radius); }

.score { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 700;
  border: 3px solid currentColor; font-variant-numeric: tabular-nums; }
.score-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.score-hot { color: var(--hot); background: color-mix(in srgb, var(--hot) 12%, transparent); }
.score-good { color: var(--good); }
.score-ok { color: var(--ok); }
.score-low { color: var(--low); }
.move { font-weight: 600; font-size: .9rem; }
.move-up { color: var(--up); } .move-down { color: var(--down); } .move-flat { color: var(--muted); }
.move-new { color: var(--warm); }
.mall { display: inline-block; padding: 0 6px; border-radius: 4px; background: #b42318; color: #fff; font-size: .72rem; font-weight: 700; line-height: 1.5; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

.crumbs { font-size: .88rem; margin-bottom: 12px; }
.product-head { display: grid; grid-template-columns: 320px 1fr; gap: 24px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.product-img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--surface-2); }
.product-info h1 { font-size: clamp(1.15rem, 2.6vw, 1.5rem); margin: 0 0 6px; }
.price-row { display: flex; align-items: baseline; gap: 10px; margin: 10px 0; }
.price { font-size: 1.7rem; }
.discount { color: var(--down); font-weight: 600; }
.score-row { display: flex; gap: 14px; align-items: center; margin: 14px 0; }
.score-row p { margin: 0; }
.btn-buy { width: 100%; max-width: 340px; min-height: 50px; font-size: 1.05rem; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.fact, .card, .chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.fact { display: flex; flex-direction: column; gap: 2px; }
.fact strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: .92rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-scale { display: flex; justify-content: space-between; font-size: .8rem; margin-top: 4px; }
.chart-single strong { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.note { font-size: .85rem; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }
.breakdown { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.breakdown li { display: grid; grid-template-columns: 170px 1fr 110px; gap: 12px; align-items: center; }
.bd-bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bd-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bd-value { text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.related { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.related a { display: flex; flex-direction: column; gap: 6px; text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; height: 100%; font-size: .85rem; }
.related img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.related span:not(.score) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.related .score { width: 36px; height: 36px; font-size: .85rem; margin-top: auto; }

.prose { max-width: 760px; }
.prose h1 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; font-size: .93rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--surface-2); }

@media (max-width: 960px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: 1 / -1; }
  .filter-actions { grid-column: 1 / -1; }
  .filter-actions .btn { flex: 1; }
  .rank-head { display: none; }
  .rank-row { grid-template-columns: 30px repeat(4, minmax(0, 1fr)) auto; row-gap: 8px;
    grid-template-areas: 'pos main main main main score' 'pos c1 c2 c3 c4 c4'; }
  .rank-pos { grid-area: pos; align-self: start; padding-top: 16px; }
  .rank-main { grid-area: main; }
  .cell-score { grid-area: score; }
  .c-sold { grid-area: c1; } .c-move { grid-area: c2; } .c-price { grid-area: c3; } .c-comm { grid-area: c4; }
  .rank-row .cell:not(.cell-score) { font-size: .88rem; }
  .rank-row > .cell:not(.cell-score)::before { content: attr(data-label); font-size: .72rem; color: var(--muted); }
  .product-head { grid-template-columns: 1fr; }
  .product-img { max-width: 360px; margin: 0 auto; }
  .facts { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .related { grid-template-columns: repeat(3, 1fr); }
  .breakdown li { grid-template-columns: 120px 1fr 90px; }
}
@media (max-width: 420px) {
  .rank-main img, .img-ph { width: 48px; height: 48px; }
  .rank-row > .cell small { display: none; }
  .related { grid-template-columns: repeat(2, 1fr); }
  .breakdown li { grid-template-columns: 1fr 80px; }
  .bd-bar { grid-column: 1 / -1; grid-row: 2; }
}
