/* =============================================================================
   The Circle Samui — Back-office — Design system
   -----------------------------------------------------------------------------
   Sobre, premium, cohérent avec une agence immobilière haut de gamme.
   Neutres chauds + accent terracotta (#C0754C) = charte officielle The Circle Samui.
   (La variable reste nommée --lagon pour ne pas toucher ses ~37 références.)
   Titres en serif légère (Fraunces) ; UI en Hanken Grotesk / système.

   Tout composant utilisé par les 7 écrans est défini ICI. Les vues ne doivent
   AJOUTER AUCUN CSS — elles assemblent ces classes.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Tokens
   ----------------------------------------------------------------------------- */
:root {
  /* Encre / texte */
  --ink:        #1a1d1c;
  --ink-soft:   #3a4340;
  --ink-mute:   #6b7470;
  --ink-faint:  #9aa19d;

  /* Surfaces (neutres chauds) */
  --paper:      #ffffff;
  --paper-2:    #f7f6f3;   /* fond d'app */
  --paper-3:    #fbfaf8;   /* cartes alternées */
  --line:       #e6e4de;
  --line-soft:  #efedE8;

  /* Accent terracotta — charte officielle (nom --lagon conservé, cf. en-tête) */
  --lagon:      #C0754C;   /* terracotta — accent principal */
  --lagon-deep: #9F5C37;   /* terracotta foncé (hover/textes) */
  --lagon-soft: #EBD8C8;   /* terracotta clair (fonds doux) */
  --lagon-tint: #F7EFE8;   /* crème très clair (fonds subtils) */

  /* Statuts / sémantique */
  --success:      #1f7a4d;
  --success-soft: #e4f1e9;
  --info:         #2b5a8a;
  --info-soft:    #e6eef6;
  --warn:         #9a6b1e;
  --warn-soft:    #f6eedd;
  --danger:       #9a3a2e;
  --danger-soft:  #f6e4e1;
  --muted:        #6b7470;
  --muted-soft:   #ecebE6;

  /* Typo */
  --font-ui:    "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;

  /* Rayons */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Ombres */
  --sh-sm: 0 1px 2px rgba(20,25,24,.06);
  --sh:    0 2px 8px rgba(20,25,24,.07), 0 1px 2px rgba(20,25,24,.05);
  --sh-lg: 0 12px 40px rgba(20,25,24,.14), 0 4px 12px rgba(20,25,24,.08);

  /* Espacements */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Layout */
  --nav-w: 248px;
  --maxw:  1240px;

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* -----------------------------------------------------------------------------
   2. Reset
   ----------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 500; line-height: 1.2; letter-spacing: -.01em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* -----------------------------------------------------------------------------
   3. Layout : nav latérale + zone principale
   ----------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }

.app-nav {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-4);
  background: var(--paper);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-2) var(--sp-2); }
.brand__logo { height: 34px; width: auto; display: block; flex: 0 0 auto; }
.brand__name { display: flex; flex-direction: column; line-height: 1.2; }
.brand__name strong { font-family: var(--font-serif); font-weight: 500; font-size: 1.05rem; }
.brand__sub { font-size: .72rem; color: var(--ink-mute); letter-spacing: .02em; }

.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: block; padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-sm); color: var(--ink-soft); font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link:hover { background: var(--paper-2); color: var(--ink); }
.nav-link.is-active { background: var(--lagon-soft); color: var(--lagon-deep); }

.nav-foot { display: flex; flex-direction: column; gap: var(--sp-3); border-top: 1px solid var(--line); padding-top: var(--sp-4); }
.nav-user { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.nav-user__avatar {
  display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: var(--r-pill); background: var(--lagon-soft); color: var(--lagon-deep);
  font-weight: 600; font-size: .85rem;
}
.nav-user__email { font-size: .82rem; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-main { min-width: 0; }
.view { max-width: var(--maxw); margin: 0 auto; padding: var(--sp-6) var(--sp-6); }

/* En-tête de page (titre + actions) — utilisable par les vues. */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4);
  margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.page-head__titles { display: flex; flex-direction: column; gap: var(--sp-1); }
.page-title { font-size: 1.7rem; }
.page-subtitle { color: var(--ink-mute); font-size: .92rem; }
.page-head__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: var(--sp-2); font-size: .82rem; color: var(--ink-mute); margin-bottom: var(--sp-3); }
.breadcrumb a:hover { color: var(--lagon); }
.breadcrumb__sep { color: var(--ink-faint); }

