/* Adaptations mobile de Presmile (mobile-first, ne touche pas au design system).
   Chargé après bundle.css. Breakpoints alignés sur ceux du bundle :
   < 768px téléphone, < 1024px tablette (tab bar), >= 1024px desktop (sidebar). */

/* Safe areas (iPhone à encoche / barre d'accueil) : viewport-fit=cover est activé */
@media (max-width: 1023.98px) {
  .pm-shell__main { padding-bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom, 0px) + var(--space-8)); }
  .pm-page {
    padding-left: max(var(--space-4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--space-4), env(safe-area-inset-right, 0px));
    min-width: 0;
  }
  .pm-fab { bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom, 0px) + var(--space-4)); right: max(var(--space-4), env(safe-area-inset-right, 0px)); }
  .pm-toasts { bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom, 0px) + var(--space-4)); }
  .pm-shell__main { min-width: 0; }
}
#setupScreen { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }

/* Modales / tiroirs en bottom sheet : le pied ne passe pas sous la barre d'accueil */
@media (max-width: 767.98px) {
  .pm-dialog__foot { padding-bottom: max(var(--space-4), env(safe-area-inset-bottom, 0px)); }
  .pm-dialog__body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
}

/* Tab bar : pastille "il y a du nouveau" sur l'entrée Plus */
.pm-tabbar a { position: relative; -webkit-tap-highlight-color: transparent; }
.pm-tabbar__dot { position: absolute; top: 6px; left: calc(50% + 10px); width: 10px; height: 10px; border-radius: 50%; background: var(--danger-text, #b3261e); border: 2px solid var(--surface-card); }
.pm-tabbar a .pm-ic { width: 22px; height: 22px; }

/* Feuille « Plus » */
.pm-sheet-nav { display: grid; gap: var(--space-1); }
.pm-sheet-nav .pm-nav-item { min-height: 52px; font-size: 16px; }
.pm-sheet-account { display: grid; gap: 2px; padding: var(--space-3) var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-2); }

/* ---------- ResponsiveTable : tableaux -> cartes sous 768px ----------
   Rôles posés sur les <th data-m> puis copiés sur les <td data-role> par le JS
   (enhanceTableRows) : title | aside (montant) | sub | field (libellé: valeur) | status | actions. */
.pm-rt-more { display: none; }
@media (max-width: 767.98px) {
  .pm-rtable-wrap { border: 0; background: none; overflow: visible; border-radius: 0; }
  .pm-rtable, .pm-rtable tbody { display: block; width: 100%; }
  .pm-rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pm-rtable tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start;
    column-gap: var(--space-3); row-gap: var(--space-2);
    background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
    padding: var(--space-4); margin-bottom: var(--space-3);
  }
  .pm-rtable tbody tr:hover { background: var(--surface-card); }
  .pm-rtable tbody tr.is-selected { background: var(--brand-soft); }
  .pm-table__wrap .pm-rtable tr:last-child td { border-bottom: 0; }
  .pm-rtable td {
    display: block; grid-column: 1 / -1; order: 4; min-width: 0; min-height: 0; padding: 0; border: 0;
    text-align: left; overflow-wrap: anywhere; font-size: 14px; line-height: 20px;
  }
  .pm-rtable td[data-role="title"] { grid-column: 1; order: 1; font: 600 16px/22px var(--font-body); }
  .pm-rtable td[data-role="aside"] { grid-column: 2; order: 2; text-align: right; white-space: nowrap; font: 700 16px/22px var(--font-body); font-variant-numeric: tabular-nums; }
  .pm-rtable td[data-role="sub"] { order: 3; color: var(--text-secondary); }
  .pm-rtable td[data-role="field"] { display: flex; justify-content: space-between; gap: var(--space-3); }
  .pm-rtable td[data-role="field"]::before { content: attr(data-label); flex: none; color: var(--text-secondary); font-weight: 500; }
  .pm-rtable td[data-blank] { display: none; }
  .pm-rtable td[data-role="status"] { order: 5; }
  .pm-rtable td[data-role="actions"] { order: 6; padding-top: var(--space-3); margin-top: var(--space-1); border-top: 1px solid var(--border-subtle); }
  .pm-rtable td[data-role="actions"] { display: flex; gap: var(--space-2); }
  .pm-rtable td[data-role="actions"] > .pm-row { flex: 1; min-width: 0; gap: var(--space-2); flex-wrap: nowrap; }
  .pm-rtable td[data-role="actions"] .pm-btn { flex: 1 1 auto; min-width: 0; padding: 0 var(--space-3); white-space: nowrap; }
  .pm-rtable td[data-role="actions"] .pm-btn--icon, .pm-rtable td[data-role="actions"] .pm-rt-more { flex: 0 0 var(--size-touch); }
  .pm-rtable .pm-rt-secondary { display: none; }
  .pm-rt-more { display: inline-flex; }
  .pm-rtable td.empty { grid-column: 1 / -1; order: 1; text-align: center; color: var(--text-secondary); padding: var(--space-6) 0; }
  #rowActionsBody { display: grid; gap: var(--space-2); }
}

