:root {
  --bg: #080c1c;
  --panel: #0c1330;
  --panel-2: #111a3d;
  --gold: #bd9a3f;
  --gold-2: #d6b768;
  --text: #f2ede1;
  --muted: rgba(242, 237, 225, 0.62);
  --line: rgba(214, 183, 104, 0.22);
  --ok: #8fd4ab;
  --err: #e0a0a0;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 'Montserrat', system-ui, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}
body.area-gerant { padding-bottom: 40px; }
a { color: var(--gold-2); }
h1, h2 { font-family: 'Oswald', sans-serif; font-weight: 600; letter-spacing: 0.02em; margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; color: var(--gold-2); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.gold { color: var(--gold-2); }
.mono, code { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.06em; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(8, 12, 28, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85rem; }
.topbar-brand img { height: 34px; width: auto; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; padding: 6px; }

.page { max-width: 560px; margin: 0 auto; padding: 18px 16px; }
.area-gerant .page { max-width: 1000px; }

/* Cartes */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.card.prose p { color: var(--muted); }
.card.prose strong { color: var(--text); }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.pill { background: rgba(189, 154, 63, 0.15); color: var(--gold-2); border-radius: 999px; padding: 5px 12px; font-weight: 600; font-size: 0.85rem; }

/* Formulaires */
.form label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold-2); margin: 14px 0 6px; font-weight: 600; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=tel],
.form input[type=date], .form input[type=number], .form input[type=search], .form input[type=time] {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.form input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.form .btn { margin-top: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; text-transform: none !important; letter-spacing: 0 !important; color: var(--muted) !important; font-weight: 400 !important; font-size: 0.85rem !important; margin-top: 18px !important; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold); flex: none; }
.inline-form { display: flex; gap: 10px; margin-bottom: 14px; }
.inline-form input { flex: 1; }
.inline-form .btn { margin-top: 0; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 22px; border-radius: 10px; border: 1px solid var(--gold);
  font: 600 0.88rem 'Montserrat', sans-serif; letter-spacing: 0.04em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; transition: background .2s, color .2s;
}
.btn-gold { background: var(--gold); color: var(--bg); }
.btn-gold:hover { background: var(--gold-2); }
.btn-outline { background: transparent; color: var(--gold-2); }
.btn-outline:hover { background: rgba(189, 154, 63, 0.12); }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.75rem; }
.stack { display: grid; gap: 12px; margin-top: 22px; }
.actions-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* Alertes */
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 0.9rem; }
.alert-error { background: rgba(190, 90, 90, 0.15); color: var(--err); }
.alert-success { background: rgba(90, 170, 120, 0.15); color: var(--ok); }
.alert-info { background: rgba(189, 154, 63, 0.14); color: var(--gold-2); }

/* Accueil */
.hero-app { text-align: center; padding: 18px 4px 6px; }
.hero-logo { width: 150px; height: auto; margin-bottom: 12px; }
.hero-app h1 { font-size: 1.9rem; }
.steps { display: grid; gap: 10px; margin: 26px 0; }
.step { display: flex; gap: 14px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.step span { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--bg); display: grid; place-items: center; font-weight: 700; }
.step p { margin: 3px 0 0; color: var(--muted); }
.fineprint { text-align: center; font-size: 0.8rem; margin-top: 18px; }
.fineprint a { color: var(--muted); }
.lock { font-size: 2.4rem; margin-bottom: 6px; }

