/* Coque de l'application : liseré #97d0e3, shell arrondi, barre latérale façon Linear, en-tête collant. */

.app { min-height: 100dvh; }
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; background: #fff; }
.main-col { display: flex; flex-direction: column; min-width: 0; }

@media (min-width: 1024px) {
  body.has-shell { background: var(--background); }
  .app { height: 100dvh; padding: var(--frame); }
  .shell {
    height: calc(100dvh - 2 * var(--frame));
    min-height: 0;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    border-radius: var(--radius);
    overflow: hidden;
    transition: grid-template-columns var(--dur-modal) var(--ease-out);
  }
  html[data-sb="collapsed"] .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .main-col { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
}

/* ---------- Barre latérale ---------- */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
  }
}
.sb-brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-3); min-height: var(--header-h); }
.sb-brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; object-fit: contain; }
.sb-brand .name { display: grid; line-height: 1.2; min-width: 0; }
.sb-brand .name strong { font-weight: 600; letter-spacing: -.01em; }
.sb-brand .name span { color: var(--text-muted); font-size: var(--fs-12); }
.sb-brand .btn { margin-left: auto; }

.sb-nav { flex: 1; overflow-y: auto; padding: var(--sp-2) var(--sp-3) var(--sp-4); display: grid; align-content: start; gap: var(--sp-4); scrollbar-width: thin; }
.sb-group { display: grid; gap: 2px; }
.sb-group__title { padding: 0 var(--sp-2) var(--sp-1); color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sb-link {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 34px; padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--foreground); text-decoration: none; font-weight: 500;
  white-space: nowrap;
}
.sb-link .icon { width: 18px; height: 18px; color: var(--text-muted); }
.sb-link .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-link .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.sb-link .count[data-tone] { background: var(--tint); }
.sb-link[aria-current="page"] { background: var(--accent); }
.sb-link[aria-current="page"] .icon { color: var(--primary); }
@media (hover: hover) and (pointer: fine) { .sb-link:hover { background: var(--accent); } }
@media (pointer: coarse) { .sb-link { min-height: 44px; } }

.sb-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-modal) var(--ease-out); }
.sb-sub > div { overflow: hidden; display: grid; gap: 2px; padding-left: 30px; }
.sb-item.is-open .sb-sub { grid-template-rows: 1fr; }
.sb-sub .sb-link { min-height: 30px; font-weight: 400; color: var(--text-muted); }
.sb-sub .sb-link[aria-current="page"] { color: var(--foreground); font-weight: 500; }
.sb-toggle .chev { transition: transform var(--dur-pop) var(--ease-out); }
.sb-item.is-open .sb-toggle .chev { transform: rotate(90deg); }

.sb-foot { border-top: 1px solid var(--sidebar-border); padding: var(--sp-3); display: grid; gap: var(--sp-2); }
.sb-profile { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; padding: var(--sp-1) var(--sp-1); border-radius: var(--radius-sm); }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--secondary); color: #fff; font-size: var(--fs-12); font-weight: 600; letter-spacing: .02em;
}
.sb-profile .who { display: grid; min-width: 0; line-height: 1.25; }
.sb-profile .who strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-profile .who span { color: var(--text-muted); font-size: var(--fs-12); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-profile .btn { margin-left: auto; }

/* Rail replié */
@media (min-width: 1024px) {
  html[data-sb="collapsed"] .sb-brand { padding-inline: 0; justify-content: center; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-3); }
  html[data-sb="collapsed"] .sb-brand .name,
  html[data-sb="collapsed"] .sb-group__title,
  html[data-sb="collapsed"] .sb-link .label,
  html[data-sb="collapsed"] .sb-link .chev,
  html[data-sb="collapsed"] .sb-sub,
  html[data-sb="collapsed"] .sb-profile .who,
  html[data-sb="collapsed"] .sb-demo-label { display: none; }
  html[data-sb="collapsed"] .sb-brand .btn { margin: 0; }
  html[data-sb="collapsed"] .sb-nav { padding-inline: var(--sp-2); }
  html[data-sb="collapsed"] .sb-link { justify-content: center; padding: 0; position: relative; }
  html[data-sb="collapsed"] .sb-link .count { position: absolute; top: 1px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
  html[data-sb="collapsed"] .sb-profile { flex-direction: column; padding: 0; }
  html[data-sb="collapsed"] .sb-profile .btn { margin: 0; }
}

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--header-h); padding: 0 var(--sp-6);
  background: #fff; border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: inline-flex; }
