:root {
  --bg: #071224; --bg2: #0b1b33; --card: #0f2442; --card2: #14305a; --line: #1e3d68;
  --text: #eaf1fb; --muted: #8ea6c4;
  --yellow: #f7ec13; --blue: #2f8bff; --navy: #0f3e6e;
  --ok: #35d49a; --warn: #ffb020; --danger: #ff5c6c;
  --r: 16px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh; touch-action: manipulation;
  background: radial-gradient(1200px 600px at 80% -10%, #12335f55, transparent), var(--bg);
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
small { color: var(--muted); }
[hidden] { display: none !important; }
img { max-width: 100%; }

/* ---------- boutons / champs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 12px; cursor: pointer;
  transition: transform .08s, filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--yellow); color: #0a1830; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #5a2733; background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { padding: 14px 20px; font-size: 17px; width: 100%; }
.link { background: none; border: 0; color: var(--yellow); font: inherit; font-weight: 700; cursor: pointer; padding: 0 0 0 12px; }

input, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, select:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px #f7ec1330; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--yellow); padding: 0; }
input[type=file] { padding: 8px; font-size: 14px; }
.err { color: var(--danger); font-weight: 600; min-height: 1.2em; font-size: 14px; }

/* ---------- login ---------- */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login h1 { font-size: 22px; margin-bottom: 8px; }
.logo-lg { width: 150px; margin: 0 auto; filter: drop-shadow(0 8px 24px #000a); }
.logo-sm { width: 38px; height: 38px; object-fit: contain; flex: none; }

/* ---------- jetons ---------- */
.toks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tok {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px;
  padding: 3px 11px 3px 4px; border-radius: 999px; background: #ffffff10; border: 1px solid #ffffff14;
}
.tok i {
  width: 20px; height: 20px; border-radius: 50%; display: inline-block;
  box-shadow: inset 0 -3px 0 #0003, inset 0 2px 0 #fff5;
}
.tok.y i { background: var(--yellow); }
.tok.b i { background: var(--blue); }
.tok.lg { font-size: 16px; }
.tok.lg i { width: 26px; height: 26px; }
.free { color: var(--muted); font-size: 13px; }

/* ---------- hôtesse ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 14px 10px; background: #071224e6; backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .who small b { color: var(--yellow); }
.offline { background: var(--warn); color: #1b1200; text-align: center; font-weight: 700; padding: 6px; font-size: 14px; }

.grid { display: grid; gap: 12px; padding: 14px 14px calc(24px + var(--safe-b)); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1250px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 48px 0; }

.gift {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; color: inherit; font: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; cursor: pointer;
  transition: transform .1s, filter .2s, opacity .2s; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.gift:active { transform: scale(.95); }
.gift .ph { position: relative; aspect-ratio: 1/1; background: #0a1a30; display: grid; place-items: center; }
.gift .ph img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.noimg { font-size: 44px; opacity: .5; }
.gift .qty {
  position: absolute; top: 8px; right: 8px; min-width: 34px; text-align: center; padding: 3px 10px; border-radius: 999px;
  background: #071224d9; border: 1px solid var(--line); font-weight: 800; font-size: 15px;
}
.gift .meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.gift .nm { font-weight: 700; font-size: 15px; line-height: 1.2; }
.gift.out { filter: grayscale(1); opacity: .38; cursor: not-allowed; }
.ribbon {
  position: absolute; inset: auto 0 14px 0; text-align: center; font-weight: 900; letter-spacing: .12em; text-transform: uppercase;
  background: #000a; padding: 6px 0; font-size: 14px;
}
.gift.pop { animation: pop .35s ease; }
@keyframes pop { 0% { box-shadow: 0 0 0 0 #f7ec13aa; transform: scale(.95); } 100% { box-shadow: 0 0 0 16px #f7ec1300; transform: scale(1); } }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 0; right: 0; bottom: calc(76px + var(--safe-b)); z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px;
}
.toast {
  pointer-events: auto; background: #0e2848; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  box-shadow: 0 10px 30px #000a; display: flex; align-items: center; font-weight: 600; max-width: 520px; animation: up .2s ease;
}
.toast.ok { border-color: #1f6f56; }
.toast.err { border-color: #7a2c38; color: #ffd2d7; }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }

/* ---------- admin : layout ---------- */
.adm { min-height: 100dvh; }
.side {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + var(--safe-t)) 14px 8px; background: #071224; border-bottom: 1px solid var(--line); /* pas de backdrop-filter ici : il piégerait .nav (position: fixed) */
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand div { display: flex; flex-direction: column; }
.side .foot { display: flex; align-items: center; gap: 8px; }
.side .foot small { display: none; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; background: #08162cf2; backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; color: var(--muted);
  text-decoration: none; font-size: 12px; font-weight: 600;
}
.nav a.on { color: var(--yellow); }
.adm-main { padding: 16px 14px calc(96px + var(--safe-b)); max-width: 1200px; margin: 0 auto; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-h h2 { font-size: 24px; }

@media (min-width: 900px) {
  .adm { display: grid; grid-template-columns: 250px 1fr; }
  .side {
    position: sticky; top: 0; height: 100dvh; flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 24px; padding: 24px 16px; border-bottom: 0; border-right: 1px solid var(--line);
  }
  .nav { position: static; flex-direction: column; background: none; border: 0; backdrop-filter: none; padding: 0; gap: 4px; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15px; }
  .nav a.on { background: var(--card); }
  .side .foot { margin-top: auto; flex-direction: column; align-items: stretch; }
  .side .foot small { display: block; text-align: center; }
  .adm-main { padding: 28px 32px 40px; width: 100%; }
  #toasts { bottom: 24px; }
}

/* ---------- admin : dashboard ---------- */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 700; padding: 7px 14px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--yellow); color: #0a1830; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(5, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 -2px 0 #0003, inset 0 1px 0 #fff5; }
.dot.y { background: var(--yellow); } .dot.b { background: var(--blue); }
.kpi small { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.kpi b { display: block; font-size: 32px; margin-top: 4px; line-height: 1.1; }
.kpi em { font-style: normal; color: var(--muted); font-size: 13px; }
.kpi.y b { color: var(--yellow); } .kpi.b b { color: var(--blue); } .kpi.bad b { color: var(--danger); }
.panels { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .panels { grid-template-columns: 1fr 1fr; } .panels .wide { grid-column: 1/-1; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.panel h3 { font-size: 16px; margin-bottom: 14px; }
.insights { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.insights li { padding-left: 22px; position: relative; }
.insights li::before { content: "◆"; position: absolute; left: 0; color: var(--yellow); font-size: 12px; top: 4px; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 170px; }
.col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.col .v { font-size: 11px; color: var(--muted); height: 14px; }
.col .bar { width: 100%; background: linear-gradient(var(--yellow), #bdb300); border-radius: 6px 6px 0 0; min-height: 2px; }
.col .bar.zero { background: var(--line); }
.col .l { font-size: 10px; color: var(--muted); height: 14px; white-space: nowrap; }
.hb { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 36px; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 14px; }
.hb .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .t { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.hb .f { height: 100%; background: var(--blue); border-radius: 99px; }
.hb .f.y { background: var(--yellow); }
.hb .f.warn { background: var(--warn); } .hb .f.bad { background: var(--danger); } .hb .f.ok { background: var(--ok); }
.hb .c { text-align: right; font-weight: 800; }
.hb .c small { font-weight: 500; }
.recent { display: flex; flex-direction: column; }
.recent .it { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.recent .it:first-child { border-top: 0; }
.recent .it .tm { color: var(--muted); font-variant-numeric: tabular-nums; }
.recent .it small { display: block; }
.none { color: var(--muted); padding: 12px 0; text-align: center; }

/* ---------- admin : listes ---------- */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px;
}
.row.off { opacity: .6; }
.row .th { width: 64px; height: 64px; border-radius: 12px; background: #0a1a30; overflow: hidden; display: grid; place-items: center; font-size: 28px; }
.row .th img { width: 100%; height: 100%; object-fit: cover; }
.row .grow { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.row .nm { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .stk { grid-column: 1/-1; display: flex; align-items: baseline; gap: 8px; }
.row .stk b { font-size: 22px; } .row .stk b.bad { color: var(--danger); }
.row .acts { grid-column: 1/-1; display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 800px) {
  .row { grid-template-columns: 64px 1fr 170px auto; }
  .row .stk, .row .acts { grid-column: auto; }
  .row .stk { flex-direction: column; gap: 0; align-items: flex-start; }
}
.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #ffffff14; color: var(--muted); }
.badge.role-admin { background: #f7ec1322; color: var(--yellow); }
.badge.ok { background: #35d49a22; color: var(--ok); }
.badge.bad { background: #ff5c6c22; color: var(--danger); }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: #030a14cc; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
@media (min-width: 700px) { .overlay { align-items: center; } }
.sheet {
  width: min(520px, 100%); max-height: 92dvh; overflow: auto; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 700px) { .sheet { border-radius: 22px; } }
.sheet h3 { font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; color: var(--muted); }
.field.chk { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.btns { display: flex; gap: 10px; justify-content: flex-end; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; width: 80px; }
.imgrow { display: flex; gap: 12px; align-items: center; }
.prev { width: 84px; height: 84px; flex: none; border-radius: 14px; background: #0a1a30; overflow: hidden; display: grid; place-items: center; font-size: 34px; border: 1px solid var(--line); }
.prev img { width: 100%; height: 100%; object-fit: cover; }
.imgrow .col2 { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
