/* Hestia — reset, layout et composants de base. Voir docs/DESIGN.md.
   Aucune couleur en dur : uniquement var(--…) définies dans tokens.css. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/fonts/Inter-Variable.woff2") format("woff2");
}

/* ---------- Reset léger ---------- */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button, input, select {
  font: inherit;
  color: inherit;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

h1, h2, h3, p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

[x-cloak] {
  display: none !important;
}

/* ---------- Layout ---------- */

:root {
  --sidebar-w: 64px;
  --sidebar-w-expanded: 224px;
  --topbar-h: 56px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

:root[data-sidebar="expanded"] .sidebar {
  width: var(--sidebar-w-expanded);
}

.sidebar-header {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-quick-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
}

/* Menu déroulant unifié de l'en-tête de sidebar : famille (switcher
   placeholder multi-famille v2) + profil + thème + déconnexion — remplace
   l'ancien family-switcher (en-tête) et le menu avatar (pied de sidebar,
   supprimé). Le contenu du dropdown réutilise .avatar-menu (composant
   « Menu contextuel » générique, DESIGN.md §5) via une seconde classe.
   Toujours affiché (y compris sidebar réduite, où seule l'icône avatar du
   bouton reste visible) : plus de display:none conditionné à
   data-sidebar="expanded" ici, c'est .sidebar-menu-text ci-dessous qui
   porte cette condition. */
.sidebar-menu {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

.sidebar-menu-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  cursor: pointer;
  min-width: 0;
}

.sidebar-menu-button:hover {
  background: var(--surface-alt);
}

/* Icône carrée à coins arrondis portant l'initiale de la famille — reprend
   l'icône de réduction/agrandissement qu'elle remplace dans l'en-tête de
   sidebar (ce contrôle vit désormais dans .section-topbar-start). Reste
   neutre (gris), comme les icônes d'outils (DESIGN.md §1) plutôt que
   colorée en --primary : ce n'est pas une action. */
.sidebar-menu-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.sidebar-menu-text {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  overflow: hidden;
}

:root[data-sidebar="expanded"] .sidebar-menu-text {
  display: flex;
}

/* Icône « chevrons haut/bas » (sélecteur), alignée tout à droite du bouton
   grâce à .sidebar-menu-text en flex:1 juste au-dessus qui absorbe l'espace
   restant. Masquée en sidebar réduite comme .sidebar-menu-text : seule
   l'icône avatar reste visible. */
.sidebar-menu-chevron {
  display: none;
  flex-shrink: 0;
  color: var(--text-muted);
}

:root[data-sidebar="expanded"] .sidebar-menu-chevron {
  display: block;
}

.sidebar-menu-name {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-menu-profile {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spécificité .avatar-menu.sidebar-menu-dropdown (2 classes) : l'emporte sur
   .avatar-menu (positionnement par défaut du composant générique, plus loin
   dans la feuille) sans dépendre de l'ordre des règles. Pas de
   max-height/overflow-y ici : le sous-menu Thème est un flyout positionné
   à droite (.sidebar-menu-theme-options, left: 100%) et un overflow sur ce
   conteneur le découperait (CSS Overflow §3 : overflow-y non-visible force
   overflow-x à auto, impossible de garder un seul axe visible). Le contenu
   du menu reste de toute façon court (familles + profil/thème/déconnexion),
   pas besoin de scroll interne. */
.avatar-menu.sidebar-menu-dropdown {
  left: 0;
  right: auto;
  top: calc(100% + 6px);
  min-width: 220px;
}

/* Décale les items rattachés à une section du menu (familles listées sous
   « Famille », Profil/Thème sous le nom du membre connecté) sans indenter
   les titres de section (.avatar-menu-name) eux-mêmes. */
.avatar-menu-indent {
  padding-left: 12px;
}

.sidebar-menu-family-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.sidebar-menu-placeholder {
  color: var(--text-muted);
  cursor: not-allowed;
}

.sidebar-menu-placeholder:hover {
  background: none !important;
}

.sidebar-menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}

/* Sous-menu Thème : flyout ancré à droite de son item plutôt qu'empilé en
   dessous (position:relative sur le <li> parent, le sous-menu se positionne
   par rapport à lui). */
.sidebar-menu-theme {
  position: relative;
}

/* Sélecteur .avatar-menu .sidebar-menu-theme > button (2 classes) plutôt que
   .sidebar-menu-theme > button seul : à spécificité égale avec
   .avatar-menu button (display:block, plus bas dans ce fichier), c'est ce
   dernier qui l'emportait par ordre de règles et cassait la mise en ligne
   du chevron (repoussé sous "Thème" au lieu d'aligné à droite). */
.avatar-menu .sidebar-menu-theme > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.sidebar-menu-theme-options {
  position: absolute;
  left: calc(100% + 6px);
  top: 0;
  min-width: 180px;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  z-index: 61;
}

.sidebar-menu-theme-options li {
  padding: 0;
}

/* .avatar-menu .sidebar-menu-theme-options button (2 classes), même raison
   que .avatar-menu .sidebar-menu-theme > button ci-dessus : sans le préfixe
   .avatar-menu, .avatar-menu button (display:block, plus bas) l'emportait
   par ordre de règles et empilait le libellé et la coche au lieu de les
   aligner sur une ligne. */
.avatar-menu .sidebar-menu-theme-options button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.sidebar-menu-theme-options button:hover {
  background: var(--surface-alt);
}

/* Déclencheur unique de la palette de commandes (Ctrl+K), remplace les
   anciens boutons Créer + Recherche (DESIGN.md §4/§6). */
.btn.sidebar-search-trigger {
  width: 100%;
  padding: 0;
  justify-content: center;
  color: var(--text-muted);
  border-color: var(--border-strong);
}

.btn.sidebar-search-trigger:hover {
  color: var(--text);
  background: var(--surface-alt);
}

:root[data-sidebar="expanded"] .btn.sidebar-search-trigger {
  padding: 0 10px;
  justify-content: flex-start;
}

.sidebar-search-label,
.sidebar-search-kbd {
  display: none;
}

:root[data-sidebar="expanded"] .sidebar-search-label {
  display: inline;
  flex: 1;
  text-align: left;
}

:root[data-sidebar="expanded"] .sidebar-search-kbd {
  display: inline-flex;
}

.sidebar-search-kbd {
  align-items: center;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
}

.rail-item {
  position: relative;
  height: 40px;
  width: 44px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
}

:root[data-sidebar="expanded"] .rail-item {
  width: 100%;
  margin: 0;
}

.rail-item svg {
  flex-shrink: 0;
}

.rail-item:hover {
  background: var(--surface-alt);
}

.rail-item.is-active {
  background: var(--surface-alt);
  color: var(--primary);
}

.rail-item-label {
  display: none;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-sidebar="expanded"] .rail-item-label {
  display: inline;
}

.rail-item .tooltip {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--topbar-bg);
  color: var(--text-invert);
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s ease;
  z-index: 50;
}

.rail-item:hover .tooltip {
  opacity: 1;
}

:root[data-sidebar="expanded"] .rail-item .tooltip {
  display: none;
}

/* Badge de notification (nombre d'échéances à traiter, app.routers.notifications) :
   pastille pleine en sidebar repliée (icône seule, chiffre masqué), pilule
   avec chiffre alignée à droite du libellé en sidebar étendue. */
.rail-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 8px;
  height: 8px;
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
  background: var(--danger-fg);
  color: var(--danger-fg);
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
}

/* :not([hidden]) : un badge à 0 (hidden) ne doit jamais recevoir ce
   display:inline-flex, sans quoi il l'emporterait sur le display:none par
   défaut du navigateur pour [hidden] (spécificité plus faible). */
:root[data-sidebar="expanded"] .rail-item .rail-badge:not([hidden]) {
  position: static;
  order: 3;
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  text-indent: 0;
  overflow: visible;
  color: var(--text-invert);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 35;
}

:root[data-sidebar="expanded"] .section-topbar {
  left: var(--sidebar-w-expanded);
}

/* Regroupe le toggle sidebar et le titre pour que justify-content:
   space-between (sur .section-topbar) ne s'applique qu'entre ce groupe et
   .section-actions, pas entre les trois éléments individuellement. */
.section-topbar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.section-title {
  font-size: 24px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.content {
  margin-top: var(--topbar-h);
  margin-left: var(--sidebar-w);
  padding: 24px;
}

:root[data-sidebar="expanded"] .content {
  margin-left: var(--sidebar-w-expanded);
}

.content-inner {
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .sidebar.is-open {
    display: flex;
    width: var(--sidebar-w-expanded);
    bottom: 0;
    box-shadow: var(--shadow-overlay);
  }

  .sidebar.is-open .rail-item-label,
  .sidebar.is-open .sidebar-search-label,
  .sidebar.is-open .sidebar-search-kbd {
    display: inline-flex;
  }

  .sidebar.is-open .sidebar-menu-text {
    display: flex;
  }

  .sidebar.is-open .sidebar-menu-chevron {
    display: block;
  }

  .sidebar.is-open .btn.sidebar-search-trigger {
    padding: 0 10px;
    justify-content: flex-start;
  }

  .sidebar.is-open .rail-item {
    width: 100%;
    margin: 0;
  }

  .sidebar.is-open .rail-item .rail-badge:not([hidden]) {
    position: static;
    order: 3;
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    text-indent: 0;
    overflow: visible;
    color: var(--text-invert);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .section-topbar {
    left: 0;
  }

  .content {
    margin-left: 0;
  }
}

.avatar-menu {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: 6px;
  z-index: 60;
}

.avatar-menu a,
.avatar-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.avatar-menu a:hover,
.avatar-menu button:hover {
  background: var(--surface-alt);
}

.avatar-menu .is-danger {
  color: var(--danger-fg);
}

/* ---------- Composants ---------- */

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}

/* Onglets (menu réglages, Phase 16) — navigation simple par liens, chaque
   onglet est une page complète (pas de fragment HTMX) : cohérent avec le
   reste du menu réglages (Phase 15), pas de duplication de state côté client. */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-link {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.tab-link:hover {
  color: var(--text);
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.kpi-delta {
  margin-top: 4px;
  font-size: 12.5px;
}

.kpi-delta.is-up {
  color: var(--ok-fg);
}

.kpi-delta.is-down {
  color: var(--danger-fg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-invert);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--surface-alt);
}

.btn-danger {
  background: var(--danger-fg);
  color: var(--text-invert);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-icon {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-icon .tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--topbar-bg);
  color: var(--text-invert);
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s ease;
}

.btn-icon:hover .tooltip {
  opacity: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-ok      { background: var(--ok-bg);      color: var(--ok-fg); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn-fg); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.badge-info    { background: var(--info-bg);    color: var(--info-fg); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Saisie multi-étiquettes (Phase 20, shared/_tag_input_field.html) : puces +
   champ libre partageant un même cadre façon .input, suggestions en
   dropdown façon .avatar-menu juste en dessous. */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tag-input-field {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--text);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 6px 0 10px;
  border-radius: var(--radius-pill);
  background: var(--info-bg);
  color: var(--info-fg);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.tag-chip-remove:hover {
  background: rgb(0 0 0 / .1);
}

.tag-suggestions {
  position: relative;
}

.tag-suggestions-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: 6px;
  margin: 0;
  list-style: none;
  z-index: 60;
}

.tag-suggestions-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.tag-suggestions-list button:hover {
  background: var(--surface-hover);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-heading {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.detail-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  padding-left: 12px;
}

.detail-field-label {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.detail-subheading {
  font-weight: 700;
}

.field label {
  font-size: 12.5px;
  font-weight: 500;
}

.field .hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

.input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.input:focus-visible {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}

textarea.input {
  height: auto;
  padding: 8px 10px;
  font-family: inherit;
  resize: vertical;
}

.required-marker {
  color: var(--danger-fg);
  margin-left: 2px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Auth (login / setup) ---------- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  background: var(--bg);
}

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
  width: 100%;
}

.auth-logo {
  height: 80px;
  width: auto;
}

.auth-logo-dark {
  display: none;
}

[data-theme="dark"] .auth-logo-light {
  display: none;
}

[data-theme="dark"] .auth-logo-dark {
  display: block;
}

/* Fragment HTMX cible (login.html, login_2fa.html) : flex item de
   .auth-screen sans largeur propre, donc "auto" (shrink-to-fit) sous
   align-items: center — la .auth-card enfant en width: 100% hériterait
   d'un conteneur indéfini et resterait elle aussi réduite au contenu.
   width: 100% ici rétablit un conteneur de taille définie pour que
   max-width sur .auth-card/.auth-card-login fasse effectivement foi. */
#login-card {
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.auth-card-wide {
  max-width: 440px;
}

/* Bloc de connexion (login), légèrement plus large que la .auth-card
   standard (360px -> 512px). Champs et bouton en héritent via width: 100%
   (.field est en flex-column, stretch par défaut). Scopé à cette seule
   carte, pas à .auth-card en général (setup, welcome, 2FA, oauth_refused
   restent à 360/440px). */
.auth-card-login {
  max-width: 512px;
}

.auth-card-login .auth-submit svg {
  flex-shrink: 0;
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

.auth-error {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 12.5px;
  list-style: none;
}

.auth-submit {
  width: 100%;
  margin-top: 8px;
}

.auth-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 16px 0;
}

.auth-separator::before,
.auth-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Tables ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.table thead th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  padding: 8px 12px;
}

/* Liens de tri d'en-tête (DESIGN.md, § Tables) : pas de soulignement par
   défaut du navigateur — seuls la couleur héritée et le curseur signalent
   l'interactivité, comme les autres contrôles bouton/menu de l'app. */
.table thead th a {
  color: inherit;
  text-decoration: none;
}

.table tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  height: 44px;
}

/* Pas de surlignage au survol des lignes des tableaux principaux
   (DESIGN.md, § Tables) : le curseur pointeur suffit à signaler les lignes
   cliquables (.table-row), sans changement de fond qui alourdit la liste.
   Exception : Contrats, Biens, Papiers, Favoris, Rendez-vous et Santé,
   tables migrées vers le nouveau patron recherche + filtres par colonne +
   pagination (voir plus bas) — le survol y est activé. Scopé par table
   (pas un .table-row global) pour ne pas changer les autres tables
   principales, qui partagent la même classe .table-row et n'ont pas
   encore ce patron. */
#contract-table .table-row:hover,
#asset-table .table-row:hover,
#document-table .table-row:hover,
#bookmark-table .table-row:hover,
#appointment-table .table-row:hover,
#health-record-table .table-row:hover {
  background: var(--surface-hover);
}

/* Table nichée dans un sous-bloc (.item-card, ex. bloc Documents) : le
   fond d'en-tête --surface-alt s'y confondrait avec le sous-bloc lui-même
   (déjà --surface-alt) — en-tête aligné sur la teinte de hover des lignes
   (--surface-hover, réellement différente du fond ambiant du sous-bloc).
   Contrairement aux tableaux principaux, cette table nichée garde son
   survol de ligne : la liste y est plus dense et sert de navigateur de
   fichiers, où le repère visuel de la ligne survolée reste utile. */
.item-card .table thead th {
  background: var(--surface-hover);
}

.item-card .table tbody tr:hover {
  background: var(--surface-hover);
}

.item-card .table tbody td a {
  text-decoration: none;
}

.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.row-menu {
  position: relative;
  display: inline-block;
}

.row-menu-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-card-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.item-card-header.has-label {
  justify-content: space-between;
}

.avatar-menu-name {
  padding: 8px 10px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* ---------- Barre d'outils de table : recherche globale, filtres par
   colonne, pagination (DESIGN.md, § Tables — Contrats, premier tableau
   principal à utiliser ce patron) ---------- */

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.table-toolbar-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
}

.table-search {
  position: relative;
  min-width: 260px;
  flex: 1 1 260px;
  max-width: 360px;
}

.table-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.table-search .input {
  width: 100%;
  padding-left: 34px;
}

.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12.5px;
  font-weight: 500;
}

.filter-chip a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: inherit;
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
}

