:root {
  --bg: #f7f7f8;
  --card: #fff;
  --text: #242426;
  --muted: #68686e;
  --border: #dedee2;
  --primary: #cb001a;
  --primary-dark: #a90016;
  --danger: #a51b2c;
  --ok: #23724e;
  --warn: #86620c;
  --accent-soft: #fff0f2;
  --radius: 4px;
  font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 30px; font-weight: 600; margin: 0 0 1rem; }
h2 { font-size: 19px; font-weight: 600; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code, pre, textarea.code { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; color: var(--text); padding: .55rem 1.5rem; position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border); min-height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: 1rem; color: var(--text); font-weight: 600; }
.brand img { display: block; width: 156px; height: auto; }
.brand-product { border-left: 1px solid var(--border); padding-left: 1rem; }
#nav { display: flex; gap: 1rem; align-items: center; }
#nav a, #nav button.link { color: var(--text); }
#nav a:hover, #nav button.link:hover { color: var(--primary); }
#nav .who { color: var(--muted); font-size: .85rem; }

/* Menu burger (case à cocher + label), visible uniquement sur petit écran */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.burger { display: none; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.grid .card { margin: 0; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 220px; position: relative; }
/* Texte d'aide hors flux : les champs d'une ligne gardent la même hauteur */
.row > .field > .help { position: absolute; top: 100%; left: 0; margin-top: .25rem; }
.row:has(> .field > .help) { padding-bottom: 1rem; }
.row > .field ~ button { margin-bottom: .8rem; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field .label { font-weight: 600; font-size: .85rem; }
.field .help { color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; background: #fff; width: 100%; color: var(--text);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
textarea.code { min-height: 320px; white-space: pre; tab-size: 2; }
textarea.invalid { border-color: var(--danger); background: #fff6f5; }
.check { display: flex; align-items: center; gap: .5rem; margin: .35rem 0; cursor: pointer; }
.check input { width: 16px; height: 16px; }

button, .btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 4px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; font: inherit; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: var(--primary-dark); text-decoration: none; }
button.secondary { background: #fff; color: var(--primary); }
button.secondary:hover { background: var(--accent-soft); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #fdecea; }
button.link { background: none; border: none; color: var(--primary); padding: 0; }
button.small { padding: .2rem .5rem; font-size: .8rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f2f2f4; font-size: .8rem; font-weight: 600; color: var(--muted); }
td input, td select { padding: .3rem .4rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; color: var(--muted); border: none; border-bottom: 3px solid transparent; border-radius: 0; margin-bottom: -2px; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs button:hover { background: var(--accent-soft); }

.badge { display: inline-block; padding: .1rem .45rem; border-radius: 3px; font-size: .75rem; background: #f0f0f2; color: var(--text); margin-right: .25rem; }
.badge.on { background: #e8f3ed; color: var(--ok); }
.badge.role-admin { background: var(--accent-soft); color: var(--danger); }
.badge.mod { background: #f8f1dc; color: var(--warn); }

.alert { padding: .75rem 1rem; border-radius: 4px; margin: .75rem 0; }
.alert.error { background: #fdecea; color: #7b1d14; }
.alert.warn { background: #f8f1dc; color: #6d4c06; }
.alert.info { background: #f0f0f2; color: var(--text); }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }

.module-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.module { border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; background: #fff; }
.module.on { border-color: var(--primary); background: var(--accent-soft); }
.module.disabled { opacity: .55; }

.savebar {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border); padding: .75rem 1rem;
  display: flex; gap: 1rem; align-items: center; margin: 1rem -1.5rem -1.5rem;
}
.dirty { color: var(--warn); font-weight: 600; }

pre.view { background: #242426; color: #f7f7f8; padding: 1rem; border-radius: 4px; overflow: auto; max-height: 480px; }
.token { background: #f8f1dc; padding: .75rem; border-radius: 4px; word-break: break-all; font-family: 'IBM Plex Mono', ui-monospace, monospace; }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--text); color: #fff; padding: .7rem 1rem; border-radius: 4px; max-width: 420px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

.login { max-width: 380px; margin: 4rem auto; }
.reset { margin-left: .4rem; }


/* ---------- Mobile (en fin de fichier pour primer sur les règles de base) ---------- */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: .6rem 1rem; }
  .brand { gap: .65rem; }
  .brand img { width: 132px; }
  .brand-product { padding-left: .65rem; }
  .burger { display: block; cursor: pointer; color: var(--text); font-size: 1.6rem; line-height: 1; padding: .15rem .4rem; user-select: none; }
  .anon .burger { display: none; }
  .burger::before { content: '☰'; }
  .nav-toggle:checked ~ .burger::before { content: '✕'; }
  .nav-toggle:focus-visible ~ .burger { outline: 2px solid var(--primary); border-radius: 4px; }
  #nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0; margin-top: .5rem; }
  .nav-toggle:checked ~ #nav { display: flex; }
  #nav a, #nav button.link, #nav .who { padding: .75rem .25rem; border-top: 1px solid var(--border); text-align: left; font-size: 1rem; }

  main { padding: 1rem; }
  h1 { font-size: 1.3rem; }
  .card { padding: 1rem; overflow-x: auto; }
  .card table { min-width: 560px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .row > .field { flex-basis: 100%; }
  .row > .field > .help { position: static; margin-top: 0; }
  .row:has(> .field > .help) { padding-bottom: 0; }
  .row > .field ~ button { margin-bottom: .8rem; width: 100%; justify-content: center; }
  .savebar { margin: 1rem -1rem -1rem; flex-wrap: wrap; }
  .module-cards { grid-template-columns: 1fr; }
  .login { margin: 2rem auto; }
  #toasts { left: 1rem; right: 1rem; }
  .toast { max-width: none; }
}