:root {
  --bg: #120800;
  --bg-elevated: #1a0d00;
  --bg-card: #1e0e00;
  --bg-card-hover: #241200;
  --border: #2a1800;
  --border-light: #3d2200;
  --text-primary: #f5e6d3;
  --text-secondary: #b89b7a;
  --text-muted: #8a6e4b;
  --gold: #F0A500;
  --gold-dim: #c48a00;
  --gold-bright: #ffc940;
  --saffron: #E8642A;
  --saffron-dim: #c45020;
  --teal: #1D9E75;
  --teal-dim: #157a5a;
  --danger: #e8453a;
  --font-ui: 'Sora', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  padding-bottom: 80px;
  min-height: 100vh;
}

/* ---- Offline Banner ---- */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--saffron);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.3px;
}
.offline-banner.hidden { display: none; }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(18, 8, 0, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
  text-decoration: none;
}

.topbar-location {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.topbar-bell {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 18px;
  cursor: pointer;
}

/* ---- Search ---- */
.search-bar {
  margin: 16px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus { border-color: var(--gold-dim); }

.search-bar::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.6;
}

/* ---- Category Chips ---- */
.category-chips {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.category-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 36px;
  display: flex; align-items: center;
}

.chip:hover { border-color: var(--border-light); }
.chip.active {
  background: var(--gold);
  color: #120800;
  border-color: var(--gold);
  font-weight: 600;
}

/* ---- Hero Card ---- */
.hero-card {
  margin: 0 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--gold);
}

.hero-badge {
  display: inline-block;
  background: var(--saffron);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.hero-shop {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hero-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 16px;
}

.hero-coupon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1.5px dashed var(--gold-dim);
  border-radius: var(--radius-sm);
}

.hero-coupon code {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 1px;
}

.btn-copy {
  padding: 8px 14px;
  background: var(--gold);
  color: #120800;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
  min-height: 36px;
}
.btn-copy:hover { opacity: 0.85; }
.btn-copy:active { transform: scale(0.96); }

/* ---- Section Headers ---- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-count {
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
  background: rgba(240, 165, 0, 0.1);
  padding: 4px 10px;
  border-radius: 12px;
}

/* ---- Shop Grid ---- */
.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 20px;
}

.shop-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-card:hover { border-color: var(--border-light); background: var(--bg-card-hover); }
.shop-card:active { transform: scale(0.98); }

.shop-thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  background: var(--bg-elevated);
}

.shop-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

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

.shop-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 10px;
}

.shop-offer-count {
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
}

/* Partner CTA card */
.partner-cta {
  background: linear-gradient(135deg, var(--bg-card) 0%, #1a1000 100%);
  border: 1.5px dashed var(--gold-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  min-height: 140px;
}

.partner-cta-icon {
  font-size: 32px;
}

.partner-cta-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
}

.partner-cta-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Offer Rows ---- */
.offers-list {
  padding: 0 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.offer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.offer-row:hover { border-color: var(--border-light); }

.offer-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.offer-info { flex: 1; min-width: 0; }

.offer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.offer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.offer-shop-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 10px;
}

.offer-discount {
  font-size: 11px;
  font-weight: 700;
  color: var(--saffron);
}

.offer-coupon-box {
  flex-shrink: 0;
  padding: 8px 12px;
  background: var(--bg);
  border: 1.5px dashed var(--gold-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
}

.offer-coupon-box:hover {
  border-color: var(--gold);
  background: rgba(240, 165, 0, 0.08);
}

.offer-coupon-box.copied {
  border-color: var(--teal);
  color: var(--teal);
}

/* ---- Product Grid ---- */
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 20px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}

.product-card:hover { border-color: var(--border-light); }

.product-img {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
}

.product-new-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.product-details {
  padding: 12px;
}

.product-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.product-shop {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.product-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}

.product-original {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ---- Shop Detail ---- */
.shop-hero {
  padding: 24px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.shop-hero-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.shop-hero-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.shop-hero-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.shop-hero-tag {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.shop-hero-count {
  font-size: 13px;
  color: var(--gold);
  font-weight: 500;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 12px;
  text-decoration: none;
}

.tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ---- Partner Dashboard ---- */
.partner-screen {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.partner-header {
  text-align: center;
  margin-bottom: 24px;
}

.partner-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.partner-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input, .form-select {
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
  min-height: 48px;
}

.form-input:focus, .form-select:focus { border-color: var(--gold-dim); }
.form-input::placeholder { color: var(--text-muted); }

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b89b7a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.btn-primary {
  padding: 16px;
  background: var(--gold);
  color: #120800;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition);
  min-height: 52px;
  text-align: center;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  padding: 14px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--border-light); color: var(--text-primary); }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.partner-shop-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.partner-shop-id {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: rgba(18, 8, 0, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
  min-width: 56px;
  min-height: 44px;
  justify-content: center;
}

.nav-item.active { color: var(--gold); }
.nav-icon { font-size: 22px; line-height: 1; }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toast.success { border-color: var(--teal); color: var(--teal); }
.toast.error { border-color: var(--danger); color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ---- Loading & Empty ---- */
.loading {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 60px 16px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
  margin-bottom: 8px;
}

.empty-state-sub {
  font-size: 12px;
  opacity: 0.7;
}

/* ---- Screen transitions ---- */
.screen {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ---- Selection ---- */
::selection {
  background: rgba(240, 165, 0, 0.3);
  color: var(--text-primary);
}
