:root {
  --fond: #f6f4ef;
  --surface: #fffdf9;
  --surface-2: #f1ede4;
  --encre: #17181c;
  --encre-doux: #5c5e68;
  --or: #94742a;
  --or-clair: #c9a94f;
  --trait: #e0dbcf;
  --rouge: #9c322a;
  --vert: #2d6a45;
  --bleu: #2c4f7c;
  --ombre: 0 1px 2px rgba(23, 24, 28, .05), 0 8px 24px rgba(23, 24, 28, .06);
  --rayon: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #131419;
    --surface: #1a1c23;
    --surface-2: #22252e;
    --encre: #ecebe6;
    --encre-doux: #9b9da7;
    --or: #cba75a;
    --or-clair: #8a7233;
    --trait: #2e313b;
    --rouge: #e07a70;
    --vert: #6fbf90;
    --bleu: #8fb4e8;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
a { color: var(--bleu); text-decoration-thickness: 1px; text-underline-offset: 2px; }
small { font-size: .82rem; }

.sur-titre {
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--encre-doux);
  font-weight: 600;
}

/* ------------------------------------------------------------------ entete */

.barre {
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
  position: sticky;
  top: 0;
  z-index: 20;
}

.barre-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.marque {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--encre);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.marque .sceau {
  width: 24px; height: 24px;
  border: 1.5px solid var(--or);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .62rem; letter-spacing: .04em;
  color: var(--or); font-family: var(--sans); font-weight: 700;
}

.liens { display: flex; gap: 4px; margin-left: auto; align-items: center; }

.liens a {
  color: var(--encre-doux);
  text-decoration: none;
  font-size: .88rem;
  padding: 7px 12px;
  border-radius: 7px;
}
.liens a:hover { background: var(--surface-2); color: var(--encre); }
.liens a.actif { color: var(--encre); background: var(--surface-2); font-weight: 600; }

/* ---------------------------------------------------------------- contenus */

main { max-width: 1120px; margin: 0 auto; padding: 34px 24px 80px; }

.titre-page { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.titre-page p { margin: 0; color: var(--encre-doux); }

.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 22px;
  margin-bottom: 20px;
}
.carte > h2:first-child, .carte > h3:first-child { margin-top: 0; }

.grille-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }

.stat { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 16px 18px; }
.stat .valeur { font-family: var(--serif); font-size: 1.6rem; line-height: 1.2; }
.stat .valeur.numero { font-family: var(--mono); font-size: 1.12rem; letter-spacing: -.02em; }

/* -------------------------------------------------------------- depot ------ */

.depot {
  border: 2px dashed var(--trait);
  border-radius: 14px;
  background: var(--surface);
  padding: 44px 24px;
  text-align: center;
  transition: border-color .15s, background .15s, transform .15s;
  cursor: pointer;
}
.depot:hover { border-color: var(--or-clair); }
.depot.survol { border-color: var(--or); background: var(--surface-2); transform: scale(1.004); }
.depot.occupe { opacity: .6; pointer-events: none; }
.depot h3 { margin-bottom: 4px; }
.depot p { color: var(--encre-doux); margin: 0; font-size: .9rem; }
.depot .icone { font-size: 1.9rem; line-height: 1; margin-bottom: 10px; color: var(--or); }
.depot.compact { padding: 26px 20px; }

/* ------------------------------------------------------------------ boutons */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: .9rem; font-weight: 500;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--trait);
  background: var(--surface);
  color: var(--encre);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primaire { background: var(--encre); color: var(--surface); border-color: var(--encre); }
.btn.primaire:hover { opacity: .88; }
.btn.danger { color: var(--rouge); border-color: var(--trait); }
.btn.plein { width: 100%; justify-content: center; padding: 11px; }
.btn.petit { padding: 5px 10px; font-size: .82rem; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ tables */

.table-enveloppe { overflow-x: auto; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th {
  text-align: left; font-weight: 600; font-size: .68rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--encre-doux); padding: 11px 14px; border-bottom: 1px solid var(--trait); white-space: nowrap;
  background: var(--surface-2);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--trait); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, .mono { font-family: var(--mono); font-size: .82rem; }
td.vide { color: var(--encre-doux); }

.vignette { width: 44px; height: 44px; object-fit: cover; border-radius: 5px; border: 1px solid var(--trait); display: block; background: var(--surface-2); }
.vignette-absente { width: 44px; height: 44px; border-radius: 5px; border: 1px dashed var(--trait); display: grid; place-items: center; color: var(--encre-doux); font-size: .7rem; }

/* ------------------------------------------------------------------- etats */

.puce {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--trait);
  color: var(--encre-doux); white-space: nowrap;
}
.puce.ok { color: var(--vert); border-color: color-mix(in srgb, var(--vert) 35%, transparent); }
.puce.attente { color: var(--or); border-color: color-mix(in srgb, var(--or) 40%, transparent); }
.puce.manque { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 35%, transparent); }

