:root {
  --green: #0C763C;
  --green-dark: #08552B;
  --red: #721112;
  --red-soft: #9B2224;
  --cream: #FBF6EE;
  --paper: #FFFFFF;
  --ink: #0E0E0E;
  --muted: #6B645C;
  --line: #E8DFD2;
  --ok: #0C763C;
  --bad: #B42318;
  --warn: #B26B00;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(14, 14, 14, .08), 0 2px 6px rgba(14, 14, 14, .05);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 480px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 960px; }

/* Top bar */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 6px; gap: 12px;
}
.top .logo { height: 44px; width: auto; }
.lang {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: 14px; cursor: pointer; min-height: 36px; white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 12px 20px;
  border: 0; border-radius: 14px; cursor: pointer;
  background: var(--green); color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: 0 6px 16px rgba(12, 118, 60, .28);
  transition: transform .12s ease, background .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.red { background: var(--red); box-shadow: 0 6px 16px rgba(114, 17, 18, .25); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; font-weight: 600; font-size: 16px; min-height: 48px; }
.btn.small { width: auto; min-height: 40px; font-size: 15px; padding: 8px 14px; border-radius: 10px; }

/* Inputs */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.input {
  width: 100%; min-height: 54px; padding: 12px 16px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper);
  font-size: 18px; outline: none; transition: border-color .2s;
}
.input:focus { border-color: var(--green); }
.input.ltr { direction: ltr; text-align: left; }
.ig-input { position: relative; }
.ig-input .at { position: absolute; top: 50%; transform: translateY(-50%); left: 16px; color: var(--muted); font-size: 18px; direction: ltr; }
.ig-input .input { padding-left: 36px; direction: ltr; text-align: left; }

.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.err { color: var(--bad); font-weight: 600; min-height: 1.5em; margin: 8px 0 0; font-size: 15px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pill.ok { background: #E3F3E9; color: var(--ok); }
.pill.bad { background: #FDE7E5; color: var(--bad); }
.pill.warn { background: #FFF1DB; color: var(--warn); }
.code { font-family: ui-monospace, "SF Mono", Consolas, monospace; direction: ltr; unicode-bidi: isolate; letter-spacing: .06em; }

/* ---------- Wheel page ---------- */
.hero { text-align: center; padding: 10px 0 4px; }
.hero h1 { margin: 0; font-size: clamp(26px, 7.5vw, 34px); line-height: 1.2; color: var(--red); font-weight: 700; }
.hero p { margin: 6px 0 0; color: var(--muted); font-size: 16px; }

.wheel-box { position: relative; width: min(88vw, 400px); aspect-ratio: 1; margin: 18px auto 18px; }
.wheel-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--red), var(--red-soft), var(--red));
  padding: 10px; box-shadow: 0 18px 40px rgba(114, 17, 18, .25);
}
#wheel { width: 100%; height: 100%; border-radius: 50%; will-change: transform; }
.pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 3;
  border-left: 18px solid transparent; border-right: 18px solid transparent;
  border-top: 34px solid var(--ink);
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.3));
}
.hub {
  position: absolute; top: 50%; left: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 50%; background: #fff; z-index: 2; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  display: grid; place-items: center; border: 4px solid var(--green);
}
.hub img { width: 78%; height: auto; }
.wheel-empty { position: absolute; inset: 10px; border-radius: 50%; display: grid; place-items: end center; background: #fff; text-align: center; padding: 0 18% 20%; color: var(--muted); font-weight: 600; z-index: 1; }

.steps { display: grid; gap: 8px; margin: 18px 0 8px; padding: 0; list-style: none; counter-reset: s; }
.steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--muted); }
.steps li::before {
  counter-increment: s; content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; margin-top: 1px;
}
.terms { font-size: 12.5px; color: var(--muted); text-align: center; margin: 18px 0 28px; }

