/* ---------- Deals ---------- */
.deals-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.deals-search { flex: 1 1 240px; max-width: 340px; }
#deals-reset { margin-left: 2px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.stat { position: relative; min-width: 0; padding: 12px 16px 13px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.stat-value { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-value.good { color: var(--green); }
.stat-sub { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sub b { color: var(--ink-2); font-weight: 700; }
.hist { position: absolute; right: 16px; bottom: 14px; display: flex; align-items: flex-end; gap: 3px; height: 30px; }
.hist span { width: 7px; min-height: 2px; height: var(--h); border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--green) 35%, var(--line)); }
.hist span.peak { background: var(--green-bar); }
.stat-hist .stat-sub { padding-right: 56px; }
.stat-skel { height: 58px; margin: 12px 16px; }

.deals-layout { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 20px; align-items: start; margin-top: 14px; }
.deals-main { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.deals-main, .table-head, .deal-row { --cols: 40px minmax(0, 1fr) minmax(0, 150px) 76px 92px 132px; }
.table-head { display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center; height: 34px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--sunken); font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.table-head > span:first-child { grid-column: span 2; }
.table-head .r { text-align: right; }
.spread-legend { display: flex; align-items: center; gap: 5px; justify-content: flex-end; white-space: nowrap; }
.spread-legend .dot + .dot, .spread-legend .dot:not(:first-child) { margin-left: 6px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.deal { background: var(--green); }

.deal-list > li + li { border-top: 1px solid var(--line); }
.deal-row { display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center; width: 100%; min-height: 56px; padding: 8px 14px; text-align: left; transition: background var(--t); }
.deal-row:hover { background: var(--sunken); }
.deal-row[aria-expanded="true"] { background: var(--sunken); }
.deal-row .thumb { width: 40px; height: 40px; }
.deal-title { min-width: 0; }
.deal-name { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-meta { display: flex; gap: 6px; align-items: center; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; }
.deal-meta .sep { width: 2px; height: 2px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.deal-meta .promo { color: var(--green-ink); font-weight: 700; }
.deal-store { min-width: 0; font-size: var(--fs-sm); font-weight: 500; }
.deal-store span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-store small { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-price { text-align: right; font-variant-numeric: tabular-nums; }
.deal-price strong { display: block; font-weight: 600; }
.deal-price small { display: block; font-size: var(--fs-xs); color: var(--muted); }
.deal-off { text-align: right; font-variant-numeric: tabular-nums; }
.off-pill { display: inline-block; padding: 1px 7px; border-radius: var(--r-pill); background: var(--green-soft); color: var(--green-ink); font-weight: 600; font-size: var(--fs-sm); }
.deal-off small { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); }

.spread { position: relative; height: 22px; }
.spread::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--line-strong); }
.spread .seg-line { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: color-mix(in srgb, var(--green) 40%, transparent); }
.spread i { position: absolute; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--faint); }
.spread i.deal { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: var(--green); box-shadow: 0 0 0 2px var(--surface); }
.spread .median { position: absolute; top: 3px; bottom: 3px; width: 1.5px; margin-left: -.75px; background: var(--ink-2); border-radius: 1px; }

.deal-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 6px 14px 16px 66px; background: var(--sunken); }
.detail-title { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.ladder { display: grid; gap: 3px; }
.rung { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr) 64px; gap: 10px; align-items: center; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.rung span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.rung b { height: 6px; border-radius: 3px; width: var(--w); background: var(--line-strong); }
.rung.is-deal span, .rung.is-deal em { color: var(--green-ink); font-weight: 700; }
.rung.is-deal b { background: var(--green-bar); }
.rung em { font-style: normal; text-align: right; color: var(--ink-2); font-weight: 600; }
.detail-why { display: grid; gap: 10px; align-content: start; font-size: var(--fs-sm); color: var(--ink-2); }
.detail-why .row { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-why .actions { display: flex; gap: 8px; align-items: center; }

.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.list-foot:has(#deals-count:empty):has(#deals-more[hidden]) { display: none; }
.deal-empty { padding: 32px 20px; text-align: center; display: grid; gap: 8px; justify-items: center; color: var(--ink-2); }
.deal-empty h3 { font-size: var(--fs-md); color: var(--ink); }
.deal-skel { display: grid; grid-template-columns: 40px minmax(0, 1fr) 200px; gap: 12px; align-items: center; padding: 8px 14px; height: 56px; }
.deal-skel + .deal-skel { border-top: 1px solid var(--line); }

.deals-side { display: grid; gap: 12px; position: sticky; top: 72px; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 12px 14px 12px; display: grid; gap: 8px; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.side-head h2 { font-size: var(--fs); }
.side-note { padding: 0 4px; }
.bars { display: grid; gap: 1px; }
.hbar { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 26px; padding: 0 6px; margin: 0 -6px; border-radius: var(--r-sm); font-size: var(--fs-sm); text-align: left; width: calc(100% + 12px); font-variant-numeric: tabular-nums; }
.hbar::before { content: ''; position: absolute; left: 0; top: 3px; bottom: 3px; width: var(--w); border-radius: var(--r-sm); background: color-mix(in srgb, var(--green) 9%, var(--sunken)); z-index: 0; transition: background var(--t); }
.hbar > * { position: relative; z-index: 1; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 500; }
.hbar em { font-style: normal; font-weight: 600; color: var(--ink); }
button.hbar:hover::before { background: color-mix(in srgb, var(--green) 16%, var(--sunken)); }
.hbar.active::before { background: var(--green-soft); }
.hbar.active span, .hbar.active em { color: var(--green-ink); }
.side-more { justify-self: start; }

.idx { display: grid; gap: 0; }
.idx-row { display: grid; grid-template-columns: minmax(0, 104px) minmax(0, 1fr) 44px; gap: 8px; align-items: center; min-height: 22px; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.idx-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 500; }
.idx-row > em { font-style: normal; text-align: right; font-weight: 600; }
.idx-track { position: relative; height: 12px; }
.idx-track::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-strong); }
.idx-track b { position: absolute; top: 3px; height: 6px; border-radius: 3px; }
.idx-row.cheap b { background: var(--green-bar); }
.idx-row.cheap > em { color: var(--green-ink); }
.idx-row.dear b { background: color-mix(in srgb, var(--amber) 70%, var(--line)); }
.idx-row.small > span { color: var(--muted); font-weight: 500; }
.idx-row.even b { background: var(--muted); }
.idx-row.even > em { color: var(--muted); font-weight: 500; }
.idx-row.dear > em { color: var(--amber); }

@media (max-width: 1100px) {
  .deals-main, .table-head, .deal-row { --cols: 40px minmax(0, 1fr) minmax(0, 120px) 72px 88px 108px; }
}
@media (max-width: 960px) {
  .deals-layout { grid-template-columns: minmax(0, 1fr); }
  .deals-side { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .side-note { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 680px) {
  .deals-search { max-width: none; flex-basis: 100%; }
  .deals-toolbar .select { flex: 1 1 30%; }
  .deals-toolbar .select select { width: 100%; max-width: none; }
  .table-head { display: none; }
  .deal-row { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "img title off" "img store price"; row-gap: 2px; }
  .deal-row .thumb { grid-area: img; align-self: start; }
  .deal-title { grid-area: title; }
  .deal-store { grid-area: store; display: flex; gap: 4px; font-size: var(--fs-xs); }
  .deal-store small { display: none; }
  .deal-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .deal-price { grid-area: price; display: flex; gap: 6px; align-items: baseline; justify-content: flex-end; }
  .deal-price small { display: inline; }
  .deal-off { grid-area: off; }
  .deal-off small { display: none; }
  .deal-row .spread { display: none; }
  .deal-detail { grid-template-columns: minmax(0, 1fr); padding-left: 14px; }
  .deals-side { grid-template-columns: minmax(0, 1fr); }
}

.idx-gap { font-size: var(--fs-xs); color: var(--faint); padding: 2px 0; text-align: center; border-block: 1px dashed var(--line); margin: 3px 0; }
.deals-scope { margin-left: auto; }
@media (max-width: 1100px) { .deals-scope { display: none; } }
@media (max-width: 680px) {
  .select-prefix { display: none; }
  .select.sort select { padding-left: 10px; }
  .stat-sub { white-space: normal; }
}