/* ---------- Utilitaires de mise en page (remplacent les grilles inline à largeur fixe) ---------- */
/* Liste + panneau latéral : une colonne sous 1024px, panneau à droite au-dessus.
   La largeur du panneau se règle avec --split-side. .pm-split__first le remonte en premier sur mobile. */
.pm-split { display: grid; gap: 24px; align-items: start; grid-template-columns: minmax(0, 1fr); --split-side: 340px; }
.pm-split > * { min-width: 0; }
@media (min-width: 1024px) { .pm-split { grid-template-columns: minmax(0, 1fr) var(--split-side); } }
@media (max-width: 1023.98px) { .pm-split > .pm-split__first { order: -1; } }
/* Champs côte à côte : empilés sous 768px, labels au-dessus */
.pm-cols-2 { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .pm-cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
/* KPI du tableau de bord : 2 colonnes (3 lignes) sur mobile, 3 puis 6 colonnes au-dessus */
.pm-stats { display: grid; gap: var(--space-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1023.98px) { .pm-stats .pm-stat { padding: var(--space-3) var(--space-4); } }
@media (min-width: 768px) { .pm-stats { gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .pm-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* Visible uniquement quand la sidebar est là (le FAB prend le relais sous 1024px) */
@media (max-width: 1023.98px) { .pm-desktop-only { display: none !important; } }

.pm-mobile-only { display: none; }
@media (max-width: 1023.98px) { .pm-mobile-only { display: flex; } }
@media (max-width: 767.98px) { .pm-fill-mobile { width: 100%; } }

/* ---------- Barre d'action collée en bas (récap devis) ----------
   Sous 1024px la carte « Récapitulatif » devient une barre fixe au-dessus de la tab bar :
   total + bouton principal toujours sous le pouce. Les détails (client, lieu…) sont déjà dans le formulaire. */
@media (max-width: 1023.98px) {
  #view-quotes { margin-bottom: 88px; }
  .pm-action-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom, 0px)); z-index: 99; }
  .pm-action-bar > .pm-card {
    display: flex !important; align-items: center; gap: var(--space-4);
    border-radius: 0; border-width: 1px 0 0; box-shadow: 0 -4px 12px rgb(0 0 0 / .08);
    padding: var(--space-3) max(var(--space-4), env(safe-area-inset-right, 0px)) var(--space-3) max(var(--space-4), env(safe-area-inset-left, 0px));
  }
  .pm-action-bar .pm-card__title, .pm-action-bar .pm-kv, .pm-action-bar p, .pm-action-bar .is-sub { display: none; }
  .pm-action-bar .pm-totals { width: auto !important; flex: 1; min-width: 0; }
  .pm-action-bar .is-total { display: grid; justify-items: start; gap: 0; border: 0; padding: 0; margin: 0; white-space: nowrap; }
  .pm-action-bar .is-total > span:first-child { font: 500 13px/16px var(--font-body); color: var(--text-secondary); }
  .pm-action-bar .is-total > span:last-child { font: 700 22px/28px var(--font-body); font-variant-numeric: tabular-nums; }
  .pm-action-bar > .pm-card > div:last-of-type { flex: 1; }
}

/* Ligne de formulaire : 1 colonne (2 dès 768px), toutes les colonnes au-dessus de 1024px */
.pm-form-row { display: grid; gap: var(--space-4); align-items: end; grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1023.98px) { .pm-form-row > * { min-width: 0; } }
@media (min-width: 768px) { .pm-form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .pm-form-row--invoice { grid-template-columns: 2fr 1fr 1fr 1fr auto; } }
/* Texte + action : empilés sous 768px */
.pm-cols-auto { display: grid; gap: 24px; align-items: center; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .pm-cols-auto { grid-template-columns: 1fr auto; } }
/* Les enfants directs d'une page ne doivent pas l'élargir (tableaux, chips défilantes) */
.pm-page > * { min-width: 0; }

/* Sous 1024px : la liste passe avant le formulaire de création (on consulte plus qu'on ne crée) */
@media (max-width: 1023.98px) { .pm-order-last-mobile { order: 10; } }
/* Filtres : à la ligne plutôt que masqués hors écran */
@media (max-width: 767.98px) { .pm-chips { flex-wrap: wrap; overflow: visible; } }

/* ---------- Assistant (chat) ---------- */
.pm-chat-history { max-height: 55dvh; min-height: 30dvh; }
@media (min-width: 768px) { .pm-chat-card { min-height: 620px; } .pm-chat-history { max-height: 520px; } }
.pm-composer { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: end; border-top: 1px solid var(--border-subtle); padding-top: var(--space-4); }
.pm-composer .pm-btn { width: 100%; }
@media (min-width: 768px) { .pm-composer { grid-template-columns: minmax(0, 1fr) auto auto; } .pm-composer .pm-btn { width: auto; } }

/* ---------- Cibles tactiles >= 44px ---------- */
@media (max-width: 767.98px) {
  /* liens-titres des cartes : zone de tap agrandie sans changer la hauteur de la carte */
  .pm-rtable td[data-role="title"] a { display: inline-block; padding: 12px 0; margin: -12px 0; }
  .pm-segments button { min-height: var(--size-touch); }
}
/* Boutons de validation des formulaires : pleine largeur sous le pouce */
@media (max-width: 767.98px) { .pm-btn[id$="SubmitBtn"], .pm-btn[id$="CancelBtn"] { width: 100%; } }

/* ---------- Calendrier : barre de navigation ---------- */
@media (max-width: 767.98px) {
  .pm-cal__bar { grid-template-columns: var(--size-touch) minmax(0, 1fr) var(--size-touch); row-gap: var(--space-2); }
  .pm-cal__bar > .pm-row { display: contents; }
  .pm-cal__bar .pm-btn { padding: 0; min-width: 0; }
  .pm-cal__prev { order: 1; } .pm-cal__bar .pm-cal__title { order: 2; } .pm-cal__next { order: 3; }
  .pm-cal__today { display: none; }
  .pm-btn__label { display: none; }
}

/* ---------- Calendrier mobile : Semaine / Mois ---------- */
#calAgenda { display: none !important; }
.pm-calm { display: none; }
@media (max-width: 1023.98px) { .pm-calm { display: grid; gap: var(--space-3); min-width: 0; } }
.pm-calm .pm-segments { justify-self: stretch; display: grid; grid-template-columns: 1fr 1fr; }

/* bande des jours (Semaine) et grille du mois : mêmes boutons de jour */
.pm-cm__strip { position: sticky; top: 0; z-index: var(--z-sticky); display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px;
  background: var(--surface-card); padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.pm-cm__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.pm-cm__dowh { text-align: center; font: 600 12px/16px var(--font-body); color: var(--text-secondary); padding: 2px 0 4px; }
.pm-cm__day { display: grid; justify-items: center; align-content: start; gap: 2px; min-height: var(--size-touch); padding: 4px 0 6px; border: 0; border-radius: var(--radius-md); background: none; color: var(--text-primary); cursor: pointer; font: 600 16px/24px var(--font-body); -webkit-tap-highlight-color: transparent; }
.pm-cm__dow { font: 600 12px/16px var(--font-body); color: var(--text-secondary); }
.pm-cm__num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font: 600 16px/1 var(--font-body); font-variant-numeric: tabular-nums; }
.pm-cm__day.is-today .pm-cm__num { background: var(--brand-primary); color: #12245C; }
.pm-cm__day.is-selected { background: var(--brand-soft); }
.pm-cm__day.is-selected .pm-cm__num { box-shadow: 0 0 0 2px var(--text-primary); }
.pm-cm__day.is-out { opacity: .4; }
.pm-cm__dots { display: flex; gap: 3px; justify-content: center; min-height: 8px; color: var(--text-primary); }
.pm-cm__dots .pm-cal__dot { width: 6px; height: 6px; }
.pm-cm__dots .pm-cal__dot--ring { width: 7px; height: 7px; border-width: 1.5px; }
.pm-cal__dot--alert { color: var(--danger-text); }

/* détail jour par jour */
.pm-wkdays { display: grid; gap: var(--space-3); }
.pm-wkday { display: grid; gap: var(--space-2); scroll-margin-top: 96px; min-width: 0; }
.pm-wkday__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font: 700 15px/22px var(--font-body); text-transform: capitalize; margin: 0; padding-top: var(--space-2); }
.pm-wkday.is-selected .pm-wkday__head span:first-child { text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--brand-primary); text-underline-offset: 4px; }
.pm-wkday__tag { text-transform: none; font: 600 12px/16px var(--font-body); padding: 2px 8px; border-radius: var(--radius-pill); background: var(--brand-primary); color: #12245C; }
.pm-wkday__empty { margin: 0; font: 400 14px/20px var(--font-body); color: var(--text-secondary); padding: 0 0 var(--space-2); }
.pm-wkev { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); width: 100%; text-align: left; min-height: var(--size-touch);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border: 1px solid var(--border-subtle); border-left: 5px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--surface-card); color: var(--text-primary); cursor: pointer; font: inherit; }
.pm-wkev__main { display: grid; gap: 2px; min-width: 0; }
.pm-wkev__title { font: 600 15px/22px var(--font-body); overflow-wrap: anywhere; }
.pm-wkev__meta { font: 400 14px/20px var(--font-body); color: var(--text-secondary); overflow-wrap: anywhere; }
.pm-wkev .pm-badge { flex: none; }
.pm-wkev--confirmed { border-left-color: var(--brand-primary); background: var(--brand-soft); }
.pm-wkev--potential { border-left-color: var(--warning-border); background: repeating-linear-gradient(135deg, var(--warning-bg) 0 6px, var(--surface-card) 6px 12px); }
.pm-wkev--prospect { border-left-color: var(--border-default); }
.pm-wkev--completed { border-left-color: var(--text-disabled); color: var(--text-secondary); }
.pm-wkev--conflict { border-left-color: var(--danger-border); background: var(--danger-bg); }

