/* Pli : identité « par avion ». Encre marine pour la structure, papier froid pour le contenu,
   rayures rouge/bleu de l'enveloppe aérienne comme signature (connexion, rédaction, accès). */
:root {
  --bg: #EDF0F5;
  --panel: #FFFFFF;
  --panel-2: #F6F8FB;
  --line: #E0E5ED;
  --grid: #ECEFF4;
  --fg: #131A2A;
  --muted: #627084;
  --accent: #2447B3;
  --accent-soft: #E7ECFA;
  --on-accent: #FFFFFF;
  --red: #D63B3B;
  --star: #DB9A00;
  --ink: #0E1630;
  --ink-2: #19244A;
  --ink-fg: #E8EDF8;
  --ink-muted: #8F9BBB;
  --good: #1B7A47; --good-soft: #E1F3E8;
  --warn: #9A6200; --warn-soft: #FBF0D9;
  --crit: #B3261E; --crit-soft: #FBE4E2;
  --shadow: 0 1px 2px rgba(14, 22, 48, .06), 0 8px 24px rgba(14, 22, 48, .07);
  --shadow-lg: 0 24px 60px rgba(14, 22, 48, .22);
  --radius: 14px;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --airmail: repeating-linear-gradient(-45deg, var(--red) 0 9px, transparent 9px 16px, var(--accent) 16px 25px, transparent 25px 32px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0A0F1D; --panel: #121A2C; --panel-2: #172036; --line: #232E47; --grid: #1B2439;
  --fg: #E5EAF4; --muted: #8B97AF; --accent: #84A2FF; --accent-soft: #1C2850; --on-accent: #0A0F1D;
  --red: #F06B6B; --star: #F2C14E;
  --ink: #070B17; --ink-2: #131C36; --ink-fg: #E5EAF4; --ink-muted: #7F8BA8;
  --good: #5CC98A; --good-soft: #13291D; --warn: #E8B530; --warn-soft: #2B2311; --crit: #F2827A; --crit-soft: #331918;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  color-scheme: dark; } }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* Marque */
.brand { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.03em; display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel); color: var(--accent); position: relative; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px var(--line); }
.logo::after { content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: var(--airmail); }
.airmail { height: 6px; background: var(--airmail); }

/* Boutons */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; font-weight: 500; text-decoration: none; color: var(--fg); display: inline-flex; align-items: center; gap: 7px; line-height: 1.2; }
.btn:hover { border-color: color-mix(in srgb, var(--muted) 60%, transparent); background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.btn.danger { color: var(--crit); }
.btn.danger:hover { border-color: var(--crit); background: var(--crit-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: none; color: var(--muted); display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--panel-2); color: var(--fg); }

/* Étiquettes d'état */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good); background: var(--good-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.crit { color: var(--crit); background: var(--crit-soft); }

/* Avatars : teinte stable dérivée du nom */
.avatar { --h: 220; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; letter-spacing: .02em; color: #FFFFFF; background: oklch(0.56 0.12 var(--h)); flex: none; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

.mono { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.err { color: var(--crit); font-size: 13px; }

/* Notification */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--ink-fg); padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: calc(100vw - 32px); display: flex; gap: 16px; align-items: center; box-shadow: var(--shadow-lg); }
.toast button { background: none; border: 0; color: #A9BDFF; font-weight: 600; padding: 0; }
.toast button:hover { text-decoration: underline; }

/* Fenêtres */
.modal-back { position: fixed; inset: 0; background: rgba(7, 11, 23, .5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { background: var(--panel); border-radius: 18px; width: min(460px, 100%); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal .in { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-family: var(--font-display); font-size: 22px; letter-spacing: -0.02em; }
.modal p { margin: 0; color: var(--muted); line-height: 1.55; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.modal input { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 10px 12px; color: var(--fg); }
.modal input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }

/* Chargement */
.skeleton { background: linear-gradient(90deg, var(--grid) 0%, var(--panel-2) 50%, var(--grid) 100%); background-size: 200% 100%; border-radius: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s linear infinite; }
  @keyframes shimmer { to { background-position: -200% 0; } }
  .btn, .icon-btn { transition: background-color .15s, border-color .15s, color .15s; }
  .modal { animation: pop .18s ease-out; }
  @keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
}

/* Barre latérale encre, commune à la messagerie et à l'admin */
.side { background: var(--ink); color: var(--ink-fg); display: flex; flex-direction: column; gap: 22px; padding: 20px 14px; min-width: 0; }
.side .brand { padding-inline: 6px; color: #FFFFFF; }
.nav { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 10px; text-align: left; color: var(--ink-muted); font-weight: 500; text-decoration: none; }
.nav-item svg { flex: none; }
.nav-item:hover { background: var(--ink-2); color: var(--ink-fg); }
.nav-item[aria-current="true"], .nav-item[aria-selected="true"] { background: var(--ink-2); color: #FFFFFF; font-weight: 600; box-shadow: inset 3px 0 0 #A9BDFF; }
.nav-item .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px; background: #A9BDFF; color: var(--ink); font-size: 11px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.nav-item .count.muted { background: var(--ink-2); color: var(--ink-muted); }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); padding: 0 12px; margin-bottom: 6px; opacity: .8; }
.side .icon-btn { color: var(--ink-muted); }
.side .icon-btn:hover { background: var(--ink-2); color: #FFFFFF; }
