:root {
  /* iFigo brand — Blinkit-style layout, own palette */
  --ifigo-ink: #0f172a;
  --ifigo-slate: #1e293b;
  --ifigo-orange: #f97316;
  --ifigo-orange-dark: #ea580c;
  --ifigo-orange-soft: #fff7ed;
  --ifigo-sky: #38bdf8;
  --ifigo-sky-soft: #e0f2fe;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --danger: #ef4444;
  --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.1);
  --radius: 12px;
  --radius-pill: 999px;
  --img-slot: 76%;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(1.25rem + var(--safe-b));
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Sticky top shell ── */
.top-shell {
  position: sticky;
  top: 0;
  z-index: 30;
}

/* ── Header (iFigo slate + orange) ── */
.header {
  background: linear-gradient(135deg, var(--ifigo-ink) 0%, var(--ifigo-slate) 100%);
  color: #fff;
  padding: calc(0.65rem + var(--safe-t)) 1rem 0.85rem;
}

.header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 480px;
  margin: 0 auto;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.header__logo,
.header__logo-img {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}

.header__logo {
  background: linear-gradient(135deg, var(--ifigo-orange), var(--ifigo-orange-dark));
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.header__logo-img {
  display: block;
  background: transparent;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.header__title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header__sub {
  font-size: 0.72rem;
  color: var(--ifigo-sky);
  margin-top: 0.1rem;
}

.header__refresh {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.header__refresh:active {
  background: rgba(255, 255, 255, 0.2);
}

.header__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 480px;
  margin: 0.65rem auto 0;
  font-size: 0.72rem;
}

.status-pill {
  background: rgba(249, 115, 22, 0.25);
  color: #fed7aa;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.status-time {
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Category + sort bar ── */
.sticky-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.cats {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.65rem 1rem 0.5rem;
  max-width: 480px;
  margin: 0 auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.cats::-webkit-scrollbar { display: none; }

.cat {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 4.25rem;
  padding: 0.5rem 0.35rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
}

.cat__icon {
  font-size: 1.25rem;
  line-height: 1;
}

.cat__label {
  white-space: nowrap;
  max-width: 4rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat.is-active {
  background: var(--ifigo-orange-soft);
  border-color: var(--ifigo-orange);
  color: var(--ifigo-orange-dark);
  font-weight: 700;
}

.toolbar {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem;
}

.toolbar__sort {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.75rem;
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
}

.toolbar__sort select {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

/* ── Product grid (2-col mobile) ── */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  padding: 0.75rem 0.75rem 0;
  max-width: 480px;
  margin: 0 auto;
}

@media (min-width: 520px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 720px;
    gap: 0.85rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header__top,
  .header__status,
  .cats,
  .toolbar,
  .view-more-wrap,
  .footer {
    max-width: 720px;
  }
}

/* ── Product card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.card:active {
  box-shadow: var(--shadow-md);
}

/* Equal square image area on every card */
.card__media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.card__img-slot {
  position: absolute;
  top: 12%;
  left: 12%;
  width: var(--img-slot);
  height: var(--img-slot);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.card__img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.card__badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.card__badge--deal {
  background: var(--ifigo-orange);
}

.card__body {
  padding: 0.55rem 0.6rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-height: 7.5rem;
}

.card__cat {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--ifigo-orange);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card__bestseller {
  display: inline-block;
  width: fit-content;
  margin-top: 0.15rem;
  padding: 0.12rem 0.35rem;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
  color: #c45500;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fdba74;
  border-radius: 4px;
  letter-spacing: 0.01em;
}

.card__bestseller[hidden] {
  display: none;
}

.card__title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.1em;
}

.card__title a {
  color: inherit;
}

.card__rating {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  min-height: 1em;
  margin-bottom: 0.2rem;
}

/* Amazon.in-style price block */
.amazon-price {
  margin-bottom: 0.35rem;
  flex: 1;
  min-width: 0;
}

.amazon-price__row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem 0.45rem;
}

.amazon-price__deal {
  font-size: 1.05rem;
  font-weight: 700;
  color: #b12704;
  letter-spacing: -0.02em;
}

.amazon-price__deal--link {
  font-size: 0.88rem !important;
  font-weight: 700;
  color: #cc0c39;
}

.amazon-price__pct {
  font-size: 0.82rem;
  font-weight: 700;
  color: #cc0c39;
}

.amazon-price__mrp-line {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
  margin-top: 0.1rem;
  font-size: 0.72rem;
  color: #565959;
}

.amazon-price__mrp {
  text-decoration: line-through;
}

.amazon-price__save {
  margin-top: 0.15rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #007600;
}

.card__footer {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  margin-top: auto;
  padding-top: 0.35rem;
}

.card__deal-block,
.card__discount {
  display: none !important;
}

.card__prices {
  display: none;
}

.price-now,
.price-was,
.price-save {
  display: none;
}

.stars {
  color: #f59e0b;
  font-weight: 700;
}

/* Official Amazon-style CTA (yellow pill, dark text) */
.card__cta,
.card__cta--amazon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.6rem;
  background: #ffd814;
  background-image: none;
  color: #0f1111;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  border: 1px solid #fcd200;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  box-shadow: none;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.card__cta:hover,
.card__cta--amazon:hover {
  background: #f7ca00;
  border-color: #f2c200;
  box-shadow: none;
  transform: none;
  color: #0f1111;
}

.card__cta:active,
.card__cta--amazon:active {
  background: #f0b800;
  opacity: 1;
  transform: none;
}

/* ── View more ── */
.view-more-wrap {
  max-width: 480px;
  margin: 0.85rem auto 0;
  padding: 0 0.75rem;
  text-align: center;
}

.btn-view-more {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ifigo-orange-dark);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}

.btn-view-more:active {
  background: var(--ifigo-orange-soft);
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty .muted {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* ── Footer ── */
.footer {
  max-width: 480px;
  margin: 1.5rem auto 0;
  padding: 1rem 0.75rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.footer__links {
  margin-top: 0.55rem;
}

.footer__links a,
.footer a {
  color: var(--ifigo-orange-dark);
  font-weight: 600;
  text-decoration: none;
}

.footer__links a:hover,
.footer a:hover {
  text-decoration: underline;
}

/* ── Skeleton loading (same aspect ratio as cards) ── */
.skeleton {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1.65;
  overflow: hidden;
  position: relative;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, rgba(15, 23, 42, 0.04) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.muted { color: var(--text-muted); }