/* En-tête compact : la semaine doit être visible sans défiler */
.pm-calm__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; }
@media (min-width: 768px) { .pm-calm__today { display: none; } .pm-calm__head { grid-template-columns: 1fr; } }
@media (max-width: 1023.98px) {
  #view-calendar { gap: var(--space-3); }
  #view-calendar > .pm-page__head { flex-wrap: nowrap; align-items: center; }
  #view-calendar > .pm-page__head p { display: none; }
  #view-calendar > .pm-page__head .title-1 { font-size: 28px; line-height: 34px; }
  #view-calendar > .pm-page__head .pm-btn { min-height: var(--size-touch); padding: 0 var(--space-3); font-size: 14px; white-space: nowrap; }
  #view-calendar .pm-cal { padding-top: var(--space-2); }
  .pm-cal__title { text-transform: none; font-size: 18px; line-height: 24px; }
  .pm-cal__title::first-letter { text-transform: uppercase; }
  .pm-wkday__head { text-transform: none; }
  .pm-wkday__head span:first-child::first-letter { text-transform: uppercase; }
}

/* Horaires d'un événement */
/* Liens vers les factures d'un devis (acompte, solde) dans « Mes devis » */
.pm-doc-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.pm-doc-link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font: inherit; font-size: 14px; color: var(--text-secondary); text-decoration: underline; cursor: pointer; }
.pm-doc-link .pm-ic { width: 16px; height: 16px; }
.pm-cols-2--keep { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }  /* deux heures côte à côte, même sur téléphone */
.pm-wkev__time { font: 700 13px/18px var(--font-body); font-variant-numeric: tabular-nums; color: var(--text-secondary); letter-spacing: .02em; }