.filter-chip a:hover {
  background: rgb(0 0 0 / .08);
}

.filter-chips-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  text-decoration: underline;
}

.filter-chips-clear:hover {
  color: var(--text);
}

.th-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.th-flex-end {
  justify-content: flex-end;
}

.table thead th {
  position: relative;
}

.col-filter {
  position: relative;
}

.col-filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.col-filter-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.col-filter-toggle.is-active {
  color: var(--primary);
}

.column-filter-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: 12px;
  z-index: 65;
  font-weight: 400;
  text-transform: none;
  color: var(--text);
}

.column-filter-popover.is-right {
  left: auto;
  right: 0;
}

.column-filter-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.column-filter-label + .column-filter-label {
  margin-top: 10px;
}

.column-filter-popover .input {
  width: 100%;
  margin-bottom: 8px;
}

.column-filter-range {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.column-filter-range .input {
  margin-bottom: 0;
}

.column-filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.column-filter-preset {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12.5px;
  text-decoration: none;
}

.column-filter-preset:hover {
  background: var(--surface-alt);
}

.column-filter-preset.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--ok-bg);
}

.column-filter-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.column-filter-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.column-filter-check:hover {
  background: var(--surface-alt);
}

.column-filter-check input {
  accent-color: var(--primary);
}

