:root {
  --bg: #0b0b12;
  --surface: #15151f;
  --surface-2: #1d1d2a;
  --surface-3: #262636;
  --sep: rgba(255, 255, 255, .07);
  --text: #f5f5f7;
  --text-2: #a1a1b5;
  --text-3: #6e6e84;
  --gold: #ffc24b;
  --orange: #ff8a3d;
  --ink: #1d1203;
  --gacha: #b197fc;
  --vol: #4cc9f0;
  --ok: #3ddc97;
  --bad: #ff6b6b;
  --chef: #ff5c8a;
  --adjoint: #5b8cff;
  --admin: #3ddc97;
  --r-lg: 22px;
  --r: 16px;
  --r-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --tab-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { display: block; }
.app { max-width: 620px; margin: 0 auto; min-height: 100dvh; padding: env(safe-area-inset-top) 0 calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
.loading { padding: 64px 20px; text-align: center; color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- En-tête ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: rgba(11, 11, 18, .78); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.top .fam { font-size: .82rem; font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.me { display: flex; align-items: center; gap: 8px; border: 0; background: var(--surface-2); padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; }
.me .av { width: 28px; height: 28px; font-size: .8rem; }
.me span { font-size: .85rem; font-weight: 600; }
.title { padding: 6px 20px 2px; }
.title h1 { margin: 0; font-size: 2.05rem; line-height: 1.1; letter-spacing: -.025em; font-weight: 750; }
.title p { margin: 4px 0 0; color: var(--text-2); font-size: .95rem; }
.demo { margin: 10px 20px 0; padding: 9px 14px; border-radius: var(--r-sm); background: rgba(255, 194, 75, .1); color: var(--gold); font-size: .8rem; }

/* ---------- Barre d'onglets ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(16, 16, 24, .82); backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px); border-top: 1px solid var(--sep); }
.tabs-in { max-width: 620px; margin: 0 auto; display: flex; }
.tabs button { flex: 1; height: var(--tab-h); border: 0; background: none; color: var(--text-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .68rem; font-weight: 600; letter-spacing: .01em; cursor: pointer; position: relative; transition: color .2s; }
.tabs button svg { width: 25px; height: 25px; transition: transform .35s var(--ease); }
.tabs button[aria-current="page"] { color: var(--gold); }
.tabs button[aria-current="page"] svg { transform: translateY(-1px) scale(1.06); }
.tabs .dot { position: absolute; top: 9px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg); }

/* ---------- Mise en page ---------- */
.view { padding: 14px 16px 0; display: grid; gap: 14px; animation: rise .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.section-label { margin: 10px 4px -4px; font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 18px; }
.card.tight { padding: 6px 0; }
.card h2 { margin: 0 0 4px; font-size: 1.15rem; letter-spacing: -.01em; }
.card h3 { margin: 0; font-size: 1.02rem; letter-spacing: -.01em; }
.muted { color: var(--text-2); font-size: .88rem; margin: 0; }
.faint { color: var(--text-3); font-size: .8rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }

/* Héros d'accueil */
.hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 22px 20px; background: radial-gradient(120% 140% at 100% 0%, rgba(255, 138, 61, .32), transparent 55%), radial-gradient(120% 120% at 0% 100%, rgba(177, 151, 252, .28), transparent 55%), var(--surface-2); }
.hero h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.hero .chips { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Pastilles */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip.chef { background: rgba(255, 92, 138, .16); color: var(--chef); }
.chip.adjoint { background: rgba(91, 140, 255, .16); color: var(--adjoint); }
.chip.admin { background: rgba(61, 220, 151, .14); color: var(--admin); }
.chip.gacha { background: rgba(177, 151, 252, .16); color: var(--gacha); }
.chip.vol { background: rgba(76, 201, 240, .15); color: var(--vol); }
.chip.ok { background: rgba(61, 220, 151, .14); color: var(--ok); }
.chip.bad { background: rgba(255, 107, 107, .14); color: var(--bad); }
.chip.wait { background: rgba(255, 194, 75, .13); color: var(--gold); }
.chip.sm { height: 22px; padding: 0 8px; font-size: .7rem; }
.chip svg { width: 14px; height: 14px; }

/* Avatars */
.av { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem; color: #fff; background: linear-gradient(135deg, var(--c1, #5b8cff), var(--c2, #b197fc)); overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.lg { width: 64px; height: 64px; font-size: 1.4rem; border-radius: 18px; }

/* Listes groupées */
.list { display: grid; }
.cell { display: flex; align-items: center; gap: 12px; padding: 11px 18px; min-height: 58px; position: relative; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; height: 1px; background: var(--sep); }
.cell.plain + .cell.plain::before { left: 18px; }
.cell .t { font-weight: 600; overflow-wrap: anywhere; }
.cell .s { font-size: .8rem; color: var(--text-2); }
.cell .end { margin-left: auto; display: flex; align-items: center; gap: 8px; text-align: right; }
.cell .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.cell .val small { display: block; font-size: .68rem; font-weight: 500; color: var(--text-3); }
.empty { padding: 22px 18px; text-align: center; color: var(--text-3); font-size: .9rem; }

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border-radius: var(--r); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--text-2); }
.stat.accent b { background: linear-gradient(90deg, var(--gold), var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Champs */
label.field { display: grid; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--text-2); }
input, select, textarea { width: 100%; min-height: 48px; padding: 12px 14px; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); outline: none; transition: border-color .2s, background .2s; }
input:focus, select:focus, textarea:focus { border-color: rgba(255, 194, 75, .55); background: var(--surface-3); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pin { letter-spacing: .6em; text-align: center; font-size: 1.35rem; font-weight: 700; }
input[type="number"] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 20px; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--gold), var(--orange)); color: var(--ink); font-weight: 700; cursor: pointer; transition: transform .2s var(--ease), opacity .2s; }
.btn:active { transform: scale(.96); }
.btn.block { width: 100%; }
.btn.soft { background: var(--surface-3); color: var(--text); }
.btn.danger { background: rgba(255, 107, 107, .14); color: var(--bad); }
.btn.sm { min-height: 38px; padding: 0 14px; border-radius: 11px; font-size: .86rem; }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; cursor: pointer; transition: transform .2s var(--ease); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.danger { color: var(--bad); background: rgba(255, 107, 107, .12); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Contrôle segmenté */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 34px; border: 0; border-radius: 9px; background: none; color: var(--text-2); font-size: .85rem; font-weight: 650; cursor: pointer; transition: background .25s var(--ease), color .25s; }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.seg.type button[aria-pressed="true"][data-v="gacha"] { background: rgba(177, 151, 252, .22); color: var(--gacha); }
.seg.type button[aria-pressed="true"][data-v="vol"] { background: rgba(76, 201, 240, .2); color: var(--vol); }
.seg.sm button { min-height: 30px; font-size: .78rem; padding: 0 10px; }

/* Semaine */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: var(--r); padding: 8px; }
.weekbar .lbl { text-align: center; font-weight: 650; font-size: .95rem; }
.weekbar .lbl small { display: block; color: var(--text-3); font-weight: 500; font-size: .76rem; }

/* Barres de progression */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gacha), var(--gold)); transform-origin: left; animation: grow .8s var(--ease); }
.bar.done > i { background: var(--ok); }
.bar.thin { height: 5px; }
@keyframes grow { from { transform: scaleX(0); } }