/* ---------- Temps réel : retour visuel ---------- */
/* toasts cliquables (demande de devis, facture payée...) */
.pm-toast--rt { width: 100%; text-align: left; cursor: pointer; font: inherit; color: var(--text-primary); }
.pm-toast--rt:focus-visible { outline: 3px solid var(--text-primary); outline-offset: 2px; }
.pm-toast--rt .pm-toast__body { display: grid; gap: 1px; }

/* pastille de non-lus sur l'onglet (mobile) ; la barre latérale réutilise .pm-count */
.pm-tabbar__badge { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: grid; place-items: center; background: var(--brand-primary); color: #12245C; font: 700 11px/1 var(--font-body);
  border: 2px solid var(--surface-card); box-sizing: content-box; }
.pm-tabbar__badge.hidden { display: none; }

/* mise en évidence brève de ce qui vient d'arriver ou de changer */
@keyframes pm-flash { 0%, 35% { background-color: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-primary) inset; } 100% { background-color: transparent; box-shadow: 0 0 0 0 transparent inset; } }
.pm-flash { animation: pm-flash 2.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .pm-flash { animation: none; background-color: var(--brand-soft); } }

/* indicateur discret de connexion coupée */
.pm-rt-status { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%); z-index: var(--z-toast);
  max-width: calc(100vw - 24px); padding: 6px 14px; border-radius: var(--radius-pill); font: 600 13px/18px var(--font-body); text-align: center;
  box-shadow: var(--shadow-md); pointer-events: none; }