.column-filter-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.pagination-size select.input {
  height: 30px;
  padding: 0 8px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

a.pagination-page:hover {
  background: var(--surface-alt);
}

.pagination-page.is-active {
  background: var(--primary);
  color: var(--text-invert);
}

span.pagination-page[aria-disabled] {
  color: var(--text-muted);
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  color: var(--text-muted);
}

/* ---------- Drawer ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .35);
  z-index: 70;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(400px, 40vw, 720px);
  max-width: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  z-index: 80;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Documents kDrive (Phase 19, remplace les pièces jointes) ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.breadcrumb a {
  color: var(--text-muted);
}

.kdrive-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.kdrive-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
}

.kdrive-row:last-child {
  border-bottom: none;
}

.kdrive-row:hover {
  background: var(--surface-alt);
}

.kdrive-row-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 6px;
  color: var(--text);
  text-decoration: none;
}

.kdrive-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kdrive-row-chevron {
  margin-left: auto;
  color: var(--text-muted);
  flex: none;
}

.kdrive-row .btn-ghost {
  flex: none;
}

.kdrive-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.kdrive-empty-icon {
  font-size: 22px;
}

.kdrive-newfolder .form-row {
  margin: 0;
}

/* ---------- Modal « sélecteur » (parcours d'une arborescence, ex. kDrive)
   — variante plus large que le modal de confirmation/formulaire court
   (docs/DESIGN.md §6) : en-tête et pied fixes, liste au milieu scrollable
   pour ne jamais pousser les actions hors écran. ---------- */

.modal-picker {
  width: 620px;
  max-height: min(600px, calc(100vh - 64px));
  padding: 0;
  display: flex;
  flex-direction: column;
}

.modal-picker-header {
  flex: none;
  padding: 20px 20px 0;
}

.modal-picker-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-picker-title-row h2 {
  margin-bottom: 0;
}

.modal-picker-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 20px;
}