@media (min-width: 1024px) { .topbar .menu-btn { display: none; } }
@media (max-width: 767px) { .topbar { padding: 0 var(--sp-3); } }
.topbar .mobile-brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 600; text-decoration: none; }
.topbar .mobile-brand img { width: 26px; height: 26px; border-radius: 7px; }
@media (min-width: 1024px) { .topbar .mobile-brand { display: none; } }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-muted); font-size: var(--fs-14); }
.crumbs ol { display: flex; align-items: center; gap: 6px; list-style: none; padding: 0; min-width: 0; }
.crumbs li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--border-strong); }
.crumbs a { text-decoration: none; color: var(--text-muted); white-space: nowrap; }
.crumbs a:hover { color: var(--foreground); }
.crumbs [aria-current="page"] { color: var(--foreground); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1023px) { .crumbs { display: none; } }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.demo-banner { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Contenu ---------- */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--sp-6);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--sp-5);
  --sticky-top: var(--header-h);
}
.content:focus { outline: none; }
@media (max-width: 767px) { .content { padding: var(--sp-4) var(--sp-3) var(--sp-8); gap: var(--sp-4); } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3) var(--sp-4); }
.page-head__title { display: grid; gap: 4px; min-width: 0; flex: 1 1 320px; }
.page-head__title .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-12); }
.page-head__title p { color: var(--text-muted); }
.page-head__title h1 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); overflow-wrap: anywhere; }
.page-head .btn-row { margin-left: auto; }

/* ---------- Tiroir mobile ---------- */
.drawer {
  margin: 0; height: 100dvh; max-height: 100dvh; width: min(300px, 86vw); max-width: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--sidebar);
  transform: none;
  transition: transform var(--dur-modal) var(--ease-drawer), overlay var(--dur-modal) allow-discrete, display var(--dur-modal) allow-discrete;
}
.drawer:not([open]) { transform: translateX(-100%); }
@starting-style { .drawer[open] { transform: translateX(-100%); } }
.drawer::backdrop { transition: opacity var(--dur-modal) var(--ease-out), overlay var(--dur-modal) allow-discrete, display var(--dur-modal) allow-discrete; }
.drawer:not([open])::backdrop { opacity: 0; }
@starting-style { .drawer[open]::backdrop { opacity: 0; } }
.drawer .sidebar { display: flex; flex-direction: column; height: 100%; border: 0; }

/* ---------- Pages d'exception (connexion, 404) ---------- */
body.frame { background: var(--background); min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--sp-6) + 2rem) var(--sp-4); }
body.frame > main { width: 100%; display: grid; place-items: center; }

/* Connexion : carte unique, centrée sur les deux axes ; la mention de pied est hors du flux pour ne pas décaler le centrage. */
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  padding: var(--sp-8) var(--sp-8) var(--sp-6);
  display: grid;
  gap: var(--sp-6);
}
.auth-head { display: grid; justify-items: center; gap: var(--sp-2); text-align: center; }
.auth-head img { width: 44px; height: 44px; border-radius: 11px; margin-bottom: var(--sp-2); }
.auth-head h1 { font-size: var(--fs-24); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.auth-head p { color: var(--text-muted); font-size: var(--fs-14); }
.auth-card form { display: grid; gap: var(--sp-4); }
.auth-card form .btn--block { margin-top: var(--sp-2); }
.auth-card .btn--lg { min-height: 44px; font-size: var(--fs-16); gap: var(--sp-2); }
.auth-card .pw-wrap { position: relative; }
.auth-card .pw-wrap .input { width: 100%; padding-right: 44px; }
.auth-card .pw-wrap .reveal { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); }
.auth-card .foot { display: flex; gap: var(--sp-2); align-items: flex-start; padding-top: var(--sp-4); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-12); line-height: 1.5; }
.auth-card .foot .icon { flex: none; margin-top: 1px; }
.frame-note { position: fixed; left: 0; right: 0; bottom: var(--sp-4); margin: 0; padding: 0 var(--sp-4); color: var(--foreground); font-size: var(--fs-12); text-align: center; }
@media (max-width: 480px) {
  .auth-card { padding: var(--sp-6) var(--sp-5) var(--sp-5); gap: var(--sp-5); }
}
@media (max-height: 560px) { .frame-note { position: static; margin-top: var(--sp-4); } }

.nf { display: grid; justify-items: center; gap: var(--sp-3); text-align: center; background: #fff; border-radius: var(--radius); padding: var(--sp-8); width: min(520px, 100%); }
.nf .code { font-size: 6rem; font-weight: 700; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.nf p { color: var(--text-muted); }

/* Écran de démarrage pendant la vérification de session */
body.is-booting .shell { visibility: hidden; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
body:not(.is-booting) .boot { display: none; }
