/* Panneau établissement — module 4.
   Identité : vert pin (signalétique de résidence) sur papier chaud,
   miel pour l'attention (appels), brique pour le destructif.
   Corps en Atkinson Hyperlegible (lisibilité), titres Bricolage Grotesque,
   données techniques en IBM Plex Mono. */

:root {
  --paper: #F4F3EC;
  --card: #FFFFFF;
  --ink: #212B25;
  --ink-soft: #5A675F;
  --pine: #2E5B4F;
  --pine-dark: #1F4038;
  --sage: #E3EAE2;
  --sage-deep: #C9D6C9;
  --honey: #C08A2A;
  --honey-soft: #F6EBD4;
  --brick: #A64435;
  --brick-soft: #F3E0DC;
  --line: #D9DCD0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(33, 43, 37, .06), 0 4px 14px rgba(33, 43, 37, .05);
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", var(--font-body);
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--pine); }
button { font-family: inherit; font-size: 1rem; cursor: pointer; }
:focus-visible { outline: 3px solid var(--honey); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--font-mono); font-size: .85em; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }

/* ---------- barre supérieure ---------- */

/* trois zones : titre à gauche, menu centré, compte à droite — les deux
   colonnes latérales sont de largeur égale, le menu est donc centré sur
   la fenêtre et non sur l'espace restant */
.topbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "marque sections compte";
  align-items: center; gap: 1.25rem;
  background: var(--pine); color: #F6F4EE;
  padding: 0 1.5rem; height: 60px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand { grid-area: marque; }
.topbar nav { grid-area: sections; }
.topbar-right { grid-area: compte; }
/* le bouton des sections ne sert qu'aux fenêtres étroites (voir plus bas) */
.nav-toggle { display: none; }
.topbar .brand {
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  display: flex; align-items: center; gap: .6rem; white-space: nowrap;
  min-width: 0;  /* la colonne peut se resserrer sans pousser sur le menu */
}
/* fenêtre étroite : le nom de l'établissement s'abrège au lieu de déborder */
.topbar .brand-label { overflow: hidden; text-overflow: ellipsis; }
.brand-plate {
  background: #F6F4EE; color: var(--pine); border-radius: 6px;
  width: 30px; height: 30px; display: grid; place-items: center;
  font-size: 1.05rem; flex: 0 0 auto;
}
/* logo de l'établissement : un bandeau large est admis, la hauteur mène */
.brand-plate.brand-logo {
  width: auto; max-width: 160px; object-fit: contain;
  background: transparent; border-radius: 4px;
}
.topbar nav { display: flex; gap: .25rem; justify-content: center; }
.topbar-right {
  display: flex; align-items: center; gap: 1.25rem; justify-self: end;
}
.topbar nav a {
  color: #E8EFE7; text-decoration: none; padding: .45rem .9rem;
  border-radius: 999px; font-weight: 700; font-size: .95rem;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .12); }
.topbar nav a.active { background: #F6F4EE; color: var(--pine-dark); }
.topbar nav a .pill {
  background: var(--honey); color: #fff; border-radius: 999px;
  font-size: .75rem; padding: 0 .45rem; margin-left: .35rem;
}
.topbar .who { font-size: .875rem; opacity: .9; }

/* bascule disponible / absent (poste d'accueil) */
.avail {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255, 255, 255, .12); border-radius: 999px;
  padding: .25rem .35rem .25rem .85rem; font-size: .875rem;
  border: none; color: inherit;
}
.avail .dot { width: 10px; height: 10px; border-radius: 50%; background: #9AA79E; }
.avail.on .dot { background: #7FD98F; box-shadow: 0 0 0 4px rgba(127, 217, 143, .25); }

.btn-ghost-light {
  background: transparent; border: 1px solid rgba(255, 255, 255, .4);
  color: #F6F4EE; border-radius: 8px; padding: .35rem .8rem;
}
.btn-ghost-light:hover { background: rgba(255, 255, 255, .12); }

/* ---------- avatar et menu profil ---------- */

.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: #F6F4EE; color: var(--pine-dark);
  display: inline-grid; place-items: center;
  font-weight: 700; font-size: .9rem; user-select: none;
}
.avatar.lg { width: 76px; height: 76px; font-size: 1.6rem; }

.profile { position: relative; }
.avatar-btn {
  background: none; border: none; padding: 2px; border-radius: 50%;
  display: grid; place-items: center;
}
.avatar-btn:hover .avatar { box-shadow: 0 0 0 3px rgba(255, 255, 255, .3); }

.profile-menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line);
  min-width: 240px; padding: .35rem; z-index: 60;
}
.profile-menu .menu-id {
  padding: .5rem .65rem .6rem;
  border-bottom: 1px solid var(--line); margin-bottom: .3rem;
}
.menu-sep { border: none; border-top: 1px solid var(--line); margin: .3rem 0; }
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; font-size: .95rem;
  padding: .5rem .65rem; border-radius: 7px; color: inherit;
}
.menu-item:hover { background: var(--sage); }
.menu-item.danger { color: var(--brick); }
.menu-item.danger:hover { background: var(--brick-soft); }

