/* NutriSaaS — Coque de l'app (passe design 2026-10) : colonne patients, en-tete
   patient + onglets, bouton compte rendu, barre basse mobile, ecran de connexion,
   largeurs et densite des onglets. Charge apres theme.css.
   Paliers :
   - telephone / tablette portrait (<= 640 px, ou <= 1024 px en portrait) :
     onglets du haut caches, barre basse, colonne patients en tiroir plein ecran ;
   - ailleurs : en-tete patient sur UNE ligne de hauteur fixe ; onglets longs, courts
     puis icones selon la place (detail dans la section "En-tete patient"). */

/* Hauteur de l appli = ecran VISIBLE (dvh). Avec 100vh, sur telephone, le bas de la page
   passait sous la barre d adresse et la barre basse, impossible a atteindre. */
body.h-screen { height: 100vh; height: 100dvh; }

/* ---------- Boutons communs ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; flex-shrink: 0;
  border: 0; border-radius: var(--r-ctl); background: transparent;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; stroke: currentColor; fill: none; }
.icon-btn-danger:hover { background: #fef2f2; color: #b91c1c; }
.dark .icon-btn-danger:hover { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.5rem; padding: .5rem 1rem; border: 0; border-radius: var(--r-ctl);
  background: var(--brand); color: #fff; font-size: .875rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 2px rgba(21, 128, 61, .3);
}
.btn-primary:hover { background: var(--brand-hover); box-shadow: 0 6px 16px -6px rgba(21, 128, 61, .55); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-primary svg { width: 1rem; height: 1rem; stroke: currentColor; fill: none; }
.btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.25rem; padding: .4rem .75rem; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); background: transparent; color: var(--ink-2);
  font-size: .8rem; font-weight: 600; cursor: pointer;
}
.btn-quiet svg { width: .95rem; height: .95rem; stroke: currentColor; fill: none; }
.btn-quiet:hover { background: var(--hover); color: var(--ink); }
.btn-quiet.is-danger:hover { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.dark .btn-quiet.is-danger:hover { color: #fca5a5; border-color: rgba(252, 165, 165, .4); background: rgba(239, 68, 68, .12); }
.link-quiet {
  background: none; border: 0; padding: .25rem; cursor: pointer;
  font-size: .78rem; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(91, 107, 128, .45);
}
.link-quiet:hover { color: var(--ink); text-decoration-color: currentColor; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Colonne patients ---------- */
#app-sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; height: 100%; z-index: 10; flex-shrink: 0;
}
.dark #app-sidebar { background: #111a2c !important; border-color: var(--line) !important; }
.sd-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-height: 3.5rem; padding: .5rem .5rem .5rem 1rem; border-bottom: 1px solid var(--line);
}
.sd-brand { display: flex; align-items: center; gap: .45rem; font-size: 1.05rem; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.sd-brand svg { width: 1.25rem; height: 1.25rem; stroke: var(--brand-ink); fill: none; }
.sd-head-actions { display: flex; align-items: center; gap: .125rem; }
.sd-tools { padding: .75rem .75rem .5rem; display: flex; flex-direction: column; gap: .5rem; }
.sd-tools .btn-primary { width: 100%; }
.sd-tools .link-quiet { align-self: center; margin-top: -.25rem; }
.sd-search { position: relative; }
.sd-search > svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; stroke: var(--muted); fill: none; pointer-events: none; }
.sd-search .inp { padding-left: 2.1rem; padding-right: 2.25rem; }
.sd-search .icon-btn { position: absolute; right: .125rem; top: 50%; transform: translateY(-50%); width: 2rem; height: 2rem; }
.sd-search .icon-btn svg { width: .9rem; height: .9rem; }
#btn-admin-dash { align-items: center; justify-content: center; gap: .4rem; min-height: 2.25rem; border-radius: var(--r-ctl); font-size: .8rem; font-weight: 600; cursor: pointer; }
#btn-admin-dash svg { width: .95rem; height: .95rem; stroke: currentColor; fill: none; }
.sd-list-title { padding: .5rem 1.25rem .25rem; font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
#cl-list { flex: 1; overflow-y: auto; padding: .125rem .5rem .75rem; }
.sb-item {
  width: 100%; display: flex; align-items: center; gap: .625rem; margin-bottom: 2px;
  padding: .45rem .55rem; border: 0; border-radius: var(--r-ctl); background: transparent;
  color: var(--ink-2); font-size: .875rem; text-align: left; cursor: pointer;
}
.sb-item:hover { background: var(--hover); }
.sb-item-avatar {
  width: 2rem; height: 2rem; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: #e2e8f0; color: #334155;
}
.dark .sb-item-avatar { background: #334155; color: #e2e8f0; }
.sb-item-text { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.sb-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 500; }
.sb-item-meta { font-size: .75rem; color: var(--muted); }
.sb-item.sb-item-active { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-soft-line); }
.sb-item-active .sb-item-avatar { background: var(--brand); color: #fff; }
.sb-item-active .sb-item-name { font-weight: 700; color: #14532d; }
.sb-item-active .sb-item-meta { color: #166534; }
.dark .sb-item-active .sb-item-name { color: #dcfce7; }
.dark .sb-item-active .sb-item-meta { color: #86efac; }
.sb-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.sb-empty svg { width: 1.9rem; height: 1.9rem; stroke: currentColor; fill: none; margin: 0 auto .6rem; opacity: .7; }
.sb-empty strong { display: block; color: var(--ink-2); font-size: .85rem; margin-bottom: .25rem; }
.sd-foot { padding: .625rem .75rem .75rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .25rem; text-align: center; }
.sd-version { font-size: .7rem; color: var(--muted); }

/* Tiroir telephone : entree glissee (animation, pas transition : la transition de
   margin-left est volontairement coupee a ce palier, voir layout.css). */
@media (max-width: 768px) {
  #app-sidebar.mobile-drawer-open { animation: nsDrawerIn .24s var(--ease-out); }
}
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait) {
  #app-sidebar .sd-head { min-height: 3.75rem; }
  #app-sidebar .icon-btn { width: 2.75rem; height: 2.75rem; }
  .sb-item { padding: .65rem .6rem; font-size: .95rem; }
  .sb-item-avatar { width: 2.25rem; height: 2.25rem; }
}

/* ---------- En-tete patient ---------- */
/* Regle d or : la barre garde la MEME hauteur a toutes les largeurs (3.5rem) et rien
   n y entre ou n en sort en poussant les voisins (statut "Enregistre" flottant).
   Les paliers sont calcules sur la largeur du contenu de la barre (container query)
   pour que le nom du patient garde toujours ~10rem avant qu un palier ne bascule :
     >= 1240 px : onglets longs + "Generer le compte rendu" en toutes lettres
     1060-1239  : onglets longs + compte rendu en icone
     830-1059   : onglets courts (Tableau, Infos, Seance, Besoins, Menus)
     < 830      : onglets en icones seules
     < 600      : sans pastille d initiales ; < 520 : sans badge score (vu sur le tableau de bord).
   La ligne meta (sexe, age, taille, poids) reste toujours sous le nom, coupee par "..."
   si besoin : le nom ne monte ni ne descend quand on change de largeur. */
#main-area { background: var(--bg) !important; }
#cv .hd.cv-hd {
  background: var(--surface); border-bottom: 1px solid var(--line);
  height: 3.5rem; padding: 0 1.25rem; flex-shrink: 0; position: relative; z-index: 5;
  display: flex; align-items: center;
  container-type: inline-size; container-name: cv-header;
}
.cv-hd-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem; flex-wrap: nowrap; }
.cv-hd .cv-hd-row { width: 100%; }

#cv-hd-left {
  display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 0 1 auto;
}
#cv-av {
  width: 2.25rem; height: 2.25rem; min-width: 2.25rem; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .8rem; letter-spacing: .02em;
}
.cv-id {
  min-width: 0; flex: 0 1 auto; display: flex; flex-direction: column; overflow: hidden;
}
.cv-id-row {
  display: flex; align-items: center; gap: .25rem; min-width: 0;
}
#cv-name {
  margin: 0; font-size: 1.0625rem; font-weight: 700; line-height: 1.25; color: var(--ink);
  min-width: 0; max-width: 26rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-del { width: 1.85rem; height: 1.85rem; flex-shrink: 0; }
.cv-del svg { width: 1rem; height: 1rem; }
#cv-meta {
  font-size: .78rem; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Badge score santé : reste TOUJOURS accolé au patient (à côté de la corbeille), jamais projeté à droite */
#cv-health-score {
  align-items: baseline; gap: 0; padding: .125rem .5rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; flex-shrink: 0; cursor: default; line-height: 1.35;
  align-self: center;
}
#cv-health-score .hs-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* Stabilite (28/10) : chiffres de meme largeur et place reservee pour "100/100" ; 97 -> 100 decalait
   les onglets de 5 px. Le contenu est centre dans cette largeur. */
