/* ===== Maison Maryjane — Fidélité ===== */
:root {
  --green: #4caf50;
  --green-dark: #3a8f3e;
  --green-soft: #e8f5e9;
  --red: #e0483d;
  --red-dark: #c53a30;
  --red-soft: #fdecea;
  --ink: #1c1c1e;
  --ink-2: #3a3a3c;
  --muted: #8a8a8e;
  --line: #e6e6e3;
  --bg: #f4f4f2;
  --card: #ffffff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.06);
  --font-display: "Fjalla One", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 400; letter-spacing: .3px; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- Layout ---------- */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 820px; margin: 0 auto; padding: 20px 18px 40px; flex: 1; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; padding-top: max(12px, env(safe-area-inset-top));
}
.topbar .brand-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .leaf { width: 26px; height: 26px; flex: none; }
.topbar .brand-txt { line-height: 1.05; min-width: 0; }
.topbar .brand-txt b { font-family: var(--font-display); font-size: 16px; display: block; letter-spacing: .5px; text-transform: uppercase; }
.topbar .brand-txt span { font-size: 11px; color: #b9b9bd; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.super { background: var(--green); }
.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 40px; height: 40px; border-radius: 999px; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }

.tabs { display: flex; gap: 8px; margin-top: 4px; }
.tabs button {
  border: none; background: transparent; color: var(--muted);
  padding: 10px 4px; font-weight: 700; font-size: 15px; border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--green); }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 999px; padding: 15px 22px; font-size: 16px; font-weight: 700;
  background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .05s ease, filter .15s ease; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn.green { background: var(--green); }
.btn.green:hover { background: var(--green-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: var(--red-dark); }
.btn.sm { padding: 10px 16px; font-size: 14px; width: auto; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- Cards & fields ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 16px; background: #fff; color: var(--ink); outline: none; transition: border-color .15s;
}
.input:focus, select.input:focus { border-color: var(--green); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.err { color: var(--red-dark); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 22px;
  background: radial-gradient(1200px 500px at 50% -10%, #2a2a2c 0%, var(--ink) 55%); }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 30px 26px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.login-logo .leaf { width: 54px; height: 54px; }
.login-logo b { font-family: var(--font-display); font-size: 24px; text-transform: uppercase; letter-spacing: 1px; }
.login-logo span { font-size: 13px; color: var(--muted); }

/* ---------- Search ---------- */
.search-hero { position: relative; margin-bottom: 8px; }
.search-hero .search-input {
  width: 100%; padding: 18px 18px 18px 52px; font-size: 18px; border-radius: 16px;
  border: 1.5px solid var(--line); background: #fff; outline: none;
}
.search-hero .search-input:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.search-hero .mag { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; }

.result-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.result {
  display: flex; align-items: center; gap: 14px; background: var(--card); border: 1.5px solid transparent;
  border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-sm); text-align: left; width: 100%;
}
.result:hover { border-color: var(--green); }
.avatar { width: 44px; height: 44px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: var(--font-display); flex: none; }
.result .who { flex: 1; min-width: 0; }
.result .who b { font-size: 16px; display: block; }
.result .who small { color: var(--muted); }
.result .pts { font-family: var(--font-display); font-size: 20px; color: var(--green-dark); }
.result .pts small { font-size: 11px; color: var(--muted); display: block; text-align: right; font-family: var(--font-body); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Client detail ---------- */
.back { background: none; border: none; color: var(--muted); font-weight: 600; font-size: 15px; padding: 4px 0; margin-bottom: 10px; display: inline-flex; gap: 6px; align-items: center; }
.client-head { text-align: center; padding: 18px 0 6px; }
.client-head .avatar-lg { width: 76px; height: 76px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 30px; margin: 0 auto 12px; }
.client-head h1 { font-size: 26px; margin: 0; }
.client-head .meta { color: var(--muted); font-size: 14px; margin-top: 6px; }
.balance { text-align: center; margin: 18px 0 22px; }
.balance .num { font-family: var(--font-display); font-size: 68px; line-height: 1; color: var(--ink); }
.balance .lbl { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: var(--muted); margin-top: 4px; }

.qty-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; }
.qty-row label { font-weight: 600; color: var(--ink-2); }
.qty-input { width: 120px; text-align: center; font-size: 22px; font-family: var(--font-display); padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); }
.qty-input:focus { outline: none; border-color: var(--green); }
.presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.preset { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 700; color: var(--ink-2); }
.preset:hover { border-color: var(--ink); }

.pm-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pm {
  border: none; border-radius: 20px; padding: 30px 10px; color: #fff; font-family: var(--font-display);
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .06s ease, filter .15s;
}
.pm:active { transform: scale(.97); }
.pm .sign { font-size: 52px; line-height: 1; }
.pm .txt { font-size: 15px; letter-spacing: .5px; }
.pm.plus { background: var(--green); box-shadow: 0 10px 26px rgba(76,175,80,.35); }
.pm.plus:hover { background: var(--green-dark); }
.pm.minus { background: var(--red); box-shadow: 0 10px 26px rgba(224,72,61,.30); }
.pm.minus:hover { background: var(--red-dark); }
.pm:disabled { opacity: .45; pointer-events: none; }

/* ---------- Tables (supervisor) ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar .input { flex: 1; min-width: 160px; }
.toolbar select.input { max-width: 200px; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--card); }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: 13px 14px; font-size: 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; background: #fafafa; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
.delta { font-family: var(--font-display); font-size: 16px; }
.delta.pos { color: var(--green-dark); }
.delta.neg { color: var(--red-dark); }
.badge { display: inline-block; background: var(--green-soft); color: var(--green-dark); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.row-actions { display: flex; gap: 8px; }
.mini { border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.mini:hover { border-color: var(--ink); }
.mini.del { color: var(--red-dark); border-color: var(--red-soft); }
.mini.del:hover { border-color: var(--red); }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.section-title h2 { font-size: 20px; margin: 0; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0; }
.modal { background: #fff; width: 100%; max-width: 460px; border-radius: 22px 22px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 16px; font-size: 20px; }
@media (min-width: 620px) { .modal-back { align-items: center; } .modal { border-radius: 22px; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(30px);
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 999px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--green-dark); }
.toast.bad { background: var(--red-dark); }

.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: flex; justify-content: center; padding: 40px; }
.center-load .spinner { border-color: var(--line); border-top-color: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }
.mt { margin-top: 16px; }
.muted { color: var(--muted); }

/* ---------- Stats (rapport) ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 6px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 16px; text-align: center; }
.stat .n { font-family: var(--font-display); font-size: 34px; line-height: 1; color: var(--green-dark); }
.stat .l { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 6px; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr; } .stat { display: flex; align-items: baseline; justify-content: center; gap: 10px; } .stat .l { margin-top: 0; } }