/* ---------- structure ---------- */

main.wrap { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }

/* ---------- page Administration : menu latéral ---------- */

.admin-layout {
  display: grid; grid-template-columns: 210px 1fr;
  gap: 1.4rem; align-items: start;
}
.side-nav { display: flex; flex-direction: column; gap: .25rem; }
.side-nav a {
  padding: .55rem .85rem; border-radius: 8px;
  text-decoration: none; color: var(--ink); font-weight: 700;
}
.side-nav a:hover { background: var(--sage); }
.side-nav a.active { background: var(--pine); color: #F6F4EE; }
/* Le menu passe au-dessus du contenu, en rangée qui se replie. minmax(0, …) :
   sans cela, la rangée de liens imposerait sa largeur minimale à la colonne
   et débordrait la fenêtre au lieu de revenir à la ligne. */
@media (max-width: 760px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
}

.view-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.view-head p { margin: .25rem 0 0; }
.view-head .view-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card { margin-top: 1.25rem; }
.card > h2, .card > h3 { margin-bottom: .9rem; }

/* ---------- formulaires ---------- */

label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-weight: 700; font-size: .875rem; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=datetime-local], input[type=tel], input[type=search], textarea, select {
  width: 100%; padding: .55rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #FDFDFB;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--pine); outline: none; box-shadow: 0 0 0 3px rgba(46, 91, 79, .15); }
.field-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.field-row > * { flex: 1 1 150px; }
input[type=color] {
  width: 100%; height: 40px; padding: .2rem .3rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: #FDFDFB;
}
/* champ adresse de la fiche : saisie libre + recherche BAN + coordonnées */
.field-adresse { margin-bottom: .9rem; }
.field-adresse .field-titre { display: block; font-weight: 700; font-size: .875rem; margin-bottom: .3rem; }
.adresse-champ { display: flex; align-items: flex-start; gap: .5rem; }
.adresse-champ textarea { flex: 1 1 auto; }
.adresse-champ > button { flex: 0 0 auto; white-space: nowrap; }
.coords-etat { color: var(--ink-soft); }
.coords-etat .mono { color: var(--ink); }

/* propositions d'adresses (modale de recherche) */
.ban-liste { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; max-height: 46vh; overflow-y: auto; }
.ban-liste:empty { margin-top: 0; }
.ban-item { display: flex; align-items: center; gap: .3rem; }
.ban-choix {
  flex: 1 1 auto; display: flex; flex-direction: column; gap: .1rem;
  text-align: left; padding: .45rem .6rem; border: 1px solid transparent;
  border-radius: 8px; background: none; color: inherit; font-size: .95rem;
}
.ban-choix:hover, .ban-choix:focus-visible { background: var(--sage); border-color: var(--line); }
.ban-adresse { font-weight: 700; }
.ban-item .btn-picto { text-decoration: none; }

/* champ logo de la fiche établissement : aperçu + actions */
.field-logo { margin-bottom: .9rem; }
.field-logo .field-titre { display: block; font-weight: 700; font-size: .875rem; }
.logo-champ { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo-apercu {
  width: 132px; height: 66px; flex: 0 0 auto; display: grid; place-items: center;
  border: 1px dashed var(--line); border-radius: 10px; background: #FDFDFB;
  overflow: hidden;
}
.logo-apercu img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-apercu .logo-vide {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 700;
  color: var(--line);
}
.logo-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .9rem; padding: .6rem .9rem .8rem; }
legend { font-weight: 700; font-size: .875rem; padding: 0 .3rem; }
.check { display: flex; align-items: center; gap: .5rem; margin: .3rem 0; font-size: .95rem; }
.check input { width: auto; }

/* interrupteur — même hauteur que les champs voisins d'une .field-row */
.switch { display: flex; align-items: center; gap: .55rem; min-height: 40px; font-size: .95rem; }
.switch input {
  appearance: none; flex: none; width: 40px; height: 22px; margin: 0;
  border: none; border-radius: 999px; background: #C7CCC2;
  position: relative; cursor: pointer; transition: background .15s;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .15s;
}
.switch input:checked { background: var(--pine); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { box-shadow: 0 0 0 3px rgba(46, 91, 79, .15); }

.btn {
  background: var(--pine); color: #fff; border: none; border-radius: 8px;
  padding: .55rem 1.1rem; font-weight: 700;
}
.btn:hover { background: var(--pine-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-2 {
  background: var(--sage); color: var(--pine-dark); border: none;
  border-radius: 8px; padding: .55rem 1.1rem; font-weight: 700;
}
.btn-2:hover { background: var(--sage-deep); }
a.btn, a.btn-2 { display: inline-block; text-decoration: none; }
.btn-danger { background: var(--brick); color: #fff; border: none; border-radius: 8px; padding: .55rem 1.1rem; font-weight: 700; }
.btn-danger:hover { filter: brightness(.9); }
.btn-sm { padding: .3rem .7rem; font-size: .875rem; }
.btn-link { background: none; border: none; color: var(--pine); font-weight: 700; padding: .2rem .4rem; text-decoration: underline; }
.btn-link.danger { color: var(--brick); }

/* ---------- page Thème (Administration) ---------- */

.theme-apercu {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; font-weight: 400;
}
.theme-apercu .apercu-topbar {
  display: flex; align-items: center; gap: .6rem;
  background: var(--pine); color: #F6F4EE;
  padding: .55rem .9rem;
  font-family: var(--font-display); font-weight: 700;
}
.theme-apercu .apercu-onglet {
  margin-left: auto; background: #F6F4EE; color: var(--pine-dark);
  border-radius: 999px; padding: .2rem .8rem; font-size: .85rem;
}
.theme-apercu .apercu-corps {
  padding: 1rem; background: var(--paper);
  display: grid; gap: .7rem; font-family: var(--font-body);
}

/* ---------- tableaux ---------- */

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft);
  padding: .5rem .75rem; border-bottom: 2px solid var(--line);
  white-space: nowrap; vertical-align: bottom;
}
table.list td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tbody tr:last-child > td { border-bottom: none; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--sage); }

/* Tri : l'en-tête devient un bouton, la flèche montre le sens en cours. */
.tableau-tri {
  display: inline-flex; align-items: center; gap: .35rem;
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; text-transform: inherit;
  letter-spacing: inherit; text-align: left;
}
.tableau-tri:hover { color: var(--pine); }
.tableau-fleche { font-size: .9em; opacity: .35; line-height: 1; }
.tableau-tri:hover .tableau-fleche { opacity: .7; }
table.list th.trie { color: var(--pine); }
table.list th.trie .tableau-fleche { opacity: 1; }

/* Barre d'outils : recherche plein texte à gauche, filtres, compte à droite. */
.tableau-outils {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .8rem;
}
.tableau-outils input[type=search] {
  width: auto; flex: 1 1 200px; max-width: 320px; padding: .4rem .7rem;
  font-size: .95rem;
}
.tableau-outils select {
  width: auto; flex: 0 0 auto; max-width: 240px; padding: .4rem 1.8rem .4rem .6rem;
  font-size: .9rem;
}
.tableau-reinit { margin-left: .1rem; }
.tableau-compte {
  margin-left: auto; font-size: .85rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
/* Tri par la barre d'outils : il ne paraît qu'en cartes, quand la rangée
   d'en-têtes — et le tri par clic qu'elle porte — a disparu. */
.tableau-tri-mobile { display: none; align-items: center; gap: .3rem; }
.tableau-tri-mobile select { max-width: 11rem; }
.tableau-tri-sens {
  width: 1.9rem; height: 1.9rem; border-color: var(--line);
  background: #FDFDFB;
}
.tableau-tri-sens:disabled { opacity: .45; cursor: default; }
/* Dernier recours : entre la largeur des cartes et celle du bureau, un
   tableau trop large défile plutôt que d'écraser ses colonnes. */
.tableau-defile { overflow-x: auto; }
.tableau .empty-hint { margin-bottom: 0; }

/* colonne d'actions : toujours à droite, jamais coupée */
table.list td.col-actions, table.list th.col-actions {
  text-align: right; white-space: nowrap; width: 1%;
}
.row-actions { display: flex; gap: .6rem; justify-content: flex-end; }

/* actions en picto : le glyphe porte l'action, le libellé vit dans
   title + aria-label — un bouton sans texte reste annoncé et infobullé */
.btn-picto {
  width: 2rem; height: 2rem; flex: none; padding: 0;
  display: grid; place-items: center;
  font-size: 1.05rem; line-height: 1;
  background: none; color: var(--ink);
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.btn-picto:hover { background: var(--sage); border-color: var(--line); }
.btn-picto.danger:hover { background: var(--brick); border-color: var(--brick); }
/* action attendue de la ligne (inviter un proche) : elle se voit sans survol */
.btn-picto.plein { background: var(--sage); border-color: var(--line); }
.btn-picto.plein:hover { background: var(--sage-deep); border-color: var(--sage-deep); }
.btn-picto:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
/* emplacement réservé d'une action indisponible sur cette ligne */
.btn-picto.creux { visibility: hidden; }
/* des pastilles se serrent, des mots soulignés ont besoin d'air */
.row-actions:has(.btn-picto) { gap: .15rem; }

/* ---------- ligne dépliable (établissements → bornes) ---------- */

table.list th.col-plier, table.list td.col-plier { width: 2.4rem; padding-right: 0; }
.plier {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  font-size: 1rem; line-height: 1; padding: .25rem .35rem; border-radius: 6px;
}
.plier:hover { background: var(--sage-deep); color: var(--pine-dark); }
.plier span { display: inline-block; transition: transform .15s ease; }
.plier.ouvert span { transform: rotate(90deg); }
/* la ligne dépliée prolonge la ligne du site : pas de survol, pas de curseur */
table.list tr.depli td { background: var(--paper); padding: .8rem 1rem .9rem 3rem; }

.bornes-resume { margin: 0 0 .5rem; }
ul.bornes-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
ul.bornes-mini li {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
ul.bornes-mini .nom { font-weight: 700; }

.tag {
  display: inline-block; border-radius: 999px; padding: .1rem .6rem;
  font-size: .8rem; font-weight: 700;
}
.tag.green { background: var(--sage); color: var(--pine-dark); }
.tag.honey { background: var(--honey-soft); color: #7A5314; }
.tag.brick { background: var(--brick-soft); color: var(--brick); }
.tag.gray { background: #E9E9E4; color: var(--ink-soft); }

/* ---------- résidents ---------- */

.res-photo {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  background: var(--sage); display: inline-grid; place-items: center;
  font-weight: 700; color: var(--pine-dark); font-family: var(--font-display);
}
.res-photo.lg { width: 76px; height: 76px; font-size: 1.6rem; }

.contact-card {
  display: flex; align-items: center; gap: .9rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .9rem; margin-bottom: .6rem; background: var(--card);
}
.contact-card.dragging { opacity: .4; }
.contact-card.drag-over { border-color: var(--pine); box-shadow: 0 0 0 2px rgba(46, 91, 79, .25); }
.contact-card .pos {
  font-family: var(--font-mono); font-weight: 600; font-size: .8rem;
  background: var(--pine); color: #fff; border-radius: 6px;
  width: 26px; height: 26px; display: grid; place-items: center; flex: none;
}
.contact-card .pos.off { background: #C7CCC2; }
.contact-card .grip { cursor: grab; color: var(--ink-soft); flex: none; user-select: none; }
.contact-card .body { flex: 1; min-width: 0; }
.contact-card .actions { display: flex; gap: .25rem; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- appels : carte signature ---------- */

.call-card {
  display: flex; align-items: center; gap: 1.1rem;
  border: 1px solid var(--honey); background: #FFFDF6;
  border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: .8rem;
  animation: call-in .25s ease-out;
}
@keyframes call-in { from { transform: translateY(-6px); opacity: 0; } }
.call-card.taken { border-color: var(--pine); background: #F7FBF7; animation: none; }

.ring {
  --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--honey) calc(var(--p) * 1%), #EFE6D2 0);
  display: grid; place-items: center; position: relative;
}
.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #FFFDF6; }
.ring .sec { position: relative; font-family: var(--font-mono); font-weight: 600; font-size: 1rem; color: #7A5314; }
.call-card.taken .ring { background: var(--sage); }
.call-card.taken .ring::before { background: #F7FBF7; }
.call-card.taken .ring .sec { color: var(--pine-dark); }

.call-card .body { flex: 1; min-width: 0; }
.call-card .who { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.call-card .actions { display: flex; gap: .5rem; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.queue-empty {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 2.2rem; text-align: center; color: var(--ink-soft);
}

/* ---------- bornes ---------- */

.kiosk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.kiosk-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kiosk-card .head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.state-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-right: .4rem; }
.state-en_ligne .state-dot { background: #4CAF74; }
.state-en_session .state-dot { background: #3D8BD4; }
.state-en_appel .state-dot { background: var(--honey); }
.state-hors_ligne .state-dot { background: #B33A2C; }
.kiosk-card dl { margin: .4rem 0 .8rem; font-size: .875rem; }
.kiosk-card dt { color: var(--ink-soft); float: left; width: 40%; }
.kiosk-card dd { margin: 0 0 .2rem 40%; }
/* les actions se partagent toute la largeur de la carte, sur une ou deux
   rangées selon la place. Même rembourrage pour toutes : sans
   box-sizing: border-box, la base flex se partage le contenu et des paddings
   inégaux donneraient des largeurs inégales. */
.kiosk-card .actions {
  display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap;
}
.kiosk-card .actions > * {
  flex: 1 1 7rem; text-align: center; padding: .3rem .7rem;
}

/* ---------- diffusion ---------- */

/* Texte mis en forme par markdown.js — tout en em pour rester juste dans
   l'aperçu miniature comme à taille normale. */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .7em; }
.md h2, .md h3, .md h4 {
  font-family: var(--font-display); font-size: 1.15em; font-weight: 700;
  margin: .9em 0 .4em;
}
.md ul, .md ol { margin: 0 0 .7em; padding-left: 1.5em; }
.md li { margin-bottom: .25em; }
.md hr { border: none; border-top: 1px solid currentColor; opacity: .25; margin: .9em 0; }
.md code {
  font-family: var(--font-mono); font-size: .9em;
  background: rgba(33, 43, 37, .07); border-radius: 4px; padding: 0 .25em;
}

label.field > span.field-aide {
  font-weight: 400; font-size: .8rem; color: var(--ink-soft);
  margin: .35rem 0 0;
}
.field-inline { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.kiosk-picker {
  border-left: 2px solid var(--sage-deep); padding: .1rem 0 .3rem .7rem;
  margin: 0 0 .5rem;
}
.kiosk-picker .check { gap: .45rem; }
.cibles { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }
.cible { display: inline-flex; align-items: center; gap: .3rem; }

/* Aperçu borne — décalque de l'écran de veille (.veille de borne/css/borne.css) :
   fond vert nuit, horloge, panneau arrondi translucide, invitation en bas.
   Les valeurs reprennent telles quelles les rem de la borne, en em : la règle
   de police ci-dessous est la même que la sienne (100vw / 1080 * 16), à ceci
   près que la largeur de l'aperçu remplace celle de l'écran. */

/* letterbox sombre, comme la borne en mode d'essai (body.cadre) */
.borne-cadre {
  background: #0B120E; border-radius: 16px; padding: .8rem;
  width: fit-content; margin: 0 auto;
}
.borne-preview {
  --largeur: min(320px, 34vh);       /* plafonné en hauteur : la modale ne défile pas */
  --rem: calc(var(--largeur) / 1080 * 16);   /* 1 rem de la borne, à l'échelle */
  width: var(--largeur); aspect-ratio: 9 / 16;
  font-size: var(--rem);
  /* fond de veille de la borne — suit le thème de l'établissement */
  background: var(--borne-nuit, #16261F); color: #FBF8F1; border-radius: 6px;
  box-shadow: 0 0 0 1px #000, 0 12px 40px rgba(0, 0, 0, .55);
  overflow: hidden; display: flex; flex-direction: column;
  align-items: center; text-align: center; padding: 6em 4em; gap: 2em;
}
.borne-preview .bp-heure {
  font-family: var(--font-display); font-size: 11em; font-weight: 700;
  line-height: 1;
}
.borne-preview .bp-date {
  font-size: 2.75em; text-transform: capitalize;
  /* la veille glisse la météo entre la date et le nom ; l'aperçu ne l'affiche
     pas (le panneau n'a pas de bulletin) mais réserve sa place — bloc 6.25rem,
     1.5rem d'air et l'écart de 2rem qu'elle ajoute — pour que le nom y soit
     réduit comme sur la borne. La marge est en rem de la borne : en em, elle
     suivrait la taille de la date. */
  margin-bottom: calc(var(--rem) * 9.75);
}
/* nom de l'établissement, comme sur la veille : la taille de l'horloge quand
   le texte tient, un cran plus bas sinon (DiffusionView._ajusterNom) */
.borne-preview .bp-residence {
  font-family: var(--font-display); font-weight: 700;
  font-size: 11em; line-height: 1.05;
  width: 100%; text-wrap: balance; overflow-wrap: break-word;
}
/* la « pilule » : le panneau d'annonce, seul bloc du message sur la veille.
   Sa police vaut 2 em du cadre, et padding/rayon se mesurent en em de
   l'élément : les rem de la borne y sont donc divisés par deux. */
.borne-preview .bp-panneau {
  background: rgba(255, 255, 255, .08); border-radius: 1em;   /* 2rem borne */
  padding: 1.25em 1.5em; max-width: 30em; font-size: 2em;
  /* coupée comme sur la borne, qui ne défile pas : ce que l'aperçu montre est
     ce que le résident lira, ni plus ni moins (bp-alerte le dit en clair) */
  min-height: 0; overflow: hidden; text-align: left;
}
.borne-preview .bp-titre {
  font-weight: 700; font-size: 1.125em; margin-bottom: .22em;  /* .5rem borne */
}
/* le texte du message occupe la même part d'écran que sur la borne : interligne
   1.4 (le panneau vit à 1.5) et paragraphes à 1.2rem de la borne, soit .6em du
   corps de la pilule. Sans cela l'aperçu réduirait le nom plus que la borne. */
.borne-preview .bp-panneau { line-height: 1.4; }
.borne-preview .md p,
.borne-preview .md ul, .borne-preview .md ol { margin-bottom: .6em; }
.borne-preview .md ul, .borne-preview .md ol { padding-left: 1.3em; }
.borne-preview .md h2, .borne-preview .md h3, .borne-preview .md h4 {
  margin: .8em 0 .4em;
}
.borne-preview .bp-invite {
  margin-top: auto; font-size: 2.75em; font-weight: 700; opacity: .8;
}
/* fond sombre : contraste inversé pour les incrustations du Markdown */
.borne-preview .md code { background: rgba(255, 255, 255, .14); }
.bp-legende { text-align: center; margin-top: .7rem; }
/* message trop long pour l'écran de veille : dit avant la publication, pas
   découvert dans le couloir */
.bp-alerte {
  text-align: center; margin-top: .5rem; font-weight: 700; color: #7A5314;
  background: var(--honey-soft); border-radius: 8px; padding: .45rem .8rem;
}

/* ---------- connexion ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 420px; }
.login-card .brandline { text-align: center; margin-bottom: 1.5rem; }
.login-card .brandline .brand-plate { width: 52px; height: 52px; font-size: 1.9rem; border-radius: 12px; margin: 0 auto .6rem; background: var(--pine); color: #F6F4EE; }
.login-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.login-tabs button {
  flex: 1; border: 1px solid var(--line); background: var(--card);
  padding: .5rem; border-radius: 8px; font-weight: 700; color: var(--ink-soft);
}
.login-tabs button.active { background: var(--pine); border-color: var(--pine); color: #fff; }

/* ---------- modales & toasts ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(33, 43, 37, .45);
  display: grid; place-items: center; z-index: 50; padding: 1.5rem;
}
.modal {
  background: var(--card); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 1.5rem;
}
.modal.wide { max-width: 860px; }

/* formulaire en deux colonnes — repliées l'une sous l'autre si la fenêtre
   ne les tient pas côte à côte */
.form-cols {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 1.5rem; align-items: start;
}
@media (max-width: 760px) { .form-cols { grid-template-columns: 1fr; } }
.form-cols .form-col > :last-child { margin-bottom: 0; }
.field-grand textarea { min-height: 190px; }
.modal h2 { margin-bottom: 1rem; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }

#toast-root { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--ink); color: #F6F4EE; border-radius: 999px;
  padding: .55rem 1.2rem; box-shadow: var(--shadow); font-size: .95rem;
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--brick); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.token-box {
  font-family: var(--font-mono); font-size: .85rem; background: var(--sage);
  border-radius: 8px; padding: .8rem; word-break: break-all; margin: .6rem 0;
}

.empty-hint { color: var(--ink-soft); padding: 1rem 0; }

/* ---- lecteur de badges du poste (badges-poste.js) ---- */

/* fenêtre « à qui est ce badge ? » : photo et nom en tête, comme la fiche */
.badge-lu-tete { display: flex; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.badge-lu-tete h2 { margin: .1rem 0 .2rem; }
.badge-lu-tete p { margin: 0; }

/* fenêtre « Nouveau badge » : ce que dit le lecteur, au-dessus du champ UID */
.lecteur-etat { margin-bottom: 1rem; }
.lecteur-pret, .lecteur-absent, .lecteur-libre, .lecteur-pris {
  margin: 0; padding: .6rem .8rem; border-radius: 8px; font-size: .95rem;
}
.lecteur-pret { background: var(--sage); color: var(--pine-dark); }
.lecteur-absent { background: #EFEFEA; color: var(--ink-soft); }
.lecteur-libre { background: var(--sage); color: var(--pine-dark); font-weight: 700; }
.lecteur-pris { background: var(--honey-soft); color: #7A5314; }

/* ---- avertissement d'appel, sous la bascule Disponible / Absent ----
   Visible depuis toutes les pages sauf la vue Appels, où la file est déjà
   sous les yeux. */

.avail-zone { position: relative; }
.avail-zone .notif-ancre { position: absolute; top: calc(100% + .5rem); right: 0; z-index: 40; }

.notif-appel {
  width: 19rem; padding: .8rem .9rem;
  background: var(--card); border: 1px solid var(--brick);
  border-left: 4px solid var(--brick);
  border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: left;
}
.notif-appel .tete {
  display: flex; align-items: center; gap: .4rem;
  color: var(--brick); font-weight: 700; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .03em;
}
.notif-appel .tete .point {
  width: .5rem; height: .5rem; border-radius: 50%; background: var(--brick);
  animation: sonne-point 1.1s ease-in-out infinite;
}
@keyframes sonne-point { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.notif-appel .qui {
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  margin-top: .25rem;
}
.notif-appel .actions { display: flex; gap: .4rem; margin-top: .7rem; }
.notif-appel .actions .btn { flex: 1; }

/* ---- panneau d'appel du poste (§6.3.3) ----
   Monté hors des vues : le poste garde la file et les fiches sous la main.
   Réduit, il se range en bas à droite sans couper la communication. */

.poste-appel {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 55;
  width: min(46rem, calc(100vw - 3rem));
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.poste-appel .visio-cadre {
  position: relative; aspect-ratio: 4 / 3; background: #1B241F;
}
.poste-appel .visio-scene { position: absolute; inset: 0; }
.poste-appel .visio-vignette {
  position: absolute; right: .8rem; top: .8rem; width: 9rem; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden; background: #10160F;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.poste-appel .visio-vignette:empty { display: none; }

.poste-appel .bandeau {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 1.6rem .9rem .7rem;
  color: #fff; display: flex; flex-direction: column; gap: .1rem;
  background: linear-gradient(to top, rgba(0, 0, 0, .78), transparent);
}
.poste-appel .bandeau .qui { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.poste-appel .bandeau .small { color: rgba(255, 255, 255, .8); }
.poste-appel .bandeau .etat { margin-top: .3rem; font-weight: 700; }
.poste-appel .bandeau .duree { font-family: var(--font-mono); font-size: .95rem; }

.poste-appel .commandes {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .8rem;
}
.poste-appel .commandes .btn-danger { margin-left: auto; }

/* pastilles rondes : le picto porte l'action, le libellé vit dans
   title + aria-label (voir _majRond) */
.poste-appel .commandes .rond {
  width: 2.5rem; height: 2.5rem; flex: none; padding: 0;
  display: grid; place-items: center;
  font-size: 1.35rem; line-height: 1;
  background: var(--sage); color: var(--ink);
  border: 1px solid var(--line); border-radius: 50%;
  cursor: pointer;
}
.poste-appel .commandes .rond:hover { background: var(--sage-deep); }
.poste-appel .commandes .rond:focus-visible {
  outline: 2px solid var(--pine); outline-offset: 2px;
}
/* micro ou caméra coupé : l'écart doit se voir d'un coup d'œil */
.poste-appel .commandes .rond.coupe {
  background: var(--brick); border-color: var(--brick); color: #fff;
}

/* réduit : vignette de veille, seules les commandes essentielles restent */
.poste-appel.reduit { width: 20rem; }
.poste-appel.reduit .visio-cadre { aspect-ratio: 16 / 9; }
.poste-appel.reduit .visio-vignette { display: none; }
/* réduit : la fiche du résident reste à portée, c'est ce qu'on consulte
   justement pendant l'appel */
.poste-appel.reduit .bandeau .small,
.poste-appel.reduit .commandes .rond:not(.reduire):not(.fiche) { display: none; }

/* ---------- fenêtres étroites ----------
   Le panneau reste une application de bureau (§6.3), mais il doit tenir sur
   un portable de couloir ou une tablette tenue en main. Trois paliers :
   1000 px les en-têtes de tableau s'aèrent, 900 px les onglets passent
   derrière un bouton, 760 px les tableaux se lisent en cartes. */

/* Entre les cartes et le bureau, un en-tête qui ne se coupe pas impose sa
   largeur au tableau : on lui rend le droit de revenir à la ligne. */
@media (max-width: 1000px) {
  table.list th { white-space: normal; }
}

/* ---- barre supérieure : les onglets passent derrière un bouton ---- */

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "menu marque compte";
    gap: .75rem; padding: 0 .9rem;
  }
  .nav-toggle {
    grid-area: menu; display: grid; place-items: center;
    width: 2.5rem; height: 2.5rem; padding: 0;
    background: rgba(255, 255, 255, .12); border: none; border-radius: 8px;
    color: inherit;
  }
  .nav-toggle:hover { background: rgba(255, 255, 255, .22); }
  /* trois traits dessinés : le trait central est l'élément, les deux autres
     ses pseudo-éléments — pas d'image à charger */
  .nav-traits, .nav-traits::before, .nav-traits::after {
    display: block; width: 1.15rem; height: 2px; border-radius: 2px;
    background: currentColor;
  }
  .nav-traits { position: relative; }
  .nav-traits::before, .nav-traits::after { content: ""; position: absolute; }
  .nav-traits::before { top: -6px; }
  .nav-traits::after { top: 6px; }

  /* les onglets quittent le gabarit : panneau déroulant sous la barre */
  .topbar nav {
    display: none; position: absolute; top: 100%; left: .6rem; right: .6rem;
    flex-direction: column; gap: .15rem;
    background: var(--card); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .35rem; z-index: 40;
  }
  .topbar.nav-ouvert nav { display: flex; }
  .topbar nav a {
    color: var(--ink); border-radius: 7px; padding: .6rem .7rem;
    font-size: 1rem;
  }
  .topbar nav a:hover { background: var(--sage); }
  .topbar nav a.active { background: var(--pine); color: #F6F4EE; }
  .topbar-right { gap: .75rem; }
}

/* La pastille dit l'essentiel : au plus étroit, le libellé de la bascule
   Disponible / Absent s'efface (il reste dans title et dans l'annonce). */
@media (max-width: 560px) {
  .avail-label { display: none; }
  .avail { padding: .35rem; }
  .avail .dot { width: 12px; height: 12px; }
}

/* ---- corps de page ---- */

@media (max-width: 760px) {
  main.wrap { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1rem; }
  .card + .card { margin-top: 1rem; }
  .modal-backdrop { padding: .8rem; }
  .modal { padding: 1.15rem; }
  /* une carte de borne ne peut pas être plus large que la colonne */
  .kiosk-grid { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
  /* l'avertissement d'appel est ancré à droite : il ne doit pas sortir */
  .notif-appel { width: 19rem; max-width: calc(100vw - 1.8rem); }
  /* carte d'appel et fiche contact : les actions passent sous le texte */
  .call-card, .contact-card { flex-wrap: wrap; }
  .call-card .actions, .contact-card .actions {
    flex: 1 1 100%; justify-content: flex-start;
  }
  .adresse-champ { flex-wrap: wrap; }
}

/* ---- tableaux en cartes ----
   Sous cette largeur, aucune répartition de colonnes ne tient : plutôt
   qu'une barre de défilement horizontale, chaque ligne devient une carte et
   l'intitulé de colonne (data-label, posé par tableau.js) passe devant sa
   valeur. Le tri se fait alors par la barre d'outils. */

@media (max-width: 760px) {
  .tableau-defile { overflow-x: visible; }
  .tableau-tri-mobile { display: inline-flex; }
  .tableau-compte { margin-left: 0; }

  /* :not([hidden]) — le tableau vide et les lignes repliées gardent leur
     droit de disparaître, que « display: block » leur retirerait */
  table.list:not([hidden]), table.list tbody,
  table.list tr:not([hidden]) { display: block; }
  table.list thead { display: none; }
  table.list tbody tr {
    position: relative; margin-bottom: .7rem; padding: .55rem .8rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--card);
  }
  table.list tbody tr:last-child { margin-bottom: 0; }
  table.list td, table.list tbody tr:last-child > td {
    display: flex; align-items: baseline; gap: .8rem;
    padding: .22rem 0; border-bottom: none;
  }
  table.list td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 7rem; font-size: .75rem; line-height: 1.7;
    text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
  }
  /* le survol habille la carte entière, plus la seule cellule */
  table.list tr.click:hover td { background: none; }
  table.list tr.click:hover { background: var(--sage); }
  /* les actions se rangent à gauche, sous les valeurs */
  table.list td.col-actions { width: auto; text-align: left; white-space: normal; }
  .row-actions { justify-content: flex-start; }

  /* ligne dépliable : la flèche se pose dans le coin de la carte, le détail
     se glisse dessous sans reprendre le décalage des colonnes */
  table.list td.col-plier {
    position: absolute; top: .35rem; right: .45rem; width: auto; padding: 0;
  }
  /* la marge négative annule celle de la carte du dessus : le détail lui
     reste collé, comme la ligne dépliée prolonge sa ligne sur un bureau */
  table.list tr.depli {
    margin: -.7rem 0 .7rem; padding: 0;
    border: 1px solid var(--line); border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
  }
  table.list tr.depli td { padding: .7rem .8rem; }
}

@media (max-width: 480px) {
  main.wrap { padding: 1rem .75rem 3rem; }
  table.list td { flex-wrap: wrap; gap: 0 .8rem; }
  table.list td[data-label]::before { flex-basis: 100%; }
}

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

/* progression d'un travail long (site de démonstration, suppression) */
.progression .barre {
  height: 10px; margin: 1rem 0 .7rem; border-radius: 999px; overflow: hidden;
  background: var(--sage);
}
.progression .barre > span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: var(--pine); transition: width .3s;
}
.progression-etape { margin: 0; font-weight: 700; }
.progression-pause { margin: .35rem 0 0; color: var(--brick); }