.pm-rt-status--warn { background: var(--warning-bg); color: var(--text-primary); border: 1px solid var(--warning-border); }
.pm-rt-status--ok { background: var(--success-bg); color: var(--text-primary); border: 1px solid var(--success-border, var(--border-subtle)); }
.pm-rt-status.hidden { display: none; }

/* sur l'écran Devis, la barre « Créer le devis » occupe le bas : les toasts se posent au-dessus d'elle */
@media (max-width: 1023.98px) { body[data-view="quotes"] .pm-toasts { bottom: calc(var(--size-tabbar) + env(safe-area-inset-bottom, 0px) + var(--space-4) + 76px); } }

/* ---------- Paramètres et conformité ---------- */
.pm-logo-box { width: 160px; height: 90px; display: grid; place-items: center; border: 1px dashed var(--border-default); border-radius: var(--radius-md); background: var(--surface-sunken); overflow: hidden; }
.pm-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pm-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.pm-issue { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); background: var(--surface-card); font: 400 14px/20px var(--font-body); }
.pm-issue--blocking { background: var(--danger-bg); border-color: var(--danger-border); }
.pm-issue--warning { background: var(--warning-bg); border-color: var(--warning-border); }
.pm-issue__msg { min-width: 0; overflow-wrap: anywhere; }
.pm-issue .pm-btn { flex: none; }
.pm-issues-more > summary { cursor: pointer; font: 600 14px/44px var(--font-body); color: var(--text-secondary); }
.pm-issues-more .pm-issues { margin-top: var(--space-2); }
.pm-issue-badge { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; }
.pm-issue-badge--warn { background: var(--warning-bg); border: 1px solid var(--warning-border); }
.pm-issue-badge--ok { background: var(--success-bg); }
.pm-provider { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-card); }
.pm-provider.is-active { border-color: var(--brand-primary); background: var(--brand-soft); }
.pm-provider.is-disabled { opacity: .85; }
@media (max-width: 767.98px) { .pm-issue { flex-direction: column; align-items: stretch; } .pm-issue .pm-btn { width: 100%; } }

