:root {
  color-scheme: light dark;
  --bg: #f3f4f8;
  --surface: #ffffff;
  --fg: #1b1e27;
  --muted: #555b6e;
  --link: #3730a3;
  --error: #b3261e;
  --error-bg: #fdecea;
  --ok: #1e7a3c;
  --accent: #4f46e5;
  --on-accent: #ffffff;
  --accent-soft: #eef0ff;
  --border: #868c9c;
  --line: #e2e4ec;
  --focus: #4f46e5;
  --shadow: 0 1px 2px rgb(20 24 40 / .06), 0 4px 16px rgb(20 24 40 / .06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b24;
    --fg: #e6e8ef;
    --muted: #a0a6b8;
    --link: #a5b4fc;
    --error: #ff8a80;
    --error-bg: #3a1a1a;
    --ok: #7ee2a0;
    --accent: #818cf8;
    --on-accent: #0f1117;
    --accent-soft: #23264a;
    --border: #6b7185;
    --line: #2a2e3b;
    --focus: #a5b4fc;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0 auto; padding: 0 1rem 3rem; max-width: 64rem;
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg); background: var(--bg);
}
a { color: var(--link); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--accent-soft); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* En-tête */
header {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
  padding: 1.25rem 0; margin-bottom: 1rem; border-bottom: 1px solid var(--line);
}
nav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
nav a {
  padding: .4rem .75rem; border-radius: 999px; text-decoration: none; color: var(--fg); font-weight: 500;
}
nav a:hover { background: var(--accent-soft); color: var(--link); }
nav form { margin-left: .5rem; }

/* Sections en cartes */
main > section, main > form, main > table, .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.5rem; margin: 0 0 1.25rem;
}
main > table { padding: 0; overflow: hidden; }

/* Tableaux */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }

/* Formulaires */
label { display: block; font-weight: 600; font-size: .92rem; margin: .9rem 0 .3rem; }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem;
}
input[type=text], input[type=password], textarea { width: 100%; }
textarea { min-height: 8rem; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--focus); }

button {
  font: inherit; font-weight: 600; cursor: pointer; margin: .9rem .4rem 0 0;
  color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem 1rem;
  transition: background .15s, transform .05s;
}
button:hover { background: var(--accent-soft); }
button:active { transform: translateY(1px); }
button.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
.inline { display: inline; }
.inline button, nav button { margin: 0; }
nav button { padding: .35rem .8rem; font-weight: 500; }

/* Messages */
.muted { color: var(--muted); }
[role=alert] {
  color: var(--error); background: var(--error-bg); font-weight: 600;
  border-left: 4px solid var(--error); border-radius: 8px; padding: .75rem 1rem;
}
.ok { color: var(--ok); font-weight: 600; }

/* Étapes du lancement */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 1rem 0; }
ol.steps li {
  counter-increment: step; position: relative; padding: .45rem 0 .45rem 2.6rem;
}
ol.steps li::before {
  content: counter(step); position: absolute; left: 0; top: .35rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center;
  font-size: .85rem; font-weight: 700; color: var(--link); background: var(--accent-soft);
}
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
.actions button { margin: 0; }

/* Modale */
dialog {
  width: min(28rem, calc(100vw - 2rem)); padding: 1.5rem;
  color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(10 12 20 / .55); backdrop-filter: blur(3px); }
dialog h2 { margin-bottom: .25rem; }
dialog[open] { animation: pop .15s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  dialog[open] { animation: none; }
  button { transition: none; }
}

/* Connexion */
.login { max-width: 22rem; margin: 12vh auto 0; }
.login h1 { text-align: center; margin-bottom: 1.25rem; }
.login button { width: 100%; margin-right: 0; }

@media (max-width: 40rem) {
  main > section, main > form, .card { padding: 1rem; }
  th, td { padding: .55rem .6rem; }
}
