:root {
  --navy: #061638;
  --navy-border: #122857;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --green: #0f9d58;
  --green-bg: #e6f4ea;
  --amber-bg: #fef7e0;
  --amber-text: #b06000;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(17, 24, 39, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Deep Navy Brand Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  border-bottom: 1px solid var(--navy-border);
  padding: 12px 0;
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.brand:hover .brand-mark {
  transform: translateY(-1px);
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  background: linear-gradient(180deg, #f8fafc 0%, #cbd5e1 60%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
}

.search-wrap input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  background: #ffffff;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.region-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.region-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  color: #cbd5e1;
  transition: background 0.15s, color 0.15s;
}

.region-btn.active {
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-outline {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
  padding: 7px 13px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.btn-outline:hover {
  border-color: #60a5fa;
  background: rgba(37, 99, 235, 0.25);
}

/* Error Banner */
.error-banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.9rem;
  font-weight: 500;
}

.error-banner.hidden {
  display: none;
}

/* Zero-CLS Ad Slots */
.ad-slot {
  margin: 18px 0;
  background: var(--surface);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}

.ad-leaderboard {
  min-height: 112px;
}

.ad-infeed {
  min-height: 130px;
  margin-top: 28px;
}

.ad-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.ad-placeholder {
  background: #f8fafc;
  color: #64748b;
  font-size: 0.85rem;
  padding: 22px 12px;
  border-radius: 8px;
}

/* Hero & Filters */
.hero-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.hero-bar h1 {
  margin: 0;
  font-size: 1.55rem;
  color: var(--navy);
}

.hero-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.sort-wrap select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
}

.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0 8px;
}

.cat-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.results-meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 8px 0 14px;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(6, 22, 56, 0.1);
}

.card-img-wrap {
  position: relative;
  height: 190px;
  background: #f3f4f6;
  overflow: hidden;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discount-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--green);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
}

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.35;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.best-price {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy);
}

.best-store-label {
  font-size: 0.8rem;
  color: var(--green);
  font-weight: 600;
}

.mini-offers {
  margin: 10px 0 14px;
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-offer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
  padding: 4px 6px;
  border-radius: 6px;
}

.mini-offer-row:hover {
  background: #f3f4f6;
}

.card-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-primary,
.btn-secondary {
  text-align: center;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eff6ff;
  color: var(--primary);
}

.btn-secondary:hover {
  background: #dbeafe;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 22, 56, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: var(--surface);
  border-radius: 14px;
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.modal-sm {
  max-width: 560px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: #f3f4f6;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
}

.modal-header-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.modal-header-grid img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
}

.spec-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.spec-tag {
  background: #f3f4f6;
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 6px;
}

.chart-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.compare-table th,
.compare-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

.compare-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
}

.badge-lowest {
  display: inline-block;
  background: var(--green-bg);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

.badge-featured {
  display: inline-block;
  background: var(--amber-bg);
  color: var(--amber-text);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

.strike {
  text-decoration: line-through;
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 6px;
}

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

/* Footer */
.footer {
  margin-top: 40px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  font-size: 0.88rem;
}

.footer-brand {
  letter-spacing: 0.1em;
  color: var(--navy);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.disclosure {
  max-width: 760px;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 8px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

@media (max-width: 680px) {
  .modal-header-grid {
    grid-template-columns: 1fr;
  }
  .compare-table th:nth-child(2),
  .compare-table td:nth-child(2) {
    display: none;
  }
}