:root {
  --bg: #0b0809;
  --bg-2: #120d0f;
  --surface: #171114;
  --surface-2: #1f171b;
  --line: #2e2227;
  --line-2: #3d2d34;
  --text: #ece3da;
  --muted: #9d8c86;
  --faint: #6c5d59;
  --blood: #a51b2e;
  --blood-2: #c92a40;
  --glow: rgba(201, 42, 64, .18);
  --gold: #b8945a;
  --gold-2: #d6b67c;
  --ok: #78a47d;
  --warn: #cf9f42;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --r: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); min-height: 100vh;
  background-image: radial-gradient(ellipse 80% 45% at 50% -10%, rgba(165, 27, 46, .13), transparent 70%);
  background-attachment: fixed;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { color: #f0d49e; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .01em; }
::selection { background: var(--blood); color: #fff; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- Boutons & champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font: 500 14px var(--sans); padding: .6em 1.1em; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, color .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); color: #fff; }
.btn.primary { background: var(--blood); border-color: var(--blood); color: #fff; }
.btn.primary:hover { background: var(--blood-2); border-color: var(--blood-2); }
.btn.gold { background: transparent; border-color: #5d4a2c; color: var(--gold-2); }
.btn.gold:hover { background: rgba(184, 148, 90, .1); border-color: var(--gold); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: #ea7c8d; border-color: #5c2731; }
.btn.danger:hover { background: #3b1219; }
.btn.ok { background: transparent; color: #a6d0aa; border-color: #2f4c34; }
.btn.ok:hover { background: rgba(120, 164, 125, .1); }
.btn.sm { padding: .35em .75em; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r); padding: .6em .8em; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 100px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blood-2); box-shadow: 0 0 0 3px var(--glow); }
label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .35em; }
.field { margin-bottom: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.row > .field { flex: 1 1 180px; }
.err { color: #f08a98; font-size: 14px; min-height: 1.2em; }
.hint { font-size: 13px; color: var(--faint); margin: .3rem 0 0; }
.choix { display: flex; gap: .5rem; flex-wrap: wrap; }
.choix label { flex: 1 1 140px; margin: 0; text-transform: none; letter-spacing: 0; font: 500 14px var(--sans); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: .65em .9em; cursor: pointer; display: flex; gap: .5em; align-items: center; }
.choix input { width: auto; accent-color: var(--blood-2); }
.choix label:has(input:checked) { border-color: var(--blood-2); background: rgba(165, 27, 46, .12); }

/* ---------- Badges ---------- */
.tag {
  display: inline-block; font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: .42em .6em; border-radius: 3px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.tag.red { color: #f2939f; border-color: #5e2632; background: rgba(165, 27, 46, .12); }
.tag.gold { color: var(--gold-2); border-color: #594629; }
.tag.ok { color: #a6d0aa; border-color: #2f4c34; }
.tag.warn { color: #e5bd68; border-color: #56441f; }
.tag.blood { color: #fff; background: var(--blood); border-color: var(--blood); }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: 100%; max-width: 390px; text-align: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 2.4rem 1.8rem; box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 0 1px rgba(184, 148, 90, .08);
}
.login img { width: 72px; height: 72px; filter: drop-shadow(0 0 22px rgba(201, 42, 64, .35)); margin-bottom: 1rem; }
.login h1 { font-size: 34px; margin-bottom: .1em; }
.login .devise { font: italic 500 17px var(--serif); color: var(--gold); margin: 0 0 1.4rem; }
.login form { text-align: left; }
.login .btn { width: 100%; margin-top: .4rem; }

/* ---------- Coquille ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(11, 8, 9, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 1.4rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font: 600 21px var(--serif); white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.brand:hover { color: #fff; }
.nav { display: flex; gap: .2rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: .45em .8em; border-radius: var(--r); font-weight: 500; font-size: 14px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.on { color: #fff; background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--blood-2); }
.moi { position: relative; }
.moi > button { background: none; border: 1px solid var(--line-2); color: var(--text); border-radius: 20px; padding: .3em .8em .3em .35em;
  display: flex; align-items: center; gap: .5em; cursor: pointer; font: 500 14px var(--sans); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--blood); color: #fff; font: 600 11px var(--sans); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  min-width: 210px; padding: .4rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .55); display: none; }
.menu.on { display: block; }
.menu .who { padding: .5rem .7rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.menu button { width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: .55rem .7rem; border-radius: 5px; cursor: pointer; font: 14px var(--sans); }
.menu button:hover { background: var(--surface-2); }
main { max-width: 1240px; margin: 0 auto; padding: 2rem 16px 5rem; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.6rem; }
.kicker { font: 500 11px var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin-bottom: .4rem; }
.page-head h1 { font-size: clamp(32px, 4.4vw, 44px); margin: 0; }
.sub { color: var(--muted); margin: .3rem 0 0; }

/* ---------- Registre ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1.6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.stat:hover { border-color: var(--line-2); }
.stat.on { border-color: var(--blood-2); box-shadow: 0 0 0 3px var(--glow); }
.stat b { display: block; font: 600 34px/1 var(--serif); }
.stat span { font-size: 13px; color: var(--muted); }
.stat.s-attente b { color: var(--muted); }
.stat.s-epreuves b { color: var(--warn); }
.stat.s-accepte b { color: var(--gold-2); }
.stat.s-refuse b { color: #e77a8b; }
.filtres { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.filtres input { flex: 1 1 240px; }
.filtres select { flex: 0 1 190px; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .9rem; }
.carte {
  display: block; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.1rem 1.2rem 1rem; position: relative; overflow: hidden; transition: border-color .15s, transform .15s;
}
.carte:hover { color: var(--text); border-color: var(--line-2); transform: translateY(-1px); }
.carte::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2); }
.carte.s-epreuves::before { background: var(--warn); }
.carte.s-accepte::before { background: var(--gold); }
.carte.s-refuse::before { background: var(--blood); }
.carte.s-refuse { opacity: .7; }
.carte h3 { font-size: 25px; margin: 0; }
.carte .nuit { font: italic 500 17px var(--serif); color: var(--gold-2); }
.carte .meta { font-size: 13px; color: var(--muted); margin: .55rem 0 .7rem; }
.carte .tags { margin-top: .5rem; }
.barre { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.barre i { display: block; height: 100%; background: linear-gradient(90deg, var(--blood), var(--gold)); border-radius: 3px; }
.prog { display: flex; align-items: center; gap: .6rem; font-size: 12px; color: var(--muted); margin-top: .7rem; }
.prog .barre { flex: 1; }
.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 10px; }
.empty h3 { color: var(--text); font-size: 26px; }

/* ---------- Dossier ---------- */
.dossier-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; margin-bottom: 1.6rem; }
.dossier-head h1 { font-size: clamp(36px, 5vw, 52px); margin: 0; }
.dossier-head .vrai { color: var(--muted); font: italic 500 19px var(--serif); }
.dossier-head .tags { margin-top: .7rem; }
.dossier { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.4rem; align-items: start; }
.bloc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.3rem 1.4rem; margin-bottom: 1.4rem; }
.bloc > h2 { font-size: 24px; display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.bloc > h2 .btn { font-family: var(--sans); }
.texte { white-space: pre-line; color: #dcd2c8; }
dl.ident { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; margin: 0; font-size: 14px; }
dl.ident dt { color: var(--muted); }
dl.ident dd { margin: 0; }
.decision { border-left: 3px solid var(--line-2); padding: .2rem 0 .2rem 1rem; }
.decision.s-accepte { border-color: var(--gold); }
.decision.s-refuse { border-color: var(--blood); }
.decision.s-epreuves { border-color: var(--warn); }
.decision .titre { font: 600 22px var(--serif); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.mission { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; margin-bottom: .7rem; background: var(--bg-2); }
.mission .mh { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; flex-wrap: wrap; }
.mission h4 { font-size: 20px; margin: 0; }
.mission .cr { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line-2); }
.mission .cr b { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.etapes { list-style: none; margin: 0; padding: 0; counter-reset: e; }
.etapes li { display: grid; grid-template-columns: 36px 1fr; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.etapes li:last-child { border-bottom: 0; }
.etapes .puce { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center;
  font: 600 15px var(--serif); color: var(--faint); background: none; cursor: pointer; padding: 0; }
.etapes li.fait .puce { background: var(--gold); border-color: var(--gold); color: #1a1208; }
.etapes li.actuelle .puce { border-color: var(--blood-2); color: var(--blood-2); box-shadow: 0 0 0 3px var(--glow); }
.etapes .puce:disabled { cursor: default; }
.etapes h4 { font-size: 19px; margin: 0; }
.etapes li:not(.fait):not(.actuelle) h4 { color: var(--muted); }
.etapes .d { font-size: 13px; color: var(--muted); }
.etapes .v { font-size: 13px; color: var(--gold); margin-top: .2rem; }
.etapes .v q { color: #dcd2c8; font-style: italic; }

.journal { list-style: none; margin: 0; padding: 0; }
.journal li { padding: .65rem 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.journal li:last-child { border-bottom: 0; }
.journal .jm { font-size: 12px; color: var(--faint); display: flex; justify-content: space-between; gap: .5rem; }
.journal .jm button { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 12px; padding: 0; }
.journal .jm button:hover { color: #ea7c8d; }
.journal li.evt { color: var(--muted); }
.journal li.evt .t::before { content: '✦ '; color: var(--gold); font-size: 10px; }
.journal li.note .t { white-space: pre-line; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: .8rem 1rem; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.lien { cursor: pointer; }
table.data tr.lien:hover td { background: var(--surface-2); }
.nom-t { font: 600 18px var(--serif); }

/* ---------- Siège ---------- */
.deux { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.4rem; align-items: start; }
.etape-adm { display: grid; grid-template-columns: 28px 1fr auto; gap: .7rem; align-items: start; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.etape-adm:last-child { border-bottom: 0; }
.etape-adm .n { font: 600 18px var(--serif); color: var(--gold); text-align: center; }
.etape-adm .b { display: flex; gap: .25rem; }
.mdp-box { font: 500 20px var(--mono); text-align: center; background: var(--bg-2); border: 1px dashed var(--gold); border-radius: 8px; padding: .8rem; margin: .8rem 0; color: var(--gold-2); user-select: all; }
pre.message { white-space: pre-wrap; font: 13px/1.5 var(--mono); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: .8rem; margin: 0 0 1rem; }

/* ---------- Modale & toast ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(4, 2, 3, .78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 1.5rem 1.5rem 1.2rem; box-shadow: 0 30px 80px rgba(0, 0, 0, .7); margin: auto; }
.modal h2 { font-size: 28px; }
.modal .row:last-child { justify-content: flex-end; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60;
  background: var(--surface-2); border: 1px solid var(--line-2); padding: .7rem 1.1rem; border-radius: 8px; transition: .2s; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: var(--blood-2); color: #f6a8b3; }

@media (max-width: 900px) {
  .dossier, .deux { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar-in { gap: .7rem; }
  .brand span { display: none; }
  .moi > button span.n { display: none; }
  .bloc { padding: 1.1rem 1rem; }
  table.data .opt { display: none; }
}

/* Chiffres alignés (Cormorant affiche des chiffres « elzéviriens » par défaut) */
.stat b, .etapes .puce, .etape-adm .n { font-variant-numeric: lining-nums tabular-nums; }
