/* Loyalty Points — design system. Arabic-first (RTL), logical properties throughout, mobile-first. */
:root {
    --brand: #0E7C66;
    --brand-600: #0B6A57;
    --brand-50: #E7F5F1;
    --accent: #D97706;
    --accent-50: #FEF3C7;
    --ink: #0F172A;
    --ink-2: #334155;
    --muted: #64748B;
    --line: #E2E8F0;
    --bg: #F6F8FA;
    --card: #FFFFFF;
    --danger: #DC2626;
    --danger-50: #FEE2E2;
    --ok: #059669;
    --ok-50: #D1FAE5;
    --warn: #B45309;
    --warn-50: #FEF3C7;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 12px rgb(15 23 42 / .05);
    --shadow-lg: 0 12px 32px rgb(15 23 42 / .14);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-ar: "IBM Plex Sans Arabic", "Cairo", Tahoma, sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5; min-height: 100vh; overflow-x: hidden; overflow-wrap: break-word; }
.grow, .card, .item, .modal, td.wrap-cell { overflow-wrap: anywhere; }
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] button, [dir="rtl"] select, [dir="rtl"] textarea { font-family: var(--font-ar); }
input, button, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- layout */
.wrap { max-width: 1200px; margin-inline: auto; padding-inline: 16px; }
.narrow { max-width: 520px; }
.stack > * + * { margin-block-start: 12px; }
.stack-lg > * + * { margin-block-start: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.pos-layout { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .pos-layout { grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr); align-items: start; } .sticky { position: sticky; top: 76px; } }
main { padding-block: 20px 64px; }