#cv-health-score { font-variant-numeric: tabular-nums; min-width: 4.5rem; justify-content: center; }
#cv-health-score .hs-val { font-size: .84rem; font-weight: 700; }
#cv-health-score .hs-max { font-size: .7rem; font-weight: 600; }
#cv-health-score .hs-na { font-size: .7rem; font-weight: 600; }

/* Onglets : piste segmentée, centrée dans l espace libre. Meme hauteur a tous les paliers. */
#cv-hd-tabs {
  display: flex; gap: 2px; padding: 3px; margin-inline: auto; min-width: 0;
  background: var(--seg-bg); border-radius: 10px;
  overflow-x: auto; scrollbar-width: none; flex: 0 0 auto;
}
#cv-hd-tabs::-webkit-scrollbar { display: none; }
.tab-short { display: none; }
.tnav {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; flex-shrink: 0;
  height: 2rem; padding: 0 .75rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2); font-size: .84rem; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.tnav svg { width: .95rem; height: .95rem; stroke: currentColor; fill: none; flex-shrink: 0; }
.tnav:not(.on):hover { background: rgba(255, 255, 255, .65); color: var(--ink); }
.dark .tnav:not(.on) { color: #cbd5e1; }
.dark .tnav:not(.on):hover { background: var(--hover); color: #f8fafc; }
.tnav.on, .dark .tnav.on {
  background: var(--seg-on); color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .1), 0 0 0 1px rgba(15, 23, 42, .04);
}
.tnav.on svg { color: var(--brand-ink); }
.dark .tnav.on { box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }

#cv-hd-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; margin-left: auto; }
/* Statut d enregistrement : pastille flottante sous la barre, a droite. Elle apparait et
   disparait sans jamais decaler le nom ni les onglets. */
#autosave-status {
  position: absolute; right: 1.25rem; top: calc(100% + .375rem); z-index: 6;
  padding: .2rem .55rem; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 4px 12px -6px rgba(15, 23, 42, .3);
  font-size: .75rem; font-weight: 600; white-space: nowrap; pointer-events: none;
  transition: opacity .25s ease-out;
}
#rpt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; flex-shrink: 0;
  height: 2.25rem; padding: 0 .9rem; border: 0; border-radius: var(--r-ctl);
  background: #0f172a; color: #fff; font-size: .84rem; font-weight: 700; white-space: nowrap; cursor: pointer;
  position: relative;
}
#rpt-btn:hover { background: #1e293b; box-shadow: 0 6px 16px -8px rgba(15, 23, 42, .6); }
.dark #rpt-btn { background: #e2e8f0; color: #0f172a; }
.dark #rpt-btn:hover { background: #f8fafc; }
#rpt-btn svg { width: 1.1rem; height: 1.1rem; stroke: currentColor; fill: none; flex-shrink: 0; }
#rpt-btn .rpt-short { display: none; }