.modal-picker-footer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border);
}

.kdrive-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: kdrive-spin .6s linear infinite;
}

@keyframes kdrive-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .drawer {
    width: 100%;
  }
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .35);
  z-index: 90;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  max-width: calc(100% - 32px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: 20px;
  z-index: 100;
}

.modal h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Palette de commandes (Ctrl+K) ---------- */

.command-palette {
  top: 15%;
  transform: translateX(-50%);
  width: 620px;
  max-width: calc(100% - 32px);
  max-height: min(480px, calc(100vh - 96px));
  padding: 0;
  display: flex;
  flex-direction: column;
}

.command-palette-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.command-palette-search-icon {
  display: flex;
  flex-shrink: 0;
  color: var(--text-muted);
}

.command-palette-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-size: 15px;
  color: var(--text);
}

.command-palette-input::placeholder {
  color: var(--text-muted);
}

.command-palette-close {
  flex-shrink: 0;
}

.command-palette-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.command-palette-group + .command-palette-group {
  margin-top: 8px;
}

.command-palette-group-title {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.command-palette-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.command-palette-item:hover,
.command-palette-item:focus-visible {
  background: var(--surface-alt);
}

.command-palette-item-kind {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: 11px;
  font-weight: 600;
}

.command-palette-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-palette-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.upload-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 16px;
}

