:root {
  --brand: #8e5a8c; --brand-2: #b07fae; --brand-soft: #f3eaf3; --ink: #2d2a2e; --muted: #77707a;
  --line: #e7e1e8; --bg: #faf8fa; --card: #fff; --ok: #2f7d4f; --ok-soft: #e4f3ea; --warn: #a86a00; --warn-soft: #fbf0dc;
  --bad: #b3364a; --bad-soft: #fbe6ea; --radius: 10px; --shadow: 0 1px 2px rgba(45,42,46,.06), 0 4px 16px rgba(45,42,46,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--brand); }
h1 { font-size: 24px; margin: 0 0 4px; } h2 { font-size: 18px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.boot { display: grid; place-items: center; height: 100vh; } .boot img { height: 64px; opacity: .8; }

/* Mise en page */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { height: 48px; margin: 0 8px 18px; align-self: flex-start; }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--brand-soft); }
.side a.on { background: var(--brand); color: #fff; }
.side .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 12px 4px; }
.side .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; }
.side a.on .badge { background: #fff; color: var(--brand); }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.main { padding: 28px 32px 60px; max-width: 1200px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.burger { display: none; }

/* Composants */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { padding: 16px 18px; } .stat b { font-size: 28px; display: block; color: var(--brand); } .stat span { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 16px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--brand); } .btn.ghost:hover { background: var(--brand-soft); filter: none; }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); } .btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: 4px 10px; font-size: 13px; } .btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; color: #4a454c; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #d8d1d9; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: var(--brand-2); }
input[type=checkbox] { width: auto; } textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; } .check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; } .form-grid .full { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eee; color: #555; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; flex: none; font-size: 14px; }
.avatar.lg { width: 96px; height: 96px; font-size: 30px; } .avatar.md { width: 56px; height: 56px; font-size: 18px; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--brand-soft); margin-bottom: 14px; font-size: 14px; }
.notice.warn { background: var(--warn-soft); } .notice.bad { background: var(--bad-soft); } .notice.ok { background: var(--ok-soft); }
.copy { display: flex; gap: 8px; } .copy input { font-family: ui-monospace, monospace; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.checklist { list-style: none; padding: 0; margin: 0; } .checklist li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.checklist li:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }

/* Annuaire */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.person { display: flex; gap: 14px; align-items: flex-start; }
.person .info { min-width: 0; } .person .info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.person .name { font-weight: 600; font-size: 15px; }

/* Organigramme */
.org { overflow-x: auto; padding: 10px 0 20px; }
.org ul { padding-top: 20px; position: relative; display: flex; justify-content: center; margin: 0; padding-left: 0; }
.org li { list-style: none; text-align: center; position: relative; padding: 20px 6px 0; }
.org li::before, .org li::after { content: ''; position: absolute; top: 0; right: 50%; border-top: 1px solid #cbbfcc; width: 50%; height: 20px; }
.org li::after { right: auto; left: 50%; border-left: 1px solid #cbbfcc; }
.org li:only-child::before, .org li:only-child::after { display: none; } .org li:only-child { padding-top: 0; }
.org li:first-child::before, .org li:last-child::after { border: 0 none; }
.org li:last-child::before { border-right: 1px solid #cbbfcc; border-radius: 0 6px 0 0; } .org li:first-child::after { border-radius: 6px 0 0 0; }
.org ul ul::before { content: ''; position: absolute; top: 0; left: 50%; border-left: 1px solid #cbbfcc; height: 20px; }
.org > ul { padding-top: 0; } .org > ul > li { padding-top: 0; } .org > ul > li::before, .org > ul > li::after { display: none; }
.org .node { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 150px; max-width: 190px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.org .node:hover { border-color: var(--brand-2); }
.org .node b { font-size: 14px; } .org .node span { font-size: 12px; color: var(--muted); }

/* Authentification */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #f6eef6 0%, #faf8fa 60%); }
.auth .card { width: 100%; max-width: 440px; padding: 32px; }
.auth .logo { height: 64px; display: block; margin: 0 auto 18px; }
.auth h1 { text-align: center; font-size: 20px; margin-bottom: 18px; }
.qr { display: block; margin: 12px auto; border: 1px solid var(--line); border-radius: 8px; }
.code-input { font-size: 22px; letter-spacing: .4em; text-align: center; font-family: ui-monospace, monospace; }

/* Fiche convention imprimable */
.fiche dl { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; margin: 0; } .fiche dt { color: var(--muted); } .fiche dd { margin: 0; white-space: pre-wrap; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 10; max-width: 90vw; }
#toast.on { opacity: 1; transform: translateX(-50%); } #toast.bad { background: var(--bad); }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(45,42,46,.4); }
dialog .card { margin: 0; border: 0; box-shadow: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 5; transform: translateX(-100%); transition: .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .burger { display: inline-flex; margin-bottom: 12px; }
  .main { padding: 18px 16px 60px; }
  .g2, .g3, .g4, .form-grid { grid-template-columns: 1fr; }
  .fiche dl { grid-template-columns: 1fr; }
}
@media print {
  .side, .burger, .no-print, #toast { display: none !important; }
  .shell { display: block; } .main { padding: 0; } .card { box-shadow: none; border: 0; }
}
