:root {
  --c-cream: #FBFDE2;  /* very light */
  --c-yellow: #F9DD29; /* primary accent */
  --c-peach: #E6B48B;  /* soft accent */
  --c-orange: #D28345; /* mid accent */
  --c-rust:  #A14E20;  /* dark accent */
  --c-brown: #49260A;  /* darkest text */

  --bg: var(--c-cream);
  --text: var(--c-brown);
  --muted: #6b5b4f;
  --card: #ffffff;
  --ring: rgba(0,0,0,.12);
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --radius: 18px;
}

/* changed: apply theme gradient background to page */
/* Background: cream with soft shaded gradient */
html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  background: linear-gradient(180deg, #FBFDE2 0%, #F8F6D9 45%, #EFE6C2 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* changed: make cards and main surfaces slightly translucent for contrast over gradient */
/* Navbar: translucent, slightly shady and sticky */
.nav {
  background: rgba(255, 255, 255, 0.72); /* translucent cream */
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  box-shadow: 0 6px 18px rgba(16,24,40,0.06); /* soft shadow */
  border-bottom: 1px solid rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 120;
}

/* Ensure nav text/icons are readable on translucent background */
.nav .brand, .nav .tab, .nav .scan-btn, .nav .nav-toggle {
  color: var(--c-brown);
}

/* Small hover and active states for clarity */
.nav .tab:hover {
  background: rgba(0,0,0,0.03);
}
.nav .tab.active {
  background: rgba(0,0,0,0.06);
}

/* If you lock body scroll when menu opens, use this class */
body.nav-menu-open { overflow: hidden; }

/* =============================
   RESET + BASE
   ============================= */
html,body { height:100%; width:100%; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin:0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }

/* container */
.container { max-width:1100px; margin:0 auto; padding: 0 16px; }

/* Images */
img { max-width:100%; height:auto; display:block; }
a {
  color: inherit; 
  text-decoration: none;
}
.tabs {
  display: flex; 
  gap: 6px; 
  align-items: center; 
  flex-wrap: wrap;
}
.tab {
  padding: 10px 14px; 
  border-radius: 999px; 
  background: transparent; 
  border: 1px solid transparent; 
  font-weight: 600; 
  color: var(--text); 
  opacity: .9;
}
.tab.active {
  background: var(--c-yellow); 
  border-color: #0000;
}
.scan-btn {
  display: flex; 
  align-items: center; 
  gap: 10px; 
  padding: 10px 14px; 
  border-radius: 999px; 
  background: var(--c-rust); 
  color: #fff; 
  box-shadow: var(--shadow);
}
.scan-btn svg {
  width: 18px;
  height: 18px;
}

/* =============================
   NAVBAR
   ============================= */
.nav {
  position:relative; 
  z-index:120; 
  background:var(--card,#fff); 
  width:100%;
}
.nav-inner {
  display:flex; 
  align-items:center; 
  gap:12px; 
  height:64px; 
  position:relative;
}
.brand {
  display:flex; 
  align-items:center; 
  gap:10px; 
  white-space:nowrap;
}
.logo {
  width: 36px; 
  height: 36px; 
  border-radius: 12px; 
  background: linear-gradient(135deg, var(--c-yellow), var(--c-orange)); 
  box-shadow: inset 0 0 0 3px #fff7;
}
.logo-img {
  width:40px; 
  height:40px; 
  object-fit:cover; 
  border-radius:8px; 
  box-shadow: inset 0 0 0 3px #fff7;
}

/* menu desktop */
.nav-menu { 
  display:flex; 
  align-items:center; 
  gap:12px; 
  flex:1; 
  justify-content:flex-end; 
}
.tabs { 
  display:flex; 
  gap:8px; 
  align-items:center; 
}
.tab { 
  padding:8px 12px; 
  border-radius:10px; 
  white-space:nowrap; 
  overflow:hidden; 
  text-overflow:ellipsis; 
}

/* mobile collapse */
.nav-toggle { 
  display:none; 
  background:transparent; 
  border:0; 
  padding:6px; 
  margin-left:auto; 
}
@media (max-width:760px) {
  .nav-toggle { display:inline-flex; }
  .nav-menu {
    position:fixed;
    left:8px;
    right:8px;
    top:72px;
    background:var(--card,#fff);
    border-radius:12px;
    padding:10px;
    flex-direction:column;
    gap:8px;
    box-shadow:0 10px 30px rgba(0,0,0,.12);
    display:none;
    max-height: calc(100vh - 96px);
    overflow:auto;
  }
  .nav.nav-open .nav-menu { display:flex; }
  .nav-extras { width:100%; justify-content:space-between; align-items:center; }
  .tab { width:100%; display:block; padding:12px; box-sizing:border-box; }
}

/* Responsive navbar: show hamburger at <=1000px, menu becomes dropdown */
.nav-inner { overflow: visible; }

/* hide any injected toggle by default (desktop) */
#navToggle, #dynamicNavToggle { display: none; }

/* standard desktop menu */
.nav-menu { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }

/* collapse breakpoint (windowed / mobile) */
@media (max-width:1000px) {
  /* show toggle */
  #navToggle, #dynamicNavToggle {
    display: inline-flex;
    margin-left: auto;
    background: transparent;
    border: 0;
    padding: 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
  }

  /* hide nav menu until opened */
  .nav .nav-menu { display: none !important; }

  /* when .nav-open is present show dropdown */
  .nav.nav-open .nav-menu {
    display: flex !important;
    position: absolute;
    top: calc(100% + 8px);
    left: 8px;
    right: 8px;
    margin: 0 8px;
    background: rgba(255,255,255,0.98);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    padding: 8px;
    gap: 8px;
    align-items: center;
    flex-direction: row;        /* horizontal row on windowed */
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    z-index: 9998;
  }

  /* very small screens: stack vertically */
  @media (max-width:560px) {
    .nav.nav-open .nav-menu { flex-direction: column; white-space: normal; padding: 12px; }
    .nav.nav-open .tabs { flex-direction: column; width:100%; }
    .nav.nav-open .tab { display:block; width:100%; padding:10px 12px; border-radius:10px; }
    .nav.nav-open .nav-extras { width:100%; justify-content:space-between; margin-top:8px; }
  }

  /* menu items look like pills in row mode */
  .nav.nav-open .tab {
    display:inline-flex;
    padding:8px 12px;
    border-radius:999px;
    margin:0 6px;
    white-space:nowrap;
  }
}

/* =============================
   HERO
   ============================= */
.hero {
  padding: 34px 0 20px;
}
.hero-card {
  background: linear-gradient(160deg, color-mix(in oklab, var(--c-yellow), #fff 12%), color-mix(in oklab, var(--c-peach), #fff 15%));
  border-radius: var(--radius);
  padding: 28px; 
  display: grid; 
  grid-template-columns: 1.2fr .8fr; 
  gap: 24px; 
  box-shadow: var(--shadow); 
  border: 1px solid var(--ring);
}
.hero h1 {
  margin: 0 0 6px; 
  font-size: clamp(22px, 3.2vw, 36px); 
  line-height: 1.15;
}
.hero p {
  margin: 0; 
  max-width: 55ch;
}

.stats {
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: 14px; 
  margin-top: 18px;
}
.stat {
  background: #fff; 
  border: 1px solid var(--ring); 
  border-radius: 14px; 
  padding: 14px; 
  text-align: center;
}
.stat .num {
  font-weight: 900; 
  font-size: clamp(22px, 4vw, 36px); 
  color: var(--c-rust);
}
.stat .label {
  font-weight: 600; 
  opacity: .8;
}

.address {
  background: #fff; 
  border: 1px solid var(--ring); 
  border-radius: 14px; 
  padding: 16px; 
  display: flex; 
  gap: 12px; 
  align-items: flex-start;
}
.addr-icon {
  width: 38px;
  height: 38px; 
  border-radius: 10px; 
  background: var(--c-orange); 
  display: grid; 
  place-items: center; 
  color: #fff;
}

/* =============================
   SECTIONS
   ============================= */
.section {
  padding: 22px 0;
}
.section h2 {
  margin: 0 0 12px; 
  font-size: clamp(18px, 2.2vw, 24px);
}
.grid {
  display: grid; 
  gap: 14px;
}
.grid.cards {
  grid-template-columns: repeat(4, 1fr);
}
.grid.cards .card {
  background: var(--card); 
  border: 1px solid var(--ring); 
  border-radius: 14px; 
  padding: 14px; 
  display: flex; 
  flex-direction: column; 
  gap: 8px;
}
.card .title {
  font-weight: 700;
}
.card .meta {
  font-size: .95rem; 
  opacity: .85;
}

.grid.vouchers {
  grid-template-columns: repeat(4, 1fr);
}
.voucher {
  background: var(--card); 
  border: 1px dashed var(--c-orange); 
  border-radius: 16px; 
  padding: 16px; 
  position: relative; 
  overflow: hidden;
}
.voucher::after {
  content: ""; 
  position: absolute; 
  inset: 0; 
  background: linear-gradient(90deg, #0000, #0001, #0000);
}
.voucher .badge {
  display: inline-block; 
  background: var(--c-yellow); 
  color: #000; 
  font-weight: 800; 
  padding: 6px 10px; 
  border-radius: 999px; 
  margin-bottom: 8px;
}
.voucher .store {
  font-weight: 800; 
  color: var(--c-rust);
}

/* =============================
   FOOTER
   ============================= */
footer {
  padding: 40px 0; 
  color: #fff; 
  background: linear-gradient(120deg, var(--c-rust), var(--c-brown)); 
  margin-top: 30px;
}
footer .wrap {
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 16px; 
  flex-wrap: wrap;
}
footer small {
  opacity: .9;
}

/* =============================
   RESPONSIVE
   ============================= */
@media (max-width: 1024px) {
  .grid.cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid.vouchers {
    grid-template-columns: repeat(3, 1fr);
  }
  .hero-card {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .nav-inner { height:56px; }
  #navToggle { display:inline-flex; align-items:center; justify-content:center; background:transparent; border:0; margin-left:auto; padding:8px; border-radius:8px; }
  .nav-menu {
    position:fixed;
    left:8px;
    right:8px;
    top:72px;
    background:var(--card,#fff);
    border-radius:12px;
    padding:10px;
    flex-direction:column;
    gap:8px;
    box-shadow:0 10px 30px rgba(0,0,0,.12);
    display:none;
    max-height: calc(100vh - 96px);
    overflow:auto;
  }
  .nav.nav-open .nav-menu { display:flex; }
  .nav-extras { width:100%; justify-content:space-between; align-items:center; }
  .tab { width:100%; display:block; padding:12px; box-sizing:border-box; }
}
@media (max-width: 720px) {
  .tabs {
    display: none;
  }
  .grid.cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid.vouchers {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 460px) {
  .grid.cards, .grid.vouchers {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr;
  }
}

/* Prevent horizontal overflow caused by long elements */
* { max-width: 100vw; }

/* Improve touch targets */
.tab, .btn, .scan-btn, select { min-height:44px; }

/* Ensure forms/cards fit small screens */
.profile-card, .card, .hero-card { width:100%; box-sizing:border-box; }

/* Small font-size tuning on tiny devices */
@media (max-width:420px) {
  body { font-size:15px; }
  .logo-img { width:34px; height:34px; }
  .container { padding:0 12px; }
}

/* Prevent horizontal scroll */
html,body { width:100%; overflow-x:hidden; }
* { box-sizing:border-box; max-width:100%; }

/* when menu open, lock background scroll */
body.nav-menu-open { overflow:hidden; }

/* ensure toggle is clickable and above menu */
#navToggle {
  position: relative;
  z-index: 9999 !important;
  pointer-events: auto !important;
  background: transparent;
  border: 0;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Force hamburger on top and clickable */
#navToggle, #dynamicNavToggle {
  position: relative !important;
  z-index: 99999 !important;
  pointer-events: auto !important;
  display: inline-flex !important;
  background: transparent !important;
  border: 0 !important;
}
.nav-menu {
  z-index: 1000;
  pointer-events: auto;
}
.nav-inner { overflow: visible !important; } /* prevent clipping */

/* QR scanner overlay */
#qrOverlay .qr-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6,6,8,0.55);
  z-index: 99999;
  padding: 20px;
}
#qrOverlay .qr-panel {
  width: 100%;
  max-width: 680px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 12px;
}
#qrOverlay .qr-video-wrap { width:100%; display:flex; align-items:center; justify-content:center; }
#qrOverlay video {
  width: 100%;
  max-width: 640px;
  height: auto;
  border-radius: 8px;
  background: #000;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#qrOverlay .qr-close {
  position: absolute;
  right: 18px;
  top: 18px;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  z-index: 100000;
}
#qrOverlay .qr-info { color: #fff; text-align:center; font-weight:600; }
#qrOverlay .qr-result { color:#FFD84D; word-break:break-all; }
#qrOverlay .qr-btn { margin-top:6px; padding:8px 12px; border-radius:8px; border:none; background:#F9DD29; color:#49260A; font-weight:700; cursor:pointer; }
@media (max-width:420px) {
  #qrOverlay .qr-panel { padding:10px; max-width: 92vw; }
  #qrOverlay video { max-height: 58vh; }
}

/* Ensure the menu becomes visible when .nav.nav-open */
.nav.nav-open .nav-menu {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}
/* fallback for collapsed layouts */
@media (max-width:1000px) {
  .nav.nav-open .nav-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 8px;
    right: 8px;
    background: rgba(255,255,255,0.98);
    border-radius: 12px;
    padding: 8px;
    gap: 8px;
    z-index: 9999;
    overflow-x: auto;
    white-space: nowrap;
  }
}