/* Reusable widgets: score gauge, badges, ranking table, filters, cards, tabs, category board, charts. */

/* score gauge, movement, mall */
.gauge { --v: 0; --c: var(--brand); position: relative; display: inline-grid; place-items: center; width: 46px; height: 46px;
  border-radius: 50%; background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--low) 0); flex: none; }
.gauge::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.gauge b { position: relative; font-family: var(--mono); font-size: .9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.gauge-lg { width: 76px; height: 76px; }
.gauge-lg::before { inset: 7px; }
.gauge-lg b { font-size: 1.4rem; }
.tier-hot { --c: var(--hot); } .tier-hot b { color: var(--brand-strong); }
.tier-good { --c: var(--good); } .tier-ok { --c: var(--ok); } .tier-low { --c: var(--low); } .tier-low b { color: var(--muted); }
.move { font-family: var(--mono); font-weight: 600; font-size: .86rem; }
.move-up { color: var(--up); } .move-down { color: var(--down); } .move-flat { color: var(--muted); font-weight: 500; }
.move-new { font-family: 'IBM Plex Sans Thai', sans-serif; display: inline-block; width: fit-content; padding: 0 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-size: .74rem; }
.mall { display: inline-block; padding: 0 6px; border-radius: 4px; background: #d0011b; color: #fff; font-family: var(--mono);
  font-size: .66rem; font-weight: 600; line-height: 1.6; letter-spacing: .03em; vertical-align: 1px; }

/* filters */
.chips, .presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 16px;
  background: var(--tint); border-radius: var(--radius); padding: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); min-width: 0; }
.field input, .field select { font: inherit; font-size: .93rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 8px 10px; width: 100%; min-height: 44px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }

/* ranking table */
.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) 64px 112px 92px 84px 104px; gap: 12px; align-items: center; padding: 10px 16px; }
.rank-head { font-size: .76rem; font-weight: 600; color: var(--muted); background: var(--tint); border-bottom: 1px solid var(--line); }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-row + .rank-row { border-top: 1px solid var(--line); }
.rank-row:hover { background: #fffaf6; }
.rank-pos { font-family: var(--mono); font-weight: 600; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rank-row:nth-child(-n + 3) .rank-pos { color: var(--brand-strong); }
.rank-main { display: flex; gap: 12px; align-items: center; text-decoration: none; min-width: 0; }
.rank-main img, .rank-main .img-ph { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.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; font-size: .95rem; }
.rank-main:hover .rank-name { color: var(--brand-strong); }
.rank-sub { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell { display: flex; flex-direction: column; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .92rem; font-weight: 500; min-width: 0; }
.cell small { font-family: 'IBM Plex Sans Thai', sans-serif; color: var(--muted); font-weight: 400; font-size: .74rem; }
.cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--tint); border-radius: var(--radius); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-family: var(--mono); font-size: .88rem; }

/* product cards */
.pgrid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.pcard a { display: flex; flex-direction: column; height: 100%; text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s; }
.pcard a:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.pcard-media { position: relative; display: block; aspect-ratio: 1; background: var(--tint); }
.pcard-media img, .pcard-media .img-ph { width: 100%; height: 100%; object-fit: cover; }
.pcard-score { position: absolute; left: 8px; bottom: 8px; }
.pcard-score .gauge { box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .35); }
.pcard-off { position: absolute; top: 8px; right: 8px; background: var(--brand); color: var(--on-brand); font-family: var(--mono);
  font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pcard-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; flex: 1; }
.pcard-cat { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9rem; line-height: 1.45; font-weight: 500; }
.pcard-price { font-size: 1.05rem; font-weight: 600; color: var(--brand-strong); margin-top: auto; }
.pcard-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .76rem; color: var(--muted); }

/* CSS-only tabs */
.tab-radio { position: absolute; opacity: 0; pointer-events: none; }
.tab-bar { display: flex; gap: 6px; overflow-x: auto; padding: 4px; margin-bottom: 14px; background: var(--tint); border-radius: 999px; width: fit-content; max-width: 100%; }
.tab { flex: none; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab-panel { display: none; }
#pick-score:checked ~ .tab-bar .tab-score, #pick-rising:checked ~ .tab-bar .tab-rising,
#pick-commission:checked ~ .tab-bar .tab-commission, #pick-sold:checked ~ .tab-bar .tab-sold {
  background: var(--surface); color: var(--brand-strong); font-weight: 600; box-shadow: 0 2px 8px -4px rgba(0, 0, 0, .25); }
#pick-score:checked ~ .panel-score, #pick-rising:checked ~ .panel-rising,
#pick-commission:checked ~ .panel-commission, #pick-sold:checked ~ .panel-sold { display: block; }
#pick-score:focus-visible ~ .tab-bar .tab-score, #pick-rising:focus-visible ~ .tab-bar .tab-rising,
#pick-commission:focus-visible ~ .tab-bar .tab-commission, #pick-sold:focus-visible ~ .tab-bar .tab-sold { outline: 2px solid var(--brand); }
.more-link { display: inline-block; margin-top: 12px; color: var(--brand-strong); font-weight: 500; text-decoration: none; }
.more-link:hover { text-decoration: underline; }

/* category leaderboard */
.catboard { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.catboard a { display: grid; grid-template-columns: 28px 48px minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.catboard a:hover { border-color: var(--brand); }
.catboard img, .catboard .img-ph { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.cb-pos { color: var(--brand-strong); font-weight: 600; text-align: center; }
.cb-text { display: flex; flex-direction: column; min-width: 0; }
.cb-text .muted { font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-score { display: flex; align-items: center; gap: 8px; }
.cb-bar, .bd-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--tint-2); overflow: hidden; }
.cb-bar span, .bd-bar span { display: block; height: 100%; background: linear-gradient(90deg, #ffb27a, var(--brand)); border-radius: 99px; }
.cb-score b { width: 38px; text-align: right; }

/* charts + score breakdown */
.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: .9rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; }
.chart-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.chart-scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .76rem; margin-top: 4px; }
.chart-single strong { display: block; font-family: var(--mono); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.note { font-size: .84rem; color: var(--muted); background: var(--tint); border-left: 3px solid var(--brand); border-radius: 6px; 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-value { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .86rem; }
