:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7684;
  --accent: #FF0000;
  --accent-dark: #CC0000;
  --border: #dde1e6;
  --success-bg: #e6f6ec;
  --success-fg: #1c6b3c;
  --error-bg: #fdeaea;
  --error-fg: #a02020;
  --info-bg: #eaf1fb;
  --info-fg: #2a5599;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  background: #fff;
  border-bottom: 3px solid var(--accent);
}
.topbar-inner {
  max-width: 1620px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: inline-flex; align-items: center; }
.logo { height: 42px; width: auto; display: block; }
.lang a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 0.6rem;
  font-size: 0.9rem;
}
.lang a.active { color: var(--accent); font-weight: 700; text-decoration: underline; }
@media (max-width: 480px) {
  .logo { height: 32px; }
}

.container {
  max-width: 1620px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
}
body.public .container { max-width: 1080px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }

h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }

.event-meta { color: var(--muted); }
.event-meta span { margin-right: 1.2rem; }
.hello { font-size: 1.1rem; }
.hint { color: var(--muted); font-size: 0.9rem; }
.muted { color: var(--muted); }

.stack label { display: block; font-weight: 600; margin: 0.8rem 0 0.25rem; font-size: 0.95rem; }
.stack label.radio { font-weight: 400; margin: 0.3rem 0; }
.freetext {
  background: #fafbfc;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0 1rem;
}
.freetext p:first-child, .hint p:first-child { margin-top: 0; }
.freetext p:last-child, .hint p:last-child { margin-bottom: 0; }
div.hint { margin: 0.5rem 0; }

.consent {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  background: #fafbfc;
}
.consentlabel {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  cursor: pointer;
}
.consentlabel input[type="checkbox"] {
  margin-top: 0.25rem;
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}
.consenttext p:first-child { margin-top: 0; }
.consenttext p:last-child { margin-bottom: 0; }

/* Cartes de texte repliables (onglet Textes). */
details.textcard > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-weight: 700;
  user-select: none;
}
details.textcard > summary::-webkit-details-marker { display: none; }
details.textcard > summary::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border: solid var(--muted, #8a929c);
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
details.textcard[open] > summary::before { transform: rotate(45deg); }
details.textcard[open] > summary { margin-bottom: 0.9rem; }
details.textcard > summary:hover { color: var(--accent); }

.dangerzone { border-color: #e0b4b4; }
.dangerzone h2 { color: #a02020; }
.dangerzone .hint { max-width: 32rem; margin: 0.2rem 0 0; }
.dangersep { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="time"], select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 1rem 0 0;
}
legend { font-weight: 600; padding: 0 0.4rem; }

button, .button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.3rem;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.9rem;
}
button:hover, .button:hover { background: var(--accent-dark); }
button.danger { background: #c22; padding: 0.35rem 0.8rem; font-size: 0.85rem; margin-top: 0; }
button.danger:hover { background: #911; }
.button.ghost, button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  margin-top: 0;
}
button.linklike {
  background: none;
  color: var(--muted);
  padding: 0;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  text-decoration: underline;
}
button.linklike:hover { background: none; color: var(--text); }

.alert {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin: 0.8rem 0;
}
.alert.success { background: var(--success-bg); color: var(--success-fg); }
.alert.error { background: var(--error-bg); color: var(--error-fg); }
.alert.info { background: var(--info-bg); color: var(--info-fg); }

.grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 0.7rem;
}
.grid3 label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.2rem; }
@media (max-width: 640px) {
  .grid3 { grid-template-columns: 1fr; }
}
.companion { margin-bottom: 0.9rem; }
.companion h3 { margin: 0.3rem 0 0.4rem; font-size: 0.95rem; color: var(--muted); }