/* -----------------------------------------------------------------------------
   4. Boutons
   ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 9px 16px; border-radius: var(--r-sm);
  font-weight: 600; font-size: .9rem; line-height: 1.2;
  border: 1px solid transparent; background: var(--paper); color: var(--ink);
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--lagon); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--lagon); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--lagon-deep); }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn--ghost:hover:not(:disabled) { background: var(--paper-2); border-color: var(--ink-faint); color: var(--ink); }

.btn--danger { background: var(--paper); border-color: var(--danger); color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn--sm { padding: 5px 11px; font-size: .82rem; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; aspect-ratio: 1; }

/* -----------------------------------------------------------------------------
   5. Cartes & sections
   ----------------------------------------------------------------------------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card__head { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.card__title { font-size: 1.1rem; }
.card__body { padding: var(--sp-5); }
.card + .card { margin-top: var(--sp-4); }

/* -----------------------------------------------------------------------------
   6. Formulaires
   ----------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field > label, .field__label {
  font-size: .82rem; font-weight: 600; color: var(--ink-soft); letter-spacing: .01em;
}
.field__hint { font-size: .78rem; color: var(--ink-mute); }
.field__req { color: var(--danger); margin-left: 2px; }
.field__badge { font-size: .68rem; font-weight: 600; color: var(--ink-faint); }

.input, .select, .textarea,
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-faint); }
.input:focus, .select:focus, .textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--lagon); box-shadow: 0 0 0 3px var(--lagon-soft);
}
.textarea, .field textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
select.select, .field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7470' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* Champ invalide. */
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--danger); }
.field--invalid input:focus, .field--invalid select:focus, .field--invalid textarea:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.field__error { font-size: .78rem; color: var(--danger); font-weight: 500; }

/* Cases à cocher / interrupteurs alignés. */
.field--check { flex-direction: row; align-items: center; gap: var(--sp-2); }
.field--check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--lagon); flex: 0 0 auto; }
.field--check label { font-weight: 500; color: var(--ink); }

/* Groupe i18n FR/EN (deux sous-champs côte à côte). */
.i18n-group { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.i18n-group .field__lang { font-size: .7rem; font-weight: 700; color: var(--lagon); text-transform: uppercase; letter-spacing: .04em; }

/* Grille de formulaire + sections titrées. */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 var(--sp-5); }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }

.form-section { margin-bottom: var(--sp-6); }
.form-section__head { margin-bottom: var(--sp-4); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line-soft); }
.form-section__title { font-size: 1.15rem; }
.form-section__desc { font-size: .85rem; color: var(--ink-mute); margin-top: 2px; }

/* Barre d'actions collante (sauvegarde / annulation) en bas d'un formulaire. */
.form-actions {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  margin-top: var(--sp-5); padding: var(--sp-4) 0;
  background: linear-gradient(to top, var(--paper-2) 70%, transparent);
}
/* Variante non collante : barres d'actions à l'intérieur d'une modale / carte. */
.form-actions--static { position: static; margin-top: 0; padding: 0; background: none; }
.form-actions__status { margin-right: auto; font-size: .85rem; color: var(--ink-mute); }
.form-actions__status.is-dirty { color: var(--warn); }
.form-actions__status.is-saved { color: var(--success); }

/* Bloc de champs conditionnel (affiché/masqué selon un select ou une case).
   Le masquage repose sur l'attribut [hidden] (déjà géré globalement). */
.form-cond { margin-top: var(--sp-2); }

/* Champ interne 🔒 : teinte discrète + liseré gauche pour le distinguer d'un
   champ public (cf. _CONTRAT.md §6). S'applique au .field porteur. */
.field--internal {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  background: var(--lagon-tint);
  border-left: 3px solid var(--lagon-soft);
  border-radius: var(--r-sm);
}
.field--internal.field--check { padding: var(--sp-2) var(--sp-3); }

/* Grille de cases à cocher (équipements, options multi-sélection). */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-2) var(--sp-4);
  margin-top: 6px;
}
.check-grid .field--check { margin-bottom: 0; }

/* Pile de lignes d'options (sous-éditeur villa_options). */
.opt-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.opt-list .card { margin: 0; }