.alerte { border-radius: 9px; padding: 12px 15px; margin-bottom: 16px; font-size: .9rem; border: 1px solid var(--trait); background: var(--surface); }
.alerte.erreur { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 35%, transparent); background: color-mix(in srgb, var(--rouge) 7%, var(--surface)); }
.alerte.succes { color: var(--vert); border-color: color-mix(in srgb, var(--vert) 35%, transparent); background: color-mix(in srgb, var(--vert) 7%, var(--surface)); }
.alerte.info { color: var(--encre-doux); }
.alerte ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- formulaires */

label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--encre); }
.aide { font-weight: 400; color: var(--encre-doux); font-size: .78rem; margin-top: 4px; }

input[type=text], input[type=password], input[type=file], input[type=search], textarea, select {
  width: 100%;
  font: inherit; font-size: .9rem;
  padding: 9px 11px;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: var(--fond);
  color: var(--encre);
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, .depot:focus-visible {
  outline: 2px solid var(--or); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.5; font-family: var(--serif); font-size: .95rem; }
.champ { margin-bottom: 16px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* -------------------------------------------------------------- connexion */

.page-acces { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.acces { width: 100%; max-width: 400px; }
.acces .sceau-grand {
  width: 54px; height: 54px; margin: 0 auto 18px;
  border: 2px solid var(--or); border-radius: 50%;
  display: grid; place-items: center; color: var(--or);
  font-weight: 700; font-size: .8rem; letter-spacing: .06em;
}
.acces .carte { padding: 30px; }
.acces h1 { text-align: center; font-size: 1.5rem; margin-bottom: 4px; }
.acces .intro { text-align: center; color: var(--encre-doux); font-size: .88rem; margin-bottom: 24px; }
.code-mfa { font-family: var(--mono); font-size: 1.5rem; text-align: center; letter-spacing: .5em; padding: 12px !important; text-indent: .5em; }
.qr { display: block; margin: 0 auto 14px; border-radius: 8px; border: 1px solid var(--trait); background: #fff; padding: 8px; }
.secret { font-family: var(--mono); font-size: .8rem; word-break: break-all; text-align: center; color: var(--encre-doux); background: var(--surface-2); padding: 8px; border-radius: 6px; }

/* ------------------------------------------------------------------ divers */

.deux-colonnes { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
/* Sans min-width, une piste de grille prend la largeur intrinsèque de son
   contenu : une photo de 1000 px écrase la colonne voisine. */
.deux-colonnes > * { min-width: 0; }
@media (max-width: 860px) { .deux-colonnes, .duo { grid-template-columns: 1fr; } }

.liste-plate { list-style: none; margin: 0; padding: 0; }
.liste-plate li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--trait); font-size: .87rem; }
.liste-plate li:last-child { border-bottom: none; }
.liste-plate .cle { color: var(--encre-doux); }

.apercu-pdf { width: 100%; height: 640px; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--surface-2); }

.progression { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.progression span { display: block; height: 100%; background: var(--or); width: 0; transition: width .25s; }

.masque { display: none !important; }
.pied { text-align: center; color: var(--encre-doux); font-size: .78rem; padding: 30px 0 0; }

/* -------------------------------------------------------------- selection */

.col-choix { width: 34px; }
.col-choix input { width: 15px; height: 15px; accent-color: var(--or); cursor: pointer; }

/* La barre reste au bas de l'ecran tant qu'une case est cochee. */
.barre-selection {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 13px 18px;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: 0 -2px 20px rgba(23, 24, 28, .10);
}
.barre-selection .decompte { font-weight: 600; }
.barre-selection .actions { margin-left: auto; }

.actions.sans-retour { flex-wrap: nowrap; }
.actions.sans-retour .btn { white-space: nowrap; }

/* --------------------------------------------------------------- utilitaires */
/* La CSP interdit les styles en ligne : les ajustements ponctuels passent par
   ces classes plutôt que par des attributs style. */

.note      { color: var(--encre-doux); font-size: .9rem; }
.note-fine { color: var(--encre-doux); font-size: .85rem; }
.centre    { text-align: center; }
.sans-marge { margin: 0; }
.espace-avant   { margin-top: 14px; }
.espace-avant-court { margin-top: 10px; }
.espace-avant-long  { margin-top: 34px; }
.espace-apres  { margin-bottom: 14px; }
.espace-apres-court { margin-bottom: 8px; }
.zone-haute { min-height: 130px; }
.zone-basse { min-height: 70px; }
.champ-large { min-width: 280px; }
.sans-cadre { border: none; }

.photo-fiche {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--trait);
  background: var(--surface-2);
}
