:root {
  --navy: #1A3A52;
  --gold: #C9A96E;
  --cream: #FAF7F2;
  --ink: #1d2733;
  --muted: #6b7684;
  --line: #e7e1d6;
  --ok: #2e7d4f;
  --err: #b3261e;
  --warn: #9a6b00;
  --wa: #1fa855;
  --brand: var(--navy);
  --r: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  background: var(--cream); color: var(--ink); line-height: 1.5; font-size: 16px;
}
a { color: var(--navy); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: .05em; }
small { color: var(--muted); font-weight: 400; }

.container { max-width: 760px; margin: 0 auto; padding: 16px; }
.container.narrow { max-width: 480px; }
.container.wide { max-width: 1080px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 0 0 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card.highlight { border-color: var(--gold); background: #fffaf0; }

/* טפסים */
label { display: block; font-weight: 500; margin: 0 0 12px; font-size: .95rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { resize: vertical; }
input[type="color"] { padding: 4px; height: 46px; }
input[type="checkbox"] { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.row { display: flex; gap: 8px; align-items: stretch; }
.row input { margin: 0; }
.grid2, .grid3 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
/* שדה נסתר נגד בוטים. בלי הזזה לצד: בעברית הזזה שמאלה מרחיבה את הדף */
.hp { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
html, body { overflow-x: clip; }
.form-error { background: #fdecea; color: var(--err); border-radius: 10px; padding: 10px 12px; font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 18px;
  border-radius: 12px; border: 0; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--line); color: var(--ink); white-space: nowrap;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.big { width: 100%; padding: 15px; font-size: 1.05rem; }
.chip {
  display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 999px; font-size: .85rem; font-weight: 500;
  background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; cursor: pointer; font-family: inherit;
}
.chip.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.chip.danger { color: var(--err); }

.flash { margin: 12px auto; max-width: 760px; padding: 12px 16px; border-radius: 12px; background: #eef6f1; color: var(--ok); font-weight: 500; }
.flash.err { background: #fdecea; color: var(--err); }
.flash.warn { background: #fff4d6; color: var(--warn); max-width: none; }

/* ---------- הדף הציבורי ---------- */
body.public { background: var(--cream); }
.hero { background: var(--brand); color: #fff; text-align: center; padding: 32px 16px 56px; }
.hero.small { padding: 22px 16px 40px; }
.hero h1 { font-size: 1.7rem; margin: 10px 0 0; }
.hero .tagline { opacity: .85; margin: 4px 0 0; }
.logo { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255,255,255,.85); background: #fff; }
.logo.letter { display: inline-grid; place-items: center; font-size: 2.2rem; font-weight: 700; color: var(--brand); }
body.public main { margin-top: -36px; }
.club-card { position: relative; background: #fff; border-radius: 18px; padding: 22px 18px 18px; box-shadow: 0 6px 24px rgba(16,24,40,.1); margin-bottom: 18px; }
.club-badge { position: absolute; top: -12px; right: 18px; background: var(--gold); color: #fff; font-weight: 700; font-size: .8rem; padding: 3px 12px; border-radius: 999px; }
.club-card h2 { font-size: 1.3rem; margin-top: 4px; }
.benefit { font-size: 1.05rem; font-weight: 500; background: #fbf6ec; border-radius: 10px; padding: 10px 12px; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .9rem; color: var(--muted); }
.club-card.done { text-align: center; }
.check { width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 1.8rem; }
.benefit-code { font-family: ui-monospace, Menlo, monospace; font-size: 2.2rem; font-weight: 700; letter-spacing: .25em; background: var(--cream); border: 2px dashed var(--gold); border-radius: 14px; padding: 12px; margin: 10px 0; direction: ltr; }
.coupon { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 2px dashed var(--gold); border-radius: 14px; padding: 12px 14px; margin-bottom: 18px; font-weight: 500; }
.coupon .code { font: inherit; font-weight: 700; letter-spacing: .08em; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer; direction: ltr; }
.links { display: grid; gap: 10px; }
.link-btn { display: flex; align-items: center; gap: 12px; padding: 15px 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); font-weight: 500; }
.link-btn .ico svg, .tabbar .ico svg { width: 22px; height: 22px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.powered { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 0 32px; }
.powered a { color: var(--muted); }

/* ---------- אפליקציה / ניהול ---------- */
body.app { padding-bottom: 84px; }
.appbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--navy); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.appbar .biz { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-actions { display: flex; gap: 6px; }
.tabbar { position: fixed; bottom: 0; inset-inline: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 10px; font-size: .75rem; color: var(--muted); text-decoration: none; }
.tabbar a .ico svg { stroke: var(--muted); }
.tabbar a.on { color: var(--navy); font-weight: 700; }
.tabbar a.on .ico svg { stroke: var(--navy); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.stat .n { font-size: 1.8rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat .l { font-weight: 500; font-size: .9rem; }
.stat .s { color: var(--muted); font-size: .78rem; }
.redeem { font-weight: 500; padding: 8px 10px; border-radius: 8px; margin-top: 10px; }
.redeem.ok { background: #eef6f1; color: var(--ok); }
.redeem.warn { background: #fff4d6; color: var(--warn); }
.redeem.err { background: #fdecea; color: var(--err); }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bars li:last-child { border: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.count { background: var(--gold); color: #fff; font-size: .85rem; border-radius: 999px; padding: 2px 10px; vertical-align: middle; }
.search input { margin: 0 0 10px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tabs a { padding: 7px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .85rem; white-space: nowrap; }
.tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.members { list-style: none; padding: 0; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.member { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.member:last-child { border: 0; }
.member.sent { opacity: .55; }
.m-name { font-weight: 700; }
.m-sub { color: var(--muted); font-size: .88rem; }
.m-sub a { color: inherit; direction: ltr; unicode-bidi: embed; }
.m-side { text-align: left; }
.m-code { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; letter-spacing: .08em; }
.m-date { color: var(--muted); font-size: .78rem; }
.tag { font-size: .72rem; font-weight: 500; padding: 1px 8px; border-radius: 999px; }
.tag.ok { background: #eef6f1; color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; background: #fff; border: 1px dashed var(--line); border-radius: var(--r); }
.templates { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.msg-preview { white-space: pre-wrap; background: #e9f7ee; border-color: #cfe9d8; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 14px; }
.progress span { display: block; height: 100%; background: var(--wa); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: grid; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border: 0; }

.btn-rows { display: grid; gap: 8px; margin-bottom: 12px; }
.btn-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.btn-row input, .btn-row select { margin: 0; }
.btn-row .inline { display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; }
@media (min-width: 720px) { .btn-row { grid-template-columns: 1.2fr 2fr 70px auto auto auto; align-items: center; } .btn-row.add { grid-template-columns: 1fr 1.2fr 2fr auto; } }
.btn-row .sort { text-align: center; }

/* כניסה */
body.plain .container { padding-top: 8vh; }
.login { text-align: center; }
.login form { text-align: right; margin-top: 16px; }
.brand-mark { width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 16px; background: var(--navy); color: var(--gold); display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; }
.prose h2 { margin-top: 16px; }

/* ניהול */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form { display: inline; margin: 0; }
tr.paused td { opacity: .6; }
tr.paused td.actions { opacity: 1; }
.tag.off { background: #f1ece3; color: var(--muted); }
.btn.danger { background: var(--err); color: #fff; }
.danger-card { border-color: #f3c7c3; }
.danger-card ul { padding-inline-start: 20px; }
.danger-card hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.qr-cell img { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; }

/* =========================================================
   מערכת הניהול (אפליקציה + דשבורד + כניסה):
   כל דבר במסגרת עם שורת כותרת, פינות כמעט ישרות, בלי אלמנטים צפים
   ========================================================= */
.mgmt { --r: 2px; --frame: #cfc8bb; --head: #f1ede5; background: #f6f4f0; }
.mgmt .appbar { position: static; padding-top: 12px; border-bottom: 3px solid var(--gold); }
.mgmt .hbtn {
  display: inline-block; padding: 6px 12px; border: 1px solid rgba(255,255,255,.55); border-radius: 2px;
  color: #fff; text-decoration: none; font-size: .85rem; font-weight: 500; background: transparent;
}
.mgmt .hbtn:hover { background: rgba(255,255,255,.12); }
.mgmt .appbar-actions { gap: 8px; }

.mgmt .topnav { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); background: #fff; border-bottom: 1px solid var(--frame); }
.mgmt .topnav a {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 4px; font-size: .9rem;
  color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--frame); border-bottom: 3px solid transparent;
}
.mgmt .topnav a:first-child { border-inline-start: 0; }
.mgmt .topnav a.on { border-bottom-color: var(--navy); font-weight: 700; background: #faf8f4; }
.mgmt .topnav .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mgmt .topnav .badge { background: var(--err); color: #fff; font-size: .72rem; padding: 0 6px; border-radius: 2px; }
body.app.mgmt { padding-bottom: 24px; }

.panel { background: #fff; border: 1px solid var(--frame); border-radius: 2px; margin: 0 0 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--head); border-bottom: 1px solid var(--frame); }
.panel-h h2 { margin: 0; font-size: 1rem; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.panel-b { padding: 14px; }
.panel-b > :last-child { margin-bottom: 0; }
.panel.flush .panel-b { padding: 0; }
.panel.danger { border-color: #e2a8a3; }
.panel.danger .panel-h { background: #fbeceb; border-color: #e2a8a3; color: var(--err); }
.panel.highlight { border-color: var(--gold); }
.panel.highlight .panel-h { background: #f8efdd; border-color: var(--gold); }

.mgmt .btn, .mgmt .chip, .mgmt input, .mgmt select, .mgmt textarea, .mgmt .tag, .mgmt .count, .mgmt .flash { border-radius: 2px; }
.mgmt .btn { padding: 10px 16px; border: 1px solid var(--frame); background: #fff; }
.mgmt .btn.primary { background: var(--navy); border-color: var(--navy); }
.mgmt .btn.wa { background: var(--wa); border-color: var(--wa); }
.mgmt .btn.danger { background: var(--err); border-color: var(--err); }
.mgmt .btn.big { padding: 13px; }
.mgmt .chip { padding: 6px 10px; border-color: var(--frame); }
.mgmt input, .mgmt select, .mgmt textarea { border-width: 1px; border-color: var(--frame); }
.mgmt .flash { margin: 12px auto 0; border: 1px solid #b9d8c4; border-inline-start: 4px solid var(--ok); max-width: 728px; }
.mgmt .flash.err { border-color: #e2a8a3; border-inline-start-color: var(--err); }
.mgmt .flash.warn { border-color: #e6cf94; border-inline-start-color: var(--warn); max-width: none; margin: 0 0 16px; }
.mgmt .count { padding: 1px 8px; }

.mgmt .stats { gap: 0; border: 1px solid var(--frame); background: #fff; margin: 0; }
.mgmt .stat { border: 0; border-radius: 0; padding: 0; border-inline-start: 1px solid var(--frame); border-bottom: 1px solid var(--frame); }
.mgmt .stat .l { background: var(--head); border-bottom: 1px solid var(--frame); padding: 6px 10px; font-size: .82rem; }
.mgmt .stat .n { padding: 10px 10px 0; }
.mgmt .stat .s { padding: 0 10px 10px; }
@media (min-width: 640px) { .mgmt .stat { border-bottom: 0; } }
.mgmt .panel.flush .stats { border: 0; }

.mgmt .tabs { gap: 0; border: 1px solid var(--frame); width: max-content; max-width: 100%; }
.mgmt .tabs a { border-radius: 0; border: 0; border-inline-start: 1px solid var(--frame); padding: 7px 12px; }
.mgmt .tabs a:first-child { border-inline-start: 0; }
.mgmt .members { border: 1px solid var(--frame); border-radius: 0; }
.mgmt .panel .members { border-width: 1px 0 0; }
.mgmt .member { border-bottom-color: var(--frame); }
.mgmt .empty { border-radius: 0; border-color: var(--frame); }
.mgmt .progress { border-radius: 0; }
.mgmt table { border: 1px solid var(--frame); }
.mgmt .panel table { border-width: 0; }
.mgmt th { background: var(--head); color: var(--ink); border-bottom: 1px solid var(--frame); }
.mgmt td { border-bottom-color: var(--frame); }
.mgmt .msg-preview { border: 1px solid #cfe9d8; background: #eef8f1; padding: 12px; white-space: pre-wrap; }
.mgmt .btn-row { border-radius: 0; border-color: var(--frame); }
.mgmt .panel-b .search input { margin-bottom: 10px; }
.mgmt .panel-b .tabs { margin-bottom: 12px; }
.mgmt .login-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; background: var(--navy); color: var(--gold); font-weight: 700; font-size: 1.4rem; border-radius: 2px; }
.mgmt .qr-cell img { border-radius: 0; }

/* מסך קופה */
.pos-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--frame); }
.pos-row:last-child { border-bottom: 0; }
.pos-row .who { font-weight: 700; font-size: 1.05rem; }
.pos-row .meta { color: var(--muted); font-size: .85rem; }
.pos-row .acts { display: flex; gap: 6px; }
.pos-row.reward { background: #fbf6ec; }

/* כרטיסייה בדף הלקוח */
.punch-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0; direction: rtl; }
.punch { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; color: var(--line); }
.punch.on { border: 2px solid var(--brand); background: var(--brand); color: #fff; }
.punch.gift { border-color: var(--gold); color: var(--gold); }
.punch-count { text-align: center; font-weight: 700; font-size: 1.1rem; }
.pending-box { text-align: center; background: #fbf6ec; border: 2px dashed var(--gold); border-radius: 12px; padding: 14px; font-weight: 500; }
.reward-box { text-align: center; background: var(--ok); color: #fff; border-radius: 12px; padding: 16px; font-weight: 700; font-size: 1.1rem; }
.find-form { margin-top: 10px; }
.find-form summary { cursor: pointer; color: var(--muted); font-size: .9rem; text-align: center; }

.panel hr { border: 0; border-top: 1px solid var(--frame); margin: 14px 0; }
.panel ul { padding-inline-start: 20px; }

.panel .pad { padding: 14px; }
@media (max-width: 420px) { .mgmt .topnav .ico { display: none; } .mgmt .topnav a { font-size: .85rem; } }

.req-code { font-family: ui-monospace, Menlo, monospace; font-size: 2.6rem; font-weight: 700; letter-spacing: .1em; color: var(--brand); margin: 6px 0; direction: ltr; }
.pos-code { font-family: ui-monospace, Menlo, monospace; font-size: 1.4rem; font-weight: 700; border: 2px solid var(--navy); padding: 2px 8px; margin-inline-end: 10px; color: var(--navy); }
.pos-row .left { display: flex; align-items: center; }
.pos-row.undone { opacity: .5; text-decoration: line-through; }
.peak-on { background: #fff4d6; border-color: #e6cf94; }
.push-status { font-weight: 500; }
