/* AppHeader, AccountMenu, SettingsNav — C01 / C16 (direction A).
   Header blanc 70 px (64 px ≤ 1279, 56 px ≤ 860), marque à gauche,
   navigation à pictogrammes, actif souligné 2 px, pas de sidebar. */

.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 40px;
  height: var(--header-height); padding: 0 var(--space-8);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-size: 24px; font-weight: 700; letter-spacing: -.6px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand > span { color: var(--accent); }
.brand:hover { color: var(--text); }
.app-nav { flex: 1; align-self: stretch; display: flex; min-width: 0; }
.menu-toggle { display: none; }
.main-nav { display: flex; align-items: stretch; gap: var(--space-6); height: 100%; }
.main-nav > a {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 4px;
  border-bottom: 2px solid transparent; color: var(--text-muted); text-decoration: none;
  font-size: var(--text-sm); font-weight: 600; white-space: nowrap;
  transition: color var(--fast), border-color var(--fast);
}
.main-nav > a:hover { color: var(--text); }
.main-nav > a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.counter {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--selection); color: var(--accent); font-size: 12px; font-weight: 700;
}
.nav-end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.account .popover-trigger { max-width: 240px; }
.account .popover-trigger > span:not(.count):not(.chevron) { overflow: hidden; text-overflow: ellipsis; }
.account-section { display: grid; gap: var(--space-2); }
.account-links { display: grid; margin: 0 calc(-1 * var(--space-2)); }
.account-links > a, .account-links > button {
  display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-small); background: none;
  color: var(--text); font-size: var(--text-sm); text-decoration: none; text-align: left;
}
.account-links > a:hover, .account-links > button:hover { background: var(--surface-2); }
.account-links kbd { margin-left: auto; }

/* La barre est plus large que la page de la largeur de ses deux marges : son
   texte s'aligne ainsi sur le contenu des pages `.page-settings`. */
.settings-nav {
  display: flex; gap: var(--space-6); overflow-x: auto; scrollbar-width: none;
  max-width: calc(var(--settings-width) + 2 * var(--space-8)); margin: var(--space-6) auto 0; padding: 0 var(--space-8);
  background: linear-gradient(var(--border), var(--border)) left bottom / 100% 1px no-repeat content-box;
}
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav a { flex: none; padding: 12px 0; white-space: nowrap; border-bottom: 2px solid transparent; color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 600; }
.settings-nav a:hover { color: var(--text); }
.settings-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

@media (max-width: 1279px) { .app-header { gap: var(--space-6); padding: 0 var(--space-6); } }
@media (max-width: 860px) {
  .app-header { gap: var(--space-3); padding: 0 var(--space-4); }
  .brand { font-size: 20px; }
  .app-nav { flex: 0 0 auto; align-self: center; order: -1; }
  .menu-toggle { display: inline-grid; }
  .main-nav {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 41;
    display: none; flex-direction: column; gap: 4px; height: auto; max-height: calc(100dvh - var(--header-height)); overflow-y: auto;
    padding: var(--space-4); background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-overlay);
  }
  .main-nav.open { display: flex; }
  .main-nav > a { min-height: 44px; padding: 0 var(--space-2); border-bottom: 0; border-left: 2px solid transparent; }
  .main-nav > a[aria-current="page"] { border-left-color: var(--accent); background: var(--selection); }
  .account .popover-trigger > span:not(.count):not(.chevron) { display: none; }
  .popover.account { position: static; }
  .account .popover-panel { position: absolute; top: calc(100% + 1px); left: var(--space-4); right: var(--space-4); margin: 0; max-width: none; box-shadow: var(--shadow-overlay); }
}

/* Pages centrées : connexion, TOTP, 404, hors ligne (C24). */
.app-main { padding: var(--space-8); }
.page { max-width: 1216px; margin: 0 auto; display: grid; gap: var(--space-6); }
.page-settings { max-width: var(--settings-width); }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-6); }
.page-header-text { display: grid; gap: var(--space-1); min-width: 0; flex: 1 1 24rem; }
.page-lead { max-width: 70ch; color: var(--text-muted); }
.page-header-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Ligne de titre d'une carte ou d'un panneau : titre, compteur, actions. */
.section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.section-header-text { display: grid; gap: var(--space-1); min-width: 0; flex: 1 1 16rem; }
.section-header h2, .section-header h3, .section-header h4 { display: flex; align-items: center; gap: var(--space-2); }
.section-header h3 { font-size: var(--text-body); font-weight: 600; }
.section-header-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.section-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--surface-2); color: var(--text-muted); font-size: var(--text-xs); font-weight: 700;
}
/* Barre d'outils de page : sélecteurs et filtres à cocher sur une rangée qui se replie. */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.toolbar > .field:not(.field-check) { min-width: 12rem; }
.toolbar-check {
  position: relative; display: flex; align-items: center; min-height: var(--control-height); padding: 0 var(--space-3);
  border: 1px solid var(--control-border); border-radius: var(--radius-small); background: var(--surface);
  transition: border-color var(--fast), background var(--fast);
}
.toolbar-count { margin-left: auto; align-self: flex-end; line-height: var(--control-height); color: var(--text-muted); font-size: var(--text-sm); }
.toolbar-check .field-check { min-height: 0; align-items: center; }
.toolbar-check .field-check input { margin: 0; }
.toolbar-check .field-check > label::after { content: ""; position: absolute; inset: 0; }
.toolbar-check .field-check > input { position: relative; z-index: 1; }
.toolbar-check:hover:not(:has(input:disabled)) { border-color: var(--text-muted); }
.toolbar-check:has(input:checked) { border-color: var(--accent); background: var(--selection); }
.toolbar-check:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 860px) {
  .toolbar > .field:not(.field-check) { flex: 1 1 100%; min-width: 0; }
  .toolbar > .toolbar-count { flex-basis: 100%; margin-left: 0; line-height: inherit; }
}

.centered-page { display: grid; place-items: center; min-height: 100dvh; padding: var(--space-4); background: var(--bg); }
.login-card { display: grid; gap: var(--space-4); width: min(420px, 100%); padding: var(--space-8); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.login-card .brand { font-size: 24px; }
.login-card h1 { font-size: 24px; line-height: 32px; }
.login-card .form > .button { justify-self: stretch; }
.form-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); }
@media (max-width: 860px) {
  .app-main { padding: var(--space-4); }
  .login-card { padding: var(--space-6); }
  .page-header h1 { font-size: 24px; line-height: 32px; }
  .settings-nav { margin-top: var(--space-3); padding: 0 var(--space-4); }
}
