/* ===== Tokens ===== */
:root {
  --bg: #f5f3fb;
  --surface: #ffffff;
  --surface-2: #f0edf8;
  --ink: #1d1530;
  --ink-2: #5d5573;
  --line: #e2ddef;
  --brand: #6d28d9;
  --brand-2: #4c1d95;
  --brand-soft: #ede7fb;
  --gold: #f5b301;
  --gold-soft: #fff4d1;
  --ok: #059669;
  --ok-soft: #d9f5ea;
  --warn: #b45309;
  --warn-soft: #fff1d6;
  --bad: #dc2626;
  --bad-soft: #fde4e4;
  --wa: #1fa855;
  --held: #f6c453;
  --taken: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 21, 48, .06), 0 6px 20px rgba(29, 21, 48, .06);
  --font: 'Inter', 'Cairo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
html[lang="ar"] { --font: 'Cairo', 'Inter', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
body.has-cart { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* ===== Top bar ===== */
.topbar {
  background: linear-gradient(120deg, var(--brand-2), var(--brand) 60%, #8b5cf6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(76, 29, 149, .25);
}
.topbar-in {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; min-width: 0; }
.brand-mark { font-size: 1.5rem; line-height: 1; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-tag { font-size: .7rem; font-weight: 700; background: rgba(255, 255, 255, .2); padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.lang-toggle {
  color: #fff; text-decoration: none; font-weight: 700; font-size: .9rem;
  border: 1.5px solid rgba(255, 255, 255, .5); border-radius: 99px; padding: 6px 14px; white-space: nowrap;
}
.lang-toggle:hover { background: rgba(255, 255, 255, .12); }
.lang-toggle[hreflang="ar"] { font-family: 'Cairo', sans-serif; }
.adminnav {
  max-width: 1280px; margin: 0 auto; padding: 0 12px 10px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.adminnav::-webkit-scrollbar { display: none; }
.adminnav a, .navbtn {
  color: rgba(255, 255, 255, .85); text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: 7px 12px; border-radius: 10px; white-space: nowrap; background: none; border: 0; cursor: pointer;
}
.adminnav a:hover, .navbtn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.adminnav a.on { background: #fff; color: var(--brand-2); }
.adminnav form { margin-inline-start: auto; }

/* ===== Layout ===== */
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.wrap.wide { max-width: 1280px; }
.narrow { max-width: 560px; margin: 0 auto; }
.foot { text-align: center; color: var(--ink-2); font-size: .8rem; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.page-title { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 800; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 600; }
html[dir="rtl"] .back { direction: rtl; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
@media (min-width: 600px) { .card { padding: 22px; } }

/* ===== Hero ===== */
.hero { text-align: center; padding: 8px 0 18px; }
.hero h1 { font-size: clamp(1.7rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -.01em; }
.lead { color: var(--ink-2); font-size: 1.05rem; max-width: 560px; margin: 0 auto 14px; }
.hero-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; font-weight: 600; font-size: .9rem; }
.pill-gold { background: var(--gold-soft); border-color: #f3d98a; color: #7a5600; }
.winner-banner { display: inline-block; background: var(--gold-soft); border: 1px solid #f3d98a; color: #7a5600; font-weight: 800; padding: 10px 18px; border-radius: 12px; font-size: 1.1rem; }


/* ===== Board ===== */
.board-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
@media (min-width: 600px) { .board-panel { padding: 18px; } }
.board-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg b { color: var(--ink); }
.lg-a i { background: #fff; border: 1.5px solid #c9c0e0; }
.lg-h i { background: repeating-linear-gradient(45deg, #fbe3a3, #fbe3a3 3px, #f8d77f 3px, #f8d77f 6px); border: 1px solid #eec463; }
.lg-t i { background: var(--taken); }
.tool-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.jump { flex: 1 1 160px; }
.jump input { width: 100%; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; cursor: pointer; user-select: none; }
.toggle input { width: 20px; height: 20px; accent-color: var(--brand); }
.toggle.big { font-size: 1rem; margin: 6px 0; }
.ranges { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ranges::-webkit-scrollbar { display: none; }
.ranges button {
  flex: 0 0 auto; border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 6px 14px; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--ink-2);
  font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}
.ranges button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
}
@media (min-width: 900px) { .board { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 7px; } }
.cell {
  aspect-ratio: 1; min-height: 44px; border-radius: 10px; border: 1.5px solid #d6cdec;
  background: #fff; font-weight: 800; font-size: 1rem; cursor: pointer; color: var(--ink);
  font-variant-numeric: tabular-nums; padding: 0; position: relative;
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .cell.s-a:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 4px 10px rgba(109, 40, 217, .18); } }
.cell.s-a:active { transform: scale(.94); }
.cell.sel { background: linear-gradient(140deg, var(--brand), #8b5cf6); border-color: var(--brand-2); color: #fff; box-shadow: 0 4px 12px rgba(109, 40, 217, .35); }
.cell.sel::after { content: '✓'; position: absolute; top: 2px; inset-inline-end: 5px; font-size: .62rem; }
.cell.s-h { background: repeating-linear-gradient(45deg, #fbe3a3, #fbe3a3 6px, #f8d77f 6px, #f8d77f 12px); border-color: #eec463; color: #7a5600; cursor: not-allowed; }
.cell.s-t { background: var(--taken); border-color: #b91c1c; color: rgba(255, 255, 255, .9); cursor: not-allowed; }
.cell:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.cell.pulse { animation: pulse 1.2s ease 2; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 179, 1, .8); } 50% { box-shadow: 0 0 0 8px rgba(245, 179, 1, 0); } }

/* Admin boards are clickable in every state */
.board-admin .cell { cursor: pointer; }
.board-admin .cell.s-t { color: #fff; }
.board-admin .cell.picked { outline: 3px solid var(--gold); outline-offset: 2px; transform: scale(1.06); }
.board-admin .cell.is-winner { background: var(--gold); border-color: #c98f00; color: #3b2a00; }

/* ===== Cart bar ===== */
.cartbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(29, 21, 48, .12);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.cartbar-in { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.cart-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cart-nums { color: var(--ink-2); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 10px); opacity: 0; transition: opacity .2s, transform .2s;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: 12px; padding: 10px 18px;
  font-weight: 700; font-size: .98rem; text-decoration: none; cursor: pointer; line-height: 1.2;
  min-height: 44px; transition: filter .12s, transform .12s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff; box-shadow: 0 4px 14px rgba(109, 40, 217, .3); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-soft { background: var(--brand-soft); color: var(--brand-2); }
.btn-soft:hover { filter: brightness(.97); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ok { background: #047857; color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger-soft { background: var(--bad-soft); color: #a51c1c; }
.btn-wa { background: #15803d; color: #fff; }
.wa-lang { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; font-size: .9rem; font-weight: 600; color: #15803d; }
.wa-lang svg { width: 18px; height: 18px; }
.wa-lang select { width: auto; min-width: 150px; padding: 6px 10px; font-size: .9rem; }
.btn-gold { background: var(--gold); color: #3b2a00; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 13px 22px; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }
.btn.copied { background: var(--ok-soft); color: var(--ok); }
.btn-link { background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; padding: 10px; font-weight: 600; }
.ico { flex: 0 0 auto; }

/* ===== Forms ===== */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { font-weight: 700; font-size: .92rem; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 14px; font-size: 16px; min-height: 46px; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(109, 40, 217, .12); }
input.file, input[type=file] { font-size: .9rem; padding: 8px 0; width: 100%; max-width: 100%; min-width: 0; }
.form > *, .field { min-width: 0; }
.has-err input { border-color: var(--bad); }
.err { color: var(--bad); font-size: .88rem; font-weight: 600; }
.hint { color: var(--ink-2); font-size: .84rem; }
.phone-input { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.phone-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(109, 40, 217, .12); }
.phone-input .prefix { display: flex; align-items: center; padding: 0 12px; background: var(--surface-2); font-weight: 700; color: var(--ink-2); border-inline-end: 1.5px solid var(--line); }
.phone-input input { border: 0; border-radius: 0; box-shadow: none !important; flex: 1; min-width: 0; }
.hold-note { background: var(--warn-soft); color: #7a3e06; border-radius: 10px; padding: 10px 12px; margin: 0; font-size: .92rem; font-weight: 600; }

/* ===== Flash / badges / chips ===== */
.flash { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 600; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: #035c40; border-color: #a8e5cd; }
.flash-err { background: var(--bad-soft); color: #8f1717; border-color: #f6b9b9; }
.flash-warn { background: var(--warn-soft); color: #7a3e06; border-color: #f3d39b; }
.badge { display: inline-block; font-size: .78rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.b-held { background: var(--warn-soft); color: var(--warn); }
.b-submitted { background: #dbeafe; color: #1d4ed8; }
.b-confirmed, .b-open { background: var(--ok-soft); color: var(--ok); }
.b-expired, .b-cancelled, .b-closed, .b-removed { background: #ece9f2; color: #5d5573; }
.b-rejected { background: var(--bad-soft); color: var(--bad); }
.tag { font-size: .72rem; background: var(--surface-2); color: var(--ink-2); border-radius: 6px; padding: 1px 6px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips.center { justify-content: center; margin: 12px 0; }
.chip { direction: ltr; unicode-bidi: isolate; display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 8px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-2); font-weight: 800; font-size: .9rem; font-variant-numeric: tabular-nums; }
.chips-lg .chip, .chip-lg { min-width: 44px; height: 40px; font-size: 1.05rem; border-radius: 10px; }
.muted-chips .chip { background: #ece9f2; color: var(--ink-2); }

/* ===== Checkout / order ===== */
.summary { display: grid; gap: 12px; }
.summary-row { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.summary-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; font-weight: 700; }
.summary-total b { font-size: 1.6rem; font-weight: 800; }
.order-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.countdown-box { display: flex; align-items: baseline; gap: 10px; justify-content: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); flex-wrap: wrap; }
.countdown { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand-2); direction: ltr; }
.countdown-box.urgent .countdown { color: var(--bad); }
.steps { list-style: none; padding: 18px; counter-reset: s; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.steps > li { counter-increment: s; position: relative; padding-inline-start: 44px; min-width: 0; }
@media (max-width: 420px) { .steps { padding: 16px 14px; } .steps > li { padding-inline-start: 38px; } }
.steps > li::before {
  content: counter(s); position: absolute; inset-inline-start: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: .95rem;
}
.steps p { margin: 6px 0 0; }
.pay-grid { display: grid; gap: 10px; margin-top: 10px; }
.pay-item { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "l b" "v b"; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; column-gap: 10px; }
.pay-item .muted { grid-area: l; font-size: .82rem; }
.pay-val { grid-area: v; font-size: clamp(1.05rem, 4.8vw, 1.35rem); font-weight: 800; font-variant-numeric: tabular-nums; text-align: start; white-space: nowrap; }
html[dir="rtl"] .pay-val { text-align: right; }
.pay-item .btn { grid-area: b; }
.whish-go { margin-top: 10px; }
.copy-num[hidden], .whish-go[hidden] { display: none; }
.sent-form { margin-top: 12px; }
.cancel-form { margin: 4px 0 10px; }
.state-card { padding: 28px 20px; }
.state-icon { font-size: 3rem; line-height: 1; margin-bottom: 10px; }
.state-card.ok { border-color: #a8e5cd; background: linear-gradient(180deg, #f0fbf6, #fff 60%); }
.state-card.bad .btn { margin-top: 10px; }
.help-line { margin-top: 18px; }

/* ===== Admin ===== */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.admin-head .page-title { margin: 0 0 8px; }
.round-picker select { min-height: 40px; padding: 6px 12px; width: auto; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 16px; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.stat-n { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-n small { font-size: .9rem; color: var(--ink-2); font-weight: 700; }
.stat-l { color: var(--ink-2); font-size: .85rem; font-weight: 600; }
.stat-warn { border-color: #bcd3fb; background: #f3f7ff; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: .9rem; padding: 7px 12px; border-radius: 9px; white-space: nowrap; }
.tabs a.on { background: var(--brand); color: #fff; }
.tabs .count { font-size: .75rem; opacity: .8; margin-inline-start: 2px; }
.search { display: flex; gap: 6px; flex: 1 1 260px; }
.search input { min-height: 42px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { padding: 36px 16px; color: var(--ink-2); font-weight: 600; }
.wa-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-color: #9fe0b8; background: #effbf3; }

/* Responsive table: real table on desktop, stacked cards on phones/tablets */
.rtable { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rtable th { text-align: start; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; white-space: nowrap; }
.rtable td { padding: 12px; border-top: 1px solid var(--line); vertical-align: top; }
.rtable .actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rtable tr.row-submitted td { background: #f8fbff; }
@media (max-width: 899px) {
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable { background: none; border: 0; box-shadow: none; }
  .rtable thead { display: none; }
  .rtable tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; padding: 6px 4px; }
  .rtable tr.row-submitted { border-color: #bcd3fb; }
  .rtable tr.row-submitted td { background: none; }
  .rtable td { border: 0; padding: 6px 12px; display: grid; grid-template-columns: 96px minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: center; }
  .rtable td > * { justify-self: start; }
  .rtable td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 4; align-self: start; padding-top: 2px; font-size: .78rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
  .rtable td.actions { display: flex; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 4px; }
  .rtable td.actions::before { display: none; }
  .rtable td.actions .btn { flex: 1 1 auto; }
  .rtable td.actions > form { flex: 1 1 auto; display: flex; }
  .rtable td.actions > form .btn { width: 100%; }
}
html[lang="ar"] .rtable th, html[lang="ar"] .rtable td::before { text-transform: none; letter-spacing: 0; }

.dialog { border: 0; border-radius: 18px; padding: 22px; width: min(460px, calc(100vw - 24px)); box-shadow: 0 24px 60px rgba(0, 0, 0, .3); color: var(--ink); background: var(--surface); }
.dialog::backdrop { background: rgba(29, 21, 48, .5); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.settings-grid { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.settings-grid .card { margin: 0; }
.settings-col { display: grid; gap: 16px; align-content: start; min-width: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.plain-list a { font-weight: 700; }

/* ===== Winner ===== */
.winner-layout { display: grid; gap: 16px; align-items: start; }
/* Lookup box on top, the board of numbers underneath. */
.winner-layout { grid-template-columns: minmax(0, 1fr); }
.lookup-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.lookup-main .lookup-lottery { margin: 0; }
.lookup-main .lookup-form { flex: 1 1 320px; max-width: 560px; }
@media (min-width: 900px) {
  .lookup-card:has(.result:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; }
  .lookup-card:has(.result:not([hidden])) .lookup-main { flex-direction: column; align-items: stretch; }
  .lookup-card:has(.result:not([hidden])) .lookup-form { flex: none; max-width: none; }
  .lookup-card .result { margin-top: 0; }
}
.lookup-form { display: flex; gap: 8px; }
.lookup-form input { font-size: 1.4rem; font-weight: 800; text-align: center; min-height: 52px; }
.result { margin-top: 18px; text-align: center; display: grid; gap: 12px; }
.result-num { font-size: clamp(3rem, 14vw, 4.5rem); font-weight: 800; color: var(--brand-2); line-height: 1; font-variant-numeric: tabular-nums; }
.secret { display: grid; gap: 12px; }
.secret-blur { filter: blur(6px); user-select: none; color: var(--ink-2); font-weight: 800; font-size: 1.2rem; }
.details { display: grid; gap: 10px; animation: reveal .35s ease; }
@keyframes reveal { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.d-name { font-size: 1.6rem; font-weight: 800; }
.d-phone { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.d-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.result .flash { margin: 8px 0 0; }

.login-box { margin-top: 6vh; }

@media (max-width: 420px) {
  .btn-lg { font-size: 1rem; }
  .countdown { font-size: 2rem; }
  .field-row { grid-template-columns: 1fr; }
  .rtable td { grid-template-columns: 84px 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
input[type=file]::file-selector-button {
  border: 0; background: var(--brand-soft); color: var(--brand-2); font-weight: 700;
  padding: 9px 14px; border-radius: 10px; margin-inline-end: 10px; cursor: pointer; font-family: inherit;
}

/* =====================================================================
   v2: lottery picker, LIVE bar, socials, admin shell
   ===================================================================== */

/* Header keeps the same layout in both languages: brand left, language button right. */
.topbar-in, .mainbar { direction: ltr; }
html[dir="rtl"] .brand-name, html[dir="rtl"] .mainbar-title { direction: rtl; }
.btn-dark { background: #111; color: #fff; }
.btn-dark:hover { filter: brightness(1.25); }
.state-card .btn-dark { margin-top: 14px; }

/* LIVE bar */
.live-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(90deg, #e11d48, #dc2626); color: #fff; text-decoration: none;
  padding: 10px 16px; font-weight: 700; text-align: center;
}
.live-banner:hover { filter: brightness(1.08); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: livepulse 1.4s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.8); } 70% { box-shadow: 0 0 0 10px rgba(255,255,255,0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } }
.live-cta { background: rgba(255,255,255,.2); border-radius: 99px; padding: 2px 12px; font-size: .9rem; }

/* Footer socials */
.foot { display: grid; gap: 10px; justify-items: center; }
.socials { display: flex; gap: 10px; }
.social { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.social:hover { background: var(--brand-soft); color: var(--brand-2); }
.social.s-whatsapp { color: var(--wa); }

/* Lottery picker */
.hero-prize { font-size: 1.15rem; font-weight: 700; margin: -4px 0 8px; }
.lottery-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.lottery-card {
  display: grid; gap: 12px; align-content: start; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.lottery-card:hover { transform: translateY(-3px); border-color: #c8b6f3; box-shadow: 0 10px 28px rgba(76, 29, 149, .14); }
.lottery-card.paused { opacity: .85; }
.lc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lc-head h2 { font-size: 1.25rem; margin: 0; }
.lc-prize { margin: 0; font-weight: 700; color: var(--brand-2); }
.lc-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.lc-meta .pill { font-size: .82rem; padding: 4px 10px; }
.lc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #a78bfa); border-radius: inherit; }
.ltag { display: inline-flex; align-items: center; gap: 4px; background: var(--gold-soft); color: #6b4a00; border: 1px solid #f3d98a; border-radius: 99px; padding: 2px 10px; font-weight: 700; font-size: .82rem; text-decoration: none; white-space: nowrap; }
.for-lottery { margin: -6px 0 12px; }

/* ===== Admin shell ===== */
body.is-admin { display: block; background: #f4f2f9; }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, #2e1065, #4c1d95); color: #fff; padding: 16px 12px; overflow-y: auto; z-index: 40;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 14px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 8px; }
.side .brand { font-size: 1.05rem; }
.side .side-x { display: none; }
.side-nav { display: grid; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.78); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.on { background: #fff; color: var(--brand-2); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.nav-count { margin-inline-start: auto; background: var(--gold); color: #3b2a00; border-radius: 99px; font-size: .75rem; padding: 1px 8px; min-width: 22px; text-align: center; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 6px 4px; border-top: 1px solid rgba(255,255,255,.12); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-txt { display: grid; line-height: 1.2; min-width: 0; }
.me-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { color: rgba(255,255,255,.65); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #3b2a00; font-weight: 800; flex: 0 0 auto; }
.avatar.sm { width: 28px; height: 28px; font-size: .8rem; }
.icon-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.side-backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.mainbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  background: rgba(244, 242, 249, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: 10px 24px; min-height: 60px;
}
.mainbar-title { font-size: 1.25rem; font-weight: 800; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.mainbar .lang-toggle { color: var(--brand-2); border-color: #cdbff0; background: #fff; }
.content { padding: 20px 24px 40px; display: grid; gap: 16px; align-content: start; }
.content > .flash { margin: 0; }

.pagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pagebar-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }
.pagebar-note { margin: 0; flex: 1 1 280px; }
.round-picker label { display: flex; align-items: center; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding-inline-start: 10px; }
.round-picker select { border: 0; box-shadow: none !important; min-height: 42px; font-weight: 700; padding-inline: 6px 30px; width: auto; max-width: 70vw; background-color: transparent; }

.content .stats { margin: 0; gap: 12px; }
.stats-3 { grid-template-columns: repeat(3, 1fr) !important; }
.stat { text-decoration: none; color: inherit; padding: 14px 16px; gap: 4px; }
a.stat:hover { border-color: #c8b6f3; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid var(--line); background: #fbfaff; }
.panel-head .tabs { border: 0; background: transparent; padding: 0; }
.panel-head .search { flex: 1 1 240px; max-width: 420px; margin-inline-start: auto; }
.panel > .flash { margin: 10px; }
.panel .rtable { border: 0; border-radius: 0; box-shadow: none; }
.panel .empty { padding: 40px 16px; text-align: center; color: var(--ink-2); font-weight: 600; }
.wa-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #effbf3; border: 1px solid #9fe0b8; border-radius: var(--radius); padding: 14px 16px; }

/* Lotteries page */
.lot-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.lot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; align-content: start; }
.lot-closed { background: #faf9fc; }
.lot-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.lot-head h2 { margin: 0; font-size: 1.15rem; }
.lot-head p { margin: 4px 0 0; }
.lot-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.lot-facts div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.lot-facts dt { font-size: .72rem; color: var(--ink-2); font-weight: 700; }
.lot-facts dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.lot-meta { margin: 0; }
.lot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 480px) { .lot-facts { grid-template-columns: repeat(2, 1fr); } }

/* Users / settings */
.user-cell { display: inline-flex; align-items: center; gap: 8px; }
.roles { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.roles legend { margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.role-opt { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.role-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.role-opt input { margin-top: 4px; accent-color: var(--brand); }
.role-opt span { display: grid; }
.role-opt small { color: var(--ink-2); }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.link-list a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); text-decoration: none; font-weight: 700; }
.field .label .ico { vertical-align: -4px; }
.settings-grid h2 { font-size: 1.05rem; }
.lookup-lottery { margin-bottom: 12px; }

/* Admin on tablets/phones: side menu slides in */
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 272px; max-width: 84vw; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  html[dir="rtl"] .side { transform: translateX(-105%); }
  .side { left: 0; right: auto; }
  body.side-open .side { transform: none; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 10, 40, .45); z-index: 35; }
  .side .side-x { display: grid; color: #fff; }
  .menu-btn { display: grid; }
  .mainbar { padding: 8px 12px; }
  .content { padding: 14px 12px 32px; gap: 12px; }
}
@media (max-width: 600px) {
  .stats-3 .stat-n { font-size: 1.25rem; }
  .panel-head .search { max-width: none; }
  .round-picker, .round-picker label, .round-picker select { width: 100%; max-width: none; }
}
html[lang="ar"] .steps > li::before { content: counter(s, arabic-indic); }

/* Orders table: fewer, tighter columns; never wider than the panel */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.otable td { vertical-align: middle; padding: 10px; }
.otable th { padding: 10px; }
.otable .buyer b, .otable .buyer .phone { display: block; }
.otable .buyer .phone { font-size: .88rem; margin-top: 2px; }
.otable .nums .chips { gap: 4px; }
.otable .nums .chip { min-width: 30px; height: 26px; font-size: .85rem; padding: 0 6px; }
.otable .amount { display: block; font-weight: 800; margin-top: 4px; }
.otable .ltag { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.otable .status > *, .otable .proof > * { display: block; width: max-content; max-width: 100%; }
.otable .status > * + *, .otable .proof > * + * { margin-top: 3px; }
@media (min-width: 900px) {
  .otable .buyer { min-width: 130px; }
  .otable .nums { min-width: 116px; }
  .otable td.actions { display: table-cell; width: 1%; }
  .otable td.actions form, .otable td.actions > .btn, .otable td.actions > span { display: flex; margin: 0 0 6px; }
  .otable td.actions .btn { width: 100%; white-space: nowrap; }
}
@media (max-width: 899px) {
  .table-scroll { overflow: visible; }
  .otable td.status, .otable td.proof, .otable td.nums { display: grid; grid-template-columns: 96px minmax(0, 1fr); }
  .otable td.status > *, .otable td.proof > *, .otable td.nums > * { grid-column: 2; }
}

/* ===== Audit fixes: long text, share link ===== */
h1, h2, h3, bdi, .lc-prize, .hero-prize, .buyer b, .d-name, .lead, .flash, .card p { overflow-wrap: anywhere; }
.ltag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.ltag-link { text-decoration: none; max-width: 100%; display: inline-flex; }
.order-head { min-width: 0; }
.otable .ref { overflow-wrap: anywhere; max-width: 200px; white-space: normal; }
.otable .status > * { white-space: normal; }
.proof-hint { margin: 0; color: var(--ink-2); font-weight: 600; }
.share-box { background: var(--surface-2); border-radius: 12px; padding: 10px; display: grid; gap: 6px; }
.share-label { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.share-row { display: flex; gap: 6px; align-items: center; }
.share-url { flex: 1; min-width: 0; min-height: 36px !important; padding: 6px 10px !important; font-size: .85rem !important; background: #fff; }
.pagebar .share-row { flex: 1 1 320px; max-width: 520px; }

/* ===== Lotteries: filters and full-width rows ===== */
.lot-filters { margin-bottom: 14px; }
.lot-filters .search { max-width: 600px; }
.sort-pick { min-height: 42px; width: auto; flex: 0 0 auto; }
.lot-grid { grid-template-columns: minmax(0, 1fr); }
.lot-main, .lot-side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.lot-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lot-facts dt { line-height: 1.25; }
@media (min-width: 760px) {
  .lot { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); column-gap: 18px; align-items: start; }
  .lot-side { grid-column: 1 / -1; }
}
@media (min-width: 1200px) {
  .lot { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.3fr); }
  .lot-side { grid-column: auto; }
  .lot-closed { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; }
  .lot-closed .lot-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lot-closed .lot-actions { flex-wrap: nowrap; }
}
/* Automatic WhatsApp state in the orders list */
.wa-st { display: inline-block; }
.wa-read { color: #0b6bcb; font-weight: 700; }
.wa-err { display: block; color: #8f1717; font-weight: 600; max-width: 260px; }