/* Coffres */
.chest { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.chest-head { padding: 18px 18px 14px; display: grid; gap: 10px; }
.chest-head .row h3 { font-size: 1.15rem; }
.chest-badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.chest-badge.c1 { background: linear-gradient(135deg, #ffd88a, #ffb547); }
.chest-badge.c2 { background: linear-gradient(135deg, #c8b6ff, #8f6bff); color: #fff; }
.chest-badge.c3 { background: linear-gradient(135deg, #ff9a7a, #ff4f6d); color: #fff; }
.chest .cell { min-height: 62px; }
.chest .mini { width: 92px; }
.chest .mini .faint { display: block; text-align: right; margin-bottom: 4px; }
.qty { width: 84px; min-height: 40px; padding: 6px 10px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.add-line { display: grid; grid-template-columns: minmax(0, 1fr) 84px auto; gap: 8px; padding: 12px 18px 18px; border-top: 1px solid var(--sep); }
.add-line select, .add-line input { min-height: 42px; padding: 8px 12px; }
.check { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(61, 220, 151, .16); color: var(--ok); }
.check svg { width: 15px; height: 15px; }
.pending { width: 26px; height: 26px; border-radius: 50%; border: 2px dashed var(--text-3); }

/* Recrues */
.recrue { background: var(--surface); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 14px; }
.recrue .id { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--surface-2); color: var(--text-2); border-radius: 8px; padding: 3px 8px; font-size: .78rem; font-variant-numeric: tabular-nums; cursor: pointer; }
.recrue .id svg { width: 13px; height: 13px; }
.recrue .infos { margin: 0; white-space: pre-wrap; color: var(--text-2); font-size: .92rem; }
.votebar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-3); position: relative; }
.votebar .p { background: var(--ok); }
.votebar .c { background: var(--bad); margin-left: auto; }
.votebar .mid { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .5; }
.vote-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vote { min-height: 48px; border-radius: 14px; border: 1.5px solid var(--surface-3); background: none; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: all .25s var(--ease); color: var(--text-2); }
.vote svg { width: 18px; height: 18px; }
.vote:active { transform: scale(.96); }
.vote.pour[aria-pressed="true"] { background: rgba(61, 220, 151, .16); border-color: var(--ok); color: var(--ok); }
.vote.contre[aria-pressed="true"] { background: rgba(255, 107, 107, .14); border-color: var(--bad); color: var(--bad); }
details.voters summary { cursor: pointer; color: var(--text-3); font-size: .8rem; list-style: none; }
details.voters summary::-webkit-details-marker { display: none; }
details.voters .row { margin-top: 8px; flex-wrap: wrap; gap: 6px; }
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-pick .av.lg { background: var(--surface-3); color: var(--text-3); }

/* Alertes */
.alert { display: flex; gap: 12px; padding: 14px 18px; position: relative; }
.alert + .alert::before { content: ""; position: absolute; top: 0; left: 18px; right: 0; height: 1px; background: var(--sep); }
.alert .ic { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold), var(--orange)); color: var(--ink); }
.alert .ic svg { width: 18px; height: 18px; }
.alert .t { font-weight: 650; }
.alert p { margin: 2px 0 0; color: var(--text-2); font-size: .9rem; white-space: pre-wrap; }
.alert .new { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; margin-top: 6px; }

/* Taupe */
.spy { background: var(--surface); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 12px; }
.shield { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-size: .88rem; }
.shield svg { width: 20px; height: 20px; flex: none; }
.shield.on { color: var(--vol); background: rgba(76, 201, 240, .1); }
.shield.off { color: var(--text-3); }

/* Bandeaux */
.banner { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); }
.banner .ic { flex: none; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: rgba(255, 194, 75, .14); color: var(--gold); }
.banner .ic svg { width: 22px; height: 22px; }
details.more { background: var(--surface); border-radius: var(--r-lg); }
details.more summary { padding: 16px 18px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { padding-bottom: 6px; }
details.more > div { padding: 0 18px 18px; }

/* Connexion */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; background: radial-gradient(80% 60% at 50% 0%, rgba(255, 138, 61, .18), transparent 70%), radial-gradient(70% 50% at 50% 100%, rgba(177, 151, 252, .14), transparent 70%); }
.login-box { width: 100%; max-width: 380px; display: grid; gap: 18px; text-align: center; }
.login-logo { width: 84px; height: 84px; margin: 0 auto; border-radius: 24px; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold), var(--orange)); color: var(--ink); box-shadow: 0 18px 50px rgba(255, 138, 61, .35); }
.login-logo svg { width: 44px; height: 44px; }
.login h1 { margin: 0; font-size: 2rem; letter-spacing: -.03em; }
.login form { display: grid; gap: 12px; text-align: left; }
.error { color: var(--bad); font-size: .88rem; min-height: 1.3em; margin: 0; text-align: center; }

