:root {
  --green: #143d35; --green-2: #1d544a; --gold: #d5b477;
  --bg: #f5f6f3; --surface: #fff; --ink: #1d2623; --muted: #66726d; --line: #dde2dc;
  --ok: #2c7a5a; --warn: #a56a00; --bad: #b3402a; --info: #2b5f8a;
  --ok-bg: #e4f1ea; --warn-bg: #f8eed9; --bad-bg: #f7e4df; --info-bg: #e3edf5; --muted-bg: #eceee9;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614; --surface: #17201d; --ink: #e6ece9; --muted: #98a6a0; --line: #2b3732;
    --ok: #6ccf9f; --warn: #e3b25a; --bad: #f0907a; --info: #86b8e2;
    --ok-bg: #173026; --warn-bg: #352a14; --bad-bg: #361d17; --info-bg: #17293a; --muted-bg: #222c28;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
a { color: var(--info); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Gabarit ─────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--green); color: #e8efec; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 4px 10px 18px; font-weight: 600; font-size: 1.05rem; color: #fff; }
.brand small { display: block; font-weight: 400; color: #a9c1b9; font-size: .8rem; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; color: #8fb0a5; font-size: .8rem; }
.nav a { display: block; padding: 7px 10px; border-radius: var(--radius); color: #e8efec; text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { background: var(--green-2); }
.nav a[aria-current="page"] { background: var(--green-2); border-left-color: var(--gold); color: #fff; }
.nav .count { float: right; background: var(--gold); color: var(--green); border-radius: 10px; padding: 0 7px; font-size: .75rem; font-weight: 600; }
.sidebar-foot { margin-top: 20px; padding: 12px 10px 0; border-top: 1px solid #2f5a50; font-size: .85rem; color: #a9c1b9; }
.sidebar-foot .btn { margin-top: 8px; }
.main { padding: 26px 32px 60px; min-width: 0; max-width: 1280px; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .15s; }
  .sidebar.open { transform: none; }
  .main { padding: 16px 14px 50px; }
  .topbar { display: block; padding: 12px 14px 0; }
}

.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 8px; }

/* ── Boutons, champs ─────────────────────────────────── */
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-2); border-color: var(--green-2); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: .875rem; }
.icon-btn { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; }
.field-error { color: var(--bad); margin: 0; min-height: 1em; font-size: .9rem; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.check input { margin-top: 4px; }
.check small { display: block; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 190px; }

/* ── Tableaux ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .85rem; color: var(--muted); background: var(--bg); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--gold) 9%, transparent); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }
.sub { display: block; color: var(--muted); font-size: .85rem; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); } .badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }

.notice { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.notice-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.notice-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.notice-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.notice-info { background: var(--info-bg); color: var(--info); border-color: var(--info); }

/* ── Tableau de bord ─────────────────────────────────── */
.queue { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.queue a { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.queue a.zero { border-left-color: var(--line); color: var(--muted); }
.queue strong { font-size: 1.7rem; display: block; line-height: 1.1; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.facts div { padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: .85rem; } .facts dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 600; }
dl.facts { margin: 0; }

/* ── Modales, toasts ─────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(10, 20, 17, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 8px; width: min(520px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: var(--radius); background: var(--green); color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast-bad { background: var(--bad); } .toast-warn { background: var(--warn); }

/* ── Connexion / configuration ───────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--green); }
.auth-card { background: var(--surface); border-radius: 8px; padding: 30px; width: min(440px, 100%); border-top: 4px solid var(--gold); }
.auth-card h1 { margin-bottom: 4px; } .auth-card > p { margin: 0 0 18px; }
.auth-card .btn-primary { width: 100%; padding: 10px; }
.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.steps span { padding: 2px 10px; border-radius: 10px; background: var(--muted-bg); color: var(--muted); font-size: .85rem; }
.steps .on { background: var(--green); color: #fff; } .steps .done { background: var(--ok-bg); color: var(--ok); }

.secret { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 1.15rem; letter-spacing: .08em; padding: 10px 12px; background: var(--bg); border: 1px dashed var(--muted); border-radius: var(--radius); word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; padding: 12px; background: var(--bg); border-radius: var(--radius); margin: 10px 0; }

/* ── Matrices (permissions) ──────────────────────────── */
.perm-group { margin-bottom: 14px; }
.perm-group h3 { font-size: .95rem; margin-bottom: 4px; color: var(--muted); }
.matrix td, .matrix th { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
details > summary { cursor: pointer; color: var(--info); }
pre.json { background: var(--bg); padding: 8px; border-radius: var(--radius); overflow-x: auto; font-size: .8rem; max-width: 520px; }
.policy-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.policy-section h2 { margin-bottom: 2px; } .policy-section > p { margin: 0 0 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); }
.gallery { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; }
.thumb { height: 120px; width: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.section-sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
