/* Écran Équipe : qui utilise le tableau de bord, avec quel rôle et quel compte.

   Même langage que Applications et Canaux : relief par la seule clarté (aucune bordure au repos, une marche
   de ton plus claire pour ce qui ressort), aucune ombre sauf ce qui flotte (fenêtres, menu « … »). Le
   turquoise ne dit qu'un état (compte personnel, copié) ; l'action principale est en inversion (fond ivoire,
   texte marine, classe .btn-stop). Les survols et appuis des boutons .btn viennent de buttons.css.

   Un seul écart (8 px) entre les lignes. La mise en page suit la largeur du bloc (requête de conteneur) :
     ≥ 700 px : une ligne par personne, en colonnes (écran 1440 : bloc 960 ; écran 768 : bloc 736)
     sinon    : trois lignes empilées à côté de la pastille (écran 390 : bloc 358)
   Pas des lignes : 64 px large ; 87 px empilé ; plus 8 px d'écart. Les lignes grises ont la même taille. */

.tm, .tm-modal, .tm-menu {
  --tm-gap: 8px;
  --tm-rest: rgba(246,242,234,.045);
  --tm-raised: rgba(246,242,234,.075);
  --tm-hover: rgba(246,242,234,.10);
  --tm-press: rgba(246,242,234,.14);
}

/* ── Écran ──────────────────────────────────────────────────────────────── */

.tm { container: tm / inline-size; max-width: 960px; margin-top: 32px; min-width: 0; }
.tm-sec + .tm-sec { margin-top: 32px; }
.tm-h { margin: 0 0 12px; font-family: inherit; font-size: 16px; font-weight: 600; line-height: 24px; letter-spacing: 0; color: var(--ivory); }
.tm-n { color: var(--mute); font-weight: 500; font-variant-numeric: tabular-nums; }
.tm-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 12px; min-height: 40px; }
.tm-sec-head .tm-h { margin: 0; }
.tm-add { flex: none; min-height: 40px; padding: 0 16px; gap: 8px; }
.tm-quiet { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--mute); }

/* Prénom, pastille de rôle, point d'état */
.tm-name { min-width: 0; font-size: 14px; font-weight: 600; line-height: 20px; color: var(--ivory); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-you { flex: none; font-size: 12.5px; font-weight: 500; line-height: 20px; color: var(--mute); }
.tm-you::before { content: "· "; }
.tm-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; background: rgba(246,242,234,.07);
  color: var(--sand); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tm-tag.admin { background: rgba(246,242,234,.14); color: var(--ivory); }
/* Limite d'accès : une étiquette neutre de plus, un peu plus discrète que le rôle. */
.tm-tag-policy { display: inline-block; max-width: 100%; height: 20px; padding: 0 7px; overflow: hidden; text-overflow: ellipsis; background: rgba(246,242,234,.05);
  color: var(--sand); font-size: 11.5px; font-weight: 500; line-height: 20px; }
.tm-dot { flex: none; width: 6px; height: 6px; background: var(--mute); }
.tm-dot.is-ok { background: var(--turq); }
.tm-dot.is-warn { background: var(--ochre-light); }

/* Mon compte */
.tm-card { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; min-height: 80px; padding: 16px; background: var(--tm-raised); }
.tm-card .avatar { width: 48px; height: 48px; font-size: 22px; flex: none; }
.tm-card-txt { flex: 1 1 220px; min-width: 0; }
.tm-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.tm-card .tm-name { font-size: 16px; line-height: 24px; }
.tm-card-sub { min-height: 18px; margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--sand); }
.tm-st { display: inline-flex; align-items: center; gap: 7px; }
.tm-card-act { flex: none; }