/* Carte fidelite */
.loyalty-card {
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 22px;
  margin-bottom: 16px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(214, 183, 104, 0.35), transparent 55%),
    linear-gradient(135deg, #16205a, #0c1330 60%, #080c1c);
  border: 1px solid rgba(214, 183, 104, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.lc-top { display: flex; align-items: center; justify-content: space-between; }
.lc-top img { height: 44px; width: auto; }
.lc-top span { font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.75rem; color: var(--gold-2); }
.lc-points { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.lc-points .num { font-family: 'Oswald', sans-serif; font-size: 3.6rem; line-height: 1; color: var(--gold-2); }
.lc-points .unit { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85rem; color: var(--muted); }
.lc-name { font-weight: 600; font-size: 1.05rem; }
.lc-since { color: var(--muted); font-size: 0.78rem; }
.progress { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; margin: 10px 0 8px; border: 1px solid var(--line); }
.progress div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 999px; }
.voucher-banner { display: block; text-decoration: none; color: var(--text); border-color: var(--gold); background: rgba(189, 154, 63, 0.12); }
.voucher-banner span { display: block; color: var(--gold-2); font-size: 0.85rem; margin-top: 4px; }

/* Recompenses */
.reward { display: flex; gap: 14px; align-items: center; justify-content: space-between; }
.reward h2 { color: var(--text); margin-bottom: 4px; }
.reward p { margin: 0; }
.reward-side { text-align: right; display: grid; gap: 8px; justify-items: end; flex: none; }
.reward .cost { font-family: 'Oswald', sans-serif; color: var(--gold-2); font-size: 1.1rem; }
.reward.locked { opacity: 0.6; }

/* Bon */
.voucher h1 { color: var(--gold-2); font-size: 1.8rem; }
.voucher-code { font-family: ui-monospace, Menlo, monospace; font-size: 2.8rem; letter-spacing: 0.12em; font-weight: 700; background: #fff; color: var(--bg); border-radius: 12px; padding: 14px 10px; margin: 16px 0; }
.voucher-name { font-size: 1.15rem; font-weight: 600; }
.big-icon { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto 14px; font-size: 2.2rem; background: rgba(189, 154, 63, 0.15); }
.big-icon.ok { background: rgba(90, 170, 120, 0.2); color: var(--ok); }
.gain { font-family: 'Oswald', sans-serif; font-size: 2.6rem; color: var(--gold-2); margin: 0 0 8px; }

/* Historique */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history li div { display: grid; }
.delta { font-family: 'Oswald', sans-serif; font-size: 1.15rem; }
.delta.plus { color: var(--ok); }
.delta.minus { color: var(--err); }

details.danger summary { cursor: pointer; color: var(--err); font-weight: 600; }
details.danger[open] summary { margin-bottom: 12px; }

/* Barre d'onglets (clients) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(12, 19, 48, 0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 0.64rem; font-weight: 600; }
.tabbar a.on { color: var(--gold-2); }

/* Espace gerant */
.gerant-nav { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px; max-width: 1000px; margin: 0 auto; }
.gerant-nav a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.gerant-nav a.on { background: var(--gold); border-color: var(--gold); color: var(--bg); }
.gerant-nav .borne-link { margin-left: auto; color: var(--gold-2); border-color: var(--gold); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 2px; }
.kpi .num { font-family: 'Oswald', sans-serif; font-size: 2rem; color: var(--gold-2); }
.kpi .small-num { font-size: 1.1rem; }
.kpi span:last-child { color: var(--muted); font-size: 0.82rem; }
.howto { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 8px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
.table th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold-2); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: rgba(189, 154, 63, 0.06); }
.actions-cell { display: flex; gap: 8px; justify-content: flex-end; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.b-pending { background: rgba(189, 154, 63, 0.18); color: var(--gold-2); }
.b-used { background: rgba(90, 170, 120, 0.16); color: var(--ok); }
.b-expired { background: rgba(190, 90, 90, 0.14); color: var(--err); }
.voucher-check { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 6px; }
.voucher-check.pending { border-color: var(--ok); }

/* Borne d'entree (plein ecran) */
body.borne { padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 100vh; gap: 6px; }
.borne-logo { width: 140px; height: auto; }
.borne h1 { font-size: clamp(1.8rem, 5vw, 3rem); margin: 8px 0 0; }
.borne h1 span { color: var(--gold-2); }
.borne p { color: var(--muted); font-size: 1.1rem; }
.borne-qr { width: min(70vw, 60vh, 460px); aspect-ratio: 1; background: #fff; border-radius: 22px; padding: 18px; margin: 12px 0; display: grid; place-items: center; color: var(--bg); }
.borne-qr svg { width: 100%; height: 100%; display: block; }
.borne-timer { width: min(70vw, 60vh, 460px); height: 6px; border-radius: 999px; background: var(--panel); overflow: hidden; }
.borne-timer div { height: 100%; background: var(--gold); }
.borne-small { font-size: 0.9rem !important; margin-top: 10px; }
.borne-exit { position: fixed; top: 14px; right: 16px; color: var(--muted); font-size: 0.8rem; }

@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
  .reward { flex-direction: column; align-items: stretch; }
  .reward-side { justify-items: start; text-align: left; grid-auto-flow: column; align-items: center; justify-content: space-between; }
}

/* Affiche du QR code papier */
.poster { background: #fff; color: #080c1c; border-radius: var(--radius); padding: 36px 28px; text-align: center; max-width: 560px; margin: 0 auto 20px; }
.poster-logo { width: 150px; height: auto; background: #080c1c; border-radius: 50%; padding: 10px; }
.poster-title { font-size: 2.2rem; color: #080c1c; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.poster-gain { font-size: 1.25rem; margin: 0 0 14px; }
.poster-gain strong { color: #9a7a26; }
.poster-qr { width: 78%; margin: 0 auto 18px; }
.poster-qr svg { width: 100%; height: auto; display: block; }
.poster-steps { text-align: left; display: inline-block; margin: 0; padding-left: 22px; font-size: 1rem; line-height: 1.7; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--err); }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(143, 212, 171, 0.2); }
.days { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.days label { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; text-transform: none !important; letter-spacing: 0 !important; color: var(--text) !important; font-weight: 500 !important; cursor: pointer; }
.days input { accent-color: var(--gold); }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; padding: 0 !important; }
  .topbar, .gerant-nav, .tabbar, .no-print, .alert { display: none !important; }
  .page { padding: 0; max-width: none; }
  .poster { max-width: none; border-radius: 0; padding: 0; }
  .poster-qr { width: 70%; }
}
.code-input { text-align: center; font-family: ui-monospace, Menlo, monospace !important; font-size: 2rem !important; letter-spacing: 0.3em; text-transform: uppercase; padding: 14px !important; }
.voucher-check.validated, .voucher-check.used { border-color: var(--line); }
.select { width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.card.inactive { opacity: 0.55; }
.defi-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.defi-head h2 { color: var(--text); margin-bottom: 6px; }
.defi .cost { font-family: 'Oswald', sans-serif; color: var(--gold-2); font-size: 1.1rem; white-space: nowrap; }
.defi.done { border-color: rgba(143, 212, 171, 0.4); }
.defi-ok { color: var(--ok); font-weight: 600; margin: 4px 0 0; }
.ref-code { text-align: center; background: var(--bg); border: 1px dashed var(--gold); border-radius: 10px; padding: 12px; margin: 10px 0; font-size: 1.6rem; letter-spacing: 0.2em; color: var(--gold-2); }

/* Mention sanitaire obligatoire (loi Evin), en bas de chaque page */
.health-notice { text-align: center; font-size: 0.68rem; color: rgba(242, 237, 225, 0.42); margin: 22px 0 4px; }
body.borne .health-notice { position: fixed; left: 0; right: 0; bottom: 10px; margin: 0; font-size: 0.8rem !important; }
.poster-notice { font-size: 0.8rem; color: #555; margin: 18px 0 0; }

/* Profil (haut a droite) */
.profile-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.profile-btn.on, .profile-btn:hover { color: var(--gold-2); border-color: var(--gold); }

/* Bouton Scanner au centre de la barre du bas */
.tabbar { align-items: end; }
.tab-scan { position: relative; }
.tab-scan .scan-btn {
  width: 58px; height: 58px; margin-top: -30px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: var(--bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 0 4px var(--bg);
}
.tabbar a.tab-scan { color: var(--gold-2); }

/* Page scanner */
.scanner-view { position: relative; width: 100%; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame { position: absolute; inset: 14%; border: 3px solid var(--gold-2); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.45); pointer-events: none; }
.scanner-msg { text-align: center; margin-top: 14px; }

/* Defis uniques deja reussis : liste compacte en bas de page */
.finished-title { font-size: 0.9rem; color: var(--muted); margin: 26px 0 8px; text-transform: uppercase; letter-spacing: 0.08em; }
.finished-list { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.finished-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; font-size: 0.82rem; border-top: 1px solid var(--line); color: var(--ok); }
.finished-list li:first-child { border-top: 0; }
