/* Habillage legacy : coque DIMO (spec §2.2) — barre haute 59 px, menu latéral 200 px repliable,
   onglets MDI des fiches ouvertes, zone de contenu. Jetons : tokens.css. Aucun style en ligne (CSP). */
html, body.lg { height: 100%; }
body.lg { display: flex; flex-direction: column; }
.lg-skip { position: absolute; left: var(--space-2); top: -40px; z-index: 200; padding: 6px 10px; background: #ffffff; color: var(--text); border-radius: var(--radius); }
.lg-skip:focus { top: var(--space-2); }

/* Barre haute */
.lg-topbar { display: flex; flex: none; align-items: center; gap: var(--space-2); height: var(--topbar-h); padding: 0 var(--space-3); background: var(--topbar); color: var(--sidebar-text); }
.lg-topbar__brand { color: var(--sidebar-text); font-size: 18px; font-weight: 600; letter-spacing: .02em; text-decoration: none; }
.lg .lg-topbar__brand { color: var(--sidebar-text); }
.lg-topbar__spacer { flex: 1; }
.lg-topbar__user { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-transform: uppercase; }
.lg-topbar form { margin: 0; }
.lg-topbar__btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius); background: transparent; color: var(--sidebar-text); font-size: 16px; cursor: pointer; }
.lg-topbar__btn:hover { background: rgba(255, 255, 255, .12); }
/* Menu utilisateur (#152) : <details> natif (clavier sans JS), habillage et mot de passe. */
.lg-usermenu { position: relative; }
.lg-usermenu__toggle { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 var(--space-2); border-radius: var(--radius); list-style: none; cursor: pointer; }
.lg-usermenu__toggle::-webkit-details-marker { display: none; }
.lg-usermenu__toggle:hover { background: rgba(255, 255, 255, .12); }
.lg-usermenu__toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.lg-usermenu__panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 120; display: flex; flex-direction: column; min-width: 220px; padding: var(--space-2); background: var(--bg-panel); color: var(--text); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0, 0, 0, .2); }
.lg-usermenu__title { margin: 0 0 4px; color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.lg-usermenu__item { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: 6px var(--space-2); border: 0; border-radius: var(--radius); background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.lg-usermenu__item:hover { background: var(--row-hover); }
.lg-usermenu__item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.lg-usermenu__item[aria-pressed="true"] { font-weight: 700; }
.lg-usermenu__panel form + .lg-usermenu__item { margin-top: 4px; border-top: 1px solid var(--panel-border); }
.lg-langs { display: inline-flex; gap: 2px; }
.lg-lang { height: 24px; min-width: 32px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--sidebar-text); font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }
.lg-lang[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Corps : menu + espace de travail */
.lg-app { display: flex; flex: 1; min-height: 0; }
.lg-sidebar { flex: none; width: var(--sidebar-w); overflow-y: auto; background: var(--sidebar); color: var(--sidebar-text); transition: width .15s; }
.lg-workspace { display: flex; flex: 1; flex-direction: column; min-width: 0; overflow: auto; }

/* Menu latéral : 1er niveau avec icône, sous-menus en <details> */
.lg-menu { margin: 0; padding: var(--space-1) 0; list-style: none; }
.lg-menu--sub { padding: 0 0 var(--space-1); }
.lg-menu--sub .lg-menu__link { padding-left: 34px; font-size: 12px; }
.lg-menu--sub .lg-menu--sub .lg-menu__link { padding-left: 46px; }
.lg-menu__link { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: 8px var(--space-3); color: var(--sidebar-text); text-decoration: none; cursor: pointer; list-style: none; }
.lg .lg-menu__link { color: var(--sidebar-text); }
.lg-menu__link::-webkit-details-marker { display: none; }
.lg-menu__link:hover { background: rgba(255, 255, 255, .08); }
.lg .lg-menu__link[aria-current="page"] { background: var(--bg-app); color: var(--text); font-weight: 600; }
.lg-menu__link--soon .lg-menu__label { opacity: .75; }
.lg-menu__icon { flex: none; width: 18px; text-align: center; }
.lg-menu__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-menu__chevron { flex: none; font-size: 10px; transition: transform .15s; }
.lg-menu__group:not([open]) > .lg-menu__link .lg-menu__chevron { transform: rotate(-90deg); }

/* Menu replié : icônes seules */
.lg--collapsed .lg-sidebar { width: 48px; }
.lg--collapsed .lg-menu__label, .lg--collapsed .lg-menu__chevron, .lg--collapsed .lg-menu--sub { display: none; }
.lg--collapsed .lg-menu__link { justify-content: center; padding: 10px 0; }

/* Onglets MDI */
.lg-mdi { display: flex; flex: none; flex-wrap: wrap; align-items: flex-end; gap: var(--space-1); padding: var(--space-2) var(--space-3) 0; background: var(--bg-app); border-bottom: 1px solid var(--panel-border); }
.lg-mdi__tabs { display: flex; flex: 1; gap: 2px; min-width: 0; overflow-x: auto; }
.lg-mdi__tab { display: flex; flex: none; align-items: center; max-width: 220px; background: #ffffff; border: 1px solid var(--panel-border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.lg-mdi__tab.is-active { background: var(--accent); border-color: var(--accent); }
.lg-mdi__tab.is-active .lg-mdi__select, .lg-mdi__tab.is-active .lg-mdi__close { color: #ffffff; font-weight: 600; }
.lg-mdi__tab.is-dirty { border-color: var(--tab-dirty); box-shadow: inset 0 3px 0 var(--tab-dirty); }
.lg-mdi__select { display: flex; align-items: center; gap: 6px; min-width: 0; height: 30px; padding: 0 8px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.lg-mdi__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-mdi__form { display: flex; margin: 0; }
.lg-mdi__close, .lg-mdi__closeall { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: var(--radius); background: none; color: var(--text-muted); cursor: pointer; }
.lg-mdi__close:hover, .lg-mdi__closeall:hover { color: var(--danger); }
.lg-mdi__closeall { margin-bottom: 3px; border: 1px solid var(--panel-border); background: #ffffff; }
.lg-mdi__count { margin-bottom: 7px; color: var(--text-muted); font-size: 11px; }
.lg-mdi__alert { flex-basis: 100%; margin: var(--space-1) 0 var(--space-2); padding: 6px 10px; background: #ffffff; border: 1px solid var(--panel-border); border-left: 6px solid var(--tone-warning); border-radius: var(--radius); }

/* Panneaux des onglets (un <section> par fiche, conservé dans le DOM) */
.lg-mdi-panels { flex: 1; }
.lg-mdi-panel { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); }
.lg-mdi-panel[hidden] { display: none; }
.lg-mdi-panel[aria-busy="true"]::before { content: attr(data-loading); color: var(--text-muted); font-style: italic; }
.lg-mdi-panel__error { padding: 6px 10px; background: #ffffff; border-left: 6px solid var(--danger); }

/* Fil d'Ariane des écrans à venir */
.ui-trail { margin: 0; color: var(--text-muted); }

/* Page sans coque (utilisateur anonyme : connexion, accès d'urgence) */
.lg-bare { flex: 1; overflow: auto; }

@media (max-width: 720px) {
  .lg-topbar__user, .lg-mdi__count { display: none; }
}

/* Zone des fragments d'erreur HTMX (#21) : au-dessus des toasts, vide = invisible. */
.lg-htmx-errors { position: fixed; right: var(--space-4); top: var(--space-4); z-index: 101; max-width: 420px; }
.lg-htmx-errors:empty { display: none; }