/* -----------------------------------------------------------------------------
   7. Tableaux
   ----------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--sh-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table thead th {
  text-align: left; padding: 12px var(--sp-4);
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-mute); background: var(--paper-3); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td { padding: 12px var(--sp-4); border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--ink-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--paper-3); }
.table tbody tr.is-clickable { cursor: pointer; }
.table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .td-actions { text-align: right; white-space: nowrap; }
.table .td-actions .btn { margin-left: var(--sp-1); }
.table .td-strong { font-weight: 600; color: var(--ink); }
.table .td-mute { color: var(--ink-mute); }

/* -----------------------------------------------------------------------------
   8. Badges de statut
   ----------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .74rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--info    { background: var(--info-soft);    color: var(--info); }
.badge--warn    { background: var(--warn-soft);    color: var(--warn); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--muted   { background: var(--muted-soft);   color: var(--muted); }
.badge--plain::before { display: none; }

/* Petites étiquettes neutres (ex. "Brouillon", "Publié"). */
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); font-size: .72rem; font-weight: 600; background: var(--paper-2); color: var(--ink-mute); border: 1px solid var(--line); }
.tag--lagon { background: var(--lagon-soft); color: var(--lagon-deep); border-color: transparent; }

/* -----------------------------------------------------------------------------
   9. Onglets
   ----------------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); overflow-x: auto; }
.tab {
  padding: 10px var(--sp-4); font-weight: 600; font-size: .9rem; color: var(--ink-mute);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--lagon-deep); border-bottom-color: var(--lagon); }
.tab__count { margin-left: 6px; font-size: .72rem; color: var(--ink-faint); }

/* -----------------------------------------------------------------------------
   10. Barre d'outils + recherche
   ----------------------------------------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.toolbar__spacer { flex: 1; }
.search { position: relative; flex: 0 1 320px; }
.search input { padding-left: 36px; }
.search__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.filter-select { flex: 0 0 auto; min-width: 160px; }

/* Pagination. */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); margin-top: var(--sp-5); }
.pagination__info { font-size: .85rem; color: var(--ink-mute); }

/* -----------------------------------------------------------------------------
   11. Modale (réutilisée par confirmDialog et les vues)
   ----------------------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: var(--sp-4);
  background: rgba(20,25,24,.42);
  opacity: 0; visibility: hidden;
  transition: opacity .2s var(--ease), visibility .2s var(--ease);
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal__dialog {
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto;
  background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  transform: translateY(8px) scale(.98); transition: transform .2s var(--ease);
}
.modal.is-open .modal__dialog { transform: none; }
.modal__dialog--lg { max-width: 760px; }
.modal__dialog--xl { max-width: 1040px; }
.modal__head { padding: var(--sp-5) var(--sp-5) var(--sp-3); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.modal__title { font-size: 1.25rem; }
.modal__close { font-size: 1.4rem; line-height: 1; color: var(--ink-mute); padding: 4px 8px; border-radius: var(--r-sm); }
.modal__close:hover { background: var(--paper-2); color: var(--ink); }
.modal__body { padding: 0 var(--sp-5) var(--sp-5); color: var(--ink-soft); }
.modal__foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: var(--sp-3); }

/* -----------------------------------------------------------------------------
   12. Toasts
   ----------------------------------------------------------------------------- */
.toast-slot {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 1100;
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 280px; max-width: 420px; padding: 12px var(--sp-3) 12px var(--sp-4);
  background: var(--ink); color: #fff; border-radius: var(--r);
  box-shadow: var(--sh-lg); pointer-events: auto;
  opacity: 0; transform: translateY(10px); transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(10px); }
