:root {
  color-scheme: dark;
  --bg: #060b16;
  --card: #111827;
  --text: #f1f5f9;
  --muted: #cbd5f5;
  --accent: #7dd3fc;
  --border: #1f2937;
  --danger: #f87171;
  --success: #34d399;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #112240, var(--bg));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

img {
  max-width: 100%;
  height: auto;
}

.site-header {
  padding: 32px clamp(16px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand img {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 4px;
}

.subtitle {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  margin: 6px 0 0;
  max-width: 640px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.primary-link,
.ghost-link {
  font-size: 1rem;
  border-radius: 999px;
  padding: 12px 22px;
  text-decoration: none;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.primary-link {
  background: linear-gradient(120deg, #60a5fa, #3b82f6);
  color: #fff;
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-link.full-width {
  width: 100%;
}

.primary-link.secondary {
  background: linear-gradient(120deg, #ffd89c, #ffa723);
  color: #1f1306;
  box-shadow: 0 8px 22px rgba(255, 167, 35, 0.4);
}

.ghost-link {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: var(--text);
}

.ghost-link.small {
  font-size: 0.95rem;
  padding: 8px 14px;
}

main {
  padding: 0 clamp(16px, 5vw, 72px) 48px;
}

.popular {
  background: rgba(8, 13, 24, 0.9);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 28px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

.personalized {
  margin: 32px 0;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.how-it-works {
  margin: 32px 0 0;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(8, 13, 24, 0.85);
}

.how-it-works ol {
  margin: 16px 0 0;
  padding-left: 20px;
  font-size: 1.05rem;
  display: grid;
  gap: 12px;
}

.how-it-works li {
  line-height: 1.5;
}

.popular-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.updated {
  font-size: 0.95rem;
  color: var(--muted);
}

.status-message {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 18px;
}

.popular-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.popular-controls input {
  flex: 1;
  min-width: 200px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.9);
  padding: 10px 16px;
  color: var(--text);
  font-size: 1rem;
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.product-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.product-top img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.product-name {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.25;
}

.price-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  font-size: 1.1rem;
}

.price-now {
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
}

.price-prev {
  color: var(--muted);
  text-decoration: line-through;
  white-space: nowrap;
}

.delta {
  font-weight: 600;
  white-space: nowrap;
}

.delta.negative {
  color: var(--success);
}

.delta.positive {
  color: var(--danger);
}

.product-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-actions .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.open-link {
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(120deg, #ffd89c, #ffa723);
  color: #1f1306;
  text-decoration: none;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 22px rgba(255, 167, 35, 0.4);
}

.small-print {
  font-size: 0.9rem;
  color: #a0aec0;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.history-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  gap: 12px;
}

.modal-history-wrapper {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.modal-pagination {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.history-list li .price-change {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  font-weight: 600;
}

.history-list li .price-change.up {
  color: var(--danger);
}

.history-list li .price-change.down {
  color: var(--success);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.pager-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.page-select select {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 8px 16px;
}

.site-footer {
  text-align: center;
  padding: 36px 16px 24px;
  font-size: 0.95rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #0f172a;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 680px;
  width: 100%;
  padding: 24px;
  position: relative;
  box-shadow: 0 25px 55px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.65rem;
  cursor: pointer;
}

.modal-header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.modal-header img {
  width: 92px;
  height: 92px;
  border-radius: 20px;
  object-fit: cover;
}

.modal-price {
  font-size: 1.4rem;
  margin: 4px 0 0;
}

.full-width {
  width: 100%;
  text-align: center;
}

@media (max-width: 640px) {
  .product-card {
    padding: 16px;
  }

  .brand img {
    width: 56px;
    height: 56px;
  }

  .primary-link,
  .ghost-link {
    width: 100%;
    text-align: center;
  }

  .personalized {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination {
    flex-direction: column;
    align-items: flex-start;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
