/* Console ENCG. Palette « Lin et caramel », thème du soir selon l'appareil, mouvement doux. */
@font-face {
  font-family: "Nunito";
  src: url("/static/fonts/nunito.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #F1EEE8; --card: #FFFFFC; --line: #DAD3C6;
  --txt: #26231F; --txt2: #37322C; --muted: #585148;
  --accent: #9A5A22; --on-accent: #FFFFFF; --tint: #F0E2CF; --tint-fg: #6B3D14;
  --ok-bg: #DCE8DC; --ok-fg: #2C4A39; --warn-bg: #F3E7C6; --warn-fg: #5E4508; --bad-bg: #F3DDD8; --bad-fg: #7A2E25;
  --shadow: 0 8px 30px rgba(90, 60, 25, .08); --shadow-up: 0 18px 40px rgba(90, 60, 25, .14);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Nunito", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1C18; --card: #2A2621; --line: #3D372F;
    --txt: #EDE6DA; --txt2: #D8CFC0; --muted: #B5AB9C;
    --accent: #DFA06A; --on-accent: #24180D; --tint: #43362A; --tint-fg: #F0D9BE;
    --ok-bg: #2F4236; --ok-fg: #CFE3D5; --warn-bg: #4A3E1E; --warn-fg: #F0DFA8; --bad-bg: #4A2A26; --bad-fg: #F3CFC8;
    --shadow: 0 8px 30px rgba(0, 0, 0, .28); --shadow-up: 0 18px 40px rgba(0, 0, 0, .4);
  }
}

@view-transition { navigation: auto; }

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--txt);
  font: 400 1rem/1.55 var(--font); -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
h1, h2, p, ul, ol, dl, dd { margin: 0; }
h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); font-weight: 800; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 1.2rem; font-weight: 800; line-height: 1.3; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); }
code { font-family: "Cascadia Code", Consolas, ui-monospace, monospace; font-size: .95em; }
img { max-width: 100%; }

/* Mise en page */
main { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
main.page { max-width: 880px; margin: 0 auto; padding-block: 28px 56px; display: flex; flex-direction: column; gap: 20px; }
main.page.wide { max-width: 1240px; }
main.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding-block: 32px; }
main.auth .card { width: 100%; max-width: 440px; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  background: var(--card); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--txt); font-weight: 800; line-height: 1.15; }
.brand small { display: block; font-weight: 600; font-size: .8rem; color: var(--muted); }
.bar nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.bar nav a {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 14px;
  color: var(--txt2); font-weight: 700; text-decoration: none; transition: background-color .3s var(--ease), color .3s var(--ease);
}
.bar nav a:hover { background: var(--tint); }
.bar nav a[aria-current="page"] { background: var(--tint); color: var(--tint-fg); }