/* ---------- Options de ligne et de document ---------- */
.pm-line__opts { grid-column: 1 / -1; }
.pm-line__opts > summary, .pm-more-opts > summary { cursor: pointer; font: 600 13px/44px var(--font-body); color: var(--text-secondary); list-style-position: inside; }
.pm-line__opts-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); padding-bottom: var(--space-2); }
.pm-line__opts .pm-line__label, .pm-line__opts-grid .pm-line__label { display: block; margin-bottom: 4px; }
.pm-more-opts { border-top: 1px solid var(--border-subtle); padding-top: var(--space-1); }

/* ---------- Fiche événement : note interne et rubriques repliables ---------- */
.ev-note { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--warning-bg); border: 1px solid var(--warning-border); }
.ev-note .pm-textarea { background: var(--surface-card); min-height: 72px; }
.ev-note__client { display: grid; gap: 4px; padding-top: 8px; border-top: 1px dashed var(--border-subtle); white-space: normal; font-size: 14px; }
.ev-sec { border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--surface-card); }
.ev-sec > summary { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; padding: 12px 40px 12px 14px; min-height: 48px; cursor: pointer; list-style: none; position: relative; }
.ev-sec > summary::-webkit-details-marker { display: none; }
.ev-sec > summary::after { content: ""; position: absolute; right: 16px; top: 20px; width: 8px; height: 8px; border-right: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); transform: rotate(45deg); transition: transform .15s; }
.ev-sec[open] > summary::after { transform: rotate(-135deg); top: 24px; }
.ev-sec > summary:hover { background: var(--surface-sunken); border-radius: 12px; }
.ev-sec__title { font-weight: 600; }
.ev-sec__meta { font-size: 13px; color: var(--text-secondary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ev-sec__meta[data-tone="muted"] { opacity: .7; font-style: italic; }
.ev-sec__meta[data-tone="ok"] { color: var(--success-text); }
.ev-sec__body { display: grid; gap: 10px; padding: 4px 14px 14px; }
.ev-sec.hidden { display: none; }
/* Bouton Enregistrer toujours à portée de main sur ordinateur, même fiche longue */
@media (min-width: 1024px) { .ev-savebar { flex-wrap: nowrap; position: sticky; bottom: 0; z-index: 2; background: var(--surface-card); padding: 12px 0; margin-bottom: -12px; border-top: 1px solid var(--border-subtle); } }

/* ---- Garde-fous de mise en page (toutes largeurs) ----
   Rien ne doit élargir son conteneur au-delà de l'écran ou de la carte : un champ date (largeur native du navigateur),
   un bouton au libellé long, un nom ou un email sans espace. Les grilles prennent la largeur disponible (minmax(0, 1fr))
   au lieu de celle de leur contenu, et un libellé de bouton trop long passe à la ligne au lieu de déborder. */
body { overflow-wrap: break-word; }
.pm-field, .ev-sec__body { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.pm-field > *, .ev-sec__body > * { min-width: 0; }
.pm-input, .pm-select, .pm-textarea, .pm-select-wrap { min-width: 0; max-width: 100%; }
.pm-btn { max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; padding-top: 6px; padding-bottom: 6px; }
.pm-badge { max-width: 100%; white-space: normal; line-height: 1.2; padding-top: 4px; padding-bottom: 4px; }
