:root {
  --red: #e41a1c;
  --red-dark: #b3000f;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --bg: #f6f5f3;
  --card: #ffffff;
  --line: #e6e4e0;
  --green: #138a36;
  --green-bg: #e7f6ec;
  --gold: #fff7e0;
  --gold-line: #f2d98a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  line-height: 1.45;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* hero */
.hero {
  text-align: center;
  padding: 28px 8px 20px;
}
.hero h1 { margin: 0; }
.logo {
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--red);
}
.logo .dot { color: var(--ink); opacity: 0.55; font-weight: 700; }
.tagline {
  color: var(--muted);
  margin: 8px auto 0;
  max-width: 540px;
  font-size: 15px;
}

/* states */
.state {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  box-shadow: var(--shadow);
}
.state-error { color: var(--red-dark); }
.state button {
  margin-left: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

/* best-deal banner */
.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 8px 0 22px;
  box-shadow: var(--shadow);
}
.banner-quiet {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
.banner-emoji { font-size: 32px; line-height: 1; }
.banner-title { font-size: 17px; font-weight: 700; }
.banner-sub { margin-top: 2px; font-size: 15px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.banner-price { font-size: 20px; font-weight: 800; }
.banner-was { text-decoration: line-through; opacity: 0.75; }
.banner-badge {
  background: rgba(255, 255, 255, 0.22);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}
.banner-quiet .banner-badge { background: var(--green-bg); color: var(--green); }
.banner-save { opacity: 0.9; font-size: 13px; }

/* matrix */
.matrix-wrap { margin-bottom: 28px; }
.matrix-wrap h2,
.deals h2 {
  font-size: 18px;
  margin: 0 0 12px;
}
.matrix-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}
.matrix {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
}
.matrix th,
.matrix td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.matrix thead th {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.th-photo { display: block; height: 48px; width: auto; margin: 4px auto 0; object-fit: contain; }
.corner { text-align: left; }
.store-cell,
.corner {
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
  text-align: left;
  min-width: 96px;
}
.store-cell { box-shadow: 1px 0 0 var(--line); }
.store-name { font-weight: 700; }
.store-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  vertical-align: middle;
}
.price-cell .price { font-weight: 700; font-size: 16px; }
.price-cell .was {
  font-size: 11px;
  color: var(--muted);
  text-decoration: line-through;
}
.price-cell .was .off {
  color: var(--red);
  font-weight: 700;
  text-decoration: none;
  margin-left: 2px;
}
.price-cell .unit { font-size: 11px; color: var(--muted); margin-top: 1px; }
.price-cell.is-discount { background: var(--gold); }
.price-cell.is-cheapest .price { color: var(--green); }
.price-cell.is-cheapest {
  outline: 2px solid var(--green);
  outline-offset: -2px;
  border-radius: 6px;
}
td.empty { color: var(--line); }

/* legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch-cheapest { border: 2px solid var(--green); }
.swatch-discount { background: var(--gold); border: 1px solid var(--gold-line); }

/* deals */
.deals { margin-bottom: 28px; }
.deals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.deal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.deal-head { display: flex; justify-content: space-between; align-items: center; }
.deal-store {
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.deal-price { font-weight: 800; font-size: 18px; }
.deal-title { margin: 0; font-size: 16px; }
.deal-desc { margin: 0; font-size: 13px; color: var(--muted); }
.deal-valid {
  align-self: flex-start;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}

/* footer */
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.foot-note { font-size: 12px; }
.link-btn {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0 0 0 4px;
}

/* stats page */
.muted { color: var(--muted); }
a.logo { text-decoration: none; }
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--red); line-height: 1.1; }
.stat-lbl { font-size: 13px; color: var(--muted); margin-top: 6px; }
.stats-daily h2 { font-size: 18px; margin: 0 0 12px; }
.daily-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  box-shadow: var(--shadow);
}
.daily-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.daily-row:last-child { border-bottom: none; }
.daily-day { color: var(--muted); font-variant-numeric: tabular-nums; }
.daily-bar-wrap { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.daily-bar { display: block; height: 100%; background: var(--red); border-radius: 6px; }
.daily-vals { font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-legend { font-size: 12px; margin-top: 10px; }

@media (max-width: 480px) {
  .banner-title { font-size: 16px; }
  .matrix th, .matrix td { padding: 8px 6px; }
  .daily-row { grid-template-columns: 78px 1fr auto; }
}
