:root {
  --brand: #111111;
  --bg: #f4f4f2;
  --card: #ffffff;
  --text: #161616;
  --muted: #6b6b6b;
  --line: #e3e3df;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --bad: #c0392b;
  --radius: 14px;
  font-family: 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.5; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
.wrap { max-width: 480px; margin: 0 auto; padding: 20px 16px 48px; }
.wide { max-width: 1100px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input[type='checkbox'] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.help { font-size: 13px; color: var(--muted); margin-top: 3px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button:disabled { opacity: 0.5; cursor: default; }
.btn-light { background: #fff; color: var(--brand); }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-bad { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn-small { padding: 6px 10px; font-size: 14px; }
.full { width: 100%; }

.msg { padding: 12px 14px; border-radius: 10px; margin: 12px 0; font-size: 15px; }
.msg-ok { background: #e7f5ec; color: #145c33; }
.msg-bad { background: #fbeaea; color: #8a2a20; }
.msg-wait { background: #fdf5e6; color: #7a5212; }

.brandbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brandbar img { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); }

/* Loyalty card */
.loyalty { background: var(--brand); color: #fff; border-radius: 20px; padding: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.loyalty .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.loyalty img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stamp {
  aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.5);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: rgba(255, 255, 255, 0.6);
}
.stamp.on { background: #fff; border: 2px solid #fff; color: var(--brand); font-size: 20px; }
.stamp.gift { border-style: solid; }
.loyalty .foot { display: flex; justify-content: space-between; margin-top: 16px; font-size: 14px; opacity: 0.9; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.history li:last-child { border-bottom: 0; }

/* Admin */
.topbar { background: var(--brand); color: #fff; }
.topbar .wrap { padding-top: 12px; padding-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.topbar select { width: auto; padding: 6px 10px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; }
.tabs button { background: #fff; color: var(--text); border-color: var(--line); white-space: nowrap; font-weight: 500; }
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; min-width: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 26px; }
.req { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--line); }
.req:last-child { border-bottom: 0; }
.req .who { flex: 1; min-width: 180px; }
.warn { color: var(--warn); font-size: 14px; font-weight: 600; }
.count { width: 74px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 13px; background: #eee; }
.pill.ok { background: #e7f5ec; color: #145c33; }
.pill.bad { background: #fbeaea; color: #8a2a20; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.qrbox { display: flex; justify-content: center; padding: 16px; background: #fff; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 99; max-width: 90vw;
}
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }

@media print {
  .noprint { display: none !important; }
  body { background: #fff; }
}

/* ---------- Loyalty card (themes) ---------- */
.lc {
  position: relative; overflow: hidden; border-radius: 24px; padding: 22px 20px 18px;
  background: var(--lc-bg); color: var(--lc-ink);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.12);
}
.lc-glow {
  position: absolute; inset: -40% -20% auto auto; width: 70%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 65%); pointer-events: none;
}
.lc::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.lc-top { position: relative; display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.lc-brand { display: flex; gap: 12px; align-items: center; }
.lc-logo { width: 46px; height: 46px; object-fit: contain; background: #fff; border-radius: 12px; padding: 4px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.lc-name { font-size: 19px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.2; }
.lc-title { font-size: 13px; opacity: 0.8; }
.lc-count { text-align: right; line-height: 1; }
.lc-count b { font-size: 30px; }
.lc-count span { font-size: 15px; opacity: 0.75; }
.lc-stamps { position: relative; display: grid; gap: 10px; }
.lc-stamp {
  aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--lc-ink); opacity: 0.6;
  border: 2px dashed currentColor;
}
.lc-stamp.gift { border-style: solid; opacity: 0.85; font-size: 18px; }
.lc-stamp.on {
  opacity: 1; border: 2px solid var(--lc-accent); background: var(--lc-accent); color: var(--lc-stamp-ink);
  font-size: 22px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}
.lc-stamp.pop { animation: lc-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) backwards; animation-delay: var(--d); }
.lc-stamp.on img { width: 70%; height: 70%; object-fit: contain; border-radius: 50%; }
@keyframes lc-pop { from { transform: scale(0.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .lc-stamp.pop { animation: none; } }
.lc-bar { position: relative; height: 6px; border-radius: 99px; margin: 18px 0 10px; background: rgba(127, 127, 127, 0.3); overflow: hidden; }
.lc-bar i { display: block; height: 100%; border-radius: inherit; background: var(--lc-accent); }
.lc-foot { position: relative; display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.lc-since { position: relative; font-size: 12px; opacity: 0.65; margin-top: 4px; }

.gift { display: flex; gap: 14px; align-items: center; }
.gift img, .gift-icon { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; flex: none; }
.gift-icon { display: flex; align-items: center; justify-content: center; font-size: 36px; background: #faf3f5; }
.gift-name { font-size: 18px; font-weight: 700; }
.earn { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.earn-h { font-weight: 700; margin-bottom: 4px; }
.earn ul { margin: 0; padding-left: 20px; }
.earn li { margin: 3px 0; }

/* Admin design pickers */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.swatch { border: 2px solid var(--line); border-radius: 12px; padding: 0; overflow: hidden; background: #fff; color: var(--text); font-weight: 500; display: block; text-align: left; }
.swatch.sel { border-color: #111; box-shadow: 0 0 0 2px #111; }
.swatch i { display: block; height: 46px; }
.swatch span { display: block; padding: 6px 8px; font-size: 13px; }
.icons { display: flex; flex-wrap: wrap; gap: 8px; }
.icons button { background: #fff; color: var(--text); border-color: var(--line); min-width: 64px; flex-direction: column; gap: 0; padding: 6px 10px; font-weight: 500; font-size: 12px; }
.icons button b { font-size: 22px; }
.icons button.sel { border-color: #111; box-shadow: 0 0 0 2px #111; }
.imgpick { display: flex; gap: 12px; align-items: center; }
.imgpick img { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.preview-sticky { position: sticky; top: 12px; }

/* Print just the chosen QR poster */
@media print {
  body.printing .qr-poster:not(.print-target) { display: none !important; }
  body.printing .qr-poster.print-target { box-shadow: none; border: 0; }
}

/* Coupon reveal on the customer card */
.coupon { border: 2px dashed var(--ok); border-radius: 14px; padding: 14px; text-align: center; background: #f3fbf6; margin-top: 12px; }
.coupon code { display: block; font-size: 26px; font-weight: 800; letter-spacing: 2px; margin: 6px 0; color: #145c33; }

/* Customer card page blocks (order/visibility set by the admin) */
.layout-off { display: none !important; }
.block-gap:has(> :not(.hidden)) { margin: 10px 0; }