/* Boutons secondaires : un ton plus clair que le fond, texte ivoire (l'action principale reste en inversion). */
.btn.tm-soft { min-height: 36px; padding: 0 14px; background: rgba(246,242,234,.09); color: var(--ivory); font-size: 13px; font-weight: 600; }
.btn.tm-soft:hover:not(:disabled) { background: rgba(246,242,234,.16); }
.btn.tm-danger { background: var(--danger); color: var(--navy); }
.btn.tm-danger:hover:not(:disabled) { background: #FFB5A6; }
.btn.tm-danger:focus-visible { outline-color: var(--ivory); }

/* Liste : une ligne par personne. Empilé par défaut ; en colonnes dans un bloc assez large. */
.tm-hd { display: none; }
.tm-list { display: flex; flex-direction: column; gap: var(--tm-gap); }
.tm-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "av who more" "av meta more" "av last more";
  column-gap: 12px; row-gap: 2px; align-items: start; min-height: 64px; padding: 12px 8px 12px 12px;
  background: var(--tm-rest); transition: opacity .15s ease; }
.tm-list:not(.with-menu) .tm-row { grid-template-columns: 40px minmax(0, 1fr); grid-template-areas: "av who" "av meta" "av last"; padding-right: 16px; }
.tm-row.is-busy { opacity: .6; }
.tm-av { grid-area: av; }
.tm-av .avatar { width: 40px; height: 40px; font-size: 18px; }
.tm-row.off .avatar { opacity: .45; }
.tm-row.off .tm-tag { opacity: .7; }
.tm-row.off .tm-name { color: var(--sand); }
/* Empilé : la pastille de rôle suit le prénom (ligne 1), l'état d'accès a sa ligne ; en colonnes, chacun a la sienne. */
.tm-who { grid-area: who; display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 22px; }
/* Empilé, avec la limite : l'étiquette passe sous le prénom et le rôle s'il n'y a pas la place (sans limite, rien ne change). */
.tm-who.has-policy { flex-wrap: wrap; gap: 4px 6px; }
.tm-policy-in { flex: 0 1 auto; display: inline-flex; min-width: 0; max-width: 100%; }
.tm-who .tm-name { flex: 0 1 auto; }
.tm-role-in { flex: none; display: inline-flex; margin-left: 4px; }
.tm-meta { grid-area: meta; display: flex; align-items: center; min-width: 0; min-height: 20px; }
.tm-role { display: none; }
.tm-acc { display: inline-flex; align-items: center; gap: 7px; min-width: 0; white-space: nowrap; font-size: 13px; line-height: 20px; color: var(--sand); }
.tm-acc.is-off { color: var(--mute); }
.tm-last { grid-area: last; min-height: 17px; font-size: 12.5px; line-height: 17px; color: var(--mute); font-variant-numeric: tabular-nums; }

.tm-more { grid-area: more; align-self: center; display: grid; place-items: center; width: 40px; height: 40px; margin: 0; padding: 0;
  background: none; border: 0; color: var(--sand); cursor: pointer; transition: background .15s ease, color .15s ease; }
.tm-more:hover:not(:disabled) { background: var(--tm-hover); color: var(--ivory); }
.tm-more[aria-expanded="true"] { background: var(--tm-press); color: var(--ivory); }
.tm-more:focus-visible { outline: 2px solid var(--turq); outline-offset: 0; }
.tm-more:disabled { cursor: default; opacity: .6; }