/* Paliers (voir l en-tete de cette section). Le bouton compte rendu en icone garde le
   meme carre 2.25rem partout ; les onglets icones gardent la hauteur 2rem. */
@container cv-header (max-width: 1239px) {
  #rpt-btn #rpt-btn-text { display: none; }
  #rpt-btn { width: 2.25rem; padding: 0; gap: 0; }
}
@container cv-header (max-width: 1059px) {
  .tab-long { display: none; }
  .tab-short { display: inline; }
}
@container cv-header (max-width: 829px) {
  .tnav-text { display: none; }
  #cv-hd-tabs .tnav { width: 2.25rem; padding: 0; gap: 0; }
  #cv-hd-tabs .tnav svg { width: 1.1rem; height: 1.1rem; }
}
/* Seulement quand les onglets sont dans la barre (pas sur telephone / tablette portrait). */
@media (min-width: 1025px), (min-width: 641px) and (orientation: landscape) {
  @container cv-header (max-width: 599px) {
    #cv-av { display: none; }
  }
  @container cv-header (max-width: 519px) {
    #cv-health-score { display: none !important; }
  }
}

/* Téléphone et tablette portrait : onglets dans la barre basse, identité patient à gauche */
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait) {
  #cv .hd.cv-hd { padding: 0 .75rem 0 .5rem; }
  .cv-hd-row { gap: .5rem; }
  #cv-hd-left { gap: .4rem; }
  #btn-toggle-sb-cv { width: 2.25rem; height: 2.25rem; }
  #cv-hd-right { gap: .375rem; }
  #rpt-btn #rpt-btn-text { display: none; }
  #rpt-btn { width: 2.25rem; padding: 0; gap: 0; }
  #autosave-status { right: .75rem; }
  #cv-name { font-size: 1rem; }
}
@media (max-width: 480px) {
  #cv-name { font-size: .95rem; }
  #cv-health-score { padding: .1rem .35rem; }
  #cv-health-score .hs-val { font-size: .78rem; }
  #cv-health-score .hs-max { font-size: .65rem; }
  #cv-hd-left { gap: .3rem; }
  .cv-del { width: 1.75rem; height: 1.75rem; }
  #rpt-btn #rpt-btn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Barre de navigation basse (telephone) ---------- */
#cv-bottom-nav {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: .3rem .375rem calc(.3rem + env(safe-area-inset-bottom, 0px)); gap: 0;
  box-shadow: 0 -6px 20px -12px rgba(15, 23, 42, .25);
}
.dark #cv-bottom-nav { background: #111a2c; border-color: var(--line); }
.bnav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  flex: 1; min-height: 3.25rem; padding: .2rem 0; border: 0; background: none; border-radius: 10px;
  color: var(--muted); font-size: .72rem; font-weight: 600; cursor: pointer;
}
.bnav-btn svg {
  width: 1.25rem; height: 1.25rem; box-sizing: content-box; padding: .2rem .95rem; border-radius: 999px;
  stroke: currentColor; fill: none; transition: background-color .2s var(--ease-out), color .2s;
}
.bnav-btn.on, .dark .bnav-btn.on { color: var(--ink); background: none; }
.bnav-btn.on svg { background: var(--brand-soft); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-soft-line); }
.dark .bnav-btn:not(.on) { color: #b4c0d0; }

/* ---------- Zone de contenu : largeur et densite ---------- */
#cv-scroll-area { padding: 1rem 1.25rem !important; container-type: inline-size; container-name: cvs; }
@media (max-width: 640px) { #cv-scroll-area { padding: .75rem .75rem !important; } }
/* 01/11 : la bulle IA (fixe, en bas a droite) ne couvre plus la fin de la page sur ordinateur : on garde de la place sous
   le dernier bloc. Sur telephone, la regle plus bas (barre basse comprise) prend le relais. */
body:has(:is(#ai-conclusion-bubble, #ai-menus-bubble)[style*="flex"]) #cv-scroll-area { padding-bottom: 5.5rem !important; }
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait) {
  #cv-scroll-area { padding-bottom: calc(4.25rem + 1.25rem + env(safe-area-inset-bottom, 0px)) !important; }
  body:has(#ai-conclusion-bubble[style*="flex"]) #cv-scroll-area { padding-bottom: calc(4.25rem + 5rem + env(safe-area-inset-bottom, 0px)) !important; }
}
#t-dashboard, #t-infos, #t-tanita, #t-nutri { max-width: 104rem !important; gap: 1rem !important; }
#t-menus { max-width: 80rem !important; }
#cv-scroll-area .card { border-radius: var(--r-card) !important; }
#cv-scroll-area .card[style*="padding:1.5rem"], #cv-scroll-area .card[style*="padding: 1.5rem"] { padding: 1.125rem 1.25rem !important; }
#cv-scroll-area .card[style*="padding:1.25rem"] { padding: 1rem 1.125rem !important; }
#cv-scroll-area .dark-banner { padding: .75rem 1rem !important; border-radius: var(--r-card) !important; }
.acc-card { border-radius: var(--r-card); margin-bottom: .75rem !important; }
.acc-header { padding: .75rem 1.125rem !important; font-size: .95rem; }
.acc-body { padding: 1rem 1.125rem !important; }
.sh { margin-bottom: .875rem; }
#t-dashboard .dash-score { padding: 1.125rem 1.25rem !important; }
#t-dashboard .dash-score > div:first-child { margin-bottom: 1rem !important; }
#t-dashboard .dash-kpis { gap: .75rem !important; }
#t-dashboard .dash-kpis > .card { padding: .875rem 1rem !important; }
#t-dashboard .dash-bottom { gap: 1rem !important; }
#t-menus > div > div:first-child { justify-content: flex-start !important; }

/* Grand ecran : le bilan passe en 2 colonnes (score a gauche, indicateurs a droite). */
@container cvs (min-width: 1150px) {
  #t-dashboard:not([style*="display: none"]):not([style*="display:none"]) {
    display: grid !important; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start;
  }
  #t-dashboard > .dark-banner, #t-dashboard > .dash-bottom { grid-column: 1 / -1; }
  #t-dashboard > .dash-kpis { grid-template-columns: 1fr 1fr !important; }
  #t-tanita:not([style*="display: none"]):not([style*="display:none"]) {
    display: grid !important; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 1rem;
  }
  #t-tanita > .seance-new { grid-column: 1 / -1; }
  /* 01/11 : graphique + historique a gauche, journal des consultations a droite SEULEMENT s'il y en a un :
     sinon une colonne vide restait a droite (grand ecran) et l'historique etait coupe. */
  #t-tanita:has(#timeline-card:not([style*="display: none"]):not([style*="display:none"])) {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }
  #t-tanita:not(:has(#timeline-card:not([style*="display: none"]):not([style*="display:none"]))) #t-tanita-col-right { display: none; }
}
/* Infos patient en 2 colonnes (28/10, Kylian : "il reste de la place a droite") : identite, mesures
   et sport a gauche ; conclusion puis dossier clinique (sante, habitudes) a droite. Sur une colonne
   (telephone), meme ordre qu'avant : fiche, sport, clinique, conclusion. */
@container cvs (min-width: 900px) {
  #t-infos:not([style*="display: none"]):not([style*="display:none"]) {
    display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 1rem;
  }
  #t-infos-col-right > #acc-card-conclusion { order: -1; }
}

/* Grilles du contenu : basculent selon la largeur REELLE de la zone (sans la colonne
   patients ni le panneau IA), pas selon l ecran. Remplace le palier 1024 px de responsive.css. */
#cv-scroll-area [style*="grid-template-columns"] > * { min-width: 0; }
@container cvs (max-width: 759px) {
  [style*="grid-template-columns: repeat(4"], [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: 1fr 1fr 1fr 1fr"], [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
}
@container cvs (max-width: 559px) {
  [style*="grid-template-columns: 1fr 1fr 1fr"], [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: repeat(3"], [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: 1fr !important;
  }
}
/* Score sante : jauge au-dessus des piliers quand la zone est etroite. */
@container cvs (max-width: 699px) {
  #dash-score-grid { grid-template-columns: 1fr !important; gap: 1rem !important; }
  #dash-score-grid > div:first-child { padding: 1rem !important; }
}
#dash-score-piliers .hs-pts, #dash-score-piliers .hs-na { white-space: nowrap; }
/* Bandeaux (Tableau de bord, Questionnaire) : bouton sous le texte quand la zone est etroite. */
.dark-banner button { white-space: nowrap; }
@container cvs (max-width: 619px) {
  .dark-banner { flex-direction: column !important; align-items: stretch !important; gap: .85rem !important; }
  .dark-banner > div:last-child { flex-wrap: wrap !important; }
  .dark-banner > button, .dark-banner > div:last-child > button { flex: 1 1 100% !important; justify-content: center !important; }
}
/* Bilan (onglet Besoins) : colonnes fixes au lieu de "auto-fit", qui laissait une carte
   seule sur sa ligne (4 + 1, 2 + 1). En 2 colonnes, une carte impaire prend toute la ligne.
   Les classes n ont pas d effet dans le compte rendu PDF (styles en ligne conserves). */
#cv-scroll-area .bilan-grid { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
#cv-scroll-area .habits-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
@container cvs (max-width: 899px) {
  #cv-scroll-area .bilan-grid, #cv-scroll-area .habits-grid { grid-template-columns: 1fr 1fr !important; }
  #cv-scroll-area .bilan-grid > :last-child:nth-child(odd),
  #cv-scroll-area .habits-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@container cvs (max-width: 479px) {
  #cv-scroll-area .bilan-grid, #cv-scroll-area .habits-grid { grid-template-columns: 1fr !important; }
}
/* Tableaux larges : defilement horizontal signale par une ombre sur le bord droit. */
.table-scroll {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--surface, #fff) 30%, transparent) left / 2rem 100% no-repeat local,
    linear-gradient(to left, var(--surface, #fff) 30%, transparent) right / 2rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .14), transparent) left / .6rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .14), transparent) right / .6rem 100% no-repeat scroll;
}
#ration-table { min-width: 34rem; }

/* Zones tactiles du contenu sur ecran tactile : 40 px minimum. */
@media (pointer: coarse) {
  #cv-scroll-area .inp, #cv-scroll-area select, #cv-scroll-area input:not([type="radio"]):not([type="checkbox"]):not([type="range"]),
  #cv-scroll-area button:not(.me-color-dot), #chart-filters .dtab { min-height: 2.5rem; }
  #cv-scroll-area .me-color-dot { width: 1.75rem; height: 1.75rem; min-height: 0; flex-shrink: 0; aspect-ratio: 1; }
  #cv-scroll-area .me-btn { min-width: 2.5rem; height: 2.5rem; }
  #cv-scroll-area table button { min-width: 2.5rem; }
}

/* ---------- Ecran de connexion ---------- */
.auth-screen { background: var(--bg) !important; background-image: none !important; }
.auth-card {
  width: 100%; max-width: 24rem; padding: 2rem 1.75rem 1.5rem; border-radius: 16px !important;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 24px 48px -28px rgba(15, 23, 42, .35);
}
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-logo { width: 2.75rem; height: 2.75rem; stroke: var(--brand-ink); fill: none; margin: 0 auto .75rem; display: block; }
.auth-title { font-size: 1.5rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.auth-sub { margin-top: .25rem; font-size: .9rem; color: var(--muted); }
.auth-body { display: flex; flex-direction: column; gap: 1rem; }
.auth-fields { display: flex; flex-direction: column; gap: 1rem; }
.auth-body .inp { min-height: 2.75rem; font-size: 1rem; }
.pw-field { position: relative; }
.pw-field .inp { padding-right: 3rem; }
.pw-toggle { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); width: 2.5rem; height: 2.5rem; }
.pw-toggle:not(:disabled):active { transform: translateY(-50%); }
.pw-toggle .pw-eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .pw-eye { display: none; }
.pw-toggle[aria-pressed="true"] .pw-eye-off { display: block; }
.auth-error { color: var(--danger-ink); font-size: .8rem; font-weight: 600; text-align: center; }
.auth-submit { width: 100%; min-height: 2.75rem; font-size: .95rem; }
.auth-link { background: none; border: 0; cursor: pointer; color: var(--brand-ink); font-size: .85rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.auth-foot { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); text-align: center; font-size: .72rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Zones tactiles (telephone, tablette portrait) : 44 px minimum ---------- */
@media (max-width: 640px), (max-width: 1024px) and (orientation: portrait) {
  #btn-toggle-sb-cv { width: 2.75rem; height: 2.75rem; }
  .link-quiet { min-height: 2.75rem; padding: .5rem .75rem; }
  .sd-foot .btn-quiet, .sd-foot button { min-height: 2.75rem; }
  .sd-search .inp { min-height: 2.75rem; }
  .auth-link { min-height: 2.75rem; padding: .5rem .75rem; }
  .q-step-btn { height: 2.75rem !important; }
}
/* Questionnaire sur un ecran bas (telephone en paysage, ecran d'ordinateur zoome : 700x420, 853x480) :
   meme disposition, en plus serre, pour laisser au moins 60 % de la hauteur aux questions. */
@media (max-height: 600px) {
  #m-questionnaire .mbox { max-height: 98vh !important; padding: .6rem 1rem !important; }
  #m-questionnaire .mbox > div:first-child { margin-bottom: .4rem !important; padding-bottom: .3rem !important; }
  #m-questionnaire .mbox > div:first-child .txt2 { display: none; }
  #q-wizard-title { font-size: 1rem !important; }
  #m-questionnaire .mbox > div:nth-child(2) { margin-bottom: .4rem !important; height: 4px !important; }
  #q-steps-indicator { min-height: 0 !important; margin-bottom: .4rem !important; padding: 0 2px !important; }
  #q-steps-indicator .q-step-btn { height: 2rem !important; padding: .2rem .65rem !important; font-size: .72rem !important; }
  #m-questionnaire .mbox > div:last-child { margin-top: .4rem !important; padding-top: .4rem !important; }
  #m-questionnaire .mbox > div:last-child button { padding-top: .4rem !important; padding-bottom: .4rem !important; }
}
/* Tres bas (640x360 = ecran a 200 %) : les pastilles d'etapes s'effacent, le titre « Etape n / 7 »
   et la barre de progression disent deja ou on en est. */
@media (max-height: 400px) {
  #q-steps-indicator { display: none !important; }
}

/* ---------- Petits ajustements telephone (verifies en 390 px) ---------- */
@media (max-width: 640px) {
  #chart-filters .dtab { flex-shrink: 0; white-space: nowrap; }
  /* Une grille passee en 1 colonne garde ses "span 2" : sans ca, colonne fantome et champs ecrases. */
  [style*="grid-column:span 2"], [style*="grid-column: span 2"] { grid-column: 1 / -1 !important; }
}
#mesure-table td, #mesure-table th { white-space: nowrap; }
@media (max-width: 768px) {
  /* Ombre du tiroir ferme qui depassait sur le bord gauche de l ecran. */
  #app-sidebar:not(.mobile-drawer-open) { box-shadow: none !important; }
}

/* 01/11 : le mot "Patients" a cote de l'icone trois traits (colonne repliee ou tiroir). Texte present des le
   premier affichage et de largeur fixe : l'en-tete ne bouge pas. Sur tres petite barre, l'icone seule. */
#btn-toggle-sb-cv { width: auto !important; padding: 0 .6rem 0 .5rem; gap: .35rem; }
#btn-toggle-sb-cv .sb-toggle-label { font-size: .82rem; font-weight: 600; line-height: 1; white-space: nowrap; }
@container cv-header (max-width: 419px) {
  #btn-toggle-sb-cv .sb-toggle-label { display: none; }
  #btn-toggle-sb-cv { width: 2.25rem !important; padding: 0; }
}

/* 01/11 : "Nouveau patient (questionnaire)" tient sur une ligne dans la colonne de 17 rem (1280 px). */
.sd-tools .btn-primary { white-space: nowrap; padding: .5rem .6rem; gap: .35rem; font-size: .8125rem; letter-spacing: -.005em; }
