/* CouponPing — dark theme, mobile-first */
:root {
  --bg: #0f1419;
  --bg-soft: #17202a;
  --card: #1c2632;
  --card-2: #223041;
  --line: #2c3b4e;
  --text: #eef3f7;
  --muted: #93a3b3;
  --accent: #ff4d6d;
  --accent-2: #ffb703;
  --green: #2dd4a8;
  --blue: #4aa8ff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; }
.brand-word {
  font-size: 1.35rem; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-word.fallback { -webkit-text-fill-color: unset; color: var(--text); }
.view-toggle { display: flex; background: var(--bg-soft); border-radius: 999px; padding: 4px; border: 1px solid var(--line); }
.toggle-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.toggle-btn.active { background: var(--accent); color: #fff; }

/* ---------- Setup notice ---------- */
.setup-notice {
  max-width: 640px; margin: 48px auto; padding: 28px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.setup-notice code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }

/* ---------- Main layout ---------- */
#app { max-width: 720px; margin: 0 auto; padding: 12px 12px 80px; }
.view { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Map ---------- */
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#map { height: 46vh; min-height: 300px; width: 100%; background: #0b0f14; z-index: 1; }
.map-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(0,0,0,0.65); color: #fff; font-size: 0.78rem;
  padding: 6px 12px; border-radius: 999px; pointer-events: none; z-index: 500;
}
#store-map { height: 240px; border-radius: 10px; border: 1px solid var(--line); z-index: 1; }

/* Custom Leaflet pin (divIcon, no image assets) */
.cp-pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
  background: var(--accent); transform: rotate(-45deg);
  border: 3px solid #fff; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.cp-pin::after {
  content: "🎟"; transform: rotate(45deg); font-size: 12px; line-height: 1;
}
.cp-popup { color: #111; font-family: inherit; }
.cp-popup h4 { margin: 0 0 6px; font-size: 0.95rem; }
.cp-popup ul { margin: 6px 0 0; padding-left: 16px; font-size: 0.82rem; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: 0.85rem; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* ---------- Deal cards ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head h2, .panel h2 { margin: 0; font-size: 1.15rem; }
.deal-count { color: var(--muted); font-size: 0.85rem; }
.deals { display: flex; flex-direction: column; gap: 10px; }
.deal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.deal-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.deal-title { font-size: 1.02rem; font-weight: 700; margin: 0; }
.deal-store { color: var(--muted); font-size: 0.85rem; }
.deal-desc { color: var(--muted); font-size: 0.9rem; margin: 0; }
.deal-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.78rem; color: var(--muted); }
.badge {
  align-self: flex-start; font-weight: 800; font-size: 0.85rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.tag { background: var(--bg-soft); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }

/* ---------- Panels / forms ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.field-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 11px 12px; font-size: 1rem;
}
.input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px; text-transform: uppercase; }
.btn {
  border: 0; border-radius: 10px; padding: 12px 16px;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { padding: 7px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.check-grid label {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; font-size: 0.85rem; cursor: pointer;
}
.verify-row { display: flex; gap: 8px; }
.verify-row .input { flex: 1; }

/* ---------- Coupons (owner) ---------- */
.coupons { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.coupon-row {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.coupon-row .used { color: var(--muted); font-size: 0.82rem; }
.coupon-row.ended { opacity: 0.55; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.active { background: var(--green); }
.status-dot.ended { background: var(--muted); }

/* ---------- Verify result ---------- */
.verify-card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.verify-card p { margin: 6px 0; font-size: 0.9rem; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.pill.issued { background: rgba(45, 212, 168, 0.15); color: var(--green); }
.pill.used { background: rgba(147, 163, 179, 0.15); color: var(--muted); }

/* ---------- Redeem modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 22px; max-width: 380px; width: 100%; text-align: center;
  display: flex; flex-direction: column; gap: 12px; position: relative;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: 0;
  color: var(--muted); font-size: 1.2rem; cursor: pointer;
}
.modal-card h3 { margin: 0; }
.code-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 2.6rem; font-weight: 800; letter-spacing: 6px;
  background: var(--bg-soft); border: 2px dashed var(--accent);
  border-radius: 12px; padding: 16px 8px;
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 3000;
          display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast {
  background: var(--card-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; font-size: 0.9rem; box-shadow: var(--shadow);
  animation: slideup 0.25s ease-out;
}
@keyframes slideup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

/* ---------- Leaflet dark popup tweaks ---------- */
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper { border-radius: 12px; }

.signed-in { margin: 0; }

@media (min-width: 640px) {
  #app { padding: 20px 20px 100px; }
  .deals { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}