.upload-dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--surface-alt);
}

.upload-filelist {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  text-align: left;
}

.upload-file-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 100%;
}

.upload-file-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}

.upload-file-remove:hover {
  color: var(--danger-fg);
}

/* ---------- Wizard (création de bien / contrat) ---------- */

.wizard-steps li {
  cursor: pointer;
}

.wizard-steps li.is-active {
  color: var(--primary);
  font-weight: 600;
}

.wizard-steps li.is-disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---------- Calendrier (Phase 5) ---------- */

.calendar-filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.calendar-filter-checks {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  height: 36px;
}

.calendar-filter-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 14px;
  color: var(--text);
}

.calendar-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

.calendar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calendar-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

#calendar {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-alt);
  --fc-neutral-text-color: var(--text);
  --fc-border-color: var(--border);
}

#calendar .fc-toolbar-title {
  font-size: 18px;
  font-weight: 600;
}

#calendar .fc-button-primary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

#calendar .fc-button-primary:hover {
  background: var(--surface-alt);
}

#calendar .fc-button-primary:not(:disabled).fc-button-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-invert);
}

#calendar .fc-daygrid-day-number,
#calendar .fc-col-header-cell-cushion {
  color: var(--text);
}

#calendar .fc-day-today {
  background: var(--surface-alt);
}