/* Feuilles (dialogues) */
dialog { width: 100%; max-width: 620px; max-height: 92dvh; margin: auto auto 0; border: 0; border-radius: 26px 26px 0 0; padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--text); overflow-y: auto; }
dialog[open] { animation: sheet .4s var(--ease); }
@keyframes sheet { from { transform: translateY(100%); } }
dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }
dialog .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
dialog h3 { margin: 0 0 16px; font-size: 1.25rem; }
dialog form { display: grid; gap: 12px; }
dialog .actions { display: flex; gap: 10px; margin-top: 6px; }
dialog .actions .btn { flex: 1; }
@media (min-width: 700px) { dialog { margin: auto; border-radius: 26px; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 30px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; background: rgba(245, 245, 247, .96); color: #111; padding: 12px 20px; border-radius: 999px; font-size: .9rem; font-weight: 600; box-shadow: 0 12px 34px rgba(0, 0, 0, .45); animation: pop .35s var(--ease); white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Comptes reliés (principal / secondaires) */
.idtag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 7px; background: var(--surface-2); color: var(--text-2); font-size: .72rem; font-weight: 600; }
.idtag.none { color: var(--text-3); font-style: italic; }
.group + .group { border-top: 1px solid var(--sep); }
.group .cell + .cell::before { left: 70px; }
.cell.sub { padding-left: 46px; }
.cell.sub::after { content: ""; position: absolute; left: 30px; top: 0; bottom: 50%; width: 12px; border-left: 2px solid var(--surface-3); border-bottom: 2px solid var(--surface-3); border-bottom-left-radius: 8px; }
.cell.sub .av { width: 34px; height: 34px; font-size: .85rem; }
.group-total { display: flex; justify-content: space-between; gap: 10px; padding: 8px 18px 12px 46px; font-size: .8rem; color: var(--text-2); }
.group-total { flex-wrap: wrap; } .group-total b { color: var(--gold); font-weight: 650; white-space: nowrap; }
.link-box { display: grid; gap: 10px; padding: 14px; border-radius: var(--r); background: var(--surface-2); }
.link-box b { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.link-box b svg { width: 16px; height: 16px; }
.link-box input { background: var(--surface-3); }
.chips + .chips { margin-top: 8px; }
.sec-line { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 12px 18px; }
.sec-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.idtag { white-space: nowrap; }
.sec-line + .sec-line { border-top: 1px solid var(--sep); }
.mini-field { display: grid; gap: 2px; font-size: .66rem; font-weight: 600; color: var(--text-3); }
.mini-field input { min-height: 38px; padding: 6px 8px; text-align: right; font-weight: 700; }