.toast__icon { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; font-size: .8rem; font-weight: 700; background: rgba(255,255,255,.16); }
.toast__msg { flex: 1; font-size: .9rem; line-height: 1.4; }
.toast__close { color: rgba(255,255,255,.7); font-size: 1.2rem; line-height: 1; padding: 0 4px; }
.toast__close:hover { color: #fff; }
.toast--success { background: #143b2b; }
.toast--success .toast__icon { background: rgba(120,220,160,.28); }
.toast--error { background: #4a1a14; }
.toast--error .toast__icon { background: rgba(240,150,130,.3); }
.toast--warn { background: #45350f; }
.toast--info { background: var(--ink); }

/* -----------------------------------------------------------------------------
   13. États vides / chargement / erreur
   ----------------------------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-3); padding: var(--sp-7) var(--sp-5);
  color: var(--ink-mute);
}
.empty__icon {
  display: grid; place-items: center; width: 56px; height: 56px;
  border-radius: var(--r-pill); background: var(--paper-2); color: var(--ink-faint);
  font-size: 1.5rem; font-family: var(--font-serif);
}
.empty__title { font-family: var(--font-serif); font-size: 1.2rem; color: var(--ink); }
.empty__msg { max-width: 420px; font-size: .92rem; }
.empty--error .empty__icon { background: var(--danger-soft); color: var(--danger); font-weight: 700; }

.loading { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-7); color: var(--ink-mute); }
.loading__label { font-size: .92rem; }
.spinner {
  width: 20px; height: 20px; flex: 0 0 20px;
  border: 2px solid var(--line); border-top-color: var(--lagon);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton (placeholder de ligne en chargement, facultatif pour les vues). */
.skeleton { background: linear-gradient(90deg, var(--line-soft) 25%, var(--paper-2) 37%, var(--line-soft) 63%); background-size: 400% 100%; border-radius: var(--r-sm); animation: shimmer 1.4s ease infinite; height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* -----------------------------------------------------------------------------
   14. Dropzone + vignettes (médias / documents)
   ----------------------------------------------------------------------------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-6); text-align: center;
  border: 2px dashed var(--line); border-radius: var(--r-lg); background: var(--paper-3);
  color: var(--ink-mute); cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.dropzone:hover { border-color: var(--lagon); color: var(--ink-soft); }
.dropzone.is-dragover { border-color: var(--lagon); background: var(--lagon-tint); color: var(--lagon-deep); }
.dropzone__icon { font-size: 1.6rem; }
.dropzone__hint { font-size: .82rem; color: var(--ink-faint); }
.dropzone input[type="file"] { display: none; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.thumb {
  position: relative; border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; background: var(--paper-2);
}
.thumb__img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-2); }
.thumb__file { display: grid; place-items: center; aspect-ratio: 4 / 3; color: var(--ink-faint); font-size: 1.8rem; }
.thumb__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 6px 8px; background: var(--paper); border-top: 1px solid var(--line-soft); }
.thumb__name { font-size: .76rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb__actions { display: flex; gap: 4px; flex: 0 0 auto; }
.thumb__badge { position: absolute; top: 6px; left: 6px; }
.thumb__handle { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; display: grid; place-items: center; background: rgba(255,255,255,.9); border-radius: var(--r-sm); color: var(--ink-mute); cursor: grab; font-size: .85rem; }
.thumb.is-uploading { opacity: .6; }
.thumb__progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--lagon); transition: width .2s var(--ease); }

/* -----------------------------------------------------------------------------
   15. Divers utilitaires (utilisables par les vues, mais sans en abuser)
   ----------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--ink-mute); }
.small { font-size: .85rem; }
.mono { font-variant-numeric: tabular-nums; }
.lock-hint { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; color: var(--ink-faint); }

/* Bandeau d'information (rappels : champ interne 🔒, etc.). */
.note { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r); background: var(--lagon-tint); border: 1px solid var(--lagon-soft); color: var(--lagon-deep); font-size: .85rem; }
.note--warn { background: var(--warn-soft); border-color: #ecdcb6; color: var(--warn); }
.note--danger { background: var(--danger-soft); border-color: #eccac4; color: var(--danger); }

/* Liste de définition clé/valeur (détail d'un lead, d'une candidature…).
   Partagée par leads.js et submissions.js. */
.def-list { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.def-list dt, .def-row__key { font-size: .78rem; font-weight: 600; color: var(--ink-mute); }
.def-list dd { margin: 0; font-size: .9rem; color: var(--ink); word-break: break-word; overflow-wrap: anywhere; }
.def-list dd.def-list__pre, .def-row__val--pre { white-space: pre-wrap; }
/* Variante en lignes empilées (libellé + valeur sur deux colonnes souples). */
.def-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); }
.def-row__key { min-width: 120px; flex: 0 0 auto; }
.def-row__val { font-size: .85rem; color: var(--ink); word-break: break-word; }
.def-empty { color: var(--ink-faint); font-style: italic; }

/* Bloc JSON / texte brut (payload non structuré, données non fiables). */
.raw {
  margin: 0; padding: var(--sp-3) var(--sp-4);
  background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  font-size: .82rem; line-height: 1.5; white-space: pre-wrap;
  word-break: break-word; overflow-wrap: anywhere; color: var(--ink-soft);
  max-height: 260px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Pastille « non lu » (leads nouveaux). */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lagon); margin-right: var(--sp-2); vertical-align: middle; flex: 0 0 auto; }

