/* ==========================================================================
   Base & structure de l'application
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-ui);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--encre);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 500; }
h1 { font-family: var(--f-titre); font-size: var(--t-xl); line-height: 1.15; letter-spacing: -.01em; }
h2 { font-family: var(--f-titre); font-size: var(--t-lg); line-height: 1.2; }
h3 { font-size: var(--t-md); font-weight: 500; }
p  { margin: 0 0 var(--s-3); max-width: 72ch; }
a  { color: inherit; text-decoration-color: var(--trait-fort); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--rouge); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-champ); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --- Shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--encre); color: #D8DAE0;
  padding: var(--s-5) 0;
}
.brand { display: block; padding: 0 var(--s-5) var(--s-5); text-decoration: none; color: var(--blanc); }
.brand__sigle {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-ui); font-weight: 500; font-size: 34px; letter-spacing: .06em; line-height: 1;
}
.brand__sigle svg { width: 18px; height: 18px; color: var(--rouge); margin-top: 2px; }
.brand__rule { height: 2px; background: var(--rouge); margin: 10px 0 7px; }
.brand__conseil { font-weight: 300; font-size: 12px; letter-spacing: .62em; color: #BFC2C9; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s-2) var(--s-3); flex: 1; overflow-y: auto; }
.nav__group { margin-top: var(--s-4); padding: 0 var(--s-3) var(--s-1); font-size: var(--t-xs); color: #7D818A; }
.nav a {
  position: relative; display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3) 9px 34px; border-radius: var(--r-champ);
  color: #C4C7CE; text-decoration: none; font-size: var(--t-base);
}
.nav a:hover { color: var(--blanc); background: var(--encre-2); }
.nav a[aria-current="page"] { color: var(--blanc); background: var(--encre-3); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 12px; height: 12px; transform: translateY(-50%);
  background: var(--rouge);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}
.nav .count { margin-left: auto; font-size: var(--t-xs); color: var(--blanc); background: var(--rouge); border-radius: var(--r-pill); padding: 0 7px; line-height: 18px; }

.sidebar__foot { padding: var(--s-4) var(--s-5) 0; border-top: 1px solid var(--encre-3); font-size: var(--t-sm); }
.sidebar__user { color: var(--blanc); }
.sidebar__role { color: #8E929B; font-size: var(--t-xs); }
.sidebar__actions { display: flex; gap: var(--s-3); margin-top: var(--s-3); }
.sidebar__actions a, .sidebar__actions button {
  color: #B9BCC4; background: none; border: 0; padding: 0; font: inherit; font-size: var(--t-sm); cursor: pointer; text-decoration: none;
}
.sidebar__actions a:hover, .sidebar__actions button:hover { color: var(--blanc); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  padding: var(--s-3) var(--s-6); background: var(--blanc); border-bottom: 1px solid var(--trait);
  font-size: var(--t-sm); color: var(--ardoise);
}
.topbar__mandat strong { color: var(--encre); font-weight: 500; }
.topbar__spacer { flex: 1; }
.topbar select { min-width: 220px; }
.menu-toggle { display: none; }

.view { padding: var(--s-6); max-width: 1480px; width: 100%; }

/* --- En-tête de page ------------------------------------------------------ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head__titre h1 { padding-bottom: 10px; position: relative; }
.page-head__titre h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 56px; height: 2px; background: var(--rouge); }
.page-head__sub { margin-top: var(--s-2); color: var(--ardoise); font-size: var(--t-sm); }
.page-head__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.back-link { display: inline-block; margin-bottom: var(--s-3); font-size: var(--t-sm); color: var(--ardoise); text-decoration: none; }
.back-link:hover { color: var(--encre); }

.readonly-banner {
  display: flex; gap: var(--s-2); align-items: center;
  padding: var(--s-2) var(--s-6); background: var(--ambre-voile); color: var(--ambre); font-size: var(--t-sm);
  border-bottom: 1px solid #EFDFC0;
}

/* --- Grilles ------------------------------------------------------------ */
.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--main-side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack > * + * { margin-top: var(--s-5); }

@media (max-width: 1100px) {
  .grid--main-side, .grid--2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s ease; }
  .shell.nav-open .sidebar { transform: none; }
  .menu-toggle { display: inline-flex; }
  .view { padding: var(--s-4); }
  .topbar { padding: var(--s-3) var(--s-4); }
  h1 { font-size: var(--t-lg); }
}
.topbar .menu-toggle { display: none; }
@media (max-width: 860px) { .topbar .menu-toggle { display: inline-flex; } }