@container tm (min-width: 700px) {
  .tm-hd { display: grid; grid-template-columns: 40px minmax(0, 1fr) var(--tm-role-w, 130px) minmax(160px, .9fr) 130px; column-gap: 12px; align-items: end;
    padding: 0 12px; margin: 0 0 8px; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--mute); }
  .tm-hd.with-menu { grid-template-columns: 40px minmax(0, 1fr) var(--tm-role-w, 130px) minmax(160px, .9fr) 130px 40px; padding-right: 8px; }
  .tm-row, .tm-list:not(.with-menu) .tm-row { grid-template-columns: 40px minmax(0, 1fr) var(--tm-role-w, 130px) minmax(160px, .9fr) 130px; grid-template-areas: none; align-items: center; padding: 12px; }
  .tm-list.with-menu .tm-row { grid-template-columns: 40px minmax(0, 1fr) var(--tm-role-w, 130px) minmax(160px, .9fr) 130px 40px; padding-right: 8px; }
  .tm-av, .tm-who, .tm-last, .tm-more { grid-area: auto; }
  .tm-meta { display: contents; }
  .tm-role { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
  .tm-role-in, .tm-policy-in { display: none; }
  .tm-who, .tm-who.has-policy { min-height: 0; flex-wrap: nowrap; }
  .tm-hd.has-policy, .tm-list.has-policy { --tm-role-w: 160px; }
  .tm-last { min-height: 0; font-size: 13px; line-height: 20px; color: var(--sand); }
  .tm-row.off .tm-last { color: var(--mute); }
  /* Libellé « Dernière connexion : » : lu par les lecteurs d'écran, sans doublonner l'en-tête. */
  .tm-pre { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@container tm (max-width: 560px) {
  .tm-card-txt { flex-basis: calc(100% - 64px); }
  .tm-card-act { flex: 1 1 100%; }
  .tm-account-btn, .tm-sk-btn { width: 100%; }
}

/* Mot de passe commun */
.tm-common { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; padding: 16px; background: var(--tm-rest); }
.tm-common-txt { min-width: 0; max-width: 640px; }
.tm-common .s-label { font-size: 15px; line-height: 20px; }
.tm-common .s-help { margin-top: 4px; font-size: 13px; line-height: 1.5; }
.tm-common-note { color: var(--sand); }
.tm-common .switch { flex: none; }
.switch.locked { cursor: not-allowed; }
.switch:focus-visible { outline: 2px solid var(--turq); outline-offset: 2px; }

/* États : chargement, erreur, vide */
.tm-row.is-skel { pointer-events: none; }
.tm-sk { display: block; background: rgba(246,242,234,.08); }
.tm-sk-av { width: 40px; height: 40px; }
.tm-sk-name { width: 120px; max-width: 60%; height: 12px; margin: 4px 0; }
.tm-sk-role { width: 96px; height: 22px; }
.tm-sk-acc { width: 128px; height: 10px; margin: 5px 0; }
.tm-sk-last { width: 140px; max-width: 80%; height: 10px; margin: 3px 0 4px; }
.tm-sk-status { width: 170px; max-width: 100%; height: 10px; margin: 4px 0; }
.tm-sk-btn { width: 190px; height: 36px; }
.tm-sk-switch { width: 44px; height: 24px; }
.tm-empty, .tm-error { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; min-height: 60px; padding: 12px 16px;
  background: var(--tm-rest); color: var(--sand); font-size: 14px; line-height: 1.5; }
.tm-empty p, .tm-error p { margin: 0; }
.tm-error .ico { color: var(--danger); }
.tm-link { display: inline-flex; align-items: center; min-height: 32px; padding: 0; margin: 0; background: none; border: 0;
  color: var(--ivory); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-decoration-color: rgba(246,242,234,.4); text-underline-offset: 3px; }
.tm-link:hover { text-decoration-color: var(--ivory); }
.tm-link:focus-visible { outline: 2px solid var(--turq); outline-offset: 2px; }

/* ── Menu « … » ─────────────────────────────────────────────────────────── */

.tm-menu { position: fixed; z-index: 95; display: flex; flex-direction: column; gap: 2px; min-width: 248px; max-width: calc(100vw - 16px);
  padding: 6px; background: #16214A; box-shadow: 0 18px 40px rgba(4,8,22,.55); animation: mnFade .1s ease; }
.tm-mi { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; width: 100%; min-height: 40px;
  margin: 0; padding: 8px 12px; background: none; border: 0; color: var(--ivory); font: inherit; font-size: 14px; line-height: 20px; text-align: left; cursor: pointer; }
.tm-mi:hover { background: var(--tm-hover); }
.tm-mi:focus { outline: none; background: var(--tm-press); }
.tm-mi:focus-visible { outline: 2px solid var(--turq); outline-offset: -2px; }
.tm-mi.danger { color: var(--danger); }
.tm-mi.is-off { color: var(--mute); cursor: default; }
.tm-mi.is-off:hover { background: none; }
.tm-mi.is-off:focus { background: var(--tm-rest); }
.tm-mi-hint { font-size: 12px; line-height: 16px; color: var(--mute); }
.tm-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ── Fenêtres ───────────────────────────────────────────────────────────── */

.modal.tm-modal { max-width: 520px; gap: 18px; background: #16214A; border: 0; box-shadow: 0 24px 64px rgba(4,8,22,.55); }
.tm-m-head { min-width: 0; }
.tm-modal .tm-m-head .display { margin: 0; font-size: 24px; line-height: 1.15; overflow-wrap: anywhere; }
.tm-m-lead { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: var(--sand); }
.tm-m-lead strong, .tm-m-body strong { color: var(--ivory); font-weight: 600; }
.tm-m-body p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--sand); }
.tm-m-body p + p { margin-top: 8px; }
/* Ce que change la limite : trois lignes courtes, une marche de ton chacune (comme les choix de rôle). */
.tm-points { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tm-points li { padding: 10px 14px; background: var(--tm-rest); font-size: 14px; line-height: 1.5; color: var(--sand); }

/* Choisir le modèle d'un membre : la fenêtre de choix du modèle d'un agent (styles « mdl-* » de models.css), avec les marges des fenêtres de l'équipe. */
.modal.tm-modal.mdl-modal { max-width: 600px; height: min(740px, 90vh); padding: 24px 24px 20px; gap: 16px; overflow: hidden; }
.tm-choice .tm-m-head, .tm-choice .actions { flex: none; }
.tm-choice .mdl-opt.is-skel { pointer-events: none; min-height: 52px; }
.tm-choice .mdl-info .mdl-line strong { color: var(--ivory); font-weight: 600; }
.tm-choice .mdl-info .mdl-same { color: var(--ivory); font-weight: 600; }
.tm-choice .mdl-error { margin-top: 16px; }

.tm-fields { display: flex; flex-direction: column; gap: 16px; }
.tm-field { display: flex; flex-direction: column; gap: 6px; }
.tm-modal .tm-label { display: block; margin: 0; font-size: 13px; font-weight: 600; color: var(--ivory); }
.tm-input-wrap { position: relative; }
.tm-modal .tm-input { width: 100%; min-height: 46px; padding: 12px 14px; font-size: 15px; font-variant-ligatures: none; }
.tm-input-wrap .tm-input { padding-right: 50px; }
.tm-modal .tm-input[aria-invalid="true"] { border-color: var(--danger); }
.tm-modal .tm-input:disabled { opacity: .55; }
.tm-eye { position: absolute; top: 0; right: 0; width: 46px; height: 100%; display: grid; place-items: center; margin: 0; padding: 0;
  background: none; border: 0; color: var(--mute); cursor: pointer; transition: color .15s ease; }
.tm-eye:hover { color: var(--ivory); }
.tm-eye:focus-visible { outline: 2px solid var(--turq); outline-offset: -2px; }
.tm-help { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--mute); }
.tm-ferr { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--danger); }
.tm-ferr:empty { display: none; }
.tm-alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: rgba(255,158,138,.10); color: var(--ivory); font-size: 13.5px; line-height: 1.5; }
.tm-alert .ico { flex: none; margin-top: 3px; color: var(--danger); }
.tm-alert p { margin: 0; }

