/* ==========================================================================
   Portail — feuille de style
   Papier chaud et encre en clair, charbon chaud en sombre (suit le réglage du
   téléphone). Une seule couleur vive, la terre cuite, pour le logo et les
   repères. Police système (San Francisco sur iPhone) : rien à télécharger.
   ========================================================================== */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1d1b18;
  --muted: #6d675e;
  --faint: #a29b90;
  --line: #e4e0d8;
  --accent: #b9532a;          /* terre cuite */
  --on-ink: #ffffff;          /* texte posé sur un bouton plein */
  --danger: #c0362c;
  --warn: #9a5b06; --warn-soft: #fbefdc;
  --ok: #2f7d4f;
  --shadow: 0 1px 2px rgba(29, 27, 24, .05), 0 6px 20px rgba(29, 27, 24, .06);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311; --surface: #1e1c19; --ink: #f1eee8; --muted: #a39d93; --faint: #6f6a62; --line: #2e2b27;
    --accent: #e2794c; --on-ink: #141311; --danger: #ff6b5e; --warn: #f0b45a; --warn-soft: #2e2312; --ok: #5cc48a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 19px; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 18px 0 6px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 12px; }
a { color: inherit; }
code { font: 15px/1.4 ui-monospace, "SF Mono", Menlo, monospace; }
small { display: block; color: var(--muted); font-size: 14px; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- Logo --------------------------------------------------------------------- */
.logo { width: 64px; height: 64px; display: block; margin: 0 0 18px; color: var(--ink); }

/* --- Écrans d'entrée (connexion, double authentification…) -------------------- */
.entree {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: calc(var(--safe-top) + 48px) 16px calc(var(--safe-bottom) + 32px);
}
.carte-entree { width: 100%; max-width: 420px; }
.sous-titre { color: var(--muted); margin-bottom: 22px; }
.note { background: var(--surface); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.liens { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 18px; }

/* --- Champs et boutons ----------------------------------------------------------- */
.champ { display: block; margin-bottom: 14px; }
.champ > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.champ small { margin-top: 6px; }
input[type=text], input[type=password], input:not([type]), input[inputmode] {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px;
  -webkit-appearance: none; appearance: none;
}
input:focus { border-color: var(--ink); outline: none; }
input.code { font: 600 26px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .18em; text-align: center; }
.erreur { color: var(--danger); font-size: 15px; }
.erreur:empty { display: none; }
.note.erreur { color: var(--warn); background: var(--warn-soft); box-shadow: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 16px/1.2 inherit; font-family: inherit; text-decoration: none; cursor: pointer;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--on-ink);
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.secondaire { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.plein { width: 100%; margin-top: 4px; }
.lien { background: none; border: 0; padding: 6px 0; font: inherit; font-size: 15px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.lien.danger { color: var(--danger); }
.rangee { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 14px; }
.coche { display: flex; gap: 10px; align-items: center; margin: 6px 0 16px; font-size: 16px; }
.coche input { width: 22px; height: 22px; accent-color: var(--accent); }

/* --- Double authentification ------------------------------------------------------ */
.etapes { padding-left: 20px; margin: 0 0 16px; color: var(--muted); }
.etapes li { margin-bottom: 8px; }
.etapes b { color: var(--ink); }
.qr { display: block; width: 220px; height: 220px; margin: 4px auto 16px; border-radius: 14px; background: #fff; padding: 6px; }
details.cle { margin: 14px 0 18px; font-size: 15px; }
details.cle summary { cursor: pointer; color: var(--muted); }
.cle-texte code { font-size: 16px; letter-spacing: .04em; word-break: break-all; }
.petit { color: var(--muted); font-size: 14px; }
.codes { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.codes li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.codes code { font-size: 17px; letter-spacing: .06em; }

/* --- Accueil ------------------------------------------------------------------------- */
.accueil, .page {
  max-width: 560px; margin: 0 auto;
  padding: calc(var(--safe-top) + 28px) 16px calc(var(--safe-bottom) + 40px);
}
.tete { margin-bottom: 22px; }
.date { color: var(--muted); margin: 0 0 2px; font-size: 15px; }
.tete h1 { font-size: 34px; }
.bandeau { background: var(--surface); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; font-size: 15px; color: var(--muted); box-shadow: var(--shadow); }
.bandeau.attention { color: var(--warn); background: var(--warn-soft); box-shadow: none; }
.bandeau.attention p { margin-bottom: 10px; }

.applis { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 12px; }
@media (min-width: 560px) { .applis { grid-template-columns: 1fr 1fr; } }
.appli {
  display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
  background: var(--surface); border-radius: var(--radius); padding: 14px; text-decoration: none; box-shadow: var(--shadow);
  min-height: 84px; transition: transform .08s ease;
}
.appli:active { transform: scale(.985); }
.appli img { grid-row: 1 / span 2; width: 56px; height: 56px; border-radius: 13px; display: block; }
.appli .nom { font-weight: 650; font-size: 18px; align-self: end; }
.appli .desc { color: var(--muted); font-size: 14px; align-self: start; }

/* --- Blocs (Mon compte, Utilisateurs, liens de l'accueil) ----------------------------- */
.bloc { background: var(--surface); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.bloc > p { color: var(--muted); font-size: 15px; }
.sous-bloc { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.accueil .bloc { padding: 4px 16px; }
.ligne { display: block; position: relative; padding: 13px 28px 13px 0; text-decoration: none; border-bottom: 1px solid var(--line); }
.ligne:last-child { border-bottom: 0; }
.ligne span { font-weight: 600; }
.ligne::after { content: "›"; position: absolute; right: 2px; top: 50%; transform: translateY(-55%); color: var(--faint); font-size: 24px; line-height: 1; }
.retour { display: inline-block; text-decoration: none; color: var(--muted); padding: 6px 0; margin-bottom: 8px; }
.page h1 { margin-bottom: 18px; }

.liste { list-style: none; padding: 0; margin: 0 0 12px; }
.liste > li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.liste > li:last-child { border-bottom: 0; }
.liste > li > div:first-child { flex: 1 1 200px; }
.comptes .actions-compte { display: flex; flex-wrap: wrap; gap: 4px 14px; width: 100%; }
.comptes [data-zone-lien] { width: 100%; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); vertical-align: 2px; }
.badge.rouge { color: var(--danger); }
.badge.orange { color: var(--warn); }
.lien-texte code { display: block; font-size: 13px; word-break: break-all; background: var(--bg); padding: 10px; border-radius: 10px; }

/* --- Fenêtres et messages ----------------------------------------------------------------- */
.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + var(--safe-bottom)); z-index: 10; }
@media (min-width: 560px) { .voile { align-items: center; } }
.fenetre { background: var(--surface); border-radius: 20px; padding: 20px; width: 100%; max-width: 420px; }
.fenetre p { color: var(--muted); }
.fenetre .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: 14px; font-size: 15px;
  max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 20;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.erreur { background: var(--danger); color: #fff; }

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