/* Feuille de style commune. Palette et typographie alignées sur le relevé fonctionnel
   (bleu-vert d'accent, neutres froids), thème clair et sombre. */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --ink: #1b2430; --muted: #5b6675; --line: #d9dfe6; --line-soft: #e8edf1;
  --accent: #0f6b7a; --accent-ink: #ffffff; --accent-soft: #dcedf0; --nav-bg: #14212b; --nav-ink: #c9d3dc; --nav-active: #1f3340;
  --ok: #2f9e6b; --warn: #e08a2a; --danger: #d64545; --danger-soft: #fbe5e5; --ok-soft: #e2f4ea;
  --radius: 4px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --surface: #171d23; --ink: #e6ebef; --muted: #9aa6b2; --line: #2a333d; --line-soft: #222b34;
    --accent: #4fc1d0; --accent-ink: #0b1216; --accent-soft: #12303a; --nav-bg: #0b1014; --nav-ink: #9fb0be; --nav-active: #1a252e;
    --danger-soft: #3a1c1c; --ok-soft: #173126;
  }
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif; line-height: 1.5;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Gabarit : barre latérale + contenu */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.nav { background: var(--nav-bg); color: var(--nav-ink); padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 4px; }
.nav .brand { color: #fff; font-weight: 600; font-size: 15px; padding: 6px 10px 14px; line-height: 1.3; }
.nav .brand small { display: block; color: var(--nav-ink); font-weight: 400; font-size: 12px; }
.nav a { color: inherit; text-decoration: none; display: block; padding: 8px 10px; border-radius: var(--radius); font-size: 14px; }
.nav a:hover { background: var(--nav-active); color: #fff; }
.nav a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav .group { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #7f8f9d; padding: 12px 10px 4px; }
.nav a.soon { opacity: .45; cursor: default; }
.nav .spacer { flex: 1; }
.nav .me { font-size: 13px; padding: 10px; border-top: 1px solid #243240; margin-top: 8px; }
.nav .me b { color: #fff; display: block; }
.main { padding: 24px 32px 48px; min-width: 0; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; }
  .nav.open { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--nav-bg); color: #fff; padding: 10px 16px; }
  .topbar button { background: transparent; border: 1px solid #3a4a58; color: #fff; padding: 6px 10px; border-radius: var(--radius); }
  .main { padding: 16px; }
}

/* En-tête de page */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; margin: 0; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 14px; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cartes, tableaux */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card h2 { font-size: 17px; margin: 0 0 12px; }
.card h2 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
tr.inactive td { color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 24px; color: var(--muted); text-align: center; }

/* Formulaires */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 14px 18px; }
.form .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.field > span b { color: var(--danger); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: 14px; width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:disabled, .field select:disabled { background: var(--bg); color: var(--muted); }
.help { font-size: 12px; color: var(--muted); margin: 0; }
.form-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 220px; }

/* Étiquettes */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.danger { color: var(--danger); border-color: var(--danger); }
.pill.accent { color: var(--accent); border-color: var(--accent); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; border: 1px solid rgba(0,0,0,.15); }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); padding: 1px 8px; border-radius: 3px; font-size: 12px; margin: 2px 4px 2px 0; }

/* Messages */
.alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 14px; font-size: 14px; }
.alert.error { border-color: var(--danger); background: var(--danger-soft); }
.alert.ok { border-color: var(--ok); background: var(--ok-soft); }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 50; max-width: min(90vw, 420px); }

/* Fenêtre modale */
.modal-back { position: fixed; inset: 0; background: rgba(10, 16, 20, .55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 40; overflow: auto; }
.modal { background: var(--surface); border-radius: 6px; border: 1px solid var(--line); width: min(720px, 100%); padding: 20px 22px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }

/* Page centrée (connexion, invitation) */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.center .card { width: min(420px, 100%); margin: 0; }
.center h1 { font-size: 20px; margin: 0 0 4px; }
.center .eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }

/* Matrice de droits */
.rights th:first-child, .rights td:first-child { width: 36px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rights td.desc { color: var(--muted); font-size: 13px; }
.rights .inactive-note { color: var(--warn); font-size: 12px; display: block; }
.switch { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.switch button { border: 0; background: var(--surface); padding: 3px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.switch button.on { background: var(--accent); color: var(--accent-ink); }
.switch button:disabled { cursor: default; }

/* Accueil */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: inherit; }
.tile:hover { border-color: var(--accent); }
.tile .n { font-size: 30px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 6px; }
.tile.soon { opacity: .55; }

/* Listes réordonnables */
.sortable li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius); margin-bottom: 6px; background: var(--surface); }
.sortable li .grow { flex: 1; }
.sortable li .mini { display: flex; gap: 4px; }
.sortable li.off { opacity: .55; }
.sortable { list-style: none; padding: 0; margin: 0; }
pre.json { font-size: 12px; white-space: pre-wrap; word-break: break-word; margin: 0; color: var(--muted); }