/* Choix du rôle : une ligne par rôle, avec ce qu'il permet. */
.tm-roles { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; padding: 0; border: 0; }
.tm-roles .tm-label { margin-bottom: 6px; padding: 0; }
.tm-modal .tm-opt { display: flex; flex-direction: row; align-items: flex-start; gap: 12px; margin: 0; padding: 12px 14px;
  background: var(--tm-rest); font-size: 14px; font-weight: 400; color: var(--ivory); cursor: pointer; transition: background .15s ease; }
.tm-modal .tm-opt:hover, .tm-modal .tm-opt:has(input:checked) { background: var(--tm-raised); }
.tm-modal .tm-opt:has(input:focus-visible) { outline: 2px solid var(--turq); outline-offset: -2px; }
.tm-modal .tm-opt input[type="radio"]:focus-visible { outline: 0; }
.tm-opt input { margin-top: 1px; }
.tm-opt-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tm-opt-name { font-size: 14px; font-weight: 600; line-height: 20px; color: var(--ivory); }
.tm-opt-sub { font-size: 12.5px; line-height: 1.45; color: var(--mute); }

/* Mot de passe provisoire : gros, net, sélectionnable d'un clic. */
.tm-secret { display: flex; flex-direction: column; gap: 8px; }
.tm-secret-row { display: flex; align-items: stretch; gap: 8px; }
.tm-modal .tm-temp { flex: 1 1 auto; min-width: 0; min-height: 60px; padding: 0 16px; border-color: transparent; background: rgba(246,242,234,.07);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 28px; font-weight: 600; letter-spacing: .06em;
  color: var(--ivory); font-variant-ligatures: none; user-select: all; -webkit-user-select: all; }
