/* PromotionPulse — Products Gallery
   Design tokens lifted from the Figma prototype: navy #1E3A8A primary with a
   #2563EB gradient, Outfit for UI, monospace for prices, 16px card radius. */

:root {
  --navy:        #1E3A8A;
  --blue:        #2563EB;
  --ink:         #0F172A;
  --text:        #334155;
  --muted:       #64748B;
  --faint:       #94A3B8;
  --line:        #E2E8F0;
  --line-soft:   #F1F5F9;
  --bg:          #F8FAFC;
  --card:        #FFFFFF;
  --red:         #EF4444;
  --emerald:     #047857;
  --emerald-bg:  #ECFDF5;
  --amber:       #F59E0B;
  --orange:      #F97316;

  --radius-card: 16px;
  --radius-pill: 999px;
  --shadow-sm:   0 1px 2px rgba(15, 23, 42, .06);
  --shadow-lg:   0 20px 48px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }

/* Any explicit `display` beats the UA default of `[hidden] { display: none }`,
   so every grid/flex container in here would ignore the attribute and stay
   on screen. Declared once, up front, rather than patched per component. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: Outfit, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------- top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: linear-gradient(100deg, var(--navy), var(--blue));
  color: #fff;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }

.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  font-weight: 800; letter-spacing: .5px;
}

.brand h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.brand p  { margin: 1px 0 0; font-size: 11px; color: rgba(255,255,255,.72); }

.topnav { display: flex; gap: 4px; flex-wrap: wrap; }

.topnav a {
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,.78);
  text-decoration: none;
}
.topnav a:hover  { background: rgba(255,255,255,.12); color: #fff; }
.topnav a.active { background: rgba(255,255,255,.20); color: #fff; }

.topbar-meta { font-size: 10.5px; color: rgba(255,255,255,.68); font-variant-numeric: tabular-nums; }

/* ---------------- KPI tiles ---------------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  padding: 18px 24px 4px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
}

.kpi .label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--faint);
  font-weight: 600;
}

.kpi .value {
  margin-top: 5px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: -.5px;
}

.kpi .sub { font-size: 10.5px; color: var(--faint); margin-top: 2px; }

/* ---------------- layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  padding: 14px 24px 40px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static !important; }
}

/* ---------------- filters ---------------- */
.filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.filters-head h2 { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink); }

.link-btn {
  background: none; border: none; padding: 0;
  color: var(--blue); font-size: 11px; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

.field { display: block; margin-bottom: 15px; }

.field > span {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--faint);
  font-weight: 600;
  margin-bottom: 6px;
}
.field > span b { color: var(--blue); font-family: "JetBrains Mono", monospace; }

.field input[type="search"] {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
}
.field input[type="search"]:focus { border-color: var(--blue); background: #fff; }

.field input[type="range"] { width: 100%; accent-color: var(--navy); }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); cursor: pointer; }
.toggle input { accent-color: var(--navy); width: 15px; height: 15px; }

.chips { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }

.chips button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}
.chips button:hover  { border-color: var(--blue); color: var(--blue); }
.chips button.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.facet { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 12px; }

.facet h3 {
  margin: 0 0 7px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--faint);
  font-weight: 600;
}

.facet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.facet-item:hover { color: var(--ink); }
.facet-item input { accent-color: var(--navy); width: 14px; height: 14px; flex-shrink: 0; }
.facet-item .name  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-item .count { margin-left: auto; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }

.facet .more { font-size: 10.5px; color: var(--blue); background: none; border: none; padding: 3px 0 0; font-weight: 600; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------------- content head ---------------- */
.content-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.content-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.content-head p  { margin: 2px 0 0; font-size: 11.5px; color: var(--faint); }

.sorts { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.sorts > span { font-size: 11px; color: var(--muted); margin-right: 2px; }

.sorts button {
  border: none;
  background: none;
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.sorts button:hover  { background: var(--line-soft); }
.sorts button.active { background: var(--navy); color: #fff; }

.active-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.active-filters .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 10.5px;
  font-weight: 600;
}
.active-filters .tag button { border: none; background: none; color: inherit; padding: 0; font-size: 13px; line-height: 1; }

/* ---------------- card grid ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(224px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }

/* Generated brand tile — ClickFlyer supplies no product photography, so the
   card head is a deterministic brand-coloured tile instead of a broken img. */
.card-media {
  position: relative;
  height: 128px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-media .tile-brand {
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.4px;
  text-align: center;
  padding: 0 14px;
  text-shadow: 0 1px 8px rgba(0,0,0,.18);
  line-height: 1.15;
}
.card-media .tile-pack {
  position: absolute;
  bottom: 9px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: .04em;
}
/* Crops come off the flyer at whatever aspect the product tile had, mostly
   portrait (~0.6), against a 1.75 landscape card. Positioned absolutely
   rather than sized with height:100%, which resolved against the grid item
   rather than the 128px container and let a 331px-tall crop render at 513px
   and get clipped. `contain` then shows the whole product. */
.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  padding: 5px;
}

.badge-discount {
  position: absolute; top: 8px; left: 8px;
  background: var(--red); color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 2px 7px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  box-shadow: 0 0 0 2px rgba(255,255,255,.5), 0 2px 6px rgba(0,0,0,.2);
  line-height: 1.35;
}

.badge-status {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  font-size: 8.5px;
  font-weight: 700;
  color: var(--muted);
}
.badge-status .dot { width: 5px; height: 5px; }

.badge-status[data-status="Active"]   { color: var(--emerald); border-color: #A7F3D0; }
.badge-status[data-status="Upcoming"] { color: #1D4ED8;        border-color: #BFDBFE; }
.badge-status[data-status="Expired"]  { color: var(--faint);   border-color: var(--line); }

.badge-ending {
  position: absolute; bottom: 8px; left: 8px;
  background: var(--orange); color: #fff;
  font-size: 8.5px; font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}

.card-hover {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.32);
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .2s ease;
}
.card:hover .card-hover { opacity: 1; }

.card-hover span {
  background: #fff; color: var(--ink);
  font-size: 10.5px; font-weight: 700;
  padding: 6px 16px;
  border-radius: 11px;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
}

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

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }

.card-meta .cat {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.retailer-chip {
  width: 21px; height: 21px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 8.5px; font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.card-title {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 33px;
}

.card-tags { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }

.promo-pill {
  font-size: 9px; font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid;
}
.promo-pill[data-t="Price Off"]   { background:#EFF6FF; color:#1D4ED8; border-color:#BFDBFE; }
.promo-pill[data-t="Multi-buy"]   { background:#ECFEFF; color:#0E7490; border-color:#A5F3FC; }
.promo-pill[data-t="Bundle Deal"] { background:#EEF2FF; color:#4338CA; border-color:#C7D2FE; }
.promo-pill[data-t="Buy 1 Get 1"] { background:#F5F3FF; color:#6D28D9; border-color:#DDD6FE; }

.card-dates { margin-left: auto; font-size: 8.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.card-prices { display: flex; align-items: baseline; gap: 7px; margin-top: auto; flex-wrap: wrap; }

.price-now {
  font-size: 15.5px; font-weight: 800;
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: -.4px;
}
.price-was {
  font-size: 10.5px;
  color: var(--faint);
  text-decoration: line-through;
  font-family: "JetBrains Mono", monospace;
}
.price-save {
  margin-left: auto;
  font-size: 9px; font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-bg);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-family: "JetBrains Mono", monospace;
}
.price-missing { font-size: 9.5px; color: var(--faint); font-style: italic; }

/* ---------------- empty / more ---------------- */
.empty { grid-column: 1 / -1; text-align: center; padding: 72px 20px; }
.empty .icon { font-size: 42px; }
.empty h3 { margin: 12px 0 4px; font-size: 15px; color: var(--text); }
.empty p  { margin: 0; font-size: 12.5px; color: var(--faint); }

.more-wrap { display: flex; justify-content: center; padding: 22px 0 0; }

.more-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 11px;
  padding: 9px 22px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.more-btn:hover { border-color: var(--blue); }

.skeleton {
  height: 244px;
  border-radius: var(--radius-card);
  background: linear-gradient(100deg, #EEF2F7 30%, #F8FAFC 50%, #EEF2F7 70%);
  background-size: 220% 100%;
  animation: shimmer 1.15s infinite linear;
}
@keyframes shimmer { to { background-position: -220% 0; } }

/* ---------------- secondary pages (flyers / trends) ---------------- */
.page { padding: 14px 24px 40px; }

.flyer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.flyer {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
  text-decoration: none;   /* the whole card is an <a> to the flyer on wowdeals */
  color: inherit;
}
.flyer:hover h3 { color: var(--blue); }
.flyer:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.flyer-cover { position: relative; height: 210px; background: var(--line-soft); overflow: hidden; }
.flyer-cover img { width: 100%; height: 100%; object-fit: cover; }

.flyer-cover .pages {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(15,23,42,.78);
  color: #fff;
  font-size: 9.5px; font-weight: 700;
  padding: 3px 8px; border-radius: var(--radius-pill);
  font-family: "JetBrains Mono", monospace;
}

.flyer-cover .days {
  position: absolute; top: 8px; left: 8px;
  background: var(--orange); color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 3px 9px; border-radius: var(--radius-pill);
}

.flyer-body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.flyer-body .retailer { display: flex; align-items: center; gap: 7px; }
.flyer-body h3 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.32;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flyer-body .dates { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; margin-top: auto; }

.chart-stack { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }

.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink); }
.chart-card .cap { margin: 2px 0 12px; font-size: 10.5px; color: var(--faint); }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 9px; font-size: 10.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 11px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---------------- SKU performance panel ---------------- */
.perf-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin: 16px 0 4px;
}

.perf {
  background: linear-gradient(160deg, #F8FAFC, #EEF2F7);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 9px 10px;
  text-align: center;
}
.perf .k { font-size: 8.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 600; }
.perf .v { font-size: 15px; font-weight: 800; color: var(--ink); font-family: "JetBrains Mono", monospace; margin-top: 3px; }
.perf .v.good { color: var(--emerald); }
.perf .v.bad  { color: var(--red); }

.retailer-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 11.5px; }
.retailer-table th {
  text-align: left; font-size: 8.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); font-weight: 600; padding: 5px 7px; border-bottom: 1px solid var(--line);
}
.retailer-table td { padding: 6px 7px; border-bottom: 1px solid var(--line-soft); }
.retailer-table td.num { font-family: "JetBrains Mono", monospace; text-align: right; }
.retailer-table .chip-sm {
  width: 17px; height: 17px; border-radius: 5px; color: #fff;
  font-size: 7.5px; font-weight: 800; display: inline-grid; place-items: center; margin-right: 6px;
}

.variant-note {
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--muted);
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 9px;
  padding: 7px 10px;
}

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 22px;
  z-index: 50;
}

.modal {
  background: #fff;
  border-radius: 20px;
  width: min(680px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 30px 70px rgba(15,23,42,.32);
}

.modal-head { position: relative; height: 150px; display: grid; place-items: center; }
.modal-head .tile-brand { font-size: 27px; font-weight: 800; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.22); }

.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}

.modal-body { padding: 20px 22px 24px; }
.modal-body h3 { margin: 0 0 3px; font-size: 18px; color: var(--ink); font-weight: 700; }
.modal-body .sub { font-size: 11.5px; color: var(--faint); margin-bottom: 15px; }

.modal-prices { display: flex; align-items: baseline; gap: 11px; margin-bottom: 18px; flex-wrap: wrap; }
.modal-prices .now { font-size: 28px; font-weight: 800; font-family: "JetBrains Mono", monospace; color: var(--ink); letter-spacing: -1px; }
.modal-prices .was { font-size: 14px; color: var(--faint); text-decoration: line-through; font-family: "JetBrains Mono", monospace; }
.modal-prices .save {
  font-size: 11px; font-weight: 700;
  color: var(--emerald); background: var(--emerald-bg);
  border: 1px solid #A7F3D0;
  padding: 4px 11px; border-radius: var(--radius-pill);
  font-family: "JetBrains Mono", monospace;
}

.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

.spec {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 9px 11px;
}
.spec .k { font-size: 9px; text-transform: uppercase; letter-spacing: .11em; color: var(--faint); font-weight: 600; }
.spec .v { font-size: 12.5px; color: var(--ink); font-weight: 600; margin-top: 3px; word-break: break-word; }

.history { margin-top: 18px; }
.history h4 { margin: 0 0 8px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); font-weight: 600; }
.history .chart { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px; }
