:root {
  /* Image de fond du site : dépose ton image dans le dossier public sous ce nom (ou change le nom ici) */
  --fond: url('/fond.png');
  --ink: #0c0c0c;
  --panel: #161616;
  --panel-2: #1e1e1e;
  --line: #2e2e2e;
  --brass: #e8e6df;
  --brass-dim: #8a8982;
  --bone: #e9e5d7;
  --muted: #98a59d;
  --in: #7bb896;
  --out: #d0624e;
  --radius: 4px;
  --veil: .78;
  --role-membre: #98a59d;
  --role-grade: #e9e5d7;
  --role-chef: #e8e6df;
  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --gothic: 'Pirata One', 'Old English Text MT', Georgia, serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  /* Voile sombre par-dessus l'image pour garder les textes lisibles (0.78 = voile fort ; baisse le chiffre pour voir davantage l'image) */
  background:
    linear-gradient(rgba(12, 12, 12, var(--veil)), rgba(12, 12, 12, var(--veil))),
    var(--fond) center / cover no-repeat fixed,
    var(--ink);
  color: var(--bone);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--display); font-weight: 800; letter-spacing: .02em; margin: 0; line-height: 1.05; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.2rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--brass); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Écran de connexion ---------- */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  /* Écran de connexion : voile plus léger pour que l'image se voie mieux */
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(255,255,255,.025) 79px 80px),
    linear-gradient(rgba(12, 12, 12, .55), rgba(12, 12, 12, .55)),
    var(--fond) center / cover no-repeat,
    var(--ink);
}
.gate-card {
  width: min(420px, 100%);
  background: rgba(12, 12, 12, .72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(6px);
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; border: 1px solid var(--line); }
.logo-text { font-family: var(--gothic); font-size: 4.6rem; line-height: .85; color: var(--bone); letter-spacing: .02em; }
.logo-text small { display: block; font-family: var(--display); font-weight: 600; font-size: 1.15rem; letter-spacing: .28em; color: var(--brass); margin-top: 8px; }
.logo.compact img { width: 40px; height: 40px; border-radius: 10px; }
.logo.compact .logo-text { font-size: 2.3rem; }
.logo.compact .logo-text small { font-size: .7rem; letter-spacing: .2em; margin-top: 4px; }
.gate-card .sub { color: var(--muted); margin: 10px 0 28px; }
.gate-card form { display: grid; gap: 14px; }

/* ---------- Mise en page ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav { display: grid; gap: 2px; }
.nav button {
  all: unset;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  border-left: 3px solid transparent;
}
.nav button:hover { color: var(--bone); background: var(--panel-2); }
.nav button[aria-current="page"] { color: var(--bone); background: var(--panel-2); border-left-color: var(--brass); font-weight: 600; }
.nav button:focus-visible { outline: 2px solid var(--brass); }
.who { margin-top: auto; font-size: .9rem; color: var(--muted); display: grid; gap: 8px; }
.who strong { color: var(--bone); display: block; }

main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 6px; }

/* ---------- Composants ---------- */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--bone);
  padding: 9px 16px;
  border-radius: var(--radius);
}
button:hover { border-color: var(--brass-dim); }
button.primary { background: var(--brass); color: #1a1405; border-color: var(--brass); font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--out); }
button.small { padding: 4px 10px; font-size: .85rem; }
button.link { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }

label { display: grid; gap: 5px; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--bone);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 0; border-color: var(--brass); }
.check { display: flex; align-items: center; gap: 8px; color: var(--bone); }
.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.error { color: var(--out); font-size: .9rem; min-height: 1.2em; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 18px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* La caisse : élément central du tableau de bord */
.vault {
  border: 1px solid var(--brass-dim);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-radius: var(--radius);
  padding: 26px clamp(18px, 3vw, 32px);
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}
.vault .label { color: var(--muted); }
.vault .big { font-family: var(--display); font-weight: 800; font-size: clamp(3.2rem, 9vw, 6rem); line-height: .95; color: var(--brass); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; flex: 1; min-width: 260px; max-width: 520px; }
.stat { border-left: 2px solid var(--line); padding-left: 12px; }
.stat b { font-family: var(--display); font-size: 1.9rem; display: block; line-height: 1; }
.stat span { color: var(--muted); font-size: .85rem; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.two-col .card + .card { margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; }
.in { color: var(--in); }
.out { color: var(--out); }
.muted { color: var(--muted); }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.chef { color: var(--role-chef); border-color: var(--role-chef); }
.tag.grade { color: var(--role-grade); border-color: var(--role-grade); }
.tag.membre { color: var(--role-membre); border-color: var(--role-membre); }
.tag.off { color: var(--out); border-color: var(--out); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 20px 4px; }
.filters { display: flex; gap: 6px; }
.filters button[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
.stock-qty { font-family: var(--display); font-size: 1.6rem; font-weight: 800; }
.stock-qty.zero { color: var(--out); }

/* ---------- Objets reçus (déclaration de braquage) ---------- */
.loot { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.loot summary, details.sub summary { cursor: pointer; padding: 10px 12px; font-weight: 600; color: var(--bone); }
.loot summary:hover, details.sub summary:hover { color: var(--brass); }
.loot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; padding: 4px 12px 14px; }
.loot-item { color: var(--bone); }
.field-label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 5px; }
#part-menu .loot-grid { max-height: 220px; overflow-y: auto; }
.loot-item input { padding: 6px 9px; }

/* ---------- Page Informations ---------- */
[hidden] { display: none !important; }
.groups { display: grid; gap: 10px; }
.groups .card + .card { margin-top: 0; }
.group-name { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tag.rel-bonne { color: var(--in); border-color: var(--in); }
.tag.rel-conflit { color: var(--out); border-color: var(--out); }
.tag.rel-neutre { color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kv .wide { grid-column: 1 / -1; }
.map-thumb { display: block; padding: 0; margin-top: 6px; max-width: 380px; overflow: hidden; line-height: 0; }
.map-thumb img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.map-thumb.small { max-width: 240px; }
.map-thumb.small img { max-height: 140px; }
.storage-map { margin-bottom: 12px; }
dialog.zoom { width: min(1100px, calc(100vw - 32px)); }
dialog.zoom img { display: block; max-width: 100%; max-height: calc(100vh - 190px); margin: 0 auto; }
details.sub { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 10px; background: var(--panel-2); }
details.sub[open] > summary { border-bottom: 1px solid var(--line); }
details.sub > .table-wrap, details.sub > .empty { padding: 0 12px; }
.sub-actions { padding: 10px 12px 12px; }

/* ---------- Photos de profil ---------- */
.avatar { border-radius: 50%; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); flex: none; display: block; }
.avatar.sm { width: 32px; height: 32px; }
.avatar.md { width: 44px; height: 44px; }
.avatar.lg { width: 76px; height: 76px; }
.avatar.xl { width: 104px; height: 104px; }
.avatar.initial { display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: var(--muted); }
.avatar.sm.initial { font-size: 1rem; } .avatar.lg.initial { font-size: 2rem; } .avatar.xl.initial { font-size: 2.8rem; }
.avatar-btn { padding: 0; border: none; background: none; border-radius: 50%; line-height: 0; flex: none; }
.avatar-btn:hover .avatar { border-color: var(--brass); }
.who-id { display: flex; align-items: center; gap: 10px; }
.welcome { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; }
.welcome-text h2 { font-size: 1.8rem; }
.welcome-text p { color: var(--muted); margin-top: 6px; }
.welcome-title { font-family: var(--body); font-size: 1rem; font-weight: 500; }

/* ---------- Hiérarchie des membres ---------- */
.hier-section { --cat: var(--line); border-left: 3px solid var(--cat); padding: 2px 0 2px 20px; margin-left: 14px; margin-bottom: 28px; position: relative; }
.hier-section.plain { border-left: none; padding-left: 0; margin-left: 0; }
.hier-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; margin-left: -45px; }
.hier-rank { width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--panel); border: 3px solid var(--cat); color: var(--cat); font-family: var(--display); font-weight: 800; font-size: 1.5rem; }
.hier-head h3 { color: var(--cat); font-size: 1.7rem; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.member-card { display: flex; gap: 14px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.member-card.is-off { opacity: .55; }
.member-info { min-width: 0; display: grid; gap: 4px; }
.member-name { font-family: var(--display); font-weight: 800; font-size: 1.35rem; line-height: 1.1; overflow-wrap: anywhere; }
.member-meta { font-size: .85rem; }

/* ---------- Recherche et groupes dépliants ---------- */
.searchbar { margin: 0 0 14px; }
.searchbar input { max-width: 520px; }
.group-acc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.group-acc:hover { border-color: var(--brass-dim); }
.group-acc > summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; cursor: pointer; list-style: none; }
.group-acc > summary::-webkit-details-marker { display: none; }
.group-acc > summary::before { content: '▸'; color: var(--brass); transition: transform .15s; }
.group-acc[open] > summary::before { transform: rotate(90deg); }
.group-acc[open] > summary { border-bottom: 1px solid var(--line); }
.group-acc .group-name { flex: 1; min-width: 200px; }
.group-title { font-family: var(--display); font-weight: 800; font-size: 1.4rem; letter-spacing: .02em; }
.group-sum-info { font-size: .88rem; }
.group-body { padding: 16px 18px 18px; }

/* ---------- Paramètres ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.settings-grid .card + .card { margin-top: 0; }
.card-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.role-row { display: grid; grid-template-columns: 90px 1fr 90px; gap: 12px; align-items: end; margin-bottom: 12px; }
.role-row .tag { align-self: center; text-align: center; }
input[type=color] { padding: 2px 4px; height: 38px; cursor: pointer; }
input[type=range] { padding: 0; accent-color: var(--brass); }
output { color: var(--bone); font-weight: 600; }

.rank-cell { width: 2.2em; color: var(--muted); font-family: var(--display); font-weight: 800; font-size: 1.2rem; }
.cat-section { border-left: 4px solid var(--line); }
.cat-section .card-title h3 { font-size: 1.4rem; }

/* ---------- Task List ---------- */
.tasks { display: grid; gap: 10px; }
.task { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.task.is-done { opacity: .6; }
.task.is-done .task-title { text-decoration: line-through; }
.task-main { flex: 1; min-width: 220px; display: grid; gap: 4px; }
.task-title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-meta { font-size: .85rem; }
.group-pills { display: grid; gap: 6px; }
.group-pill { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; }
.group-pill[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
.week { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.day { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.day.today { border-color: var(--brass); }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.day-empty { font-size: .85rem; }
.plan-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border-left: 3px solid var(--brass-dim); background: var(--panel); border-radius: var(--radius); }
.plan-item.a_faire { border-left-color: var(--in); }
.plan-item.commande { border-left-color: var(--out); }
.plan-item.is-done .plan-main > div:first-child { text-decoration: line-through; opacity: .6; }
.plan-main { flex: 1; min-width: 0; display: grid; gap: 3px; overflow-wrap: anywhere; }
.plan-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .8rem; }
.check-btn { padding: 0 4px; border: none; background: none; font-size: 1.3rem; line-height: 1; color: var(--bone); }

/* ---------- Fenêtre modale ---------- */
dialog {
  background: var(--panel);
  color: var(--bone);
  border: 1px solid var(--brass-dim);
  border-radius: var(--radius);
  padding: 24px;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}
dialog::backdrop { background: rgba(5, 9, 7, .75); }
dialog h2 { margin-bottom: 16px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--bone);
  color: #111;
  padding: 10px 18px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  font-weight: 500;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--out); color: #fff; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; border-right: none; border-bottom: 1px solid var(--line); }
  .nav { display: flex; overflow-x: auto; order: 3; width: 100%; gap: 4px; }
  .nav button { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .nav button[aria-current="page"] { border-bottom-color: var(--brass); }
  .who { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .who strong { display: inline; }
  .two-col { grid-template-columns: 1fr; }
  .welcome { flex-direction: column; text-align: center; }
  .hier-section { margin-left: 8px; padding-left: 14px; }
  .hier-head { margin-left: -37px; }
  .hier-rank { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Améliorations : statistiques, journal, minuteurs et carte interactive ---------- */
.announcement { margin-bottom: 18px; border-left: 3px solid var(--brass); }
.announcement p { white-space: normal; overflow-wrap: anywhere; }
.intel-map { width: 100%; height: 380px; min-height: 280px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); z-index: 0; }
.map-card { margin-bottom: 18px; }
.heist-rules-card { margin-bottom: 18px; }
.heist-rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.heist-rule { display: grid; gap: 4px; padding: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.heist-rule strong { text-transform: capitalize; color: var(--bone); }
.heist-rule span, .heist-rule small { color: var(--muted); font-size: .84rem; }
.heist-rule .countdown { color: var(--brass); font-size: .9rem; }
@media (max-width: 720px) { .intel-map { height: 300px; } }


/* Carte GTA V dédiée */
.gta-map-card { padding: 14px; }
.gta-world-map { width: 100%; height: min(72vh, 760px); min-height: 420px; background: #19416b; border: 1px solid var(--line); border-radius: 4px; z-index: 0; overflow: hidden; }
.gta-map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.gta-map-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.gta-map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.gta-map-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.gta-map-filter { display: flex; align-items: center; gap: 8px; }
.gta-map-filter select { width: auto; min-width: 190px; }
.gta-map-help { color: var(--muted); font-size: .85rem; margin-top: 10px; }
.gta-marker-wrap { background: transparent; border: 0; }
.gta-marker { display: flex; width: 32px; height: 32px; align-items: center; justify-content: center; border: 2px solid var(--marker-color); border-radius: 50%; background: rgba(12,12,12,.92); box-shadow: 0 2px 8px #0009; font-size: 15px; }
.gta-popup { min-width: 180px; color: #171717; font-family: var(--body); }
.gta-popup strong { display: block; font-size: 1rem; color: #151515; }
.gta-popup-kind { display: inline-block; margin-top: 3px; font-size: .78rem; color: #555; }
.gta-popup p { margin: 8px 0; white-space: normal; overflow-wrap: anywhere; }
.gta-popup small { color: #666; }
.gta-popup-actions { display: flex; gap: 6px; margin-top: 10px; }
.gta-popup-actions button { padding: 4px 8px; font-size: .8rem; color: #222; border-color: #aaa; background: #f3f3f3; }
.gta-popup-actions button.danger { color: #a52626; }
.gta-map-error { display: grid; place-content: center; gap: 10px; height: 100%; padding: 24px; text-align: center; color: var(--bone); }
.gta-map-error p { color: var(--muted); }
.gta-marker-list-card { margin-top: 18px; }
@media (max-width: 720px) { .gta-world-map { min-height: 360px; height: 58vh; } .gta-map-filter { width: 100%; } .gta-map-filter select { flex: 1; min-width: 0; } }

/* Les espaces momentanément visibles autour de l'image reprennent la couleur de l'océan de la carte. */
#gta-world-map, #gta-world-map .leaflet-container, #gta-world-map .leaflet-pane { background-color: #19416b; }
#gta-world-map .leaflet-image-layer { max-width: none !important; }