.tm-modal .tm-temp:focus { border-color: var(--turq); }
.btn.tm-copy { flex: none; min-width: 132px; gap: 8px; }
.btn.tm-copy.is-done { background: rgba(246,242,234,.09); color: var(--turq); }
.tm-note { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--sand); }
.tm-sr { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tm-sr.show { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; font-size: 12.5px; line-height: 1.45; color: var(--danger); }

.tm-modal .actions { justify-content: flex-end; margin-top: 0; }
.tm-modal .tm-must-actions { justify-content: space-between; }

/* ── Autres écrans : verrous réservés aux administrateurs ───────────────── */

.s-help.s-locked { display: flex; align-items: center; gap: 6px; }
.s-help.s-locked .ico { flex: none; }
.mdl-lock { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--mute); }
.mdl-lock .ico { flex: none; }
.me .me-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me .me-role { font-size: 11px; color: var(--mute); }

/* ── Tablette et téléphone ──────────────────────────────────────────────── */

@media (max-width: 860px) {
  .tm { margin-top: 24px; }
  .tm-add { min-height: 44px; }
  .btn.tm-soft { min-height: 44px; }
  .tm-more { width: 44px; height: 44px; }
  .tm-row { min-height: 68px; }
  .tm-sk-btn { height: 44px; }
  .tm-common .switch::before { content: ""; position: absolute; inset: -10px -6px; }   /* zone tactile de 44 px */
  .tm-link { min-height: 44px; }
  .tm-mi { min-height: 44px; }
  .tm-common { align-items: flex-start; }
  .modal.tm-modal { max-width: none; gap: 14px; }
  .modal.tm-modal.mdl-modal { max-width: none; height: 92dvh; max-height: 92dvh; padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .tm-choice .mdl-list { margin: 0 -16px; padding: 0 16px; }
  .tm-modal .actions .btn { min-height: 44px; }
  .tm-modal .tm-input { min-height: 48px; }
  .tm-eye { width: 48px; }
  .tm-modal .tm-opt { min-height: 60px; }
}
@media (max-width: 560px) {
  .tm-modal .actions .btn { flex: 1 1 0; white-space: normal; }
  .tm-modal .actions .btn.tm-copy { flex: none; }
  .tm-secret-row { flex-direction: column; }
  .btn.tm-copy { min-height: 48px; }
  .tm-modal .tm-temp { font-size: 24px; text-align: center; }
  .tm-modal .tm-must-actions { flex-direction: column-reverse; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-row, .tm-more, .tm-eye, .tm-modal .tm-opt { transition: none; }
}