#calendar .fc-event {
  cursor: pointer;
  border-width: 1px;
  font-size: 12.5px;
}

/* ---------- Kanban (Phase 6) ---------- */

.kanban-columns {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  flex: 0 0 280px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-column-add {
  flex: 0 0 200px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  align-items: center;
  justify-content: center;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kanban-column-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.kanban-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kanban-card.sortable-ghost {
  opacity: .4;
}

.kanban-card.sortable-chosen {
  border-color: var(--primary);
}

.kanban-card-title {
  font-size: 13.5px;
  font-weight: 500;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kanban-card-link {
  font-size: 12.5px;
  color: var(--info-fg);
  text-decoration: none;
}

.kanban-card-link:hover {
  text-decoration: underline;
}

.kanban-add-card {
  align-self: flex-start;
}

/* ---------- Budget (Phase 6) ---------- */

.budget-period-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
}

.budget-chart-wrapper {
  position: relative;
  height: 280px;
}

/* ---------- Vacances (Phase 6) ---------- */

.reservation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-step-list li {
  padding: 8px 0;
  cursor: pointer;
}

/* ---------- Kiosque (Phase 7) — écran partagé, thème sombre forcé ---------- */

.kiosk-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.kiosk-header {
  height: 72px;
  flex: none;
  background: var(--topbar-bg);
  color: var(--text-invert);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  font-size: 20px;
  font-weight: 600;
}

.kiosk-content {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.kiosk-agenda-day {
  margin-bottom: 24px;
}

.kiosk-agenda-day-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kiosk-agenda-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 8px;
  font-size: 18px;
}

.kiosk-agenda-item .badge {
  flex: none;
}

.kiosk-empty {
  color: var(--text-muted);
  font-size: 18px;
  padding: 40px 0;
  text-align: center;
}