/* Méta inline (reçu le, source, villa…) au-dessus d'un détail. */
.meta-inline { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-4); font-size: .82rem; color: var(--ink-mute); }
.meta-inline strong { color: var(--ink); font-weight: 600; }
.section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-mute); margin: var(--sp-5) 0 var(--sp-3); }

/* Pied d'upload (fichier sélectionné + bouton) — écran Documents/Médias. */
.upload-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-3); }
.upload-name { word-break: break-word; }
.upload-name .spinner { margin-right: 6px; }
.upload-status { margin-top: var(--sp-2); min-height: 1.2em; }
.upload-status .spinner { margin-right: 6px; }
/* Double nom (libellé + nom de fichier réel) en cellule de tableau. */
.file-name { display: block; font-weight: 600; color: var(--ink); word-break: break-word; }
.file-subname { display: block; margin-top: 2px; word-break: break-word; }
/* Dropzone désactivée pendant un envoi. */
.dropzone.is-disabled { opacity: .6; pointer-events: none; }

/* -----------------------------------------------------------------------------
   16. Écran de connexion
   ----------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-5); background: radial-gradient(120% 100% at 50% 0%, var(--lagon-tint), var(--paper-2)); }
.login__card { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-lg); padding: var(--sp-6); }
.login__brand { text-align: center; margin-bottom: var(--sp-5); }
.login__logo { display: block; width: auto; max-width: 220px; max-height: 104px; margin: 0 auto var(--sp-3); }
.login__sub { color: var(--ink-mute); font-size: .9rem; margin-top: 2px; }
.login__form { display: flex; flex-direction: column; gap: var(--sp-2); }
.login__form .field { margin-bottom: var(--sp-2); }
.login__error { padding: 10px var(--sp-3); border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-size: .85rem; font-weight: 500; }
.login__hint { text-align: center; font-size: .8rem; color: var(--ink-faint); margin-top: var(--sp-4); }

/* -----------------------------------------------------------------------------
   17. Responsive : tablette / mobile — la nav passe en barre horizontale,
       les grilles repassent en une colonne.
   ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .app-nav {
    position: sticky; top: 0; height: auto; z-index: 50;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0; }
  .nav-list { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; gap: 2px; }
  .nav-link { padding: 8px 12px; }
  .nav-foot { flex-direction: row; align-items: center; border-top: none; padding-top: 0; margin-left: auto; }
  .nav-foot .btn--block { width: auto; }
  .nav-user__email { max-width: 140px; }
  .view { padding: var(--sp-5) var(--sp-4); }

  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-full { grid-column: auto; }
  .i18n-group { grid-template-columns: 1fr; }

  .toast-slot { left: var(--sp-4); right: var(--sp-4); align-items: stretch; }
  .toast { min-width: 0; max-width: none; }
}

@media (max-width: 560px) {
  .page-head { flex-direction: column; }
  .page-head__actions { width: 100%; }
  .search { flex-basis: 100%; }
}

/* -----------------------------------------------------------------------------
   18. QR codes (écran #/qr — Module 4)
       Grille de cartes : une par villa. Réutilise les tokens du design system.
   ----------------------------------------------------------------------------- */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}

.qr-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}

.qr-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
}
.qr-card__name {
  font-size: 1.05rem;
  line-height: 1.2;
  margin: 0;
}

/* Visuel QR : carré blanc, centré. Le SVG interne est mis à l'échelle au conteneur. */
.qr-card__svg {
  align-self: center;
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2);
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.qr-card__svg svg { display: block; width: 100%; height: auto; }
.qr-card__novalue { color: var(--ink-faint); font-size: .85rem; }

.qr-card__linkrow {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.qr-card__link {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .8rem;
  color: var(--lagon-deep);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qr-card__link--empty { color: var(--ink-mute); }

.qr-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.qr-card__actions .btn { flex: 1 1 auto; }

.qr-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line-soft);
}
.qr-card__scans { font-size: .85rem; color: var(--ink-mute); }
.qr-card__scans strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Champ hors écran (repli de copie sans Clipboard API). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
