:root {
  --bg: #0f1724; --panel: #172233; --panel-2: #1e2b40; --text: #e8eef7; --muted: #9aabc2;
  --accent: #4fb3ff; --accent-text: #06213a; --border: #2a3a52;
  --ok: #3ecf8e; --warn: #f5b942; --danger: #ff6b6b; --info: #7aa7ff;
  --radius: 12px; --nav-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa; --panel: #ffffff; --panel-2: #eef2f8; --text: #142033; --muted: #5b6b82;
    --accent: #0b6fc2; --accent-text: #ffffff; --border: #d7dfeb;
    --ok: #12855a; --warn: #9a6400; --danger: #c62828; --info: #2f5bd3;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.loading { padding: 2rem; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

/* Mise en page */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar { display: none; }
.main { padding: 1rem 1rem calc(var(--nav-h) + 1.5rem); max-width: 1100px; width: 100%; margin: 0 auto; }
.topbar > button.link { margin-left: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: .02em; }
.brand img { width: 32px; height: 32px; }
.bottomnav { position: fixed; inset: auto 0 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--panel); border-top: 1px solid var(--border); z-index: 10; }
.navlink { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .68rem; min-width: 0; padding: 4px 2px; }
.navlink .ico { font-size: 1.25rem; line-height: 1; }
.navlink .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.navlink.active { color: var(--accent); }
.navlink:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

@media (min-width: 860px) {
  .shell { grid-template-columns: 240px 1fr; }
  .sidebar { display: flex; flex-direction: column; gap: .25rem; padding: 1.25rem .75rem;
    background: var(--panel); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; }
  .sidebar .brand { padding: .25rem .5rem 1.25rem; }
  .sidebar .navlink { flex-direction: row; justify-content: flex-start; gap: .75rem; font-size: .95rem;
    padding: .6rem .75rem; border-radius: 8px; }
  .sidebar .navlink.active { background: var(--panel-2); }
  .sidebar .spacer { flex: 1; }
  .bottomnav { display: none; }
  .main { padding: 2rem 2rem 2rem; }
  .topbar .brand { display: none; }
}

/* Composants */
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.card header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.empty { border: 1px dashed var(--border); border-radius: 10px; padding: 1rem; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .65rem 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: flex-start; justify-content: space-between; }
.list .grow { flex-basis: 12rem; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.danger { color: var(--danger); }
.badge.info { color: var(--info); } .badge.muted { color: var(--muted); }
.badge.demo { color: #fff; background: #b4237a; border-color: #b4237a; }
.banner { padding: .6rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; }
.banner.demo { background: #b4237a; color: #fff; }
.banner.error { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); border: 1px solid var(--danger); }
.banner.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); border: 1px solid var(--ok); }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Formulaires */
form { display: grid; gap: .75rem; }
label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; min-height: 44px; }
textarea { min-height: 7rem; resize: vertical; }
.row { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .row { grid-template-columns: 1fr 1fr; } }
button { font: inherit; cursor: pointer; border-radius: 8px; padding: .55rem 1rem; min-height: 44px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.link { background: none; border: 0; color: var(--accent); padding: .25rem; min-height: auto; }
button:disabled { opacity: .6; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 100%; max-width: 400px; padding: 1.5rem; }
.login .brand { justify-content: center; font-size: 1.4rem; margin-bottom: 1rem; }

/* Petits écrans : le badge passe sous le texte pour laisser toute la largeur au contenu. */
@media (max-width: 599px) {
  .list > li { flex-direction: column; align-items: stretch; }
  .list > li > .badge, .list > li > button { align-self: flex-start; }
  .list .grow { flex-basis: auto; }
}

/* Inscription */
.enroll .card { max-width: 480px; }
.enroll h2 { margin-top: 1rem; }
.qr { display: block; width: 220px; height: 220px; margin: .5rem auto 1rem; background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
details { margin: 0 0 1rem; }
