:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #2b2620;
  --muted: #7a7266;
  --line: #e8e1d5;
  --accent: #9a7b4f;
  --accent-ink: #ffffff;
  --accent-soft: #f3ead9;
  --green: #3d7a4f;
  --green-soft: #e7f2ea;
  --red: #a2453c;
  --red-soft: #f8e9e7;
  --amber: #9a7b1f;
  --amber-soft: #f7f0d8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 38, 32, 0.05), 0 8px 24px rgba(43, 38, 32, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Heebo", "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.wrap-narrow { max-width: 640px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; color: var(--ink); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 0.85rem; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  padding: 9px 16px; font-size: 0.95rem; font-family: inherit;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; border-radius: 8px; }

input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 9px 10px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.8rem; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.gray { background: var(--accent-soft); color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 9px 16px; border-radius: 10px 10px 0 0; color: var(--muted); font-size: 0.95rem;
}
.tabs a.active { background: var(--surface); border: 1px solid var(--line); border-bottom-color: var(--surface); color: var(--ink); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* Invitation page */
.invite-hero {
  text-align: center; padding: 48px 20px 32px;
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  border-radius: 0 0 32px 32px;
}
.invite-hero .eyebrow { letter-spacing: 0.2em; font-size: 0.8rem; color: var(--accent); text-transform: uppercase; }
.invite-hero h1 { font-size: 2rem; margin: 8px 0 4px; }
.invite-hero .hebdate { color: var(--muted); }

.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  flex: 1; min-width: 110px; text-align: center; padding: 14px 8px;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; font-size: 1rem; font-family: inherit; transition: all 0.15s;
}
.choice.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.notice { padding: 12px 16px; border-radius: 10px; margin: 12px 0; }
.notice.green { background: var(--green-soft); color: var(--green); }
.notice.amber { background: var(--amber-soft); color: var(--amber); }

@media (max-width: 560px) {
  .wrap { padding: 16px 10px 48px; }
  .card { padding: 14px; }
}

/* Numeric stepper: always LTR so minus/plus keep their places in RTL pages. */
.stepper { display: flex; gap: 8px; direction: ltr; align-items: stretch; }
.stepper input { text-align: center; font-size: 1.1rem; font-weight: 600; width: 72px; flex: 1; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.step-btn { flex: 0 0 44px; font-size: 1.3rem; font-weight: 700; padding: 8px 0; line-height: 1; }

/* ── Megiim identity refinements ─────────────────────────────────────── */
h1, .invite-hero h1, .stat .num {
  font-family: "Frank Ruhl Libre", "Heebo", serif;
}
h1 { font-weight: 800; letter-spacing: -0.01em; }

.topbar { padding: 12px 20px; }
.topbar .brand { font-family: "Frank Ruhl Libre", serif; font-size: 1.15rem; font-weight: 800; }
.topbar .brand::before { content: "💌 "; }

/* Clickable stat tiles: same tile, honest affordance. */
a.stat { display: block; color: inherit; }
a.stat:hover { text-decoration: none; }
.stat.clickable { cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
.stat.clickable:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.stat .num { font-size: 1.9rem; }

/* Funnel: one connected strip instead of loose tiles. */
.funnel { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.fstep {
  flex: 1; min-width: 96px; text-align: center; padding: 10px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .85rem; transition: border-color .15s, transform .15s;
}
.fstep b { display: block; font-family: "Frank Ruhl Libre", serif; font-size: 1.5rem; color: var(--ink); }
.fstep:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.fstep.gold { background: var(--accent-soft); border-color: var(--accent); }
.fstep.gold b { color: var(--accent); }
.farrow { align-self: center; color: var(--muted); flex: 0 0 auto; }

/* Credits panel */
.credits-card h2 { margin-bottom: 12px; }
.wa-line { margin: 0 0 10px; font-weight: 500; }
.wa-line.ok { color: var(--green); }
.wa-line.warn { color: var(--amber); }
.balance-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 12px 0 6px; }
.balance { display: flex; flex-direction: column; line-height: 1.3; }
.balance .lbl { color: var(--muted); font-size: .8rem; }
.balance .amount { font-family: "Frank Ruhl Libre", serif; font-size: 2rem; font-weight: 800; direction: ltr; }
.packs { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.pack { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn.pack:hover { background: var(--accent); color: var(--accent-ink); }

/* Filter chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 99px; padding: 5px 14px; font-size: .85rem; font-family: inherit; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