/* Cartes */
.card {
  background: var(--card); border-radius: 28px; padding: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.card.highlight { background: var(--tint); color: var(--tint-fg); box-shadow: none; }
.card.empty { align-items: center; text-align: center; padding-block: 48px; }
.card.empty p { max-width: 44ch; color: var(--muted); }
.mark { align-self: center; }
.hello { display: flex; flex-direction: column; gap: 4px; }
.lead { font-size: 1.1rem; color: var(--muted); }
.hint { font-size: .95rem; color: var(--muted); }

/* Formulaires */
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack button { margin-top: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.row > div { flex: 1 1 180px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label { font-weight: 700; }
input, select {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--bg); color: var(--txt); font: inherit; transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
input:focus, select:focus { outline: none; border-color: var(--accent); background: var(--card); }
input.code { font-size: 1.5rem; font-weight: 800; letter-spacing: .25em; text-align: center; }
button, .button {
  min-height: 50px; padding: 0 26px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .25s var(--ease), filter .25s var(--ease), box-shadow .25s var(--ease);
}
button:hover, .button:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: var(--shadow-up); }
button:active, .button:active { transform: scale(.97); box-shadow: none; }
button.quiet, a.quiet {
  min-height: 44px; padding: 0 14px; background: transparent; color: var(--txt2); font-weight: 700; box-shadow: none;
  border-radius: 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button.quiet:hover, a.quiet:hover { background: var(--tint); transform: none; filter: none; box-shadow: none; }
button.danger { color: var(--bad-fg); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Messages */
.error, .notice, .warning { padding: 14px 18px; border-radius: 18px; font-weight: 700; animation: pop .45s var(--ease); }
.error { background: var(--bad-bg); color: var(--bad-fg); }
.notice { background: var(--ok-bg); color: var(--ok-fg); }
.warning { background: var(--warn-bg); color: var(--warn-fg); }
.pill { display: inline-flex; padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: var(--tint); color: var(--tint-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }

/* Double authentification */
.steps { counter-reset: step; display: flex; flex-direction: column; gap: 22px; }
.steps > li { counter-increment: step; display: flex; flex-direction: column; gap: 8px; padding-left: 48px; position: relative; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -4px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--tint); color: var(--tint-fg); font-weight: 800; display: flex; align-items: center; justify-content: center;
}
/* Sur un écran large, les consignes à gauche et le QR code à droite : tout tient sans défiler. */
main.auth .card.wide { max-width: 880px; gap: 10px; }
.card.wide .mark { width: 56px; height: 56px; align-self: flex-start; }
.setup { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 20px 44px; align-items: center; margin-top: 10px; }
.scan { display: flex; flex-direction: column; gap: 14px; }
.scan .qr { align-self: center; }
.setup .steps { gap: 18px; }
.setup .steps p { font-size: .95rem; color: var(--txt2); }
@media (max-width: 760px) {
  .setup { grid-template-columns: minmax(0, 1fr); }
}
.qr { align-self: flex-start; padding: 10px; border-radius: 18px; background: #FFFFFF; line-height: 0; }
.qr svg { width: 200px; height: 200px; max-width: 100%; display: block; }
.secret { display: inline-block; padding: 10px 14px; border-radius: 12px; background: var(--bg); color: var(--txt); font-weight: 700; word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.codes li { padding: 10px; border-radius: 12px; background: var(--bg); text-align: center; font-weight: 700; }
details summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 10px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform .3s var(--ease);
}
details[open] summary::after { transform: translateY(2px) rotate(225deg); }
details p { margin-top: 6px; }

/* Comptes et journal */
.facts { display: flex; flex-direction: column; gap: 12px; }
.facts div { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.facts dt { flex: 0 0 140px; color: var(--muted); font-weight: 700; }
.people { display: flex; flex-direction: column; gap: 12px; }
.people .card { padding: 18px 24px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.who { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
.who span { color: var(--muted); overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.actions { flex: 1 1 100%; }
.actions form { display: block; }
.actions button { justify-content: flex-start; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; vertical-align: top; overflow-wrap: anywhere; }
td.when { white-space: nowrap; color: var(--muted); }
th { color: var(--muted); font-weight: 700; }
tbody tr + tr td { border-top: 1px solid var(--line); }
/* Sur un écran étroit, chaque ligne du journal devient une fiche : rien ne défile de côté. */
@media (max-width: 760px) {
  table.log thead { display: none; }
  table.log, table.log tbody, table.log tr, table.log td { display: block; }
  table.log tr { padding: 12px 0; }
  table.log tr + tr { border-top: 1px solid var(--line); }
  table.log td, tbody tr + tr td { border: 0; padding: 2px 0; }
  table.log td::before { content: attr(data-label) " : "; color: var(--muted); font-weight: 700; }
  table.log td.when { white-space: normal; }
}

/* Mouvement */
.rise { animation: rise .7s var(--ease) both; }
.rise:nth-child(2) { animation-delay: .07s; }
.rise:nth-child(3) { animation-delay: .14s; }
.rise:nth-child(4) { animation-delay: .21s; }
.people .rise:nth-child(n+5) { animation-delay: .28s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.breathe { animation: breathe 4.2s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes breathe { 50% { transform: translateY(-3px) scale(1.03); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}