.adminnav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 1.5rem;
}
.adminnav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.95rem;
}
.adminnav a:hover { background: var(--bg); }
.adminnav a.active { background: var(--accent); color: #fff; }
.adminnav .spacer { flex: 1; }
.adminnav .who { color: var(--muted); font-size: 0.9rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  text-align: center;
}
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat.clickable { cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.stat.clickable:hover { border-color: var(--accent); }
/* Tuile active : couleurs inversées (fond accent, texte blanc). */
.stat.active { background: var(--accent); border-color: var(--accent); }
.stat.active .value, .stat.active .label { color: #fff; }

/* Indicateur de présence (connecté·e / dernière connexion). */
.online { background: #c9f0cf; color: #0f5132; padding: 1px 6px; border-radius: 4px; }
.online::before { content: "\25CF"; color: #1a9c3e; font-size: 0.7em; margin-right: 0.35em; vertical-align: 0.1em; }
.lastseen { color: #98a0aa; font-size: 0.82em; font-weight: 400; margin-left: 0.45em; white-space: nowrap; }
/* Lignes accompagnant·e dans la liste des participants (tableau de bord). */
tr.comp-row > td { background: #fafbfc; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }

.badge {
  display: inline-block;
  border-radius: 99px;
  padding: 0.15rem 0.7rem;
  font-size: 0.82rem;
  white-space: nowrap;
}
.badge.yes { background: var(--success-bg); color: var(--success-fg); }
.badge.no { background: var(--error-bg); color: var(--error-fg); }
.badge.pending { background: #f0f0f0; color: var(--muted); }

.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.row h2 { margin: 0; }
.inline-form { display: inline-block; margin: 0; }
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 800px) {
  .cols { grid-template-columns: 1fr; }
}
code { background: #f0f0f0; padding: 0.1rem 0.3rem; border-radius: 4px; }

details.changepw {
  margin-top: 1.2rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}
details.changepw summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem;
}
details.changepw[open] summary { color: var(--text); font-weight: 600; }
details.changepw form { max-width: 380px; }

/* ---- partners.hrs-zp.ch : ajouts ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.kpis { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.6rem; }
.kpi { flex: 1 1 120px; background: #f4f6f9; border: 1px solid #e2e7ee; border-radius: 10px; padding: 0.8rem 1rem; text-align: center; }
.kpi-n { font-size: 1.9rem; font-weight: 700; color: #1c2733; line-height: 1.1; }
.kpi-l { font-size: 0.8rem; color: #5a6673; margin-top: 0.25rem; }
.hint { color: #5a6673; font-size: 0.9rem; }

/* ---- Formulaire institut (§1→§9) ---- */
.pform .card { margin-bottom: 1rem; }
.pform h2 { margin: 0 0 0.8rem; font-size: 1.15rem; }
.pform h3 { margin: 1rem 0 0.4rem; font-size: 0.95rem; color: #3a4654; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }
.fgrid > div { display: flex; flex-direction: column; }
@media (max-width: 680px) { .fgrid { grid-template-columns: 1fr; } }
.cours-block { border: 1px solid #e2e7ee; border-radius: 10px; padding: 0.7rem 0.9rem; margin-bottom: 0.8rem; background: #fafbfc; }
.subsec { margin-top: 0.8rem; }
label.check { display: block; font-weight: 400; margin: 0.25rem 0; cursor: pointer; }
label.check.big { font-size: 1.02rem; margin: 0.1rem 0 0.5rem; }
.formbar { display: flex; gap: 0.8rem; justify-content: flex-end; flex-wrap: wrap; }
.filelist { list-style: none; padding: 0; margin: 0.5rem 0; }
.filelist li { padding: 0.25rem 0; border-bottom: 1px solid #eef1f5; }
.link-danger { background: none; border: none; color: #c0392b; cursor: pointer; text-decoration: underline; font-size: 0.85rem; padding: 0; }

/* ---- Matrice gestionnaire d'accès ---- */
table.matrix { border-collapse: collapse; font-size: 0.85rem; }
table.matrix th, table.matrix td { border: 1px solid #e2e7ee; padding: 0.35rem 0.5rem; }
table.matrix th { background: #f4f6f9; font-weight: 600; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.brouillon { background: #eceff3; color: #5a6673; }
.badge.soumis { background: #e7f0fb; color: #1d5fb0; }
.badge.en_validation { background: #fff3d6; color: #9a6b00; }
.badge.valide { background: #e3f5e8; color: #1f7a3d; }
.badge.refuse { background: #fce4e4; color: #b3281f; }
.badge.en_attente { background: #fff3d6; color: #9a6b00; }

/* ---- Back-office : validation, fiches, filtres ---- */
.filterbar a { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; color: #3a4654; text-decoration: none; font-size: 0.88rem; }
.filterbar a.active { background: #1c2733; color: #fff; }
table.kv { border-collapse: collapse; width: 100%; }
table.kv th { text-align: left; vertical-align: top; width: 38%; padding: 0.3rem 0.6rem 0.3rem 0; color: #5a6673; font-weight: 600; }
table.kv td { padding: 0.3rem 0; }
.button.small { padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.decide-form { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.btn-ok { background: #1f7a3d; }
.btn-ok:hover { background: #196632; }
.btn-no { background: #b3281f; }
.btn-no:hover { background: #95211a; }

/* ---- Hiérarchie cours + matrice affectation ---- */
.cours-parent { border-left: 3px solid #d7dde5; padding-left: 0.8rem; margin-bottom: 0.6rem; }
.cours-parent > h4 { margin: 0.6rem 0 0.4rem; font-size: 1rem; color: #1c2733; }
table.aff { border-collapse: collapse; font-size: 0.85rem; margin-top: 0.3rem; }
table.aff th, table.aff td { border: 1px solid #e2e7ee; padding: 0.3rem 0.5rem; }
table.aff th { background: #f4f6f9; font-weight: 600; }

/* ---- E-mails / mise à jour annuelle ---- */
.mailprev { border: 1px solid #e2e7ee; border-radius: 8px; margin-top: 0.5rem; max-height: 420px; overflow: auto; background: #fff; }
.progbar { height: 14px; background: #eceff3; border-radius: 999px; overflow: hidden; }
.progbar-fill { height: 100%; width: 0; background: #2a5599; transition: width 0.25s; }
.button.small { padding: 0.25rem 0.7rem; font-size: 0.85rem; }
button.ghost.small { padding: 0.2rem 0.6rem; font-size: 0.82rem; }
@media print { .adminnav, .topbar, button, .filterbar { display: none !important; } }

/* Bouton retirer une affectation */
.aff-clear { background: none; border: 1px solid #e2e7ee; border-radius: 6px; color: #b3281f; cursor: pointer; font-size: 0.8rem; line-height: 1; padding: 0.15rem 0.4rem; }
.aff-clear:hover { background: #fce4e4; }
.badge.remplace { background: #eceff3; color: #8a929c; }

/* Volet d'édition d'une personne */
.pedit { max-width: 320px; margin-top: 0.3rem; }
.pedit label { display: block; margin-top: 0.3rem; font-weight: 400; font-size: 0.85rem; color: #5a6673; }
.pedit input, .pedit select { width: 100%; }