/* ---------------- topbar */
.topbar { position: sticky; top: 0; z-index: 30; background: rgb(255 255 255 / .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #13a083); color: #fff; display: grid; place-items: center; font-size: 15px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--brand-50); text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.tabbar { display: none; }
@media (max-width: 760px) {
    .topbar .nav.desktop { display: none; }
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px env(safe-area-inset-bottom); justify-content: space-around; box-sizing: border-box; }
    /* Fixed height (60px + safe area) in every language so sticky/fixed bars above it can offset exactly. */
    .tabbar { height: calc(60px + env(safe-area-inset-bottom)); align-items: flex-start; }
    .tabbar a { display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); padding: 4px 2px; gap: 2px;
        flex: 1 1 0; min-width: 0; max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
    .tabbar a > * { max-width: 100%; }
    .tabbar a .ico { font-size: 1.25rem; line-height: 1; }
    .tabbar a.active { color: var(--brand); font-weight: 700; }
    .tabbar a:hover { text-decoration: none; }
    main { padding-block-end: 96px; }
}

/* ---------------- cards & text */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.card.tight { padding: 12px 14px; }
.card h2, .card h3 { margin-block-end: 10px; }
h1 { font-size: clamp(1.45rem, 2.6vw, 2rem); line-height: 1.25; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .76rem; }
.bold { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.center { text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--brand-50); color: var(--brand-600); white-space: nowrap; }
.pill.warn { background: var(--warn-50); color: var(--warn); }
.pill.danger { background: var(--danger-50); color: var(--danger); }
.pill.gray { background: #F1F5F9; color: var(--ink-2); }
.divider { height: 1px; background: var(--line); margin-block: 12px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .ico { font-size: 2rem; display: block; margin-block-end: 6px; }

/* ---------------- KPIs */
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.kpi .value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: .78rem; font-weight: 700; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: #EEF2F6; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------------- forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #CBD5E1; border-radius: var(--radius-sm); background: #fff; font-size: 1rem; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input.big { min-height: 54px; font-size: 1.15rem; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.form-error { color: var(--danger); font-size: .88rem; font-weight: 600; }

/* ---------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 700; cursor: pointer; background: #EEF2F6; color: var(--ink); white-space: nowrap; transition: background .15s; }
.btn:hover { background: #E2E8F0; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: #F8FAFC; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .86rem; }
.btn.lg { min-height: 54px; font-size: 1.08rem; padding-inline: 22px; }
.btn.block { width: 100%; }
.btn.busy { pointer-events: none; opacity: .7; }
.icon-btn { min-width: 40px; min-height: 40px; padding: 6px; }

/* ---------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
.t th, .t td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t th { background: #F8FAFC; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.t tr:last-child td { border-bottom: 0; }
.t td.wrap-cell { white-space: normal; min-width: 180px; }
.t tr.clickable { cursor: pointer; }
.t tr.clickable:hover td { background: #F8FAFC; }

/* ---------------- list items / POS */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.item.selectable { cursor: pointer; }
.item.selectable:hover { border-color: var(--brand); }
.svc-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.svc { text-align: start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 76px; }
.svc:hover { border-color: var(--brand); background: var(--brand-50); }
.svc .price { font-weight: 800; color: var(--brand-600); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: .86rem; font-weight: 600; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart-line:last-child { border-bottom: 0; }
.totals { display: grid; gap: 6px; }
/* POS cart: on wide screens the panel is capped to the viewport and scrolls internally; the payment
   block (totals + Complete) is sticky at the bottom so it is always visible however long the cart is. */
.cart-panel { display: flex; flex-direction: column; }
.cart-panel > * { flex-shrink: 0; }
.cart-pay { position: sticky; bottom: -18px; z-index: 2; background: #fff; margin: 4px -18px -18px; padding: 12px 18px 18px;
    border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); display: flex; flex-direction: column; gap: 10px;
    box-shadow: 0 -6px 12px -10px rgb(15 23 42 / .25); }
@media (min-width: 960px) {
    /* 150px = top bar + optional plan banner + gaps, so the panel fits even when the page is not scrolled. */
    .cart-panel { max-height: calc(100vh - 150px); overflow-y: auto; overscroll-behavior: contain; }
    @supports (height: 100dvh) { .cart-panel { max-height: calc(100dvh - 150px); } }
    .pos-mobile-bar { display: none !important; }
}
/* Phones/tablets (single column): a compact fixed bar keeps Total + Complete always reachable. */
.pos-mobile-bar { display: none; }
@media (max-width: 959px) {
    .pos-mobile-bar { display: flex; align-items: center; gap: 12px; position: fixed; inset-inline: 0; left: 0; right: 0; bottom: 0; z-index: 35;
        background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 20px -12px rgb(15 23 42 / .35);
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
    .pos-mobile-bar a { color: inherit; text-decoration: none; min-width: 0; }
    .pos-layout { padding-bottom: 84px; }
}
@media (max-width: 760px) { .pos-mobile-bar { bottom: calc(60px + env(safe-area-inset-bottom)); padding-bottom: 10px; } }
@media (max-width: 959px) { .cart-pay { bottom: 0; } }
/* Long page forms: the primary action stays visible at the bottom of the viewport while the form is on screen. */
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: #fff; margin: 8px -18px -18px; padding: 12px 18px;
    border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 12px -10px rgb(15 23 42 / .25); }
.sticky-actions.bare { margin: 8px 0 0; border-radius: var(--radius-sm); }
@media (max-width: 760px) { .sticky-actions { bottom: calc(60px + env(safe-area-inset-bottom)); } }
@media (max-width: 760px) { .cart-pay { bottom: calc(60px + env(safe-area-inset-bottom)); } }
.totals .row { flex-wrap: nowrap; justify-content: space-between; }
.totals .grand { font-size: 1.35rem; font-weight: 800; }
.balance-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.balance-strip > div { background: #F8FAFC; border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.balance-strip b { display: block; font-size: 1.15rem; }
.stamps { display: flex; gap: 6px; flex-wrap: wrap; }
.stamp { width: 30px; height: 30px; border-radius: 50%; border: 2px dashed #CBD5E1; display: grid; place-items: center; font-size: .9rem; }
.stamp.on { background: var(--brand); border: 2px solid var(--brand); color: #fff; }

/* ---------------- membership card (customer pass) */
.member-card { border-radius: 20px; padding: 22px; color: #fff; background: linear-gradient(140deg, var(--tc1, #0E7C66), var(--tc2, #0F172A)); box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.member-card::after { content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgb(255 255 255 / .08); }
.member-card .big { font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.qr-box { background: #fff; border-radius: 16px; padding: 14px; display: inline-block; }
.qr-box svg { display: block; width: 200px; height: 200px; }

/* ---------------- landing */
.hero { padding-block: 40px 24px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.15; letter-spacing: -.01em; }
.hero p.lead { font-size: 1.12rem; color: var(--ink-2); max-width: 640px; }
.feature .ico { font-size: 1.6rem; }
.price-card { display: flex; flex-direction: column; gap: 10px; }
.price-card .amount { font-size: 1.8rem; font-weight: 800; }
.price-card ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.price-card li::before { content: "✓ "; color: var(--brand); font-weight: 800; }
.price-card.featured { border: 2px solid var(--brand); }
.section { padding-block: 32px; }
.section-title { text-align: center; margin-block-end: 20px; }
.industry-pick { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.industry-pick label { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; background: #fff; font-weight: 600; font-size: .9rem; }
.industry-pick input { accent-color: var(--brand); }
.industry-pick label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
details.faq { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff; }
details.faq summary { cursor: pointer; font-weight: 700; }
details.faq p { margin-block-start: 8px; color: var(--ink-2); }

/* ---------------- overlays */
.toast-host { position: fixed; inset-inline: 0; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; padding-inline: 16px; }
@media (max-width: 760px) { .toast-host { bottom: 84px; } }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; max-width: 520px; pointer-events: auto; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
/* Modal — robust across browsers:
   - explicit top/right/bottom/left (no `inset` shorthand) on a fixed overlay appended to <body>;
   - centred with `margin: auto` inside a flex overlay = "safe" centring: if the dialog is ever taller
     than the screen it is NOT pushed above the top edge (align-items:center would clip it);
   - height capped with a vh fallback, dvh only where supported (mobile browser bars);
   - the dialog scrolls internally; its action row is pinned to the bottom. */
.modal-back { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; z-index: 90;
    background: rgb(15 23 42 / .5); display: flex; overflow-y: auto; padding: 16px; }
.modal { margin: auto; flex: 0 1 auto; width: 560px; max-width: 100%; max-height: calc(100vh - 32px);
    display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
    background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-lg); }
@supports (height: 100dvh) { .modal { max-height: min(90dvh, calc(100dvh - 32px)); } }
.modal > * { flex-shrink: 0; }
/* Pinned action rows (no :has() — an unsupported selector would void the whole rule in older browsers). */
.modal .modal-actions, .modal > .row.end:last-child, .modal > form > .row.end:last-child {
    position: sticky; bottom: -20px; z-index: 1; background: #fff; margin: 8px -20px -20px; padding: 12px 20px;
    border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.modal.wide { width: 760px; }
/* Long multi-section dialogs: title + close stay visible while the body scrolls. */
.modal .modal-head { position: sticky; top: -20px; z-index: 2; background: #fff; margin: -20px -20px 0; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.spinner { width: 22px; height: 22px; border: 3px solid #CBD5E1; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 40px; }
.banner { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-50); color: var(--warn); font-weight: 600; font-size: .9rem; }
.banner.info { background: var(--brand-50); color: var(--brand-600); }

/* ---------------- receipt / print */
.receipt { max-width: 380px; margin-inline: auto; font-size: .92rem; }
.receipt .line { display: flex; justify-content: space-between; gap: 8px; }
@media print {
    .topbar, .tabbar, .no-print, .toast-host { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; }
    main { padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 480px) { .hide-sm { display: none; } }
