:root {
  --ink: #0e1a22;
  --ink-soft: #3d4f5c;
  --muted: #6b7c88;
  --line: #c9d4dc;
  --paper: #f3f6f8;
  --surface: #ffffff;
  --teal: #0a6f5c;
  --teal-soft: #d8f0ea;
  --amber: #b45309;
  --amber-soft: #fde8d0;
  --midodo: #1d4e89;
  --huamao: #7a3e12;
  --shadow: 0 1px 0 rgba(14, 26, 34, 0.04), 0 12px 32px rgba(14, 26, 34, 0.06);
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7ebe6 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #d9e4ef 0%, transparent 50%),
    var(--paper);
  line-height: 1.45;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(14, 26, 34, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 26, 34, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 85%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top,
.toolbar,
.result-meta,
.list {
  position: relative;
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.top {
  display: grid;
  gap: 1.5rem;
  padding: 2.25rem 0 1.25rem;
  animation: rise 0.55s ease both;
}

@media (min-width: 860px) {
  .top {
    grid-template-columns: 1.2fr 1fr;
    align-items: end;
  }
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.lede {
  margin: 0.65rem 0 0;
  max-width: 36ch;
  color: var(--ink-soft);
  font-size: 1rem;
}

.stat-rail {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

@media (min-width: 520px) {
  .stat-rail {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  backdrop-filter: blur(8px);
  animation: rise 0.6s ease both;
}

.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }

.stat .label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .value {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.65s ease both;
  animation-delay: 0.08s;
}

.search {
  flex: 1 1 220px;
}

.search input,
.select-wrap select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search input:focus,
.select-wrap select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.select-wrap {
  flex: 0 1 150px;
}

.result-meta {
  margin: 1rem auto 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 3rem;
}

.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
  transition: border-color 0.2s, transform 0.2s;
}

.row:hover {
  border-color: color-mix(in srgb, var(--teal) 45%, var(--line));
  transform: translateY(-1px);
}

.row.matched {
  border-left: 3px solid var(--teal);
}

.row-main {
  display: grid;
  gap: 1rem;
}

@media (min-width: 780px) {
  .row-main {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr);
    align-items: start;
  }
}

.brand-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.prod-brand {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.prod-name {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.barcode {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
}

.badge-save {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-save.tie {
  background: var(--amber-soft);
  color: var(--amber);
}

.offers {
  display: grid;
  gap: 0.5rem;
}

@media (min-width: 560px) {
  .offers.matched-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.offer {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--paper);
  min-height: 100%;
}

.offer.winner {
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
  background: linear-gradient(160deg, var(--teal-soft), #fff 70%);
}

.offer.missing {
  opacity: 0.55;
  border-style: dashed;
}

.offer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.supplier {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.supplier.midodo { color: var(--midodo); }
.supplier.huamao { color: var(--huamao); }

.tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
}

.price {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.price small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.2rem;
}

.offer-meta {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.offer-name {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.loading {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