/* Coupon */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(14, 14, 14, .55);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
  overflow-y: auto; animation: fade .25s ease;
}
@media (min-height: 700px) { .overlay { align-items: center; } }
.coupon {
  width: 100%; max-width: 420px; background: var(--paper); border-radius: 24px; overflow: hidden;
  box-shadow: 0 30px 60px rgba(0,0,0,.35); animation: rise .45s cubic-bezier(.2, .9, .3, 1.2);
}
.coupon .head { background: var(--green); color: #fff; text-align: center; padding: 22px 18px 18px; }
.coupon .head .k { font-size: 15px; opacity: .9; }
.coupon .head .prize { font-size: clamp(26px, 8vw, 32px); font-weight: 700; line-height: 1.25; margin-top: 4px; }
.coupon .cut { height: 22px; position: relative; background: var(--paper); }
.coupon .cut::before, .coupon .cut::after { content: ""; position: absolute; top: -11px; width: 22px; height: 22px; border-radius: 50%; background: rgba(14,14,14,.55); }
.coupon .cut::before { left: -11px; } .coupon .cut::after { right: -11px; }
.coupon .cut span { position: absolute; top: -1px; left: 18px; right: 18px; border-top: 2px dashed var(--line); }
.coupon .body { padding: 0 20px 20px; text-align: center; }
.coupon .qr { width: 180px; margin: 0 auto; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.coupon .qr svg { width: 100%; height: auto; }
.coupon .bigcode { font-size: 28px; font-weight: 700; margin: 10px 0 2px; }
.coupon .meta { font-size: 14px; color: var(--muted); }
.coupon .rules { text-align: start; background: var(--cream); border-radius: 14px; padding: 12px 14px; margin: 14px 0; font-size: 14px; }
.coupon .rules div { display: flex; gap: 8px; padding: 3px 0; }
.coupon .state { margin: 10px 0 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px) scale(.96); opacity: 0; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* ---------- Cashier ---------- */
.branch-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--green); color: #fff; border-radius: 14px; margin: 8px 0 14px; font-weight: 600; }
.branch-bar button { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 10px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
#reader { width: 100%; border-radius: 16px; overflow: hidden; background: #000; margin-bottom: 12px; }
#reader video { border-radius: 16px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.result { margin-top: 16px; border-radius: var(--radius); overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
.result .band { padding: 16px; color: #fff; font-weight: 700; font-size: 20px; display: flex; gap: 10px; align-items: center; }
.result .band.ok { background: var(--ok); }
.result .band.bad { background: var(--bad); }
.result .band.warn { background: var(--warn); }
.result .inner { padding: 16px; }
.result .prize { font-size: 26px; font-weight: 700; line-height: 1.3; }
.result .who { font-size: 20px; font-weight: 700; direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .result .who { text-align: right; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; margin: 10px 0; cursor: pointer; font-size: 16px; }
.check input { width: 24px; height: 24px; accent-color: var(--green); flex: none; margin: 0; }
.check:has(input:checked) { border-color: var(--green); background: #F1F9F4; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); margin: 8px 0 16px; scrollbar-width: none; }
.tabs button { flex: 1 0 auto; border: 0; background: transparent; padding: 10px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--muted); min-height: 42px; }
.tabs button[aria-selected="true"] { background: var(--green); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--paper); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--muted); }
.prize-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center; padding: 14px; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 10px; }
.prize-row .dot { width: 14px; height: 14px; border-radius: 50%; }
.prize-row .nm { font-weight: 700; }
.prize-row .sub { font-size: 13px; color: var(--muted); }
.prize-row.off { opacity: .5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch input { width: 22px; height: 22px; accent-color: var(--green); }
.notice { padding: 12px 14px; border-radius: 14px; background: #FFF1DB; color: #6A4100; font-size: 14px; margin-bottom: 12px; }
dialog { border: 0; border-radius: 20px; padding: 0; width: min(94vw, 460px); box-shadow: 0 30px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(14,14,14,.5); }
dialog form { padding: 20px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
input[type="color"].input { padding: 4px; height: 54px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
