/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0c0e14;
  --surface:    #13151f;
  --surface-2:  #1c1f2e;
  --surface-3:  #242840;
  --border:     #2a2e48;
  --border-2:   #373c60;
  --text:       #e8eaf0;
  --text-muted: #6b7280;
  --text-dim:   #4b5263;
  --accent:     #e53935;
  --gold:       #f5c842;
  --green:      #22c55e;
  --green-dim:  #14532d;
  --red:        #ef4444;
  --radius:     12px;
  --shadow:     0 4px 32px rgba(0,0,0,.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1rem;
}
.header-inner { max-width: 820px; margin: 0 auto; }
header h1 { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.5px; display: flex; align-items: center; gap: .5rem; }
.tagline { color: var(--text-muted); margin-top: .2rem; font-size: .9rem; }

/* ── Main ─────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 1.75rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Panel ────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.panel h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.panel-header h2 { margin-bottom: 0; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #c62828; border-color: #c62828; }

/* ── Loading / spinner ────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--text-muted);
  padding: .75rem 0;
  font-size: .9rem;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Best price banner ────────────────────────────────── */
.best-banner {
  background: linear-gradient(135deg, #0a1a0a, #0d1f0d);
  border: 1px solid #1e4d1e;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.best-banner-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--green);
  margin-bottom: .3rem;
}
.best-banner-retailer {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
}
.best-banner-offer {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.best-banner-price {
  font-size: 2.75rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.best-banner-unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}
.best-banner-total {
  font-size: .78rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: .35rem;
}
.meta-text { font-size: .78rem; color: var(--text-muted); }

/* ── Price list ───────────────────────────────────────── */
.price-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.price-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1.25rem;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 1rem;
  transition: border-color .15s, background .15s;
}
.price-row:hover {
  border-color: var(--border-2);
  background: var(--surface-3);
}
.price-row.best {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}

.price-row-rank {
  font-size: .75rem;
  font-weight: 800;
  color: var(--text-dim);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.price-row.best .price-row-rank { color: var(--green); }

.price-row-info { min-width: 0; }
.price-row-name {
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  line-height: 1.2;
}
.price-row-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.price-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .3rem;
  flex-shrink: 0;
}
.per-can {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.price-row.best .per-can { color: var(--gold); }
.per-can-unit {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.view-link {
  font-size: .72rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.view-link:hover { text-decoration: underline; }

/* ── Offer & online badges ────────────────────────────── */
.offer-badge {
  display: inline-block;
  font-size: .58rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.offer-badge.clubcard { background: #003087; color: #e8dcc8; }
.offer-badge.nectar   { background: #7c3aed; color: #fff; }
.offer-badge.morecard { background: #065f46; color: #a7f3d0; }
.offer-badge.offer    { background: #92400e; color: #fde68a; }

.online-badge {
  font-size: .58rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15rem .4rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}

/* ── Store filter pill ────────────────────────────────── */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: .25rem .5rem .25rem .75rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.filter-pill-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--border-2);
  color: var(--text-muted);
  font-size: .75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background .15s, color .15s;
}
.filter-pill-clear:hover { background: var(--red); color: #fff; }

/* ── Location controls ────────────────────────────────── */
.location-controls {
  display: flex;
  margin-bottom: 1.25rem;
}
.postcode-input-group { display: flex; gap: .5rem; }
.postcode-input-group input {
  padding: .45rem .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .875rem;
  width: 130px;
  outline: none;
  transition: border-color .15s;
}
.postcode-input-group input:focus { border-color: var(--accent); }

/* ── Store list ───────────────────────────────────────── */
.store-list { display: flex; flex-direction: column; gap: .5rem; }
.store-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .875rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.store-card-left { display: flex; flex-direction: column; gap: .2rem; }
.store-card-name { font-weight: 700; font-size: .9rem; }
.store-card-address { font-size: .78rem; color: var(--text-muted); }
.store-card-hours { font-size: .75rem; color: var(--text-muted); }
.store-card-distance {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}
.store-empty { color: var(--text-muted); font-size: .875rem; padding: .5rem 0; }

/* ── Error ────────────────────────────────────────────── */
.error-msg {
  color: var(--red);
  font-size: .875rem;
  padding: .5rem 0;
}

/* ── Footer ───────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem 1rem;
  color: var(--text-dim);
  font-size: .72rem;
  border-top: 1px solid var(--border);
}

/* ── Utilities ────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 520px) {
  .price-row { grid-template-columns: 1.5rem 1fr auto; gap: .6rem; padding: .75rem .9rem; }
  .per-can { font-size: 1.25rem; }
  .best-banner { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .best-banner-price { font-size: 2.25rem; }
}
